:confused:
Could someone advise how to write a device driver for WinNT using MASM32 ?
Are there on the Net any examples of device drivers for WinNT / 2000 coded in Win32Asm / asm ?

Thank you very much in advance for any examples, links.
Posted on 2001-08-26 07:07:30 by Ola
Ola:

Well I was going to save this for my tutorial but due to the loss of my previous job I have not had any available time to make any progress on it (I was working on converting a C example into Win32 ASM and doing a tutorial on the subject).

Located within the attached archive you will find a NT based driver written in both C (not by me, I took it from one of my Nt Device Driver books and added some comments) and Win32 Assembly (this done by myself). You will also find the needed include files and an installer (also borrowed from some place else).

Everything is in rough form (it has been a long time since I have even looked at it) so please forgive the mess.

Should you have any questions that are not covered by the sample then please let me know.

Also, please let me know how useful you find the sample.

Thanks.

:alright:
Posted on 2001-08-27 17:17:26 by madprgmr
MadPrgmr:
Many thanks for your examples. I did not study the codes closely yet, but for the first time it is always hard and ANY samples are very helpful, Thanks again.


I am particularly interested in reading/writing data from/to COM Port under Windows NT with a device driver.

I would very appreciate any ideas, samples how to do that with a driver, or maybe there is a solution to send/receive data to/from COM Port without driver. (I can do that under Win 98/ME, at least there are many asm codes in Windows 98 DDK and for some reason there are nothing in assembler in Windows NT 4.0 DDK !? Under NT I do not have any idea how to start, please help...):(

Thanks
Posted on 2001-08-28 10:56:19 by Ola
Now i writing app and use my COM unit.
Of course, many macros and other units hide some piece of code, but...
If you interested in i can help
Posted on 2001-08-28 11:37:41 by Alexey
I am particularly interested in reading/writing data from/to COM Port under Windows NT with a device driver


Ola:

I am sorry to say that I my experiences have not been in the area of COM port drivers under any platform. About the only input that I can supply along these lines is taken from my dealings with other types of hardware via ports:

Before you can access any port (if you want to do it by the book and make it a true NT based designed app, otherwise you can use the in/out instructions and run the risk of corrupting the HAL at some point down the line) you need to convert the port number to a system-relative port address (Take a look at HalTranslateBusAddress and then MmMapIoSpace). Once you have obtained a system-relative port address you can the use any of the following functions to access the port:

READ_PORT_BUFFER_UCHAR
READ_PORT_BUFFER_ULONG
READ_PORT_BUFFER_USHORT
READ_PORT_UCHAR
READ_PORT_ULONG
READ_PORT_USHORT
READ_REGISTER_BUFFER_UCHAR
READ_REGISTER_BUFFER_ULONG
READ_REGISTER_BUFFER_USHORT
READ_REGISTER_UCHAR
READ_REGISTER_ULONG
READ_REGISTER_USHORT
WRITE_PORT_BUFFER_UCHAR
WRITE_PORT_BUFFER_ULONG
WRITE_PORT_BUFFER_USHORT
WRITE_PORT_UCHAR
WRITE_PORT_ULONG
WRITE_PORT_USHORT
WRITE_REGISTER_BUFFER_UCHAR
WRITE_REGISTER_BUFFER_ULONG
WRITE_REGISTER_BUFFER_USHORT
WRITE_REGISTER_UCHAR
WRITE_REGISTER_ULONG
WRITE_REGISTER_USHORT

for some reason there are nothing in assembler in Windows NT 4.0 DDK


Once you have the driver structer out of the way (just use the hello world sample driver contained within my previously attached file as a template) the trouble in converting C drivers to assembly is greatly reduced. I find that the fastest way to ensure that you have a clean translation (meaning one that is going to work properly) is to take a look at how the C driver is working (using SoftIce) and then take a look at your assembly made driver. By doing this you can quickly compare function setup's and return results.

I know that the above response is not exactly what you are looking for but I hope that it helps in some way.
Posted on 2001-08-28 12:33:46 by madprgmr
How to Write NT Services in Assembly Language by Cynical Pinnacle.

This tutorial teaches you step by step on how to write NT services in asm. Concise and to the point, this is a must read for NT lovers. Come with source code of a simple beep service which you can use to learn about NT services.

http://win32asm.rxsp.com/beepserv.txt

ancev
Posted on 2001-08-28 21:30:01 by ancev
Alexey:
Thanks for suggestion.

On my experience by now it seems that it is possible to read and write data from and to COM Port under Windows NT using functions like CeateFile, SetUpComm, ReadFile, WriteFile, CloseHandle just the same as under Windows 98.
It is a solution, and it works.

But I need some examples with interrupts, where an application can intercepts interrupts and reacts on them.

Does anyone have any ideas how to intercept interrupt under Windows NT? (for example interrupts from KeyBoard, COM Port, LPT Port, like showen in some Win 98 DDK asm samples)

MadPrgmr:
I think it's not a bad idea to use SoftIce, mayby I'll try something
like that.

Thanks
Posted on 2001-09-10 10:58:51 by Ola
Does anyone have any ideas how to intercept interrupt under Windows NT? (for example interrupts from KeyBoard, COM Port, LPT Port, like showen in some Win 98 DDK asm samples)


Ola:

Check out the the following functions (in the NT DDK help):
1) IoConnectInterrupt
2) HalGetInterruptVector
and look into DpcForIsr Routine and CustomDpc Routines.

Another route to take is to check into Filter Drivers. As an example (one that I have drawn from in the past) I have attached the source code to a Keyboard Filter driver (the file is Ctrl2cap, developed by Mark Russinovich and can be normally downloaded from
www.sysinternals.com

Hope this helps point you in the right direction.
Posted on 2001-09-10 13:12:27 by madprgmr