2

I am using IDA to find out parameters of a routine in a DLL. I browsed to the routine in question and saw that IDA has automatically done that job for me and put a comment like this:

 ; =============== S U B R O U T I N E =======================================
CODE:0048E5BC
CODE:0048E5BC ; Attributes: bp-based frame
CODE:0048E5BC
CODE:0048E5BC ; int __stdcall Active(int, double, double, double, char, char, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, double, double, char)

I want to know how much reliable this info is if I want to call this function in C# (using p/invoke)?

4

It's not very reliable. IDA can't determine types beyond analyzing the size and type of loads and stores. For instance IDA doesn't tell the difference between a pointer to a type and an integer, given that they're the same size, as far as I know. Other than that all it can do is propagate type information entered by the user. I believe the Hex-Rays decompiler does a bit more advanced argument analysis but it's also not able to extract correct function signatures in many cases.

Argument counts can be guessed from stack pushes and stack accesses on x86 but it's important to remember that there's no requirement that the calling convention use the stack at all. On less register starved architectures, determining argument counts is bit harder due to more efficient calling conventions using registers instead of the stack.

If you want to actually call that function it's extremely likely that you'll want to analyze it in more detail than what IDA gives you automatically.

  • Analyze it with olly, put a INT3 breakpoint on the function and observe the stack :) – Dominik Antal Jun 26 '14 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.