2 * Misc Toolhelp functions
4 * Copyright 1996 Marcus Meissner
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "wine/winbase16.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(toolhelp);
41 /* FIXME: to make this work, we have to call back all these registered
42 * functions from all over the WINE code. Someone with more knowledge than
43 * me please do that. -Marcus
49 FARPROC16 lpfnCallback;
53 static int nrofnotifys = 0;
55 static FARPROC16 HookNotify = NULL;
58 /***********************************************************************
59 * TaskFindHandle (TOOLHELP.65)
61 BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask )
64 return TaskNext16( lpte );
68 /***********************************************************************
69 * NotifyRegister (TOOLHELP.73)
71 BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback,
76 FIXME("(%x,%x,%x), semi-stub.\n",
77 htask, (DWORD)lpfnCallback, wFlags );
78 if (!htask) htask = GetCurrentTask();
79 for (i=0;i<nrofnotifys;i++)
80 if (notifys[i].htask==htask)
84 notifys=HeapAlloc( GetProcessHeap(), 0,
85 sizeof(struct notify) );
87 notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
88 sizeof(struct notify)*(nrofnotifys+1));
89 if (!notifys) return FALSE;
92 notifys[i].htask=htask;
93 notifys[i].lpfnCallback=lpfnCallback;
94 notifys[i].wFlags=wFlags;
98 /***********************************************************************
99 * NotifyUnregister (TOOLHELP.74)
101 BOOL16 WINAPI NotifyUnregister16( HTASK16 htask )
105 FIXME("(%x), semi-stub.\n", htask );
106 if (!htask) htask = GetCurrentTask();
107 for (i=nrofnotifys;i--;)
108 if (notifys[i].htask==htask)
112 memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
113 notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
114 (nrofnotifys-1)*sizeof(struct notify));
119 /***********************************************************************
120 * StackTraceCSIPFirst (TOOLHELP.67)
122 BOOL16 WINAPI StackTraceCSIPFirst16(STACKTRACEENTRY *ste, WORD wSS, WORD wCS, WORD wIP, WORD wBP)
124 FIXME("(%p, ss %04x, cs %04x, ip %04x, bp %04x): stub.\n", ste, wSS, wCS, wIP, wBP);
128 /***********************************************************************
129 * StackTraceFirst (TOOLHELP.66)
131 BOOL16 WINAPI StackTraceFirst16(STACKTRACEENTRY *ste, HTASK16 Task)
133 FIXME("(%p, %04x), stub.\n", ste, Task);
137 /***********************************************************************
138 * StackTraceNext (TOOLHELP.68)
140 BOOL16 WINAPI StackTraceNext16(STACKTRACEENTRY *ste)
142 FIXME("(%p), stub.\n", ste);
146 /***********************************************************************
147 * InterruptRegister (TOOLHELP.75)
149 BOOL16 WINAPI InterruptRegister16( HTASK16 task, FARPROC callback )
151 FIXME("(%04x, %p), stub.\n", task, callback);
155 /***********************************************************************
156 * InterruptUnRegister (TOOLHELP.76)
158 BOOL16 WINAPI InterruptUnRegister16( HTASK16 task )
160 FIXME("(%04x), stub.\n", task);
164 /***********************************************************************
165 * TimerCount (TOOLHELP.80)
167 BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo )
170 * In standard mode, dwmsSinceStart = dwmsThisVM
172 * I tested this, under Windows in enhanced mode, and
173 * if you never switch VM (ie start/stop DOS) these
174 * values should be the same as well.
176 * Also, Wine should adjust for the hardware timer
177 * to reduce the amount of error to ~1ms.
178 * I can't be bothered, can you?
180 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
184 /***********************************************************************
185 * SystemHeapInfo (TOOLHELP.71)
187 BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo )
189 STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
190 HANDLE16 oldDS = stack16->ds;
191 WORD user = LoadLibrary16( "USER.EXE" );
192 WORD gdi = LoadLibrary16( "GDI.EXE" );
194 pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
196 pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
198 pHeapInfo->hUserSegment = user;
199 pHeapInfo->hGDISegment = gdi;
200 FreeLibrary16( user );
201 FreeLibrary16( gdi );
206 /***********************************************************************
207 * ToolHelpHook (KERNEL.341)
208 * see "Undocumented Windows"
210 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler)
214 FIXME("(%p), stub.\n", lpfnNotifyHandler);
216 HookNotify = lpfnNotifyHandler;
217 /* just return previously installed notification function */