• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Interrupt calls

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.
0
ajay_champ
Asked:
ajay_champ
  • 5
  • 2
  • 2
  • +3
1 Solution
 
JYoungmanCommented:
NT prevents you from doing this.

0
 
ajay_champAuthor Commented:
Youngman, Do U mean to say that NT doesn't allows using interrupt calls (like Int 10h) ?
0
 
Answers2000Commented:
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)

0
Become a Leader in Data Analytics

Gain the power to turn raw data into better business decisions and outcomes in your industry. Transform your career future by earning your MS in Data Analytics. WGU’s MSDA program curriculum features IT certifications from Oracle and SAS.  

 
BonevCommented:
Easy way to create device context for the entire screen is:
HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
0
 
kellyjjCommented:
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)
0
 
laeuchliCommented:
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
0
 
ajay_champAuthor Commented:
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 ?
0
 
ajay_champAuthor Commented:
Hey no one replied to my last question ?????
0
 
BonevCommented:
The question is locked - either accept, or reject the proposed answer.
0
 
Answers2000Commented:
>> 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.



0
 
ajay_champAuthor Commented:
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().
0
 
ajay_champAuthor Commented:
Hey why noone is replying ?
0

Featured Post

Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

  • 5
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now