| View previous topic :: View next topic |
| Author |
Message |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Wed Mar 19, 2008 2:08 am Post subject: About push[] to stack. |
|
|
I'm trying to create a script for warrock.exe,
while the game is running I'm writing to some address.
a push[xxxxxxx] command
the problem is I dont know how long is the dword of the stack.
how can I get his lenght.
thanks.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Mar 19, 2008 4:19 am Post subject: |
|
|
What do you mean "the length"? of the stack?
and don't you mean "push xxxxxx"?
When you push something to the stack, esp will point to the stack address of it, for example esp is 22FFC4, so when you'll push something esp will point to 22FFC0 (DWORD is 4 bytes) and when you pop something, esp will incrase by 4. (unless you push/pop more/less than 4 bytes)
|
|
| Back to top |
|
 |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Tue Apr 08, 2008 7:31 am Post subject: |
|
|
| How much byte I know it push/pop ??
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Apr 08, 2008 8:04 am Post subject: |
|
|
| Depends what you push on. For example, "push 0" would only push 1 byte whereas "push eax" would push a dword.
|
|
| Back to top |
|
 |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Tue Apr 08, 2008 8:10 am Post subject: |
|
|
I want to do like this
| Code: |
5149B3:
push 930004
ret
930004:
mov ebx,458CA000
mov eax,0
mov [ecx+00000174],ebx
mov edx,[esp+0c]
mov [ecx+00000178],eax
mov [ecx+0000017C],ebx
push 5149C9
ret
|
but In stand of "push 5149C9" i want to make it that the code will know where to return, like the code will return to 5149C9 with no push 5149C9
I saw someone doing it with this function push[]...
If I can do push 5149C9 with another function - then the code every time will be much easier to me.
Like
| Code: |
5149B3:
push 930004
ret
930004:
mov ebx,458CA000
mov eax,0
mov [ecx+00000174],ebx
mov edx,[esp+0c]
mov [ecx+00000178],eax
mov [ecx+0000017C],ebx
push [2a]
ret //will go back to 5149C9 because of push [2a]
|
|
|
| Back to top |
|
 |
Recifense I post too much
Reputation: 166
Joined: 17 Mar 2008 Posts: 3688 Location: Pernambuco - Brazil
|
Posted: Fri Apr 11, 2008 12:14 pm Post subject: |
|
|
According to "IA-32 Intel® Architecture Software Developer’s Manual":
Description
Decrements the stack pointer and then stores the source operand on the top of the stack. The address-size attribute of the stack segment determines the stack pointer size (16 bits or 32 bits), and the operand-size attribute of the current code segment determines the amount the stack pointer is decremented (2 bytes or 4 bytes). For example, if these address- and operand-size attributes are 32, the 32-bit ESP register (stack pointer) is decremented by 4 and, if they are 16, the 16-bit SP register is decremented by 2. (The B flag in the stack segment’s segment descriptor determines the stack’s address-size attribute, and the D flag in the current code segment’s segment descriptor, along with prefixes, determines the operand-size attribute and also the address-size attribute of the source operand.) Pushing a 16-bit operand when the stack addresssize attribute is 32 can result in a misaligned the stack pointer (that is, the stack pointer is not aligned on a doubleword boundary).
Operation
IF StackAddrSize = 32
THEN
IF OperandSize = 32
THEN
ESP <- ESP - 4;
SS:ESP <- SRC; (* push doubleword *)
ELSE (* OperandSize = 16*)
ESP <- ESP - 2;
SS:ESP <- SRC; (* push word *)
FI;
ELSE (* StackAddrSize = 16*)
IF OperandSize = 16
THEN
SP <- SP - 2;
SS:SP <- SRC; (* push word *)
ELSE (* OperandSize = 32*)
SP <- SP - 4;
SS:SP <- SRC; (* push doubleword *)
FI;
FI;
I guess that one way to solve the problem is to inform the compiler what you want to be pushed. You can do that by using the cast "dword ptr" for 4 bytes or "word prt" for 2 bytes. Ex.: push dword ptr 1.
Cheers
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Apr 12, 2008 9:11 am Post subject: |
|
|
| TheRedEye wrote: | | How much byte I know it push/pop ?? |
EAX is a 32-bit register (and EBX, ECX, etc...), 32 bit = 4 bytes.
I've never seen someone pushing 2 bytes, but you can push 2 or 1 bytes.
|
|
| Back to top |
|
 |
Psy Grandmaster Cheater Supreme
Reputation: 1
Joined: 27 Mar 2008 Posts: 1366
|
Posted: Sat Apr 12, 2008 9:29 am Post subject: |
|
|
You can push 16-bit registers... so like 'push ax' is a very valid instruction.
EAX is a general purpose register as was stated
|
|
| Back to top |
|
 |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Sat Apr 12, 2008 1:17 pm Post subject: |
|
|
hmm
I'm not using a compiler, I'm writing into a process of a game.
How can I use this push options?
|
|
| Back to top |
|
 |
Recifense I post too much
Reputation: 166
Joined: 17 Mar 2008 Posts: 3688 Location: Pernambuco - Brazil
|
Posted: Mon Apr 14, 2008 10:46 am Post subject: |
|
|
Well, I guess you can use def byte and def double word to solve this problem:
push 0400 => 66 68 00 04 (push word ptr)
push 0400 => 68 00 04 00 00 (push dword ptr)
Using DEFs you can do like that:
db 68 // push dword ptr
dd 0400
db 66 68 //push word ptr
dw 0400
Cheers.
|
|
| Back to top |
|
 |
Psy Grandmaster Cheater Supreme
Reputation: 1
Joined: 27 Mar 2008 Posts: 1366
|
Posted: Mon Apr 14, 2008 3:23 pm Post subject: |
|
|
| Or just type "push <value>" shouldn't be an issue, unless its a real old CE build that has interpreter issues...
|
|
| Back to top |
|
 |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Tue Apr 15, 2008 11:21 am Post subject: |
|
|
hmm in order to jmp back 4 address place
I need to PUSH ??
what value?
|
|
| Back to top |
|
 |
Labyrnth Moderator
Reputation: 10
Joined: 28 Nov 2006 Posts: 6301
|
Posted: Tue Apr 15, 2008 12:00 pm Post subject: |
|
|
| TheRedEye wrote: | hmm in order to jmp back 4 address place
I need to PUSH ??
what value? |
WTf, man i think you need to learn some basic assembly.
If you just want to jump back 4 address's just use a jcc instruction.
|
|
| Back to top |
|
 |
TheRedEye Cheater
Reputation: 0
Joined: 30 May 2007 Posts: 30
|
Posted: Tue Apr 15, 2008 3:50 pm Post subject: |
|
|
jcc
?
I saw someone doing it with push []
how can I do it like he does?
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Mon Apr 21, 2008 1:13 pm Post subject: |
|
|
push Address
ret
But you don't have to do that, you can simply jmp Address.
|
|
| Back to top |
|
 |
|