x64 Build

I’m not a very experienced driver developer, and I’m trying to get my driver
to compile for x64. I have WS2003 SP1 DDK installed and set up. I can get
the x86 build environment going and it builds the driver just fine. But
when I use the AMD64 environment, I get linker errors about unresolved
externals:

KeQuerySystemTime
KeInitializeSpinLock
KeGetCurrentThread
KeLowerIrql
KfRaiseIrql

I was able to fix the KeGetCurrentThread because it seems on x64 only
PsGetCurrentThread is exported, and not KeGetCurrentThread, but the headers
#define PsGetCurrentThread to KeGetCurrentThread, so I just #undef’ed it.

However, I’m looking at KeInitializeSpinLock. On x86 this is exported by
ntoskrnl.dll (use ntoskrnl.lib). On x64, it doesn’t seem to be exported by
any of the libs. I even grabbed the actual dll off of my x64 machine, and
it doesn’t even export it at all!? Am I missing something here? I finally
did find it in ddk_ext.lib, but that’s for building a debug driver that
checks that function calls are done correctly.

What should I be linking against, or what do I need to define so that the
headers define the correct functions???

KeGetCurrentThread appears to be available and valid in all three processor
types. Are you compiling with the AMD 64 environment for NET? You have not
specified how you ‘get the x86 build environment going’. Use the build
environments in the start menu with a sources file and use ‘build -ceZ’.

“Cody Cutrer” wrote in message news:xxxxx@ntdev…
> I’m not a very experienced driver developer, and I’m trying to get my
> driver to compile for x64. I have WS2003 SP1 DDK installed and set up. I
> can get the x86 build environment going and it builds the driver just
> fine. But when I use the AMD64 environment, I get linker errors about
> unresolved externals:
>
> KeQuerySystemTime
> KeInitializeSpinLock
> KeGetCurrentThread
> KeLowerIrql
> KfRaiseIrql
>
> I was able to fix the KeGetCurrentThread because it seems on x64 only
> PsGetCurrentThread is exported, and not KeGetCurrentThread, but the
> headers #define PsGetCurrentThread to KeGetCurrentThread, so I just
> #undef’ed it.
>
> However, I’m looking at KeInitializeSpinLock. On x86 this is exported by
> ntoskrnl.dll (use ntoskrnl.lib). On x64, it doesn’t seem to be exported
> by any of the libs. I even grabbed the actual dll off of my x64 machine,
> and it doesn’t even export it at all!? Am I missing something here? I
> finally did find it in ddk_ext.lib, but that’s for building a debug driver
> that checks that function calls are done correctly.
>
> What should I be linking against, or what do I need to define so that the
> headers define the correct functions???
>
>

I set up my build environment from the command prompt:

I cd to C:\WINDDK\3790.1830\bin
setenv C:\WINDDK\3790.1830 fre amd64 wnet
(That changes my directory back to C:\WINDDK\3790.1830)

Then I cd to my source directory and run:

build -cZ

“David J. Craig” wrote in message
news:xxxxx@ntdev…
> KeGetCurrentThread appears to be available and valid in all three
> processor types. Are you compiling with the AMD 64 environment for NET?
> You have not specified how you ‘get the x86 build environment going’. Use
> the build environments in the start menu with a sources file and use
> ‘build -ceZ’.
>
> “Cody Cutrer” wrote in message news:xxxxx@ntdev…
>> I’m not a very experienced driver developer, and I’m trying to get my
>> driver to compile for x64. I have WS2003 SP1 DDK installed and set up.
>> I can get the x86 build environment going and it builds the driver just
>> fine. But when I use the AMD64 environment, I get linker errors about
>> unresolved externals:
>>
>> KeQuerySystemTime
>> KeInitializeSpinLock
>> KeGetCurrentThread
>> KeLowerIrql
>> KfRaiseIrql
>>
>> I was able to fix the KeGetCurrentThread because it seems on x64 only
>> PsGetCurrentThread is exported, and not KeGetCurrentThread, but the
>> headers #define PsGetCurrentThread to KeGetCurrentThread, so I just
>> #undef’ed it.
>>
>> However, I’m looking at KeInitializeSpinLock. On x86 this is exported by
>> ntoskrnl.dll (use ntoskrnl.lib). On x64, it doesn’t seem to be exported
>> by any of the libs. I even grabbed the actual dll off of my x64 machine,
>> and it doesn’t even export it at all!? Am I missing something here? I
>> finally did find it in ddk_ext.lib, but that’s for building a debug
>> driver that checks that function calls are done correctly.
>>
>> What should I be linking against, or what do I need to define so that the
>> headers define the correct functions???
>>
>>
>
>
>

Ahh, I found the problem. I was trying to build a file system filter driver
for x64. The problem was I only have IFS Kit for XP SP1, but I have DDK for
2003 SP1. So I was using the x64 tools, but apparently the headers for IFS
aren’t quite as AMD64 smart as they need to be. So I copied over a few
lines from ntddk.h from the ddk to overwrite the not AMD64 aware lines in
ntifs.h, and everything works perfectly now!

