Vector35 / Vector35/binaryninja-api
Missing `this` parameter for C++ methods with symbols
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Description
Version and Platform (required):
- Binary Ninja Version: 5.1.7363-dev Personal (acd6c39c)
- OS: Mac
- OS Version: 14.6.1
- CPU Architecture: M1
Bug Description:
When analyzing any C++ binary that has symbols, it seems that binja tries to automatically set the function arguments based on this symbol information. However, it misses any hidden parameters, e.g. this or the return value pointer for functions that return an object.
Steps To Reproduce:
I made this small test program to demonstrate the issue:
#include <stdio.h>
#include <string.h>
class MyClass
{
public:
void Init()
{
x = 1.0f;
y = true;
strcpy(z, "Hello");
}
void Print(const char* prefix)
{
printf("%s: x=%g y=%i z=%s\n", prefix, x, y, z);
}
MyClass Copy()
{
return *this;
}
private:
float x;
bool y;
char z[0x10];
};
int main(int argc, const char* argv[])
{
MyClass a;
a.Init();
a.Print("a");
MyClass b;
b = a.Copy();
b.Print("b");
return 0;
}
Please provide all steps required to reproduce the behavior:
- Compile the binary with symbols
g++ test.cpp -o symbols_testand open in binja - Look at
MyClass::InitandMyClass::Printmethods and observe that they're missing thethisargument - Look at
MyClass::Copymethod and observe that it is missing return value argument andthisargument - Strip the binary
strip symbols_test -o nosymbols_testand open in binja - Look at the same methods and see that they now have the correct number of arguments (1 for Init/Print, 2 for Copy)
Incorrect output screenshot:
Expected Behavior:
For thiscall methods, the implicit this parameter should be accounted for. For methods that return an object, a return value argument should also be accounted for.
For the example case above, this is what the manually fixed up output looks like:
Screenshots/Video Recording:
If applicable, please add screenshots/video recording here to help explain your problem.
Binary:
Additional Information:
Please add any other context about the problem here.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.