Hi
I'm trying to a communicate with a VxD that I have developed :
Using Windows98 FE, but I dont know if this has any significance.
VxD code snippet:
DWORD _cdecl OnW32Deviceiocontrol(PDIOCPARAMETERS p)
{
DWORD dwRet;
Debug_Printf("MyDrv : OnW32Deviceiocontrol entered : dwIoControlCode =
%d \n", p->dwIoControlCode );
switch (p->dwIoControlCode)
{
case DIOC_OPEN:
{
Debug_Printf("MyDrv:DIOC_OPEN\n");
dwRet = 0;
}
break;
case DIOC_CLOSEHANDLE:
{
Debug_Printf("MyDrv:DIOC_CLOSEHANDLE\n");
dwRet = 0;
}
break;
case EVENTVXD_REGISTER:
{
Debug_Printf("MyDrv: EVENTVXD_REGISTER\n");
hWnd = (HANDLE)p->lpvInBuffer;
appThread = Get_Cur_Thread_Handle();
bClientRegistered = TRUE;
dwRet = 0;
}
break;
case EVENTVXD_RELEASEMEM:
{
_HeapFree((PVOID)p->lpvInBuffer, 0);
return 0;
}
default:
{
Debug_Printf("Default\n");
dwRet = ERROR_NOT_SUPPORTED;
}
}
return dwRet;
}
Win32 code snippet :
TCHAR VxDName[] = _T("\\\\.\\MyDRV.VXD");
m_hDevice = CreateFile(
VxDName,
0,
0,
0,
0,
FILE_FLAG_DELETE_ON_CLOSE,
(HANDLE) NULL);
if (m_hDevice == INVALID_HANDLE_VALUE)
{
DWORD err;
err = GetLastError();
CString str;
str.Format("Cannot load VxD, error=%08lx", err);
MessageBox(str,"",MB_OK);
m_hDevice = NULL;
DestroyWindow();
return 0;
}
else
{
DWORD dwReturn;
HWND hWnd = m_hWnd;
if ( !DeviceIoControl(m_hDevice, EVENTVXD_REGISTER, m_hWnd,
sizeof(HWND), NULL, 0, &dwReturn, NULL))
{
CString str;
str.Format("DeviceIoControl failed handle = 0x%X, Nput =
0x%X, error=0x%X\n", m_hDevice, m_hWnd, GetLastError());
MessageBox(str,"",MB_OK);
m_hDevice = NULL;
DestroyWindow();
return 0;
}
}
I can open the VxD from my program, but I can't communicate using
DeviceIoControl.
Device IoControl return FALSE and GetLastError return
ERROR_INVALID_PARAMETER.
What am I doing wrong.
TIA
Simon