Hi. I was wondering can we use interupts with MASM?
Apparently my code is large enough, that I miss char's coming in the serial port. I recall reading about DOS stuff where you would swap the handler's address with your preferred one. Does anyone have some links I can check out?

Thanks.
Posted on 2002-03-19 16:12:46 by sceptor
I doubt that you can change interrupt handlers in win32, but I could be wrong. If you are missing characters how about creating a thread just for send/receive serial port.

http://www.asmcommunity.net/board/showthread.php?threadid=3908&highlight=serial+port
Posted on 2002-03-19 17:29:04 by bdjames
The DOS interrupt table in real mode starts at address 0h. If you want to hook the serial port install your interrupt handler by writing your handler's address to the serial port interrupt offset in that table. You'll need an older MASM version (5?) to compile DOS apps I think.

If you are doing this in protected mode or in Win32 you'll need to familiarize yourself with the interrupt descriptor table (IDT) and Windows will not so easily give up access to it. I'm not certain where to look for more info, but you could always try looking through Icezelion's VxD stuff, or download the MS DDK for reference.
Posted on 2002-03-19 17:29:12 by iblis
As I know that the interrupts aren't used in the windows programming stuff. but you can use the windows api's.
About the serial port I think if you want to program it in windows under assembly that you use (IN , OUT) instructions or (MOV ,anything), these instruction must have the address of the serial port and you can get it from the device manger of the windows. And I recommand to use the IN , OUT instructions if you want any help about them, ask about it.
Posted on 2002-03-21 03:15:08 by amr
Interrupts are use quite often in Windows, if not for another reason then because of the gpf's that have to be handled.

Under win98 you can modify the idt as you like, thus hooking whatever interrupts you want. Under winNT, win2000 and winXP the idt is protected, and you'll have to do system drivers to be able to change them (if that is at all possible).

As to whether the interrupts are used, I should think there would be uses both for virus and anti-virus programs (I've noticed a couple of my interrupts are changed, and I do hope it's my antivirus and NOT a virus doing it). Not to mention device drivers, debuggers, dumbass copyprotection programs (hiding your protection in an interrupt makes it rather obvious what's going on) and all sorts of other stuff.

Blue skies
Fake
Posted on 2002-03-21 10:10:37 by Fake51
I cannot recommend using in/out directly under windows, as it will
only work on cruddy old 9x. Serial I/O has been discussed before,
and I believe there is some library available that supports both 9x
and NT.
Posted on 2002-03-21 17:14:30 by f0dder
I agree with f0dder here, interrupts can be used in ring zero in 9x systems but it is messy and complicated code that is OS version specific so its not much use. The port instructions IN/OUT are not normally accessible in protected mode so you are better to find another way to do what you are after.

I think the SYSINTERNALS guys do the IO library.

Regards,

hutch@movsd.com
Posted on 2002-03-21 20:26:41 by hutch--
Hi,

beginner question. Would it be correct to assume that this code fails under Windows 2000.

----------------------------------------------------
.386
.MODEL FLAT
.STACK
.DATA
msg DB "Hello, world.", 0dh, 0ah, '$'

.CODE
_start:
Begin: mov ah, 09
lea dx, msg
int 21h
Finish: mov ax, 4C00h
int 21h
END _start
------------------------------------------------------

I got a book full of examples using interupts in a similar way. Having trust to printed word would like word of expert that program fails for reasons other than my wrong coding style.

Cheers
Posted on 2002-03-22 18:42:53 by Mikew
Mikew: that code shouldn't fail on 2k. The reason being is that int 21h is the dos interrupt, 2k emulates dos programs, and can run dos programs that don't access the hardware directly. So you couldn't use the bios int 10h, or almost any other.
Posted on 2002-03-22 22:39:29 by Asm_Freak
Ya... but i dont know of many dos programs, suitable for emulation that is compiled under "MODEL FLAT" ??

Your book is most likely intended for 16 dos apps using MS DOS as its OS. For win 2000 and alike, stay away from interupts until you feel "advanced" enough to play around in Ring 0 (as f0dder mentioned).

Your book will be good for the basics only.. ie) moving data back and forth, using the stack.. etc. But beyond this, windows has an API for practially any dos int you would like to use in an average app.

