I think it is better to be explicit here, instead of relying on ASM's
current lack of equals()/hashCode() methods in the AbstractInsnNode
class.
Signed-off-by: Graham <gpe@openrs2.dev>
I suspect it is excluded on Jagex's end so the client deals correctly
with any class loading failures caused by the absence of the
netscape.javascript.JSObject class.
Signed-off-by: Graham <gpe@openrs2.dev>
This will make naming libraries easier, as we won't have to thread
library names through every Library{Reader,Writer} implementation.
Signed-off-by: Graham <gpe@openrs2.dev>
JS5 seems to refer to many things, so I'm intending to name Jagex's
custom class file format "packclass" instead of "js5". My reasoning is
that the tool for unpacking it is called unpackclass. If you use the
same logic behind naming the Pack200 packer unpack200, then "packclass"
is a reasonable name for Jagex's class file format.
Signed-off-by: Graham <gpe@openrs2.dev>
This commit adds support for mapping:
* class names
* field names
* field owners
* method names
* method owners
It does not yet support argument names, local variable names or
re-ordering method arguments. Local variable names are blocked on
Fernflower patches and method argument re-ordering is blocked on the IR.
Signed-off-by: Graham <gpe@openrs2.dev>
At the moment, this means hard-coding the HD client but we should
reintroduce support for the SD and unsigned clients in the future.
This change provides a few benefits:
* Performance (~3x faster), as I generally only care about the HD
client.
* Allows us to continue injecting the NameMap for the HD client without
worrying about how to avoid injecting it (or support a different
NameMap) for the SD and unsigned clients.
Signed-off-by: Graham <gpe@openrs2.dev>
This fixes a bug where classes disappeared from the map if they did not
need to be re-compiled when incremental compilation is enabled.
Signed-off-by: Graham <gpe@openrs2.dev>
volatile is pointless if a field is final - even on arrays/objects, as
it only applies to the reference, not the contents of the target.
Signed-off-by: Graham <gpe@openrs2.dev>
If we don't do this then we incorrectly mark some fields as final, due
to writes present inside if blocks removed by ConstantArgTransformer.
Signed-off-by: Graham <gpe@openrs2.dev>
This fixes a bug where fields could never become static if a class had a
mixture of static and non-static fields and constructors.
Signed-off-by: Graham <gpe@openrs2.dev>
The new entry set functionality allows us to distinguish fields NEVER
written from fields we haven't explored yet. This allows us to find more
EXACTLY_ONCE fields in constructors with loops.
Signed-off-by: Graham <gpe@openrs2.dev>
Propagating them looks a bit silly, because the arguments are unused. I
think this problem mainly occurs in constructors, which the dummy
argument obfuscator doesn't touch.
Signed-off-by: Graham <gpe@openrs2.dev>
The aim of this change is to ensure that the automatically chosen class,
field and method names stay as similar as possible between runs.
Signed-off-by: Graham <gpe@openrs2.dev>
This change paves the way to feed the NameMap into the TypedRemapper,
such that refactored names (and static member movements) are preserved
across deobfuscator runs.
Signed-off-by: Graham <gpe@openrs2.dev>
We don't need to track the class version and maxStack value: the
Library::remap will already have access to them (and always needs to, as
it has to fiddle with {Class,Field,Method}Nodes to actually move the
field).
Signed-off-by: Graham <gpe@openrs2.dev>
My rough plan for combining static scrambling and remapping is to split
Library::remap into three passes:
* Remove static methods, fields and initializers from the library,
storing them in a temporary location.
* Pass all classes through ClassNodeRemapper, as we do now.
* Add static methods, fields and initializers to their new classes,
remapping as we do so.
This ensures a ClassNode is never in a state where it has a mixture of
remapped and non-remapped fields, methods or instructions. This is
important to ensure no conflicts can occur when we use the refactored
names from the NameMap, rather than the auto-generated names.
It means TypedRemapper needs the ability to provide the instructions
that make up a field's initializer, such that Library::remap can move
these instructions to a different InsnList. The new getFieldInitializer
method and FieldInitializer type support this.
Signed-off-by: Graham <gpe@openrs2.dev>
Fixes a problem where `Constructor<?> var0 =
clazz.getDeclaredConstructor(); return var0.newInstance();` was transformed to
`Constructor<?> var0 = clazz.getDeclaredConstructor(); return
var0.getDeclaredConstructor().newInstance();`
Signed-off-by: Desetude <harry@desetude.com>