Fix warnings in 64bit.
[wine/multimedia.git] / dlls / kernel / toolhelp16.c
blob23b206a8e555efeddb8721cb8068172c55d8dbcf
1 /*
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #include <ctype.h>
30 #include <assert.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wine/winbase16.h"
34 #include "winerror.h"
35 #include "toolhelp.h"
36 #include "wine/server.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
46 static struct notify
48 HTASK16 htask;
49 FARPROC16 lpfnCallback;
50 WORD wFlags;
51 } *notifys = NULL;
53 static int nrofnotifys = 0;
55 static FARPROC16 HookNotify = NULL;
58 /***********************************************************************
59 * TaskFindHandle (TOOLHELP.65)
61 BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask )
63 lpte->hNext = hTask;
64 return TaskNext16( lpte );
68 /***********************************************************************
69 * NotifyRegister (TOOLHELP.73)
71 BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback,
72 WORD wFlags )
74 int i;
76 FIXME("(%x,%lx,%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)
81 break;
82 if (i==nrofnotifys) {
83 if (notifys==NULL)
84 notifys=HeapAlloc( GetProcessHeap(), 0,
85 sizeof(struct notify) );
86 else
87 notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
88 sizeof(struct notify)*(nrofnotifys+1));
89 if (!notifys) return FALSE;
90 nrofnotifys++;
92 notifys[i].htask=htask;
93 notifys[i].lpfnCallback=lpfnCallback;
94 notifys[i].wFlags=wFlags;
95 return TRUE;
98 /***********************************************************************
99 * NotifyUnregister (TOOLHELP.74)
101 BOOL16 WINAPI NotifyUnregister16( HTASK16 htask )
103 int i;
105 FIXME("(%x), semi-stub.\n", htask );
106 if (!htask) htask = GetCurrentTask();
107 for (i=nrofnotifys;i--;)
108 if (notifys[i].htask==htask)
109 break;
110 if (i==-1)
111 return FALSE;
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));
115 nrofnotifys--;
116 return TRUE;
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);
125 return TRUE;
128 /***********************************************************************
129 * StackTraceFirst (TOOLHELP.66)
131 BOOL16 WINAPI StackTraceFirst16(STACKTRACEENTRY *ste, HTASK16 Task)
133 FIXME("(%p, %04x), stub.\n", ste, Task);
134 return TRUE;
137 /***********************************************************************
138 * StackTraceNext (TOOLHELP.68)
140 BOOL16 WINAPI StackTraceNext16(STACKTRACEENTRY *ste)
142 FIXME("(%p), stub.\n", ste);
143 return TRUE;
146 /***********************************************************************
147 * InterruptRegister (TOOLHELP.75)
149 BOOL16 WINAPI InterruptRegister16( HTASK16 task, FARPROC callback )
151 FIXME("(%04x, %p), stub.\n", task, callback);
152 return TRUE;
155 /***********************************************************************
156 * InterruptUnRegister (TOOLHELP.76)
158 BOOL16 WINAPI InterruptUnRegister16( HTASK16 task )
160 FIXME("(%04x), stub.\n", task);
161 return TRUE;
164 /***********************************************************************
165 * TimerCount (TOOLHELP.80)
167 BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo )
169 /* FIXME
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();
181 return TRUE;
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" );
193 stack16->ds = user;
194 pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
195 stack16->ds = gdi;
196 pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
197 stack16->ds = oldDS;
198 pHeapInfo->hUserSegment = user;
199 pHeapInfo->hGDISegment = gdi;
200 FreeLibrary16( user );
201 FreeLibrary16( gdi );
202 return TRUE;
206 /***********************************************************************
207 * ToolHelpHook (KERNEL.341)
208 * see "Undocumented Windows"
210 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler)
212 FARPROC16 tmp;
214 FIXME("(%p), stub.\n", lpfnNotifyHandler);
215 tmp = HookNotify;
216 HookNotify = lpfnNotifyHandler;
217 /* just return previously installed notification function */
218 return tmp;