Synchronization Problems
From: Christopher Lansing (c_lansing_at_hotmail.com)
Date: 10/29/04
- Next message: Pavel A.: "Re: bandwidth limit"
- Previous message: Zhou: "Re: USB question"
- Next in thread: Pavel A.: "Re: Synchronization Problems"
- Reply: Pavel A.: "Re: Synchronization Problems"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 29 Oct 2004 00:01:20 -0400
I am having a strange problem with the _VWIN32_WaitSingleObject service.
If the object is signaled before _VWIN32_WaitSingleObject is called,
then it works fine, if the object is not signaled, but I provide a
timeout and allow it to expire, it works fine. However if the object is
signaled while the driver is waiting, then it produces a familiar shade
of blue on my screen, attached to "A fatal exception 0E has occurred at
0028:00000026."
In case that's not enough, let me explain a little of what I'm trying to do.
I am writing a driver that needs to hook some VCOMM services to allow
for user interaction with the process. For my purposes here I'll use an
example of providing a user information about what port is being opened.
Further more, I wish to provide these notifications in Ring 3, and
keep as much code as possible out of Ring0. Now for the final curve
ball, I don't want the _VCOMM_OpenPort service to return until the user
has had a chance to view the information.
In order to provide the information to the user, and then wait, I have
set up a Ring 3 application that loads the device driver, and uses
DeviceIOControl to provide the driver with the address for an APC
routine, and a Ring0 handle to an event created for the purpose of
waiting. The application then enters an alertable sleep. The driver
hooks the _VCOMM_OpenPort service, and when that hook is called, my
driver first queues the APC, then waits on the previously provided
handle. When the user is done, the Ring3 application signals the
object, and the driver should continue, call the real _VCOMM_OpenPort,
and finish opening the port.
The part of the application code used to set up the event and callback
is (with error checking stripped out)
. . .
HANDLE hVxD = CreateFile(VXD_NAME, 0, 0, NULL, 0,
FILE_FLAG_OVERLAPPED | FILE_FLAG_DELETE_ON_CLOSE, NULL);
hWaitObject = CreateEvent(NULL, FALSE, FALSE, NULL);
dwVxDWait = OpenVxDHandle(hWaitObject);
PORTCALLBACKS pc;
pc.dwVxDWaitHandle = dwVxDWait;
pc.OpenProc = PortOpenAPC;
DWORD bytesRet;
DeviceIoControl(hVxD, SETCALLBACKINFO, &pc, sizeof pc, NULL, 0,
&bytesRet, NULL);
SleepEx(INFINITE, TRUE);
. . .
The test function PortOpenAPC is simply (for now)
VOID CALLBACK PortOpenAPC(ULONG_PTR dwParam) {
MessageBox(NULL, "PortOpen", "PortOpen", MB_OK);
SetEvent(hWaitObject);
}
And the driver code in the apparent problem area is
. . .
push eax
push ebx
push edx
VxDCall _VWIN32_QueueUserAPC <[PortOpenAPC], 0, [hThread]>
mov ebx, [hWait]
mov edx, -1
mov eax, FALSE
VxDCall _VWIN32_WaitSingleObject
pop edx
pop ebx
pop eax
. . .
This code is part of the hook routine on _VCOMM_OpenPort. PortOpenAPC,
hWait, and hThread are all obtained during a DeviceIOControl call. I
know the APC is working because I do get the message box, but when the
signal is triggered, I blue screen.
Has anybody seen anything like this before? Even more hopeful, does
anyone know what the problem might be, and how to fix it? (and by the
way, it does have to be compatible with all Windows 9x based systems)
Thanks in Advance,
Christopher Lansing
- Next message: Pavel A.: "Re: bandwidth limit"
- Previous message: Zhou: "Re: USB question"
- Next in thread: Pavel A.: "Re: Synchronization Problems"
- Reply: Pavel A.: "Re: Synchronization Problems"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|