Discussion:
Develop driver 32/64 bit (IA & AMD64) for XP, Vista & Seven for WH
(too old to reply)
Moulefrite
2010-09-01 15:54:03 UTC
Permalink
Hi all,
I have a project where it's necessary to "upgrade" sourceCode of
smartcardReader driver for pass WHQL certification.
This driver works fine in XP 32 bits.
Someone can explain me differents steps for finish this project.
For the moment :
_ I have updated the .inf file for execute "AMD64" routine.
_ Recomplied the sourceCode and installed to XP x64 bit, and driver seems to
be work.

Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?

If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?

I have an other problem, I have compiled a "wnet64" drivers that work with
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Even if I remove the integrity verification signature drivers, result is the
same.
Some one have an idea ?

I have read MSDN but I don't know if this driver need some rewrite for work
with Vista, Seven OS or just need a particular compilation.
For exemple this link found in other thread :
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
Someone can explain me the different part to rewrite ( ioDeviceControl ? ,
inOutBuffer from IRP ?)
Interest to use this macro : ULongToHandle(ul) ?

Thanks a lot by advance (^_^)

ps : Sorry for my poor level in english.
Don Burn
2010-09-01 16:16:17 UTC
Permalink
Yes if you are going for WHQL you should use the latest WDK. Your build
environment is correct by using the oldest 64-bit OS you will support
all of them. I suspect your install problem is that 64-bit drivers
must have a digital signature to load. Try having Windbg connected and
boot choosing the F8 option to ignore signatures and see if that allows
the driver to load.

If you are not doing stupid things like passing 32-bit pointers in IOCTL
data you should not need to modify your driver for 64-bit. You may need
to in order to pass WHQL.


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi all,
I have a project where it's necessary to "upgrade" sourceCode of
smartcardReader driver for pass WHQL certification.
This driver works fine in XP 32 bits.
Someone can explain me differents steps for finish this project.
_ I have updated the .inf file for execute "AMD64" routine.
_ Recomplied the sourceCode and installed to XP x64 bit, and driver seems to
be work.
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
I have an other problem, I have compiled a "wnet64" drivers that work with
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Even if I remove the integrity verification signature drivers, result is the
same.
Some one have an idea ?
I have read MSDN but I don't know if this driver need some rewrite for work
with Vista, Seven OS or just need a particular compilation.
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
Someone can explain me the different part to rewrite ( ioDeviceControl ? ,
inOutBuffer from IRP ?)
Interest to use this macro : ULongToHandle(ul) ?
Thanks a lot by advance (^_^)
ps : Sorry for my poor level in english.
Moulefrite
2010-09-01 18:23:03 UTC
Permalink
Hi Don Burn and thank you for your reply,

I have tested the F8 Mode and now the driver has been installed correctly,
My problem now, is I don't have debugView informations appears when I launch
the remote debug ( remote debug from debugView v 4.74), which work fine with
XP 64 but not Vista and Seven 64 (even with firewall disabled).

I don't know why, and normally driver works fine because I can connect the
reader to a smartcard.

Thanks a lot for your help.

SomeOne could gave me a tools like usbMonitor for visualise bulk IN/OUT frame.
and a tool for debug my sourceCode ( like softIce for XP and older).

