wined3d: Remove fake nvidia card in GetAdapterIdentifier.
[wine/dibdrv.git] / dlls / kernel32 / toolhelp16.c
blobfdb611f55b91efc53392856536675a1326d42ebf
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 "winternl.h"
34 #include "winerror.h"
36 #include "wine/winbase16.h"
37 #include "toolhelp.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(toolhelp);
42 /* FIXME: to make this work, we have to call back all these registered
43 * functions from all over the WINE code. Someone with more knowledge than
44 * me please do that. -Marcus
47 static struct notify
49 HTASK16 htask;
50 FARPROC16 lpfnCallback;
51 WORD wFlags;
52 } *notifys = NULL;
54 static int nrofnotifys = 0;
56 static FARPROC16 HookNotify = NULL;
59 /***********************************************************************
60 * TaskFindHandle (TOOLHELP.65)
62 BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask )
64 lpte->hNext = hTask;
65 return TaskNext16( lpte );
69 /***********************************************************************
70 * NotifyRegister (TOOLHELP.73)
72 BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback,
73 WORD wFlags )
75 int i;
77 FIXME("(%x,%x,%x), semi-stub.\n",
78 htask, (DWORD)lpfnCallback, wFlags );
79 if (!htask) htask = GetCurrentTask();
80 for (i=0;i<nrofnotifys;i++)
81 if (notifys[i].htask==htask)
82 break;
83 if (i==nrofnotifys) {
84 if (notifys==NULL)
85 notifys=HeapAlloc( GetProcessHeap(), 0,
86 sizeof(struct notify) );
87 else
88 notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
89 sizeof(struct notify)*(nrofnotifys+1));
90 if (!notifys) return FALSE;
91 nrofnotifys++;
93 notifys[i].htask=htask;
94 notifys[i].lpfnCallback=lpfnCallback;
95 notifys[i].wFlags=wFlags;
96 return TRUE;
99 /***********************************************************************
100 * NotifyUnregister (TOOLHELP.74)
102 BOOL16 WINAPI NotifyUnregister16( HTASK16 htask )
104 int i;
106 FIXME("(%x), semi-stub.\n", htask );
107 if (!htask) htask = GetCurrentTask();
108 for (i=nrofnotifys;i--;)
109 if (notifys[i].htask==htask)
110 break;
111 if (i==-1)
112 return FALSE;
113 memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
114 notifys=HeapReAlloc( GetProcessHeap(), 0, notifys,
115 (nrofnotifys-1)*sizeof(struct notify));
116 nrofnotifys--;
117 return TRUE;
120 /***********************************************************************
121 * StackTraceCSIPFirst (TOOLHELP.67)
123 BOOL16 WINAPI StackTraceCSIPFirst16(STACKTRACEENTRY *ste, WORD wSS, WORD wCS, WORD wIP, WORD wBP)
125 FIXME("(%p, ss %04x, cs %04x, ip %04x, bp %04x): stub.\n", ste, wSS, wCS, wIP, wBP);
126 return TRUE;
129 /***********************************************************************
130 * StackTraceFirst (TOOLHELP.66)
132 BOOL16 WINAPI StackTraceFirst16(STACKTRACEENTRY *ste, HTASK16 Task)
134 FIXME("(%p, %04x), stub.\n", ste, Task);
135 return TRUE;
138 /***********************************************************************
139 * StackTraceNext (TOOLHELP.68)
141 BOOL16 WINAPI StackTraceNext16(STACKTRACEENTRY *ste)
143 FIXME("(%p), stub.\n", ste);
144 return TRUE;
147 /***********************************************************************
148 * InterruptRegister (TOOLHELP.75)
150 BOOL16 WINAPI InterruptRegister16( HTASK16 task, FARPROC callback )
152 FIXME("(%04x, %p), stub.\n", task, callback);
153 return TRUE;
156 /***********************************************************************
157 * InterruptUnRegister (TOOLHELP.76)
159 BOOL16 WINAPI InterruptUnRegister16( HTASK16 task )
161 FIXME("(%04x), stub.\n", task);
162 return TRUE;
165 /***********************************************************************
166 * TimerCount (TOOLHELP.80)
168 BOOL16 WINAPI TimerCount16( TIMERINFO *pTimerInfo )
170 /* FIXME
171 * In standard mode, dwmsSinceStart = dwmsThisVM
173 * I tested this, under Windows in enhanced mode, and
174 * if you never switch VM (ie start/stop DOS) these
175 * values should be the same as well.
177 * Also, Wine should adjust for the hardware timer
178 * to reduce the amount of error to ~1ms.
179 * I can't be bothered, can you?
181 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
182 return TRUE;
185 /***********************************************************************
186 * SystemHeapInfo (TOOLHELP.71)
188 BOOL16 WINAPI SystemHeapInfo16( SYSHEAPINFO *pHeapInfo )
190 STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
191 HANDLE16 oldDS = stack16->ds;
192 WORD user = LoadLibrary16( "USER.EXE" );
193 WORD gdi = LoadLibrary16( "GDI.EXE" );
194 stack16->ds = user;
195 pHeapInfo->wUserFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
196 stack16->ds = gdi;
197 pHeapInfo->wGDIFreePercent = (int)LocalCountFree16() * 100 / LocalHeapSize16();
198 stack16->ds = oldDS;
199 pHeapInfo->hUserSegment = user;
200 pHeapInfo->hGDISegment = gdi;
201 FreeLibrary16( user );
202 FreeLibrary16( gdi );
203 return TRUE;
207 /***********************************************************************
208 * ToolHelpHook (KERNEL.341)
209 * see "Undocumented Windows"
211 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler)
213 FARPROC16 tmp;
215 FIXME("(%p), stub.\n", lpfnNotifyHandler);
216 tmp = HookNotify;
217 HookNotify = lpfnNotifyHandler;
218 /* just return previously installed notification function */
219 return tmp;