473,394 Members | 1,951 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,394 software developers and data experts.

DeviceIoControl

I am looking for information on using the [DeviceIoControl] Win32 API
procedure, or its equivalent in C#. I have looked but can find no
satisfactory references.

I am working on an existing product that has a few kernel components (device
and filter drivers) and I need to be able to communicate with these
components. I am replacing some older C++ code that used [DeviceIoControl]
to perform this communication. Also, there is some low level information,
such as drive geometry, that can be retrieved by sending
[IOCTL_DISK_GET_DRIVE_GEOMETRY] to a device object.

One reference speaks of placing the calls in unmanaged C++ code and expose
these classes to the .Net applications, but I would prefer to use all
managed code.

Another approach speaks of using PInvoke. This seems to be overly
complicated.

I did find a reference that indicated that 'sequential structure layouts'
could be used to define the structures passed into and received from the
kernel components, and that the API calls could be defined using [DllImport]
declarations. This seems more promising, but it requires that I define all
of the structures myself (they are already defined in the API), and it is
not clear how variable length structures would be handled.

Are there any simpler interfaces for communciating directly with kernel
components? Is there a ,Net replacement for [DeviceIoControl]? Is there a
better way of using this API?

-Ken
Nov 15 '05 #1
2 2819
Ken,
One reference speaks of placing the calls in unmanaged C++ code and expose
these classes to the .Net applications, but I would prefer to use all
managed code.
Well you could use Managed C++ if you want.

Another approach speaks of using PInvoke. This seems to be overly
complicated.

I did find a reference that indicated that 'sequential structure layouts'
could be used to define the structures passed into and received from the
kernel components, and that the API calls could be defined using [DllImport]
declarations. This seems more promising
This *is* P/Invoke.

and it is not clear how variable length structures would be handled.


See if this helps

http://www.dotnetinterop.com/faq/?q=...leLengthStruct

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
Use the System.Management classes WMI to read driver information such as
drive geometry.

Willy.

"Ken Allen" <ke******@sympatico.ca> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I am looking for information on using the [DeviceIoControl] Win32 API
procedure, or its equivalent in C#. I have looked but can find no
satisfactory references.

I am working on an existing product that has a few kernel components
(device
and filter drivers) and I need to be able to communicate with these
components. I am replacing some older C++ code that used [DeviceIoControl]
to perform this communication. Also, there is some low level information,
such as drive geometry, that can be retrieved by sending
[IOCTL_DISK_GET_DRIVE_GEOMETRY] to a device object.

One reference speaks of placing the calls in unmanaged C++ code and expose
these classes to the .Net applications, but I would prefer to use all
managed code.

Another approach speaks of using PInvoke. This seems to be overly
complicated.

I did find a reference that indicated that 'sequential structure layouts'
could be used to define the structures passed into and received from the
kernel components, and that the API calls could be defined using
[DllImport]
declarations. This seems more promising, but it requires that I define all
of the structures myself (they are already defined in the API), and it is
not clear how variable length structures would be handled.

Are there any simpler interfaces for communciating directly with kernel
components? Is there a ,Net replacement for [DeviceIoControl]? Is there a
better way of using this API?

-Ken

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.