View previous topic :: View next topic |
Author |
Message |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
Posted: Sun Mar 12, 2017 8:58 am Post subject: How to compare & assign multi level pointer? |
|
|
Say, there's a pointer that has
Offset1: 04
Offset2: 11A
Register for the base address is eax.
Now i want to compare that pointer in asm. How do I do that?
Code: | cmp dword [eax+04+11A],#whatever
//doesn't work
push ebx
mov ebx,[eax+04]
cmp dword [ebx+11A],#whatever
je whatevercode
pop ebx
//also doesn't work // Updated: it worked. |
Any suggestion?
Also is there anyway to assign that pointer to address list? I know the method BaseAddress+offset but the Pointer itself (no +offset).
----
Update 01: My bad, the second one actually works. Now the question is how to assign that pointer to address list without offset?
Code: |
push ebx
push ecx
mov ecx,[eax+04]
mov ebx,[ecx+11A]
mov [checker3],ebx
pop ecx
pop ebx |
checker3 failed. This one is for learning purpose only. _________________
Open for Simple Table request, depends on my interest. |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Mar 12, 2017 9:55 am Post subject: |
|
|
How did checker3 fail? Did you get a compilation error? Did it have the wrong value?
Code: | push ecx
mov ecx,[eax+04]
mov [checker3],ecx
pop ecx |
|
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Mar 12, 2017 10:09 am Post subject: |
|
|
Use my code then add an offset of 11A to your table entry? Or add to my code: |
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sun Mar 12, 2017 10:17 am Post subject: |
|
|
Not sure what you are trying to do here, but if you are wanting to store a value in checker3, then you should not set it up as a pointer in your table. If you are wanting to put an address in checker3, then set it up as a pointer, but use load effective address for storing. |
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
Posted: Sun Mar 12, 2017 10:26 am Post subject: |
|
|
@++METHOS it's as Zanzer solution. (:
Zanzer wrote: | Use my code then add an offset of 11A to your table entry? Or add to my code: |
Oh this one is right, Thanks.
But why is that different than:
Code: | mov ecx,[eax+04]
mov [checker3],ecx |
Please explain. _________________
Open for Simple Table request, depends on my interest. |
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sun Mar 12, 2017 10:38 am Post subject: |
|
|
Okay. I had to reread this thread. I was totally confused. I should get some more sleep, probably. Do not mind me.  |
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Mar 12, 2017 11:29 am Post subject: |
|
|
Code: | mov ecx,[eax+04] // ECX now equals the base *address* you want
mov ebx,[ecx+11A] // ECX + 11A is the final *address* you want
// but this instruction sets EBX to the *value* at that address |
Saving ECX into checker3 and then adding 11A as an offset in your table (instead of 0, like you had) will get you to the address you want.
Or, in my second code, you could simply add 11A to the value you just stored there (ECX).
That too will take you to the address you want. |
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
Posted: Sun Mar 12, 2017 11:42 am Post subject: |
|
|
Zanzer wrote: | Code: | mov ecx,[eax+04] // ECX now equals the base *address* you want
mov ebx,[ecx+11A] // ECX + 11A is the final *address* you want
// but this instruction sets EBX to the *value* at that address |
Saving ECX into checker3 and then adding 11A as an offset in your table (instead of 0, like you had) will get you to the address you want.
Or, in my second code, you could simply add 11A to the value you just stored there (ECX).
That too will take you to the address you want. |
It's still a bit vague to me. Like i said I know that I can simply
Then on the Table list just add 2 offsets +04 and +11A I will get that one.
But I want checker3 to instantly give me the address and value without those 2 offsets on the Table (This one is more of learning purpose, well, for me as I have a limited knowledge of asm)
Still don't really get why sometimes it's a value and sometimes an address or pointer. _________________
Open for Simple Table request, depends on my interest. |
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sun Mar 12, 2017 12:36 pm Post subject: |
|
|
I do not know if this would work or not:
Code: | //stuff
label(checker3)
registersymbol(checker3)
newmem:
push edi
lea edi,[eax+04]+11A
mov [checker3],edi
pop edi
//originalcode
checker3:
dd 0
//stuff |
If not, then maybe...
Code: | //stuff
label(checker3)
registersymbol(checker3)
newmem:
push edi
lea edi,[eax+04]
lea edi,[edi+11A]
mov [checker3],edi
pop edi
//originalcode
checker3:
dd 0
//stuff |
|
|
Back to top |
|
 |
gameplayer Advanced Cheater
Reputation: 2
Joined: 26 Jun 2011 Posts: 97 Location: Vietnam
|
Posted: Mon Mar 13, 2017 8:20 pm Post subject: |
|
|
@ColonelRVH
Since you say the final value is sometimes a pointer address. Are you sure that the final value (with offset 11A) is a dword value?
BTW, you can not set both address and it's value directly without a different base address in CE's memory by using simple code injection method. |
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
Posted: Tue Mar 14, 2017 7:58 am Post subject: |
|
|
++METHOS wrote: | I do not know if this would work or not:
Code: | //stuff
label(checker3)
registersymbol(checker3)
newmem:
push edi
lea edi,[eax+04]+11A
mov [checker3],edi
pop edi
//originalcode
checker3:
dd 0
//stuff |
If not, then maybe...
Code: | //stuff
label(checker3)
registersymbol(checker3)
newmem:
push edi
lea edi,[eax+04]
lea edi,[edi+11A]
mov [checker3],edi
pop edi
//originalcode
checker3:
dd 0
//stuff |
|
both of them didn't work, zanzer did it perfectly, just dunno why though.  _________________
Open for Simple Table request, depends on my interest. |
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue Mar 14, 2017 8:02 am Post subject: |
|
|
Hard to say without knowing what you are really trying to do and without seeing what you are actually doing. Glad you got it sorted, though.
But, yeah, The Zanzer is just that good.  |
|
Back to top |
|
 |
ColonelRVH Advanced Cheater
Reputation: 1
Joined: 22 Jan 2015 Posts: 59 Location: VN
|
|
Back to top |
|
 |
|