Answered by:
GetResult() returns E_ACCESSDENIED use dymanic dll

Question
-
I write a dymanic dll for metor style apps and desktop mode used.
And use LoadPackagedLibrary to load a DLL form metro style app.
Metro Style app Code:
HINSTANCE LibHandle2; LibHandle2 = LoadPackagedLibrary(L"XXX", 0); DWORD error = GetLastError(); POUTPUT p2 = (POUTPUT)GetProcAddress(LibHandle2, "Test"); int n2 = (*p2)();
DLL Code:
ComPtr<ICreateDeviceAccessAsync> access; ComPtr<IDeviceIoControl> deviceControl; hr = CreateDeviceAccessInstance(L"DevicePath", GENERIC_READ | GENERIC_WRITE, &access); hr = access->Wait(INFINITE); THROW_HR(hr); hr = access->GetResult(IID_PPV_ARGS(&deviceControl));
It occur E_ACCESSDENIED 0x80070005 General access denied error at hr = access->GetResult(IID_PPV_ARGS(&deviceControl));
I have gone through the BUILD conference video and aware of (1) application manifest, (2) device metadata and (3) privileged interface property.
I have done all that and use MoFX2App (no code change) sample code successfully.
Can we use Win32DLL project "CreateDeviceAccessInstance and IDeviceIoControl " to communication with the driver?
- Edited by Robert.wang Thursday, April 19, 2012 7:30 AM
Wednesday, April 18, 2012 8:00 AM
Answers
-
Hello,
Which the DLL project did you create?
You should use this templates
"Visual C++ -> Windows Metro style -> Blank Dynamic-Link Library" or "Visual C++ -> Windows Metro style -> WinRT Component DLL".For more information, please check:
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/64fad5ed-8248-48ec-9d57-7a9128bc4032Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
- Marked as answer by Jesse Jiang Monday, May 7, 2012 2:45 AM
Thursday, April 19, 2012 7:44 AM
All replies
-
Hello,
Which the DLL project did you create?
You should use this templates
"Visual C++ -> Windows Metro style -> Blank Dynamic-Link Library" or "Visual C++ -> Windows Metro style -> WinRT Component DLL".For more information, please check:
http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/64fad5ed-8248-48ec-9d57-7a9128bc4032Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
- Marked as answer by Jesse Jiang Monday, May 7, 2012 2:45 AM
Thursday, April 19, 2012 7:44 AM -
I use this templates.
"Visual C++ -> Win32 -> Win32 Project ->DLL
Is it support to communication with the driver use "CreateDeviceAccessInstance and IDeviceIoControl" API?
Is it Only "Visual C++ -> Windows Metro style -> Blank Dynamic-Link Library" and "Visual C++ -> Windows Metro style -> WinRT Component DLL" templates that we can use to communication with the driver?
Thursday, April 19, 2012 11:00 AM -
Hello,
The Win32 template can add the WinRT namespace, you should enable /ZW and disable /GM-, and then include the metadata file into your project.
The template for WinRT Component DLL will be more convenient.
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Wednesday, April 25, 2012 7:59 AM