View previous topic :: View next topic |
Author |
Message |
sjl002 Master Cheater Reputation: 0
Joined: 31 Aug 2013 Posts: 305
|
Posted: Mon Jul 25, 2016 8:46 am Post subject: Comapre ID problems |
|
|
Hi
I find wood , stone , ... ID in Strong Hold2.That is this :
Wood ID : cmp [esp+4],00000001
Stone ID : cmp [esp+4],00000002
,
.
.
.
Now if we want compare this two with others ID and move this tow(Wood and stone) 99. only stone and wood change to 99
for example :
Code: | [ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
newmem:
cmp [esp+4],00000001 //Wood ID
jne originalcode
cmp [esp+4],00000002//Stone ID
jne originalcode
mov [ecx+eax*4+00000C00],(int)99
originalcode:
mov eax,[ecx+eax*4+00000C00]
exit:
jmp returnhere
"Stronghold2.exe"+7975:
jmp newmem
nop
nop
returnhere:
[DISABLE]
dealloc(newmem)
"Stronghold2.exe"+7975:
mov eax,[ecx+eax*4+00000C00]
//Alt: db 8B 84 81 00 0C 00 00
|
can you help me!?
|
|
Back to top |
|
|
PinPoint Expert Cheater Reputation: 10
Joined: 07 Apr 2016 Posts: 223 Location: Scotland
|
Posted: Mon Jul 25, 2016 9:04 am Post subject: |
|
|
Should us AOB.
Does esp have the address for the ID's when the instruction called?
You never had a jump to the exit/return in your script under newmem either so it will alwyas write the originalcode section.
I would have built it something like this
Code: | [ENABLE]
aobscan(INJECT,8B 84 81 00 0C 00 00)
alloc(newmem,2048)
label(returnhere)
label(code)
newmem:
cmp [esp+4],00000001 //Wood ID
je code
cmp [esp+4],00000002//Stone ID
je code
mov eax,[ecx+eax*4+00000C00]
jmp returnhere
code:
mov [ecx+eax*4+00000C00],63
mov eax,[ecx+eax*4+00000C00]
jmp returnhere
INJECT:
jmp newmem
nop
nop
returnhere:
registersymbol(INJECT)
[DISABLE]
INJECT:
mov eax,[ecx+eax*4+00000C00]
//Alt: db 8B 84 81 00 0C 00 00
dealloc(newmem)
unregistersymbol(INJECT)
|
Last edited by PinPoint on Mon Jul 25, 2016 10:55 am; edited 1 time in total |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4299
|
Posted: Mon Jul 25, 2016 9:22 am Post subject: |
|
|
Your logic is flawed. If the ID isn't 1, it will execute the original code (that's what you wrote). If the ID is 1, it will execute the original code (1 isn't equal to 2). No matter what you do, it will never move 99 into that address.
One way to solve this would be to check if it's above 2 first then if it's equal to 0. Jump to originalcode upon either condition.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Mon Jul 25, 2016 5:07 pm Post subject: |
|
|
Code: | newmem:
cmp [esp+4],00000001 //Wood ID
je @f
cmp [esp+4],00000002//Stone ID
je @f
jmp originalcode
@@:
mov [ecx+eax*4+00000C00],(int)99
originalcode:
mov eax,[ecx+eax*4+00000C00] |
|
|
Back to top |
|
|
cooleko Grandmaster Cheater Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Mon Jul 25, 2016 10:14 pm Post subject: |
|
|
Why are you using @f and @@ here? a quick google explained what it means, but you arent getting the benefit described in this link
http://www.asmcommunity.net/forums/topic/?id=28731
Is it just a lazy way of labeling or do you have some other benefit?
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue Jul 26, 2016 7:53 am Post subject: |
|
|
It's just quick since you don't have to assign any labels.
|
|
Back to top |
|
|
STN I post too much Reputation: 42
Joined: 09 Nov 2005 Posts: 2672
|
Posted: Tue Jul 26, 2016 9:50 am Post subject: |
|
|
Reading this thread reminds me of the phrase blind leading the blind
Just an addendum to @@ thing, if you have label before @@ - @F will jump to that label e.g
je @F // jumps to somelabel instead of @@ below
mov bla
somelabel:
cmp bla
@@:
inc bla
It is very useful when you're lazy and don't feel like defining labels but can get confusing if your script is huge and you're jumping all over the place
_________________
|
|
Back to top |
|
|
sjl002 Master Cheater Reputation: 0
Joined: 31 Aug 2013 Posts: 305
|
Posted: Tue Jul 26, 2016 11:06 pm Post subject: |
|
|
Thanks for your helps.
Now i put "mov [ebp-78],(int)100" to script but game crash.Why?
I wanted that wood and stone go to "mov [ebp-78],(int)100" and "mov [ecx+eax*4+00000C00],(int)100".
Code: |
newmem:
cmp [esp+4],00000001 //Wood ID
je @f
cmp [esp+4],00000002//Stone ID
je @f
jmp originalcode
@@:
mov [ebp-78],(int)100 // Really resource (when i add this game crashed)
mov [ecx+eax*4+00000C00],(int)100//Virtual(Visual) resource |
|
|
Back to top |
|
|
cooleko Grandmaster Cheater Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Tue Jul 26, 2016 11:17 pm Post subject: |
|
|
because "ebp-78" isnt what you thought it was. Odds are you are writing over something important instead of the value you wanted to.
|
|
Back to top |
|
|
STN I post too much Reputation: 42
Joined: 09 Nov 2005 Posts: 2672
|
Posted: Wed Jul 27, 2016 11:38 am Post subject: |
|
|
Curious to know where did this mov [ebp-78] came from?
_________________
|
|
Back to top |
|
|
|