473,788 Members | 3,027 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is C# support load device driver?

I wrote a simple virtual device driver int15.sys, Is C# support load the
device driver from AP?
Nov 16 '05 #1
12 13773
Steve wrote:
I wrote a simple virtual device driver int15.sys, Is C# support load the
device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #2
Nope, yoou can interact directly with them vice the DeviceIOControl API. I've done this in the past to write to area of the physical disk that win32 doesn't support.

So I guess to be able to interact with a device driver from C# you'd have to P/Invoke to DeviceIOControl

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn************ ***@msnews.micr osoft.com>

Steve wrote:
I wrote a simple virtual device driver int15.sys, Is C# support load the
device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #3
Yes, you are right, after I load device driver, I can use DeviceIOControl , I
wrote a virtual device driver, int15h.sys,
the purpose of this device driver is provide a interface to BIOS int15h, we
also modify the BIOS int15h, support
wireless/bluetooth power on/off, AP through virtual device driver, can power
on/off PC system wireless/bluetooth.

I need to load int15h.sys before I use DeviceIOControl , in C++, I found some
API
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);
GetServiceName( Path, Driver, DeviceName);
int dwStatus = DriverInstall(S CManager, Path, Driver);
int dwStatus1 = DriverStart(SCM anager, Driver);
can load the driver, my question is "Can C# support load device driver?"
"Richard Blewett [DevelopMentor]" wrote:
Nope, yoou can interact directly with them vice the DeviceIOControl API. I've done this in the past to write to area of the physical disk that win32 doesn't support.

So I guess to be able to interact with a device driver from C# you'd have to P/Invoke to DeviceIOControl

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn************ ***@msnews.micr osoft.com>

Steve wrote:
> I wrote a simple virtual device driver int15.sys, Is C# support load the
> device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]

Nov 16 '05 #4
Can you not use CreateFile to open the device?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<EA************ *************** *******@microso ft.com>

Yes, you are right, after I load device driver, I can use DeviceIOControl , I
wrote a virtual device driver, int15h.sys,
the purpose of this device driver is provide a interface to BIOS int15h, we
also modify the BIOS int15h, support
wireless/bluetooth power on/off, AP through virtual device driver, can power
on/off PC system wireless/bluetooth.

I need to load int15h.sys before I use DeviceIOControl , in C++, I found some
API
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);
GetServiceName( Path, Driver, DeviceName);
int dwStatus = DriverInstall(S CManager, Path, Driver);
int dwStatus1 = DriverStart(SCM anager, Driver);
can load the driver, my question is "Can C# support load device driver?"
"Richard Blewett [DevelopMentor]" wrote:
Nope, yoou can interact directly with them vice the DeviceIOControl API. I've done this in the past to write to area of the physical disk that win32 doesn't support.

So I guess to be able to interact with a device driver from C# you'd have to P/Invoke to DeviceIOControl

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn************ ***@msnews.micr osoft.com>

Steve wrote:
I wrote a simple virtual device driver int15.sys, Is C# support load the
device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

Frans.

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #5
Yes, before DeviceIOControl , use CreateFile to get a handle.
if not support load driver in C#, is anyone know the dllentry for
GetServiceName
DriverInstall
DriverStart
For I only found OpenSCManager from MSDN
[DllImport("adva pi32.dll")]
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);

"Richard Blewett [DevelopMentor]" wrote:
Can you not use CreateFile to open the device?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<EA************ *************** *******@microso ft.com>

Yes, you are right, after I load device driver, I can use DeviceIOControl , I
wrote a virtual device driver, int15h.sys,
the purpose of this device driver is provide a interface to BIOS int15h, we
also modify the BIOS int15h, support
wireless/bluetooth power on/off, AP through virtual device driver, can power
on/off PC system wireless/bluetooth.

