Jump to content

execute from memory prob...


akshay
 Share

Recommended Posts

hey i need help

I was greatly inspired by the execute form memory example but hav a question

how can i convert image to binary.............

Your question is saying a lot of your current state.

Read about FileOpen() and FileRead() functions. But if you have image handle and want to store it to disk (not handle, image) then you'll need more than that.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Read about FileOpen() and FileRead() functions. But if you have image handle and want to store it to disk (not handle, image) then you'll need more than that.

no i do not want to save the file i want to use it in my gui (GDI Plus)

please i need an example code as well

Link to comment
Share on other sites

no i do not want to save the file i want to use it in my gui (GDI Plus)

please i need an example code as well

Your questions are confusing regarding the plainness of answers.

$hFile = FileOpen("YourPic.extension", 16)
$bFile = FileRead($hFile)
FileClose($hFile)

; $bFile; <-- you want this
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Your questions are confusing regarding the plainness of answers.

$hFile = FileOpen("YourPic.extension", 16)
$bFile = FileRead($hFile)
FileClose($hFile)

; $bFile; <-- you want this
i dont understand u

how can i create the image from memory when i do not have it binary data

i tried it ur way but the following happened

$hand = fileopen("s.gif",1)

filewrite("C:\log.txt",$hand)

exit

in te C:\log.txt it was only one line but i need the whole of it

eg

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=autoit_exe_run_from_mem.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Memory.au3>

GUICreate('Image from Stream smile.gif',200,200)
$picbox = GUICtrlCreatePic("", 10,10,64,63)
GUICtrlSetCursor(-1,0)
$LOGO = _LOGOBin()
_SetImageBinaryToCtrl($picbox,$LOGO)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3
            ProcessClose("ExecuteFromMem.exe")
            Exit
        Case $msg = $picbox
            ShellExecute("http://prospeed-jan.xprofan.com/")
    EndSelect
WEnd

Func _SetImageBinaryToCtrl($CtrlId, ByRef $Binary)
    Local $picdata = Binary($Binary)
    Local $piclength = BinaryLen($picdata)

    Local $picstruct = DllStructCreate("byte[" & $piclength & "]")
        DllStructSetData($picstruct,1,$picdata)
        Local $picmemory = DllStructGetPtr($picstruct)
        _SetMemoryImageToCtrl($CtrlId, $picmemory, $piclength)
        DllStructSetData($picstruct,1,0)
    $picstruct = ""
EndFunc

Func _SetMemoryImageToCtrl($CtrlId, $Pointer, $nSize)
    Local $hData, $pData, $pStream, $pBitmap, $hBitmap
    $hData = _MemGlobalAlloc($nSize,2)
    $pData = _MemGlobalLock($hData)
    _MemMoveMemory($Pointer,$pData,$nSize)
    _MemGlobalUnlock($hData)
    $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0)
    $pStream = $pStream[3]
    _GDIPlus_Startup()
    $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0)
    $pBitmap = $pBitmap[2]
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($pBitmap)
    _SetBitmapToCtrl($CtrlId, $hBitmap)
    If @error Then SetError(3, 0, 0)
    _GDIPlus_BitmapDispose($pBitmap)
    _GDIPlus_Shutdown()
    _WinAPI_DeleteObject($pStream)
    _MemGlobalFree($hData)
EndFunc

Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16
    Local Const $SS_CENTERIMAGE = 0x200
    Local Const $SS_REALSIZECONTROL = 0x0040

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_REALSIZECONTROL))
    If @error Then Return SetError(3, 0, 0)
        Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc

