Click here to Skip to main content
13,194,662 members (70,705 online)
Rate this:
Please Sign up or sign in to vote.
See more:
We are developing an windows 8 store device app using C# which will communicate to the device using Win32 API and IOCTL calls in a C dll. We had created a C dll with Create File and some IOCTL calls, imported in C# application. Integration goes well and when Create File function is called, it returns 'ACCESS DENIED ERROR'. We had also tried creating Manifest with requested Execution level to Administrator but still the issue is not solved. I would like to know whether Win32 API & IOCTL calls can be used directly or do I need to use any wrapper calls to make it work?

Thanks in advance.
Posted 15-Nov-12 0:32am
Richard MacCutchan 15-Nov-12 10:05am
ACCESS DENIED means you are trying to create a file in a directory which does not allow it, based on your access level. The first thing to do is to resolve this issue.
Member 9601527 16-Nov-12 9:02am

For the above said question, I got the ppt from MSFT (refer below link)
I tried implementing "CreateDeviceAccessInstance" and IDeviceIoControl API for getting the handle and accessing the device but I'm getting E_INVALIDARG for function call to GetResult(). My sequence is as follow
1. ICreateDeviceAccessAsync *pDeviceAccess
2. CreateDeviceAccessInstance (FilePath, GENERIC_READ|GENERIC_WRITE, &pDeviceAccess) - SUCCEEDS
3. pDeviceAccess->Wait(INFINITE) - SUCCEEDS
4. IDeviceIoControl *pDeviceControl
5. pDeviceAccess->GetResult(IID_IDeviceIoControl, (void **)&pDeviceControl) - Fails with E_INVALIDARG error code
Any suggestions would be helpful.

Thanks in Advance.
Member 9601527 19-Nov-12 4:52am
Step 5: Instead of using pDeviceAccess->GetResult(), I had used pDeviceAccess->QueryInterface(). The interface returned is typecasted to DeviceIoControl pointer. Now I don't get E_INVALIDARG. But while issuing the IOCTL as per below, I get E_UNEXPECTED error code.

6. pDeviceControl->DeviceIoControlSync(FSCTL_GET_RETRIEVAL_POINTERS, (UCHAR *) <Pointer to Starting VCN input buffer>, sizeof(STARTING_VCN_INPUT_BUFFER), (UCHAR *) <Pointer to retrieval buffer pointer>, sizeof(retrieval buffer structure), &dwBytesReturned);

Any input would be great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171018.2 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100