cherriesandmochi / gdmaim

GDMaim is a GDScript obfuscation plugin for the Godot Engine.
MIT License
145 stars 13 forks source link

BUG: enums assigned to constants are not being evaluated correctly #2

Closed normano closed 8 months ago

normano commented 8 months ago

When window.gd is obfuscated, you will see something like this:

const __w7HZ = Tracer.__1Gf0;

var __QSTr = __w7HZ.Info | __w7HZ.Warn | __w7HZ.Error;

Wth inline enums turned on, there is no longer a enum so cannot reference by constant, so I turned it off. After that the INFO/WARN/ERROR are still not replaced with the renamed enums.

normano commented 8 months ago

I just updated the repo with a level.gd script that has an enum. With inline enum turned off, the world.gd script obfuscated does not reference any of the renamed enums.

Also line break before a func will break replacement of inner variable names

cherriesandmochi commented 8 months ago

I'm gonna take a look at it in a short while, just want to finish something first.

normano commented 8 months ago

No worries, I will keep looking for bugs so this is more resilient.

cherriesandmochi commented 8 months ago

Line breaks before functions seem to have gotten fixed by one of the lambda changes I made.

I see now why those enum values values do not get renamed; enum values only work when they are getting accessed directly. Since constants are being evaluated before obfuscation anyways, "loading" all the enum values into constants like that should be fairly trivial.

Thanks for all the help!

cherriesandmochi commented 8 months ago

Changed the title to better match the issue. Hope you don't mind! Anyway, I'm going to stop here for today and continue working on it tomorrow.

normano commented 8 months ago

I changed const to var today and the problem persists, so it is not limited to const.

cherriesandmochi commented 8 months ago

Fixed by b852b4dfd3c50b3ed5b1ef5931e8fa29a2bc6337

cherriesandmochi commented 8 months ago

I changed const to var today and the problem persists, so it is not limited to const.

Not being able to assign inlined enums to variables is unfortunately an expected limitation. And honestly, I don't see why you would ever assign an enum to a variable instead of a constant, so I don't really want to spend time on that right now.

normano commented 8 months ago

Inlined enums was unchecked, but hey the problem is fixed. Found one more bug that I'll put in another issue. Its a simple reserved keyword one.

cherriesandmochi commented 8 months ago

Thanks for the report! This ended up being way more convoluted than I thought it would be. I hope the fix didn't break anything else, though it still works fine on my game.