자바에서 method injection이 가능한가요?

푸르미의 이미지

자바에서

1. DLL Injection 같이, method injection이나 field injection이 가능한가요?

2. method hooking이 가능한가요?

inbon의 이미지

JDI나 JVMTI agent를 이용하면 여러가지 일을 할 수 있습니다.

JPDA
http://java.sun.com/javase/6/docs/technotes/guides/jpda/index.html

JVMTI
http://java.sun.com/javase/6/docs/technotes/guides/jvmti/index.html

JDI API doc
http://java.sun.com/javase/6/docs/jdk/api/jpda/jdi/index.html

JDI Events

AccessWatchpointEvent
BreakpointEvent
ClassPrepareEvent
ClassUnloadEvent
ExceptionEvent
MethodEntryEvent
MethodExitEvent
ModificationWatchpointEvent
MonitorContendedEnteredEvent
MonitorContendedEnterEvent
MonitorWaitedEvent
MonitorWaitEvent
StepEvent
ThreadDeathEvent
ThreadStartEvent
VMDeathEvent
VMDisconnectEvent
VMStartEvent
WatchpointEvent

메소드 호출에 대한 이벤트로 MethodEntryEvent, MethodExitEvent가 있네요.

JVMTI에서는 더 low-level의 이벤트를 잡을 수 있습니다.

JDI는 Java Front-end이구요

JVMTI_Agent는 C/C++기반 라이브러리 모듈로 돌아갑니다.

====================
In-Bon Kuh
http://inbon.net

GNU OSLab.
http://race.gnu.kr
====================

====================
In-Bon Kuh
http://inbon.net

GNU OSLab.
http://race.gnu.kr
====================

hongminhee의 이미지

오… 이런 게 가능하군요. 몰랐는데 좋은 걸 알았네요. 감사합니다.