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().
:
- , (, IDL COM-).
: Microsoft, , , IoIs32bitsProcess (irp)!