Register | Login
Forum Index > Source Help > 'frame off' + 'push\pop' + 'using'
Author Message
Pages: 1
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1845] 'frame off' + 'push\pop' + 'using' - posted: 2016-05-03 10:08:05
This function Code:
#set frame off;
function test(dword x) {
  eax = x;
  using eax{eax = x}
  push eax
  mov eax, x
  pop eax
}
translates to Code:
        mov    eax, [esp + 4]
        push   eax
        mov    eax, [esp + 8]
        pop    eax
        push   eax
        mov    eax, [esp + 8]
        pop    eax
        ret    4
As we can see the offset of 'x' after 'push' is calculated correctly. Can you explain how it works and in which case it may not work?
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1850] - posted: 2016-05-03 17:28:08
The method I have wrote to track the stack works quite well, but it does have flaws, I can't say exactly what they are since I have not tested 100% everything, but if you find any bugs, just let me know smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1852] - posted: 2016-05-03 18:04:04
Some code is added in function: Code:
#set frame off;
function test(dword x) {
  eax = x;
  using eax{eax = x}  
  push eax
  mov eax, x
  pop eax
  
  using ax{eax = x}
  push ax
  mov eax, x
  pop ax
  
  esp--;
  mov eax, x
  esp++;
}
Result: Code:
        mov    eax, [esp + 4]
        push   eax
        mov    eax, [esp + 8]
        pop    eax
        push   eax
        mov    eax, [esp + 8]
        pop    eax
        push   eax
        mov    eax, [esp + 6]
        pop    eax
        push   eax
        mov    eax, [esp + 6]
        pop    eax
        dec    esp
        mov    eax, [esp + 4]
        inc    esp
        ret    4
If esp changed directly then result incorrect. After [olor=#0011ff]using ax[/color] offset correct but push eax used instead of push ax.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 11 user(s) online. 0 member(s) and 11 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd