WinDDK cross compiling problem...

Hello,

I have been building and testing non-Pnp, kmdf, software only driver on Win7, 64-bit systems, and everything works properly. We have a simple testing application, “testit”, that sends commands to the driver to test it.

Tonight, on our Win7, 64-bit system, I opened the x86 Checked Build Environment and built (cross compiled) a 32-bit version of our driver and testit.exe. I copied the driver package and testit.exe to the target WinXP Pro SP3, 32-bit computer and installed the driver. When I tried to launch testit.exe, I received an error, “Not a valid Win32 application”. So, I installed the WinDDK on the computer and built testit.exe there. When I launched it, I received the same error. I would appreciate any ideas as to what is going on… Everything built and ran correctly on Vista and Win7 64-bit computers.

Thank you for your help!
Mike

you have to build for the target os, in this case win xp x86 chk. each image embeds the os version that is supposed to run. if you compile with 7 ddk and run it on xp, then the image will have a header specifying the target os version as 6.01. you can retrieve the image version with !dh debugger command.


From: “xxxxx@a-bit-of-help.com
To: Windows System Software Devs Interest List
Sent: Monday, March 28, 2011 9:03 AM
Subject: [ntdev] WinDDK cross compiling problem…

Hello,

I have been building and testing non-Pnp, kmdf, software only driver on Win7, 64-bit systems, and everything works properly.? We have a simple testing application, “testit”, that sends commands to the driver to test it.

Tonight, on our Win7, 64-bit system, I opened the x86 Checked Build Environment and built (cross compiled) a 32-bit version of our driver and testit.exe.? I copied the driver package and testit.exe to the target WinXP Pro SP3, 32-bit computer and installed the driver.? When I tried to launch testit.exe, I? received an error, “Not a valid Win32 application”.? So, I installed the WinDDK on the computer and built testit.exe there.? When I launched it, I received the same error.? I would appreciate any ideas as to what is going on…? Everything built and ran correctly on Vista and Win7 64-bit computers.

Thank you for your help!
Mike


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Double check what you are moving to your target OS. The driver MUST be built for the radix of your OS. If you are running a 32 bit OS then you must be using the 32 version of the driver. If it’s 64 bit, you must be using the 64 bit version of the driver. Also, the 64 bit driver MUST be signed using a valid CA issued certificate, a test certificate, or signing MUST be disabled at boot on the 64 bit system.

Gary G. Little

----- Original Message -----
From: xxxxx@a-bit-of-help.com
To: “Windows System Software Devs Interest List”
Sent: Monday, March 28, 2011 2:03:25 AM
Subject: [ntdev] WinDDK cross compiling problem…

Hello,

I have been building and testing non-Pnp, kmdf, software only driver on Win7, 64-bit systems, and everything works properly. We have a simple testing application, “testit”, that sends commands to the driver to test it.

Tonight, on our Win7, 64-bit system, I opened the x86 Checked Build Environment and built (cross compiled) a 32-bit version of our driver and testit.exe. I copied the driver package and testit.exe to the target WinXP Pro SP3, 32-bit computer and installed the driver. When I tried to launch testit.exe, I received an error, “Not a valid Win32 application”. So, I installed the WinDDK on the computer and built testit.exe there. When I launched it, I received the same error. I would appreciate any ideas as to what is going on… Everything built and ran correctly on Vista and Win7 64-bit computers.

Thank you for your help!
Mike


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

What does your sources file look like? Is there an _nt_target_version directive in it? If yes, that overrides the XP targeting defaults that the XP build window provides.

d

dent from a phine with no keynoard

-----Original Message-----
From: xxxxx@a-bit-of-help.com
Sent: Monday, March 28, 2011 12:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WinDDK cross compiling problem…

Hello,

I have been building and testing non-Pnp, kmdf, software only driver on Win7, 64-bit systems, and everything works properly. We have a simple testing application, “testit”, that sends commands to the driver to test it.

Tonight, on our Win7, 64-bit system, I opened the x86 Checked Build Environment and built (cross compiled) a 32-bit version of our driver and testit.exe. I copied the driver package and testit.exe to the target WinXP Pro SP3, 32-bit computer and installed the driver. When I tried to launch testit.exe, I received an error, “Not a valid Win32 application”. So, I installed the WinDDK on the computer and built testit.exe there. When I launched it, I received the same error. I would appreciate any ideas as to what is going on… Everything built and ran correctly on Vista and Win7 64-bit computers.

