Interrupt calls

Posted on 1998-08-27
Last Modified: 2010-04-15
I'm working in MSDev Environment. I'm doing inline assembly in my C program. Everything is fine except as soon as I use any Interrupt call my prog. crashes. Why so ?
Also how can I access the video memory of my computer ? Actually I wanna get a dump of my screen.
Question by:ajay_champ
  • 5
  • 2
  • 2
  • +3

Expert Comment

ID: 1252345
NT prevents you from doing this.


Author Comment

ID: 1252346
Youngman, Do U mean to say that NT doesn't allows using interrupt calls (like Int 10h) ?

Expert Comment

ID: 1252347
Which OS and compiler.

JYoungman is right that you can not access the video memory directly from a 32bit program on NT (Console or GUI).

From VC 1.52 or earlier (the 16 bit compiler) you should be okay,

Additionally are you wanting a console (text mode) or graphics mode dump of the screen.

For a 32bit program:
1. You can get the contents of a console (text) mode window using the GetConsoleScreenBufferInfo API
2. For graphics mode you can get the entire screen into an HBITMAP using the following technique.
i. GetDC on the screen or window you want to capture (call this HDC #1)
ii. Create a compatible bitmap using CreateCompatibleBitmap (call this HBITMAP #2)
iii. Create a compatible DC using CreateCompatibleDC (call this HDC #3)
iv. Select HBITMAP #2 into HDC #3
v. BitBlt from HDC #1 into HDC #3
vi. ReleaseDC HDC #1
vii. HBITMAP #2 now contains the screen shot with HDC#3 associated with it.  You can now use these.  Don't forget to clear them up when done (DeleteDC on the DC, DeleteObject on the bitmap)

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.


Expert Comment

ID: 1252348
Easy way to create device context for the entire screen is:

Expert Comment

ID: 1252349
you got to be careful about which interrupts you call.  Some of them can really p*** off windows.  hehehe,  I know from personal expierence.   If you are working w/ windows, there are functions work-arounds that will do pretty much the same thing and are safer.  ( as safe as windows ever will be)

Expert Comment

ID: 1252350
If you want to use some of the ints, you might have to write a vxd. I would look into that if you really need to use asm in your code

Author Comment

ID: 1252351
Thanks everybody.
I want a graphics mode dump of a screen. My platforms would be Win 95/NT.
Actually I have noticed one thing. When we do Ctrl-Alt-Print Screen we get the dump of screen in the clipboard. This combination of keys must be calling some API or any other procedure. I wanna know how that could be done ?

Author Comment

ID: 1252352
Hey no one replied to my last question ?????

Expert Comment

ID: 1252353
The question is locked - either accept, or reject the proposed answer.

Accepted Solution

Answers2000 earned 50 total points
ID: 1252354
>> I want a graphics mode dump of a screen. My platforms would be Win 95/NT.

Here are the steps

1. Get the size of the screen (in pixels).  You can do this use GetSystemMetrics

int ww = GetSystemMetrics( SM_CXSCREEN ) ; // width
int hh = GetSystemMetrics( SM_CYSCREEN ) ; // height

2. Use GetDC API to get an HDC for the whole screen (call this hDCScreen)

3. Use CreateCompatibleDC to create a memory DC using the values from #1 and  #2 (call this hDCMem)

4. Use CreateCompatibleBitmap to create a bitmap HBITMAP handle (call this hBitmap)

5. SelectObject 4 into 3 ( SelectObject( hDCMem, hBitmap ) ;

6. BitBlt from the screen DC into the memory DC

BitBlt( hDCMem, 0, 0, ww, hh, hDCScreen, 0, 0, SRCCOPY ) ;

7. ReleaseDC on the screen DC

8. You now have a bitmap of the screen (hBitmap) and a DC for it (hDCMem).  When done with these delete the DC (using DeleteDC ) and then delete the bitmap (DeleteObject)

9. You can use BitBlt to copy from the DC to another Windows device (e.g. the printer or your app's window)

10. To put the bitmap on the clipboard
a. DeleteDC on hDCMem
b. OpenClipboard
c. EmptyClipboard
d. SetClipboardData (format is CF_BITMAP, data handle is hBitmap)
e. CloseClipboard
After doing this hBitmap should not be used anymore.


Author Comment

ID: 1252355
Thanx Answers2000. I'm able to get the dump. But still I 'm facing a problem which is I'm not able to take the dump of that screen into my applications client area.
Right now I'm succeded to take a dump in my Memory DC but unable to get the dump in my application's window's DC which is CWnd::GetDC().

Author Comment

ID: 1252356
Hey why noone is replying ?

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
rhel6 C system() call to zip to archive has problems 25 245
negation in C function 14 161
Want to delete all my personal data 13 146
Resolve Dependency Issues 4 79
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question