Hardware Delphi

Title: Communicate with JVMDI
Question: The Java Virtual Machine Debugger Interface allows a native dll to recieve a variety of notifications during the execution of a java program. This article explains how to create a dll in delphi to recieve these notifications
Answer:
jdk1.4 comes with jni.h and jvmdi.h which is the C specification of JVMDI.
The translated .pas file is as follows.
-------------------------------------------------------------------------------
unit JVMDIStructs;
interface
uses
SysUtils;
type
PTJObject = ^TJObject;
TJObject = packed record
end;
PTJFieldId = ^TJFieldId;
TJFieldId = packed record
end;
PTJMethodId = ^TJMethodId;
TJMethodId = packed record
end;
PJFrameId = ^TJFrameId;
TJFrameId = packed record
end;
type JObject = type PTJObject;
type JBoolean = type Byte;
type JInteger = type Integer;
type JSize = type JInteger;
type JLong = type Int64;
type JByte = type ShortInt;
type JShort = type SmallInt;
type JChar = type Word;
type JFloat = type Single;
type JDouble = type Real;
type JClass = type PTJObject;
type JThrowable = type PTJObject;
type JString = type PTJObject;
type JArray = type PTJObject;
type JBooleanArray = type JArray;
type JByteArray = type JArray;
type JCharArray = type JArray;
type JShortArray = type JArray;
type JIntArray = type JArray;
type JLongArray = type JArray;
type JFloatArray = type JArray;
type JDoubleArray = type JArray;
type JObjectArray = type JArray;
type JWeak = type JObject;
type JFieldId = type PTJFieldId;
type JMethodId = type PTJMethodId;

type JVMDI_RawMonitor = type pointer;
type JVMDIError = type JInteger;
type JFrameId = type PJFrameId;
type JThread = type JObject;
type JThreadGroup = type JObject;
type JLocation = type JLong;
PJValue = ^JValue;
JValue = packed record
case Integer of
0: (z: JBoolean);
1: (b: JByte);
2: (c: JChar);
3: (s: JShort);
4: (i: JInteger);
5: (j: JLong);
6: (f: JFloat);
7: (d: JDouble);
8: (l: JLong);
end;
PJByte = ^JByte;
PJChar = ^JChar;
PJBoolean = ^JBoolean;
PJShort = ^JShort;
PJLong = ^JLong;
PJFloat = ^JFloat;
PJDouble = ^JDouble;
PJInteger = ^JInteger;
PJObject = ^JObject;
PJClass = ^JClass;
PJLocation = ^JLocation;
PJFieldId = ^JFieldId;
PJMethodId = ^JMethodId;
PJVMDIError = ^JVMDIError;

