From c2b4bbef4f246f4fe52bd8f48613b4e20bd6aa53 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Tue, 24 May 2005 10:12:06 +0000 Subject: [PATCH] Split Win16 and Win32 toolhelp functions. Compile out win87em and 16bit toolhelp functions if 16 bit support is disabled. --- dlls/kernel/Makefile.in | 5 +- dlls/kernel/toolhelp.c | 171 -------------------------------- dlls/kernel/toolhelp16.c | 208 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+), 173 deletions(-) create mode 100644 dlls/kernel/toolhelp16.c diff --git a/dlls/kernel/Makefile.in b/dlls/kernel/Makefile.in index 14a52030f93..f35c11dd5a2 100644 --- a/dlls/kernel/Makefile.in +++ b/dlls/kernel/Makefile.in @@ -71,14 +71,15 @@ C_SRCS = \ virtual.c \ volume.c \ vxd.c \ - win87em.c \ windebug.c \ wowthunk.c C_SRCS16 = \ atom16.c \ error16.c \ - registry16.c + registry16.c \ + toolhelp16.c \ + win87em.c ASM_SRCS = relay16asm.s diff --git a/dlls/kernel/toolhelp.c b/dlls/kernel/toolhelp.c index 708aeaa4147..a3b062b3aa3 100644 --- a/dlls/kernel/toolhelp.c +++ b/dlls/kernel/toolhelp.c @@ -30,9 +30,7 @@ #include #include "windef.h" #include "winbase.h" -#include "wine/winbase16.h" #include "winerror.h" -#include "thread.h" #include "tlhelp32.h" #include "toolhelp.h" #include "wine/server.h" @@ -42,175 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(toolhelp); -/* FIXME: to make this work, we have to call back all these registered - * functions from all over the WINE code. Someone with more knowledge than - * me please do that. -Marcus - */ -static struct notify -{ - HTASK16 htask; - FARPROC16 lpfnCallback; - WORD wFlags; -} *notifys = NULL; - -static int nrofnotifys = 0; - -static FARPROC16 HookNotify = NULL; - -/*********************************************************************** - * NotifyRegister (TOOLHELP.73) - */ -BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback, - WORD wFlags ) -{ - int i; - - FIXME("(%x,%lx,%x), semi-stub.\n", - htask, (DWORD)lpfnCallback, wFlags ); - if (!htask) htask = GetCurrentTask(); - for (i=0;idwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount(); - return TRUE; -} - -/*********************************************************************** - * SystemHeapInfo (TOOLHELP.71) - */ -BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo ) -{ - STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); - HANDLE16 oldDS = stack16->ds; - WORD user = LoadLibrary16( "USER.EXE" ); - WORD gdi = LoadLibrary16( "GDI.EXE" ); - stack16->ds = user; - pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); - stack16->ds = gdi; - pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); - stack16->ds = oldDS; - pHeapInfo->hUserSegment = user; - pHeapInfo->hGDISegment = gdi; - FreeLibrary16( user ); - FreeLibrary16( gdi ); - return TRUE; -} - - -/*********************************************************************** - * ToolHelpHook (KERNEL.341) - * see "Undocumented Windows" - */ -FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler) -{ - FARPROC16 tmp; - - FIXME("(%p), stub.\n", lpfnNotifyHandler); - tmp = HookNotify; - HookNotify = lpfnNotifyHandler; - /* just return previously installed notification function */ - return tmp; -} - - /*********************************************************************** * CreateToolhelp32Snapshot (KERNEL32.@) */ diff --git a/dlls/kernel/toolhelp16.c b/dlls/kernel/toolhelp16.c new file mode 100644 index 00000000000..c29087decd5 --- /dev/null +++ b/dlls/kernel/toolhelp16.c @@ -0,0 +1,208 @@ +/* + * Misc Toolhelp functions + * + * Copyright 1996 Marcus Meissner + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include +#include "windef.h" +#include "winbase.h" +#include "wine/winbase16.h" +#include "winerror.h" +#include "toolhelp.h" +#include "wine/server.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(toolhelp); + +/* FIXME: to make this work, we have to call back all these registered + * functions from all over the WINE code. Someone with more knowledge than + * me please do that. -Marcus + */ + +static struct notify +{ + HTASK16 htask; + FARPROC16 lpfnCallback; + WORD wFlags; +} *notifys = NULL; + +static int nrofnotifys = 0; + +static FARPROC16 HookNotify = NULL; + +/*********************************************************************** + * NotifyRegister (TOOLHELP.73) + */ +BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback, + WORD wFlags ) +{ + int i; + + FIXME("(%x,%lx,%x), semi-stub.\n", + htask, (DWORD)lpfnCallback, wFlags ); + if (!htask) htask = GetCurrentTask(); + for (i=0;idwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount(); + return TRUE; +} + +/*********************************************************************** + * SystemHeapInfo (TOOLHELP.71) + */ +BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo ) +{ + STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved); + HANDLE16 oldDS = stack16->ds; + WORD user = LoadLibrary16( "USER.EXE" ); + WORD gdi = LoadLibrary16( "GDI.EXE" ); + stack16->ds = user; + pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); + stack16->ds = gdi; + pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16(); + stack16->ds = oldDS; + pHeapInfo->hUserSegment = user; + pHeapInfo->hGDISegment = gdi; + FreeLibrary16( user ); + FreeLibrary16( gdi ); + return TRUE; +} + + +/*********************************************************************** + * ToolHelpHook (KERNEL.341) + * see "Undocumented Windows" + */ +FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler) +{ + FARPROC16 tmp; + + FIXME("(%p), stub.\n", lpfnNotifyHandler); + tmp = HookNotify; + HookNotify = lpfnNotifyHandler; + /* just return previously installed notification function */ + return tmp; +}