Click here to Skip to main content
11,582,850 members (76,400 online)
Rate this: bad
Please Sign up or sign in to vote.
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 at 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 at 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 at 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
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 220
2 virusstorm 209
3 Kornfeld Eliyahu Peter 165
4 Andy Lanng 139
0 OriginalGriff 1,403
1 Sergey Alexandrovich Kryukov 970
2 Abhinav S 696
3 F-ES Sitecore 505
4 Suvendu Shekhar Giri 503

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2015
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