Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not support compare with std::string #51

Open
heheda123123 opened this issue Nov 6, 2024 · 2 comments
Open

not support compare with std::string #51

heheda123123 opened this issue Nov 6, 2024 · 2 comments

Comments

@heheda123123
Copy link

not support below code

std::string a = "hello";
a == AY_OBFUSCATE("hello");
@MarioLiebisch
Copy link

The compiler tries to find a common denominator between the obfuscator's generated class and std::string, which it simply fails (since there's no direct conversion and it doesn't automatically think around the corner to use the conversion operator to const char*).

To solve this, simply cast the macro result to const char* and it should compile/work:

std::string a = "hello";
std::cout << (a == static_cast<const char*>(AY_OBFUSCATE("hello")) ? 'T' : 'F') << std::endl;

It will still stay obfuscated until runtime (assuming you wouldn't hardcode a).

@heheda123123
Copy link
Author

heheda123123 commented Nov 7, 2024

The compiler tries to find a common denominator between the obfuscator's generated class and std::string, which it simply fails (since there's no direct conversion and it doesn't automatically think around the corner to use the conversion operator to const char*).

To solve this, simply cast the macro result to const char* and it should compile/work:

std::string a = "hello";
std::cout << (a == static_cast<const char*>(AY_OBFUSCATE("hello")) ? 'T' : 'F') << std::endl;

It will still stay obfuscated until runtime (assuming you wouldn't hardcode a).

now I use below code

a == std::string(AY_OBFUSCATE("hello"));

This would also work, but I think it would be more convenient to support equal sign comparisons directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants