Jump to content

Resource Hack through AutoIt


Recommended Posts

I don't know if your exe is valid to be opened with ResHack but you should try to google that tool :)

Since you can Run an exe with Autoit.. perhaps launching reshack and managing this like that would work.

Just trying to give some ideas

Link to comment
Share on other sites

Correct me if I'm wrong, but doesn't that edit YOUR exe during compiling. I'm trying to edit an exe of a third party app AFTER compiling. So an end user is using my app, when they start it the first time...or if they select the option to execute this function...my app would edit the resource (exe) of the other app it is going to work with in the background. Is that what Zedna's UDF does?...because I didn't get that from reading the thread.
Link to comment
Share on other sites

What do you mean by "structure"? The only "structure" I know is how it is displayed in Resource Hacker. I looked at what it look like in Notepad, but I don't see anything discernible or 'searchable' there. What do I need to know? How do I search? I did a search here, but didn't really come up with anything understandable to me. Also, is this going to require the Beta version...I'd rather stay away from it.

Link to comment
Share on other sites

Correct me if I'm wrong, but doesn't that edit YOUR exe during compiling. I'm trying to edit an exe of a third party app AFTER compiling. So an end user is using my app, when they start it the first time...or if they select the option to execute this function...my app would edit the resource (exe) of the other app it is going to work with in the background. Is that what Zedna's UDF does?...because I didn't get that from reading the thread.

My resource UDF is only for LOADING from resources.

My examples use also AutoIt3Wrapper & reshacker.exe to add data into resources AT COMPILE TIME.

Search forum for UpdateResource API

Here is link to Jos's AutoIt3Wrapper. There are also sources of his AutoIt3Wrapper (part of Scite4AutoIt3 package)

where he use UpdateResource API.

http://www.autoitscript.com/forum/index.ph...st&p=469782

Link to comment
Share on other sites

I'm using the following to try and update a dialog, and I'm getting success on every consolewrite, but that area of the application wont work anymore and when I go back into resource hacker to check on the update I get the error:

"Warning...Creation data included with compiled dialog will be lost if the file is saved!"

that shows up about 15 times when check to see if it was updated successfully, and then the last error is:

"Resource Hacker...Access violation at address 0045812B in module 'ResHacker.exe'. Read of address 02D38788.".

What is wrong? Also, is Resource Hack needed on the end user's computer to utilize this function?

#include<winapi.au3>
;
$Dialog = 5
$Filename = "C:\Additions\Misc\AppTest.exe"
$Source = "C:\Additions\Misc\1000.res"

_UpdateResources($Filename,$Source,$Dialog,1004,1033); Update Dialog

;
Func _UpdateResources($Filename,$InpResFile,$RSection,$RType,$RLanguage)
    $hDll = DllOpen("kernel32.dll")

; Begin resource Update
    $result = DllCall($hDll, "ptr", "BeginUpdateResource", "str", $Filename, "int", 0)
    ConsoleWrite('BeginUpdateResources: $result[0] = ' & $result[0] & " - LastError:"  & _WinAPI_GetLastError() & ":" & _WinAPI_GetLastErrorMessage());### Debug Console
    $rh = $result[0]

; Read file into Struct
    $hFile = _WinAPI_CreateFile($InpResFile, 2, 2)
    $tBuffer = DllStructCreate("char Text[" & FileGetSize($InpResFile)+1 & "]"); Create the buffer.
    $pBuffer = DllStructGetPtr($tBuffer)                                ; Get a pointer to that buffer.
    $bread=0
    _WinAPI_ReadFile($hFile, $pBuffer, FileGetSize($InpResFile), $bread, 0)

; Update resources
    $result = DllCall($hDll, "int", "UpdateResource", "ptr", $rh, "Long", $RSection,  "Long", $RType , "Long", $RLanguage ,"ptr",$pBuffer,'dword',DllStructGetSize ($tBuffer))
    ConsoleWrite('UpdateResources: $result[0] = ' & $result[0] & " - LastError:"  & _WinAPI_GetLastError() & ":" & _WinAPI_GetLastErrorMessage());### Debug Console

; EndUpdate
    $result = DllCall($hDll, "int", "EndUpdateResource", "ptr", $rh, "int", 0)
    ConsoleWrite('EndUpdateResources: $result[0] = ' & $result[0] & " - LastError:"  & _WinAPI_GetLastError() & ":" & _WinAPI_GetLastErrorMessage());### Debug Console

    DllClose($hdll)
EndFunc
Link to comment
Share on other sites

  • Developers

You must have a wrong structure in the file that is used to update the 1004 resource.

Updating is really fun stuff to puzzle with, but I did to add the internal resource update functions is to Dump the current resource info into a file and review it with a Hex viewer that can also compare 2 files.

This way you know that the file you use to update the resources has the same proper structure.

Jos

ps: Don;t think it will work on any UPXed program and it doesn;t wrok properly on AutoIt3 compiled scripts, Found the last one out the hard way.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1/ Again, what is meant by "Structure"? If it is the portion "1004,1033" in the function, then that is correct. If that is not the structure could you explain that some more please.

(If the structure is the "ptr, int, long" in the dllcall, I have been playing around and switching them up (I don't understand what they do I just mix and match, so could I get pointed to better info on these dll parameters than what the help is providing) but I get no difference.)

2/ How do I determine if a program is UPXed?

but I did to add the internal resource update functions is to Dump the current resource info into a file and review it with a Hex viewer that can also compare 2 files.

That sounds "above my pay grade" right now, but I'll look into it.

When you say "review it with a Hex viewer", do you mean manually? I'm not understanding how that is working.

Thanks.

Link to comment
Share on other sites

  • Developers

Bump

When you are not able to work these thing out yourself you better not try to make it work. I am not trying to make you feel stupid or put you down or anything, just being honest about it.

These aren't trivial things and you need to be able to understand whats going on before you can created a proper working script.

We have given you pointers on what to do so it is now up to you to give it a go and work things out.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

When you are not able to work these thing out yourself you better not try to make it work.

If I followed that, I would have put autoit down a long time ago, and not have learned what I have to date. It is a little hard to learn about a function when there are only 3 threads referencing UpdateResource...minus one because Zedna says his function doesn't do what I want, and minus the other because it seems you have to have resourcehack on the computer. So that leaves one solitary thread about a subject..yours, which is filled with lot of technical jargon and beta/test scripts hashing out problems that is a little hard to sift through.

Besides that, my UPXed question in the previous post might have solved my problem...I believe I understand what the structure is and I have it correct (dialog, language and such).

But I guess I'll just put this down for last in the app and muddle through it when I have more time through the dreaded msdn documents.

Link to comment
Share on other sites

  • Developers

If I were you I would use the ResHacker program and let it update the program resources in stead of trying to do it yourself.

The only reason I wrote the internal Resoirce update functions in AutoIt3Wrapper is to support X64 programs created by Aut2Exe.

ResHacker allows batch updates aswell, I have used that in AutoIt3Wrapper for quiet a while and working nicely.

Else you are obliged to hash through the MSDN Stuff like I did and I can assure you is a big puzzle. You could refer to the AutoIt3Wrapper source which has many Structures defined in it and could save some time.

I still haven't figured out how to update compiled scripts without screwing them up, but am working around that by updating the Bin file.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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