- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
JNIEXPORT jstring JNICALL _Java_com_fl_nat_Status_listProcessess0(JNIEnv *env, jobject obj) {
char format[1024*128];
char name[128];
unsigned long procs[1024], needed, ret;
if(!EnumProcesses(procs, sizeof(procs), &needed)) return (*env)->NewStringUTF(env, "");
ret = needed / sizeof(unsigned long);
unsigned int i = 0;
for(; i < ret; i++) {
if(procs[i] == 0) continue;
HANDLE hproc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, procs[i]);
GetModuleBaseName(hproc, 0, name, 128);
strncat(format, name, strlen(name));
strncat(format, ",", 1);
sprintf(name, "%i", procs[i]);
strncat(format, name, strlen(name));
strncat(format, ";", 1);
CloseHandle(hproc);
}
return (*env)->NewStringUTF(env, format);
}