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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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)

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

617 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