[KERNEL] Implement 'W' variants of Process32First / Next
Lionel Ulmer
lionel.ulmer at free.fr
Sun Feb 20 04:04:44 CST 2005
Changelog:
Implement 'W' variants of Process32First / Next APIs
--
Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/kernel/kernel32.spec
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel32.spec,v
retrieving revision 1.142
diff -u -r1.142 kernel32.spec
--- dlls/kernel/kernel32.spec 31 Jan 2005 16:23:31 -0000 1.142
+++ dlls/kernel/kernel32.spec 20 Feb 2005 10:01:37 -0000
@@ -661,9 +661,9 @@
@ stdcall PrepareTape(ptr long long)
@ stub PrivMoveFileIdentityW
@ stdcall Process32First (ptr ptr)
-@ stub Process32FirstW
+@ stdcall Process32FirstW (ptr ptr)
@ stdcall Process32Next (ptr ptr)
-@ stub Process32NextW
+@ stdcall Process32NextW (ptr ptr)
@ stdcall PulseEvent(long)
@ stdcall PurgeComm(long long)
@ stdcall -register -i386 QT_Thunk()
Index: dlls/kernel/toolhelp.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/toolhelp.c,v
retrieving revision 1.25
diff -u -r1.25 toolhelp.c
--- dlls/kernel/toolhelp.c 24 May 2004 19:06:32 -0000 1.25
+++ dlls/kernel/toolhelp.c 20 Feb 2005 10:01:37 -0000
@@ -295,19 +295,33 @@
/***********************************************************************
* TOOLHELP_Process32Next
*
- * Implementation of Process32First/Next
+ * Implementation of Process32First/Next. Note that the ANSI / Unicode
+ * version check is a bit of a hack as it relies on the fact that only
+ * the last field is actually different.
*/
-static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL first )
+static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32W lppe, BOOL first, BOOL unicode )
{
BOOL ret;
WCHAR exe[MAX_PATH];
DWORD len;
- if (lppe->dwSize < sizeof(PROCESSENTRY32))
+ if (unicode)
{
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
- ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize);
- return FALSE;
+ if (lppe->dwSize < sizeof(PROCESSENTRY32W))
+ {
+ SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32W), lppe->dwSize);
+ return FALSE;
+ }
+ }
+ else
+ {
+ if (lppe->dwSize < sizeof(PROCESSENTRY32))
+ {
+ SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize);
+ return FALSE;
+ }
}
SERVER_START_REQ( next_process )
{
@@ -324,9 +338,18 @@
lppe->th32ParentProcessID = reply->ppid;
lppe->pcPriClassBase = reply->priority;
lppe->dwFlags = -1; /* FIXME */
- len = WideCharToMultiByte( CP_ACP, 0, exe, wine_server_reply_size(reply) / sizeof(WCHAR),
- lppe->szExeFile, sizeof(lppe->szExeFile), NULL, NULL );
- lppe->szExeFile[len] = 0;
+ if (unicode)
+ {
+ memcpy(lppe->szExeFile, reply, (wine_server_reply_size(reply) + sizeof(WCHAR)));
+ }
+ else
+ {
+ LPPROCESSENTRY32 lppe_a = (LPPROCESSENTRY32) lppe;
+
+ len = WideCharToMultiByte( CP_ACP, 0, exe, wine_server_reply_size(reply) / sizeof(WCHAR),
+ lppe_a->szExeFile, sizeof(lppe_a->szExeFile), NULL, NULL );
+ lppe_a->szExeFile[len] = 0;
+ }
}
}
SERVER_END_REQ;
@@ -341,7 +364,7 @@
*/
BOOL WINAPI Process32First(HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
{
- return TOOLHELP_Process32Next( hSnapshot, lppe, TRUE );
+ return TOOLHELP_Process32Next( hSnapshot, (LPPROCESSENTRY32W) lppe, TRUE, FALSE /* ANSI */ );
}
/***********************************************************************
@@ -351,7 +374,27 @@
*/
BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
{
- return TOOLHELP_Process32Next( hSnapshot, lppe, FALSE );
+ return TOOLHELP_Process32Next( hSnapshot, (LPPROCESSENTRY32W) lppe, FALSE, FALSE /* ANSI */ );
+}
+
+/***********************************************************************
+ * Process32FirstW (KERNEL32.@)
+ *
+ * Return info about the first process in a toolhelp32 snapshot
+ */
+BOOL WINAPI Process32FirstW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe)
+{
+ return TOOLHELP_Process32Next( hSnapshot, lppe, TRUE, TRUE /* Unicode */ );
+}
+
+/***********************************************************************
+ * Process32NextW (KERNEL32.@)
+ *
+ * Return info about the "next" process in a toolhelp32 snapshot
+ */
+BOOL WINAPI Process32NextW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe)
+{
+ return TOOLHELP_Process32Next( hSnapshot, lppe, FALSE, TRUE /* Unicode */ );
}
More information about the wine-patches
mailing list