1 /*
2 * Win32 advapi functions
3 *
4 * Copyright 1995 Sven Verdoolaege
5 * Copyright 1998 Juergen Schmied
6 * Copyright 2003 Mike Hearn
7 *
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.
12 *
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.
17 *
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
21 */
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winternl.h"
29 #include "wmistr.h"
30 #include "evntrace.h"
31
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
35 WINE_DECLARE_DEBUG_CHANNEL(eventlog);
36
37 /******************************************************************************
38 * BackupEventLogA [ADVAPI32.@]
39 *
40 * Saves the event log to a backup file.
41 *
42 * PARAMS
43 * hEventLog [I] Handle to event log to backup.
44 * lpBackupFileName [I] Name of the backup file.
45 *
46 * RETURNS
47 * Success: nonzero. File lpBackupFileName will contain the contents of
48 * hEvenLog.
49 * Failure: zero.
50 */
51 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
52 {
53 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
54 return TRUE;
55 }
56
57 /******************************************************************************
58 * BackupEventLogW [ADVAPI32.@]
59 *
60 * See BackupEventLogA.
61 */
62 BOOL WINAPI BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
63 {
64 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
65 return TRUE;
66 }
67
68 /******************************************************************************
69 * ClearEventLogA [ADVAPI32.@]
70 *
71 * Clears the event log and/or saves the log to a backup file.
72 *
73 * PARAMS
74 * hEvenLog [I] Handle to event log to clear.
75 * lpBackupFileName [I] Name of the backup file.
76 *
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.
82 */
83 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
84 {
85 FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
86 return TRUE;
87 }
88
89 /******************************************************************************
90 * ClearEventLogW [ADVAPI32.@]
91 *
92 * See ClearEventLogA.
93 */
94 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
95 {
96 FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
97 return TRUE;
98 }
99
100 /******************************************************************************
101 * CloseEventLog [ADVAPI32.@]
102 *
103 * Closes a read handle to the event log.
104 *
105 * PARAMS
106 * hEventLog [I/O] Handle of the event log to close.
107 *
108 * RETURNS
109 * Success: nonzero
110 * Failure: zero
111 */
112 BOOL WINAPI CloseEventLog( HANDLE hEventLog )
113 {
114 FIXME("(%p) stub\n", hEventLog);
115 return TRUE;
116 }
117
118 /******************************************************************************
119 * DeregisterEventSource [ADVAPI32.@]
120 *
121 * Closes a write handle to an event log
122 *
123 * PARAMS
124 * hEventLog [I/O] Handle of the event log.
125 *
126 * RETURNS
127 * Success: nonzero
128 * Failure: zero
129 */
130 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
131 {
132 FIXME("(%p) stub\n", hEventLog);
133 return TRUE;
134 }
135
136 /******************************************************************************
137 * GetNumberOfEventLogRecords [ADVAPI32.@]
138 *
139 * Retrieves the number of records in an event log.
140 *
141 * PARAMS
142 * hEventLog [I] Handle to an open event log.
143 * NumberOfRecords [O] Number of records in the log.
144 *
145 * RETURNS
146 * Success: nonzero. NumberOfRecords will contain the number of records in
147 * the log.
148 * Failure: zero
149 */
150 BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
151 {
152 FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords);
153
154 if (!NumberOfRecords) return FALSE;
155 *NumberOfRecords = 0;
156
157 return TRUE;
158 }
159
160 /******************************************************************************
161 * GetOldestEventLogRecord [ADVAPI32.@]
162 *
163 * Retrieves the absolute record number of the oldest record in an even log.
164 *
165 * PARAMS
166 * hEventLog [I] Handle to an open event log.
167 * OldestRecord [O] Absolute record number of the oldest record.
168 *
169 * RETURNS
170 * Success: nonzero. OldestRecord contains the record number of the oldest
171 * record in the log.
172 * Failure: zero
173 */
174 BOOL WINAPI GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
175 {
176 FIXME("(%p,%p) stub\n", hEventLog, OldestRecord);
177
178 if (!OldestRecord) return FALSE;
179 *OldestRecord = 0;
180
181 return TRUE;
182 }
183
184 /******************************************************************************
185 * NotifyChangeEventLog [ADVAPI32.@]
186 *
187 * Enables an application to receive notification when an event is written
188 * to an event log.
189 *
190 * PARAMS
191 * hEventLog [I] Handle to an event log.
192 * hEvent [I] Handle to a manual-reset event object.
193 *
194 * RETURNS
195 * Success: nonzero
196 * Failure: zero
197 */
198 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
199 {
200 FIXME("(%p,%p) stub\n", hEventLog, hEvent);
201 return TRUE;
202 }
203
204 /******************************************************************************
205 * OpenBackupEventLogA [ADVAPI32.@]
206 *
207 * Opens a handle to a backup event log.
208 *
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.
213 *
214 * RETURNS
215 * Success: Handle to the backup event log.
216 * Failure: NULL
217 */
218 HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
219 {
220 FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName));
221 return (HANDLE)0xcafe4242;
222 }
223
224 /******************************************************************************
225 * OpenBackupEventLogW [ADVAPI32.@]
226 *
227 * See OpenBackupEventLogA.
228 */
229 HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
230 {
231 FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
232 return (HANDLE)0xcafe4242;
233 }
234
235 /******************************************************************************
236 * OpenEventLogA [ADVAPI32.@]
237 *
238 * Opens a handle to the specified event log.
239 *
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.
244 *
245 * RETURNS
246 * Success: Handle to an event log.
247 * Failure: NULL
248 */
249 HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
250 {
251 FIXME("(%s,%s) stub\n", debugstr_a(uncname), debugstr_a(source));
252 return (HANDLE)0xcafe4242;
253 }
254
255 /******************************************************************************
256 * OpenEventLogW [ADVAPI32.@]
257 *
258 * See OpenEventLogA.
259 */
260 HANDLE WINAPI OpenEventLogW( LPCWSTR uncname, LPCWSTR source )
261 {
262 FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source));
263 return (HANDLE)0xcafe4242;
264 }
265
266 /******************************************************************************
267 * ReadEventLogA [ADVAPI32.@]
268 *
269 * Reads a whole number of entries from an event log.
270 *
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.
280 *
281 * RETURNS
282 * Success: nonzero
283 * Failure: zero
284 */
285 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
286 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
287 {
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;
291 }
292
293 /******************************************************************************
294 * ReadEventLogW [ADVAPI32.@]
295 *
296 * See ReadEventLogA.
297 */
298 BOOL WINAPI ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
299 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
300 {
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;
304 }
305
306 /******************************************************************************
307 * RegisterEventSourceA [ADVAPI32.@]
308 *
309 * Returns a registered handle to an event log.
310 *
311 * PARAMS
312 * lpUNCServerName [I] UNC name of the source server.
313 * lpSourceName [I] Specifies the name of the event source to retrieve.
314 *
315 * RETURNS
316 * Success: Handle to the event log.
317 * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the
318 * Security event log.
319 */
320 HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName )
321 {
322 UNICODE_STRING lpUNCServerNameW;
323 UNICODE_STRING lpSourceNameW;
324 HANDLE ret;
325
326 FIXME("(%s,%s): stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpSourceName));
327
328 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName);
329 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName);
330 ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer);
331 RtlFreeUnicodeString (&lpUNCServerNameW);
332 RtlFreeUnicodeString (&lpSourceNameW);
333 return ret;
334 }
335
336 /******************************************************************************
337 * RegisterEventSourceW [ADVAPI32.@]
338 *
339 * See RegisterEventSourceA.
340 */
341 HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName )
342 {
343 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
344 return (HANDLE)0xcafe4242;
345 }
346
347 /******************************************************************************
348 * ReportEventA [ADVAPI32.@]
349 *
350 * Writes an entry at the end of an event log.
351 *
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.
362 *
363 * RETURNS
364 * Success: nonzero. Entry was written to the log.
365 * Failure: zero.
366 *
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.
371 */
372 BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
373 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData)
374 {
375 LPWSTR *wideStrArray;
376 UNICODE_STRING str;
377 int i;
378 BOOL ret;
379
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);
382
383 if (wNumStrings == 0) return TRUE;
384 if (!lpStrings) return TRUE;
385
386 wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWSTR) * wNumStrings);
387 for (i = 0; i < wNumStrings; i++)
388 {
389 RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
390 wideStrArray[i] = str.Buffer;
391 }
392 ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
393 wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData);
394 for (i = 0; i < wNumStrings; i++)
395 {
396 HeapFree( GetProcessHeap(), 0, wideStrArray[i] );
397 }
398 HeapFree(GetProcessHeap(), 0, wideStrArray);
399 return ret;
400 }
401
402 /******************************************************************************
403 * ReportEventW [ADVAPI32.@]
404 *
405 * See ReportEventA.
406 */
407 BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
408 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
409 {
410 int i;
411
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);
414
415 /* partial stub */
416
417 if (wNumStrings == 0) return TRUE;
418 if (!lpStrings) return TRUE;
419
420 for (i = 0; i < wNumStrings; i++)
421 {
422 switch (wType)
423 {
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;
436 }
437 }
438 return TRUE;
439 }
440
441 /******************************************************************************
442 * RegisterTraceGuidsW [ADVAPI32.@]
443 *
444 * Register an event trace provider and the event trace classes that it uses
445 * to generate events.
446 *
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
456 *
457 * RETURNS
458 * Success: ERROR_SUCCESS
459 * Failure: System error code
460 *
461 * FIXME
462 * Stub.
463 */
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 )
468 {
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;
473 }
474
475 /******************************************************************************
476 * RegisterTraceGuidsA [ADVAPI32.@]
477 *
478 * See RegisterTraceGuidsW.
479 *
480 * FIXME
481 * Stub.
482 */
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 )
487 {
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;
492 }
493
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.