I’ve built a number of user mode apps and a couple of windows services and now find myself wishing to understand device drivers in the context of working with upgrading an application which talks to a usb connected device. Our application uses a number of different .sys files to provide a usb communcation interface to a number of different usb devices. Currently these applications fail to install properly on 64bit systems. I believe this is because the drivers are 32 bit drivers and they need to be recompiled as 64bit drivers.
Question #1 - Is it enough to just recompile the driver ? Other than redoing the install inf file and doing all the stuff involved with getting the driver signed.
Drivers do not show up in the services manager like normal windows services. They also are not self installable like windows services (ie you cant do hello.sys /install from the command prompt).
Question #2 - These last two statements are true, right?
So I have the WDK 7600 and have created two drivers based on tutorials I found (one for 32 bit & one for 64bit) which look essentially like this:
#include <ntddk.h>
DRIVER_UNLOAD DriverUnload;
void DriverUnload(PDRIVER_OBJECT pDriverObject)
{
DbgPrint(“Driver 32bit unloading\n”);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
DriverObject->DriverUnload = DriverUnload;
DbgPrint(“Hello, World From 32bits\n”);
return STATUS_SUCCESS;
}
For the 32 version I build up the driver using the x86 XP Checked Build Environment and even though I’m currently testing on XP 64bit I build up the other driver using the x86 Vista Checked Build Environment.
Question #3abc - We are primarily interested in a driver for windows 7 64 bit. But what are the differances between a 64bit driver for the XP, Vista and Windows 7 platforms? Can I use the 64driver compiled under the x86 Vista Checked Build Environment in windows XP 64bit? Anything other than installation specifics to consider?
I can install the drivers using the OSRLOADER.exe and see it start and stop by using the Systernal DebugView
application both when started manually from the command prompt using net start or net stop and when using the
start and stop from OSRLOADER.
The hello64.sys registers but does not start on my xp 32 bit platform
The hello32.sys registers but does not start on my xp 64 bit platform
This is as I expect it should be
Registering a Service makes a number of Registry Entries in the Windows Registry.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<drivername>
DisplayName REG_SZ
ErrorControl REG_DWORD
ImagePath REG_EXPAND_SZ
Start REG_DWORD
Type REG_DWORD
thier is also sometimes an enum and a security sub key
Question #4
There is also some additional Operating system interaction involved in Registering a driver to which I am unclear on. When I manually create these keys and copy the file into the location referenced by ImagePath it is not enough. I dont think its the enum or security key but something else that I am missing.</ntddk.h>
You really should work with the author of the driver to answer these
questions. Here are a few answers:
1.) A simple recompile is often sufficient. HOWEVER, there are possible
problems that depend primarily on the definition of structures that may be
exchanged between user-mode and kernel-mode. See the WDK topic “Programming
Issues for 64-Bit Drivers”. The key point is that if bit-dependent data
(e.g., integers) are exchanges you will have to take additional steps to
accommodate them
2.) USB drivers are programmatically installed using functionality
illustrated in the WDK “DevCon” sample. Study that and adapt it to your
needs.
Drivers show up under Device Manager instead of Applications and Services.
3.) Drivers follow the bitness of the host. 32-bit drivers on 32-bit hosts,
64-bit drivers on 64-bit hosts. No mix-and-match.
4.) For Plug-and-Play drivers (like USB…) NEVER MAKE YOUR OWN REGISTRY
ENTRIES!!!
(Unless you really like re-imaging you machines…)
Study the WDK driver install topics and the DevCon sample.
I’m sure others will have better advice, but this will get you started.
Good luck,
Thomas F. Divine
http://www.pcausa.com
From:
Sent: Wednesday, March 24, 2010 2:39 PM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] Some simple clarifications on drivers for an interested
party (me 
> I’ve built a number of user mode apps and a couple of windows services and
> now find myself wishing to understand device drivers in the context of
> working with upgrading an application which talks to a usb connected
> device. Our application uses a number of different .sys files to provide a
> usb communcation interface to a number of different usb devices. Currently
> these applications fail to install properly on 64bit systems. I believe
> this is because the drivers are 32 bit drivers and they need to be
> recompiled as 64bit drivers.
>
> Question #1 - Is it enough to just recompile the driver ? Other than
> redoing the install inf file and doing all the stuff involved with getting
> the driver signed.
>
>
> Drivers do not show up in the services manager like normal windows
> services. They also are not self installable like windows services (ie you
> cant do hello.sys /install from the command prompt).
>
> Question #2 - These last two statements are true, right?
>
>
> So I have the WDK 7600 and have created two drivers based on tutorials I
> found (one for 32 bit & one for 64bit) which look essentially like this:
>
>
> #include <ntddk.h>
>
> DRIVER_UNLOAD DriverUnload;
>
> void DriverUnload(PDRIVER_OBJECT pDriverObject)
> {
> DbgPrint(“Driver 32bit unloading\n”);
> }
>
> NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING
> RegistryPath)
> {
> DriverObject->DriverUnload = DriverUnload;
>
> DbgPrint(“Hello, World From 32bits\n”);
>
> return STATUS_SUCCESS;
> }
>
>
>
> For the 32 version I build up the driver using the x86 XP Checked Build
> Environment and even though I’m currently testing on XP 64bit I build up
> the other driver using the x86 Vista Checked Build Environment.
>
>
> Question #3abc - We are primarily interested in a driver for windows 7 64
> bit. But what are the differances between a 64bit driver for the XP, Vista
> and Windows 7 platforms? Can I use the 64driver compiled under the x86
> Vista Checked Build Environment in windows XP 64bit? Anything other than
> installation specifics to consider?
>
>
>
>
> I can install the drivers using the OSRLOADER.exe and see it start and
> stop by using the Systernal DebugView
>
> application both when started manually from the command prompt using net
> start or net stop and when using the
>
> start and stop from OSRLOADER.
>
>
>
> The hello64.sys registers but does not start on my xp 32 bit platform
>
> The hello32.sys registers but does not start on my xp 64 bit platform
>
>
> This is as I expect it should be
>
>
> Registering a Service makes a number of Registry Entries in the Windows
> Registry.
>
>
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<drivername>
> DisplayName REG_SZ
> ErrorControl REG_DWORD
> ImagePath REG_EXPAND_SZ
> Start REG_DWORD
> Type REG_DWORD
>
> thier is also sometimes an enum and a security sub key
>
> Question #4
> There is also some additional Operating system interaction involved in
> Registering a driver to which I am unclear on. When I manually create
> these keys and copy the file into the location referenced by ImagePath it
> is not enough. I dont think its the enum or security key but something
> else that I am missing.
>
>
>
>
> —
> 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</ntddk.h>