Using a 64-bit driver from a 32-bit application

I have a Windows application that should run as 32-bit (due to other restrictions out of my control). However, my application must call and access the driver, which may be 32-bit or 64-bit, depending on the system in which it is installed.

I access the driver through calls to DeviceIoControl (), exchanging data structures declared in the include file. Data structures contain fields declared as "DWORD_PTR" (I do not control the included file either).

My problem is that on a 64-bit system, the driver expects the structures to contain a 64-bit integer (due to the DWORD_PTR declaration). However, my 32-bit program sees these DWORD_PTR as 32-bit integers. Then I have a data mismatch between my version of the data structures program and the driver understanding of these structures.

DeviceIoControl () does not work with ERROR_INSUFFICIENT_BUFFER (the data area passed to the system call is too small). I confirmed that I am not getting this error if I pass the driver a 64-bit version of the structure.

I have some ugly options from this mess. But I wonder if anyone has any more pleasant suggestions?


Decision:

  • Declare a new copy of common structures with REAL 64-bit data fields (__int64)
  • Dynamically check OS architecture (32/64)
  • 32- 64- DeviceIoControl().

:

  • 64- . .

- , (, IDL COM-).

: Microsoft, , , IoIs32bitsProcess (irp)!

+3
2

32- 64- IoIs32BitProcess(irp) DEVICE_CONTROL 64- , . .

MSDN.

, , 32- 64- . , .

+5

#define defs, 64- ? ( ).

, 64- - , , , if32bit/if64bit, - . , - :

_ASSERT(sizeof(myStruct) == sizeof(64bitStruct)) 

, , - , , .

0

Source: https://habr.com/ru/post/1706156/


All Articles