--- old/./src/windows/native/java/lang/ProcessImpl_md.c 2012-09-07 14:37:50.475436530 -0400 +++ new/./src/windows/native/java/lang/ProcessImpl_md.c 2012-09-07 14:37:50.335436534 -0400 @@ -32,6 +32,8 @@ #include "io_util.h" #include #include +#include +#include /* We try to make sure that we can read and write 4095 bytes (the * fixed limit on Linux) to the pipe on all operating systems without @@ -390,3 +392,43 @@ } return ptr_to_jlong(h); } + +JNIEXPORT jint JNICALL +Java_java_lang_ProcessImpl_getProcessId(JNIEnv *env, jclass ignored, jlong handle) +{ + return GetProcessId((HANDLE) handle); +} + +JNIEXPORT jint JNICALL +Java_java_lang_ProcessImpl_getCurrentPid(JNIEnv *env, jobject this) +{ + return GetCurrentProcessId(); +} + + +JNIEXPORT jstring JNICALL +Java_java_lang_ProcessImpl_getModuleBaseName(JNIEnv *env, jclass ignored, jint pid) +{ + char szProcessName[MAX_PATH]; + + // Get a handle to the process. + + HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | + PROCESS_VM_READ, + FALSE, pid ); + + // Get the process name. + + if (hProcess != NULL ) + { + HMODULE hMod; + DWORD cbNeeded; + + if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), + &cbNeeded) ) { + GetModuleBaseName( hProcess, hMod, szProcessName, + sizeof(szProcessName) ); + } + } + return szProcessName; +}