“Cody Cutrer” wrote in message news:xxxxx@ntdev…
>I set up my build environment from the command prompt:
>
> I cd to C:\WINDDK\3790.1830\bin
> setenv C:\WINDDK\3790.1830 fre amd64 wnet
> (That changes my directory back to C:\WINDDK\3790.1830)
>
> Then I cd to my source directory and run:
>
> build -cZ
>
> “David J. Craig” wrote in message
> news:xxxxx@ntdev…
>> KeGetCurrentThread appears to be available and valid in all three
>> processor types. Are you compiling with the AMD 64 environment for NET?
>> You have not specified how you ‘get the x86 build environment going’.
>> Use the build environments in the start menu with a sources file and use
>> ‘build -ceZ’.
>>
>> “Cody Cutrer” wrote in message
>> news:xxxxx@ntdev…
>>> I’m not a very experienced driver developer, and I’m trying to get my
>>> driver to compile for x64. I have WS2003 SP1 DDK installed and set up.
>>> I can get the x86 build environment going and it builds the driver just
>>> fine. But when I use the AMD64 environment, I get linker errors about
>>> unresolved externals:
>>>
>>> KeQuerySystemTime
>>> KeInitializeSpinLock
>>> KeGetCurrentThread
>>> KeLowerIrql
>>> KfRaiseIrql
>>>
>>> I was able to fix the KeGetCurrentThread because it seems on x64 only
>>> PsGetCurrentThread is exported, and not KeGetCurrentThread, but the
>>> headers #define PsGetCurrentThread to KeGetCurrentThread, so I just
>>> #undef’ed it.
>>>
>>> However, I’m looking at KeInitializeSpinLock. On x86 this is exported
>>> by ntoskrnl.dll (use ntoskrnl.lib). On x64, it doesn’t seem to be
>>> exported by any of the libs. I even grabbed the actual dll off of my
>>> x64 machine, and it doesn’t even export it at all!? Am I missing
>>> something here? I finally did find it in ddk_ext.lib, but that’s for
>>> building a debug driver that checks that function calls are done
>>> correctly.
>>>
>>> What should I be linking against, or what do I need to define so that
>>> the headers define the correct functions???
>>>
>>>
>>
>>
>>
>
>
>

You forgot to mention the IFS Kit requirement. The Server 2003 SP1 DDK
works well, but not for file system stuff. There is an equivalent IFS Kit
based on the same DDK. Mixing headers from different DDKs or IFS Kits is
not a good idea. The headers, libraries, and build environments are all
sync’ed.

“Cody Cutrer” wrote in message news:xxxxx@ntdev…
> Ahh, I found the problem. I was trying to build a file system filter
> driver for x64. The problem was I only have IFS Kit for XP SP1, but I
> have DDK for 2003 SP1. So I was using the x64 tools, but apparently the
> headers for IFS aren’t quite as AMD64 smart as they need to be. So I
> copied over a few lines from ntddk.h from the ddk to overwrite the not
> AMD64 aware lines in ntifs.h, and everything works perfectly now!
>
> “Cody Cutrer” wrote in message news:xxxxx@ntdev…
>>I set up my build environment from the command prompt:
>>
>> I cd to C:\WINDDK\3790.1830\bin
>> setenv C:\WINDDK\3790.1830 fre amd64 wnet
>> (That changes my directory back to C:\WINDDK\3790.1830)
>>
>> Then I cd to my source directory and run:
>>
>> build -cZ
>>
>> “David J. Craig” wrote in message
>> news:xxxxx@ntdev…
>>> KeGetCurrentThread appears to be available and valid in all three
>>> processor types. Are you compiling with the AMD 64 environment for NET?
>>> You have not specified how you ‘get the x86 build environment going’.
>>> Use the build environments in the start menu with a sources file and use
>>> ‘build -ceZ’.
>>>
>>> “Cody Cutrer” wrote in message
>>> news:xxxxx@ntdev…
>>>> I’m not a very experienced driver developer, and I’m trying to get my
>>>> driver to compile for x64. I have WS2003 SP1 DDK installed and set up.
>>>> I can get the x86 build environment going and it builds the driver just
>>>> fine. But when I use the AMD64 environment, I get linker errors about
>>>> unresolved externals:
>>>>
>>>> KeQuerySystemTime
>>>> KeInitializeSpinLock
>>>> KeGetCurrentThread
>>>> KeLowerIrql
>>>> KfRaiseIrql
>>>>
>>>> I was able to fix the KeGetCurrentThread because it seems on x64 only
>>>> PsGetCurrentThread is exported, and not KeGetCurrentThread, but the
>>>> headers #define PsGetCurrentThread to KeGetCurrentThread, so I just
>>>> #undef’ed it.
>>>>
>>>> However, I’m looking at KeInitializeSpinLock. On x86 this is exported
>>>> by ntoskrnl.dll (use ntoskrnl.lib). On x64, it doesn’t seem to be
>>>> exported by any of the libs. I even grabbed the actual dll off of my
>>>> x64 machine, and it doesn’t even export it at all!? Am I missing
>>>> something here? I finally did find it in ddk_ext.lib, but that’s for
>>>> building a debug driver that checks that function calls are done
>>>> correctly.
>>>>
>>>> What should I be linking against, or what do I need to define so that
>>>> the headers define the correct functions???
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>