Ontosy Posted January 4, 2016 Share Posted January 4, 2016 I have a dllcall that return a value that I have to convert:func joinString($Buffer, $size, $field) local $ret="", $i For $i = 1 to $size $ret &= StringStripWS(DllStructGetData($Buffer, $field, $i), 15) Next return $ret EndFuncDo it is normal or it have a other via? Link to comment Share on other sites More sharing options...
trancexx Posted January 4, 2016 Share Posted January 4, 2016 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 More sharing options...
Ontosy Posted January 4, 2016 Author Share Posted January 4, 2016 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 More sharing options...
trancexx Posted January 4, 2016 Share Posted January 4, 2016 It depends on how you get $size and what it really represents. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Ontosy Posted January 4, 2016 Author Share Posted January 4, 2016 (edited) "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 January 4, 2016 by Ontosy Link to comment Share on other sites More sharing options...
Danyfirex Posted January 4, 2016 Share Posted January 4, 2016 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 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
trancexx Posted January 4, 2016 Share Posted January 4, 2016 So you have to subtract the size of first three fields and then divide the result by 2 (1 wchar is 2 bytes). ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Danyfirex Posted January 4, 2016 Share Posted January 4, 2016 (edited) trancexx. it's right (I forgot to divide). So my second solution is wrong. I forgot Autoit structures are fixed size. Saludos Edited January 4, 2016 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Ontosy Posted January 4, 2016 Author Share Posted January 4, 2016 So maybe you need to subtract other fields(ulong * 3) or just allocate memory then used the pointer with your structure.What is the size of fields(ulong * 3)? Link to comment Share on other sites More sharing options...
Danyfirex Posted January 5, 2016 Share Posted January 5, 2016 What is the size of fields(ulong * 3)?I meant same as trancexx's answer.Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Ontosy Posted January 5, 2016 Author Share Posted January 5, 2016 f.e. if $size is 69 WCHAR fileName size is (69-3)/2 =33 ?i'm not able to see size of fields(ulong * 3) in the trancexx's answer. Link to comment Share on other sites More sharing options...
Danyfirex Posted January 5, 2016 Share Posted January 5, 2016 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 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Ontosy Posted January 5, 2016 Author Share Posted January 5, 2016 Ty, the calcule now is precise.But i have every to use iteration to obtain the string.If i use simpleDllStructGetData($FbwfCacheDetail, "fileName")i obtain "2". Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now