Regards,
Post by Don Burn
Yes if you are going for WHQL you should use the latest WDK. Your build
environment is correct by using the oldest 64-bit OS you will support
all of them. I suspect your install problem is that 64-bit drivers
must have a digital signature to load. Try having Windbg connected and
boot choosing the F8 option to ignore signatures and see if that allows
the driver to load.
If you are not doing stupid things like passing 32-bit pointers in IOCTL
data you should not need to modify your driver for 64-bit. You may need
to in order to pass WHQL.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi all,
I have a project where it's necessary to "upgrade" sourceCode of
smartcardReader driver for pass WHQL certification.
This driver works fine in XP 32 bits.
Someone can explain me differents steps for finish this project.
_ I have updated the .inf file for execute "AMD64" routine.
_ Recomplied the sourceCode and installed to XP x64 bit, and driver seems to
be work.
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
I have an other problem, I have compiled a "wnet64" drivers that work with
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Even if I remove the integrity verification signature drivers, result is the
same.
Some one have an idea ?
I have read MSDN but I don't know if this driver need some rewrite for work
with Vista, Seven OS or just need a particular compilation.
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
Someone can explain me the different part to rewrite ( ioDeviceControl ? ,
inOutBuffer from IRP ?)
Interest to use this macro : ULongToHandle(ul) ?
Thanks a lot by advance (^_^)
ps : Sorry for my poor level in english.
.
Don Burn
2010-09-01 18:43:46 UTC
Permalink
SoftIce has been gone for a long time, and most of us said good
riddance. The current approach for single machine debugging is to use a
virtual machine for debugging. For the debug output starting with Vista
you have to enable it see http://www.osronline.com/article.cfm?id=295


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi Don Burn and thank you for your reply,
I have tested the F8 Mode and now the driver has been installed correctly,
My problem now, is I don't have debugView informations appears when I launch
the remote debug ( remote debug from debugView v 4.74), which work fine with
XP 64 but not Vista and Seven 64 (even with firewall disabled).
I don't know why, and normally driver works fine because I can connect the
reader to a smartcard.
Thanks a lot for your help.
SomeOne could gave me a tools like usbMonitor for visualise bulk IN/OUT frame.
and a tool for debug my sourceCode ( like softIce for XP and older).
Regards,
Post by Don Burn
Yes if you are going for WHQL you should use the latest WDK. Your build
environment is correct by using the oldest 64-bit OS you will support
all of them. I suspect your install problem is that 64-bit drivers
must have a digital signature to load. Try having Windbg connected and
boot choosing the F8 option to ignore signatures and see if that allows
the driver to load.
If you are not doing stupid things like passing 32-bit pointers in IOCTL
data you should not need to modify your driver for 64-bit. You may need
to in order to pass WHQL.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi all,
I have a project where it's necessary to "upgrade" sourceCode of
smartcardReader driver for pass WHQL certification.
This driver works fine in XP 32 bits.
Someone can explain me differents steps for finish this project.
_ I have updated the .inf file for execute "AMD64" routine.
_ Recomplied the sourceCode and installed to XP x64 bit, and driver seems to
be work.
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
I have an other problem, I have compiled a "wnet64" drivers that work with
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Even if I remove the integrity verification signature drivers, result is the
same.
Some one have an idea ?
I have read MSDN but I don't know if this driver need some rewrite for work
with Vista, Seven OS or just need a particular compilation.
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
Someone can explain me the different part to rewrite ( ioDeviceControl ? ,
inOutBuffer from IRP ?)
Interest to use this macro : ULongToHandle(ul) ?
Thanks a lot by advance (^_^)
ps : Sorry for my poor level in english.
.
Moulefrite
2010-09-02 09:28:03 UTC
Permalink
Hi Don Burn and thanks a lot for this link,
Now I can catch debugPrint info with debugView launched in remote debug.
Post by Don Burn
SoftIce has been gone for a long time, and most of us said good
riddance. The current approach for single machine debugging is to use a
virtual machine for debugging. For the debug output starting with Vista
you have to enable it see http://www.osronline.com/article.cfm?id=295
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi Don Burn and thank you for your reply,
I have tested the F8 Mode and now the driver has been installed correctly,
My problem now, is I don't have debugView informations appears when I launch
the remote debug ( remote debug from debugView v 4.74), which work fine with
XP 64 but not Vista and Seven 64 (even with firewall disabled).
I don't know why, and normally driver works fine because I can connect the
reader to a smartcard.
Thanks a lot for your help.
SomeOne could gave me a tools like usbMonitor for visualise bulk IN/OUT frame.
and a tool for debug my sourceCode ( like softIce for XP and older).
Regards,
Post by Don Burn
Yes if you are going for WHQL you should use the latest WDK. Your build
environment is correct by using the oldest 64-bit OS you will support
all of them. I suspect your install problem is that 64-bit drivers
must have a digital signature to load. Try having Windbg connected and
boot choosing the F8 option to ignore signatures and see if that allows
the driver to load.
If you are not doing stupid things like passing 32-bit pointers in IOCTL
data you should not need to modify your driver for 64-bit. You may need
to in order to pass WHQL.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Post by Moulefrite
Hi all,
I have a project where it's necessary to "upgrade" sourceCode of
smartcardReader driver for pass WHQL certification.
This driver works fine in XP 32 bits.
Someone can explain me differents steps for finish this project.
_ I have updated the .inf file for execute "AMD64" routine.
_ Recomplied the sourceCode and installed to XP x64 bit, and driver seems to
be work.
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
I have an other problem, I have compiled a "wnet64" drivers that work with
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Even if I remove the integrity verification signature drivers, result is the
same.
Some one have an idea ?
I have read MSDN but I don't know if this driver need some rewrite for work
with Vista, Seven OS or just need a particular compilation.
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
Someone can explain me the different part to rewrite ( ioDeviceControl ? ,
inOutBuffer from IRP ?)
Interest to use this macro : ULongToHandle(ul) ?
Thanks a lot by advance (^_^)
ps : Sorry for my poor level in english.
.
.
Maxim S. Shatskih
2010-09-01 22:09:10 UTC
Permalink
Post by Moulefrite
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
I don't know the smartcard drivers in particular, but usually old driver binary (if it is not using some hard undocumented things like EPROCESS structure offsets) just plain work being installed on a new OS.

