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

Re: Win98 & DeviceIoControl by nospam

nospam
Mon May 03 05:30:31 CDT 2004

I'm too lazy to open my old source files, sorry, but I would

DeviceIoControl( .....&m_hWnd, // Address of m_hWnd,
sizeof(HWND), ....)
.......
hWnd = *( (HANDLE*)p->lpvInBuffer);




"Simon BK" <psk_NOSPAM@mail-online.dk> wrote in message
news:eBnpqZPMEHA.3712@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Re: Win98 & DeviceIoControl by Walter

Walter
Mon May 03 05:41:31 CDT 2004

nospam@cristalink.com wrote:
> I'm too lazy to open my old source files, sorry, but I would
> DeviceIoControl( .....&m_hWnd, // Address of m_hWnd,
> sizeof(HWND), ....)
> .......
> hWnd = *( (HANDLE*)p->lpvInBuffer);

Exactly. DeviceIoControl is checking the address you supply, seeing that
it's not a valid address, and returning an error before even calling the
VxD.

--
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com

Re: Win98 & DeviceIoControl by Simon

Simon
Mon May 03 06:32:24 CDT 2004

This works, Thanks guys !!

"Walter Oney" <waltoney@oneysoft.com> wrote in message
news:409621DB.A25D38C3@oneysoft.com...
> nospam@cristalink.com wrote:
> > I'm too lazy to open my old source files, sorry, but I would
> > DeviceIoControl( .....&m_hWnd, // Address of m_hWnd,
> > sizeof(HWND), ....)
> > .......
> > hWnd = *( (HANDLE*)p->lpvInBuffer);
>
> Exactly. DeviceIoControl is checking the address you supply, seeing that
> it's not a valid address, and returning an error before even calling the
> VxD.
>
> --
> Walter Oney, Consulting and Training
> Basic and Advanced Driver Programming Seminars
> Check out our schedule at http://www.oneysoft.com