Unless you can modify this interface DLL, there is no way for you to make
the interface work on x64.
It might be possible to redesign the driver to supply fake 32-bit values
to the UM DLL that cause it to pass back fake 32-bit values that you can use
(i.e. convert from a pointer to a handle), and IMHO this would be an
excellent change to your interface, but you will need to carefully study
your source to see if this is possible.
In this case, instead of ULONGLONG as Tim suggests, the field would be DWORD
or variant of unsigned __int32, but the principal is the same: a CONSTANT
size across all platforms.
It is also possible, as I previously mentioned to use a variable sized
structure to solve this problem; but if you can;t modify the DLL source then
I doubt that this is a viable option for you
“Osman TOKER” wrote in message news:xxxxx@ntdev…
In our design, there is extra dll file app used and it is out of my
control(edit) so it confused me. I changed everything you said in my
driver codes but it seems that dll files must be changed however
compiled under 64 bit system.
Osman
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, March 10, 2011 7:57 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 32 bit application for 64 bit driver
Osman TOKER wrote:
I think there is a problem about base adresses; DLL files is a bridge
of driver codes and application. This addresses is 64 bit in the
kernel mode but they defined as 32 bit in the DLL. If application use
them, it takes the wrong addresses. (BSOD: mov rax, qword
ptr[rax+r8*2].
You still misunderstand the situation here.
As I recall, you have a driver model in which the driver sends an
“address cookie” to the application, and the application hands that back
to the driver at a later point. Am I remembering correctly?
To use that model in a 64-bit system, the “address cookie” field MUST be
defined as a 64-bit type. It does not need to be a pointer, because the
user-mode application cannot do anything with that value. It’s just a
number with no meaning to the application, exactly like a window handle
or a file handle. You also cannot have it be something like a
DWORD_PTR, because that has a different size in a 32-bit app and a
64-bit app. The field must ALWAYS be 64-bits, regardless of the size of
the app or the size of the driver.
You need to remember how many different combinations there are, and be
prepared for all of them. You could have your 32-bit app call a 32-bit
driver, or a 32-bit app call a 64-bit driver, or a 64-bit app call a
64-bit driver. Your ioctl structure must handle all of those
combinations.
That means you need to change the structures that you pass in your ioctl
so that the field is declared as “unsigned __int64” or “ULONGLONG”.
That applies everywhere. You will need to do that whether the
application is 32-bit or 64-bit. You could declare your own type for
this, like:
typedef unsigned __int64 MYHANDLE;
You CANNOT define this field as a “void *”, even in the driver. The
field must always be 64 bits. So, your driver will need to have code to
cast the value to a pointer before it can be used. When you have a
32-bit driver, the top half of the structure field will be 0, but it
MUST be there.
This means you now have a backwards compatibility problem. Once you
make that change, your application will not work with the drivers you
have already released. Because of that, you might want to change the
ioctl number to make sure there are no “accidents”.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
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