How to make an string replacemnt based on a certain string ?


For example, Let?s say that when you open an .asm file on richedit (or notepad or any editor).

It opens the file and show something like:

push dword ptr
push dword ptr
push dword ptr
push dword ptr
call MyFunction


How can i make a check beginning with this order:

- Search for MyFunction
- Finds dword ptr and replace to Value1
- Finds dword ptr and replace to Value2
- Finds dword ptr and replace to Value3
- Finds dword ptr and replace to Value4

So the result should be changed to

push Value4
push Value3
push Value2
push Value1
call MyFunction

So it is a search perform routine bases on a specified string that seraches up others strings to replace.

Regards,

Beyond2000!
Posted on 2002-05-10 17:41:24 by Beyond2000!
You find your answer behind this button:
Posted on 2002-05-10 18:27:16 by bazik
Hi Bazik


I already did that, but nothing seems to fit to this issue.


I was saying in replace the text in a specific order. Withou perfoming on the specified string is.

For example if the string is

push dword ptr
push dword ptr
mov eax, 01 ---->somecode inside etc...
push dword ptr
xor eax, eax ---->somecode inside etc...
push dword ptr
call MyFunction

The search function should goes up....finding the string as wanted

-He first find the string "Myfunction",
-Then he goes up and serach for the "push"...he sees the push at the second line imediate above, and do a replace on the rest of the string to the end of the line"dword ptr "
- He goes up again find the push at the 4th line up, and replace.


The replacemnt bases could be either
-Finding "push" and replacing all the rest to the end of the line
or
- Find somedata inside the string inside the push (Seeking for dword ptr , for example, replacing only what is inside "??" string


After all this he searches down the text file for the next "Myfunction" string and he he found nothing, he returns.

On the board i didn't see something like this seraching up for specified strings and replacing to the end of the line and stuff.


Regards,

Beyond2000!
Posted on 2002-05-10 22:08:54 by Beyond2000!
Posted on 2002-05-11 03:36:49 by bazik
Hi Bazik

I read them...and there are others on the board, the algo's that are used inside a function replacment was alright.

But they don't shows how to perfome a codeback search and replace....In other hands, beginning the search from the end of the file.....Down to up....and not the opposite as are reported on the board.


The one i was looking for was that begins searching and replacing at the end of the file...so i guess that is the better way to perfome this kinda check (The codeback i mean)

Regards

Beyond2000!
Posted on 2002-05-11 04:31:14 by Beyond2000!