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
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.
44 * hEventLog [I] Handle to event log to backup.
45 * lpBackupFileName [I] Name of the backup file.
48 * Success: nonzero. File lpBackupFileName will contain the contents of
52 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
54 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
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));
69 /******************************************************************************
70 * ClearEventLogA [ADVAPI32.@]
72 * Clears the event log and/or saves the log to a backup file.
75 * hEvenLog [I] Handle to event log to clear.
76 * lpBackupFileName [I] Name of the backup file.
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
84 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
86 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
90 /******************************************************************************
91 * ClearEventLogW [ADVAPI32.@]
95 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
97 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
101 /******************************************************************************
102 * CloseEventLog [ADVAPI32.@]
104 * Closes a read handle to the event log.
107 * hEventLog [I/O] Handle of the event log to close.
113 BOOL WINAPI CloseEventLog( HANDLE hEventLog )
115 FIXME("(%p) stub\n", hEventLog);
119 /******************************************************************************
120 * DeregisterEventSource [ADVAPI32.@]
122 * Closes a write handle to an event log
125 * hEventLog [I/O] Handle of the event log.
131 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
133 FIXME("(%p) stub\n", hEventLog);
137 /******************************************************************************
138 * GetNumberOfEventLogRecords [ADVAPI32.@]
140 * Retrieves the number of records in an event log.
143 * hEventLog [I] Handle to an open event log.
144 * NumberOfRecords [O] Number of records in the log.
147 * Success: nonzero. NumberOfRecords will contain the number of records in
151 BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
153 FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords);
155 if (!NumberOfRecords) return FALSE;
156 *NumberOfRecords = 0;
161 /******************************************************************************
162 * GetOldestEventLogRecord [ADVAPI32.@]
164 * Retrieves the absolute record number of the oldest record in an even log.
167 * hEventLog [I] Handle to an open event log.
168 * OldestRecord [O] Absolute record number of the oldest record.
171 * Success: nonzero. OldestRecord contains the record number of the oldest
175 BOOL WINAPI GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
177 FIXME("(%p,%p) stub\n", hEventLog, OldestRecord);
179 if (!OldestRecord) return FALSE;
185 /******************************************************************************
186 * NotifyChangeEventLog [ADVAPI32.@]
188 * Enables an application to receive notification when an event is written
192 * hEventLog [I] Handle to an event log.
193 * hEvent [I] Handle to a manual-reset event object.
199 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
201 FIXME("(%p,%p) stub\n", hEventLog, hEvent);
205 /******************************************************************************
206 * OpenBackupEventLogA [ADVAPI32.@]
208 * Opens a handle to a backup event log.
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.
216 * Success: Handle to the backup event log.
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.
242 * lpUNCServerName [I] UNC name of the server on which the event log is
244 * lpSourceName [I] Name of the log.
247 * Success: Handle to an event log.
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.@]
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.
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
286 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
287 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
289 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
290 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
294 /******************************************************************************
295 * ReadEventLogW [ADVAPI32.@]
299 BOOL WINAPI ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
300 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
302 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
303 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
307 /******************************************************************************
308 * RegisterEventSourceA [ADVAPI32.@]
310 * Returns a registered handle to an event log.
313 * lpUNCServerName [I] UNC name of the source server.
314 * lpSourceName [I] Specifies the name of the event source to retrieve.
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;
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);
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.
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.
365 * Success: nonzero. Entry was written to the log.
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 LPWSTR *wideStrArray;
381 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%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(LPWSTR) * 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, (LPCWSTR *)wideStrArray, lpRawData);
395 for (i = 0; i < wNumStrings; i++)
397 HeapFree( GetProcessHeap(), 0, wideStrArray[i] );
399 HeapFree(GetProcessHeap(), 0, wideStrArray);
403 /******************************************************************************
404 * ReportEventW [ADVAPI32.@]
408 BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
409 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
413 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog,
414 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
418 if (wNumStrings == 0) return TRUE;
419 if (!lpStrings) return TRUE;
421 for (i = 0; i < wNumStrings; i++)
425 case EVENTLOG_SUCCESS:
426 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
428 case EVENTLOG_ERROR_TYPE:
429 ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
431 case EVENTLOG_WARNING_TYPE:
432 WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
435 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
442 /******************************************************************************
443 * RegisterTraceGuidsW [ADVAPI32.@]
445 * Register an event trace provider and the event trace classes that it uses
446 * to generate events.
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
459 * Success: ERROR_SUCCESS
460 * Failure: System error code
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 %u %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.
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 %u %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;