Screen Capture Restriction

c++ / delphi package - dll injection and api hooking
Post Reply
LeVuHoang
Posts: 131
Joined: Fri Oct 22, 2004 8:37 am

Screen Capture Restriction

Post by LeVuHoang »

Anybody have an idea about block Screen Capture ???
I tried to Hook BitBlt & StretchBlt but unsuccessful :

Code: Select all

function BitBltCallback(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): BOOL; stdcall;
begin
  if (SrcDC = GetDC(0)) and (Rop = SRCCOPY) then
  begin
    Result :=False;
    SetLastError(ERROR_ACCESS_DENIED);
  end
  else
  begin
    Result :=BitBltNext(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Rop);
    RenewHook(@BitBltNext);
  end; { if }
end; { BitBltCallback }

function StretchBltCallback(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Rop: DWORD): BOOL; stdcall;
begin
  if (SrcDC = GetDC(0)) and (Rop = SRCCOPY) then
  begin
    Result :=False;
    SetLastError(ERROR_ACCESS_DENIED);
  end
  else
  begin
    Result :=StretchBltNext(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, Rop);
    RenewHook(@StretchBltNext);
  end; { if }
end; { StretchBltCallback }
Thank you...
Dildo Park-Sex Masturbation Butt Audition Gym Braces Pornstar Panty [url=http://10+-Inch-Cock.freepornadultsite.us/]10+-Inch-Cock[/url] Cum-Covered Nympho Soccer Squirting Dick Fingering Bra Double-Penetration Lace Feet Tight-Pussy Skank Wrestling Pain Desk Czech Kinky Pregnant Latina Licking-Pussy Ass-Fucking Foursome Squirt Short-Hair Hooker Tits Cute Plumper Lolita Doggystyle
Last edited by LeVuHoang on Tue Oct 21, 2008 3:02 am, edited 1 time in total.
uall
Posts: 254
Joined: Sun Feb 20, 2005 1:24 pm

Post by uall »

the problem is that GetDC gives you everytime a new handle when you call it

so SrcDC = GetDC(0) will be NEVER the same
u have to hook user32.GetDC and if parameter is 0 you have to save this value for later comparing in BitBlt /StretchBlt
LeVuHoang
Posts: 131
Joined: Fri Oct 22, 2004 8:37 am

Post by LeVuHoang »

hi uall,
I don't know if this solution can solve the Block Screen Capture problem ?
Do you an idea about Stop a Screen Capture ?

Thank you.
madshi
Site Admin
Posts: 10765
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

It's quite hard to block screen shotting without also blocking some needed functionality. There will probably be good reasons why some programs need to get a DC to the whole screen. So you can't generally block any GetDC requests for the whole screen. And once a program has a valid DC for the whole screen, it can use any GDI function with it. So you'd have to hook all those GDI functions and compare the DC handle with the one GetDC returned (as uall said). That's really an awful lot of work and it may be hard to realize in a safe and stable way. Still some programs might find ways around your block by maybe trying to copy DC handles (don't know whether that's possible) or such stuff. Also you'd be lost if a DC handle was already created before your API hook got installed.

Really difficult stuff... <sigh>
LeVuHoang
Posts: 131
Joined: Fri Oct 22, 2004 8:37 am

Post by LeVuHoang »

I agree with madshi.
I'd tried to catch GetDC(0) handle as uall said about but after, I think It's not a good way to solve this problem...
*A lot of program using GetDC(0) to work* is a lot of GetDC handle we must work... :-?... It's an impossible !!!...
I remember that sometimes (I dont know how), I use Print Screen or Snag It to capture the desktop, All of them failt with errors about DC handle. So, they cannot grab the desktop image.
Is there any way to destroy screen capture work like that ???
I still don't know how to do that... Maybe This is a really difficult problem :-?...

Thank you
madshi
Site Admin
Posts: 10765
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

This question was asked before (not on this forum), and the answer always was "quite difficult", as far as I remember. However, I've not tried it myself. Haven't had time for that.
uall
Posts: 254
Joined: Sun Feb 20, 2005 1:24 pm

Post by uall »

the only way i know is if you use the overlay function from direct3d
then no program can create a screenshot of it

for example: try to create a screenshot from a video of the mediaplayer, you only see the mediaplayer not the video on it.

but maybe there is a way too look if the srchandle in BitBlt / StretchBlt is the desktop...
LeVuHoang
Posts: 131
Joined: Fri Oct 22, 2004 8:37 am

Post by LeVuHoang »

I saw there are many programs can capture DirectX too.
Arksole Hoax
Posts: 211
Joined: Sat May 08, 2004 11:41 am

Post by Arksole Hoax »

i tryed it hooking bitblit but suddenly every app that got it injected, blacked out :)

its kinda hart to block such programs. but if there would be some way to do that, it would be a nice approach to security systems for websites with pinpads...
Post Reply