Jump to content

dllcall return string as array


 Share

Recommended Posts

I don't think that's normal.

Even though you're too vague, my guess is that your buffer isn't created correctly to begin with. I've noticed that unexperienced users have troubles reading and interpreting the APIs documentation correctly. Your $Buffer should be correctly sized "byte" array in case that API advertises null-separated character arrays (strings). Only then you can get all the strings out of the buffer.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

I have:

typedef struct _FbwfCacheDetail{
   ULONG cacheSize;
   ULONG openHandleCount;
   ULONG fileNameLength;
   WCHAR fileName[1];
} FbwfCacheDetail, *PFbwfCacheDetail;

And convert to:

$size=4192;

$FbwfCacheDetail=DllStructCreate("ULONG cacheSize; ULONG openHandleCount; ULONG fileNameLength; WCHAR fileName[" & $size & "];")

Do it is right?

Link to comment
Share on other sites

"size [in, out] On input, contains the size of cacheDetail. If the function returns ERROR_MORE_DATA, size contains the size of the required buffer."

i trigger ERROR_MORE_DATA and get $size.

Edited by Ontosy
Link to comment
Share on other sites

I think buffer talks about  whole structure. (I'M  not over my machine to try out) 

So maybe you need to subtract other fields(ulong * 3)  or just allocate memory then used the pointer with your structure. 

 

Saludos

Link to comment
Share on other sites

trancexx. it's right (I forgot  to divide). So my second solution is wrong. I forgot Autoit structures are fixed size.

 

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

 

What is the size of fields(ulong * 3)?

I meant same as trancexx's answer.

Saludos

Link to comment
Share on other sites

Look:

$size = 4192;
$size -= (3 * 4);3=your first 3  fields   4=size of Ulong in bytes
$size /= 2 ;divide by size of wchar(2 bytes)
$FbwfCacheDetail = DllStructCreate("ULONG cacheSize; ULONG openHandleCount; ULONG fileNameLength; WCHAR fileName[" & $size & "];")

Saludos

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...