Just some thoughts...
:alright:
NaN
Posted on 2002-03-22 23:17:27 by NaN
Back to the original question:
Yes you can use Interupts under MASM. But like everybody else has said, no you cant use Interupts under windows.

Anyway trying to hook an interupt to implement serial I/O in windows is obviously going to cause a million times more problems than it will solve. Hooking the interupt will end up being the easist step.

Windows has quite a lot of documentation on serial I/O, so my advice would be best to try and look up what settings to tweak and change's to implement before going strait to the hack ring 0 (non)solution.
Posted on 2002-03-23 00:52:32 by huh
Yes, the famous int 3h :grin:
Posted on 2002-03-23 00:53:56 by stryker
Hi,

first of all, thanks for your helping. With hints I got from experts on this forum returned back to tiny model instead of flat model, re - compiled using linker version 5.6 / ml <> -Zm and it worked, shows "Hello World!" nicely and size of the .COM executable file = 29 bytes, still due to file formatting it takes 512 bytes on disk ( sigh )

New question :) How to debug this application. Two troubles run into.

1 could not enable debug symbol creation for the .COM file,
for some reason my DDK will not install, possibly service pack needed. In all, my documentation is limited to what debug environment for W2K provides. I would appreciate help creating debug symbols with linker 5.6

2 debugger trace shows very general info about some modules loaded and the line "Hello World!," but it unloads the executable before the line "Hello World!" is output on the console, and it does not get out to the debugger prompt once "Hello World!" shows up. Only after Ctrl+C or Ctrl+Break is de - pressed it breaks into interactive command prompt of debugger and at that moment there is nothing one can learn about how system lives and talks with the process.

3 debug.exe does work, stepping through and un-assembling the executable, but it is unaware of system and debugs plain code, showing some unbelievable addresses in the left hand column.

One more question - is there way to learn a header format for such a tiny file ( if any. )

Cheers
Posted on 2002-03-23 09:46:26 by Mikew
I think that you need CodeView to debug your program its the best one you can use as I think.
About interrupts, I Know there are interrupts used in windows but most of the useful interrupt that works with dos like INT 21h can't work with a win32 application so I see that there is no need for using Interrupts except if you are going to program under dos.
About dos programs
Here is one
Posted on 2002-03-23 22:23:35 by amr
Umm yeh sorry, you can use Int 3 for raising a breakpoint
Posted on 2002-03-23 22:35:07 by huh
Originally posted by Mikew

New question. How to debug this application.


Use Turbo Debug


One more question - is there way to learn a header format for such a tiny file ( if any. )



There isn't any format for a com file. It's just an image that is uploaded to memory at 100h in some segment and then executed.

Blue skies
Fake
Posted on 2002-03-24 12:30:53 by Fake51
If you're planning on debuging a .com file, don't worry about symbolic debugging. There's no symble way of placing symbolic debug information in a com file for use with TD or CodeView.


However, I see no reason why you can't simply link your program as a DOS exe instead.
Posted on 2002-03-24 16:11:43 by Canite
emm sorry for not giving answer but asking for one :)
My card sits on IRQ5 - how can you detect that it asks for an ISR? I should insert my ISR into the isr chain (if it exists), am I right? - but how can it be done?? Any suggestions, RTFM, etc?VPICD, VMMcall,handmade???:confused:
Posted on 2002-05-28 07:24:14 by drojid
Yes , we can use "native API" int int2Fh int2Fh, but should remember that they are OS specific.
Posted on 2002-05-28 07:40:48 by The Svin
Thanx, Svin,
The program has to run on only one (only one type :) ) OS, W98. No higher, no lower.
Where could I find some documentation about these api calls? DDK?
Thx&Best,
Gergo
Posted on 2002-05-28 08:26:52 by drojid