Jump to content

Recommended Posts

Posted (edited)

I'm using a UDF (in this case, the FreeImage UDF, modified by Iczer and found here: https://www.autoitscript.com/forum/topic/95357-freeimage-library/?do=findComment&comment=1334983) that in some cases returns a pointer or handle to image data in memory (in this case, the function " _FreeImage_GetBits()"). But in order to use this image data with other, more standard functions, I need to pass this image data as if it were stored as an ordinary AutoIt variable (a binary array).  How can I accomplish this?

A perfectly acceptable solution would be to somehow copy this binary data in memory to a standard AutoIt binary array, but I don't know how to do that either.

Please note that I'm only interested in safe, absolutely non-hacking-related help here!  Google has pointed me to various sites that discuss memory-related tricks that attempt to read memory data from other processes that seems to me to be focused on hacking and I strongly agree that they have absolutely no place in this forum!  But I have zero interest in such things -- I'm only interested in binary data within my own process.

Once upon a time @Ward published a UDF that might have helped here: Binary UDF (specifically, a function called _BinaryFromMemory()), but the download links have since all been crossed out, implying that either some more official way of doing such things had since been incorporated into standard AutoIt -or- that UDF was being abused in an undesired manner.

What is the recommended way of accomplishing what I need?

THANKS!

 

Edited by Mbee
typo
Posted
17 hours ago, Mbee said:

that in some cases returns a pointer or handle to image data in memory

In AutoIt, you can create a dllstruct at the position of that pointer, and *voila* you have a bytearray.

$bytearray_struct = DllStructCreate("byte[" & $sizeofdata & "]", $pointertodata)
$data = DllStructGetData($bytearray_struct) ;bytearray

 

Posted

Wow, thanks, @Andy G

I had started to look into using DllStructs and the related functions because they looked like the most promising approach, but all I was able to figure out was how to write and read the data in the structs and the like.  I had no clue how to deal with pointers.  But now I do!  Thanks again!

 

Posted
59 minutes ago, AndyG said:

In AutoIt, you can create a dllstruct at the position of that pointer, and *voila* you have a bytearray.

$bytearray_struct = DllStructCreate("byte[" & $sizeofdata & "]", $pointertodata)
$data = DllStructGetData($bytearray_struct) ;bytearray

 

Um, @AndyG , I need a little more help, please.  The second line wouldn't compile, so I changed it to...

$data = DllStructGetData($bytearray_struct, 1)

But even so, when I tried to access $data as a byte array (for example, as follows):

$data[$i]

I received the following error message: "Error: Subscript used on non-accessible variable."

For the record, I don't truly need to access the data as a binary byte array myself, but I'm calling another UDF that apparently does need to access it that way...

 

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
  • Recently Browsing   0 members

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