Freigeben über


laps, lapse and lapped

I'm on a bit of a homonymic kick lately, if you haven't been able to tell, but the blogpics (that's a blog topic btw.  As I'm also on a Dr. Seuss kick lately, expect some more made up words) lend themselves to these sorts of things.

A few posts ago I made mention of a problem that I was working on with one of you, well we've finally cracked the nut.  I apologize that it took so long to find the resolution, but we're in something of a crunch mode (don't ask why, I can't tell you anyway) so I was only able to spend a little time here and there working on it.  I would have offloaded it to a counterpart to expedite the resolution, but we're all in the same boat. :)

So I present to you the problem (in a duology);

First the lapse -

There's one little tidbit we forgot to document...

Second the lapped -

...to get a IWDFFileHandleTargetFactory created with a handle returned from CreateFile, you must use FILE_FLAG_OVERLAPPED in the CreateFile call.

The real kicker here is if you don't open the handle that way, where the debugger break ends up is a bit...curious.  But that's another story.  The end result here is, you will break in the debugger if you attempt to use that handle in a subsequent CreateFileHandleTarget call.

So at the end of the day, we need to be doing something akin to this;

 {
    IWDFFileHandleTargetFactory * pFileHandleFactory = NULL;
    HANDLE TargetHandle;
    IWDFIoTarget * IoTarget;
    HRESULT hrRes = S_OK;

    //...some code removed to protect the innocent (me)

    TargetHandle = CreateFile (
        szDeviceName, // a driver outside our current stack
        GENERIC_WRITE | GENERIC_READ,
        FILE_SHARE_WRITE | FILE_SHARE_READ,
        NULL,
        OPEN_EXISTING,
        FILE_FLAG_OVERLAPPED,
        NULL);

    if (INVALID_HANDLE_VALUE == TargetHandle)
    {
       hrRes = HRESULT_FROM_WIN32(GetLastError ());

       //
       // we can't go any further with out this handle...
       //
       return hrRes;
    }

    //
    // now we've got an overlapped file handle to use
    //

    hrRes = m_FxDevice->QueryInterface (IID_PPV_ARGS(&pFileHandleFactory));
    if ((SUCCEEDED (hrRes))
    {
        hrRes = pFileHandleFactory->CreateFileHandle (
            TargetHandle,
            &IoTarget);
        if (FAILED (hrRes))
        {
            // removed some error handling here for brevity
        }
    }

    // ... more code removed 

    SAFE_RELEASE (pFileHandleFactory);
    return hrRes;
}

Thanks to Anil for the patience while we tried to work this out. ;)

So, quickly to answer a question somebody will ask somewhere; yes, the overlapped flag requirement is by design, we just....um...er..well, kind of forgot to tell everybody that.  We'll update the documents as soon as we can.

And finally, I had to retrograde my laptop to Windows XP last night.  The Sky 6 works under Vista just fine, as does the Virtual Serial Port driver for the Telescope.  But there were too many other little applications that didn't want to work under Vista, even with AppCompat mode on and running with administrator privileges.

And finally, finally, for a bit of insight to my mind, there is no greater music to code to than 50-60's Motown.  I've fallen in love w/ the Soul Street station on XM Radio and since I can stream it at work, huzzah!

 

EDIT: Yes Bob, it was me playing on Legendary.  My doggy's good, but not that good yet, she lacks opposable thumbs. ;)

*Currently playing - Marvin Gaye, Got to Give It Up (Pt.1)