|
Prev: Need assistance with DPinst
Next: Linking a dll or a lib file developped in C++ using Visual Studio
From: Peter on 28 Apr 2008 04:28 Hi, I had used following technique in communication user-mode app <--> driver: User app passes event handle to driver and driver retrieves pointer to object body with help of ObReferenceObjectByHandle() . Driver then signals some events to user mode application with KeSetEvent(). Problem is: Currently I have 32-bit user mode app which communicates with 64-bit driver. When 64-bit driver reads 32-bit HANDLE (32-bit number) passes from user-mode, can it simple make conversion like: HANDLE h64Bit = NULL; h64Bit = (HANDLE)h32BitFromUserMode; ? Will be retrieved handle in 64-bit driver valid and can be on such called KeSetEvent() in 64-bit driver ? Peter
From: Gianluca Varenni on 28 Apr 2008 12:09 "Peter" <Peter(a)discussions.microsoft.com> wrote in message news:2C2B95B6-23D8-4D62-BCC3-52C53EA8754A(a)microsoft.com... > Hi, > > I had used following technique in communication user-mode app <--> driver: > > User app passes event handle to driver and driver retrieves pointer to > object body with help of ObReferenceObjectByHandle() . > Driver then signals some events to user mode application with > KeSetEvent(). > > Problem is: > Currently I have 32-bit user mode app which communicates with 64-bit > driver. > When 64-bit driver reads 32-bit HANDLE (32-bit number) passes from > user-mode, can it simple make conversion like: > HANDLE h64Bit = NULL; > h64Bit = (HANDLE)h32BitFromUserMode; > ? > Will be retrieved handle in 64-bit driver valid and can be on such called > KeSetEvent() > in 64-bit driver ? Yes, it works. One bit of advice, however. In your IOCTL code in the driver, you definitely need to distinguish between a 32-bit app and a 64-bit one, in order to properly parse the HANDLE passed from user mode (which can be a 32 or a 64bit integer). In case of WDM, the code is more or less this one .... HANDLE hUserEvent; PKEVENT pKernelEvent; #ifdef _AMD64_ VOID*POINTER_32 hUserEvent32Bit; #endif //_AMD64_ .... #ifdef _AMD64_ if (IoIs32bitProcess(Irp)) { // // validate the input // if (IrpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof (hUserEvent32Bit)) { SET_FAILURE_INVALID_REQUEST(); break; } hUserEvent32Bit = *(VOID*POINTER_32*)Irp->AssociatedIrp.SystemBuffer; hUserEvent = hUserEvent32Bit; } else #endif //_AMD64_ { // // validate the input // if (IrpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof (hUserEvent)) { SET_FAILURE_INVALID_REQUEST(); break; } hUserEvent = *(PHANDLE)Irp->AssociatedIrp.SystemBuffer; } Status = ObReferenceObjectByHandle(hUserEvent, EVENT_MODIFY_STATE, *ExEventObjectType, Irp->RequestorMode, (PVOID*) &pKernelEvent, NULL); Hope it helps GV -- Gianluca Varenni, Windows DDK MVP CACE Technologies http://www.cacetech.com > > Peter >
|
Pages: 1 Prev: Need assistance with DPinst Next: Linking a dll or a lib file developped in C++ using Visual Studio |