Solved

Interrupt calls

Posted on 1998-08-27
12
311 Views
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.
0
Comment
Question by:ajay_champ
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 1252345
NT prevents you from doing this.

0
 

Author Comment

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

Expert Comment

by:Answers2000
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)

0
 
LVL 1

Expert Comment

by:Bonev
ID: 1252348
Easy way to create device context for the entire screen is:
HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
0
 
LVL 2

Expert Comment

by:kellyjj
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)
0
 
LVL 5

Expert Comment

by:laeuchli
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ajay_champ
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 ?
0
 

Author Comment

by:ajay_champ
ID: 1252352
Hey no one replied to my last question ?????
0
 
LVL 1

Expert Comment

by:Bonev
ID: 1252353
The question is locked - either accept, or reject the proposed answer.
0
 
LVL 8

Accepted Solution

by:
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.



0
 

Author Comment

by:ajay_champ
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().
0
 

Author Comment

by:ajay_champ
ID: 1252356
Hey why noone is replying ?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now