Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Develop driver 32/64 bit (IA & AMD64) for XP, Vista & Seven for WH

Reply
Thread Tools Display Modes

Develop driver 32/64 bit (IA & AMD64) for XP, Vista & Seven for WH

 
 
Moulefrite
Guest
Posts: n/a

 
      09-01-2010
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/libr...=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.


 
Reply With Quote
 
 
 
 
Don Burn
Guest
Posts: n/a

 
      09-01-2010
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




"Moulefrite" <> wrote in message
news:E6180A95-8A30-4F1D-8EE0-:

> 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/libr...=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.


 
Reply With Quote
 
Moulefrite
Guest
Posts: n/a

 
      09-01-2010
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,


"Don Burn" wrote:

> 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
>
>
>
>
> "Moulefrite" <> wrote in message
> news:E6180A95-8A30-4F1D-8EE0-:
>
> > 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/libr...=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.

>
> .
>

 
Reply With Quote
 
Don Burn
Guest
Posts: n/a

 
      09-01-2010
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




"Moulefrite" <> wrote in message
news:B17F6519-DED2-45CC-9ACC-:

> 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,
>
>
> "Don Burn" wrote:
>
> > 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
> >
> >
> >
> >
> > "Moulefrite" <> wrote in message
> > news:E6180A95-8A30-4F1D-8EE0-:
> >
> > > 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/libr...=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.

> >
> > .
> >


 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      09-01-2010
> 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+.

> 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.

> 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

 
Reply With Quote
 
Moulefrite
Guest
Posts: n/a

 
      09-02-2010
Hi Don Burn and thanks a lot for this link,
Now I can catch debugPrint info with debugView launched in remote debug.

"Don Burn" wrote:

> 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
>
>
>
>
> "Moulefrite" <> wrote in message
> news:B17F6519-DED2-45CC-9ACC-:
>
> > 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,
> >
> >
> > "Don Burn" wrote:
> >
> > > 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
> > >
> > >
> > >
> > >
> > > "Moulefrite" <> wrote in message
> > > news:E6180A95-8A30-4F1D-8EE0-:
> > >
> > > > 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/libr...=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.
> > >
> > > .
> > >

>
> .
>

 
Reply With Quote
 
Moulefrite
Guest
Posts: n/a

 
      09-02-2010
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,


"Maxim S. Shatskih" wrote:

> > 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+.
>
> > 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.
>
> > 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
>
> .
>

 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      09-02-2010
> 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



http://www.storagecraft.com

 
Reply With Quote
 
Moulefrite
Guest
Posts: n/a

 
      09-02-2010
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/libr...=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

"Maxim S. Shatskih" wrote:

> > 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
>
>
>
> http://www.storagecraft.com
>
> .
>

 
Reply With Quote
 
Satya
Guest
Posts: n/a

 
      09-08-2010
Yes the "adaptation"s would be in dispatch routines (such as
BulkUsb_DispatchDevCtrl)

Satya
http://www.winprogger.com


"Moulefrite" wrote:

> 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/libr...=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
>
> "Maxim S. Shatskih" wrote:
>
> > > 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
> >
> >
> >
> > http://www.storagecraft.com
> >
> > .
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the different for PNPDTest between WLK 1.5 and WLK 1.2 Wayne Windows Vista Drivers 2 01-18-2010 08:32 PM
How do you repair windows entirely using your Windows Vista DVD Jonathan Yaniv- Windows Live Butterfly Expert Windows Vista Performance 16 02-12-2008 06:28 PM
Game Compatibility BCurrey Windows Vista Games 6 11-29-2007 08:11 PM
crcdisk.sys start up problem (with boot log) Jimmy Windows Vista Hardware 2 08-13-2007 07:22 PM
Missing VGA driver rh0000 Windows Vista Hardware 14 06-13-2007 10:21 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59