I need to load int15h.sys before I use DeviceIOControl , in C++, I found some
API
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);
GetServiceName( Path, Driver, DeviceName);
int dwStatus = DriverInstall(S CManager, Path, Driver);
int dwStatus1 = DriverStart(SCM anager, Driver);
can load the driver, my question is "Can C# support load device driver?"
"Richard Blewett [DevelopMentor]" wrote:
> Nope, yoou can interact directly with them vice the DeviceIOControl API. I've done this in the past to write to area of the physical disk that win32 doesn't support.
>
> So I guess to be able to interact with a device driver from C# you'd have to P/Invoke to DeviceIOControl
>
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
>
> nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn************ ***@msnews.micr osoft.com>
>
> Steve wrote:
>
> > I wrote a simple virtual device driver int15.sys, Is C# support load the
> > device driver from AP?

>
> Aren't drivers used by the OS (windows) ? So how did you plan to use this
> driver?
>
> Frans.
>
> --
> Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
> My .NET Blog: http://weblogs.asp.net/fbouma
> Microsoft C# MVP
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
>
>
>
> [microsoft.publi c.dotnet.langua ges.csharp]
>


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]

Nov 16 '05 #6
Richard Blewett [DevelopMentor] wrote:
Nope, yoou can interact directly with them vice the DeviceIOControl API.
I've done this in the past to write to area of the physical disk that win32
doesn't support.

So I guess to be able to interact with a device driver from C# you'd have
to P/Invoke to DeviceIOControl
(just to make it clear to me, not to nittpick ;))
But isn't this just a wrapper around Windows' device manager? There is no
way you will be able to poke into hardware without a kernel space module, as
everything is virtualized: you can't simply throw an interrupt or set an
address to a value to change some hardware's internal settings (at least
that's what I know of it).

Frans.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn0dnlt0
z3*******@msnew s.microsoft.com>

Steve wrote:
> I wrote a simple virtual device driver int15.sys, Is C# support load the
> device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #7
DeviceIOControl is simply a way of passing "op-codes" to a kernel mode device driver and retrieving the results. You obviously can't *write* a device driver in C# but you can interrogate a device driver via pinvoke.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn************ ***@msnews.micr osoft.com>

Richard Blewett [DevelopMentor] wrote:
Nope, yoou can interact directly with them vice the DeviceIOControl API.
I've done this in the past to write to area of the physical disk that win32
doesn't support.

So I guess to be able to interact with a device driver from C# you'd have
to P/Invoke to DeviceIOControl
(just to make it clear to me, not to nittpick ;))
But isn't this just a wrapper around Windows' device manager? There is no
way you will be able to poke into hardware without a kernel space module, as
everything is virtualized: you can't simply throw an interrupt or set an
address to a value to change some hardware's internal settings (at least
that's what I know of it).

Frans.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<xn0dnlt0
z3*******@msnew s.microsoft.com>

Steve wrote:
I wrote a simple virtual device driver int15.sys, Is C# support load the
device driver from AP?


Aren't drivers used by the OS (windows) ? So how did you plan to use this
driver?

--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #8

"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:D4******** *************** ***********@mic rosoft.com...
Yes, before DeviceIOControl , use CreateFile to get a handle.
if not support load driver in C#, is anyone know the dllentry for
GetServiceName
DriverInstall
DriverStart
For I only found OpenSCManager from MSDN
[DllImport("adva pi32.dll")]
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);

Drivers are no different than services in Windows, they are controled
(loaded, unloaded etc..) by the SCM, but before you can do this they need to
be installed/registered into the SC database (Registry). You can do this
from C# using the System.Manageme nt classes (and the WMI class
Win32_BaseServi ce).
First you have to create a Win32_BaseServi ce class describing your driver
(supplying stuff like PathName="\Mydr ivers\MyDriver. sys") by calling
"Create" on the Win32_BaseServi ce WMI Class.
Once you have this (registration) done you can call any of the methods like
"StartServi ce", "StopServic e", "ChangeServ ice" on an instance of this WMI
class.

Willy.
Nov 16 '05 #9
All,

Thanks for the help about this issue.