PPChar = ^PChar;
PPJByte = ^PJByte;
PPJObject = ^PJObject;
PPJClass = ^PJClass;
PJThreadArray = ^JThreadArray;
JThreadArray = array[0..4] of JThread;
PJClassArray = ^JClassArray;
JClassArray = array[0..4] of JClass;
PJMethodArray = ^JMethodArray;
JMethodArray = array[0..4] of JMethodId;
PPJavaVM = ^PJavaVM;
PJavaVM = ^JavaVM;
PJNIEnv = ^JNIEnv;
PJThread = ^JThread;
PPJThread = ^PJThread;
PJThreadGroup = ^JThreadGroup;
PPJThreadGroup = ^PJThreadGroup;
PJNINativeMethod = ^JNINativeMethod;
PJNIInvokeInterface = ^JNIInvokeInterface;
PJVMDI_RawMonitor = ^JVMDI_RawMonitor;
PPJFieldId = ^PJFieldId;
PPJMethodId = ^PJMethodId;
//JNI Invoke Interface
PDestroyJavaVM = function(vm: PJavaVM):JInteger; stdcall;
PAttachCurrentThread = function(vm: PJavaVM; env: pointer; args: pointer):JInteger; stdcall;
PDetachCurrentThread = function(vm: PJavaVM):JInteger; stdcall;
PGetEnv = function(vm: PJavaVM; env: pointer; version: integer):JInteger; stdcall;
PAttachCurrentThreadAsDaemon = function(vm: PJavaVM; env: pointer; args: pointer):JInteger; stdcall;
//JNI Native Interface
PGetVersion = function(env: PJNIEnv):JInteger; stdcall;
PDefineClass = function(env: PJNIEnv; name: PChar; loader: JObject; buf: PJByte; len: JSize): JClass; stdcall;
PFindClass = function(env: PJNIEnv; name: PChar): JClass; stdcall;
PFromReflectedMethod = function(env: PJNIEnv; method: JObject): JMethodId; stdcall;
PFromReflectedField = function(env: PJNIEnv; field: JObject): JMethodId; stdcall;
PToReflectedMethod = function(env: PJNIEnv; cls: JClass; methodID: JMethodID; isStatic: JBoolean): JObject; stdcall;
PGetSuperclass = function(env: PJNIEnv; sub: JClass):JClass; stdcall;
PIsAssignableFrom = function(env: PJNIEnv; sub: JClass; sup: JClass):JBoolean; stdcall;
PToReflectedField = function(env: PJNIEnv; cls: JClass;fieldID: JFieldID; isStatic: JBoolean): JObject; stdcall;
PThrow = function(env: PJNIEnv; obj: JThrowable): JInteger;
PThrowNew = function(env: PJNIEnv; clazz: JClass; msg: PChar): JInteger; stdcall;
PExceptionOccurred = function(env: PJNIEnv): JThrowable; stdcall;
PExceptionDescribe = procedure(env: PJNIEnv); stdcall;
PExceptionClear = procedure(env: PJNIEnv); stdcall;
PFatalError = procedure(env: PJNIEnv; msg: PChar); stdcall;
PPushLocalFrame = function(env: PJNIEnv; capacity: JInteger): JInteger; stdcall;
PPopLocalFrame = function(env: PJNIEnv; result: JObject): JObject; stdcall;
PNewGlobalRef = function(env: PJNIEnv; lobj: JObject): JObject; stdcall;
PDeleteGlobalRef = procedure(env: PJNIEnv; gref: JObject); stdcall;
PDeleteLocalRef = procedure(env: PJNIEnv; obj: JObject); stdcall;
PIsSameObject = function(env: PJNIEnv; obj1: JObject; obj2: JObject): JBoolean; stdcall;
PNewLocalRef = function(env: PJNIEnv; ref: JObject): JObject; stdcall;
PEnsureLocalCapacity = function(env: PJNIEnv; capacity: JInteger): JInteger; stdcall;
PAllocObject = function(env: PJNIEnv; clazz: JClass): JObject; stdcall;
PNewObject = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: array of const): JObject; cdecl;
PNewObjectV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JObject; stdcall;
PNewObjectA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JObject; stdcall;
PGetObjectClass = function(env: PJNIEnv; obj: JObject): JClass; stdcall;
PIsInstanceOf = function(env: PJNIEnv; obj: JObject; clazz: JClass): JBoolean; stdcall;
PGetMethodID = function(env: PJNIEnv; clazz: JClass; name: PChar; sig: PChar): JMethodId; stdcall;
PCallObjectMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JObject; cdecl;
PCallObjectMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JObject; stdcall;
PCallObjectMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JObject; stdcall;
PCallBooleanMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JBoolean; cdecl;
PCallBooleanMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JBoolean; stdcall;
PCallBooleanMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JBoolean; stdcall;
PCallByteMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JByte; cdecl;
PCallByteMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JByte; stdcall;
PCallByteMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JByte; stdcall;
PCallCharMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JChar; cdecl;
PCallCharMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JChar; stdcall;
PCallCharMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JChar; stdcall;
PCallShortMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JShort; cdecl;
PCallShortMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JShort; stdcall;
PCallShortMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JShort; stdcall;
PCallIntMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JInteger; cdecl;
PCallIntMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JInteger; stdcall;
PCallIntMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JInteger; stdcall;
PCallLongMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JLong; cdecl;
PCallLongMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JLong; stdcall;
PCallLongMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JLong; stdcall;
PCallFloatMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JFloat; cdecl;
PCallFloatMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JFloat; stdcall;
PCallFloatMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JFloat; stdcall;
PCallDoubleMethod = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const): JDouble; cdecl;
PCallDoubleMethodV = function(env: PJNIEnv; obj: JObject; methodID: JMethodID): JDouble; stdcall;
PCallDoubleMethodA = function(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue): JDouble; stdcall;
PCallVoidMethod = procedure(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: array of const); cdecl;
PCallVoidMethodV = procedure(env: PJNIEnv; obj: JObject; methodID: JMethodID); stdcall;
PCallVoidMethodA = procedure(env: PJNIEnv; obj: JObject; methodID: JMethodID; args: PJValue); stdcall;
PCallNonvirtualObjectMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JObject; cdecl;
PCallNonvirtualObjectMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JObject; stdcall;
PCallNonvirtualObjectMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JObject; stdcall;
PCallNonvirtualBooleanMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JBoolean; cdecl;
PCallNonvirtualBooleanMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JBoolean; stdcall;
PCallNonvirtualBooleanMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JBoolean; stdcall;
PCallNonvirtualByteMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JByte; cdecl;
PCallNonvirtualByteMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JByte; stdcall;
PCallNonvirtualByteMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JByte; stdcall;
PCallNonvirtualCharMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JChar; cdecl;
PCallNonvirtualCharMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JChar; stdcall;
PCallNonvirtualCharMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JChar; stdcall;
PCallNonvirtualShortMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JShort; cdecl;
PCallNonvirtualShortMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JShort; stdcall;
PCallNonvirtualShortMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JShort; stdcall;
PCallNonvirtualIntMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JInteger; stdcall;
PCallNonvirtualIntMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JInteger; stdcall;
PCallNonvirtualIntMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JInteger; stdcall;
PCallNonvirtualLongMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JLong; stdcall;
PCallNonvirtualLongMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JLong; stdcall;
PCallNonvirtualLongMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JLong; stdcall;
PCallNonvirtualFloatMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JFloat; stdcall;
PCallNonvirtualFloatMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JFloat; stdcall;
PCallNonvirtualFloatMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JFloat; stdcall;
PCallNonvirtualDoubleMethod = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const): JDouble; stdcall;
PCallNonvirtualDoubleMethodV = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID): JDouble; stdcall;
PCallNonvirtualDoubleMethodA = function(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue): JDouble; stdcall;
PCallNonvirtualVoidMethod = procedure(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: array of const); stdcall;
PCallNonvirtualVoidMethodV = procedure(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID); stdcall;
PCallNonvirtualVoidMethodA = procedure(env: PJNIEnv; obj: JObject; clazz: JClass; methodID: JMethodID; args: PJValue); stdcall;
PGetFieldID = function(env: PJNIEnv; clazz: JClass; name: PChar; sig: PChar): JFieldId; stdcall;
PGetObjectField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JObject; stdcall;
PGetBooleanField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JBoolean; stdcall;
PGetByteField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JByte; stdcall;
PGetCharField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JChar; stdcall;
PGetShortField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JShort; stdcall;
PGetIntField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JInteger; stdcall;
PGetLongField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JLong; stdcall;
PGetFloatField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JFloat; stdcall;
PGetDoubleField = function(env: PJNIEnv; obj: JObject; fieldId: JFieldID): JDouble; stdcall;
PSetObjectField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JObject); stdcall;
PSetBooleanField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JBoolean); stdcall;
PSetByteField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JByte); stdcall;
PSetCharField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JChar); stdcall;
PSetShortField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JShort); stdcall;
PSetIntField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JInteger); stdcall;
PSetLongField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JLong); stdcall;
PSetFloatField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JFloat); stdcall;
PSetDoubleField = procedure(env: PJNIEnv; obj: JObject; fieldId: JFieldID; val: JDouble); stdcall;
PGetStaticMethodID = function(env: PJNIEnv; clazz: JClass; name: PChar; sig: PChar): JMethodId; stdcall;
PCallStaticObjectMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JObject; stdcall;
PCallStaticObjectMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JObject; stdcall;
PCallStaticObjectMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JObject; stdcall;
PCallStaticBooleanMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JBoolean; stdcall;
PCallStaticBooleanMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JBoolean; stdcall;
PCallStaticBooleanMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JBoolean; stdcall;
PCallStaticByteMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JByte; stdcall;
PCallStaticByteMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JByte; stdcall;
PCallStaticByteMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JByte; stdcall;
PCallStaticCharMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JChar; stdcall;
PCallStaticCharMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JChar; stdcall;
PCallStaticCharMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JChar; stdcall;
PCallStaticShortMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JShort; stdcall;
PCallStaticShortMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JShort; stdcall;
PCallStaticShortMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JShort; stdcall;
PCallStaticIntMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JInteger; stdcall;
PCallStaticIntMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JInteger; stdcall;
PCallStaticIntMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JInteger; stdcall;
PCallStaticLongMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JLong; stdcall;
PCallStaticLongMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JLong; stdcall;
PCallStaticLongMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JLong; stdcall;
PCallStaticFloatMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JFloat; stdcall;
PCallStaticFloatMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JFloat; stdcall;
PCallStaticFloatMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JFloat; stdcall;
PCallStaticDoubleMethod = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JDouble; stdcall;
PCallStaticDoubleMethodV = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID): JDouble; stdcall;
PCallStaticDoubleMethodA = function(env: PJNIEnv; clazz: JClass; methodID: JMethodID; args: PJValue): JDouble; stdcall;
PCallStaticVoidMethod = procedure(env: PJNIEnv; cls: JClass; methodID: JMethodID); stdcall;
PCallStaticVoidMethodV = procedure(env: PJNIEnv; cls: JClass; methodID: JMethodID); stdcall;
PCallStaticVoidMethodA = procedure(env: PJNIEnv; cls: JClass; methodID: JMethodID; args: PJValue); stdcall;
PGetStaticFieldID = function(env: PJNIEnv; clazz: JClass; name: PChar; sig: PChar): JFieldId; stdcall;
PGetStaticObjectField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JObject; stdcall;
PGetStaticBooleanField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JBoolean; stdcall;
PGetStaticByteField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JByte; stdcall;
PGetStaticCharField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JChar; stdcall;
PGetStaticShortField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JShort; stdcall;
PGetStaticIntField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JInteger; stdcall;
PGetStaticLongField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JLong; stdcall;
PGetStaticFloatField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JFloat; stdcall;
PGetStaticDoubleField = function(env: PJNIEnv; clazz: JClass; fieldId: JFieldID): JDouble; stdcall;
PSetStaticObjectField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JObject); stdcall;
PSetStaticBooleanField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JBoolean); stdcall;
PSetStaticByteField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JByte); stdcall;
PSetStaticCharField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JChar); stdcall;
PSetStaticShortField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JShort); stdcall;
PSetStaticIntField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JInteger); stdcall;
PSetStaticLongField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JLong); stdcall;
PSetStaticFloatField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JFloat); stdcall;
PSetStaticDoubleField = procedure(env: PJNIEnv; clazz: JClass; fieldId: JFieldID; value: JDouble); stdcall;
PNewString = function(env: PJNIEnv; unicode: PJChar; len: JSize): JString; stdcall;
PGetStringLength = function(env: PJNIEnv; str: JString): JSize; stdcall;
PGetStringChars = function(env: PJNIEnv; str: JString; isCopy: PJBoolean): PJChar; stdcall;
PReleaseStringChars = procedure(env: PJNIEnv; str: JString; chars: PJChar); stdcall;
PNewStringUTF = function(env: PJNIEnv; utf: PChar): JString; stdcall;
PGetStringUTFLength = function(env: PJNIEnv; str: JString): JSize; stdcall;
PGetStringUTFChars = function(env: PJNIEnv; str: JString; isCopy: PJBoolean): PChar; stdcall;
PReleaseStringUTFChars = procedure(env: PJNIEnv; str: JString; chars: PChar); stdcall;
PGetArrayLength = function(env: PJNIEnv; ary: JArray): JSize; stdcall;
PNewObjectArray = function(env: PJNIEnv; len: JSize; clazz: JClass; init: JObject): JObjectArray; stdcall;
PGetObjectArrayElement = function(env: PJNIEnv; ary:JObjectArray; index: JSize): JObject; stdcall;
PSetObjectArrayElement = procedure(env: PJNIEnv; ary:JObjectArray; index: JSize; val: JObject); stdcall;
PNewBooleanArray = function(env: PJNIEnv; len: JSize): JBooleanArray; stdcall;
PNewByteArray = function(env: PJNIEnv; len: JSize): JByteArray; stdcall;
PNewCharArray = function(env: PJNIEnv; len: JSize): JCharArray; stdcall;
PNewShortArray = function(env: PJNIEnv; len: JSize): JShortArray; stdcall;
PNewIntArray = function(env: PJNIEnv; len: JSize): JIntArray; stdcall;
PNewLongArray = function(env: PJNIEnv; len: JSize): JLongArray; stdcall;
PNewFloatArray = function(env: PJNIEnv; len: JSize): JFloatArray; stdcall;
PNewDoubleArray = function(env: PJNIEnv; len: JSize): JDoubleArray; stdcall;
PGetBooleanArrayElements = function(env: PJNIEnv; ary: JBooleanArray; isCopy: PJBoolean): PJBoolean; stdcall;
PGetByteArrayElements = function(env: PJNIEnv; ary: JByteArray; isCopy: PJBoolean): PJByte; stdcall;
PGetCharArrayElements = function(env: PJNIEnv; ary: JCharArray; isCopy: PJBoolean): PJChar; stdcall;
PGetShortArrayElements = function(env: PJNIEnv; ary: JShortArray; isCopy: PJBoolean): PJShort; stdcall;
PGetIntArrayElements = function(env: PJNIEnv; ary: JIntArray; isCopy: PJBoolean): PJInteger; stdcall;
PGetLongArrayElements = function(env: PJNIEnv; ary: JLongArray; isCopy: PJBoolean): PJLong; stdcall;
PGetFloatArrayElements = function(env: PJNIEnv; ary: JFloatArray; isCopy: PJBoolean): PJFloat; stdcall;
PGetDoubleArrayElements = function(env: PJNIEnv; ary: JDoubleArray; isCopy: PJBoolean): PJDouble; stdcall;
PReleaseBooleanArrayElements = procedure(env: PJNIEnv; ary: JBooleanArray; elems: PJBoolean; mode: JInteger); stdcall;
PReleaseByteArrayElements = procedure(env: PJNIEnv; ary: JByteArray; elems: PJByte; mode: JInteger); stdcall;
PReleaseCharArrayElements = procedure(env: PJNIEnv; ary: JCharArray; elems: PJChar; mode: JInteger); stdcall;
PReleaseShortArrayElements = procedure(env: PJNIEnv; ary: JShortArray; elems: PJShort; mode: JInteger); stdcall;
PReleaseIntArrayElements = procedure(env: PJNIEnv; ary: JIntArray ; elems: PJInteger; mode: JInteger); stdcall;
PReleaseLongArrayElements = procedure(env: PJNIEnv; ary: JLongArray; elems: PJLong; mode: JInteger); stdcall;
PReleaseFloatArrayElements = procedure(env: PJNIEnv; ary: JFloatArray; elems: PJFloat; mode: JInteger); stdcall;
PReleaseDoubleArrayElements = procedure(env: PJNIEnv; ary: JDoubleArray; elems: PJDouble; mode: JInteger); stdcall;
PGetBooleanArrayRegion = procedure(env: PJNIEnv; ary: JBooleanArray; start: JSize; l: JSize; buf: PJBoolean); stdcall;
PGetByteArrayRegion = procedure(env: PJNIEnv; ary: JByteArray; start: JSize; len: JSize; buf: PJByte); stdcall;
PGetCharArrayRegion = procedure(env: PJNIEnv; ary: JCharArray; start: JSize; len: JSize; buf: PJChar); stdcall;
PGetShortArrayRegion = procedure(env: PJNIEnv; ary: JShortArray; start: JSize; len: JSize; buf: PJShort); stdcall;
PGetIntArrayRegion = procedure(env: PJNIEnv; ary: JIntArray; start: JSize; len: JSize; buf: PJInteger); stdcall;
PGetLongArrayRegion = procedure(env: PJNIEnv; ary: JLongArray; start: JSize; len: JSize; buf: PJLong); stdcall;
PGetFloatArrayRegion = procedure(env: PJNIEnv; ary: JFloatArray; start: JSize; len: JSize; buf: PJFloat); stdcall;
PGetDoubleArrayRegion = procedure(env: PJNIEnv; ary: JDoubleArray; start: JSize; len: JSize; buf: PJDouble); stdcall;
PSetBooleanArrayRegion = procedure(env: PJNIEnv; ary: JBooleanArray; start: JSize; l: JSize; buf: PJBoolean); stdcall;
PSetByteArrayRegion = procedure(env: PJNIEnv; ary: JByteArray; start: JSize; len: JSize; buf: PJByte); stdcall;
PSetCharArrayRegion = procedure(env: PJNIEnv; ary: JCharArray; start: JSize; len: JSize; buf: PJChar); stdcall;
PSetShortArrayRegion = procedure(env: PJNIEnv; ary: JShortArray; start: JSize; len: JSize; buf: PJShort); stdcall;
PSetIntArrayRegion = procedure(env: PJNIEnv; ary: JIntArray; start: JSize; len: JSize; buf: PJInteger); stdcall;
PSetLongArrayRegion = procedure(env: PJNIEnv; ary: JLongArray; start: JSize; len: JSize; buf: PJLong); stdcall;
PSetFloatArrayRegion = procedure(env: PJNIEnv; ary: JFloatArray; start: JSize; len: JSize; buf: PJFloat); stdcall;
PSetDoubleArrayRegion = procedure(env: PJNIEnv; ary: JDoubleArray; start: JSize; len: JSize; buf: PJDouble); stdcall;
PRegisterNatives = function(env: PJNIEnv; clazz: JClass; methods:PJNINativeMethod; nMethods: JInteger): JInteger; stdcall;
PUnregisterNatives = function(env: PJNIEnv; clazz: JClass): JInteger; stdcall;
PMonitorEnter = function(env: PJNIEnv; obj: JObject): JInteger; stdcall;
PMonitorExit = function(env: PJNIEnv; obj: JObject): JInteger; stdcall;
PGetJavaVM = function(env: PJNIEnv; vm: PPJavaVM): JInteger; stdcall;
PGetStringRegion = procedure(env: PJNIEnv; str: JString; start: JSize; len: JSize; buf: PJChar); stdcall;
PGetStringUTFRegion = procedure(env: PJNIEnv; str: JString; start: JSize; len: JSize; buf: PChar); stdcall;
PGetPrimitiveArrayCritical = function(env: PJNIEnv; ary: JArray; isCopy: PJBoolean): pointer; stdcall;
PReleasePrimitiveArrayCritical = procedure(env: PJNIEnv; ary: JArray; carray: pointer; mode: JInteger); stdcall;
PGetStringCritical = function(env: PJNIEnv; str: JString; isCopy: PJBoolean): PJChar; stdcall;
PReleaseStringCritical = procedure(env: PJNIEnv; str: JString; cstring: PJChar); stdcall;
PNewWeakGlobalRef = function(env: PJNIEnv; obj: JObject): JWeak; stdcall;
PDeleteWeakGlobalRef = procedure(env: PJNIEnv; ref: JWeak); stdcall;
PExceptionCheck = function(env: PJNIEnv): JBoolean; stdcall;
PNewDirectByteBuffer = function(env: PJNIEnv; address: pointer; capacity: JLong): JObject; stdcall;
PGetDirectBufferAddress = function(env: PJNIEnv; buf: JObject): pointer; stdcall;
PGetDirectBufferCapacity = function(env: PJNIEnv; buf: JObject): JLong; stdcall;
JNIInvokeInterface = packed record
reserved0: pointer;
reserved1: pointer;
reserved2: pointer;
DestroyJavaVM :PDestroyJavaVM;
AttachCurrentThread: PAttachCurrentThread;
DetachCurrentThread: PDetachCurrentThread;
GetEnv: PGetEnv;
AttachCurrentThreadAsDaemon: PAttachCurrentThreadAsDaemon;
end;
PJNINativeInterface =^JNINativeInterface;
JNINativeInterface = packed record
reserved0: pointer;
reserved1: pointer;
reserved2: pointer;
reserved3: pointer;
GetVersion : PGetVersion;
DefineClass : PDefineClass;
FindClass : PFindClass;
FromReflectedMethod : PFromReflectedMethod;
FromReflectedField : PFromReflectedField;
ToReflectedMethod : PToReflectedMethod;
GetSuperclass : PGetSuperclass;
IsAssignableFrom : PIsAssignableFrom;
ToReflectedField : PToReflectedField;
Throw : PThrow;
ThrowNew : PThrowNew;
ExceptionOccurred : PExceptionOccurred;
ExceptionDescribe : PExceptionDescribe;
ExceptionClear : PExceptionClear;
FatalError : PFatalError;
PushLocalFrame : PPushLocalFrame;
PopLocalFrame : PPopLocalFrame;
NewGlobalRef : PNewGlobalRef;
DeleteGlobalRef : PDeleteGlobalRef;
DeleteLocalRef : PDeleteLocalRef;
IsSameObject : PIsSameObject;
NewLocalRef : PNewLocalRef;
EnsureLocalCapacity : PEnsureLocalCapacity;
AllocObject : PAllocObject;
NewObject : PNewObject;
NewObjectV : PNewObjectV;
NewObjectA : PNewObjectA;
GetObjectClass : PGetObjectClass;
IsInstanceOf : PIsInstanceOf;
GetMethodID : PGetMethodID;
CallObjectMethod : PCallObjectMethod;
CallObjectMethodV : PCallObjectMethodV;
CallObjectMethodA : PCallObjectMethodA;
CallBooleanMethod : PCallBooleanMethod;
CallBooleanMethodV : PCallBooleanMethodV;
CallBooleanMethodA : PCallBooleanMethodA;
CallByteMethod : PCallByteMethod;
CallByteMethodV : PCallByteMethodV;
CallByteMethodA : PCallByteMethodA;
CallCharMethod : PCallCharMethod;
CallCharMethodV : PCallCharMethodV;
CallCharMethodA : PCallCharMethodA;
CallShortMethod : PCallShortMethod;
CallShortMethodV : PCallShortMethodV;
CallShortMethodA : PCallShortMethodA;
CallIntMethod : PCallIntMethod;
CallIntMethodV : PCallIntMethodV;
CallIntMethodA : PCallIntMethodA;
CallLongMethod : PCallLongMethod;
CallLongMethodV : PCallLongMethodV;
CallLongMethodA : PCallLongMethodA;
CallFloatMethod : PCallFloatMethod;
CallFloatMethodV : PCallFloatMethodV;
CallFloatMethodA : PCallFloatMethodA;
CallDoubleMethod : PCallDoubleMethod;
CallDoubleMethodV : PCallDoubleMethodV;
CallDoubleMethodA : PCallDoubleMethodA;
CallVoidMethod : PCallVoidMethod;
CallVoidMethodV : PCallVoidMethodV;
CallVoidMethodA : PCallVoidMethodA;
CallNonvirtualObjectMethod : PCallNonvirtualObjectMethod;
CallNonvirtualObjectMethodV : PCallNonvirtualObjectMethodV;
CallNonvirtualObjectMethodA : PCallNonvirtualObjectMethodA;
CallNonvirtualBooleanMethod : PCallNonvirtualBooleanMethod;
CallNonvirtualBooleanMethodV : PCallNonvirtualBooleanMethodV;
CallNonvirtualBooleanMethodA : PCallNonvirtualBooleanMethodA;
CallNonvirtualByteMethod : PCallNonvirtualByteMethod;
CallNonvirtualByteMethodV : PCallNonvirtualByteMethodV;
CallNonvirtualByteMethodA : PCallNonvirtualByteMethodA;
CallNonvirtualCharMethod : PCallNonvirtualCharMethod;
CallNonvirtualCharMethodV : PCallNonvirtualCharMethodV;
CallNonvirtualCharMethodA : PCallNonvirtualCharMethodA;
CallNonvirtualShortMethod : PCallNonvirtualShortMethod;
CallNonvirtualShortMethodV : PCallNonvirtualShortMethodV;
CallNonvirtualShortMethodA : PCallNonvirtualShortMethodA;
CallNonvirtualIntMethod : PCallNonvirtualIntMethod;
CallNonvirtualIntMethodV : PCallNonvirtualIntMethodV;
CallNonvirtualIntMethodA : PCallNonvirtualIntMethodA;
CallNonvirtualLongMethod : PCallNonvirtualLongMethod;
CallNonvirtualLongMethodV : PCallNonvirtualLongMethodV;
CallNonvirtualLongMethodA : PCallNonvirtualLongMethodA;
CallNonvirtualFloatMethod : PCallNonvirtualFloatMethod;
CallNonvirtualFloatMethodV : PCallNonvirtualFloatMethodV;
CallNonvirtualFloatMethodA : PCallNonvirtualFloatMethodA;
CallNonvirtualDoubleMethod : PCallNonvirtualDoubleMethod;
CallNonvirtualDoubleMethodV : PCallNonvirtualDoubleMethodV;
CallNonvirtualDoubleMethodA : PCallNonvirtualDoubleMethodA;
CallNonvirtualVoidMethod : PCallNonvirtualVoidMethod;
CallNonvirtualVoidMethodV : PCallNonvirtualVoidMethodV;
CallNonvirtualVoidMethodA : PCallNonvirtualVoidMethodA;
GetFieldID : PGetFieldID;
GetObjectField : PGetObjectField;
GetBooleanField : PGetBooleanField;
GetByteField : PGetByteField;
GetCharField : PGetCharField;
GetShortField : PGetShortField;
GetIntField : PGetIntField;
GetLongField : PGetLongField;
GetFloatField : PGetFloatField;
GetDoubleField : PGetDoubleField;
SetObjectField : PSetObjectField;
SetBooleanField : PSetBooleanField;
SetByteField : PSetByteField;
SetCharField : PSetCharField;
SetShortField : PSetShortField;
SetIntField : PSetIntField;
SetLongField : PSetLongField;
SetFloatField : PSetFloatField;
SetDoubleField : PSetDoubleField;
GetStaticMethodID : PGetStaticMethodID;
CallStaticObjectMethod : PCallStaticObjectMethod;
CallStaticObjectMethodV : PCallStaticObjectMethodV;
CallStaticObjectMethodA : PCallStaticObjectMethodA;
CallStaticBooleanMethod : PCallStaticBooleanMethod;
CallStaticBooleanMethodV : PCallStaticBooleanMethodV;
CallStaticBooleanMethodA : PCallStaticBooleanMethodA;
CallStaticByteMethod : PCallStaticByteMethod;
CallStaticByteMethodV : PCallStaticByteMethodV;
CallStaticByteMethodA : PCallStaticByteMethodA;
CallStaticCharMethod : PCallStaticCharMethod;
CallStaticCharMethodV : PCallStaticCharMethodV;
CallStaticCharMethodA : PCallStaticCharMethodA;
CallStaticShortMethod : PCallStaticShortMethod;
CallStaticShortMethodV : PCallStaticShortMethodV;
CallStaticShortMethodA : PCallStaticShortMethodA;
CallStaticIntMethod : PCallStaticIntMethod;
CallStaticIntMethodV : PCallStaticIntMethodV;
CallStaticIntMethodA : PCallStaticIntMethodA;
CallStaticLongMethod : PCallStaticLongMethod;
CallStaticLongMethodV : PCallStaticLongMethodV;
CallStaticLongMethodA : PCallStaticLongMethodA;
CallStaticFloatMethod : PCallStaticFloatMethod;
CallStaticFloatMethodV : PCallStaticFloatMethodV;
CallStaticFloatMethodA : PCallStaticFloatMethodA;
CallStaticDoubleMethod : PCallStaticDoubleMethod;
CallStaticDoubleMethodV : PCallStaticDoubleMethodV;
CallStaticDoubleMethodA : PCallStaticDoubleMethodA;
CallStaticVoidMethod : PCallStaticVoidMethod;
CallStaticVoidMethodV : PCallStaticVoidMethodV;
CallStaticVoidMethodA : PCallStaticVoidMethodA;
GetStaticFieldID : PGetStaticFieldID;
GetStaticObjectField : PGetStaticObjectField;
GetStaticBooleanField : PGetStaticBooleanField;
GetStaticByteField : PGetStaticByteField;
GetStaticCharField : PGetStaticCharField;
GetStaticShortField : PGetStaticShortField;
GetStaticIntField : PGetStaticIntField;
GetStaticLongField : PGetStaticLongField;
GetStaticFloatField : PGetStaticFloatField;
GetStaticDoubleField : PGetStaticDoubleField;
SetStaticObjectField : PSetStaticObjectField;
SetStaticBooleanField : PSetStaticBooleanField;
SetStaticByteField : PSetStaticByteField;
SetStaticCharField : PSetStaticCharField;
SetStaticShortField : PSetStaticShortField;
SetStaticIntField : PSetStaticIntField;
SetStaticLongField : PSetStaticLongField;
SetStaticFloatField : PSetStaticFloatField;
SetStaticDoubleField : PSetStaticDoubleField;
NewString : PNewString;
GetStringLength : PGetStringLength;
GetStringChars : PGetStringChars;
ReleaseStringChars : PReleaseStringChars;
NewStringUTF : PNewStringUTF;
GetStringUTFLength : PGetStringUTFLength;
GetStringUTFChars : PGetStringUTFChars;
ReleaseStringUTFChars : PReleaseStringUTFChars;
GetArrayLength : PGetArrayLength;
NewObjectArray : PNewObjectArray;
GetObjectArrayElement : PGetObjectArrayElement;
SetObjectArrayElement : PSetObjectArrayElement;
NewBooleanArray : PNewBooleanArray;
NewByteArray : PNewByteArray;
NewCharArray : PNewCharArray;
NewShortArray : PNewShortArray;
NewIntArray : PNewIntArray;
NewLongArray : PNewLongArray;
NewFloatArray : PNewFloatArray;
NewDoubleArray : PNewDoubleArray;
GetBooleanArrayElements : PGetBooleanArrayElements;
GetByteArrayElements : PGetByteArrayElements;
GetCharArrayElements : PGetCharArrayElements;
GetShortArrayElements : PGetShortArrayElements;
GetIntArrayElements : PGetIntArrayElements;
GetLongArrayElements : PGetLongArrayElements;
GetFloatArrayElements : PGetFloatArrayElements;
GetDoubleArrayElements : PGetDoubleArrayElements;
ReleaseBooleanArrayElements : PReleaseBooleanArrayElements;
ReleaseByteArrayElements : PReleaseByteArrayElements;
ReleaseCharArrayElements : PReleaseCharArrayElements;
ReleaseShortArrayElements : PReleaseShortArrayElements;
ReleaseIntArrayElements : PReleaseIntArrayElements;
ReleaseLongArrayElements : PReleaseLongArrayElements;
ReleaseFloatArrayElements : PReleaseFloatArrayElements;
ReleaseDoubleArrayElements : PReleaseDoubleArrayElements;
GetBooleanArrayRegion : PGetBooleanArrayRegion;
GetByteArrayRegion : PGetByteArrayRegion;
GetCharArrayRegion : PGetCharArrayRegion;
GetShortArrayRegion : PGetShortArrayRegion;
GetIntArrayRegion : PGetIntArrayRegion;
GetLongArrayRegion : PGetLongArrayRegion;
GetFloatArrayRegion : PGetFloatArrayRegion;
GetDoubleArrayRegion : PGetDoubleArrayRegion;
SetBooleanArrayRegion : PSetBooleanArrayRegion;
SetByteArrayRegion : PSetByteArrayRegion;
SetCharArrayRegion : PSetCharArrayRegion;
SetShortArrayRegion : PSetShortArrayRegion;
SetIntArrayRegion : PSetIntArrayRegion;
SetLongArrayRegion : PSetLongArrayRegion;
SetFloatArrayRegion : PSetFloatArrayRegion;
SetDoubleArrayRegion : PSetDoubleArrayRegion;
RegisterNatives : PRegisterNatives;
UnregisterNatives : PUnregisterNatives;
MonitorEnter : PMonitorEnter;
MonitorExit : PMonitorExit;
GetJavaVM : PGetJavaVM;
GetStringRegion : PGetStringRegion;
GetStringUTFRegion : PGetStringUTFRegion;
GetPrimitiveArrayCritical : PGetPrimitiveArrayCritical;
ReleasePrimitiveArrayCritical : PReleasePrimitiveArrayCritical;
GetStringCritical : PGetStringCritical;
ReleaseStringCritical : PReleaseStringCritical;
NewWeakGlobalRef : PNewWeakGlobalRef;
DeleteWeakGlobalRef : PDeleteWeakGlobalRef;
ExceptionCheck : PExceptionCheck;
NewDirectByteBuffer : PNewDirectByteBuffer;
GetDirectBufferAddress : PGetDirectBufferAddress;
GetDirectBufferCapacity : PGetDirectBufferCapacity;
end;
JavaVM = packed record
functions: PJNIInvokeInterface;
end;
JNIEnv = packed record
functions: PJNINativeInterface;
end;
JNINativeMethod = packed record
name: PChar;
signature: PChar;
fnPtr: pointer;
end;
PJVMDI_Thread_Info = ^JVMDI_Thread_Info;
JVMDI_Thread_Info = packed record
name: PChar;
priority: JInteger;
is_daemon: JBoolean;
thread_group: JThreadGroup;
context_class_loader: JObject;
end;
PJVMDI_Thread_Group_Info = ^JVMDI_Thread_Group_Info;
JVMDI_Thread_Group_Info = packed record
parent: JThreadGroup;
name: PChar;
max_priority: JInteger;
is_daemon: JBoolean;
end;
PJVMDI_Monitor_Info = ^JVMDI_Monitor_Info;
JVMDI_Monitor_Info = packed record
owner: JThread;
entry_count: JInteger;
waiter_count: JInteger;
waiters: PJThread;
end;
PJVMDI_Owned_Monitor_Info = ^JVMDI_Owned_Monitor_Info;
JVMDI_Owned_Monitor_Info = packed record
owned_monitor_count: JInteger;
owned_monitors: PJObject;
end;
JVMDI_Single_Step_Event_Data = packed record
thread: JThread;
clazz: JClass;
method: JMethodId;
location: JLocation;
end;
JVMDI_Breakpoint_Event_Data = packed record
thread: JThread;
clazz: JClass;
method: JMethodId;
location: JLocation;
end;
JVMDI_Field_Access_Event_Data = packed record
thread: JThread;
clazz: JClass;
method: JMethodId;
location: JLocation;
field_clazz: JClass;
obj: JObject;
field: JFieldId;
end;

