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: 206
Location: Brazil
ctl3d32 04 Sep 2010, 22:44
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 04 Sep 2010, 23:57
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
windwakr 05 Sep 2010, 00:05
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: 20445
Location: In your JS exploiting you and your system
revolution 05 Sep 2010, 00:17
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: 206
Location: Brazil
ctl3d32 05 Sep 2010, 00:47
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 05 Sep 2010, 00:49
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.