Thank you for your help!
Mike


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@a-bit-of-help.com wrote:

Hello,

I have been building and testing non-Pnp, kmdf, software only driver
on Win7, 64-bit systems, and everything works properly. We have a
simple testing application, “testit”, that sends commands to the
driver to test it.

Tonight, on our Win7, 64-bit system, I opened the x86 Checked Build
Environment

*Which* x86 Checked Build Environment? The WinXP one or another one?

and built (cross compiled) a 32-bit version of our driver and
testit.exe. I copied the driver package and testit.exe to the
target WinXP Pro SP3, 32-bit computer and installed the driver.
When I tried to launch testit.exe, I received an error, “Not
a valid Win32 application”.

Sounds like it was built for a target OS later than XP.

Hi Everyone,

Thank you very much for your ideas and explanations! I looked at our 64 bit system and saw that we are using the X86 and X64 checked environments for Vista. So, as I understand it, when I moved the cross compiled x86 driver and test application to our WinXP 32-bit test computer, they would fail because they were built to target Vista and not WinXP. I read more about the build environments in the Docs and it basically said that I can build for the supported target OS and platform (x86/amd64/ia64) by using the matching build environment. More simply put, we need to use the corresponding build environment for the corresponding target OS(s).

i.e. On our Win7, 64-bit dev computer, I can open the WinXP build environment and build the various radix versions for target WinXp systems.

So, this is the best practice… We do not want to build a least common denominator version (i.e. WinXP environment) and try to use it on Win7, etc., because each build environment optimizes its build for the target system.

This afternoon, I will open the WinXP Checked Environment and build our driver and test application. I will copy them to our WinXP Pro SP3 32-bit system, and see if things work.

Thank you again for your help and sharing your knowledge!

Mike

Glad that you are closer to getting your stuff working. Though I think you
might have a misconception about how the WDK environments work. Unless you
have code that conditionally compiles in Vista+ DDIs when a Vista+
environment is encountered, the best practice *is* to use the build
environment for the oldest OS you intend to support, from the newest WDK
that supports that OS.

The only difference in the Build environments for specific OS versions is
the headers with DDI declarations and libs that expose the DDIs present in
that OS version. The compiler and linker are the same, and I don’t know of
any OS version differences in the compiler and linker flags, just the
defines that expose or hide DDIs in the headers.

So the takeaway is to use the XP 32 and 2003 x64 environments, if those are
your oldest supported OS versions, unless you are specifically using DDIs
that were included in newer OS versions, in which case you’ll have to use
conditional compilation, and figure out how to do the same thing yourself in
the older OS versions, and build multiple driver versions based on the
target OS.

Phil

Philip D. Barila??? (303) 776-1264

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@a-bit-of-help.com
Sent: Monday, March 28, 2011 2:56 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WinDDK cross compiling problem…

Hi Everyone,

Thank you very much for your ideas and explanations! I looked at our 64 bit
system and saw that we are using the X86 and X64 checked environments for
Vista. So, as I understand it, when I moved the cross compiled x86 driver
and test application to our WinXP 32-bit test computer, they would fail
because they were built to target Vista and not WinXP. I read more about
the build environments in the Docs and it basically said that I can build
for the supported target OS and platform (x86/amd64/ia64) by using the
matching build environment. More simply put, we need to use the
corresponding build environment for the corresponding target OS(s).

i.e. On our Win7, 64-bit dev computer, I can open the WinXP build
environment and build the various radix versions for target WinXp systems.

So, this is the best practice… We do not want to build a least common
denominator version (i.e. WinXP environment) and try to use it on Win7,
etc., because each build environment optimizes its build for the target
system.

This afternoon, I will open the WinXP Checked Environment and build our
driver and test application. I will copy them to our WinXP Pro SP3 32-bit
system, and see if things work.

Thank you again for your help and sharing your knowledge!

Mike

Hi Phil,

Wow! I have to say that I really liked your response because my idea of having to build in each of the environments for each x86, x64, and ia64 platform would be a lot of work! Our driver doesn’t use any OS specific DDIs. It is a software only, non-Pnp, kmdf driver that uses Zw functions and sends some requests for disk information, so I think that your idea applies to us! We can simply build for the lowest denominator OSs: WinXP Environment for x86 and Win2k3 for x64 and ia64.

Thank you for your help with the build environments!

Mike

