4 * Copyright 1998 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/server.h"
25 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(psapi);
34 /***********************************************************************
35 * get pid from hProcess (internal)
37 static DWORD get_pid_from_process_handle(HANDLE hProcess)
41 SERVER_START_REQ( get_process_info )
43 req->handle = hProcess;
44 if ( !wine_server_call_err( req ) )
45 ret = (DWORD)reply->pid;
52 /***********************************************************************
53 * EmptyWorkingSet (PSAPI.@)
55 BOOL WINAPI EmptyWorkingSet(HANDLE hProcess)
57 return SetProcessWorkingSetSize(hProcess, 0xFFFFFFFF, 0xFFFFFFFF);
60 /***********************************************************************
61 * EnumDeviceDrivers (PSAPI.@)
63 BOOL WINAPI EnumDeviceDrivers(
64 LPVOID *lpImageBase, DWORD cb, LPDWORD lpcbNeeded)
66 FIXME("(%p, %ld, %p): stub\n", lpImageBase, cb, lpcbNeeded);
75 /***********************************************************************
76 * EnumProcesses (PSAPI.@)
78 BOOL WINAPI EnumProcesses(DWORD *lpidProcess, DWORD cb, DWORD *lpcbNeeded)
86 FIXME("(%p, %ld, %p)\n", lpidProcess,cb, lpcbNeeded);
88 if ( lpidProcess == NULL )
90 if ( lpcbNeeded != NULL )
93 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
94 if ( hSnapshot == INVALID_HANDLE_VALUE )
96 FIXME("cannot create snapshot\n");
100 countMax = cb / sizeof(DWORD);
103 ZeroMemory( &pe, sizeof(PROCESSENTRY32) );
104 pe.dwSize = sizeof(PROCESSENTRY32);
105 res = (count == 0) ? Process32First( hSnapshot, &pe ) : Process32Next( hSnapshot, &pe );
108 TRACE("process 0x%08lx\n",(long)pe.th32ProcessID);
109 if ( count < countMax )
110 lpidProcess[count] = pe.th32ProcessID;
113 CloseHandle( hSnapshot );
115 if ( lpcbNeeded != NULL )
116 *lpcbNeeded = sizeof(DWORD) * count;
118 TRACE("return %lu processes\n",count);
123 /***********************************************************************
124 * EnumProcessModules (PSAPI.@)
126 BOOL WINAPI EnumProcessModules(
127 HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded)
136 FIXME("(hProcess=0x%08x, %p, %ld, %p)\n",
137 hProcess, lphModule, cb, lpcbNeeded );
139 if ( lphModule == NULL )
141 if ( lpcbNeeded != NULL )
144 pid = get_pid_from_process_handle(hProcess);
147 FIXME("no pid for hProcess 0x%08x\n",hProcess);
151 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pid);
152 if ( hSnapshot == INVALID_HANDLE_VALUE )
154 FIXME("cannot create snapshot\n");
158 countMax = cb / sizeof(HMODULE);
161 ZeroMemory( &me, sizeof(MODULEENTRY32) );
162 me.dwSize = sizeof(MODULEENTRY32);
163 res = (count == 0) ? Module32First( hSnapshot, &me ) : Module32Next( hSnapshot, &me );
166 TRACE("module 0x%08lx\n",(long)me.hModule);
167 if ( count < countMax )
168 lphModule[count] = me.hModule;
171 CloseHandle( hSnapshot );
173 if ( lpcbNeeded != NULL )
174 *lpcbNeeded = sizeof(HMODULE) * count;
176 TRACE("return %lu modules\n",count);
181 /***********************************************************************
182 * GetDeviceDriverBaseNameA (PSAPI.@)
184 DWORD WINAPI GetDeviceDriverBaseNameA(
185 LPVOID ImageBase, LPSTR lpBaseName, DWORD nSize)
187 FIXME("(%p, %s, %ld): stub\n",
188 ImageBase, debugstr_a(lpBaseName), nSize
191 if(lpBaseName && nSize)
192 lpBaseName[0] = '\0';
197 /***********************************************************************
198 * GetDeviceDriverBaseNameW (PSAPI.@)
200 DWORD WINAPI GetDeviceDriverBaseNameW(
201 LPVOID ImageBase, LPWSTR lpBaseName, DWORD nSize)
203 FIXME("(%p, %s, %ld): stub\n",
204 ImageBase, debugstr_w(lpBaseName), nSize
207 if(lpBaseName && nSize)
208 lpBaseName[0] = '\0';
213 /***********************************************************************
214 * GetDeviceDriverFileNameA (PSAPI.@)
216 DWORD WINAPI GetDeviceDriverFileNameA(
217 LPVOID ImageBase, LPSTR lpFilename, DWORD nSize)
219 FIXME("(%p, %s, %ld): stub\n",
220 ImageBase, debugstr_a(lpFilename), nSize
223 if(lpFilename && nSize)
224 lpFilename[0] = '\0';
229 /***********************************************************************
230 * GetDeviceDriverFileNameW (PSAPI.@)
232 DWORD WINAPI GetDeviceDriverFileNameW(
233 LPVOID ImageBase, LPWSTR lpFilename, DWORD nSize)
235 FIXME("(%p, %s, %ld): stub\n",
236 ImageBase, debugstr_w(lpFilename), nSize
239 if(lpFilename && nSize)
240 lpFilename[0] = '\0';
245 /***********************************************************************
246 * GetMappedFileNameA (PSAPI.@)
248 DWORD WINAPI GetMappedFileNameA(
249 HANDLE hProcess, LPVOID lpv, LPSTR lpFilename, DWORD nSize)
251 FIXME("(hProcess=0x%08x, %p, %s, %ld): stub\n",
252 hProcess, lpv, debugstr_a(lpFilename), nSize
255 if(lpFilename && nSize)
256 lpFilename[0] = '\0';
261 /***********************************************************************
262 * GetMappedFileNameW (PSAPI.@)
264 DWORD WINAPI GetMappedFileNameW(
265 HANDLE hProcess, LPVOID lpv, LPWSTR lpFilename, DWORD nSize)
267 FIXME("(hProcess=0x%08x, %p, %s, %ld): stub\n",
268 hProcess, lpv, debugstr_w(lpFilename), nSize
271 if(lpFilename && nSize)
272 lpFilename[0] = '\0';
277 /***********************************************************************
278 * GetModuleBaseNameA (PSAPI.@)
280 DWORD WINAPI GetModuleBaseNameA(
281 HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize)
283 FIXME("(hProcess=0x%08x, hModule=0x%08x, %s, %ld): stub\n",
284 hProcess, hModule, debugstr_a(lpBaseName), nSize
287 if(lpBaseName && nSize)
288 lpBaseName[0] = '\0';
293 /***********************************************************************
294 * GetModuleBaseNameW (PSAPI.@)
296 DWORD WINAPI GetModuleBaseNameW(
297 HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
299 FIXME("(hProcess=0x%08x, hModule=0x%08x, %s, %ld): stub\n",
300 hProcess, hModule, debugstr_w(lpBaseName), nSize);
302 if(lpBaseName && nSize)
303 lpBaseName[0] = '\0';
308 /***********************************************************************
309 * GetModuleFileNameExA (PSAPI.@)
311 DWORD WINAPI GetModuleFileNameExA(
312 HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize)
314 FIXME("(hProcess=0x%08x,hModule=0x%08x, %s, %ld): stub\n",
315 hProcess, hModule, debugstr_a(lpFilename), nSize
318 if ( get_pid_from_process_handle(hProcess) == GetCurrentProcessId() )
319 return GetModuleFileNameA( hModule, lpFilename, nSize );
321 if(lpFilename&&nSize)
327 /***********************************************************************
328 * GetModuleFileNameExW (PSAPI.@)
330 DWORD WINAPI GetModuleFileNameExW(
331 HANDLE hProcess, HMODULE hModule, LPWSTR lpFilename, DWORD nSize)
333 FIXME("(hProcess=0x%08x,hModule=0x%08x, %s, %ld): stub\n",
334 hProcess, hModule, debugstr_w(lpFilename), nSize
337 if ( get_pid_from_process_handle(hProcess) == GetCurrentProcessId() )
338 return GetModuleFileNameW( hModule, lpFilename, nSize );
340 if(lpFilename && nSize)
341 lpFilename[0] = '\0';
346 /***********************************************************************
347 * GetModuleInformation (PSAPI.@)
349 BOOL WINAPI GetModuleInformation(
350 HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb)
352 FIXME("(hProcess=0x%08x, hModule=0x%08x, %p, %ld): stub\n",
353 hProcess, hModule, lpmodinfo, cb
356 memset(lpmodinfo, 0, cb);
361 /***********************************************************************
362 * GetProcessMemoryInfo (PSAPI.@)
364 BOOL WINAPI GetProcessMemoryInfo(
365 HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb)
367 FIXME("(hProcess=0x%08x, %p, %ld): stub\n",
368 Process, ppsmemCounters, cb
371 memset(ppsmemCounters, 0, cb);
376 /***********************************************************************
377 * GetWsChanges (PSAPI.@)
379 BOOL WINAPI GetWsChanges(
380 HANDLE hProcess, PPSAPI_WS_WATCH_INFORMATION lpWatchInfo, DWORD cb)
382 FIXME("(hProcess=0x%08x, %p, %ld): stub\n",
383 hProcess, lpWatchInfo, cb
386 memset(lpWatchInfo, 0, cb);
391 /***********************************************************************
392 * InitializeProcessForWsWatch (PSAPI.@)
394 BOOL WINAPI InitializeProcessForWsWatch(HANDLE hProcess)
396 FIXME("(hProcess=0x%08x): stub\n", hProcess);
401 /***********************************************************************
402 * QueryWorkingSet (PSAPI.?)
404 * I haven't been able to find the ordinal for this function,
405 * This means it can't be called from outside the DLL.
407 BOOL WINAPI QueryWorkingSet(HANDLE hProcess, LPVOID pv, DWORD cb)
409 FIXME("(hProcess=0x%08x, %p, %ld)\n", hProcess, pv, cb);
412 ((DWORD *) pv)[0] = 0; /* Empty WorkingSet */