REmnant KeInitializeSpin and Co. unresolved/already defined errors

This sounds like the old issue. Well, it still remains as very
possible issue with the latest W7 WDK.
If one file includes wdm.h and the other includes ntddk.h or ntifs.h
or FltKernel.h and the code uses KeInitializeSpinLock, there will be
linker errors on both x86.
The problem is with WDM_INCLUDED define. It’s defined when WDM.h was
included without ntddk.h or other two before it. The function is forced
non-inline on x86 if ntddk/ntifs/FltKernel are used but is used as
export if wdm is used.
OK, not many will include different header files, but it’s a bug
nonetheless. And it just made me rewrite a C++ library that only used
wdm.h because it gave out linker errors :slight_smile:

FYI for everyone, and I hope MS changes this to the same state
regardless of which header in included (I don’t see a reason why it
would not be inline everywhere, can there possibly be anything more the
Ntoskrnl version does for a spin lock apart from tracking?)


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…
>
> This sounds like the old issue. Well, it still remains as very
> possible issue with the latest W7 WDK.
> If one file includes wdm.h and the other includes ntddk.h or ntifs.h
> or FltKernel.h and the code uses KeInitializeSpinLock, there will be
> linker errors on both x86.
> The problem is with WDM_INCLUDED define. It’s defined when WDM.h was
> included without ntddk.h or other two before it. The function is forced
> non-inline on x86 if ntddk/ntifs/FltKernel are used but is used as
> export if wdm is used.
> OK, not many will include different header files, but it’s a bug
> nonetheless. And it just made me rewrite a C++ library that only used
> wdm.h because it gave out linker errors :slight_smile:

AFAIK wdm.h should not be included directly for NT platform.
Just use ntddk.h or fltkernel.h always, and forget wdm.h.

However if you want to be compatible with win2k, there are some other
compatibility #defines that can affect libraries.
Maybe all libraries must be recompiled for specific kernel version to be
safe.

Regards,
–pa

> FYI for everyone, and I hope MS changes this to the same state
> regardless of which header in included (I don’t see a reason why it
> would not be inline everywhere, can there possibly be anything more the
> Ntoskrnl version does for a spin lock apart from tracking?)
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
>
>

> AFAIK wdm.h should not be included directly for NT platform. Just use ntddk.h or fltkernel.h always, and forget

wdm.h.

Docs suggest wdm.h (as does the name for some). I don’t remember why my library has wdm.h included though.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…
>> AFAIK wdm.h should not be included directly for NT platform. Just use
>> ntddk.h or fltkernel.h always, and forget
>> wdm.h.
>
> Docs suggest wdm.h (as does the name for some). I don’t remember
> why my library has wdm.h included though.

Most of sample drivers in the wdk use ntddk.h. Some still use wdm.h however.

–pa

>

“Dejan Maksimovic” wrote in message
news:xxxxx@ntdev…
> >> AFAIK wdm.h should not be included directly for NT platform. Just
use
> >> ntddk.h or fltkernel.h always, and forget
> >> wdm.h.
> >
> > Docs suggest wdm.h (as does the name for some). I don’t
remember
> > why my library has wdm.h included though.
>
> Most of sample drivers in the wdk use ntddk.h. Some still use wdm.h
however.
>
> --pa
>

The docs I’m looking at
(http://msdn.microsoft.com/en-us/library/ff552160.aspx) say for
KeInitializeSpinLock “Header:
Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)”, so it seems that including
wdm.h directly is still correct.

James

Yep. One more bug for bug bash :slight_smile:

James Harper wrote:

The docs I’m looking at
(http://msdn.microsoft.com/en-us/library/ff552160.aspx) say for
KeInitializeSpinLock “Header:
Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)”, so it seems that including
wdm.h directly is still correct.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.