dplayx: Tests for CreatePlayer.
[wine/gsoc_dplay.git] / dlls / advapi32 / eventlog.c
blob03bb4f371dffaff13f3101b60792f21fc8a3cdca
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 "winternl.h"
29 #include "wmistr.h"
30 #include "evntrace.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
35 WINE_DECLARE_DEBUG_CHANNEL(eventlog);
37 /******************************************************************************
38 * BackupEventLogA [ADVAPI32.@]
40 * Saves the event log to a backup file.
42 * PARAMS
43 * hEventLog [I] Handle to event log to backup.
44 * lpBackupFileName [I] Name of the backup file.
46 * RETURNS
47 * Success: nonzero. File lpBackupFileName will contain the contents of
48 * hEvenLog.
49 * Failure: zero.
51 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
53 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
54 return TRUE;
57 /******************************************************************************
58 * BackupEventLogW [ADVAPI32.@]
60 * See BackupEventLogA.
62 BOOL WINAPI BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
64 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
65 return TRUE;
68 /******************************************************************************
69 * ClearEventLogA [ADVAPI32.@]
71 * Clears the event log and/or saves the log to a backup file.
73 * PARAMS
74 * hEvenLog [I] Handle to event log to clear.
75 * lpBackupFileName [I] Name of the backup file.
77 * RETURNS
78 * Success: nonzero. if lpBackupFileName != NULL, lpBackupFileName will
79 * contain the contents of hEvenLog and the log will be cleared.
80 * Failure: zero. Fails if the event log is empty or if lpBackupFileName
81 * exists.
83 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
85 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
86 return TRUE;
89 /******************************************************************************
90 * ClearEventLogW [ADVAPI32.@]
92 * See ClearEventLogA.
94 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
96 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
97 return TRUE;
100 /******************************************************************************
101 * CloseEventLog [ADVAPI32.@]
103 * Closes a read handle to the event log.
105 * PARAMS
106 * hEventLog [I/O] Handle of the event log to close.
108 * RETURNS
109 * Success: nonzero
110 * Failure: zero
112 BOOL WINAPI CloseEventLog( HANDLE hEventLog )
114 FIXME("(%p) stub\n", hEventLog);
115 return TRUE;
118 /******************************************************************************
119 * DeregisterEventSource [ADVAPI32.@]
121 * Closes a write handle to an event log
123 * PARAMS
124 * hEventLog [I/O] Handle of the event log.
126 * RETURNS
127 * Success: nonzero
128 * Failure: zero
130 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
132 FIXME("(%p) stub\n", hEventLog);
133 return TRUE;
136 /******************************************************************************
137 * GetNumberOfEventLogRecords [ADVAPI32.@]
139 * Retrieves the number of records in an event log.
141 * PARAMS
142 * hEventLog [I] Handle to an open event log.
143 * NumberOfRecords [O] Number of records in the log.
145 * RETURNS
146 * Success: nonzero. NumberOfRecords will contain the number of records in
147 * the log.
148 * Failure: zero
150 BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
152 FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords);
154 if (!NumberOfRecords) return FALSE;
155 *NumberOfRecords = 0;
157 return TRUE;
160 /******************************************************************************
161 * GetOldestEventLogRecord [ADVAPI32.@]
163 * Retrieves the absolute record number of the oldest record in an even log.
165 * PARAMS
166 * hEventLog [I] Handle to an open event log.
167 * OldestRecord [O] Absolute record number of the oldest record.
169 * RETURNS
170 * Success: nonzero. OldestRecord contains the record number of the oldest
171 * record in the log.
172 * Failure: zero
174 BOOL WINAPI GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
176 FIXME("(%p,%p) stub\n", hEventLog, OldestRecord);
178 if (!OldestRecord) return FALSE;
179 *OldestRecord = 0;
181 return TRUE;
184 /******************************************************************************
185 * NotifyChangeEventLog [ADVAPI32.@]
187 * Enables an application to receive notification when an event is written
188 * to an event log.
190 * PARAMS
191 * hEventLog [I] Handle to an event log.
192 * hEvent [I] Handle to a manual-reset event object.
194 * RETURNS
195 * Success: nonzero
196 * Failure: zero
198 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
200 FIXME("(%p,%p) stub\n", hEventLog, hEvent);
201 return TRUE;
204 /******************************************************************************
205 * OpenBackupEventLogA [ADVAPI32.@]
207 * Opens a handle to a backup event log.
209 * PARAMS
210 * lpUNCServerName [I] Universal Naming Convention name of the server on which
211 * this will be performed.
212 * lpFileName [I] Specifies the name of the backup file.
214 * RETURNS
215 * Success: Handle to the backup event log.
216 * Failure: NULL
218 HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
220 FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName));
221 return (HANDLE)0xcafe4242;
224 /******************************************************************************
225 * OpenBackupEventLogW [ADVAPI32.@]
227 * See OpenBackupEventLogA.
229 HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
231 FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
232 return (HANDLE)0xcafe4242;
235 /******************************************************************************
236 * OpenEventLogA [ADVAPI32.@]
238 * Opens a handle to the specified event log.
240 * PARAMS
241 * lpUNCServerName [I] UNC name of the server on which the event log is
242 * opened.
243 * lpSourceName [I] Name of the log.
245 * RETURNS
246 * Success: Handle to an event log.
247 * Failure: NULL
249 HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
251 FIXME("(%s,%s) stub\n", debugstr_a(uncname), debugstr_a(source));
252 return (HANDLE)0xcafe4242;
255 /******************************************************************************
256 * OpenEventLogW [ADVAPI32.@]
258 * See OpenEventLogA.
260 HANDLE WINAPI OpenEventLogW( LPCWSTR uncname, LPCWSTR source )
262 FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source));
263 return (HANDLE)0xcafe4242;
266 /******************************************************************************
267 * ReadEventLogA [ADVAPI32.@]
269 * Reads a whole number of entries from an event log.
271 * PARAMS
272 * hEventLog [I] Handle of the event log to read.
273 * dwReadFlags [I] see MSDN doc.
274 * dwRecordOffset [I] Log-entry record number to start at.
275 * lpBuffer [O] Buffer for the data read.
276 * nNumberOfBytesToRead [I] Size of lpBuffer.
277 * pnBytesRead [O] Receives number of bytes read.
278 * pnMinNumberOfBytesNeeded [O] Receives number of bytes required for the
279 * next log entry.
281 * RETURNS
282 * Success: nonzero
283 * Failure: zero
285 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
286 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
288 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
289 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
290 return FALSE;
293 /******************************************************************************
294 * ReadEventLogW [ADVAPI32.@]
296 * See ReadEventLogA.
298 BOOL WINAPI ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
299 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
301 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
302 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
303 return FALSE;
306 /******************************************************************************
307 * RegisterEventSourceA [ADVAPI32.@]
309 * Returns a registered handle to an event log.
311 * PARAMS
312 * lpUNCServerName [I] UNC name of the source server.
313 * lpSourceName [I] Specifies the name of the event source to retrieve.
315 * RETURNS
316 * Success: Handle to the event log.
317 * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the
318 * Security event log.
320 HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName )
322 UNICODE_STRING lpUNCServerNameW;
323 UNICODE_STRING lpSourceNameW;
324 HANDLE ret;
326 FIXME("(%s,%s): stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpSourceName));
328 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName);
329 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName);
330 ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer);
331 RtlFreeUnicodeString (&lpUNCServerNameW);
332 RtlFreeUnicodeString (&lpSourceNameW);
333 return ret;
336 /******************************************************************************
337 * RegisterEventSourceW [ADVAPI32.@]
339 * See RegisterEventSourceA.
341 HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName )
343 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
344 return (HANDLE)0xcafe4242;
347 /******************************************************************************
348 * ReportEventA [ADVAPI32.@]
350 * Writes an entry at the end of an event log.
352 * PARAMS
353 * hEventLog [I] Handle of an event log.
354 * wType [I] See MSDN doc.
355 * wCategory [I] Event category.
356 * dwEventID [I] Event identifier.
357 * lpUserSid [I] Current user's security identifier.
358 * wNumStrings [I] Number of insert strings in lpStrings.
359 * dwDataSize [I] Size of event-specific raw data to write.
360 * lpStrings [I] Buffer containing an array of string to be merged.
361 * lpRawData [I] Buffer containing the binary data.
363 * RETURNS
364 * Success: nonzero. Entry was written to the log.
365 * Failure: zero.
367 * NOTES
368 * The ReportEvent function adds the time, the entry's length, and the
369 * offsets before storing the entry in the log. If lpUserSid != NULL, the
370 * username is also logged.
372 BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
373 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData)
375 LPWSTR *wideStrArray;
376 UNICODE_STRING str;
377 int i;
378 BOOL ret;
380 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog,
381 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
383 if (wNumStrings == 0) return TRUE;
384 if (!lpStrings) return TRUE;
386 wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWSTR) * wNumStrings);
387 for (i = 0; i < wNumStrings; i++)
389 RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
390 wideStrArray[i] = str.Buffer;
392 ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
393 wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData);
394 for (i = 0; i < wNumStrings; i++)
396 HeapFree( GetProcessHeap(), 0, wideStrArray[i] );
398 HeapFree(GetProcessHeap(), 0, wideStrArray);
399 return ret;
402 /******************************************************************************
403 * ReportEventW [ADVAPI32.@]
405 * See ReportEventA.
407 BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
408 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
410 int i;
412 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog,
413 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
415 /* partial stub */
417 if (wNumStrings == 0) return TRUE;
418 if (!lpStrings) return TRUE;
420 for (i = 0; i < wNumStrings; i++)
422 switch (wType)
424 case EVENTLOG_SUCCESS:
425 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
426 break;
427 case EVENTLOG_ERROR_TYPE:
428 ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
429 break;
430 case EVENTLOG_WARNING_TYPE:
431 WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
432 break;
433 default:
434 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
435 break;
438 return TRUE;
441 /******************************************************************************
442 * RegisterTraceGuidsW [ADVAPI32.@]
444 * Register an event trace provider and the event trace classes that it uses
445 * to generate events.
447 * PARAMS
448 * RequestAddress [I] ControlCallback function
449 * RequestContext [I] Optional provider-defined context
450 * ControlGuid [I] GUID of the registering provider
451 * GuidCount [I] Number of elements in the TraceGuidReg array
452 * TraceGuidReg [I/O] Array of TRACE_GUID_REGISTRATION structures
453 * MofImagePath [I] not supported, set to NULL
454 * MofResourceNmae [I] not supported, set to NULL
455 * RegistrationHandle [O] Provider's registration handle
457 * RETURNS
458 * Success: ERROR_SUCCESS
459 * Failure: System error code
461 * FIXME
462 * Stub.
464 ULONG WINAPI RegisterTraceGuidsW( WMIDPREQUEST RequestAddress,
465 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
466 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCWSTR MofImagePath,
467 LPCWSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
469 FIXME("%p %p %p %u %p %s %s %p\n", RequestAddress, RequestContext,
470 ControlGuid, GuidCount, TraceGuidReg, debugstr_w(MofImagePath),
471 debugstr_w(MofResourceName), RegistrationHandle);
472 return ERROR_CALL_NOT_IMPLEMENTED;
475 /******************************************************************************
476 * RegisterTraceGuidsA [ADVAPI32.@]
478 * See RegisterTraceGuidsW.
480 * FIXME
481 * Stub.
483 ULONG WINAPI RegisterTraceGuidsA( WMIDPREQUEST RequestAddress,
484 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
485 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCSTR MofImagePath,
486 LPCSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
488 FIXME("%p %p %p %u %p %s %s %p\n", RequestAddress, RequestContext,
489 ControlGuid, GuidCount, TraceGuidReg, debugstr_a(MofImagePath),
490 debugstr_a(MofResourceName), RegistrationHandle);
491 return ERROR_CALL_NOT_IMPLEMENTED;