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 * DeregisterEventSource [ADVAPI32.@]
121 * Closes a write handle to an event log
124 * hEventLog [I/O] Handle of the event log.
130 BOOL WINAPI
DeregisterEventSource( HANDLE hEventLog
)
132 FIXME("(%p) stub\n", hEventLog
);
136 /******************************************************************************
137 * GetNumberOfEventLogRecords [ADVAPI32.@]
139 * Retrieves the number of records in an event log.
142 * hEventLog [I] Handle to an open event log.
143 * NumberOfRecords [O] Number of records in the log.
146 * Success: nonzero. NumberOfRecords will contain the number of records in
150 BOOL WINAPI
GetNumberOfEventLogRecords( HANDLE hEventLog
, PDWORD NumberOfRecords
)
152 FIXME("(%p,%p) stub\n", hEventLog
, NumberOfRecords
);
154 if (!NumberOfRecords
) return FALSE
;
155 *NumberOfRecords
= 0;
160 /******************************************************************************
161 * GetOldestEventLogRecord [ADVAPI32.@]
163 * Retrieves the absolute record number of the oldest record in an even log.
166 * hEventLog [I] Handle to an open event log.
167 * OldestRecord [O] Absolute record number of the oldest record.
170 * Success: nonzero. OldestRecord contains the record number of the oldest
174 BOOL WINAPI
GetOldestEventLogRecord( HANDLE hEventLog
, PDWORD OldestRecord
)
176 FIXME("(%p,%p) stub\n", hEventLog
, OldestRecord
);
178 if (!OldestRecord
) return FALSE
;
184 /******************************************************************************
185 * NotifyChangeEventLog [ADVAPI32.@]
187 * Enables an application to receive notification when an event is written
191 * hEventLog [I] Handle to an event log.
192 * hEvent [I] Handle to a manual-reset event object.
198 BOOL WINAPI
NotifyChangeEventLog( HANDLE hEventLog
, HANDLE hEvent
)
200 FIXME("(%p,%p) stub\n", hEventLog
, hEvent
);
204 /******************************************************************************
205 * OpenBackupEventLogA [ADVAPI32.@]
207 * Opens a handle to a backup event log.
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.
215 * Success: Handle to the backup event log.
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.
241 * lpUNCServerName [I] UNC name of the server on which the event log is
243 * lpSourceName [I] Name of the log.
246 * Success: Handle to an event log.
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.@]
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.
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
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
);
293 /******************************************************************************
294 * ReadEventLogW [ADVAPI32.@]
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
);
306 /******************************************************************************
307 * RegisterEventSourceA [ADVAPI32.@]
309 * Returns a registered handle to an event log.
312 * lpUNCServerName [I] UNC name of the source server.
313 * lpSourceName [I] Specifies the name of the event source to retrieve.
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
;
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
);
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.
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.
364 * Success: nonzero. Entry was written to the log.
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
;
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
);
402 /******************************************************************************
403 * ReportEventW [ADVAPI32.@]
407 BOOL WINAPI
ReportEventW( HANDLE hEventLog
, WORD wType
, WORD wCategory
, DWORD dwEventID
,
408 PSID lpUserSid
, WORD wNumStrings
, DWORD dwDataSize
, LPCWSTR
*lpStrings
, LPVOID lpRawData
)
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
);
417 if (wNumStrings
== 0) return TRUE
;
418 if (!lpStrings
) return TRUE
;
420 for (i
= 0; i
< wNumStrings
; i
++)
424 case EVENTLOG_SUCCESS
:
425 TRACE_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
427 case EVENTLOG_ERROR_TYPE
:
428 ERR_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
430 case EVENTLOG_WARNING_TYPE
:
431 WARN_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
434 TRACE_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
441 /******************************************************************************
442 * RegisterTraceGuidsW [ADVAPI32.@]
444 * Register an event trace provider and the event trace classes that it uses
445 * to generate events.
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
458 * Success: ERROR_SUCCESS
459 * Failure: System error code
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.
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
;