Moderators Melba23 Posted November 10, 2008 Moderators Posted November 10, 2008 Zedna, I have found a small problem when using your UDF. The function _ResourceGetAsBytes did not get the resource as bytes. At least not until I changed the final lines to read:$struct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) Return DllStructGetData($struct, 1); returns struct with bytes Rather than the original:Return DllStructCreate("byte[" & $ResSize & "]", $ResPointer); returns struct with bytes When I found that the AsBytes function did not work, I tried copying the code from the _ResourceGetAsString function above, which I had already used and knew worked well. It might well be Vista (I am running x32 Home Premium), or more probably my understanding of the UDF. The code I am using to get the resource in and out is as follows:#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, M:\Program\Au3 Scripts\Test\162.bin, rcdata, BIN_162, 0 ... ... ; Load the 162 data from the saved resource $data = _ResourceGetAsBytes("BIN_162") Thanks for producing the UDF. I do hope it is an easy fix - like pointing out my error and smacking me over the head! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ODPOA Posted November 12, 2008 Posted November 12, 2008 Hello, I was simply wondering if there was a way to run an executable this way. So instead of using file install simple use this method to include an executable(or its binary data as a string) and then run the application without ever writing it to a file. I was just wondering if it was possible. And if so, hwo would one go about doing so. Thanks
Zedna Posted November 12, 2008 Author Posted November 12, 2008 Hello, I was simply wondering if there was a way to run an executable this way.So instead of using file install simple use this method to include an executable(or its binary data as a string) and then run the application without ever writing it to a file.I was just wondering if it was possible. And if so, hwo would one go about doing so.ThanksNO. It's not possible. Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted November 12, 2008 Author Posted November 12, 2008 Zedna, I have found a small problem when using your UDF. The function _ResourceGetAsBytes did not get the resource as bytes. At least not until I changed the final lines to read:$struct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) Return DllStructGetData($struct, 1); returns struct with bytes Rather than the original:Return DllStructCreate("byte[" & $ResSize & "]", $ResPointer); returns struct with bytes When I found that the AsBytes function did not work, I tried copying the code from the _ResourceGetAsString function above, which I had already used and knew worked well. It might well be Vista (I am running x32 Home Premium), or more probably my understanding of the UDF. The code I am using to get the resource in and out is as follows:#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, M:\Program\Au3 Scripts\Test\162.bin, rcdata, BIN_162, 0 ... ... ; Load the 162 data from the saved resource $data = _ResourceGetAsBytes("BIN_162") Thanks for producing the UDF. I do hope it is an easy fix - like pointing out my error and smacking me over the head! M23@Melba23 Sorry but it's not possible to simply use your fix generally because my another UDF functions expect this function will return structure of bytes (and not directly bytes). I don't know simple solution for now without rewritting too much of other code :-( Resources UDF ResourcesEx UDF AutoIt Forum Search
Moderators Melba23 Posted November 12, 2008 Moderators Posted November 12, 2008 @Zedna,I hope you do not mind, but I have been playing with your UDF a little more.The only other time I could find _ResourceGetAsBytes used was as a call from within _ResourceSaveToFile, which as you stated does expect a structure and not bytes. If you replace the call with the code from the current GetAsBytes function, SaveToFile still works perfectly. Then you can add the Return DllStructGetData($struct, 1) line to the GetAsBytes function and the SaveToFile function is not affected.So GetAsBytes would read:; _ResourceGetAsBytes() doesn't work for RT_BITMAP type ; because _ResourceGet() returns hBitmap instead of memory pointer in this case Func _ResourceGetAsBytes($ResName, $ResType = 10, $ResLang = 0, $DLL = -1); $RT_RCDATA = 10 Local $ResPointer, $ResSize $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL) If @error Then Return SetError(1, 0, 0) $ResSize = @extended $struct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) < Changed Return DllStructGetData($struct, 1) ; returns bytes < Lines EndFuncWhile SaveToFile would read:expandcollapse popupFunc _ResourceSaveToFile($FileName, $ResName, $ResType = 10, $ResLang = 0, $CreatePath = 0, $DLL = -1); $RT_RCDATA = 10 Local $ResStruct, $ResSize, $FileHandle If $CreatePath Then $CreatePath = 8; mode 8 = Create directory structure if it doesn't exist in FileOpen() If $ResType = $RT_BITMAP Then ; workaround: for RT_BITMAP _ResourceGetAsBytes() doesn't work so use _ResourceGetAsImage() $hImage = _ResourceGetAsImage($ResName, $ResType) If @error Then Return SetError(10, 0, 0) ; create filepath if doesn't exist $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If @error Then Return SetError(11, 0, 0) FileClose($FileHandle) If @error Then Return SetError(12, 0, 0) _GDIPlus_ImageSaveToFile($hImage, $FileName) _GDIPlus_ImageDispose($hImage) $ResSize = FileGetSize($FileName) Else ; standard way ;$ResStruct = _ResourceGetAsBytes($ResName, $ResType, $ResLang, $DLL) < old line calling GetAsBytes ; Added lines with old GetAsBytes code Local $ResPointer $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL) If @error Then Return SetError(1, 0, 0) $ResSize = @extended $ResStruct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) ; Resume original code If @error Then Return SetError(1, 0, 0) $ResSize = DllStructGetSize($ResStruct) $FileHandle = FileOpen($FileName, 2+16+$CreatePath) If @error Then Return SetError(2, 0, 0) FileWrite($FileHandle, DllStructGetData($ResStruct, 1)) If @error Then Return SetError(3, 0, 0) FileClose($FileHandle) If @error Then Return SetError(4, 0, 0) EndIf Return $ResSize EndFunc Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ProgAndy Posted November 12, 2008 Posted November 12, 2008 (edited) Or Create a func and a wrapper func -Old Function renamed to _ResourceGetAsByteStruct(...) - wrapper: Func _ResourceGetAsBytes(...) Local $struct = _ResourceGetAsByteStruct(...) if @error Then Return Seterror(@error,@extended,0) Return DllStructGetData($struct,1) EndFunc Edited November 12, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Emiel Wieldraaijer Posted November 14, 2008 Posted November 14, 2008 @Zedna, Would it be possible to use this fantastic function to read an ini file with all it;s variables ? Thanks Emiel Best regards,Emiel Wieldraaijer
ODPOA Posted November 16, 2008 Posted November 16, 2008 Is there any way to inject a process into another process? For example to hack games people inject .dll files which have some sort of end effect (i would assume this is like multi-threading however giving the DLL access to the inter workings of the game allowing for wall hacks, and other such effects) So is there anyway to inject and executable the way you would a DLL??
Emiel Wieldraaijer Posted November 16, 2008 Posted November 16, 2008 Is there a way to embed an UniCode saved tekst file ? Ansi coded text files works perfect ... Best regards,Emiel Wieldraaijer
Zedna Posted November 16, 2008 Author Posted November 16, 2008 Is there a way to embed an UniCode saved tekst file ? Ansi coded text files works perfect ... Try this: Func _ResourceGetAsStringUnicode($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("wchar[" & $ResSize & "]", $ResPointer) Return DllStructGetData($struct, 1) ; returns string EndFunc and tell me the result. If it works I will add it in my UDF. Resources UDF ResourcesEx UDF AutoIt Forum Search
Emiel Wieldraaijer Posted November 16, 2008 Posted November 16, 2008 @Zedna,As you said .. add it to the UDF .. works perfect.. Another thing which i would really like in this UDF .. Something like this -> _ResourceGetAsArray (Also Unicode)Basicly the same as _FileReadToArray only from memory Thanks for this Super UDF Best regards,Emiel Best regards,Emiel Wieldraaijer
Zedna Posted November 17, 2008 Author Posted November 17, 2008 (edited) Another thing which i would really like in this UDF .. Something like this -> _ResourceGetAsArray (Also Unicode) Basicly the same as _FileReadToArray only from memory Just use this: $string = _ResourceGetAsString(...); or _ResourceGetAsStringUnicode() $array = StringSplit($string,'') Edited November 17, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Emiel Wieldraaijer Posted November 17, 2008 Posted November 17, 2008 Just use this: $string = _ResourceGetAsString(...); or _ResourceGetAsStringUnicode() $array = StringSplit($string,'') Thanks i will try Best regards, Emiel Best regards,Emiel Wieldraaijer
Zedna Posted November 27, 2008 Author Posted November 27, 2008 Updated first post. 2008-11-27 - added _ResourceGetAsStringW() --> for Unicode strings (Widechar) Resources UDF ResourcesEx UDF AutoIt Forum Search
Emiel Wieldraaijer Posted November 27, 2008 Posted November 27, 2008 Hi Zedna, Your latest (two) versions with the unicode support will not run on Windows 2000 it will create an application error when starting Best regards, Emiel Best regards,Emiel Wieldraaijer
Zedna Posted November 28, 2008 Author Posted November 28, 2008 (edited) Hi Zedna, Your latest (two) versions with the unicode support will not run on Windows 2000 it will create an application error when starting Best regards, Emiel I have created little test for ANSI/Unicode texts and it works fine for me on WINXP. I will test it also on my WIN98SE (with installed MSLU). --> works fine too. I suppose you haven't installed Microsoft Layer for Unicode (MSLU) http://msdn.microsoft.com/library/default...._me_systems.asp http://msdn.microsoft.com/en-us/magazine/cc301794.aspx I'm not sure about WIN 2000 maybe MSLU must be installed on them too. Test code: #AutoIt3Wrapper_useupx=n #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0 #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_2.txt, rcdata, TEST_TXT_2, 0 #AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%" #include "resources.au3" $gui = GUICreate("Data from resources example",820,400) $label1 = GUICtrlCreateLabel("",20,20,380,100) $label2 = GUICtrlCreateLabel("",20,200,380,100) GUISetState(@SW_SHOW) ; get string from resource $string = _ResourceGetAsString("TEST_TXT_1") GUICtrlSetData($label1, $string) ; get Unicode string from resource GUICtrlSetData($label2, _ResourceGetAsStringW("TEST_TXT_2")) While 1 If GUIGetMsg() = -3 Then Exit WEnd Text files: test_1.txttest_2.txt EDIT: Tested it also on my WIN98SE (with installed MSLU). --> works fine too. EDIT2: Try to instal GDI+ redistributable on your WIN2000. http://www.microsoft.com/downloads/details...;displaylang=en I think it will be GDI+ related because I call _GDIPlus_Startup() at begin of my UDF which is sure source of problems in that case. Edited November 29, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Emiel Wieldraaijer Posted November 29, 2008 Posted November 29, 2008 Hi Zedna, Indeed ..the missing GDIplus.dll is the source of the problem.. Is there no other way ? to allow Unicode files without GDI+ Thnx Emiel Best regards,Emiel Wieldraaijer
Zedna Posted November 30, 2008 Author Posted November 30, 2008 (edited) Hi Zedna,Indeed ..the missing GDIplus.dll is the source of the problem..Is there no other way ? to allow Unicode files without GDI+ThnxEmielIt has nothing to do with Unicode.I use GDI+ for images (other than BMP). Look at sources of my UDF.If you don't use JPG,PNG,GIF images then just remove all GDI+ stuff and use this modified UDF (without GDI+). Edited November 30, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Emiel Wieldraaijer Posted November 30, 2008 Posted November 30, 2008 Hi Zedna, i've already done so .. works perfect .. thanks Best regards, Emiel Best regards,Emiel Wieldraaijer
Zedna Posted November 30, 2008 Author Posted November 30, 2008 Hi Zedna,Indeed ..the missing GDIplus.dll is the source of the problem..Is there no other way ? to allow Unicode files without GDI+ThnxEmielSimpler solution is to copy missing GDIplus.dll into C:\Windows\System32\ directory (or instal gdiplus_dnld.exe) on WIN2000 stations.Then you can use my original UDF without any problems (on such stations). Resources UDF ResourcesEx UDF AutoIt Forum Search
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