int main (int argc, char *argv[]) { HANDLE process; DWORD pid; if (argc < 2) { printf("Usage: %s pid\n", argv[0]); return 1; } if (argc >= 3) outprefix = argv[2]; pid = atoi(argv[1]); if (pid <= 0) { STARTUPINFO sinfo; PROCESS_INFORMATION pinfo; memset(&pinfo, 0, sizeof(pinfo)); memset(&sinfo, 0, sizeof(sinfo)); sinfo.cb = sizeof(sinfo); if (!CreateProcess(NULL, argv[1], NULL, NULL, FALSE, 0, NULL, NULL, &sinfo, &pinfo)) { printf("error: CreateProcess(%s) failed.\n", argv[1]); return 1; } CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); pid = pinfo.dwProcessId; printf("Process %d created. sleep for 2 sec.\n", pid); Sleep(2000); } process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, pid); if (process == NULL) { printf("error: OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, %d) failed. GetLastError()=0x%x\n", pid, GetLastError()); return 1; } enum_modules(process); enum_maps(process); TerminateProcess(process, 0); CloseHandle(process); return 0; }
/*refresh modules - note we don't check for deleted modules but since we've open them the OS should forbid delete*/ GF_EXPORT u32 gf_modules_refresh(GF_ModuleManager *pm) { if (!pm) return 0; //!! symbian 9.1 doesn't allow for DLL browsing in /sys/bin, and can only load DLLs in /sys/bin !! #if 0 gf_enum_directory((char*)pm->dir, 0, enum_modules, pm, ".dll"); #else u32 i, mod_count; mod_count = gf_cfg_get_key_count(pm->cfg, "SymbianDLLs"); for (i=0; i<mod_count; i++) { const char *mod = gf_cfg_get_key_name(pm->cfg, "SymbianDLLs", i); if (stricmp(gf_cfg_get_key(pm->cfg, "SymbianDLLs", mod), "yes")) continue; enum_modules(pm, (char*)mod, NULL); } #endif return gf_list_count(pm->plug_list); }