Added support for WAVE_FORMAT_QUERY flag in wodOpen.
[wine/multimedia.git] / misc / toolhelp.c
blobc480224d47676e930c9323945dee562fdbcf40b3
1 /*
2 * Misc Toolhelp functions
4 * Copyright 1996 Marcus Meissner
5 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <ctype.h>
11 #include <assert.h>
12 #include "winbase.h"
13 #include "wine/winbase16.h"
14 #include "winerror.h"
15 #include "process.h"
16 #include "tlhelp32.h"
17 #include "toolhelp.h"
18 #include "heap.h"
19 #include "server.h"
20 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(toolhelp)
25 /* FIXME: to make this working, we have to callback all these registered
26 * functions from all over the WINE code. Someone with more knowledge than
27 * me please do that. -Marcus
29 static struct notify
31 HTASK16 htask;
32 FARPROC16 lpfnCallback;
33 WORD wFlags;
34 } *notifys = NULL;
36 static int nrofnotifys = 0;
38 static FARPROC16 HookNotify = NULL;
40 BOOL16 WINAPI NotifyRegister16( HTASK16 htask, FARPROC16 lpfnCallback,
41 WORD wFlags )
43 int i;
45 TRACE("(%x,%lx,%x) called.\n",
46 htask, (DWORD)lpfnCallback, wFlags );
47 if (!htask) htask = GetCurrentTask();
48 for (i=0;i<nrofnotifys;i++)
49 if (notifys[i].htask==htask)
50 break;
51 if (i==nrofnotifys) {
52 if (notifys==NULL)
53 notifys=(struct notify*)HeapAlloc( SystemHeap, 0,
54 sizeof(struct notify) );
55 else
56 notifys=(struct notify*)HeapReAlloc( SystemHeap, 0, notifys,
57 sizeof(struct notify)*(nrofnotifys+1));
58 if (!notifys) return FALSE;
59 nrofnotifys++;
61 notifys[i].htask=htask;
62 notifys[i].lpfnCallback=lpfnCallback;
63 notifys[i].wFlags=wFlags;
64 return TRUE;
67 BOOL16 WINAPI NotifyUnregister16( HTASK16 htask )
69 int i;
71 TRACE("(%x) called.\n", htask );
72 if (!htask) htask = GetCurrentTask();
73 for (i=nrofnotifys;i--;)
74 if (notifys[i].htask==htask)
75 break;
76 if (i==-1)
77 return FALSE;
78 memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
79 notifys=(struct notify*)HeapReAlloc( SystemHeap, 0, notifys,
80 (nrofnotifys-1)*sizeof(struct notify));
81 nrofnotifys--;
82 return TRUE;
85 BOOL16 WINAPI StackTraceCSIPFirst16(STACKTRACEENTRY *ste, WORD wSS, WORD wCS, WORD wIP, WORD wBP)
87 return TRUE;
90 BOOL16 WINAPI StackTraceFirst16(STACKTRACEENTRY *ste, HTASK16 Task)
92 return TRUE;
95 BOOL16 WINAPI StackTraceNext16(STACKTRACEENTRY *ste)
97 return TRUE;
100 BOOL16 WINAPI InterruptRegister16( HTASK16 task, FARPROC callback )
102 return TRUE;
105 BOOL16 WINAPI InterruptUnRegister16( HTASK16 task )
107 return TRUE;
110 /***********************************************************************
111 * ToolHelpHook (KERNEL.341)
112 * see "Undocumented Windows"
114 FARPROC16 WINAPI ToolHelpHook16(FARPROC16 lpfnNotifyHandler)
116 FARPROC16 tmp;
117 tmp = HookNotify;
118 HookNotify = lpfnNotifyHandler;
119 /* just return previously installed notification function */
120 return tmp;
124 /***********************************************************************
125 * CreateToolHelp32Snapshot (KERNEL32.179)
127 HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
129 struct create_snapshot_request *req = get_req_buffer();
131 TRACE("%lx,%lx\n", flags, process );
132 if (flags & (TH32CS_SNAPHEAPLIST|TH32CS_SNAPMODULE|TH32CS_SNAPTHREAD))
133 FIXME("flags %lx not implemented\n", flags );
134 if (!(flags & TH32CS_SNAPPROCESS))
136 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
137 return INVALID_HANDLE_VALUE;
140 /* Now do the snapshot */
141 req->flags = flags & ~TH32CS_INHERIT;
142 req->inherit = (flags & TH32CS_INHERIT) != 0;
143 server_call( REQ_CREATE_SNAPSHOT );
144 return req->handle;
148 /***********************************************************************
149 * TOOLHELP_Process32Next
151 * Implementation of Process32First/Next
153 static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY lppe, BOOL first )
155 struct next_process_request *req = get_req_buffer();
157 if (lppe->dwSize < sizeof (PROCESSENTRY))
159 SetLastError( ERROR_INSUFFICIENT_BUFFER );
160 ERR("Result buffer too small\n");
161 return FALSE;
163 req->handle = handle;
164 req->reset = first;
165 if (server_call( REQ_NEXT_PROCESS )) return FALSE;
166 lppe->cntUsage = 1;
167 lppe->th32ProcessID = (DWORD)req->pid;
168 lppe->th32DefaultHeapID = 0; /* FIXME */
169 lppe->th32ModuleID = 0; /* FIXME */
170 lppe->cntThreads = req->threads;
171 lppe->th32ParentProcessID = 0; /* FIXME */
172 lppe->pcPriClassBase = req->priority;
173 lppe->dwFlags = -1; /* FIXME */
174 lppe->szExeFile[0] = 0; /* FIXME */
175 return TRUE;
179 /***********************************************************************
180 * Process32First (KERNEL32.555)
182 * Return info about the first process in a toolhelp32 snapshot
184 BOOL WINAPI Process32First(HANDLE hSnapshot, LPPROCESSENTRY lppe)
186 return TOOLHELP_Process32Next( hSnapshot, lppe, TRUE );
189 /***********************************************************************
190 * Process32Next (KERNEL32.556)
192 * Return info about the "next" process in a toolhelp32 snapshot
194 BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY lppe)
196 return TOOLHELP_Process32Next( hSnapshot, lppe, FALSE );
199 /***********************************************************************
200 * Module32First (KERNEL32.527)
202 * Return info about the "first" module in a toolhelp32 snapshot
204 BOOL WINAPI Module32First(HANDLE hSnapshot, LPMODULEENTRY lpme)
206 FIXME("(%d,%p),stub!\n",hSnapshot,lpme);
207 return FALSE;
210 /***********************************************************************
211 * Module32Next (KERNEL32.528)
213 * Return info about the "next" module in a toolhelp32 snapshot
215 BOOL WINAPI Module32Next(HANDLE hSnapshot, LPMODULEENTRY lpme)
217 FIXME("(%d,%p),stub!\n",hSnapshot,lpme);
218 return FALSE;
221 /************************************************************************
222 * GlobalMasterHandle16 (KERNEL.28)
225 * Should return selector and handle of the information structure for
226 * the global heap. selector and handle are stored in the THHOOK as
227 * pGlobalHeap and hGlobalHeap.
228 * As Wine doesn't have this structure, we return both values as zero
229 * Applications should interpret this as "No Global Heap"
231 DWORD WINAPI GlobalMasterHandle16(void)
233 FIXME(": stub\n");
234 return 0;