473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

DeviceIoControl fails

hi,
I am using MSVADSimple from Microsoft WDK as my reference driver.I am able to get the instance of MSVADSimple driver but when i call DeviceIoControl method and pass the handle to it fails why?

I would like to share the code snippet as follows...

Expand|Select|Wrap|Line Numbers
  1.  
  2. //Generating the device info
  3. SetupDiGetClassDevs( &KSCATEGORY_AUDIO, NULL, NULL,  DIGCF_PRESENT|DIGCF_DEVICEINTERFACE );
  4.  
  5. //Enumerating device interface
  6. SetupDiEnumDeviceInterfaces(dev_info, &DeviceInfoData, &KSCATEGORY_AUDIO, i, &did);
  7.  
  8. //Getting the path to device (pdd)
  9. bRes = SetupDiGetDeviceInterfaceDetail(dev_info, &did, pdd, required_size, NULL, NULL);
  10.  
  11. //Handle to the device
  12. HANDLE hHandle = CreateFile( pdd->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
  13.             FILE_ATTRIBUTE_NORMAL, NULL);
  14.  
  15. //Passing the Handle
  16. //PData is the Out buffer where we get the driver sending value
  17. bool bRc = DeviceIoControl ( hHandle,
  18.                          (DWORD)IOCTL_SIOCTL_METHOD_OUT_DIRECT,  NULL, 0, &PData,
  19.                sizeof( PData), &bytesReturned, NULL );
  20.  
  21.  
I get correct handle from CreateFile but problem is that why DeviceIoControl fails though i get PData value whatever returned from audio driver (bytesReturned always shows a random value).Could you please suggest me what's wrong with me?

Thanks
Jan 20 '12 #1
0 1509

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ewoo | last post by:
I'm trying to write a wrapper in csharp to wrap DeviceIoControl() win32 method for IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS control code--without much luck. I've seen lots of examples out there for...
2
by: Jules Crown | last post by:
Everyone, greetings, newbee here. What I'm trying to do is to compress files on NTFS from C#. I've been fishing around for info and gathered the hereafter. I'd like to know what's wrong with...
2
by: Michael Allen | last post by:
I would like to perform something similar to the below function in C# .NET. The C++ below code is from a Microsoft DDK sample driver application. Specifically, I would like to perform Device I/O...
3
by: Jacky | last post by:
Hi, I am trying to make network card interface with VB.NET 2002. I use DeviceIOControl-function. I have tried to define inbuffer and outbuffer using byte array and it's pointer. The second I...
1
by: Pixie | last post by:
I am trying to query the change journal using the deviceIOControl API. The API doesn't return an error, but all of the values in the output buffer are zero, and they shouldn't be. My code is below. I...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
1
by: Juan Pedro Gonzalez | last post by:
Helo, I'm having problems here with the input buffer.... Ive defined the API call as: <System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _ Private Shared Function...
5
by: Lou | last post by:
is there a VB .NET way to use the API "DeviceIoControl"? -Lou
0
by: Andrew | last post by:
Hello I am trying to port some code and I am running into some issues I may or may not be able to solve on my own and would appreciate your help Basically I am trying to open the Tun Driver...
4
by: =?Utf-8?B?TWFyaW5h?= | last post by:
Does any know any sample of how to do a basic DeviceIoControl with something like IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2 in C# I have been stuck all week :( and google doesnt yield anything of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.