Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help Please] Changing name of a window.
Goto page 1, 2, 3  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Tue Apr 21, 2009 3:07 am    Post subject: [Help Please] Changing name of a window. Reply with quote

Ok, so there is big exe file (lets say abc.exe) that I would like to edit.
Lets assume that window's name is xyz.

Editing abc.exe with hex editor and changing all occurances of xyz to zyx didn't work - abc.exe crashes (no wonder - there were like 500 occurances of xyz)

I tried running ollydbg with it but I am kinda lost......

Any help please?

_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Tue Apr 21, 2009 3:59 am    Post subject: Reply with quote

Try to set a breakpoint on CreateWindow. Then when the application calls it, find out where it gets the window name from.
Back to top
View user's profile Send private message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Wed Apr 22, 2009 2:16 pm    Post subject: Reply with quote

ummm I am figuring it now... I somehow can't make it. Don't know why....
_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Apr 22, 2009 2:52 pm    Post subject: Reply with quote

SetWindowText
http://msdn.microsoft.com/en-us/library/ms633546(VS.85).aspx

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Wed Apr 22, 2009 4:31 pm    Post subject: Reply with quote

You could try opening it with a programme like this:
http://www.angusj.com/resourcehacker/
Back to top
View user's profile Send private message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Wed Jun 17, 2009 12:20 pm    Post subject: Reply with quote

The resource hacker didn't help.
The breakpoint at CreateWindow didn't help.
Checking out SetWindowText helped. Kinda.

There is this
push ecx,
push eax,
<this funny call to setwindowtext>

so I wanted to edit the push ecx part for example with
add ecx, 8
push ecx
even that slight change (eating one letter) would satisfy me. However when I want to do this olly says there is not enough room for such change. When I uncheck keep size the next few lines of the code get messed up automatically.

I wonder what tremendous changes would it require to change that name title to something completly different....

_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Jun 17, 2009 12:25 pm    Post subject: Reply with quote

Check up a bit and look where ecx has it's value set. I think it should be storing the address which the window title is stored at.
Back to top
View user's profile Send private message MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Wed Jun 17, 2009 1:07 pm    Post subject: Reply with quote

tommmmmm wrote:
The resource hacker didn't help.
The breakpoint at CreateWindow didn't help.
Checking out SetWindowText helped. Kinda.

There is this
push ecx,
push eax,
<this funny call to setwindowtext>

so I wanted to edit the push ecx part for example with
add ecx, 8
push ecx
even that slight change (eating one letter) would satisfy me. However when I want to do this olly says there is not enough room for such change. When I uncheck keep size the next few lines of the code get messed up automatically.

I wonder what tremendous changes would it require to change that name title to something completly different....
Of course it won't work, what you need to do is overwrite it with a jump to some codecave, write your code including the overwritten instructions, and then jmp back. Noz's suggestion is ideal if the string is a global string.
_________________
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Jun 18, 2009 11:40 am    Post subject: Reply with quote

sponge wrote:
tommmmmm wrote:
The resource hacker didn't help.
The breakpoint at CreateWindow didn't help.
Checking out SetWindowText helped. Kinda.

There is this
push ecx,
push eax,
<this funny call to setwindowtext>

so I wanted to edit the push ecx part for example with
add ecx, 8
push ecx
even that slight change (eating one letter) would satisfy me. However when I want to do this olly says there is not enough room for such change. When I uncheck keep size the next few lines of the code get messed up automatically.

I wonder what tremendous changes would it require to change that name title to something completly different....
Of course it won't work, what you need to do is overwrite it with a jump to some codecave, write your code including the overwritten instructions, and then jmp back. Noz's suggestion is ideal if the string is a global string.


Don't see the point in all of that mess. Just detour SetWindowText and edit the parameters.
Back to top
View user's profile Send private message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Fri Sep 04, 2009 11:02 am    Post subject: Reply with quote

I heard somewhere that you can't make jumps larger than set size, so editing the ecx at the end of the program is impossible.

I went back to idea of a constant - I found
MOV ECX,DWORD PTR SS:[ARG.7]
right before the function call

but wtf is ARG.7
I don't even know where to look for it......


-----
edit: when I clicked in olly it suddenly showed [ESP+6C]
I tried editing it to +75 or to +5A
In first case I got empty title in second some fancy letters.

ps: I presume it would be nice to see where esp leads, however it's not me who launches application (there is a launcher that launches launcher that launches application) so I have no idea what to do...

_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Sep 04, 2009 11:35 am    Post subject: Reply with quote

void:] wrote:
sponge wrote:
tommmmmm wrote:
The resource hacker didn't help.
The breakpoint at CreateWindow didn't help.
Checking out SetWindowText helped. Kinda.

There is this
push ecx,
push eax,
<this funny call to setwindowtext>

so I wanted to edit the push ecx part for example with
add ecx, 8
push ecx
even that slight change (eating one letter) would satisfy me. However when I want to do this olly says there is not enough room for such change. When I uncheck keep size the next few lines of the code get messed up automatically.

I wonder what tremendous changes would it require to change that name title to something completly different....
Of course it won't work, what you need to do is overwrite it with a jump to some codecave, write your code including the overwritten instructions, and then jmp back. Noz's suggestion is ideal if the string is a global string.


