Jump to content
Tuts 4 You

Decrypt File Into Memory


Matrix

Recommended Posts

Posted

Hi Freind

i encrypted a file with AES algorithm and i want decrypt it into Memory via a Program, i don`t want make any temp file .

plz help me :unsure:

Posted

Use the heap. You can grab all the temporary memory you need and decrypt inside the program then release the memory.

see reference to the Windows api GlobalAlloc

Z

Posted
Use the heap. You can grab all the temporary memory you need and decrypt inside the program then release the memory.

see reference to the Windows api GlobalAlloc

Z

Hi Friend

tanx , may you give me a example from Visual Basic , because i am beginner :rolleyes:

Posted (edited)

hmmm.. I code in MASM, C and Delphi. I don't have an example using Visual Basic - sorry.

Maybe another forum member may have an example. Maybe a Google will find some examples for you.

cheers

Z

Edited by Ziggy
Posted
hmmm.. I code in MASM, C and Delphi. I don't have an example using Visual Basic - sorry.

Maybe another forum member may have an example. Maybe a Google will find some examples for you.

cheers

Z

Tnax a lot of my Friend :wub::D

Posted

Here is what a Google turned up. A nice simple example.

' Use a block of memory as an intermediary step to copy
' the contents of array s() to array t(). Yes, you could copy them directly,
' but this demonstrates a few different memory functions.
Dim s(0 To 255) As Integer, t(0 To 255) As Integer ' arrays to copy from/to
Dim c As Integer, retval As Long ' counter variable & return value
Dim hMem As Long, pMem As Long ' handle and pointer to memory block' Initialize the source array s()'s data
For c = 0 To 255
s© = 2 * c ' each element equals double its index
Next c' Allocate a moveable block of memory (returns a handle) (Integer type = 2 bytes)
hMem = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, 256 * 2)
' Lock the memory block, returning a pointer to it
pMem = GlobalLock(hMem)
' Copy the entire contents of s() to the memory block
' Note that pMem is ByVal because we want its contents, not a pointer to it
CopyMemory ByVal pMem, s(0), 256 * 2
' Copy the contents of the memory block to t() (we could have just copied s() to t())
CopyMemory t(0), ByVal pMem, 256 * 2
' Unlock the memory block, destroying the pointer and freeing resources
x = GlobalUnlock(hMem)
' Free the memory block (de-allocate it)
x = GlobalFree(hMem)' Verify that t() = s(), which it should
For c = 0 To 255
If s© <> t© Then Debug.Print "Copy attempt failed."
End If

I'm no VB'er but it looks ok to me.

Z

Posted (edited)

@Matrix

if the file is too big , then you can use Global Alloc [like Ziggy said] and

read first block from file to Buffer,

decrypt

write decrypted block to file

read next block from file to Buffer,

decrypt

write next block to file

.... continue until last

PS* Assuming that you will need to save a decrypted file since you have encrypted it

Edited by starzboy
Posted

i think what he wanted is to Execute a crypted file on memory , dude see P0ke crypter if you in delphi.

Posted
i think what he wanted is to Execute a crypted file on memory , dude see P0ke crypter if you in delphi.

yes i want execute a crypted file on memory and use VB , can you help me dear :unsure: ?

Posted

simply you cant you know why there is no Power in vb meaning POINTERS are not supported in VB try CPP or delphi.

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
×
×
  • Create New...