The major exception are technology changes. For instance, NDIS5 driver will work badly on Vista+, and TDI filters will not filter half of the traffic (with Vista+, not all TCP/IP capable software are TDI clients). So are XPDM -> WDDM.

I don't know whether there was some major technology changes in smartcard stack in Vista+.
Post by Moulefrite
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
IA64 is Itanium. The usual 64-bit machine is x64.
Post by Moulefrite
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Signature issue? try on 32bit Vista.
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
Moulefrite
2010-09-02 09:42:06 UTC
Permalink
Thanks Maxim for your reply,

I noticed that with an OS 64 Bit (XP/Vista/Seven) I have a problem with
deviceIoControl routine ( MAJOR : IRP_MJ_DEVICE_CONTROL).
It appears that IOCTL process are different from 32 bit OS.
It's maybe here that it's necessary to rewrite the code for adapt for 64 bit.
( use this MACRO "ULongToHandle(ul)" and "IoIs32bitProcess" ?)

example extract from MSDN:
##################################################
##################################################
#if defined(_WIN64)
if (IoIs32bitProcess(Irp)) {
PTESTDRV_EVENT_BUFFER32 Buffer32;

if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER32)) {
DebugTrace(0, Dbg, "Irp32 : System buffer size is too
small\n", 0);

FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = &LocalBuffer;
Buffer32 = Irp->AssociatedIrp.SystemBuffer;
Buffer->Handle = (HANDLE)Buffer32->Handle;
Buffer->Key = Buffer32->Key;
}
else {
#endif
####################################################
####################################################

Someone could tell me part mandatory necessary to rewrite for work on 64bit
OSes.

Thanks by advance,

Regards,
Post by Maxim S. Shatskih
Post by Moulefrite
Someone could confirm me that for compile a driver 64 bit Vista Seven, it's
necessary to build it with "WDK 7600 >> build environnement >> Windows Server
2003" and select "X64 Free or Checked" for generate "wnet64" directory ?
I don't know the smartcard drivers in particular, but usually old driver binary (if it is not using some hard undocumented things like EPROCESS structure offsets) just plain work being installed on a new OS.
The major exception are technology changes. For instance, NDIS5 driver will work badly on Vista+, and TDI filters will not filter half of the traffic (with Vista+, not all TCP/IP capable software are TDI clients). So are XPDM -> WDDM.
I don't know whether there was some major technology changes in smartcard stack in Vista+.
Post by Moulefrite
If I use a computer with Intel processor, I can compile the driver with X64
? or necessarily with IA64 ?
IA64 is Itanium. The usual 64-bit machine is x64.
Post by Moulefrite
XP 64bit, but when I try to install it to Vista I have an error code 39 and
the same error status with seven (value 52)
Signature issue? try on 32bit Vista.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
.
Maxim S. Shatskih
2010-09-02 13:45:03 UTC
Permalink
Post by Moulefrite
I noticed that with an OS 64 Bit (XP/Vista/Seven) I have a problem with
deviceIoControl routine ( MAJOR : IRP_MJ_DEVICE_CONTROL).
It appears that IOCTL process are different from 32 bit OS.
If you use pointers or handles in IOCTL buffers - then yes.

In this case, you must declare 2 structures in your 64bit driver code - one is IOCTL buffer for 32bit clients, another - for 64bit. Like:

typedef struct _IOCTL_BUFFER
{
...
} IOCTL_BUFFER, *PIOCTL_BUFFER;

#ifdef _WIN64

typedef struct _IOCTL_BUFFER32
{
// This is for 32bit clients of 64bit driver
// Here, use VOID *POINTER_32 instead of PVOID and HANDLE
...
} IOCTL_BUFFER32, *PIOCTL_BUFFER32;

#endif

Then the 64bit driver must call IoIs32BitProcess and use one of these structures.

The apps always use IOCTL_BUFFER, both 32 and 64 bit builds.
--
Maxim S. Shatskih

Windows DDK MVP

***@storagecraft.com

http://www.storagecraft.com
Moulefrite
2010-09-02 15:47:04 UTC
Permalink
Hello Maxim and thanks a lot for your help.

I have understood the difference between both Structure.
But could you give me an example of use.

If I understand you, for ALL variable that use HANDLE type or Pointers type,
it's necessary to create both Struct for 32 and 64bit.
This MSDN link
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
present this :

typedef struct _TESTDRV_EVENT_BUFFER {
HANDLE Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER, *PTESTDRV_EVENT_BUFFER;

//
// Define a 32-bit thunking structure
//

#if defined(_WIN64)
typedef struct _TESTDRV_EVENT_BUFFER32 {
UINT32 Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER32, *PTESTDRV_EVENT_BUFFER32;
#endif

//
// Intercept the input buffer as a 32-bit structure and thunk it to
// 64-bit
NTSTATUS
TestdrvFsControl (
IN PTESTDRV_DEVICE_OBJECT TestdrvDeviceObject,
IN PIRP Irp
)
{
TESTDRV_EVENT_BUFFER LocalBuffer;

...

InputBufferLength =
IrpSp->Parameters.FileSystemControl.InputBufferLength;

#if defined(_WIN64)
if (IoIs32bitProcess(Irp)) {
PTESTDRV_EVENT_BUFFER32 Buffer32;

if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER32)) {
DebugTrace(0, Dbg, "Irp32 : System buffer size is too
small\n", 0);

FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = &LocalBuffer;
Buffer32 = Irp->AssociatedIrp.SystemBuffer;
Buffer->Handle = (HANDLE)Buffer32->Handle;
Buffer->Key = Buffer32->Key;
}
else {
#endif
if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER)) {

DebugTrace(0, Dbg, "System buffer size is too small\n", 0);

FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}

Buffer = Irp->AssociatedIrp.SystemBuffer;
#if defined(_WIN64)
}
#endif

// start using the Event Buffer

...

}


If I compare your response with this example, only bufferLength is concerned
or all parameters struct present in the IRP.
I have a difficult for understand the mecanism of adaptation 32 to 64 bit
and where adapt the code.
only where there are IRP and IOCTL exchange, in dispatch Routine ?
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
BulkUsb_DispatchDevCtrl;
DriverObject->MajorFunction[IRP_MJ_POWER] =
BulkUsb_DispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = BulkUsb_DispatchPnP;
DriverObject->MajorFunction[IRP_MJ_CREATE] =
BulkUsb_DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
BulkUsb_DispatchClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
BulkUsb_DispatchClean;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
Standard_DispatchSysCtrl;

DriverObject->DriverUnload = BulkUsb_DriverUnload;
DriverObject->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)
BulkUsb_AddDevice;

Have you got a complete example of this adaptation to 64bit ( I have
searched in DDK sample but nothing ).

Thanks a lot for your futur help
Post by Maxim S. Shatskih
Post by Moulefrite
I noticed that with an OS 64 Bit (XP/Vista/Seven) I have a problem with
deviceIoControl routine ( MAJOR : IRP_MJ_DEVICE_CONTROL).
It appears that IOCTL process are different from 32 bit OS.
If you use pointers or handles in IOCTL buffers - then yes.
typedef struct _IOCTL_BUFFER
{
...
} IOCTL_BUFFER, *PIOCTL_BUFFER;
#ifdef _WIN64
typedef struct _IOCTL_BUFFER32
{
// This is for 32bit clients of 64bit driver
// Here, use VOID *POINTER_32 instead of PVOID and HANDLE
...
} IOCTL_BUFFER32, *PIOCTL_BUFFER32;
#endif
Then the 64bit driver must call IoIs32BitProcess and use one of these structures.
The apps always use IOCTL_BUFFER, both 32 and 64 bit builds.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
.
Satya
2010-09-08 00:12:03 UTC
Permalink
Yes the "adaptation"s would be in dispatch routines (such as
BulkUsb_DispatchDevCtrl)

Satya
http://www.winprogger.com
Post by Moulefrite
Hello Maxim and thanks a lot for your help.
I have understood the difference between both Structure.
But could you give me an example of use.
If I understand you, for ALL variable that use HANDLE type or Pointers type,
it's necessary to create both Struct for 32 and 64bit.
This MSDN link
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
typedef struct _TESTDRV_EVENT_BUFFER {
HANDLE Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER, *PTESTDRV_EVENT_BUFFER;
//
// Define a 32-bit thunking structure
//
#if defined(_WIN64)
typedef struct _TESTDRV_EVENT_BUFFER32 {
UINT32 Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER32, *PTESTDRV_EVENT_BUFFER32;
#endif
//
// Intercept the input buffer as a 32-bit structure and thunk it to
// 64-bit
NTSTATUS
TestdrvFsControl (
IN PTESTDRV_DEVICE_OBJECT TestdrvDeviceObject,
IN PIRP Irp
)
{
TESTDRV_EVENT_BUFFER LocalBuffer;
...
InputBufferLength =
IrpSp->Parameters.FileSystemControl.InputBufferLength;
#if defined(_WIN64)
if (IoIs32bitProcess(Irp)) {
PTESTDRV_EVENT_BUFFER32 Buffer32;
if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER32)) {
DebugTrace(0, Dbg, "Irp32 : System buffer size is too
small\n", 0);
FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = &LocalBuffer;
Buffer32 = Irp->AssociatedIrp.SystemBuffer;
Buffer->Handle = (HANDLE)Buffer32->Handle;
Buffer->Key = Buffer32->Key;
}
else {
#endif
if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER)) {
DebugTrace(0, Dbg, "System buffer size is too small\n", 0);
FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = Irp->AssociatedIrp.SystemBuffer;
#if defined(_WIN64)
}
#endif
// start using the Event Buffer
...
}
If I compare your response with this example, only bufferLength is concerned
or all parameters struct present in the IRP.
I have a difficult for understand the mecanism of adaptation 32 to 64 bit
and where adapt the code.
only where there are IRP and IOCTL exchange, in dispatch Routine ?
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
BulkUsb_DispatchDevCtrl;
DriverObject->MajorFunction[IRP_MJ_POWER] =
BulkUsb_DispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = BulkUsb_DispatchPnP;
DriverObject->MajorFunction[IRP_MJ_CREATE] =
BulkUsb_DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
BulkUsb_DispatchClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
BulkUsb_DispatchClean;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
Standard_DispatchSysCtrl;
DriverObject->DriverUnload = BulkUsb_DriverUnload;
DriverObject->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)
BulkUsb_AddDevice;
Have you got a complete example of this adaptation to 64bit ( I have
searched in DDK sample but nothing ).
Thanks a lot for your futur help
Post by Maxim S. Shatskih
Post by Moulefrite
I noticed that with an OS 64 Bit (XP/Vista/Seven) I have a problem with
deviceIoControl routine ( MAJOR : IRP_MJ_DEVICE_CONTROL).
It appears that IOCTL process are different from 32 bit OS.
If you use pointers or handles in IOCTL buffers - then yes.
typedef struct _IOCTL_BUFFER
{
...
} IOCTL_BUFFER, *PIOCTL_BUFFER;
#ifdef _WIN64
typedef struct _IOCTL_BUFFER32
{
// This is for 32bit clients of 64bit driver
// Here, use VOID *POINTER_32 instead of PVOID and HANDLE
...
} IOCTL_BUFFER32, *PIOCTL_BUFFER32;
#endif
Then the 64bit driver must call IoIs32BitProcess and use one of these structures.
The apps always use IOCTL_BUFFER, both 32 and 64 bit builds.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
.
Moulefrite
2010-09-09 17:19:03 UTC
Permalink
Thanks Satya for your help.

My problem, is I don't have "handle" or "ulong" value like presented in the
sample to "Think".
For example, I don't have an instance of "Irp->AssociatedIrp.SystemBuffer"
to "thunk".

I have a big problem for understand clearly, what's necessary to rewrite for
work fine to 64 bit environement.

Have you got any sample ?

Thanks by advance,

Regards,
Post by Satya
Yes the "adaptation"s would be in dispatch routines (such as
BulkUsb_DispatchDevCtrl)
Satya
http://www.winprogger.com
Post by Moulefrite
Hello Maxim and thanks a lot for your help.
I have understood the difference between both Structure.
But could you give me an example of use.
If I understand you, for ALL variable that use HANDLE type or Pointers type,
it's necessary to create both Struct for 32 and 64bit.
This MSDN link
http://msdn.microsoft.com/en-us/library/ff545635%28v=VS.85%29.aspx
typedef struct _TESTDRV_EVENT_BUFFER {
HANDLE Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER, *PTESTDRV_EVENT_BUFFER;
//
// Define a 32-bit thunking structure
//
#if defined(_WIN64)
typedef struct _TESTDRV_EVENT_BUFFER32 {
UINT32 Handle;
ULONG Key;
} TESTDRV_EVENT_BUFFER32, *PTESTDRV_EVENT_BUFFER32;
#endif
//
// Intercept the input buffer as a 32-bit structure and thunk it to
// 64-bit
NTSTATUS
TestdrvFsControl (
IN PTESTDRV_DEVICE_OBJECT TestdrvDeviceObject,
IN PIRP Irp
)
{
TESTDRV_EVENT_BUFFER LocalBuffer;
...
InputBufferLength =
IrpSp->Parameters.FileSystemControl.InputBufferLength;
#if defined(_WIN64)
if (IoIs32bitProcess(Irp)) {
PTESTDRV_EVENT_BUFFER32 Buffer32;
if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER32)) {
DebugTrace(0, Dbg, "Irp32 : System buffer size is too
small\n", 0);
FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = &LocalBuffer;
Buffer32 = Irp->AssociatedIrp.SystemBuffer;
Buffer->Handle = (HANDLE)Buffer32->Handle;
Buffer->Key = Buffer32->Key;
}
else {
#endif
if (InputBufferLength < sizeof(TESTDRV_EVENT_BUFFER)) {
DebugTrace(0, Dbg, "System buffer size is too small\n", 0);
FsRtlCompleteRequest( Irp, STATUS_INVALID_PARAMETER );
return STATUS_INVALID_PARAMETER;
}
Buffer = Irp->AssociatedIrp.SystemBuffer;
#if defined(_WIN64)
}
#endif
// start using the Event Buffer
...
}
If I compare your response with this example, only bufferLength is concerned
or all parameters struct present in the IRP.
I have a difficult for understand the mecanism of adaptation 32 to 64 bit
and where adapt the code.
only where there are IRP and IOCTL exchange, in dispatch Routine ?
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
BulkUsb_DispatchDevCtrl;
DriverObject->MajorFunction[IRP_MJ_POWER] =
BulkUsb_DispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = BulkUsb_DispatchPnP;
DriverObject->MajorFunction[IRP_MJ_CREATE] =
BulkUsb_DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
BulkUsb_DispatchClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
BulkUsb_DispatchClean;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
Standard_DispatchSysCtrl;
DriverObject->DriverUnload = BulkUsb_DriverUnload;
DriverObject->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)
BulkUsb_AddDevice;
Have you got a complete example of this adaptation to 64bit ( I have
searched in DDK sample but nothing ).
Thanks a lot for your futur help
Post by Maxim S. Shatskih
Post by Moulefrite
I noticed that with an OS 64 Bit (XP/Vista/Seven) I have a problem with
deviceIoControl routine ( MAJOR : IRP_MJ_DEVICE_CONTROL).
It appears that IOCTL process are different from 32 bit OS.
If you use pointers or handles in IOCTL buffers - then yes.
typedef struct _IOCTL_BUFFER
{
...
} IOCTL_BUFFER, *PIOCTL_BUFFER;
#ifdef _WIN64
typedef struct _IOCTL_BUFFER32
{
// This is for 32bit clients of 64bit driver
// Here, use VOID *POINTER_32 instead of PVOID and HANDLE
...
} IOCTL_BUFFER32, *PIOCTL_BUFFER32;
#endif
Then the 64bit driver must call IoIs32BitProcess and use one of these structures.
The apps always use IOCTL_BUFFER, both 32 and 64 bit builds.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
.
Loading...