Release 980215
[wine/multimedia.git] / misc / toolhelp.c
blob2e485aec703c3aa7636272d21209ede45a9fc83d
1 /*
2 * Misc Toolhelp functions
4 * Copyright 1996 Marcus Meissner
5 */
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 #include "windows.h"
13 #include "win.h"
14 #include "toolhelp.h"
15 #include "stddebug.h"
16 #include "debug.h"
17 #include "heap.h"
19 /* FIXME: to make this working, we have to callback all these registered
20 * functions from all over the WINE code. Someone with more knowledge than
21 * me please do that. -Marcus
23 static struct notify
25 HTASK16 htask;
26 FARPROC16 lpfnCallback;
27 WORD wFlags;
28 } *notifys = NULL;
30 static int nrofnotifys = 0;
32 static FARPROC16 HookNotify = NULL;
34 BOOL16 WINAPI NotifyRegister( HTASK16 htask, FARPROC16 lpfnCallback,
35 WORD wFlags )
37 int i;
39 dprintf_toolhelp( stddeb, "NotifyRegister(%x,%lx,%x) called.\n",
40 htask, (DWORD)lpfnCallback, wFlags );
41 if (!htask) htask = GetCurrentTask();
42 for (i=0;i<nrofnotifys;i++)
43 if (notifys[i].htask==htask)
44 break;
45 if (i==nrofnotifys) {
46 if (notifys==NULL)
47 notifys=(struct notify*)HeapAlloc( SystemHeap, 0,
48 sizeof(struct notify) );
49 else
50 notifys=(struct notify*)HeapReAlloc( SystemHeap, 0, notifys,
51 sizeof(struct notify)*(nrofnotifys+1));
52 if (!notifys) return FALSE;
53 nrofnotifys++;
55 notifys[i].htask=htask;
56 notifys[i].lpfnCallback=lpfnCallback;
57 notifys[i].wFlags=wFlags;
58 return TRUE;
61 BOOL16 WINAPI NotifyUnregister( HTASK16 htask )
63 int i;
65 dprintf_toolhelp( stddeb, "NotifyUnregister(%x) called.\n", htask );
66 if (!htask) htask = GetCurrentTask();
67 for (i=nrofnotifys;i--;)
68 if (notifys[i].htask==htask)
69 break;
70 if (i==-1)
71 return FALSE;
72 memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
73 notifys=(struct notify*)HeapReAlloc( SystemHeap, 0, notifys,
74 (nrofnotifys-1)*sizeof(struct notify));
75 nrofnotifys--;
76 return TRUE;
79 BOOL16 WINAPI StackTraceCSIPFirst(STACKTRACEENTRY *ste, WORD wSS, WORD wCS, WORD wIP, WORD wBP)
81 return TRUE;
84 BOOL16 WINAPI StackTraceFirst(STACKTRACEENTRY *ste, HTASK16 Task)
86 return TRUE;
89 BOOL16 WINAPI StackTraceNext(STACKTRACEENTRY *ste)
91 return TRUE;
94 /***********************************************************************
95 * ToolHelpHook (KERNEL.341)
96 * see "Undocumented Windows"
98 FARPROC16 WINAPI ToolHelpHook(FARPROC16 lpfnNotifyHandler)
100 FARPROC16 tmp;
101 tmp = HookNotify;
102 HookNotify = lpfnNotifyHandler;
103 /* just return previously installed notification function */
104 return tmp;