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
36 #include "wine/winbase16.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
50 FARPROC16 lpfnCallback
;
54 static int nrofnotifys
= 0;
56 static FARPROC16 HookNotify
= NULL
;
59 /***********************************************************************
60 * TaskFindHandle (TOOLHELP.65)
62 BOOL16 WINAPI
TaskFindHandle16( TASKENTRY
*lpte
, HTASK16 hTask
)
65 return TaskNext16( lpte
);
69 /***********************************************************************
70 * NotifyRegister (TOOLHELP.73)
72 BOOL16 WINAPI
NotifyRegister16( HTASK16 htask
, FARPROC16 lpfnCallback
,
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
)
85 notifys
=HeapAlloc( GetProcessHeap(), 0,
86 sizeof(struct notify
) );
88 notifys
=HeapReAlloc( GetProcessHeap(), 0, notifys
,
89 sizeof(struct notify
)*(nrofnotifys
+1));
90 if (!notifys
) return FALSE
;
93 notifys
[i
].htask
=htask
;
94 notifys
[i
].lpfnCallback
=lpfnCallback
;
95 notifys
[i
].wFlags
=wFlags
;
99 /***********************************************************************
100 * NotifyUnregister (TOOLHELP.74)
102 BOOL16 WINAPI
NotifyUnregister16( HTASK16 htask
)
106 FIXME("(%x), semi-stub.\n", htask
);
107 if (!htask
) htask
= GetCurrentTask();
108 for (i
=nrofnotifys
;i
--;)
109 if (notifys
[i
].htask
==htask
)
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
));
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
);
129 /***********************************************************************
130 * StackTraceFirst (TOOLHELP.66)
132 BOOL16 WINAPI
StackTraceFirst16(STACKTRACEENTRY
*ste
, HTASK16 Task
)
134 FIXME("(%p, %04x), stub.\n", ste
, Task
);
138 /***********************************************************************
139 * StackTraceNext (TOOLHELP.68)
141 BOOL16 WINAPI
StackTraceNext16(STACKTRACEENTRY
*ste
)
143 FIXME("(%p), stub.\n", ste
);
147 /***********************************************************************
148 * InterruptRegister (TOOLHELP.75)
150 BOOL16 WINAPI
InterruptRegister16( HTASK16 task
, FARPROC callback
)
152 FIXME("(%04x, %p), stub.\n", task
, callback
);
156 /***********************************************************************
157 * InterruptUnRegister (TOOLHELP.76)
159 BOOL16 WINAPI
InterruptUnRegister16( HTASK16 task
)
161 FIXME("(%04x), stub.\n", task
);
165 /***********************************************************************
166 * TimerCount (TOOLHELP.80)
168 BOOL16 WINAPI
TimerCount16( TIMERINFO
*pTimerInfo
)
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();
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" );
195 pHeapInfo
->wUserFreePercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
197 pHeapInfo
->wGDIFreePercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
199 pHeapInfo
->hUserSegment
= user
;
200 pHeapInfo
->hGDISegment
= gdi
;
201 FreeLibrary16( user
);
202 FreeLibrary16( gdi
);
207 /***********************************************************************
208 * ToolHelpHook (KERNEL.341)
209 * see "Undocumented Windows"
211 FARPROC16 WINAPI
ToolHelpHook16(FARPROC16 lpfnNotifyHandler
)
215 FIXME("(%p), stub.\n", lpfnNotifyHandler
);
217 HookNotify
= lpfnNotifyHandler
;
218 /* just return previously installed notification function */