Hi,
I am a novice C++ programmer.
I have to modify already working code of someone else to include 64 bit DeviceIoControl calls as well as 32 bit calls.
Entire 32 bit app and driver works just fine on 32 bit windows:
HANDLE hDev = CreateFile(L"\\.\wikdr",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,0);
DeviceIoControl(hDev,
IOCTL_GET_PATH,
(LPVOID)(LPCTSTR)m_FileName,
(DWORD)m_FileName.GetLength()*sizeof(WCHAR),
Buffer,
BufferSize,
BytesReturned,
NULL)
On 64 bit vista however it returns 6 ERROR_INVALID_HANDLE
from the driver at the last call.
I have been reading on the subject for the past 3 days. But it is beyond me. Can anybody please fix this code for me so that it will work with both 32 and 64 bit drivers.
Same 32 bit driver has been compiled to x64 ,signed, installed and properly running. Just need a way to communicate with it.
I have the code to the driver too, but cannot change it. Because I have no longer can sign 64 bit drivers. So, fix has to be on the 32 bit app side. hdev is a 32 bit address, because app is 32 bit and kernel expects 64.
P.S:
While debugging the app Createfile does not fail hdev returns an 32 bit address like 0x00004724 and err watch only changes after DeviceIoControl is called. 64 bit driver expects a 64 bit address not 32. This could be the cause. Not sure how to implement that though on the 32 bit app side for both 32 and 64 bit drivers, Also, other parameters of that function might need casting or extending. Not sure how to properly code that.
Please keep it real simple, if you can.
.