Release 0.9.14.
[wine/multimedia.git] / dlls / advapi32 / eventlog.c
blobad477d4588ee6966ed69b8e3e2a19609596c85c5
1 /*
2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
5 * Copyright 1998 Juergen Schmied
6 * Copyright 2003 Mike Hearn
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winreg.h"
29 #include "winternl.h"
30 #include "wmistr.h"
31 #include "evntrace.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
36 WINE_DECLARE_DEBUG_CHANNEL(eventlog);
38 /******************************************************************************
39 * BackupEventLogA [ADVAPI32.@]
41 * Saves the event log to a backup file.
43 * PARAMS
44 * hEventLog [I] Handle to event log to backup.
45 * lpBackupFileName [I] Name of the backup file.
47 * RETURNS
48 * Success: nonzero. File lpBackupFileName will contain the contents of
49 * hEvenLog.
50 * Failure: zero.
52 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
54 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
55 return TRUE;
58 /******************************************************************************
59 * BackupEventLogW [ADVAPI32.@]
61 * See BackupEventLogA.
63 BOOL WINAPI BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
65 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
66 return TRUE;
69 /******************************************************************************
70 * ClearEventLogA [ADVAPI32.@]
72 * Clears the event log and/or saves the log to a backup file.
74 * PARAMS
75 * hEvenLog [I] Handle to event log to clear.
76 * lpBackupFileName [I] Name of the backup file.
78 * RETURNS
79 * Success: nonzero. if lpBackupFileName != NULL, lpBackupFileName will
80 * contain the contents of hEvenLog and the log will be cleared.
81 * Failure: zero. Fails if the event log is empty or if lpBackupFileName
82 * exists.
84 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
86 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
87 return TRUE;
90 /******************************************************************************
91 * ClearEventLogW [ADVAPI32.@]
93 * See ClearEventLogA.
95 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
97 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
98 return TRUE;
101 /******************************************************************************
102 * CloseEventLog [ADVAPI32.@]
104 * Closes a read handle to the event log.
106 * PARAMS
107 * hEventLog [I/O] Handle of the event log to close.
109 * RETURNS
110 * Success: nonzero
111 * Failure: zero
113 BOOL WINAPI CloseEventLog( HANDLE hEventLog )
115 FIXME("(%p) stub\n", hEventLog);
116 return TRUE;
119 /******************************************************************************
120 * DeregisterEventSource [ADVAPI32.@]
122 * Closes a write handle to an event log
124 * PARAMS
125 * hEventLog [I/O] Handle of the event log.
127 * RETURNS
128 * Success: nonzero
129 * Failure: zero
131 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
133 FIXME("(%p) stub\n", hEventLog);
134 return TRUE;
137 /******************************************************************************
138 * GetNumberOfEventLogRecords [ADVAPI32.@]
140 * Retrieves the number of records in an event log.
142 * PARAMS
143 * hEventLog [I] Handle to an open event log.
144 * NumberOfRecords [O] Number of records in the log.
146 * RETURNS
147 * Success: nonzero. NumberOfRecords will contain the number of records in
148 * the log.
149 * Failure: zero
151 BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
153 FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords);
155 if (!NumberOfRecords) return FALSE;
156 *NumberOfRecords = 0;
158 return TRUE;
161 /******************************************************************************
162 * GetOldestEventLogRecord [ADVAPI32.@]
164 * Retrieves the absolute record number of the oldest record in an even log.
166 * PARAMS
167 * hEventLog [I] Handle to an open event log.
168 * OldestRecord [O] Absolute record number of the oldest record.
170 * RETURNS
171 * Success: nonzero. OldestRecord contains the record number of the oldest
172 * record in the log.
173 * Failure: zero
175 BOOL WINAPI GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
177 FIXME("(%p,%p) stub\n", hEventLog, OldestRecord);
179 if (!OldestRecord) return FALSE;
180 *OldestRecord = 0;
182 return TRUE;
185 /******************************************************************************
186 * NotifyChangeEventLog [ADVAPI32.@]
188 * Enables an application to receive notification when an event is written
189 * to an event log.
191 * PARAMS
192 * hEventLog [I] Handle to an event log.
193 * hEvent [I] Handle to a manual-reset event object.
195 * RETURNS
196 * Success: nonzero
197 * Failure: zero
199 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
201 FIXME("(%p,%p) stub\n", hEventLog, hEvent);
202 return TRUE;
205 /******************************************************************************
206 * OpenBackupEventLogA [ADVAPI32.@]
208 * Opens a handle to a backup event log.
210 * PARAMS
211 * lpUNCServerName [I] Universal Naming Convention name of the server on which
212 * this will be performed.
213 * lpFileName [I] Specifies the name of the backup file.
215 * RETURNS
216 * Success: Handle to the backup event log.
217 * Failure: NULL
219 HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
221 FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName));
222 return (HANDLE)0xcafe4242;
225 /******************************************************************************
226 * OpenBackupEventLogW [ADVAPI32.@]
228 * See OpenBackupEventLogA.
230 HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
232 FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
233 return (HANDLE)0xcafe4242;
236 /******************************************************************************
237 * OpenEventLogA [ADVAPI32.@]
239 * Opens a handle to the specified event log.
241 * PARAMS
242 * lpUNCServerName [I] UNC name of the server on which the event log is
243 * opened.
244 * lpSourceName [I] Name of the log.
246 * RETURNS
247 * Success: Handle to an event log.
248 * Failure: NULL
250 HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
252 FIXME("(%s,%s) stub\n", debugstr_a(uncname), debugstr_a(source));
253 return (HANDLE)0xcafe4242;
256 /******************************************************************************
257 * OpenEventLogW [ADVAPI32.@]
259 * See OpenEventLogA.
261 HANDLE WINAPI OpenEventLogW( LPCWSTR uncname, LPCWSTR source )
263 FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source));
264 return (HANDLE)0xcafe4242;
267 /******************************************************************************
268 * ReadEventLogA [ADVAPI32.@]
270 * Reads a whole number of entries from an event log.
272 * PARAMS
273 * hEventLog [I] Handle of the event log to read.
274 * dwReadFlags [I] see MSDN doc.
275 * dwRecordOffset [I] Log-entry record number to start at.
276 * lpBuffer [O] Buffer for the data read.
277 * nNumberOfBytesToRead [I] Size of lpBuffer.
278 * pnBytesRead [O] Receives number of bytes read.
279 * pnMinNumberOfBytesNeeded [O] Receives number of bytes required for the
280 * next log entry.
282 * RETURNS
283 * Success: nonzero
284 * Failure: zero
286 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
287 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
289 FIXME("(%p,0x%08lx,0x%08lx,%p,0x%08lx,%p,%p) stub\n", hEventLog, dwReadFlags,
290 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
291 return FALSE;
294 /******************************************************************************
295 * ReadEventLogW [ADVAPI32.@]
297 * See ReadEventLogA.
299 BOOL WINAPI ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
300 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
302 FIXME("(%p,0x%08lx,0x%08lx,%p,0x%08lx,%p,%p) stub\n", hEventLog, dwReadFlags,
303 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
304 return FALSE;
307 /******************************************************************************
308 * RegisterEventSourceA [ADVAPI32.@]
310 * Returns a registered handle to an event log.
312 * PARAMS
313 * lpUNCServerName [I] UNC name of the source server.
314 * lpSourceName [I] Specifies the name of the event source to retrieve.
316 * RETURNS
317 * Success: Handle to the event log.
318 * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the
319 * Security event log.
321 HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName )
323 UNICODE_STRING lpUNCServerNameW;
324 UNICODE_STRING lpSourceNameW;
325 HANDLE ret;
327 FIXME("(%s,%s): stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpSourceName));
329 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName);
330 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName);
331 ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer);
332 RtlFreeUnicodeString (&lpUNCServerNameW);
333 RtlFreeUnicodeString (&lpSourceNameW);
334 return ret;
337 /******************************************************************************
338 * RegisterEventSourceW [ADVAPI32.@]
340 * See RegisterEventSourceA.
342 HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName )
344 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
345 return (HANDLE)0xcafe4242;
348 /******************************************************************************
349 * ReportEventA [ADVAPI32.@]
351 * Writes an entry at the end of an event log.
353 * PARAMS
354 * hEventLog [I] Handle of an event log.
355 * wType [I] See MSDN doc.
356 * wCategory [I] Event category.
357 * dwEventID [I] Event identifier.
358 * lpUserSid [I] Current user's security identifier.
359 * wNumStrings [I] Number of insert strings in lpStrings.
360 * dwDataSize [I] Size of event-specific raw data to write.
361 * lpStrings [I] Buffer containing an array of string to be merged.
362 * lpRawData [I] Buffer containing the binary data.
364 * RETURNS
365 * Success: nonzero. Entry was written to the log.
366 * Failure: zero.
368 * NOTES
369 * The ReportEvent function adds the time, the entry's length, and the
370 * offsets before storing the entry in the log. If lpUserSid != NULL, the
371 * username is also logged.
373 BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
374 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData)
376 LPCWSTR *wideStrArray;
377 UNICODE_STRING str;
378 int i;
379 BOOL ret;
381 FIXME("(%p,0x%04x,0x%04x,0x%08lx,%p,0x%04x,0x%08lx,%p,%p): stub\n", hEventLog,
382 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
384 if (wNumStrings == 0) return TRUE;
385 if (!lpStrings) return TRUE;
387 wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPCWSTR) * wNumStrings);
388 for (i = 0; i < wNumStrings; i++)
390 RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
391 wideStrArray[i] = str.Buffer;
393 ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
394 wNumStrings, dwDataSize, wideStrArray, lpRawData);
395 for (i = 0; i < wNumStrings; i++)
397 HeapFree( GetProcessHeap(), 0, (LPSTR)wideStrArray[i] );
399 HeapFree(GetProcessHeap(), 0, wideStrArray);
400 return ret;
403 /******************************************************************************
404 * ReportEventW [ADVAPI32.@]
406 * See ReportEventA.
408 BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
409 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
411 int i;
413 FIXME("(%p,0x%04x,0x%04x,0x%08lx,%p,0x%04x,0x%08lx,%p,%p): stub\n", hEventLog,
414 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
416 /* partial stub */
418 if (wNumStrings == 0) return TRUE;
419 if (!lpStrings) return TRUE;
421 for (i = 0; i < wNumStrings; i++)
423 switch (wType)
425 case EVENTLOG_SUCCESS:
426 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
427 break;
428 case EVENTLOG_ERROR_TYPE:
429 ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
430 break;
431 case EVENTLOG_WARNING_TYPE:
432 WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
433 break;
434 default:
435 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
436 break;
439 return TRUE;
442 /******************************************************************************
443 * RegisterTraceGuidsW [ADVAPI32.@]
445 * Register an event trace provider and the event trace classes that it uses
446 * to generate events.
448 * PARAMS
449 * RequestAddress [I] ControlCallback function
450 * RequestContext [I] Optional provider-defined context
451 * ControlGuid [I] GUID of the registering provider
452 * GuidCount [I] Number of elements in the TraceGuidReg array
453 * TraceGuidReg [I/O] Array of TRACE_GUID_REGISTRATION structures
454 * MofImagePath [I] not supported, set to NULL
455 * MofResourceNmae [I] not supported, set to NULL
456 * RegistrationHandle [O] Provider's registration handle
458 * RETURNS
459 * Success: ERROR_SUCCESS
460 * Failure: System error code
462 * FIXME
463 * Stub.
465 ULONG WINAPI RegisterTraceGuidsW( WMIDPREQUEST RequestAddress,
466 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
467 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCWSTR MofImagePath,
468 LPCWSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
470 FIXME("%p %p %p %lu %p %s %s %p\n", RequestAddress, RequestContext,
471 ControlGuid, GuidCount, TraceGuidReg, debugstr_w(MofImagePath),
472 debugstr_w(MofResourceName), RegistrationHandle);
473 return ERROR_CALL_NOT_IMPLEMENTED;
476 /******************************************************************************
477 * RegisterTraceGuidsA [ADVAPI32.@]
479 * See RegisterTraceGuidsW.
481 * FIXME
482 * Stub.
484 ULONG WINAPI RegisterTraceGuidsA( WMIDPREQUEST RequestAddress,
485 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
486 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCSTR MofImagePath,
487 LPCSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
489 FIXME("%p %p %p %lu %p %s %s %p\n", RequestAddress, RequestContext,
490 ControlGuid, GuidCount, TraceGuidReg, debugstr_a(MofImagePath),
491 debugstr_a(MofResourceName), RegistrationHandle);
492 return ERROR_CALL_NOT_IMPLEMENTED;