Don't see the point in all of that mess. Just detour SetWindowText and edit the parameters.

that's quite stupid. do you realise how many times that function might be called ? also most window creations do not even use SetWindowText() for setting title text.. so it's quite possible the hook would not work for future versions of the program
tommmmmm wrote:
I heard somewhere that you can't make jumps larger than set size, so editing the ecx at the end of the program is impossible.

I went back to idea of a constant - I found
MOV ECX,DWORD PTR SS:[ARG.7]
right before the function call

but wtf is ARG.7
I don't even know where to look for it......


-----
edit: when I clicked in olly it suddenly showed [ESP+6C]
I tried editing it to +75 or to +5A
In first case I got empty title in second some fancy letters.

ps: I presume it would be nice to see where esp leads, however it's not me who launches application (there is a launcher that launches launcher that launches application) so I have no idea what to do...

[ESP+6C] is a value on the stack. i am guessing what is happening is that a pointer to the window title is pushed onto the stack at some point and hence it is pointed to by ESP+6C. editing the offset does nothing other than make the title pointer to be some other random place on the stack

there are two easy ways as a solution. first off you can scroll up and find out where the pointer is being pushed. let's say it is pushing ecx << being the pointer to title. since ecx is the pointer if you follow it in the hex dump you should find the title in the data section of the program ; ) you can then edit it there. that would be the cleanest solution

a messy way and overkill is to codecave at various places, eg. just before the [ESP+6C] and then to edit the pointer there, or codecaving ecx, etc. etc.

actually an easy way to achieve what you are trying to do is to use CE to scan for the window title as a string. once you have the address you can go there in memory view and edit it there. alternatively you could breakpoint on access that address and change references to it to point to another string that you define yourself. instead of changing all references though, you need to make sure you just change the right ones

upload the exe somewhere and post the link and i'll show you what needs to be done
Back to top
View user's profile Send private message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Fri Sep 04, 2009 12:12 pm    Post subject: Reply with quote

I read a bit about code caving and I code caved
push ecx,
push eax,
<this funny call to setwindowtext>

to
add ecx, <insert some number here>
push ecx,
push eax,
<this funny call to setwindowtext>

Facts:
add ecx, 0 ; leaves old name of the program - which at least means code cave is correct and everything is working

add ecx, 8 ; gives empty one
sub ecx, 8 ; gives fancy letters

which all makes sense because we had
mov ecx, [esp+6c]
push ecx,
push eax
<call to function>

so editing esp+6c is same as editing ecx later on in the code cave.

Which leads me to the point that the mistake was at the very beginning of thoughtful process - ansi letter is not 8 bits..... but google says it is...
so I am stuck again...


ps: and the part about following esp in hex dump is a total mystery to me.... esp is set some time in the past - probably long ago in the code - so getting the esp value (then addig offset to get data string) is impossible....

_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....


Last edited by tommmmmm on Fri Sep 04, 2009 12:20 pm; edited 1 time in total
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Sep 04, 2009 12:18 pm    Post subject: Reply with quote

hex dump window is the one at bottom left. ansi letter is 8 bits indeed

add ecx, 0 >> changes nothing
add ecx, 8 >> changes title pointer to 8 letters ahead. since it's blank i am guessing the title is 7 or shorter bytes and you have changed the pointer to the null terminator or something past that
sub ecx, 8 >> changes title pointer to whatever random data was 8 bytes before

here is how to change the title. breakpoint on the push ecx, check ecx's value in the registers window on top right. go to hex dump >> ctrl-g >> enter that address

edit the address there, save the change

otherwise find another codecave, write your new title and in your codecaved bit, do mov ecx, X where X is a pointer to your new title
Back to top
View user's profile Send private message
tommmmmm
Expert Cheater
Reputation: 0

Joined: 09 Apr 2006
Posts: 147
Location: Poland

PostPosted: Fri Sep 04, 2009 12:27 pm    Post subject: Reply with quote

hmmm you were right +8 pushes 8 letters not 1. Thus I have achieved partially solution. I can edit the title by eating letters.

The other thing is that making new title would be best to edit old global constant than create one from scratch - the "following in hex dump" idea sound very nice.

However as I said there's this problem with running application:
It is launched by launcher's launcher - double clicking results in an error - and attaching olly to already running process is kinds meaningless because the title was long ago set....

I might be wrong however - I'll test both ideas atm.

_________________
My old signature contained a link to UCE for 822 GG MapleStory. So yeah, I decided to edit the signature....
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Sep 04, 2009 12:45 pm    Post subject: Reply with quote

i see what you are saying. most likely, the executable with the title is the one that is setting that also though. also likely, is that the title is a static constant as opposed to created dynamically

case : static title

find buffer address, edit buffer, save changes. next time the app is loaded the new title will be used

case : dynamic title, unlikely

try to attach to process on creation. hardware breakpoint on buffer address to see what code is creating the title, we work from there

you seem to be missing the point that you can change the 'global constant' AND SAVE IT meaning next time the app loads up the 'global constant' that is accessed will be the new, modified one
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites