locked
Why is ICreateDeviceAccessAsync::GetResult returning E_INVALIDARG? RRS feed

  • Question

  • I am trying to access a custom driver using IO control codes from a Metro app.  I have already done this successfully using a desktop app.  I am doing the following for the Metro app:

    ICreateDeviceAccessAsync *access;
    HRESULT hr = CreateDeviceAccessInstance(IID_IDeviceIoControl, L"\\\\.\\MyDevice", GENERIC_READ | GENERIC_WRITE, &access);
    if (SUCCEEDED(hr))
    {
        hr = access->Start();
        if (SUCCEEDED(hr))
        {
            hr = access->Wait(INFINITE);
            if (SUCCEEDED(hr))
            {
                IDeviceIoControl *control;
                hr = access->GetResult(reinterpret_cast<void **>(&control));
                if (SUCCEEDED(hr))
                {
                }
            }
        }
        access->Release();
    }
    

    The GetResult call is returning E_INVALIDARG.  I have not configured the device metadata for my driver, so I would expect this call to return E_ACCESSDENIED instead.  Why would this call return E_INVALIDARG?

    Tuesday, January 10, 2012 1:35 AM

Answers

  • I have not yet defined metadata for my driver, but in that case I would expect E_ACCESSDENIED instead of E_INVALIDARG.

    One thing I noticed is that if I use a device path that begins with \\?\ instead of \\.\, I get a "not found" error or an "access denied" error instead of an "invalid argument" error.  This suggests to me that CreateDeviceAccessInstance cannot accept a symbolic or MS-DOS device name the same way that CreateFile can.  Is this true?

    Wednesday, January 25, 2012 2:37 AM
  • You're correct; the API only works for device interface paths (e.g. \\?\USB#VID_0B0E&PID_2007#5&28ab2847&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}).

    Thursday, January 26, 2012 11:44 PM

All replies