kristo Posted October 12, 2011 Share Posted October 12, 2011 (edited) I'm using the resources UDF to create the following little program. I need to include a binary datafile called pattern.dat. This pattern file has to be processed afterwards which I want to do via resources.au3. Since it is not possible to write the pattern.dat to disk I want to read the data directly from the resources section. #NoTrayIcon ;------ Include the resulting pattern.dat from the sensoring device #AutoIt3Wrapper_Res_File_Add=pattern.dat, rt_rcdata, PATTERN #include "resources.au3" global $Chunk = _ResourceGetAsString("PATTERN", $RT_RCDATA) ;global $Chunk = _ResourceGetAsBytes("PATTERN", $RT_RCDATA) for $i=1 to StringLen($Chunk) step 32 $evalpart=StringMid($Chunk,($i-1*32)+1,32) ;------ Send to Transfer unit via TCP ;ActivateTranferUnit ($evalpart) ;------ Debugging only FileWriteLine(@ScriptDir & "\evalsteps_debug.txt",$evalpart) next However neither _ResourceGetAsString nor ResourceGetAsBytes seems to return the original data stream. So far all resources samples I found are saving the data to disk. Bit how can I get a variable filles with the included stream similar to FileRead()? Can anyone give me advice how to solve this. Kristo Edited October 12, 2011 by kristo Cheap, Fast, Good - Choose any two Link to comment Share on other sites More sharing options...
Zedna Posted October 12, 2011 Share Posted October 12, 2011 What is file size? Can you see PATTERN resource in compiled EXE by Reshacker? What @error codes returns _ResourceGetAsString()? Post your file. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
kristo Posted October 12, 2011 Author Share Posted October 12, 2011 What is file size?Can you see PATTERN resource in compiled EXE by Reshacker?What @error codes returns _ResourceGetAsString()? Post your file. Hi Zedna! Yes, I can see the PATTERN resource with ResHacker.exeErrorCode is 0, the resulting file size is 4 bytes, which explains why there's nothing for me to evaluate. I attached one of the pattern files for you.pattern.7z Cheap, Fast, Good - Choose any two Link to comment Share on other sites More sharing options...
kristo Posted October 12, 2011 Author Share Posted October 12, 2011 Hey Zedna, I think I found the problem within the Resource UDF. Seems that the 'byte' structure stops when encountering zeros. So I added a new function: _ResourceGetAsUByte. Func _ResourceGetAsUByte($ResName, $ResType = 10, $ResLang = 0, $DLL = -1) ; $RT_RCDATA = 10 Local $ResPointer, $ResSize, $struct $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL) If @error Then SetError(1, 0, 0) Return '' EndIf $ResSize = @extended $struct = DllStructCreate("ubyte[" & $ResSize & "]", $ResPointer) Return DllStructGetData($struct, 1) ; returns string EndFunc Now it works as intended. Hope this helps improving the resources UDF Cheers Kristo Cheap, Fast, Good - Choose any two Link to comment Share on other sites More sharing options...
Zedna Posted October 12, 2011 Share Posted October 12, 2011 Interesting prblem/solution! I still have no clue what's the source of problem, anyway I'm glad you fixed it. Resources UDF ResourcesEx UDF AutoIt Forum Search 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