P.S. The next reply deals with my build tests today based on everyone’s comments…

Hi Everyone,

On our development computer (Win7, 64-bit) I opened the “Windows XP x86 Checked Build Environment” window. I built the driver and compiler without any errors. The following shows what was reported during the builds…


C:\PROJECTS\XXXXDriver\Sys>build -ceZ
BUILD: Compile and Link for x86
BUILD: Start time: Mon Mar 28 22:09:11 2011
BUILD: Examining c:\projects\XXXXDriver\sys directory for files to compile.
c:\projects\XXXXDriver\sys Auto-cleaning queue for ‘root:x86chk’ (18 of 19 file(s) removed)
Invalidating OACR warning log for ‘root:x86chk’
BUILD: Building generated files in c:\projects\XXXXDriver\sys directory
Configuring OACR for ‘root:x86chk’ -
_NT_TARGET_VERSION SET TO WINXP
BUILD: Compiling and Linking c:\projects\XXXXDriver\sys directory
_NT_TARGET_VERSION SET TO WINXP
.
.
Linking Executable - objchk_wxp_x86\i386\XXXXDriver.sys
BUILD: Finish time: Mon Mar 28 22:09:17 2011
BUILD: Done

21 files compiled
1 executable built
-----------------------

I changed to our testit application’s folder and built it, too:
-----------------------
C:\PROJECTS\XXXXDriver\TestIt>build -ceZ
BUILD: Compile and Link for x86
BUILD: Start time: Mon Mar 28 22:13:22 2011
BUILD: Examining c:\projects\XXXXDriver\testit directory for files to compile.
c:\projects\XXXXDriver\testit Invalidating OACR warning log for ‘root:x86chk

BUILD: Compiling and Linking c:\projects\XXXXDriver\testit directory
Configuring OACR for ‘root:x86chk’ -
Compiling - testit.c
Linking Executable - objchk_wxp_x86\i386\testit.exe
BUILD: Finish time: Mon Mar 28 22:13:22 2011
BUILD: Done

3 files compiled
-----------------------

Next, I copied the objchk_wxp_x86 folder for testit to the WinXP SP3 32-bit test computer. I didn’t bother installing the driver since the error that I am fighting is before trying to work with the driver. I opened a command prompt, changed to the folder and launched testit. Unfortunately, I received the dreaded “Not a valid Win32 Application” error. Argggg… It seems that I am doing everything correctly, so I would really appreciate your suggestions and ideas.

Thanks,

Mike

Ah Haaaaaaaaa!

I noticed that _NT_TARGET_VERSION SET TO WINXP was reported when our driver was built, but it wasn’t reported for our test application, so I compared the sources files and discovered that someone had specified _NT_TARGET_VERSION for vista! Mystery solved! Working on a team can be a good thing, but sometimes there are too many hands in the pot!

Thank you Everyone for giving me your ideas and suggestions… Now, I can move forward again!

Mike

> So, this is the best practice… We do not want to build a least common denominator version (i.e. WinXP

environment) and try to use it on Win7, etc., because each build environment optimizes its build for the target
system.

It does not. The compiler and its flags are the same.

What the newer build env gives you is the ability to use the new APIs appeared in later Windows versions.

But, in terms of product maintenance, it is often (not always) much simpler to build only 1 binary (with the oldest build env), using MmGetSystemRoutineAddress to fetch the functions from the newer OS versions.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

You should have listened to me this morning, I guessed that this was your issue. Could have saved yourself some time :wink:

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@a-bit-of-help.com
Sent: Monday, March 28, 2011 11:31 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WinDDK cross compiling problem…

Ah Haaaaaaaaa!

I noticed that _NT_TARGET_VERSION SET TO WINXP was reported when our driver was built, but it wasn’t reported for our test application, so I compared the sources files and discovered that someone had specified _NT_TARGET_VERSION for vista! Mystery solved! Working on a team can be a good thing, but sometimes there are too many hands in the pot!

Thank you Everyone for giving me your ideas and suggestions… Now, I can move forward again!

Mike


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@a-bit-of-help.com wrote:

Wow! I have to say that I really liked your response because my idea of having to build in each of the environments for each x86, x64, and ia64 platform would be a lot of work! Our driver doesn’t use any OS specific DDIs. … We can simply build for the lowest denominator OSs: WinXP Environment for x86 and Win2k3 for x64 and ia64.

It is a safe bet that your driver will never in its life encounter an
ia64 system.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.