Heaventools

   English English  Deutsch Deutsch

home  products  resource tuner console  sample scripts library

Adding or Replacing Bitmaps from .BMP Files

This code demonstrates how to replace bitmaps (.BMP) in EXE and DLL files using Resource Tuner Console.

The script adds or replaces bitmaps in the DemoApp1.exe file with bitmaps sourced from .bmp files found in the "\Src" folder. Additionally, the script outputs the resulting resource tree to a log file and/or the console screen.

Note: Ensure that there are no line breaks in the script code, as VBScript requires the entire command to be on one line.

Edit Bitmap

'------------------------------------------------------------------------------
'
' This script demonstrates how to modify bitmaps in executables.
'
' The script will add or replace bitmaps in DemoApp1.exe with bitmaps from .bmp
' files in the "Src" folder and output the changes in the Resource Tree 
' to a log file.
'
' The resulting files will be created in the directory named "\Release".
' Check the log file to see the built Resource Tree. 
'
'------------------------------------------------------------------------------

Sub Main
  PEFileProxy.PostDebugString "PE file header checksum updating is enabled." 
  PEFileProxy.UpdateCheckSum = True

  PEFileProxy.PostDebugString "The creation of a backup copy is disabled." 
  PEFileProxy.CreateBackUp = False

  PEFileProxy.PostDebugString "Open the file for editing..."
  PEFileProxy.OpenFile ".\src\DemoApp1.exe"
  if (PEFileProxy.Terminated) then
    ' Issue a warning in case of error
    PEFileProxy.PostDebugString "Error when opening this file."
  else
    PEFileProxy.PostDebugString "File opened OK."
    if (not PEFileProxy.HasResources) then
      PEFileProxy.PostDebugString "The file contains no resources."
    else
      PEFileProxy.PostDebugString "The file contains resources."      

      ' This specifies the default language      
      LangID = 0 ' Default
      ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS

      PEFileProxy.PostDebugString "Change/add the bitmap..."
      ResourcesProxy.ChangeBitmap "THEBITMAP", LangID, 
CREATE_IF_NOT_EXIST, ".\src\thebitmap.bmp"

      ' Build and output the Resource Tree to a log. Optional (for demo purposes).
      ' Check the log file to see the Resource Tree built. 
      PEFileProxy.PostDebugString ""
      PEFileProxy.PostDebugString "Resource Tree built by RTC:"
      ResourcesProxy.ResourceTreeToLog
      PEFileProxy.PostDebugString ""

      ' Save file
      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

To view the changes made to the test EXE file, you can open it using Resource Tuner GUI.


SAMPLE SCRIPTS LIBRARY

Once installed Resorce Tuner Console, you will find the Demo Scripts folder nested within the directory where RTC has been installed. Within this Demo folder, there are 12 subdirectories containing script examples and sample executable files.

All sample scripts are ready to run. Select one of the .BAT files located within the Demo Scripts folders to execute the sample script. The script will make changes in the test EXE file. The resulting file will be created in the directory named Release under the directory containing the script.

The Complete Illustrated Step-by-Step Guide To Using Scripts

 Download Resource Tuner Console and learn how it can make you more productive.