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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
34 WINE_DECLARE_DEBUG_CHANNEL(eventlog
);
36 /******************************************************************************
37 * BackupEventLogA [ADVAPI32.@]
39 BOOL WINAPI
BackupEventLogA( HANDLE hEventLog
, LPCSTR lpBackupFileName
)
45 /******************************************************************************
46 * BackupEventLogW [ADVAPI32.@]
53 BackupEventLogW( HANDLE hEventLog
, LPCWSTR lpBackupFileName
)
59 /******************************************************************************
60 * ClearEventLogA [ADVAPI32.@]
62 BOOL WINAPI
ClearEventLogA ( HANDLE hEventLog
, LPCSTR lpBackupFileName
)
68 /******************************************************************************
69 * ClearEventLogW [ADVAPI32.@]
71 BOOL WINAPI
ClearEventLogW ( HANDLE hEventLog
, LPCWSTR lpBackupFileName
)
77 /******************************************************************************
78 * CloseEventLog [ADVAPI32.@]
80 BOOL WINAPI
CloseEventLog ( HANDLE hEventLog
)
86 /******************************************************************************
87 * DeregisterEventSource [ADVAPI32.@]
88 * Closes a handle to the specified event log
91 * hEventLog [I] Handle to event log
95 BOOL WINAPI
DeregisterEventSource( HANDLE hEventLog
)
97 FIXME("(%p): stub\n",hEventLog
);
101 /******************************************************************************
102 * GetNumberOfEventLogRecords [ADVAPI32.@]
109 GetNumberOfEventLogRecords( HANDLE hEventLog
, PDWORD NumberOfRecords
)
115 /******************************************************************************
116 * GetOldestEventLogRecord [ADVAPI32.@]
123 GetOldestEventLogRecord( HANDLE hEventLog
, PDWORD OldestRecord
)
129 /******************************************************************************
130 * NotifyChangeEventLog [ADVAPI32.@]
136 BOOL WINAPI
NotifyChangeEventLog( HANDLE hEventLog
, HANDLE hEvent
)
142 /******************************************************************************
143 * OpenBackupEventLogA [ADVAPI32.@]
146 OpenBackupEventLogA( LPCSTR lpUNCServerName
, LPCSTR lpFileName
)
152 /******************************************************************************
153 * OpenBackupEventLogW [ADVAPI32.@]
160 OpenBackupEventLogW( LPCWSTR lpUNCServerName
, LPCWSTR lpFileName
)
166 /******************************************************************************
167 * OpenEventLogA [ADVAPI32.@]
169 HANDLE WINAPI
OpenEventLogA(LPCSTR uncname
,LPCSTR source
)
171 FIXME("(%s,%s),stub!\n",uncname
,source
);
172 return (HANDLE
)0xcafe4242;
175 /******************************************************************************
176 * OpenEventLogW [ADVAPI32.@]
183 OpenEventLogW( LPCWSTR uncname
, LPCWSTR source
)
189 /******************************************************************************
190 * ReadEventLogA [ADVAPI32.@]
192 BOOL WINAPI
ReadEventLogA( HANDLE hEventLog
, DWORD dwReadFlags
, DWORD dwRecordOffset
,
193 LPVOID lpBuffer
, DWORD nNumberOfBytesToRead
, DWORD
*pnBytesRead
, DWORD
*pnMinNumberOfBytesNeeded
)
199 /******************************************************************************
200 * ReadEventLogW [ADVAPI32.@]
207 * nNumberOfBytesToRead []
209 * pnMinNumberOfBytesNeeded []
212 ReadEventLogW( HANDLE hEventLog
, DWORD dwReadFlags
, DWORD dwRecordOffset
,
213 LPVOID lpBuffer
, DWORD nNumberOfBytesToRead
,
214 DWORD
*pnBytesRead
, DWORD
*pnMinNumberOfBytesNeeded
)
220 /******************************************************************************
221 * RegisterEventSourceA [ADVAPI32.@]
223 HANDLE WINAPI
RegisterEventSourceA( LPCSTR lpUNCServerName
, LPCSTR lpSourceName
)
226 UNICODE_STRING lpUNCServerNameW
;
227 UNICODE_STRING lpSourceNameW
;
229 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW
, lpUNCServerName
);
230 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW
, lpSourceName
);
231 ret
= RegisterEventSourceW(lpUNCServerNameW
.Buffer
,lpSourceNameW
.Buffer
);
232 RtlFreeUnicodeString (&lpUNCServerNameW
);
233 RtlFreeUnicodeString (&lpSourceNameW
);
237 /******************************************************************************
238 * RegisterEventSourceW [ADVAPI32.@]
239 * Returns a registered handle to an event log
242 * lpUNCServerName [I] Server name for source
243 * lpSourceName [I] Source name for registered handle
250 RegisterEventSourceW( LPCWSTR lpUNCServerName
, LPCWSTR lpSourceName
)
252 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName
),
253 debugstr_w(lpSourceName
));
257 /******************************************************************************
258 * ReportEventA [ADVAPI32.@]
260 BOOL WINAPI
ReportEventA ( HANDLE hEventLog
, WORD wType
, WORD wCategory
, DWORD dwEventID
,
261 PSID lpUserSid
, WORD wNumStrings
, DWORD dwDataSize
, LPCSTR
*lpStrings
, LPVOID lpRawData
)
263 LPCWSTR
*wideStrArray
;
268 if (wNumStrings
== 0) return TRUE
;
269 if (!lpStrings
) return TRUE
;
271 wideStrArray
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPCWSTR
) * wNumStrings
);
272 for (i
= 0; i
< wNumStrings
; i
++)
274 RtlCreateUnicodeStringFromAsciiz(&str
, lpStrings
[i
]);
275 wideStrArray
[i
] = str
.Buffer
;
277 ret
= ReportEventW(hEventLog
, wType
, wCategory
, dwEventID
, lpUserSid
,
278 wNumStrings
, dwDataSize
, wideStrArray
, lpRawData
);
279 for (i
= 0; i
< wNumStrings
; i
++)
281 if (wideStrArray
[i
]) HeapFree( GetProcessHeap(), 0, (LPSTR
)wideStrArray
[i
] );
283 HeapFree(GetProcessHeap(), 0, wideStrArray
);
287 /******************************************************************************
288 * ReportEventW [ADVAPI32.@]
302 ReportEventW( HANDLE hEventLog
, WORD wType
, WORD wCategory
,
303 DWORD dwEventID
, PSID lpUserSid
, WORD wNumStrings
,
304 DWORD dwDataSize
, LPCWSTR
*lpStrings
, LPVOID lpRawData
)
310 if (wNumStrings
== 0) return TRUE
;
311 if (!lpStrings
) return TRUE
;
313 for (i
= 0; i
< wNumStrings
; i
++)
317 case EVENTLOG_SUCCESS
:
318 TRACE_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
320 case EVENTLOG_ERROR_TYPE
:
321 ERR_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
323 case EVENTLOG_WARNING_TYPE
:
324 WARN_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));
327 TRACE_(eventlog
)("%s\n", debugstr_w(lpStrings
[i
]));