Synchronization Problems

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Christopher Lansing (c_lansing_at_hotmail.com)
Date: 10/29/04


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



Relevant Pages

  • Re: Hints to write a clock driver
    ... no kernel driver involved. ... There are various DCF77 drivers in the ntp source tree. ... the basic heartbeat of ntpd is at once per sec. Going faster will ... So you enter new terrain here especially since ntpd makes use of signals ...
    (comp.protocols.time.ntp)
  • Re: this JTAG thing is a joke
    ... This was also shown to be necessary in the simulations. ... signals are weak. ... The JTAG methods for specifying an endpoint are ... Standard driver interface. ...
    (comp.arch.fpga)
  • Re: Why flashing headlights is poor driving.
    ... There was a pedestrian on that island ... raised his arm to wave at the approaching driver. ... just sat there waiting for the car to pass. ... When I am sure we have come to a complete understanding, I will give my permission for him to pass the signal at danger and to obey all other signals. ...
    (uk.rec.driving)
  • Re: How do YOU react to being cut up?
    ... Intent to do what, exactly? ... It's only intended for the tailgating driver behind me. ... "Pointing and waving is worse than flashing - you are directly ... a good driver will not give misleading signals. ...
    (uk.rec.driving)
  • Re: kernel 2.6.8 pwc patches and counterpatches
    ... > If you could get each and every author of SMP support to agree, ... Did I ever revoke the sisfb or my XFree86/X.org driver license? ... Hook or no hook. ... You provide a binary-only module which entirely replaces the mainline ...
    (Linux-Kernel)