From b4a75b9076cbaf5d3103749521a53073a011411f Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Wed, 22 Jan 2020 14:33:08 +0100 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=BA=D0=B0=20=D1=81=D0=B5=D1=80=D0=B8=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=20=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D1=86=D0=B8=D0=B5=D0=B9=20LauncherInject=20M?= =?UTF-8?q?ap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/asm/InjectClassAcceptor.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java index be720dfb..b680b94e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java @@ -139,12 +139,26 @@ else if (c == String.class) else throw new UnsupportedOperationException("Unsupported class" + c.getName()); } + } else if (e.desc.equals("Ljava/util/Map;")) { + serializeMap(injector, (Map) val); } else { if (!cPrimitivesList.contains(e.desc) || !zPrimitivesList.contains(val.getClass())) throw new UnsupportedOperationException("Unsupported class"); injector.add(new LdcInsnNode(val)); } - // TODO Map + } + + private static void serializeMap(InsnList inj, Map map) { + inj.add(new TypeInsnNode(Opcodes.NEW, "java/util/HashMap")); + inj.add(new InsnNode(Opcodes.DUP)); // +1 + inj.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/util/HashMap", "", "()V")); + map.forEach((k, v) -> { + inj.add(new InsnNode(Opcodes.DUP)); // +1-1 + inj.add(NodeUtils.getSafeStringInsnList(k)); + inj.add(NodeUtils.getSafeStringInsnList(v)); + inj.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/Map", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", true)); + inj.add(new InsnNode(Opcodes.POP)); + }); } private static void serializebArr(InsnList injector, byte[] val) {