Porting 32 bit to a 64 bit filter driver

A few years back my company developed a WinXP disk filter driver that was based off the WinDDK disperf.sys example code. I have been tasked with porting that driver to a Windows 7 64 bit driver. When I build the diskperf sample driver with the Windows 7 DDK, it builds with no errors but indicates it is not compatible for 64 bit when I try to install it. This was pretty expected since the diskperf documentation says it is not compatible with 64 bit.

My question is how do I port the sample driver for 64 bit operation? I have not been able to find much useful information on porting to a 64 bit driver… Seems kind of stupid on my part because I would assume there would be ton of information out there.

I am using the 7600.16385.1 version of the Windows DDK built in the Win7 x64 environment.

I would appreciate any help to get me started on this.

> My question is how do I port the sample driver for 64 bit operation? I

You actually don’t port the driver. Assuming you coded it
properly, you only need to recompile it using the 64-bit
target, sing it and you are free to use it.

L.

I’d agree with Ladislav, but I’d add one small niggle.

If you communicate with usermode using HANDLES (or do something smart with
FSCTL_MOVE_FILE) then you need to be aware that you might be given a 32 bit
or a 64 bit item… The FAT sources show you how to deal with that.

You may also find that the 64 bit compilers are slightly stricter which can
be refreshing.

Rod

Hi Bob,

Remember that your 64 bit driver can also be used by a 32 bit application running on Wow64. Think about this on defining structures that will be used on IOCTLs. Your 64 bit driver must deal with the case of receiving the same structure with different sizes depending on the application it is coming from.

You should also be aware of doing NEITHER transfers with embedded pointers (which is not recommended even on 32 bit) on such a case. Wow64 has no way to translate embedded pointers from 32 bit to 64 bit before sending an IRP to your driver.

That’s a useful link to check out.
http://msdn.microsoft.com/en-us/library/windows/hardware/gg487358.aspx

Regards,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br

Thanks for the prompt reply’s everyone…

So at the risk of sounding stupid(er), why does the diskperf.htm file in the MSFT sample code say the driver is not 64 bit compliant?

I built the diskperf sample using the Windows 7 x64 environment. It builds ok but does not install on my 64 bit target. During install, I just get a message saying it is not compatible with my device and to insure it is designed to work with Windows x64 systems.

I am going through the code now to check types and make sure all pointers, handles ect. are 64 bit types and variables are stongly defined (INT32, INT64 ect)…

Also, does the INF file need to change somehow to indicate a 64 bit driver??

Thanks again…

(Note that this is a DISK filter driver, thus is more appropriate for NTDEV.
This list is for file system filters)

Checklist for installing the diskperf on x64:

  1. Make sure you build the code for x64 (which it sounds like you have)

  2. Have you signed the driver? Don’t forget that x64 requires drivers to be:

a. Production signed
b. Test signed, with test signing turned on and the test cert installed
on the target
c. Unsigned only loads with debugging enabled on the target and a kernel
debugger attached.

NOTE: Diskperf is a boot start driver, so you’ll also need enable debugging
AND boot debugging:

bcdedit /set debug on
bcdedit /set bootdebug on

Do this BEFORE you try to install the driver. Otherwise, you’ll get an error
and the driver will be automatically disabled.

  1. The INF for diskperf expects the x64 binary to be in a subdirectory
    named, “amd64” (i.e. INF is in c:\foo, driver is in c:\foo\amd64).

-scott
OSR

wrote in message news:xxxxx@ntfsd…

Thanks for the prompt reply’s everyone…

So at the risk of sounding stupid(er), why does the diskperf.htm file in
the MSFT sample code say the driver is not 64 bit compliant?

I built the diskperf sample using the Windows 7 x64 environment. It builds
ok but does not install on my 64 bit target. During install, I just get a
message saying it is not compatible with my device and to insure it is
designed to work with Windows x64 systems.

I am going through the code now to check types and make sure all pointers,
handles ect. are 64 bit types and variables are stongly defined (INT32,
INT64 ect)…

Also, does the INF file need to change somehow to indicate a 64 bit driver??

Thanks again…

Thanks… You guys are great…
I was test signing it ok but had the path stuff in the inf wrong…
Looks like I get to keep my job for a little while longer.