/* * 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 "winternl.h" #include "winerror.h" #include "wine/winbase16.h" #include "toolhelp.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; /*********************************************************************** * TaskFindHandle (TOOLHELP.65) */ BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask ) { lpte->hNext = hTask; return TaskNext16( lpte ); } /*********************************************************************** * 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; }