Hi,
Dont really know if this should be posted here but i didnt really see a section for Masm32.
I got the following question, is it possible to get the size of a function (a PROC)
so u could do, for instance:
dd offset Func1 ; now this DD points to Func1
dd size Func1 ; this has to do, size of the Code inside Func1,
but the "size Func1" doesnt work, is there a simple way to do that?
Regards.
PyroMathic
Dont really know if this should be posted here but i didnt really see a section for Masm32.
I got the following question, is it possible to get the size of a function (a PROC)
so u could do, for instance:
dd offset Func1 ; now this DD points to Func1
dd size Func1 ; this has to do, size of the Code inside Func1,
but the "size Func1" doesnt work, is there a simple way to do that?
Regards.
PyroMathic
it is not posible directly. function is not a data type. you may place 2 labels (at the begin and at the end) and get size subtracting them. there could be errors because of adding prolog and epylog to functions, defined with "proc/endp"
regards
regards
thx for the quick reply..
but adding a start and end label aint really an option.... its way to much work and to "dirty"
Regards
PyroMathic
but adding a start and end label aint really an option.... its way to much work and to "dirty"
Regards
PyroMathic
PyroMathic, Shoo is right, that's the only way how to get the size.
And there is no problem with prologue and epilogue - the subtraction would be always correct.
And there is no problem with prologue and epilogue - the subtraction would be always correct.
And there is no problem with prologue and epilogue - the subtraction would be always correct.
So long as the end label is after the ENDP directive (assuming that you use the function name as the start pointer).
Ossa
That's true i can put the label after endp and before proc, but then i need to put a lot of extra work into it, i need to do it to about 200 functions or so.....
but i think ill simply make an array of all the offset's of the Functions, and then take the 1 member out of that array and look which other member is the nearesed to that member. so then i also have the size...
like this:
pfunc1 dd offset func1
pfunc2 dd offset func2
pfunc3 dd offset func3
size of func1 == pfunc2 - pfunc1
something like that.
anyway:
are there ways to enumerate all proc's in my program? (whitout building a program for it)
for example as external includes, or anything else like that..
Regards.
PyroMathic
but i think ill simply make an array of all the offset's of the Functions, and then take the 1 member out of that array and look which other member is the nearesed to that member. so then i also have the size...
like this:
pfunc1 dd offset func1
pfunc2 dd offset func2
pfunc3 dd offset func3
size of func1 == pfunc2 - pfunc1
something like that.
anyway:
are there ways to enumerate all proc's in my program? (whitout building a program for it)
for example as external includes, or anything else like that..
Regards.
PyroMathic
I think if I were you I'd consider just using some word-processing macro, to get the job done. The other way round you'll probably spend more energy trying to think up a way to save energy :)
Something like
Search for "proc"
Insert label
Find the first following "endp"
Insert label
With a variable inserted, you could have it do it automatically for all procs.
Then do another variable, set up a script that makes the variables in the source.
Fake
Something like
Search for "proc"
Insert label
Find the first following "endp"
Insert label
With a variable inserted, you could have it do it automatically for all procs.
Then do another variable, set up a script that makes the variables in the source.
Fake
pyr0, 'main' is just fine.
As for how to accomplish your task, there's more than a couple of ways to do it, and choosing the best one will depend on your needs. I guess we can all agree that manual labour is NOT fun.
Now, do you need the proc sizes at build-time or run-time?
If at run-time, it should be possible to very quickly hack together something that parses LINK's map output and generates a list of functions...
As for how to accomplish your task, there's more than a couple of ways to do it, and choosing the best one will depend on your needs. I guess we can all agree that manual labour is NOT fun.
Now, do you need the proc sizes at build-time or run-time?
If at run-time, it should be possible to very quickly hack together something that parses LINK's map output and generates a list of functions...
Maybe a custom prologue and epilogue ?
Maybe a custom prologue and epilogue ?
hmm, interesting idea - if prologue/epilogue are full-blown macros in MASM, perhaps they could be (ab)used to generate the symbols he need.