Willy,

I think you answer my question, for I am new in C#, I will try figure out
how to implement based on your suggestion, really appreciated.

"Willy Denoyette [MVP]" wrote:

"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:D4******** *************** ***********@mic rosoft.com...
Yes, before DeviceIOControl , use CreateFile to get a handle.
if not support load driver in C#, is anyone know the dllentry for
GetServiceName
DriverInstall
DriverStart
For I only found OpenSCManager from MSDN
[DllImport("adva pi32.dll")]
int SCManager = OpenSCManager(n ull, null, SC_MANAGER_ALL_ ACCESS);

Drivers are no different than services in Windows, they are controled
(loaded, unloaded etc..) by the SCM, but before you can do this they need to
be installed/registered into the SC database (Registry). You can do this
from C# using the System.Manageme nt classes (and the WMI class
Win32_BaseServi ce).
First you have to create a Win32_BaseServi ce class describing your driver
(supplying stuff like PathName="\Mydr ivers\MyDriver. sys") by calling
"Create" on the Win32_BaseServi ce WMI Class.
Once you have this (registration) done you can call any of the methods like
"StartServi ce", "StopServic e", "ChangeServ ice" on an instance of this WMI
class.

Willy.

Nov 16 '05 #10

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

Similar topics

10
7215
by: Wouter van Ooijen | last post by:
I want to use Python to interface with an USB HID device (not a keyboard or mouse, just something that uses the HID driver to avoid the need for a specific driver). Is this possible in pure Python on Windows, or even better, in a portable way? Wouter van Ooijen -- ------------------------------------ http://www.voti.nl PICmicro chips, programmers, consulting
4
2573
by: dalewz | last post by:
Hi, Could sb kindly answer my following questions: Plan: I am trying to find a language to build a GUI to communicate with our device via serial port. Questions: 1. which language (VC++ or Java) is the best?
2
6981
by: nbhalala | last post by:
Hello Friends, Hi Myself Naresh (B.E. Comp. Eng) from Mumbai... I'm a Linux Device Driver Writer... I would like to learn writing Driver of "USB Devices"...BUT before that I'm presently working on "PCI ETHERNET NETWORK ADAPTER (RTL8139)" for that - reading it's Datasheet and trying to write simple backbone Driver BUT for that friend I need your Help... Resources I have/using -
2
2130
by: Claus Konrad | last post by:
Hi Anybody got an impression whether .NET 2.0 supports USB ports? I know that the Serial (COM) and parallel ports (LPT1) are included, but how is the story on USB ports? /Claus
7
4451
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
0
1546
by: am | last post by:
Hi, I have an USB hardware device that came with some (poor) software. I would like to write my own software to use the hardware in dotnet. There are no COM dll's to reference from the original software. I have read a lot in newsgroups and everywhere it is stated that "you need a device-driver" - well I got the device-driver (.sys file in windows/system32 folder)
7
2644
by: Nuno Magalhaes | last post by:
I have a problem loading a DLL file that is exactly in the same directory of the executable. The DLL is not in .NET format but can be accessed through P/Invoke. This never happened to me. My Platform Invoke looks something like this: static extern int _EnumerateDevices(out IntPtr ppDeviceList, out int
1
2024
by: =?Utf-8?B?15DXldeo158=?= | last post by:
I have recently installed my windows XP, the process went smoothly, but I had encounterd some drivers issues after the installation. I managed to solve the ethernet adapter driver issue, but I couldn't solve the audio device problem. I have tried many programs to detect which audio device I have, and using this tool : DriverGuide ToolKit, I identified it as realtek audio device. (I have an Intel motherboard)
2
3649
by: Steve | last post by:
Hi All I have a POS program (Windows app) . I am using VB.net 2005 Pro The OPOS drivers freezes my program if Parallel port is configured for the Receipt printer and the Printer is not connected or is turned off The freezing happens when I try to Claim the device e.g I am using a .net assembly OPOSPOSPrinter.dll
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.