Am 23.03.17 um 09:12 schrieb fir:
>>
Some arguments are passed in the registers, only if it is too much they
>> are passed via the stack. The return from the procedure can give
>> you a hint if it pops something off the stack, but otherwise you'll
>> need to read and understand the assembly code of the function.
>>
> i know that.. (assume more 32 bit btw..) .. the question is if this
> this disasembly would be hard or easy (and how exactly it would be)
> as it is some kind of pattern that repeats same in each case you
> maybe not need whole analysis but something more simple.. (im not so
> much into it to know it just right away)
So you want to write an automated code analyser which gives you the
number / type of parameters? This is most probably not possible. In 16
bit, it would be partly possible, because 16 bit x86 passes everything
on the stack. The return from the procedure cleans up the stack, so "ret
20" tells you that there are 5 16bit words as parameters. But for 32bit
and 64bit you are out of luck because the parameters are passed in
registers. This is one of the things that makes today's compilers fast.
They do not compute the args, then move to the registers and call the
function - instead the computation is adapted such that the parameters
end up in the corresponding registers. Therefore it would als be next to
impossible if you had a call site for the DLL for analysis.
Your best bet as a human reverse engineer would be to go to the
beginning of the procedure and note down, which parameters are first
touched, i.e. copied, used etc. If there are parameters on the stack,
you will see access to [rsp+xx] or the frame-pointer thingy mov %rsp,
%rbp and access to [rbp+xx].
Christian