Example #1
0
 private static void HookStream(JniEnvironment environment, JniClass nativeClazz, 
     JavaVMLogTypes hook, string javaHookMethod)
 {
     JniMethod outMid = nativeClazz.GetStaticMethodId(environment, javaHookMethod, "(I)V");
     JValue[] paramArray = new JValue[1];
     paramArray[0].AssignIntValue((int)hook);
     outMid.CallStaticVoidMethod(environment, paramArray);
 }
 private static string[] GetJavaPropertyNames(JniEnvironment environment, JniClass systemClazz)
 {
     JniLocalFrame frame = environment.CreateLocalFrame(6);
     try
     {
         JniMethod getPropsMid = systemClazz.GetStaticMethodId(environment, "getProperties", "()Ljava/util/Properties;");
         JniObject propsHandle = getPropsMid.CallStaticObjectMethod(environment, null);
         JniClass propsClazz = propsHandle.GetObjectClass(environment);
         JniMethod keySetId = propsClazz.GetMethodId(environment, "keySet", "()Ljava/util/Set;");
         JniObject setHandle = keySetId.CallObjectMethod(environment, propsHandle, null);
         JniClass setClazz = setHandle.GetObjectClass(environment);
         JniMethod toArrayId = setClazz.GetMethodId(environment, "toArray", "()[Ljava/lang/Object;");
         JniObjectArray arrayHandle = (JniObjectArray)toArrayId.CallObjectMethod(environment, setHandle, null);
         string[] keyNames = JniString.ExtractStringArray(environment, arrayHandle);
         return keyNames;
     }
     finally
     {
         frame.SafePop();
     }
 }