startseite
produkte
resource tuner console
beispiel-skripts
Replacing Data Types That Stored As Custom Resources
This code shows how to modify common data types that stored as custom resources: major graphic files (.GIF, .PNG, .JPG), sound (.WAV, .MIDI) and video (.AVI) files, or binary files (.CAB, TYPELIB, etc).
The ChangeCustomResource procedure lets you replace any custom resource. The script replaces GIF in demoapp1.exe with the animated gif file from the "Src" folder.
The script also replaces the standard cursor with another "xhair2.cur" file (ChangeCursor procedure), and sets the new image base (RebaseImage procedure). The resulted file will be saved to the Destination folder.
Note: when copying out the script code, please make sure there's no line breaks. This is a requirement of VBScript: the entire command must be on one line.
'------------------------------------------------------------------------------
'
' This code shows how to modify common data types that stored as custom
' resources: major graphic files (.GIF, .PNG, .JPG), sound (.WAV, .MIDI)
' and video (.AVI) files, or binary files (.CAB, TYPELIB, etc).
'
' The resulting files will be created in the directory named "Demo\Release"
' Check the log file to see the Resource Tree built.
'
'------------------------------------------------------------------------------
Sub Main
PEFileProxy.PostDebugString "Updating the checksum in the PE file header is enabled."
PEFileProxy.UpdateCheckSum = True
PEFileProxy.PostDebugString "The creation of a backup copy is disabled."
PEFileProxy.CreateBackUp = False
PEFileProxy.PostDebugString "Opening a file..."
PEFileProxy.OpenFile ".\src\DemoApp1.exe"
if (PEFileProxy.Terminated) then
PEFileProxy.PostDebugString "Opening the file produced a fatal error."
else
PEFileProxy.PostDebugString "File successfully opened."
if (not PEFileProxy.HasResources) then
PEFileProxy.PostDebugString "The file contains no resources."
else
PEFileProxy.PostDebugString "The file contains resources."
LangID = 0 ' Default
ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS
' Replace Cursor
PEFileProxy.PostDebugString "Changing/adding Cursor..."
ResourcesProxy.ChangeCursor "32761", LangID, CREATE_IF_NOT_EXIST,
REPLACE_IF_ITEM_EXISTS, ".\src\xhair2.cur"
PEFileProxy.PostDebugString "Sorting out the cursors..."
ResourcesProxy.SortGroupCursor "", True
' Replace GIF file
PEFileProxy.PostDebugString "Changing/adding Custom Resource..."
ResourcesProxy.ChangeCustomResource "DEMO_GIF", "GIF", LangID,
CREATE_IF_NOT_EXIST, ".\src\replaced.gif"
' Output the resources as Resource Tree
' Check the log file to see the Resource Tree built.
PEFileProxy.PostDebugString ""
PEFileProxy.PostDebugString "Resource Tree built by RTC:"
ResourcesProxy.ResourceTreeToLog
PEFileProxy.PostDebugString ""
' Set the ImageBase value in the PE Optional Header to the desired address.
PEFileProxy.PostDebugString "Set new ImageBase..."
if (not PEFileProxy.RebaseImage(&H00500000)) then
PEFileProxy.PostDebugString "Can't rebase file"
end if
PEFileProxy.PostDebugString "Saving file as a new file..."
PEFileProxy.SaveAsNewImage ".\release\DemoApp1.exe"
end if
PEFileProxy.PostDebugString "Closing this file..."
PEFileProxy.CloseFile
end if
end Sub
'------------------------------------------------------------------------------
|
Um die Änderungen, die man in Test-EXE-Dateien gemacht hat, zu sehen, empfehlen wir die Benutzung von Resource Tuner GUI, einem visuellen Ressourcen-Editor.
Nachdem Sie Resource Tuner Console installiert haben, finden Sie die Beispiel-Skripts in dem Verzeichnis, in dem RTC installiert wurde. Das Setup-Programm erstellt auch das Verzeichnis "Demo" im RTC-Verzeichnis, der Testanwendungen im Unterverzeichnis "Demo\Src" enthält.
So verwenden Sie die Skripts: The Complete Illustrated Step by Step Guide To Using Scripts
Download 60-Tage Resource Tuner Console Testversion
Kaufen Sie die Vollversion