You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/18 22:04:55 UTC
svn commit: r1094719 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/platform/windows/Win32.java
native/os/win32/winapi.c
Author: mturk
Date: Mon Apr 18 20:04:54 2011
New Revision: 1094719
URL: http://svn.apache.org/viewvc?rev=1094719&view=rev
Log:
More Win32 API
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java?rev=1094719&r1=1094718&r2=1094719&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java Mon Apr 18 20:04:54 2011
@@ -80,11 +80,34 @@ final class Win32
public static final int SEMAPHORE_ALL_ACCESS = 0x001F0003;
public static final int SEMAPHORE_MODIFY_STATE = 0x00000002;
+ /* Memory allocation flags */
+ public static final int MEM_COMMIT = 0x00001000;
+ public static final int MEM_RESERVE = 0x00002000;
+ public static final int MEM_RESET = 0x00008000;
+ /* Memory free flags */
+ public static final int MEM_DECOMMIT = 0x00004000;
+ public static final int MEM_RELEASE = 0x00008000;
+ /* Memory protection flags */
+ public static final int PAGE_EXECUTE = 0x00000010;
+ public static final int PAGE_EXECUTE_READ = 0x00000020;
+ public static final int PAGE_EXECUTE_READWRITE = 0x00000040;
+ public static final int PAGE_EXECUTE_WRITECOPY = 0x00000080;
+ public static final int PAGE_NOACCESS = 0x00000001;
+ public static final int PAGE_READONLY = 0x00000002;
+ public static final int PAGE_READWRITE = 0x00000004;
+ public static final int PAGE_WRITECOPY = 0x00000008;
+ public static final int PAGE_GUARD = 0x00000100;
+ public static final int PAGE_NOCACHE = 0x00000200;
+ public static final int PAGE_WRITECOMBINE = 0x00000400;
+
public static native int CloseHandle(long handle);
public static native int LocalFree(long ptr);
public static native int WaitForSingleObject(long handle, int timeout);
public static native long CreateMutex(long sa, boolean initialOwner, String name);
public static native long OpenMutex(int access, boolean inheritHandle, String name);
+ public static native long VirtualAlloc(long base, long size, int type, int protect);
+ public static native int VirtualProtect(long addr, long size, int protect);
+ public static native int VirtualFree(long addr, long size, int type);
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c?rev=1094719&r1=1094718&r2=1094719&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c Mon Apr 18 20:04:54 2011
@@ -81,3 +81,29 @@ ACR_WIN_EXPORT(jlong, Win32, OpenMutex)(
return P2J(h);
}
+
+ACR_WIN_EXPORT(jlong, Win32, VirtualAlloc)(JNI_STDARGS, jlong base, jlong size, jint type, jint protect)
+{
+ void *mem = 0;
+
+ mem = VirtualAlloc(J2P(base, LPVOID), (SIZE_T)size, type, protect);
+ if (mem == 0)
+ ACR_SAVE_OS_ERROR();
+ return P2J(mem);
+}
+
+ACR_WIN_EXPORT(jint, Win32, VirtualProtect)(JNI_STDARGS, jlong addr, jlong size, jint protect)
+{
+ if (VirtualProtect(J2P(addr, LPVOID), (SIZE_T)size, protect, 0))
+ return 0;
+ else
+ return ACR_GET_OS_ERROR();
+}
+
+ACR_WIN_EXPORT(jint, Win32, VirtualFree)(JNI_STDARGS, jlong addr, jlong size, jint type)
+{
+ if (VirtualFree(J2P(addr, LPVOID), (SIZE_T)size, type))
+ return 0;
+ else
+ return ACR_GET_OS_ERROR();
+}