JVMDI_Field_Modification_Event_Data = packed record
thread: JThread;
clazz: JClass;
method: JMethodId;
location: JLocation;
field_clazz: JClass;
obj: JObject;
field: JFieldId;
signature_type: Char;
new_value: JValue;
end;
PJVMDI_Frame_Event_Data = ^JVMDI_Frame_Event_Data;
JVMDI_Frame_Event_Data = packed record
thread: JThread;
clazz: JClass;
method: JMethodId;
frame: JFrameId;
end;
JVMDI_Exception_Event_Data = packed record
thread: Jthread;
clazz: JClass;
method: JMethodId;
location: JLocation;
exception: JObject;
catch_clazz: JClass;
catch_method: JMethodId;
catch_location: JLocation;
end;
JVMDI_Exception_Catch_Event_Data = record
thread: JThread;
clazz: JClass;
method: JMethodId;
location: JLocation;
exception: JObject;
end;
JVMDI_User_Event_Data = packed record
obj: JObject;
key: JInteger;
end;
JVMDI_Thread_Change_Event_Data = packed record
thread: JThread;
end;
JVMDI_Class_Event_Data = packed record
thread: JThread;
clazz: JClass;
end;

PJVMDI_Event = ^JVMDI_Event;
JVMDI_Event = packed record
kind: JInteger;
reserved: pointer;
case Integer of
0: (single_step: JVMDI_Single_step_event_data);
1: (breakpoint: JVMDI_Breakpoint_event_data);
2: (frame: JVMDI_Frame_Event_Data);
3: (field_access: JVMDI_Field_Access_Event_Data);
4: (field_modification: JVMDI_Field_Modification_Event_Data);
5: (exception: JVMDI_Exception_Event_Data);
6: (exception_catch: JVMDI_Exception_Catch_Event_Data);
7: (user: JVMDI_User_Event_Data);
8: (thread_change: JVMDI_Thread_Change_Event_Data);
9: (class_event: JVMDI_Class_Event_Data);
end;
PPJVMDI_Line_Number_Entry = ^PJVMDI_Line_Number_Entry;
PJVMDI_Line_Number_Entry = ^JVMDI_Line_Number_Entry;
JVMDI_Line_Number_Entry = packed record
start_location: JLocation;
line_number: JInteger;
end;
PPJVMDI_Local_Variable_Entry = ^PJVMDI_Local_Variable_Entry;
PJVMDI_Local_Variable_Entry = ^JVMDI_Local_Variable_Entry;
JVMDI_Local_Variable_Entry = packed record
start_location: JLocation;
length: JInteger;
name: PChar;
signature: PChar;
slot: JInteger;
end;
PPJVMDI_Exception_Handler_Entry = ^PJVMDI_Exception_Handler_Entry;
PJVMDI_Exception_Handler_Entry = ^JVMDI_Exception_Handler_Entry;
JVMDI_Exception_Handler_Entry = packed record
start_location: JLocation;
end_location: Jlocation;
handler_location: JLocation;
exception: JClass;
end;
PPJVMDI_Operand_Stack_Element =^PJVMDI_Operand_Stack_Element;
PJVMDI_Operand_Stack_Element = ^JVMDI_Operand_Stack_Element;
JVMDI_Operand_Stack_Element = packed record
wrd: JInteger;
typ: JInteger;
end;
PJVMDI_Instance_Field = ^JVMDI_Instance_Field;
JVMDI_Instance_Field = packed record
instance: JObject;
field: JFieldId;
end;
PJVMDI_Static_Field = ^JVMDI_Static_Field;
JVMDI_Static_Field = packed record
clazz: JClass;
static_field: JFieldID;
end;
PJVMDI_Array_Element = ^JVMDI_Array_Element;
JVMDI_Array_Element = packed record
ary: JObjectArray;
index: JInteger;
end;
PJVMDI_Frame_Slot = ^JVMDI_Frame_Slot;
JVMDI_Frame_Slot = packed record
thread: JThread;
frame: JFrameId;
slot: JInteger;
end;
PJVMDI_Object_Reference_Info = ^JVMDI_Object_Reference_Info;
JVMDI_Object_Reference_Info = packed record
instance_field_count: JInteger;
instance_fields: PJVMDI_Instance_Field;
static_field_count: JInteger;
static_fields: PJVMDI_Static_Field;
array_element_count: JInteger;
array_elements: PJVMDI_Array_Element;
frame_slot_count: JInteger;
frame_slots: JVMDI_Frame_Slot;
end;
PJVMDI_Class_Definition = ^JVMDI_class_Definition;
JVMDI_Class_Definition = packed record
clazz: JClass;
class_byte_count: JInteger;
class_bytes: PJByte;
end;
PJVMDI_StartFunction = procedure; stdcall;
PJVMDI_EventHook = procedure(env: PJNIEnv; event: PJVMDI_Event); cdecl;
PJVMDI_AllocHook = function(size: JLong; memPtr: PPJByte): JVMDIError; stdcall;
PJVMDI_DeallocHook = function(buffer: PJByte): JVMDIError; stdcall;
//JVMDI Interface 1
PSetEventHook = function(hook: PJVMDI_EventHook):JVMDIError; stdcall;
PSetEventNotificationMode = function(mode: JInteger; eventType: JInteger; thread: JThread; args: array of const): JVMDIError; cdecl;
PGetThreadStatus = function(thread: JThread; threadStatusPtr: PJInteger; suspendStatusPtr: PJInteger): JVMDIError; stdcall;
PGetAllThreads = function(threadsCountPtr: PJInteger; threadsPtr: PPJThread): JVMDIError; stdcall;
PSuspendThread = function(thread: JThread): JVMDIError; stdcall;
PResumeThread = function(thread: JThread): JVMDIError; stdcall;
PStopThread = function(thread: JThread; exception: JObject): JVMDIError; stdcall;
PInterruptThread = function(thread: JThread): JVMDIError; stdcall;
PGetThreadInfo = function(thread: JThread; infoPtr: PJVMDI_Thread_Info): JVMDIError; stdcall;
PGetOwnedMonitorInfo = function(thread: JThread; infoPtr: PJVMDI_Owned_Monitor_Info): JVMDIError; stdcall;
PGetCurrentContendedMonitor = function(thread: JThread; monitor: PJObject): JVMDIError; stdcall;
PRunDebugThread = function(thread: JThread; proc: PJVMDI_StartFunction; arg: pointer; priority: integer): JVMDIError; stdcall;
PGetTopThreadGroups = function(groupCountPtr: PJInteger; groupsPtr: PPJThreadGroup): JVMDIError; stdcall;
PGetThreadGroupInfo = function(group: JThreadGroup; infoPtr: PJVMDI_Thread_Group_Info): JVMDIError; stdcall;
PGetThreadGroupChildren = function(group: JThreadGroup; threadCountPtr: PJInteger; threadsPtr: PPJThread; groupCountPtr: PJInteger; groupsPtr: PPJThreadGroup): JVMDIError; stdcall;
PGetFrameCount = function(thread: JThread; countPtr: PJInteger): JVMDIError; stdcall;
PGetCurrentFrame = function(thread: JThread; framePtr: PJFrameId): JVMDIError; stdcall;
PGetCallerFrame = function(called: JFrameId; framePtr: PJFrameId): JVMDIError; stdcall;
PGetFrameLocation = function(frame: JFrameId; classPtr: PJClass; methodPtr: PJMethodId; locationPtr: PJLocation): JVMDIError; stdcall;
PNotifyFramePop = function(frame: JFrameId): JVMDIError; stdcall;
PGetLocalObject = function(frame: JFrameId; slot: JInteger; valuePtr: PJObject): JVMDIError; stdcall;
PGetLocalInt = function(frame: JFrameId; slot: JInteger; valuePtr: PJInteger): JVMDIError; stdcall;
PGetLocalLong = function(frame: JFrameId; slot: JInteger; valuePtr: PJLong): JVMDIError; stdcall;
PGetLocalFloat = function(frame: JFrameId; slot: JInteger; valuePtr: PJFloat): JVMDIError; stdcall;
PGetLocalDouble = function(frame: JFrameId; slot: JInteger; valuePtr: PJDouble): JVMDIError; stdcall;
PSetLocalObject = function(frame: JFrameId; slot: JInteger; value: JObject): JVMDIError; stdcall;
PSetLocalInt = function(frame: JFrameId; slot: JInteger; value: JInteger): JVMDIError; stdcall;
PSetLocalLong = function(frame: JFrameId; slot: JInteger; value: JLong): JVMDIError; stdcall;
PSetLocalFloat = function(frame: JFrameId; slot: JInteger; value: JFloat): JVMDIError; stdcall;
PSetLocalDouble = function(frame: JFrameId; slot: JInteger; value: JDouble): JVMDIError; stdcall;
PCreateRawMonitor = function(name: PChar; monitorPtr: PJVMDI_RawMonitor): JVMDIError; stdcall;
PDestroyRawMonitor = function(monitor: PJVMDI_RawMonitor): JVMDIError; stdcall;
PRawMonitorEnter = function(monitor: PJVMDI_RawMonitor): JVMDIError; stdcall;
PRawMonitorExit = function(monitor: PJVMDI_RawMonitor): JVMDIError; stdcall;
PRawMonitorWait = function(monitor: PJVMDI_RawMonitor; millis: JLong): JVMDIError; stdcall;
PRawMonitorNotify = function(monitor: PJVMDI_RawMonitor): JVMDIError; stdcall;
PRawMonitorNotifyAll = function(monitor: PJVMDI_RawMonitor): JVMDIError; stdcall;
PSetBreakpoint = function(clazz: JClass; method: JMethodId; location: JLocation): JVMDIError; stdcall;
PClearBreakpoint = function(clazz: JClass; method: JMethodId; location: JLocation): JVMDIError; stdcall;
PClearAllBreakpoints = function(): JVMDIError; stdcall;
PSetFieldAccessWatch = function(clazz: JClass; field: JFieldId): JVMDIError; stdcall;
PClearFieldAccessWatch = function(clazz: JClass; field: JFieldId): JVMDIError; stdcall;
PSetFieldModificationWatch = function(clazz: JClass; field: JFieldId): JVMDIError; stdcall;
PClearFieldModificationWatch = function(clazz: JClass; field: JFieldId): JVMDIError; stdcall;
PSetAllocationHooks = function(ahook: PJVMDI_AllocHook; dhook: PJVMDI_DeallocHook): JVMDIError; stdcall;
PAllocate = function(size: JLong; memPtr: PPJByte): JVMDIError; stdcall;
PDeallocate = function(mem: PJByte): JVMDIError; stdcall;
PGetClassSignature = function(clazz: JClass; sigPtr: PPChar): JVMDIError; stdcall;
PGetClassStatus = function(clazz: JClass; statusPtr: PJInteger): JVMDIError; stdcall;
PGetSourceFileName = function(clazz: JClass; sourceNamePtr: PPChar): JVMDIError; stdcall;
PGetClassModifiers = function(clazz: JClass; modifiersPtr: PJInteger): JVMDIError; stdcall;
PGetClassMethods = function(clazz: JClass; methodCountPtr: PJInteger; methodsPtr: PPJMethodId): JVMDIError; stdcall;
PGetClassFields = function(clazz: JClass; fieldCountPtr: PJInteger; fieldsPtr: PPJFieldId): JVMDIError; stdcall;
PGetImplementedInterfaces = function(clazz: JClass; interfaceCountPtr: PJInteger; interfacesPtr: PPJClass): JVMDIError; stdcall;
PIsInterface = function(clazz: JClass; isInterfacePtr: PJBoolean): JVMDIError; stdcall;
PIsArrayClass = function(clazz: JClass; isArrayClassPtr: PJBoolean): JVMDIError; stdcall;
PGetClassLoader = function(clazz: JClass; classloaderPtr: PJObject): JVMDIError; stdcall;
PGetObjectHashCode = function(obj: JObject; hashCodePtr: PJInteger): JVMDIError; stdcall;
PGetMonitorInfo = function(obj: JObject; infoPtr: PJVMDI_Monitor_Info): JVMDIError; stdcall;
PGetFieldName = function(clazz: JClass; field: JFieldId; namePtr:PPChar; signaturePtr:PPChar): JVMDIError; stdcall;
PGetFieldDeclaringClass = function(clazz: JClass; field: JFieldId; declaringClassPtr: PJClass): JVMDIError; stdcall;
PGetFieldModifiers = function(clazz: JClass; field: JFieldId; modifiersPtr: PJInteger): JVMDIError; stdcall;
PIsFieldSynthetic = function(clazz: JClass; field: JFieldId; isSyntheticPtr: PJBoolean): JVMDIError; stdcall;
PGetMethodName = function(clazz: JClass; method: JMethodId; namePtr: PPChar; signaturePtr: PPChar): JVMDIError; stdcall;
PGetMethodDeclaringClass = function(clazz: JClass; method: JMethodId; declaringClassPtr: PJClass): JVMDIError; stdcall;
PGetMethodModifiers = function(clazz: JClass; method: JMethodId; modifiersPtr: PJInteger): JVMDIError; stdcall;
PGetMaxStack = function(clazz: JClass; method: JMethodId; maxPtr: PJInteger): JVMDIError; stdcall;
PGetMaxLocals = function(clazz: JClass; method: JMethodId; maxPtr: PJInteger): JVMDIError; stdcall;
PGetArgumentsSize = function(clazz: JClass; method: JMethodId; sizePtr: PJInteger): JVMDIError; stdcall;
PGetLineNumberTable = function(clazz: JClass; method: JMethodId; entryCountPtr: PJInteger; tablePtr: PPJVMDI_Line_Number_Entry): JVMDIError; stdcall;
PGetMethodLocation = function(clazz: JClass; method: JMethodId; startLocationPtr: PJLocation; endLocationPtr: PJLocation): JVMDIError; stdcall;
PGetLocalVariableTable = function(clazz: JClass; method: JMethodId; entryCountPtr: PJInteger; tablePtr: PPJVMDI_Local_Variable_Entry): JVMDIError; stdcall;
PGetExceptionHandlerTable = function(clazz: JClass; method: JMethodId; entryCountPtr: PJInteger; tablePtr: PPJVMDI_Exception_Handler_Entry): JVMDIError; stdcall;
PGetThrownExceptions = function(clazz: JClass; method: JMethodId; exceptionCountPtr: PJInteger; exceptionsPtr: PPJClass): JVMDIError; stdcall;
PGetBytecodes = function(clazz: JClass; method: JMethodId; bytecodeCountPtr: PJInteger; bytecodesPtr: PPJByte): JVMDIError; stdcall;
PIsMethodNative = function(clazz: JClass; method: JMethodId; isNativePtr: PJBoolean): JVMDIError; stdcall;
PIsMethodSynthetic = function(clazz: JClass; method: JMethodId; isSyntheticPtr: PJBoolean): JVMDIError; stdcall;
PGetLoadedClasses = function(classCountPtr: PJInteger; classesPtr: PPJClass): JVMDIError; stdcall;
PGetClassLoaderClasses = function(initiatingLoader: JObject; classesCountPtr: PJInteger; classesPtr: PPJClass): JVMDIError; stdcall;
PPopFrame = function(thread: JThread): JVMDIError; stdcall;
PSetFrameLocation = function(frame: JFrameId; location: JLocation): JVMDIError; stdcall;
PGetOperandStack = function(frame: JFrameId; operandStackSizePtr: PJInteger; operandStackPtr: PPJVMDI_Operand_Stack_Element): JVMDIError; stdcall;
PSetOperandStack = function(frame: JFrameId; operandStackSize: JInteger; operandStack: PJVMDI_Operand_Stack_Element): JVMDIError; stdcall;
PAllInstances = function(clazz: JClass; instanceCountPtr: PJInteger; instancesPtr: PPJObject): JVMDIError; stdcall;
PReferences = function(obj: JObject; refs: PJVMDI_Object_Reference_Info): JVMDIError; stdcall;
PGetClassDefinition = function(clazz: JClass; classDefPtr: PJVMDI_Class_Definition): JVMDIError; stdcall;
PRedefineClasses = function(classCount: JInteger; classDefs: PJVMDI_Class_Definition): JVMDIError; stdcall;
PGetVersionNumber = function(versionPtr: PJInteger): JVMDIError; stdcall;
PGetCapabilities = function(capabilitiesPtr: PWord): JVMDIError; stdcall;
PGetSourceDebugExtension = function(clazz: JClass; sourceDebugExtension: PPChar): JVMDIError; stdcall;
PIsMethodObsolete = function(clazz: JClass; method: JMethodId; isObsoletePtr: PJBoolean): JVMDIError; stdcall;
PSuspendThreadList = function(reqCount: JInteger; reqList: PJThread; results: PJVMDIError): JVMDIError; stdcall;
PResumeThreadList = function(reqCount: JInteger; reqList: PJThread; results: PJVMDIError): JVMDIError; stdcall;
PJVMDI_Interface_1 = ^JVMDI_Interface_1;
JVMDI_Interface_1 = packed record
SetEventHook: PSetEventHook;
SetEventNotificationMode: PSetEventNotificationMode;
GetThreadStatus: PGetThreadStatus;
GetAllThreads: PGetAllThreads;
SuspendThread: PSuspendThread;
ResumeThread: PResumeThread;
StopThread: PStopThread;
InterruptThread: PInterruptThread;
GetThreadInfo: PGetThreadInfo;
GetOwnedMonitorInfo: PGetOwnedMonitorInfo;
GetCurrentContendedMonitor: PGetCurrentContendedMonitor;
RunDebugThread: PRunDebugThread;
GetTopThreadGroups: PGetTopThreadGroups;
GetThreadGroupInfo: PGetThreadGroupInfo;
GetThreadGroupChildren: PGetThreadGroupChildren;
GetFrameCount: PGetFrameCount;
GetCurrentFrame: PGetCurrentFrame;
GetCallerFrame: PGetCallerFrame;
GetFrameLocation: PGetFrameLocation;
NotifyFramePop: PNotifyFramePop;
GetLocalObject: PGetLocalObject;
GetLocalInt: PGetLocalInt;
GetLocalLong: PGetLocalLong;
GetLocalFloat: PGetLocalFloat;
GetLocalDouble: PGetLocalDouble;
SetLocalObject: PSetLocalObject;
SetLocalInt: PSetLocalInt;
SetLocalLong: PSetLocalLong;
SetLocalFloat: PSetLocalFloat;
SetLocalDouble: PSetLocalDouble;
CreateRawMonitor: PCreateRawMonitor;
DestroyRawMonitor: PDestroyRawMonitor;
RawMonitorEnter: PRawMonitorEnter;
RawMonitorExit: PRawMonitorExit;
RawMonitorWait: PRawMonitorWait;
RawMonitorNotify: PRawMonitorNotify;
RawMonitorNotifyAll: PRawMonitorNotifyAll;
SetBreakpoint: PSetBreakpoint;
ClearBreakpoint: PClearBreakpoint;
ClearAllBreakpoints: PClearAllBreakpoints;
SetFieldAccessWatch: PSetFieldAccessWatch;
ClearFieldAccessWatch: PClearFieldAccessWatch;
SetFieldModificationWatch: PSetFieldModificationWatch;
ClearFieldModificationWatch: PClearFieldModificationWatch;
SetAllocationHooks: PSetAllocationHooks;
Allocate: PAllocate;
Deallocate: PDeallocate;
GetClassSignature: PGetClassSignature;
GetClassStatus: PGetClassStatus;
GetSourceFileName: PGetSourceFileName;
GetClassModifiers: PGetClassModifiers;
GetClassMethods: PGetClassMethods;
GetClassFields: PGetClassFields;
GetImplementedInterfaces: PGetImplementedInterfaces;
IsInterface: PIsInterface;
IsArrayClass: PIsArrayClass;
GetClassLoader: PGetClassLoader;
GetObjectHashCode: PGetObjectHashCode;
GetMonitorInfo: PGetMonitorInfo;
GetFieldName: PGetFieldName;
GetFieldDeclaringClass: PGetFieldDeclaringClass;
GetFieldModifiers: PGetFieldModifiers;
IsFieldSynthetic: PIsFieldSynthetic;
GetMethodName: PGetMethodName;
GetMethodDeclaringClass: PGetMethodDeclaringClass;
GetMethodModifiers: PGetMethodModifiers;
GetMaxStack: PGetMaxStack;
GetMaxLocals: PGetMaxLocals;
GetArgumentsSize: PGetArgumentsSize;
GetLineNumberTable: PGetLineNumberTable;
GetMethodLocation: PGetMethodLocation;
GetLocalVariableTable: PGetLocalVariableTable;
GetExceptionHandlerTable: PGetExceptionHandlerTable;
GetThrownExceptions: PGetThrownExceptions;
GetBytecodes: PGetBytecodes;
IsMethodNative: PIsMethodNative;
IsMethodSynthetic: PIsMethodSynthetic;
GetLoadedClasses: PGetLoadedClasses;
GetClassLoaderClasses: PGetClassLoaderClasses;
PopFrame: PPopFrame;
SetFrameLocation: PSetFrameLocation;
GetOperandStack: PGetOperandStack;
SetOperandStack: PSetOperandStack;
AllInstances: PAllInstances;
References: PReferences;
GetClassDefinition: PGetClassDefinition;
RedefineClasses: PRedefineClasses;
GetVersionNumber: PGetVersionNumber;
GetCapabilities: PGetCapabilities;
GetSourceDebugExtension: PGetSourceDebugExtension;
IsMethodObsolete: PIsMethodObsolete;
SuspendThreadList: PSuspendThreadList;
ResumeThreadList: PResumeThreadList;
end;
const
JNI_OK = 0;
JVMDI_VERSION_1 = $20010000;
JVMDI_VERSION_1_1 = $20010001;
JVMDI_VERSION_1_2 = $20010002;
JVMDI_VERSION_1_3 = $20010003;
JVMDI_DISABLE = 0;
JVMDI_ENABLE = 1;
JVMDI_EVENT_SINGLE_STEP = 1;
JVMDI_EVENT_BREAKPOINT = 2;
JVMDI_EVENT_FRAME_POP = 3;
JVMDI_EVENT_EXCEPTION = 4;
JVMDI_EVENT_USER_DEFINED = 5;
JVMDI_EVENT_THREAD_START = 6;
JVMDI_EVENT_THREAD_END = 7;
JVMDI_EVENT_CLASS_PREPARE = 8;
JVMDI_EVENT_CLASS_UNLOAD = 9;
JVMDI_EVENT_CLASS_LOAD = 10;
JVMDI_EVENT_FIELD_ACCESS = 20;
JVMDI_EVENT_FIELD_MODIFICATION = 21;
JVMDI_EVENT_EXCEPTION_CATCH = 30;
JVMDI_EVENT_METHOD_ENTRY = 40;
JVMDI_EVENT_METHOD_EXIT = 41;
JVMDI_EVENT_VM_INIT = 90;
JVMDI_EVENT_VM_DEATH = 99;
JVMDI_MAX_EVENT_TYPE_VAL = 99;
JVMDI_OPERAND_TYPE_REFERENCE = 1;
JVMDI_OPERAND_TYPE_INT = 2;
JVMDI_OPERAND_TYPE_FLOAT = 3;
JVMDI_OPERAND_TYPE_LONG0 = 4;
JVMDI_OPERAND_TYPE_LONG1 = 5;
JVMDI_OPERAND_TYPE_DOUBLE0 = 6;
JVMDI_OPERAND_TYPE_DOUBLE1 = 7;
JVMDI_OPERAND_TYPE_RETURN_ADDRESS = 8;
JVMDI_CLASS_STATUS_VERIFIED = 1;
JVMDI_CLASS_STATUS_PREPARED = 2;
JVMDI_CLASS_STATUS_INITIALIZED = 4;
JVMDI_CLASS_STATUS_ERROR = 8;
implementation
end.
-------------------------------------------------------------------------------
To communicate using JVMDI you will have to create a DLL that exports the JVM_OnLoad function. Its prototype is as follows
function JVM_OnLoad(vm :PJavaVM; options:PChar; reserved: pointer):integer; stdcall;
When running a java program you should call the java executable with the following parameters
java -Xdebug -Xnoagent -Xrun
When the jvm starts up it will call the JVM_Onload function.
Within this function you will have to call the SetEventHook function which takes a pointer to a hook function as a parameter. The prototype of the hook function is as follows.
procedure JVMDIEventHook(env: PJNIEnv; event: PJVMDI_Event); cdecl;
Whenever an event occurs the JVM calls the hook function. The event parameter specifies the type of the event that occured. It also contains other event dependent information
The different types of events are as follows
Single Step Event
Breakpoint Event
Field Events
Frame Events
Exception Event
Exception Catch Event
User Defined Event
Thread Events
Class Events
VM Initialization Event
VM Death Event
For more information regarding events or JVMDI in general you can refer to the following site
http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jvmdi-spec.html
Here is an example that writes to a file all java methods that were invoked during the execution of java class.
----------------------------------------------------------------
unit JVMDIUnit;
interface
uses
SysUtils, Windows, JVMDIStructs;
function JVM_OnLoad(vm :PJavaVM; options:PChar; reserved: pointer):integer; stdcall;
implementation
var
processing: boolean;
canProcess: boolean;
_vm: PJavaVM;
procedure JVMDIEventHook(env: PJNIEnv; event: PJVMDI_Event); cdecl;
var
fHandle: integer;
cnt: cardinal;
jvmi: PJVMDI_Interface_1;
strTemp: PChar;
methodName: PChar;
methodSig:PChar;
begin
if(canProcess) and (processing=false) then
begin
if(event.kind=JVMDI_EVENT_METHOD_ENTRY ) then
begin
processing:= true;
_vm.functions.GetEnv(_vm, @jvmi, JVMDI_VERSION_1_3);
fHandle:= CreateFile('C:/temp/test.txt',GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
SetFilePointer(fHandle,0, nil, FILE_END);
jvmi.GetMethodName(event.frame.clazz, event.frame.method, @methodName, @methodSig);
jvmi.GetClassSignature(event.frame.clazz, @strTemp);
WriteFile(fHandle, strTemp^, strlen(strTemp), cnt, nil);
WriteFile(fHandle, ':'#32, 2, cnt, nil);
WriteFile(fHandle, methodName^, strlen(methodName), cnt, nil);
WriteFile(fHandle, ':'#32, 2, cnt, nil);
WriteFile(fHandle, methodSig^, strlen(methodSig), cnt, nil);
WriteFile(fHandle, #13#10, 2, cnt, nil);
CloseHandle(fHandle);
processing:= false;
end;
end;
if(event.kind=JVMDI_EVENT_VM_INIT) then canProcess:= true
else if(event.kind=JVMDI_EVENT_VM_DEATH ) then canProcess:= false;
end;
function JVM_OnLoad(vm :PJavaVM; options:PChar; reserved: pointer):integer; stdcall;
var
fHandle: integer;
cnt: cardinal;
jvmi: PJVMDI_Interface_1;
begin
jvmi:= nil;
fHandle:= CreateFile('C:/temp/test.txt',GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
WriteFile(fHandle, 'H'#13#10, 3, cnt, nil);
_vm:= vm;
vm.functions.GetEnv(vm, @jvmi, JVMDI_VERSION_1_3);
jvmi.SetEventNotificationMode(JVMDI_ENABLE, JVMDI_EVENT_VM_INIT, nil, []);
jvmi.SetEventNotificationMode(JVMDI_ENABLE, JVMDI_EVENT_METHOD_ENTRY, nil,[]);
jvmi.SetEventNotificationMode(JVMDI_ENABLE, JVMDI_EVENT_METHOD_EXIT, nil, []);
jvmi.SetEventHook(JVMDIEventHook);
CloseHandle(fHandle);
result:= JNI_OK;
end;
end.
--------------------------------------------------------------------------------