Click here to Skip to main content
11,709,955 members (80,280 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 Sergey Alexandrovich Kryukov 549
1 OriginalGriff 255
2 Peter Leow 174
3 Abhinav S 110
4 Suvendu Shekhar Giri 90
0 Abhinav S 60
1 Member 4653839 40
2 barneyman 35
3 Sergey Alexandrovich Kryukov 35
4 Member 11793820 35

Advertise | Privacy | Mobile
Web01 | 2.8.150819.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