-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer uses filters, this now rewrites log events using a rewrite policy The remapping process has been moved to the logger, as otherwise log4j's extra class info would be lost
- Loading branch information
Showing
8 changed files
with
226 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
src/main/java/dev/booky/stackdeobf/mappings/RemappedThrowable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/dev/booky/stackdeobf/util/Log4jRemapUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package dev.booky.stackdeobf.util; | ||
// Created by booky10 in StackDeobfuscator (22:33 14.04.23) | ||
|
||
import dev.booky.stackdeobf.mappings.RemappingUtil; | ||
import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement; | ||
import org.apache.logging.log4j.core.impl.ThrowableProxy; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
final class Log4jRemapUtil { | ||
|
||
private static final Field PROXY_NAME = getField(ThrowableProxy.class, "name"); | ||
private static final Field PROXY_MESSAGE = getField(ThrowableProxy.class, "message"); | ||
private static final Field PROXY_LOCALIZED_MESSAGE = getField(ThrowableProxy.class, "localizedMessage"); | ||
private static final Field EXT_STACK_ELEMENT = getField(ExtendedStackTraceElement.class, "stackTraceElement"); | ||
|
||
private static Field getField(Class<?> clazz, String name) { | ||
try { | ||
Field field = clazz.getDeclaredField(name); | ||
field.setAccessible(true); | ||
return field; | ||
} catch (ReflectiveOperationException exception) { | ||
throw new RuntimeException(exception); | ||
} | ||
} | ||
|
||
static void remapThrowableProxy(ThrowableProxy proxy) throws IllegalAccessException { | ||
// remap throwable classname | ||
if (proxy.getName() != null && proxy.getName().startsWith("net.minecraft.class_")) { | ||
PROXY_NAME.set(proxy, RemappingUtil.remapClasses(proxy.getName())); | ||
} | ||
|
||
// remap throwable message | ||
if (proxy.getMessage() != null) { | ||
PROXY_MESSAGE.set(proxy, RemappingUtil.remapString(proxy.getMessage())); | ||
} | ||
if (proxy.getLocalizedMessage() != null) { | ||
PROXY_LOCALIZED_MESSAGE.set(proxy, RemappingUtil.remapString(proxy.getLocalizedMessage())); | ||
} | ||
|
||
// remap throwable stack trace | ||
for (ExtendedStackTraceElement extElement : proxy.getExtendedStackTrace()) { | ||
StackTraceElement element = extElement.getStackTraceElement(); | ||
element = RemappingUtil.remapStackTraceElement(element); | ||
EXT_STACK_ELEMENT.set(extElement, element); | ||
} | ||
|
||
// remap cause + suppressed throwables | ||
if (proxy.getCauseProxy() != null) { | ||
remapThrowableProxy(proxy.getCauseProxy()); | ||
} | ||
for (ThrowableProxy suppressed : proxy.getSuppressedProxies()) { | ||
remapThrowableProxy(suppressed); | ||
} | ||
} | ||
} |
Oops, something went wrong.