wolf9228 Posted March 16, 2008 Posted March 16, 2008 (edited) Where mistake UpdatDresourcesexpandcollapse popup#Include <WinAPI.au3> ;http://msdn2.microsoft.com/en-us/library/ms648008(VS.85).aspx ;The following example copies a dialog box resource from one executable file, Hand.exe, to another, Foot.exe, by following these steps: ;Use the LoadLibrary function to load the executable file Hand.exe. ;Use the FindResource and LoadResource functions to locate and load the dialog box resource. ;Use the LockResource function to retrieve a pointer to the dialog box resource data. ;Use the BeginUpdateResource function to open an update handle to Foot.exe. ;Use the UpdateResource function to copy the dialog box resource from Hand.exe to Foot.exe. ;Use the EndUpdateResource function to complete the update. ;The following code implements these steps. Global Const $RT_CURSOR = 1 Global Const $RT_BITMAP = 2 Global Const $RT_ICON = 3 Global Const $RT_MENU = 4 Global Const $RT_DIALOG = 5 Global Const $RT_STRING = 6 Global Const $RT_FONTDIR = 7 Global Const $RT_FONT = 8 Global Const $RT_ACCELERATORS = 9 Global Const $RT_RCDATA = 10 Global Const $RT_MESSAGETABLE = 11 Global Const $RT_GROUP_CURSOR = 12 Global Const $RT_GROUP_ICON = 14 Global Const $RT_VERSION = 16 Global Const $RT_ANICURSOR = 21 Global Const $RT_ANIICON = 22 Global Const $RT_HTML = 23 Global Const $RT_MANIFEST = 24 Global Const $SND_RESOURCE = 0x00040004 Global Const $SND_SYNC = 0x0 Global Const $SND_ASYNC = 0x1 Global Const $SND_LOOP = 0x8 Global Const $SND_NOSTOP = 0x10 Global Const $SND_NOWAIT = 0x2000 Global Const $SND_PURGE = 0x40 Func Process_Updating_Resources($pFileName = "Hand.exe" _ ,$pFileNameUpdat = "Foot.exe" _ ,$ResName = "Dialog" _ , $ResType = $RT_DIALOG _ ,$LANG_NEUTRAL = 0409 _;English_United_States ,$SUBLANG_NEUTRAL = 0409);English_United_States ;Load the .EXE file that contains the dialog box you want to copy. $hExe = _WinAPI_LoadLibrary($pFileName) if ($hExe = 0) Then MsgBox(0,"LoadLibrary", "Could not load exe.") Return 0 ENDIF ;Locate the dialog box resource in the .EXE file. $hRes = FindResource($hExe, $ResName, $ResType) if @error then MsgBox(0,"FindResource", "Could not locate dialog box.") Return 0 ENDIF ;Load the dialog box into global memory. $hResLoad = LoadResource($hExe, $hRes) if @error then MsgBox(0,"LoadResource", "Could not load dialog box.") Return 0 ENDIF ;Lock the dialog box into global memory. $lpResLock = LockResource($hResLoad) if @error Then MsgBox(0,"LockResource", "Could not lock dialog box .") Return 0 ENDIF ;Open the file to which you want to add the dialog box resource. $hUpdateRes = BeginUpdateResource($pFileNameUpdat, False) if @error then MsgBox(0,"BeginUpdateResource", "Could not open file for writing.") Return 0 ENDIF $MAKELANGID = _WinAPI_MAKELANGID($LANG_NEUTRAL, $SUBLANG_NEUTRAL) ;Add the dialog box resource to the update list. $result = UpdateResource($hUpdateRes, _;update resource handle $ResType, _ ;change dialog box resource $ResName, _ ;dialog box name $MAKELANGID, _ ;neutral language $lpResLock, _ ;ptr to resource info SizeofResource($hExe, $hRes)); // size of resource info. if ($result == FALSE) then MsgBox(0,"UpdateResource", "Could not add resource.") Return 0 ENDIF ;Write changes to FOOT.EXE and then close it. if (EndUpdateResource($hUpdateRes,True)) Then MsgBox(0,"EndUpdateResource", "Could not End Update Resource.") ENDIF ;Clean up. if Not (_WinAPI_FreeLibrary($hExe)) Then MsgBox(0,"FreeLibrary", "Could not free executable.") Return 0 ELSE Return 1 ENDIF EndFunc Func FindResource($hModule , _ $lpName , _ $lpType) ;http://msdn2.microsoft.com/en-us/library/ms648042(VS.85).aspx $Callresult = DllCall("kernel32.dll" ,"int", "FindResourceA", "hwnd", $hModule, "str", $lpName _ ,"long", $lpType) MsgBox(0,"FindResourceA", _WinAPI_GetLastErrorMessage()) Return $Callresult[0] EndFunc Func LoadResource($hModule, _ $hResInfo) ;http://msdn2.microsoft.com/en-us/library/ms648046(VS.85).aspx $Callresult = DllCall("kernel32.dll", "int", "LoadResource", "int", $hModule, "int", $hResInfo) MsgBox(0,"LoadResource", _WinAPI_GetLastErrorMessage()) Return $Callresult[0] EndFunc Func LockResource($hResData) ;http://msdn2.microsoft.com/en-us/library/ms648047(VS.85).aspx $Callresult = DllCall("kernel32.dll", "int", "LockResource", "int", $hResData) MsgBox(0,"LockResource", _WinAPI_GetLastErrorMessage()) Return $Callresult[0] EndFunc Func SizeofResource($hModule, _ $hResInfo) ;http://msdn2.microsoft.com/en-us/library/ms648048(VS.85).aspx $Callresult = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hModule, "int", $hResInfo) MsgBox(0,"SizeofResource", _WinAPI_GetLastErrorMessage()) Return $Callresult[0] EndFunc Func BeginUpdateResource($pFileName , _ $bDeleteExistingResources) ;http://msdn2.microsoft.com/en-us/library/ms648030(VS.85).aspx $Callresult = DllCall("kernel32.dll", "int", "BeginUpdateResource", "str", $pFileName, "int", _ $bDeleteExistingResources) Return $Callresult[0] EndFunc Func UpdateResource($hUpdate, _ $lpType, _ $lpName, _ $wLanguage, _ $lpData, _ $cbData ) ;http://msdn2.microsoft.com/en-us/library/ms648049(VS.85).aspx $Callresult = DllCall("kernel32.dll", "int", "UpdateResource","hwnd",$hUpdate, "str", $lpType, "str", $lpName _ ,"short",$wLanguage,"prt",$lpData,"DWORD",$cbData) MsgBox(0,"UpdateResource", _WinAPI_GetLastErrorMessage()) Return $Callresult EndFunc Func EndUpdateResource($hUpdate, _ $fDiscard) ;http://msdn2.microsoft.com/en-us/library/ms648032(VS.85).aspx $Callresult = DllCall("kernel32.dll", "int", "EndUpdateResource","hwnd",$hUpdate,"int",$fDiscard) MsgBox(0,"EndUpdateResource", _WinAPI_GetLastErrorMessage()) Return $Callresult[0] EndFuncHand.exe#AutoIt3Wrapper_useupx=n #AutoIt3Wrapper_run_after="AddRes.exe "%out%"" #include <GUIConstants.au3> #Include "resources.au3" $TXT = _ResourceGetAsString("AboutBox", $RT_RCDATA,0) $TXT = StringSplit($TXT,@CRLF) $Form1 = GUICreate("AboutBox Hand.exe", 324, 234, 210, 161) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) $Image1 = GUICtrlCreatePic("", 16, 24, 105, 97) $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP) $Label2 = GUICtrlCreateLabel("Version " & $TXT[3], 152, 48, 300, 17, $WS_GROUP) $Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP) $Label3 = GUICtrlCreateLabel("Copyright " & $TXT[1], 16, 136, 300, 17, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button2 = GUICtrlCreateButton("Chk_Update",152, 100, 75, 25 ) $Button1 = GUICtrlCreateButton("&ok", 112, 208, 75, 25) GUISetState(@SW_SHOW) _ResourceSetImageToCtrl($Image1, "AboutBoximage", 2) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE OR $nMsg = $Button1 Exit Case $nMsg = $Button2 MsgBox(0,"Hand.exe","thes Box For Hand.exe" & @CRLF & "Version 1.1.1.0" _ & @CRLF & "Copyright Wolf Microsoft" ) EndSelect WEndTXTBox.txt ===> Hand.exeWolf Microsoft 1.1.1.0Foot.exe#AutoIt3Wrapper_useupx=n #AutoIt3Wrapper_run_after="AddRes.exe "%out%"" #include <GUIConstants.au3> #Include "resources.au3" $TXT = _ResourceGetAsString("AboutBox", $RT_RCDATA,0) $TXT = StringSplit($TXT,@CRLF) $Form1 = GUICreate("AboutBox Foot.exe", 324, 234, 210, 161) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) $Image1 = GUICtrlCreatePic("", 16, 24, 105, 97) $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP) $Label2 = GUICtrlCreateLabel("Version " & $TXT[3], 152, 48, 300, 17, $WS_GROUP) $Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP) $Label3 = GUICtrlCreateLabel("Copyright " & $TXT[1], 16, 136, 300, 17, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button2 = GUICtrlCreateButton("Chk_Update",152, 100, 75, 25 ) $Button1 = GUICtrlCreateButton("&ok", 112, 208, 75, 25) GUISetState(@SW_SHOW) _ResourceSetImageToCtrl($Image1, "AboutBoximage", 2) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE OR $nMsg = $Button1 Exit Case $nMsg = $Button2 MsgBox(0,"Foot.exe","thes Box For Foot.exe" & @CRLF & "Version 0.0.0.0" _ & @CRLF & "Copyright Bill Microsoft" ) EndSelect WEndTXTBox.txt ===> Foot.exeBill Microsoft 0.0.0.0AddRes.exe$ResName = "AboutBox" $ResType = "RCDATA" $COMMAND = "ResHacker.exe -addoverwrite AU3.EXE, AU3.EXE, TXTBox.TXT," & $ResType & ", " & $ResName & ", 0" IF Run($COMMAND ,"",@SW_HIDE) THEN _ MsgBox(0,"err", "AddRes.exe Done1") $ResName = "AboutBoximage" $ResType = "BITMAP" $COMMAND = "ResHacker.exe -addoverwrite AU3.EXE, AU3.EXE, AboutBoxImage.bmp," & $ResType & ", " & $ResName & ", 0" IF Run($COMMAND ,"",@SW_HIDE) THEN _ MsgBox(0,"err", "AddRes.exe Done2")STARTUpdatDresources#include "UpdatDresources.AU3" Global $pFileName = @ScriptDir & "\Wolf\Hand.exe" Global $pFileNameUpdat = @ScriptDir & "\Bill\Foot.exe" FileCopy($pFileNameUpdat, @ScriptDir & "\UpdatFoot.exe",1) FileCopy($pFileName, @ScriptDir & "\Hand.exe",1) Sleep(3000) Global $pFileNameUpdat = "UpdatFoot.exe" Global $pFileName = "Hand.exe" Process_Updating_Resources($pFileName _ ,$pFileNameUpdat _ ,"AboutBox" _ ,$RT_RCDATA _ ,0409 _ ,0409)UpdatRes.ziphttp://www.2shared.com/file/2997750/7387c7ce/UpdatRes.html Edited March 16, 2008 by wolf9228 youtuber 1 صرح السماء كان هنا
Achilles Posted March 17, 2008 Posted March 17, 2008 (edited) What is the mistake? I haven't even tried running the code due to the amount of scripts I would have to arrange... Edit: I just noticed this is in Example Scripts... So maybe "Where mistake" isn't supposed to mean "Where is the mistake?" like I assumed. Edited March 18, 2008 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
wolf9228 Posted March 18, 2008 Author Posted March 18, 2008 (edited) What is the mistake? I haven't even tried running the code due to the amount of scripts I would have to arrange...Edit: I just noticed this is in Example Scripts... So maybe "Where mistake" isn't supposed to mean "Where is the mistake?" like I assumed.http://www.2shared.com/file/2997750/7387c7ce/UpdatRes.html Edited March 18, 2008 by wolf9228 صرح السماء كان هنا
HJW Posted March 21, 2008 Posted March 21, 2008 (edited) Hi any possibilities of a function that reads the language of the resources before patching ? like bitmap 101 has 4019 and icon 2 has neutral. thanks HJW EDIT: EnumResLangProc Function should be it. Any know how how to setup this in autoit ? Edited March 21, 2008 by HJW
wolf9228 Posted March 23, 2008 Author Posted March 23, 2008 Hi any possibilities of a function that reads the language of the resources before patching ? like bitmap 101 has 4019 and icon 2 has neutral. thanks HJW EDIT: EnumResLangProc Function should be it. Any know how how to setup this in autoit ? All the files on this link http://www.2shared.com/file/3032894/2f15b909/Res_Update.html Res_Update.au3 expandcollapse popup#include-once #Include <WinAPI.au3> Global Const $Afrikaans = 1078 Global Const $Albanian = 1052 Global Const $Arabic_Algeria = 5121 Global Const $Arabic_Bahrain = 15361 Global Const $Arabic_Egypt = 3073 Global Const $Arabic_Iraq = 2049 Global Const $Arabic_Jordan = 11265 Global Const $Arabic_Kuwait = 13313 Global Const $Arabic_Lebanon = 12289 Global Const $Arabic_Libya = 4097 Global Const $Arabic_Morocco = 6145 Global Const $Arabic_Oman = 8193 Global Const $Arabic_Qatar = 16385 Global Const $Arabic_Saudi_Arabia = 1025 Global Const $Arabic_Syria = 10241 Global Const $Arabic_Tunisia = 7169 Global Const $Arabic_U_A_E = 14337 Global Const $Arabic_Yemen = 9217 Global Const $Basque = 1069 Global Const $Belarusian = 1059 Global Const $Bulgarian = 1026 Global Const $Catalan = 1027 Global Const $Chinese_Hong_Kong_SAR = 3076 Global Const $Chinese_PRC = 2052 Global Const $Chinese_Singapore = 4100 Global Const $Chinese_Taiwan = 1028 Global Const $Croatian = 1050 Global Const $Czech = 1029 Global Const $Danish = 1030 Global Const $Dutch = 1043 Global Const $Dutch_Belgium = 2067 Global Const $English_Australia = 3081 Global Const $English_Belize = 10249 Global Const $English_Canada = 4105 Global Const $English_Ireland = 6153 Global Const $English_Jamaica = 8201 Global Const $English_New_Zealand = 5129 Global Const $English_South_Africa = 7177 Global Const $English_Trinidad = 11273 Global Const $English_United_Kingdom = 2057 Global Const $English_United_States = 1033 Global Const $Estonian = 1061 Global Const $Faeroese = 1080 Global Const $Farsi = 1065 Global Const $Finnish = 1035 Global Const $French_Standard = 1036 Global Const $French_Belgium = 2060 Global Const $French_Canada = 3084 Global Const $French_Luxembourg = 5132 Global Const $French_Switzerland = 4108 Global Const $Gaelic_Scotland = 1084 Global Const $German_Standard = 1031 Global Const $German_Austrian = 3079 Global Const $German_Liechtenstein = 5127 Global Const $German_Luxembourg = 4103 Global Const $German_Switzerland = 2055 Global Const $Greek = 1032 Global Const $Hebrew = 1037 Global Const $Hindi = 1081 Global Const $Hungarian = 1038 Global Const $Icelandic = 1039 Global Const $Indonesian = 1057 Global Const $Italian_Standard = 1040 Global Const $Italian_Switzerland = 2064 Global Const $Japanese = 1041 Global Const $Korean = 1042 Global Const $Latvian = 1062 Global Const $Lithuanian = 1063 Global Const $Macedonian_FYROM = 1071 Global Const $Malay_Malaysia = 1086 Global Const $Maltese = 1082 Global Const $Norwegian_Bokml = 1044 Global Const $Polish = 1045 Global Const $Portuguese_Brazil = 1046 Global Const $Portuguese_Portugal = 2070 Global Const $Raeto_Romance = 1047 Global Const $Romanian = 1048 Global Const $Romanian_Moldova = 2072 Global Const $Russian = 1049 Global Const $Russian_Moldova = 2073 Global Const $Serbian_Cyrillic = 3098 Global Const $Setsuana = 1074 Global Const $Slovak = 1051 Global Const $Slovenian = 1060 Global Const $Sorbian = 1070 Global Const $Spanish_Argentina = 11274 Global Const $Spanish_Bolivia = 16394 Global Const $Spanish_Chile = 13322 Global Const $Spanish_Columbia = 9226 Global Const $Spanish_Costa_Rica = 5130 Global Const $Spanish_Dominican_Republic = 7178 Global Const $Spanish_Ecuador = 12298 Global Const $Spanish_El_Salvador = 17418 Global Const $Spanish_Guatemala = 4106 Global Const $Spanish_Honduras = 18442 Global Const $Spanish_Mexico = 2058 Global Const $Spanish_Nicaragua = 19466 Global Const $Spanish_Panama = 6154 Global Const $Spanish_Paraguay = 15370 Global Const $Spanish_Peru = 10250 Global Const $Spanish_Puerto_Rico = 20490 Global Const $Spanish_Spain = 1034 Global Const $Spanish_Uruguay = 14346 Global Const $Spanish_Venezuela = 8202 Global Const $Sutu = 1072 Global Const $Swedish = 1053 Global Const $Swedish_Finland = 2077 Global Const $Thai = 1054 Global Const $Turkish = 1055 Global Const $Tsonga = 1073 Global Const $Ukranian = 1058 Global Const $Urdu_Pakistan = 1056 Global Const $Vietnamese = 1066 Global Const $Xhosa = 1076 Global Const $Yiddish = 1085 Global Const $Zulu = 1077 Global Const $RT_CURSOR = 1 Global Const $RT_BITMAP = 2 Global Const $RT_ICON = 3 Global Const $RT_MENU = 4 Global Const $RT_DIALOG = 5 Global Const $RT_STRING = 6 Global Const $RT_FONTDIR = 7 Global Const $RT_FONT = 8 Global Const $RT_ACCELERATORS = 9 Global Const $RT_RCDATA = 10 Global Const $RT_MESSAGETABLE = 11 Global Const $RT_GROUP_CURSOR = 12 Global Const $RT_GROUP_ICON = 14 Global Const $RT_VERSION = 16 Global Const $RT_ANICURSOR = 21 Global Const $RT_ANIICON = 22 Global Const $RT_HTML = 23 Global Const $RT_MANIFEST = 24 Global Const $SND_RESOURCE = 0x00040004 Global Const $SND_SYNC = 0x0 Global Const $SND_ASYNC = 0x1 Global Const $SND_LOOP = 0x8 Global Const $SND_NOSTOP = 0x10 Global Const $SND_NOWAIT = 0x2000 Global Const $SND_PURGE = 0x40 FileCopy(@ScriptDir & "\original\msgbox.exe" , @ScriptDir & "\AUTOIT.EXE",1) _UpdateResource() FileCopy(@ScriptDir & "\original\TapEditor.exe" , @ScriptDir & "\C++.exe",1) _UpdateResource("C++.exe") Func _UpdateResource($sFile = "AUTOIT.EXE",$lpType = $RT_RCDATA ,$lpName = "DATA_1", _ $wLanguage = $English_United_Kingdom,$bDiscard = False,$InpResFile = "TXT.TXT") $hUpdate = _BeginUpdateResource($sFile) Local $result, $hFile, $tSize, $tBuffer, $pBuffer,$bread = 0 Select Case $lpType = 10 OR $lpType = 16 OR $lpType = 24;RT_RCDATA, RT_VERSION and RT_MANIFEST $hFile = _WinAPI_CreateFile($InpResFile, 2, 2) IF @error THEN Return 0 $tSize = FileGetSize($InpResFile) IF @error THEN Return 0 $tBuffer = DllStructCreate("char Text[" & $tSize & "]") IF @error THEN Return 0 $pBuffer = DllStructGetPtr($tBuffer) IF @error THEN Return 0 _WinAPI_ReadFile($hFile, $pBuffer, FileGetSize($InpResFile), $bread, 0) IF @error THEN Return 0 _WinAPI_CloseHandle($hFile) IF @error THEN Return 0 $result = DllCall("kernel32.dll","int","UpdateResource", _ "hwnd",$hUpdate, _ "long",$lpType, _ "str",$lpName, _ "short",$wLanguage, _ "ptr",$pBuffer, _ "DWORD",$tSize) IF @error THEN Return 0 Else _EndUpdateResource($hUpdate,$bDiscard) Return 1 EndIf EndSelect EndFunc Func _BeginUpdateResource($sFile) $aReturn = DllCall("kernel32.dll","int","BeginUpdateResource","str",$sFile,"int",False) Return $aReturn[0] EndFunc Func _EndUpdateResource($hResource,$bDiscard = 0) $result = DllCall("kernel32.dll", "int", "EndUpdateResource", "int", $hResource, "int", $bDiscard) EndFunc AUTOIT.EXE When opening the file shows the letter C++.EXE the file open without errors youtuber 1 صرح السماء كان هنا
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