enigma icon indicating copy to clipboard operation
enigma copied to clipboard

drop out-of-bounds parameters in the `dropInvalidMappings` command

Open ix0rai opened this issue 1 year ago • 7 comments

when methods change to and from static, it can occasionally leave parameters with indices that are outside of the method's parameter bounds. this means that those parameters are useless and just take up space in mappings -- they should be tossed

ix0rai avatar Nov 06 '23 04:11 ix0rai

Since #168 they are dropped if their index is lower than the minimum. Information from the bytecode is required for the maximum https://github.com/QuiltMC/enigma/blob/2e3a60d0284f61431fbe6ac8979f483d389baeec/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EntryIndex.java#L81-L86

IotaBread avatar Dec 21 '23 18:12 IotaBread

finding the number of parameters is hard since it spills over into the LVT

OroArmor avatar Jan 04 '24 07:01 OroArmor

I just realized you can parse the descriptor and figure it out that way (plus knowing if its a static vs instance method)

OroArmor avatar Jan 04 '24 07:01 OroArmor

am I insane? the issue I ran into implementing this is knowing if it was static based on the descriptor

ix0rai avatar Jan 04 '24 07:01 ix0rai

I dont think there is a way to know unless you have indexed the jar. I remember aurora having this issue when working on the matcher

OroArmor avatar Jan 04 '24 07:01 OroArmor

When matching you'd have to index the previous jar (we don't do this currently) to know if a method changed and shift its parameters accordingly. In enigma we just need to validate and drop if any parameters are invalid. The method I mentioned in a previous comment already has access to both the method descriptor and the method access, so it'd be easy to verify there, though if we want to add local support (as an option), we need max_locals

IotaBread avatar Jan 04 '24 19:01 IotaBread

maybe we could do it as an arg you pass to the command?

ix0rai avatar Jan 04 '24 23:01 ix0rai