flat assembler
Message board for the users of flat assembler.

Index > Windows > Using LocalFree

Author
Thread Post new topic Reply to topic
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
Hi folks!

I need a little help to delete a local <QWORD> variable from memory. LocalFree does not work in the code below. How can i do that?

ex.:

Code:
proc sGetElem M,ir,ic

     local nr:QWORD
     invoke  LocalFree,[nr]
     ret
endp
    


Thanks for reading,
ctl3d32
Post 04 Sep 2010, 22:44
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
Locals are declared on the stack, are deleted after endp... assuming it gets to endp, remove that ret.
Post 04 Sep 2010, 23:57
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Tyler wrote:
Locals are declared on the stack, it is deleted after endp... assuming it gets to endp, remove that ret.


The ret is needed.



For example, lets say I have this pointless proc:
Code:
proc a a,b,c
local nr:QWORD
mov eax,1
endp
    


It becomes:
Code:
push ebp
mov ebp,esp
sub esp,8
mov eax,1
    



With a ret after the "mov eax,1" line:
Code:
push ebp
mov ebp,esp
sub esp,8
mov eax,1
leave
retn 0xC
    

_________________
----> * <---- My star, won HERE
Post 05 Sep 2010, 00:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
You don't need to free anything. Just use:
Code:
proc sGetElem M,ir,ic

     local nr:QWORD
;...
     ret
endp    
The ret will tidy up the stack properly.
Post 05 Sep 2010, 00:17
View user's profile Send private message Visit poster's website Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
Hi!

Good to know i don't have to free them by myself.

Thank you all for the quick reply!
Post 05 Sep 2010, 00:47
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
Wow, I didn't know that(obviously). I've never used procs for the very reason that I thought it was impossible to have multiple returns
Post 05 Sep 2010, 00:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.