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
33 #include "wine/winbase16.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
49 FARPROC16 lpfnCallback
;
53 static int nrofnotifys
= 0;
55 static FARPROC16 HookNotify
= NULL
;
57 /***********************************************************************
58 * NotifyRegister (TOOLHELP.73)
60 BOOL16 WINAPI
NotifyRegister16( HTASK16 htask
, FARPROC16 lpfnCallback
,
65 FIXME("(%x,%lx,%x), semi-stub.\n",
66 htask
, (DWORD
)lpfnCallback
, wFlags
);
67 if (!htask
) htask
= GetCurrentTask();
68 for (i
=0;i
<nrofnotifys
;i
++)
69 if (notifys
[i
].htask
==htask
)
73 notifys
=HeapAlloc( GetProcessHeap(), 0,
74 sizeof(struct notify
) );
76 notifys
=HeapReAlloc( GetProcessHeap(), 0, notifys
,
77 sizeof(struct notify
)*(nrofnotifys
+1));
78 if (!notifys
) return FALSE
;
81 notifys
[i
].htask
=htask
;
82 notifys
[i
].lpfnCallback
=lpfnCallback
;
83 notifys
[i
].wFlags
=wFlags
;
87 /***********************************************************************
88 * NotifyUnregister (TOOLHELP.74)
90 BOOL16 WINAPI
NotifyUnregister16( HTASK16 htask
)
94 FIXME("(%x), semi-stub.\n", htask
);
95 if (!htask
) htask
= GetCurrentTask();
96 for (i
=nrofnotifys
;i
--;)
97 if (notifys
[i
].htask
==htask
)
101 memcpy(notifys
+i
,notifys
+(i
+1),sizeof(struct notify
)*(nrofnotifys
-i
-1));
102 notifys
=HeapReAlloc( GetProcessHeap(), 0, notifys
,
103 (nrofnotifys
-1)*sizeof(struct notify
));
108 /***********************************************************************
109 * StackTraceCSIPFirst (TOOLHELP.67)
111 BOOL16 WINAPI
StackTraceCSIPFirst16(STACKTRACEENTRY
*ste
, WORD wSS
, WORD wCS
, WORD wIP
, WORD wBP
)
113 FIXME("(%p, ss %04x, cs %04x, ip %04x, bp %04x): stub.\n", ste
, wSS
, wCS
, wIP
, wBP
);
117 /***********************************************************************
118 * StackTraceFirst (TOOLHELP.66)
120 BOOL16 WINAPI
StackTraceFirst16(STACKTRACEENTRY
*ste
, HTASK16 Task
)
122 FIXME("(%p, %04x), stub.\n", ste
, Task
);
126 /***********************************************************************
127 * StackTraceNext (TOOLHELP.68)
129 BOOL16 WINAPI
StackTraceNext16(STACKTRACEENTRY
*ste
)
131 FIXME("(%p), stub.\n", ste
);
135 /***********************************************************************
136 * InterruptRegister (TOOLHELP.75)
138 BOOL16 WINAPI
InterruptRegister16( HTASK16 task
, FARPROC callback
)
140 FIXME("(%04x, %p), stub.\n", task
, callback
);
144 /***********************************************************************
145 * InterruptUnRegister (TOOLHELP.76)
147 BOOL16 WINAPI
InterruptUnRegister16( HTASK16 task
)
149 FIXME("(%04x), stub.\n", task
);
153 /***********************************************************************
154 * TimerCount (TOOLHELP.80)
156 BOOL16 WINAPI
TimerCount16( TIMERINFO
*pTimerInfo
)
159 * In standard mode, dwmsSinceStart = dwmsThisVM
161 * I tested this, under Windows in enhanced mode, and
162 * if you never switch VM (ie start/stop DOS) these
163 * values should be the same as well.
165 * Also, Wine should adjust for the hardware timer
166 * to reduce the amount of error to ~1ms.
167 * I can't be bothered, can you?
169 pTimerInfo
->dwmsSinceStart
= pTimerInfo
->dwmsThisVM
= GetTickCount();
173 /***********************************************************************
174 * SystemHeapInfo (TOOLHELP.71)
176 BOOL16 WINAPI
SystemHeapInfo16( SYSHEAPINFO
*pHeapInfo
)
178 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
179 HANDLE16 oldDS
= stack16
->ds
;
180 WORD user
= LoadLibrary16( "USER.EXE" );
181 WORD gdi
= LoadLibrary16( "GDI.EXE" );
183 pHeapInfo
->wUserFreePercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
185 pHeapInfo
->wGDIFreePercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
187 pHeapInfo
->hUserSegment
= user
;
188 pHeapInfo
->hGDISegment
= gdi
;
189 FreeLibrary16( user
);
190 FreeLibrary16( gdi
);
195 /***********************************************************************
196 * ToolHelpHook (KERNEL.341)
197 * see "Undocumented Windows"
199 FARPROC16 WINAPI
ToolHelpHook16(FARPROC16 lpfnNotifyHandler
)
203 FIXME("(%p), stub.\n", lpfnNotifyHandler
);
205 HookNotify
= lpfnNotifyHandler
;
206 /* just return previously installed notification function */