Answered by:
Why is ICreateDeviceAccessAsync::GetResult returning E_INVALIDARG?

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?
- Marked as answer by Eric Hanson-MSFTModerator Thursday, January 26, 2012 1:12 AM
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}).
- Marked as answer by Eric Hanson-MSFTModerator Friday, January 27, 2012 1:14 AM
Thursday, January 26, 2012 11:44 PM
All replies
-
Thunk Monkey,
I will look into this for you. Does the code work once you define the metadata?
Best Wishes - Eric
Tuesday, January 24, 2012 2:23 AMModerator -
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?
- Marked as answer by Eric Hanson-MSFTModerator Thursday, January 26, 2012 1:12 AM
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}).
- Marked as answer by Eric Hanson-MSFTModerator Friday, January 27, 2012 1:14 AM
Thursday, January 26, 2012 11:44 PM -
Hi all,
I still get invalid arg HRESULT from GetResult..
I'm using VS2011 with customer preview version.
Is there any solution?
I cannot find any resource for reference..
Thanks.
Monday, March 19, 2012 4:18 AM -
Could you try with this sample?
http://code.msdn.microsoft.com/windowsapps/Custom-device-access-sample-43bde679
Best Wishes - Eric
Tuesday, March 20, 2012 1:43 AMModerator