Sign in to follow this  
Followers 0
Hasher

Need help with OleCreatePictureIndirect

2 posts in this topic

Seems I am doing something wrong with OleCreatePictureIndirect but I cant pin it down , Tried Autoit debugger and Olly Debugger ut cant seem to catch this function.

dim $myPicObject
; Screenshot via Dll

$hwnd = DllCall("user32.dll","hwnd","GetDesktopWindow") 
; get handle to entire screen 

$DC = DllCall("user32.dll","ptr","GetWindowDC","hwnd",$hwnd[0]) 
; get device context for picture information

$lpRect = DllStructCreate("int;int;int;int") 
; create DllStruct for GetWindowRect call

DllCall("user32.dll","int","GetWindowRect","hwnd",$hwnd[0],"ptr",DllStructGetPtr($lpRect)) 
; get coordinates from upper-left and lower-right corner

$cDC = DllCall("gdi32.dll","ptr","CreateCompatibleDC","ptr",$DC[0]) 
; create compatible DC

$hbmp = DllCall("gdi32.dll","hwnd","CreateCompatibleBitmap","ptr",$DC[0],"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3))
; create compatible bitmap

DllCall("gdi32.dll","hwnd","SelectObject","ptr",$cDC[0],"hwnd",$hbmp[0])
; select bitmap to device context

DllCall("gdi32.dll","int","BitBlt","ptr",$cDC[0],"int",0,"int",0,"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3),"ptr",$DC[0],"int",0,"int",0,"int",0x00CC0020)
; copy picture information from the screen to device context in memory

Sleep(5000)
; break for doing anything on screen

DllCall("gdi32.dll","int","BitBlt","ptr",$DC[0],"int",0,"int",0,"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3),"ptr",$cDC[0],"int",0,"int",0,"int",0x00CC0020)
; restore previous saved screen

DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$cDC[0]); release device context for use by other apps

DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$DC[0]); release device context for use by other apps

$myPic = DllStructCreate ( "uint;uint;uint;uint;uint")
DllStructSetData($myPic,2,1)
DllStructSetData($myPic,3, $hbmp)
DllStructSetData($myPic,4,0)
DllStructSetData($myPic,5,0)
DllStructSetData($myPic,1,DllStructGetSize($myPic))

$myIID = DllStructCreate ( "uint;ushort;ushort;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte")

DllStructSetData ($myIID , 1 , 0x20400 )        
DllStructSetData ( $myIID , 4 ,0xC0 )
DllStructSetData ( $myIID , 11 , 0x46 )
DllCall ( "olepro32.dll" , "int" , "OleCreatePictureIndirect" , "ptr" , DllStructGetPtr($myPic) , "ptr" , DllStructGetPtr($myIID) , "int" , 1 , "ptr" , $myPicObject )
DllCall ( "oleaut32.dll" , "uint" , "OleSavePictureFile" , "ptr" , $myPicObject , "wstr" , "MYBMPFILE.BMP" )

Any help would be appricatied ;)


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites



I could have swore I've seen this code already once today... We use int for uint... and you'll want to check other syntax as well.

http://www.autoitscript.com/forum/index.php?showtopic=7072

http://msdn2.microsoft.com/en-gb/library/ms691294.aspx

Not quite sure what you were trying to accomplish with Olly Debugger though.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0