News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Size Of Function

Started by mabdelouahab, November 29, 2015, 06:03:34 PM

Previous topic - Next topic

mabdelouahab

Good morning all
To determine the address of a Proc I use "offset MyProc", my question is:
Is there any way to know the size of this proc or to know the address of the end proc

hutch--

Yes, write a procedure AFTER the procedure you want to find the address for and put a label AFTER is but before the next procedure and you get both the start address and by subtracting the start address from the end label address, you get the exact length as well.

Siekmanski

Put a label endtestproc: after your proc

testproc proc
   
   xor eax,eax
   ret
testproc endp
endtestproc:

   mov   eax,(endtestproc - offset testproc)   ; eax = the code size of your proc

EDIT: Hutch was faster.  :biggrin:

Creative coders use backward thinking techniques as a strategy.

hutch--

 :biggrin:

Yeah, you have to watch us old fellas, we are not as slow as we look.  ;)

jj2007


mabdelouahab

hutch,jj2007,Siekmanski, Thanks for the information
Usually The procedure ends with one of two things:
RETN ;(C3) :1 word
or
LEAVE   ;(C9) :1 word
RETN x  ;(C2 x 00 ):3 word

Can we take advantage of them, Instead of the LABEL hutch  :biggrin:
I suspect that it needs an algorithm :redface:

sinsi

You could try your own prologue/epilogue.
Tá fuinneoga a haon déag níos fearr :biggrin:

jj2007

Quote from: mabdelouahab on November 30, 2015, 09:08:48 AM
Can we take advantage of them, Instead of the LABEL hutch  :biggrin:

Of course you can, but why should you? Unless you only have the exe and no source, of course :icon_mrgreen: