Ability to use substitute in scripts? Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Hex Editing » Ability to use substitute in scripts? « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Xander Delores
Username: climbatiz

Registered: N/A
Posted on Thursday, Jan 10, 2008 - 17:03:   

so i was replacing some text with the Search>Replace Text function and (never read this b4) noticed it asked me if i wanted to add bytes to file becuz my line was longer or if i wanted to just replace everything after it without changing file size,
then i thought since this is possible in this section it must be possible using some command with ReplaceAll when doing scripts, without checking it first out and figuring it must be possible i then spent a few hrs in notepad redoing my script to do this and when i was finished i noticed the ReplaceAll function doesn't support substitute and will just as usual add bytes to file if my replace text is longer, oh what a waste of time :{ hehe

anyways, was hoping if this option could be added in a new version or unless it already exists (although i looked pretty thouroughly and didn't see anything that could help me)

why i need substitute is first of all cuz i can't change file size, like if i wanted to change (for example)
"Cars" into "Automobile" or
"Aeroplane" into "Plane"
all the letters in original file after the word Cars or Aeroplane are 0x00's and therefor can't be written in the script
unless i change it all to hex, but there's like 2000 commands in the script and last time i ran a smaller version of it in hex it seemed to take 4ever
however with the substitute options i figured i would just make "Aeroplane" change into "Plane$$$$" ($ being some char that isn't anywhere in original file) and then after script has run i would replace all my $$'s into 0x00's

well... that's about it, hope to get some answer ;}
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Thursday, Jan 10, 2008 - 18:01:   

First of all please note that you can run your own scripts only with the full version of WinHex.
Top of pagePrevious messageNext messageBottom of page Link to this message

Xander Delores
Username: climbatiz

Registered: N/A
Posted on Thursday, Jan 10, 2008 - 18:13:   

umm... do you mean like i can't substitute text cuz i might not be using a full version or are you just noting that for any1 else who might read this?
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Thursday, Jan 10, 2008 - 18:31:   

It's possible to replace ASCII text with a script, like replace "abc" with "zxy" or "123" with "fghijkl". If you replace some text with text of a different length, the file size changes. Sorry, I'm not exactly sure what you mean by "support substitute". Anyway, I prefer to not spend more time on this issue as the full version and support for it is limited to customers of ours.
Top of pagePrevious messageNext messageBottom of page Link to this message

Xander Delores
Username: climbatiz

Registered: N/A
Posted on Thursday, Jan 10, 2008 - 18:33:   

in the help faq for replace options

"WinHex is able to replace one string or hex value sequence with another one that has a different length. You will be prompted, which of the following methods shall be applied:

1st method: The data behind the occurrence is moved due to length difference. So the file size is changed. This method must not be applied to certain file types, such as executable files. It is even possible to specify nothing as the substitute, which means all occurrences will be removed from the file!

2nd method: The substitute is written into the file at the position of the occurrence. If the substitute is shorter than the searched character sequence, the exceeding characters will remain in the file. Otherwise even the bytes behind the occurrence will be overwritten (as far as the end of the file is not reached). The file size is not affected."
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Thursday, Jan 10, 2008 - 18:41:   

I was writing about replacing text with a script.

That's it, topic closed, account deleted.
Forum operated by X-Ways Software Technology AG.