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
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.
43 * hEventLog [I] Handle to event log to backup.
44 * lpBackupFileName [I] Name of the backup file.
47 * Success: nonzero. File lpBackupFileName will contain the contents of
51 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
53 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
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));
68 /******************************************************************************
69 * ClearEventLogA [ADVAPI32.@]
71 * Clears the event log and/or saves the log to a backup file.
74 * hEvenLog [I] Handle to event log to clear.
75 * lpBackupFileName [I] Name of the backup file.
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
83 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
85 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
89 /******************************************************************************
90 * ClearEventLogW [ADVAPI32.@]
94 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
96 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
100 /******************************************************************************
101 * CloseEventLog [ADVAPI32.@]
103 * Closes a read handle to the event log.
106 * hEventLog [I/O] Handle of the event log to close.
112 BOOL WINAPI CloseEventLog( HANDLE hEventLog )
114 FIXME("(%p) stub\n", hEventLog);
118 /******************************************************************************
119 * ControlTraceW [ADVAPI32.@]
121 * Control a givel event trace session
124 ULONG WINAPI ControlTraceW( TRACEHANDLE hSession, LPCWSTR SessionName, PEVENT_TRACE_PROPERTIES Properties, ULONG control )
126 FIXME("(%s, %s, %p, %d) stub\n", wine_dbgstr_longlong(hSession), debugstr_w(SessionName), Properties, control);
127 return ERROR_SUCCESS;
130 /******************************************************************************
131 * ControlTraceA [ADVAPI32.@]
136 ULONG WINAPI ControlTraceA( TRACEHANDLE hSession, LPCSTR SessionName, PEVENT_TRACE_PROPERTIES Properties, ULONG control )
138 FIXME("(%s, %s, %p, %d) stub\n", wine_dbgstr_longlong(hSession), debugstr_a(SessionName), Properties, control);
139 return ERROR_SUCCESS;
142 /******************************************************************************
143 * DeregisterEventSource [ADVAPI32.@]
145 * Closes a write handle to an event log
148 * hEventLog [I/O] Handle of the event log.
154 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
156 FIXME("(%p) stub\n", hEventLog);
160 /******************************************************************************
161 * EnableTrace [ADVAPI32.@]
163 ULONG WINAPI EnableTrace( ULONG enable, ULONG flag, ULONG level, LPCGUID guid, TRACEHANDLE hSession )
165 FIXME("(%d, 0x%x, %d, %s, %s): stub\n", enable, flag, level,
166 debugstr_guid(guid), wine_dbgstr_longlong(hSession));
168 return ERROR_SUCCESS;
171 /******************************************************************************
172 * GetNumberOfEventLogRecords [ADVAPI32.@]
174 * Retrieves the number of records in an event log.
177 * hEventLog [I] Handle to an open event log.
178 * NumberOfRecords [O] Number of records in the log.
181 * Success: nonzero. NumberOfRecords will contain the number of records in
185 BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
187 FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords);
189 if (!NumberOfRecords) return FALSE;
190 *NumberOfRecords = 0;
195 /******************************************************************************
196 * GetOldestEventLogRecord [ADVAPI32.@]
198 * Retrieves the absolute record number of the oldest record in an even log.
201 * hEventLog [I] Handle to an open event log.
202 * OldestRecord [O] Absolute record number of the oldest record.
205 * Success: nonzero. OldestRecord contains the record number of the oldest
209 BOOL WINAPI GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
211 FIXME("(%p,%p) stub\n", hEventLog, OldestRecord);
213 if (!OldestRecord) return FALSE;
219 /******************************************************************************
220 * NotifyChangeEventLog [ADVAPI32.@]
222 * Enables an application to receive notification when an event is written
226 * hEventLog [I] Handle to an event log.
227 * hEvent [I] Handle to a manual-reset event object.
233 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
235 FIXME("(%p,%p) stub\n", hEventLog, hEvent);
239 /******************************************************************************
240 * OpenBackupEventLogA [ADVAPI32.@]
242 * Opens a handle to a backup event log.
245 * lpUNCServerName [I] Universal Naming Convention name of the server on which
246 * this will be performed.
247 * lpFileName [I] Specifies the name of the backup file.
250 * Success: Handle to the backup event log.
253 HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
255 FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName));
256 return (HANDLE)0xcafe4242;
259 /******************************************************************************
260 * OpenBackupEventLogW [ADVAPI32.@]
262 * See OpenBackupEventLogA.
264 HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
266 FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
267 return (HANDLE)0xcafe4242;
270 /******************************************************************************
271 * OpenEventLogA [ADVAPI32.@]
273 * Opens a handle to the specified event log.
276 * lpUNCServerName [I] UNC name of the server on which the event log is
278 * lpSourceName [I] Name of the log.
281 * Success: Handle to an event log.
284 HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
286 FIXME("(%s,%s) stub\n", debugstr_a(uncname), debugstr_a(source));
287 return (HANDLE)0xcafe4242;
290 /******************************************************************************
291 * OpenEventLogW [ADVAPI32.@]
295 HANDLE WINAPI OpenEventLogW( LPCWSTR uncname, LPCWSTR source )
297 FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source));
298 return (HANDLE)0xcafe4242;
301 /******************************************************************************
302 * QueryAllTracesW [ADVAPI32.@]
304 * Query informations for started event trace sessions
307 ULONG WINAPI QueryAllTracesW( PEVENT_TRACE_PROPERTIES * parray, ULONG arraycount, PULONG psessioncount )
309 FIXME("(%p, %d, %p) stub\n", parray, arraycount, psessioncount);
311 if (psessioncount) *psessioncount = 0;
312 return ERROR_SUCCESS;
315 /******************************************************************************
316 * QueryAllTracesA [ADVAPI32.@]
318 * See QueryAllTracesW.
320 ULONG WINAPI QueryAllTracesA( PEVENT_TRACE_PROPERTIES * parray, ULONG arraycount, PULONG psessioncount )
322 FIXME("(%p, %d, %p) stub\n", parray, arraycount, psessioncount);
324 if (psessioncount) *psessioncount = 0;
325 return ERROR_SUCCESS;
328 /******************************************************************************
329 * ReadEventLogA [ADVAPI32.@]
331 * Reads a whole number of entries from an event log.
334 * hEventLog [I] Handle of the event log to read.
335 * dwReadFlags [I] see MSDN doc.
336 * dwRecordOffset [I] Log-entry record number to start at.
337 * lpBuffer [O] Buffer for the data read.
338 * nNumberOfBytesToRead [I] Size of lpBuffer.
339 * pnBytesRead [O] Receives number of bytes read.
340 * pnMinNumberOfBytesNeeded [O] Receives number of bytes required for the
347 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
348 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
350 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
351 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
355 /******************************************************************************
356 * ReadEventLogW [ADVAPI32.@]
360 BOOL WINAPI ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
361 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
363 FIXME("(%p,0x%08x,0x%08x,%p,0x%08x,%p,%p) stub\n", hEventLog, dwReadFlags,
364 dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
368 /******************************************************************************
369 * RegisterEventSourceA [ADVAPI32.@]
371 * Returns a registered handle to an event log.
374 * lpUNCServerName [I] UNC name of the source server.
375 * lpSourceName [I] Specifies the name of the event source to retrieve.
378 * Success: Handle to the event log.
379 * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the
380 * Security event log.
382 HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName )
384 UNICODE_STRING lpUNCServerNameW;
385 UNICODE_STRING lpSourceNameW;
388 FIXME("(%s,%s): stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpSourceName));
390 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName);
391 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName);
392 ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer);
393 RtlFreeUnicodeString (&lpUNCServerNameW);
394 RtlFreeUnicodeString (&lpSourceNameW);
398 /******************************************************************************
399 * RegisterEventSourceW [ADVAPI32.@]
401 * See RegisterEventSourceA.
403 HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName )
405 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
406 return (HANDLE)0xcafe4242;
409 /******************************************************************************
410 * ReportEventA [ADVAPI32.@]
412 * Writes an entry at the end of an event log.
415 * hEventLog [I] Handle of an event log.
416 * wType [I] See MSDN doc.
417 * wCategory [I] Event category.
418 * dwEventID [I] Event identifier.
419 * lpUserSid [I] Current user's security identifier.
420 * wNumStrings [I] Number of insert strings in lpStrings.
421 * dwDataSize [I] Size of event-specific raw data to write.
422 * lpStrings [I] Buffer containing an array of string to be merged.
423 * lpRawData [I] Buffer containing the binary data.
426 * Success: nonzero. Entry was written to the log.
430 * The ReportEvent function adds the time, the entry's length, and the
431 * offsets before storing the entry in the log. If lpUserSid != NULL, the
432 * username is also logged.
434 BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
435 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData)
437 LPWSTR *wideStrArray;
442 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog,
443 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
445 if (wNumStrings == 0) return TRUE;
446 if (!lpStrings) return TRUE;
448 wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWSTR) * wNumStrings);
449 for (i = 0; i < wNumStrings; i++)
451 RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
452 wideStrArray[i] = str.Buffer;
454 ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
455 wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData);
456 for (i = 0; i < wNumStrings; i++)
458 HeapFree( GetProcessHeap(), 0, wideStrArray[i] );
460 HeapFree(GetProcessHeap(), 0, wideStrArray);
464 /******************************************************************************
465 * ReportEventW [ADVAPI32.@]
469 BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
470 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
474 FIXME("(%p,0x%04x,0x%04x,0x%08x,%p,0x%04x,0x%08x,%p,%p): stub\n", hEventLog,
475 wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData);
479 if (wNumStrings == 0) return TRUE;
480 if (!lpStrings) return TRUE;
482 for (i = 0; i < wNumStrings; i++)
486 case EVENTLOG_SUCCESS:
487 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
489 case EVENTLOG_ERROR_TYPE:
490 ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
492 case EVENTLOG_WARNING_TYPE:
493 WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
496 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
503 /******************************************************************************
504 * RegisterTraceGuidsW [ADVAPI32.@]
506 * Register an event trace provider and the event trace classes that it uses
507 * to generate events.
510 * RequestAddress [I] ControlCallback function
511 * RequestContext [I] Optional provider-defined context
512 * ControlGuid [I] GUID of the registering provider
513 * GuidCount [I] Number of elements in the TraceGuidReg array
514 * TraceGuidReg [I/O] Array of TRACE_GUID_REGISTRATION structures
515 * MofImagePath [I] not supported, set to NULL
516 * MofResourceNmae [I] not supported, set to NULL
517 * RegistrationHandle [O] Provider's registration handle
520 * Success: ERROR_SUCCESS
521 * Failure: System error code
526 ULONG WINAPI RegisterTraceGuidsW( WMIDPREQUEST RequestAddress,
527 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
528 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCWSTR MofImagePath,
529 LPCWSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
531 FIXME("%p %p %p %u %p %s %s %p\n", RequestAddress, RequestContext,
532 ControlGuid, GuidCount, TraceGuidReg, debugstr_w(MofImagePath),
533 debugstr_w(MofResourceName), RegistrationHandle);
534 return ERROR_CALL_NOT_IMPLEMENTED;
537 /******************************************************************************
538 * RegisterTraceGuidsA [ADVAPI32.@]
540 * See RegisterTraceGuidsW.
545 ULONG WINAPI RegisterTraceGuidsA( WMIDPREQUEST RequestAddress,
546 PVOID RequestContext, LPCGUID ControlGuid, ULONG GuidCount,
547 PTRACE_GUID_REGISTRATION TraceGuidReg, LPCSTR MofImagePath,
548 LPCSTR MofResourceName, PTRACEHANDLE RegistrationHandle )
550 FIXME("%p %p %p %u %p %s %s %p\n", RequestAddress, RequestContext,
551 ControlGuid, GuidCount, TraceGuidReg, debugstr_a(MofImagePath),
552 debugstr_a(MofResourceName), RegistrationHandle);
553 return ERROR_CALL_NOT_IMPLEMENTED;
556 /******************************************************************************
557 * StartTraceW [ADVAPI32.@]
559 * Register and start an event trace session
562 ULONG WINAPI StartTraceW( PTRACEHANDLE pSessionHandle, LPCWSTR SessionName, PEVENT_TRACE_PROPERTIES Properties )
564 FIXME("(%p, %s, %p) stub\n", pSessionHandle, debugstr_w(SessionName), Properties);
565 if (pSessionHandle) *pSessionHandle = 0xcafe4242;
566 return ERROR_SUCCESS;
569 /******************************************************************************
570 * StartTraceA [ADVAPI32.@]
575 ULONG WINAPI StartTraceA( PTRACEHANDLE pSessionHandle, LPCSTR SessionName, PEVENT_TRACE_PROPERTIES Properties )
577 FIXME("(%p, %s, %p) stub\n", pSessionHandle, debugstr_a(SessionName), Properties);
578 if (pSessionHandle) *pSessionHandle = 0xcafe4242;
579 return ERROR_SUCCESS;
582 /******************************************************************************
583 * TraceEvent [ADVAPI32.@]
585 ULONG WINAPI TraceEvent( TRACEHANDLE SessionHandle, PEVENT_TRACE_HEADER EventTrace )
587 FIXME("%s %p\n", wine_dbgstr_longlong(SessionHandle), EventTrace);
588 return ERROR_CALL_NOT_IMPLEMENTED;
591 /******************************************************************************
592 * UnregisterTraceGuids [ADVAPI32.@]
594 * See RegisterTraceGuids
599 ULONG WINAPI UnregisterTraceGuids( TRACEHANDLE RegistrationHandle )
601 FIXME("%s: stub\n", wine_dbgstr_longlong(RegistrationHandle));
602 return ERROR_CALL_NOT_IMPLEMENTED;