Func _LOGOBin()
    Local $FileName = "0xFFD8FFE000104A46494600010101006000600000FFE1001645786966000049492A0008000000000000000000FFDB004300080606070605080707070909080A"
   $FileName &= "0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D"
   $FileName &= "1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC0001108003F0040"
   $FileName &= "03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D"
   $FileName &= "01020300041105122131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A43444546474849"
   $FileName &= "4A535455565758595A636465666768696A737475767778797A838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5"
   $FileName &= "C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F0100030101010101010101010000000000000102030405060708"
   $FileName &= "090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434"
   $FileName &= "E125F11718191A262728292A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A9293949596"
   $FileName &= "9798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C0301"
   $FileName &= "0002110311003F00F78DDC64D729ABF8BFEC17DF678EDE699B04E2242C703D80F7AE9657DB1393D00AE37C29FE97E30D62F32D886148978E097624FE5B17F3AF"
   $FileName &= "0B30E7AF8B8616326935776FC0EFC2538724EACD5D4509FF0009CCFF00F40CBFFF00C077FF000A07C418609116EE196DF79C2F9CA5371F6CF5AED26B88EDE332"
   $FileName &= "CD2A471AFDE791B007E2698925BDEDBEE4314F04808C821D5877E7A1A1E4CD7C35A57F52BEB343AD1D3D59574CD6ADB5240617539E7835A7BABCF759D363F0CE"
   $FileName &= "B3697DA78F2ED2EA429242B9DA8FD723B007D3B62B7B53F14DB68ED6AB7322A89D495C9C1E3AFF003ACE19855C1D4950C4FBD6D9ADC2AE0D4F96543552FBCE93"
   $FileName &= "26973EF58963E23B1BE00472A96EBD6B5C3E4023A1AF530B8FA189FE1BD7B1C5528CE93E59AB14AFE51158CAE4FF0009EB5CE780A33FD9B7D78C4E6E6E98807D"
   $FileName &= "1405AD0F13DC791A248DBB048A3C2D07D93C316119565668C48CA7A82DC915C186FDEE67567FCA923B57B9817FDE7F912F8934B9F5AD20D9413C7096914B1917"
   $FileName &= "20A8392314BE1ED1D740D256C84C653E63485F18E49CE00EC2A8EBBE25974AD4A0B1B6B2FB54D2446565DFB768CE07F5FCAB34F897C4374A63B7D262818E30F2"
   $FileName &= "316C7AF15D75B1B84A355BA92B4874B0D89A941434507AEE897C6D73E7DC69BA544D995A6F39D476400807F13FC8D5CD575CB7D2960B3BBD365BC89E2FDE9455"
   $FileName &= "70BDB1B5BAE6A9E99A47F6619F59D6EE8BCA17749349D71E83F4C0141D2F45F165F3EA16D7F72D1A9D93440B2678F978600AF1F9D7954A55B158A788A4924B45"
   $FileName &= "7EBDCE9B518C6309DDC637BB5DD95DB45D175DB77BDF0D4B1D9DF47FF2C946C5CE3EEB20E83B640FCEB47C2FAD4B705EC6F55E2BA84EC747EA0FF9FC2B92568B"
   $FileName &= "C3DE35DD64EE208A68EDA42E4B16DD8C8CFD4823E95D0EB2A2CFC71652C7F29B984EF007F75B00FE4696323FBB78986938357B7537AB4AE952936E32578DF75E"
   $FileName &= "44BE3AF35F4A448E36656E084EB8EF491F8D34C8618E34B5D480450A33067B7FBD5D21F2DD364881D7B66A3FB2D9FF00CFBA9F6AD961F1F86AB51D049A93BEE7"
   $FileName &= "9D0C4D074634EAC5E9E76392B0B93AEF8C9EF9229D2DD2258E31326D23B9F5EE6ACEADE21BEB2F16C3A6431C696ECF17CE63C9756C86FD476AD2D76EA6D22C05"
   $FileName &= "C69B6F197C82491FC3DC63D6B175FD3FFE128D32CF58D20FFA4AAE55720332F5DB9E9B95B18CFA9F5AE5C35275E756A54B3A975A5B6B1DB4E54EA4A329AB536B"
   $FileName &= "955DECFCCB1E3B9716BA7248C040D724C99E9F2A9229FE0780269771A9C9841772EF5623198C7DD3F4EB8F635969E398E583ECFA9E9624B98DB0E8CC000C3D55"
   $FileName &= "F907F95476FE3AB9B69E492F2DE17B565022821700C78FE79FD31C57A4AAE1A388559CBA5AD6D8D3EAB89FAAFB050D9EF75AFA143C3D04BE22D623B8F2CBC1F6"
   $FileName &= "937770EC721792513DCF41EC0574334DFDB3E39022F9A1B15F2B781D589CB0FC38AA5A8EBDAA7F621974ED29F4BD39884F3D940701BBAA81C0E8371F5AE83C2F"
   $FileName &= "A759E9FA6AC96E779719DDEA7D4D7062D592C253D5D4776F61D7AAE29D79AB69CA92D6DDEE69EEA37549F64B8FF9E47FEFA1FE349F64B8FF009E47FEFA1FE35F"
   $FileName &= "507CE0D611CD118661943EA3A572B2691AAF87EE64B8D25849048774903728DEFEC7DC7E39E2BADFB25C8FF9647FEFA1FE34E586ED78F2C91E8483FD6BC9C5E5"
   $FileName &= "CE753DBD0972CFF067561F172A49C5ABA7D0E324F10D9DC129AC6812E4F0488D6507078F7E94D8B5BD16CCE74DD0253213CE2D82631D0E4D766D661C1F32C816"
   $FileName &= "F5C8FF001A45B054E63B200FD56B99ACCF6718B7DCEB58BC35BE17E977638E921D7BC4E0C37282CEC5FAC49C961FED377EDD2BAAB5B48EC2C92D636CEDEBED56"
   $FileName &= "DA2BB23023DA3D148FF1A8FECB71FF003C8FFDF43FC6B7C365F515555F152BC96DD91CF88C5BA9154E2B963D91FFD9"
   Return $FileName
EndFunc

i need the whole FileName thingy

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...