I have a question about how to hook HW interrupt in flat memory mode...Maybe you can give me some directions...
@ about my application...
- created by combining Watcom C and DOS32/A.
- written for running on DOS mode( not on OS mode )
- with DOS32/A now I can access >1M memory and allocate large memory to use...(running in flat memory mode !!!)
@ current issue...
- I want to write an ISR(interrupt service routine) for one PCI card. Thus I need to "hook" the HW interrupt to test...
- For example, the PCI card's interrupt line(0x3C) = 0xE in DOS mode. That means this device will issue interrupt via 8259's IRQ 14.
But... I did not how to achieve my goal to hook this interrupt in "flat mode" ?
@ reference I found...
- in watcom C's library doc, there is one sample using _dos_getvect, _dos_setvect, and _chain_intr to hook INT 0x1C...I tested this code and found OK.
But when I apply it to my case: INT76 ( where IRQ 14 is "INT 0x76" due to (14-8) + 0x70 )then nothing happened...
* I have checked HW interrupt is truly generated but my own ISR did NOT invoked...
Do I lose something ? or are there any functions I can use (in DOS32/A) to achieve my goal ?
With your sample app that hooks INT 0x1C, was that also running in flat-mode?
That is to say - the 80x86 family run in two modes - one that has a flat address-space and the other that has segmented memory space.
When in segmented mode (DOS) there's a table that holds the address of all of the ISRs. To hook an interrupt, you simply grab the table entry you want then overwrite it with the address of your own routine. Inside your routine you do what you need, calling the original routine before, after your code or not at all. When you want to remove the hook, you simply re-write the table entry.
While in protected mode (win,linux,dos4gw/dos32a) memory is arranged quite differently. You don't have a globally accessable place that you can just read and write in quite the same way. You have the beasts known as Interrupt Descriptor Table.
I spent a long time 15 years ago trying to roll-my-own code that would enter protected mode. I've got vague memories of having trouble wrapping my head around the IDT & GDT.
What I'm getting at, is that I can't be sure that the functions you're calling are intended for flat-mode. If the ISR is running in flat-mode, you can't even address it in the 4 bytes that each entry has in a real-mode IDT.
I also don't quite follow the formula you've used to come up with int 0x76
You know what I'd probably be doing? Downloading the source-code for some old games that used the dos4g/w extended and looking there for some hints. You should find something in either the timing or the sound code. The one that immediately comes to mind is Doom. Don't remember if Duke Nukem 3d was too I beleive Rise Of The Triad - ROTT used the watcom compiler. A lot of games by iD, Apogee & 3dRealms of the era used the extender.
My app runs at "flat memory mode" in DOS(by DOS extender -DOS/32A). I added the sample code to hook INT 0x1C in my app then found OK ! Thus that code should be running in flat mode ^_^
Another example demonstrating if app is in flat mode maybe: if allocating memory on this mode, get the offset address of this pointer then I got 4-byte address ! ( If in real mode, the offset address will be 2byte because real mode is SEG:OFF format...)
As you said memory is arranged quite differently with dos extender BUT I think there must be handy APIs provided by DOS/32A to achieve this goal because it is a common demand...
And 0x76 comes in below statement: "DOS/32 Advanced will install real mode IRQ callbacks for all 16 hardware interrupts (IRQ 0-7, IRQ 8-15 = INT 08-0Fh, INT 70-77h)"
Because my device use IRQ14 thus (14-8)+0x70 = 0x76 and it is the interrupt number CPU got to calculate the entry of ISR !
I feel hard, since the width of the string in the input file is not fixed varying from 50 character to 120, so how to specify the buffer size.
If the size varies, you have to specify the maximum size, the smaller string will fit just fine in the larger strings array.
I used 'scanf' to read input, I do not need to specify the length of the string.
Yes, but this was a frequent cause of crashes due to buffer overflows, you don't HAVE to use scanf_s, if the previous version worked just fine for you, you can disable the warning with a pragma comment.
i am stuck with a problem while working with Windows CE 5.0 on handheld device.I am using Embedded VC++(eVC++) with programming in C++(MFC).
i want to set the value "Never" to a Switch state to Suspend dropdown programmatically.
This dropdown is located in settings>>Power properties.
Hi,everyone,Can i use vc++6.0 with aforge(from aforgenet.com)? i see there are framework in aforget,so i am not sure if it is possible to use vc6.0 and aforge together?looking forwards to reply,thanks.
I implemented a multi touch application. I follow MSDN tutorial using manipulation interface, here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd371408(v=vs.85).aspx[^]
But I have many problems when panning or zooming, is not redrawing and glitches in scrren. I need to limit my CView and do panning when screen is bigger than CFrameWnd, because CFramewnd does not redraw. I don't know how to get frame size and limit CView to don't pass CFrameWnd size. I tried an anchor or dock window but did not work.
Please, I need any help.
I'm using GetWindowRect like MSDN example. But I have problems when panning. I have a CView with same size as CFrameWnd, if I move the screen beyond origin the screen does not redraw. What I need is do a panning only if my CVIew is bigger than my parent frame, and don't if Cview is in origin. I tried getting screen limits but does not work.
________________ --->CFrameWnd - Glitches and does not redraw
| ___________|____ ---> CView - out of screen origin
| | |
| | |
| | |
| | |
| | |
Hey, everyone! I want to use one of the Find() methods with a richtextbox(RichTextmethod.Find Method(String, RichTextBox)) and i'd like to no if i might use a textbox's text instead of the string used in this method. thanks