2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
5 * Copyright 1998 Juergen Schmied
6 * Copyright 2003 Mike Hearn
7 * Copyright 2007 Hervé Poussineau
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
29 static RPC_UNICODE_STRING EmptyStringU
= { 0, 0, L
"" };
30 static RPC_STRING EmptyStringA
= { 0, 0, "" };
34 EVENTLOG_HANDLE_A_bind(EVENTLOG_HANDLE_A UNCServerName
)
36 handle_t hBinding
= NULL
;
37 UCHAR
*pszStringBinding
;
40 TRACE("EVENTLOG_HANDLE_A_bind() called\n");
42 status
= RpcStringBindingComposeA(NULL
,
44 (UCHAR
*)UNCServerName
,
45 (UCHAR
*)"\\pipe\\EventLog",
47 (UCHAR
**)&pszStringBinding
);
50 ERR("RpcStringBindingCompose returned 0x%x\n", status
);
54 /* Set the binding handle that will be used to bind to the server. */
55 status
= RpcBindingFromStringBindingA(pszStringBinding
,
59 ERR("RpcBindingFromStringBinding returned 0x%x\n", status
);
62 status
= RpcStringFreeA(&pszStringBinding
);
65 ERR("RpcStringFree returned 0x%x\n", status
);
73 EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName
,
78 TRACE("EVENTLOG_HANDLE_A_unbind() called\n");
80 status
= RpcBindingFree(&hBinding
);
83 ERR("RpcBindingFree returned 0x%x\n", status
);
89 EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName
)
91 handle_t hBinding
= NULL
;
92 LPWSTR pszStringBinding
;
95 TRACE("EVENTLOG_HANDLE_W_bind() called\n");
97 status
= RpcStringBindingComposeW(NULL
,
99 (LPWSTR
)UNCServerName
,
105 ERR("RpcStringBindingCompose returned 0x%x\n", status
);
109 /* Set the binding handle that will be used to bind to the server. */
110 status
= RpcBindingFromStringBindingW(pszStringBinding
,
114 ERR("RpcBindingFromStringBinding returned 0x%x\n", status
);
117 status
= RpcStringFreeW(&pszStringBinding
);
120 ERR("RpcStringFree returned 0x%x\n", status
);
128 EVENTLOG_HANDLE_W_unbind(EVENTLOG_HANDLE_W UNCServerName
,
133 TRACE("EVENTLOG_HANDLE_W_unbind() called\n");
135 status
= RpcBindingFree(&hBinding
);
138 ERR("RpcBindingFree returned 0x%x\n", status
);
143 /******************************************************************************
144 * BackupEventLogA [ADVAPI32.@]
147 BackupEventLogA(IN HANDLE hEventLog
,
148 IN LPCSTR lpBackupFileName
)
150 ANSI_STRING BackupFileName
;
153 TRACE("%p, %s\n", hEventLog
, lpBackupFileName
);
155 RtlInitAnsiString(&BackupFileName
, lpBackupFileName
);
159 Status
= ElfrBackupELFA(hEventLog
,
160 (PRPC_STRING
)&BackupFileName
);
162 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
164 Status
= I_RpcMapWin32Status(RpcExceptionCode());
168 if (!NT_SUCCESS(Status
))
170 SetLastError(RtlNtStatusToDosError(Status
));
177 /******************************************************************************
178 * BackupEventLogW [ADVAPI32.@]
182 * lpBackupFileName []
185 BackupEventLogW(IN HANDLE hEventLog
,
186 IN LPCWSTR lpBackupFileName
)
188 UNICODE_STRING BackupFileName
;
191 TRACE("%p, %s\n", hEventLog
, debugstr_w(lpBackupFileName
));
193 RtlInitUnicodeString(&BackupFileName
, lpBackupFileName
);
197 Status
= ElfrBackupELFW(hEventLog
,
198 (PRPC_UNICODE_STRING
)&BackupFileName
);
200 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
202 Status
= I_RpcMapWin32Status(RpcExceptionCode());
206 if (!NT_SUCCESS(Status
))
208 SetLastError(RtlNtStatusToDosError(Status
));
216 /******************************************************************************
217 * ClearEventLogA [ADVAPI32.@]
220 ClearEventLogA(IN HANDLE hEventLog
,
221 IN LPCSTR lpBackupFileName
)
223 ANSI_STRING BackupFileName
;
226 TRACE("%p, %s\n", hEventLog
, lpBackupFileName
);
228 RtlInitAnsiString(&BackupFileName
, lpBackupFileName
);
232 Status
= ElfrClearELFA(hEventLog
,
233 (PRPC_STRING
)&BackupFileName
);
235 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
237 Status
= I_RpcMapWin32Status(RpcExceptionCode());
241 if (!NT_SUCCESS(Status
))
243 SetLastError(RtlNtStatusToDosError(Status
));
251 /******************************************************************************
252 * ClearEventLogW [ADVAPI32.@]
255 ClearEventLogW(IN HANDLE hEventLog
,
256 IN LPCWSTR lpBackupFileName
)
258 UNICODE_STRING BackupFileName
;
261 TRACE("%p, %s\n", hEventLog
, debugstr_w(lpBackupFileName
));
263 RtlInitUnicodeString(&BackupFileName
,lpBackupFileName
);
267 Status
= ElfrClearELFW(hEventLog
,
268 (PRPC_UNICODE_STRING
)&BackupFileName
);
270 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
272 Status
= I_RpcMapWin32Status(RpcExceptionCode());
276 if (!NT_SUCCESS(Status
))
278 SetLastError(RtlNtStatusToDosError(Status
));
286 /******************************************************************************
287 * CloseEventLog [ADVAPI32.@]
290 CloseEventLog(IN HANDLE hEventLog
)
294 TRACE("%p\n", hEventLog
);
298 Status
= ElfrCloseEL(&hEventLog
);
300 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
302 Status
= I_RpcMapWin32Status(RpcExceptionCode());
306 if (!NT_SUCCESS(Status
))
308 SetLastError(RtlNtStatusToDosError(Status
));
315 /******************************************************************************
316 * ControlTraceW [ADVAPI32.@]
318 * Control a givel event trace session
321 ULONG WINAPI
ControlTraceW( TRACEHANDLE hSession
, LPCWSTR SessionName
, PEVENT_TRACE_PROPERTIES Properties
, ULONG control
)
323 FIXME("(%s, %s, %p, %d) stub\n", wine_dbgstr_longlong(hSession
), debugstr_w(SessionName
), Properties
, control
);
324 return ERROR_SUCCESS
;
327 /******************************************************************************
328 * ControlTraceA [ADVAPI32.@]
333 ULONG WINAPI
ControlTraceA( TRACEHANDLE hSession
, LPCSTR SessionName
, PEVENT_TRACE_PROPERTIES Properties
, ULONG control
)
335 FIXME("(%s, %s, %p, %d) stub\n", wine_dbgstr_longlong(hSession
), debugstr_a(SessionName
), Properties
, control
);
336 return ERROR_SUCCESS
;
339 /******************************************************************************
340 * DeregisterEventSource [ADVAPI32.@]
341 * Closes a handle to the specified event log
344 * hEventLog [I] Handle to event log
349 DeregisterEventSource(IN HANDLE hEventLog
)
353 TRACE("%p\n", hEventLog
);
357 Status
= ElfrDeregisterEventSource(&hEventLog
);
359 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
361 Status
= I_RpcMapWin32Status(RpcExceptionCode());
365 if (!NT_SUCCESS(Status
))
367 SetLastError(RtlNtStatusToDosError(Status
));
374 /******************************************************************************
375 * EnableTrace [ADVAPI32.@]
377 ULONG WINAPI
EnableTrace( ULONG enable
, ULONG flag
, ULONG level
, LPCGUID guid
, TRACEHANDLE hSession
)
379 FIXME("(%d, 0x%x, %d, %s, %s): stub\n", enable
, flag
, level
,
380 debugstr_guid(guid
), wine_dbgstr_longlong(hSession
));
382 return ERROR_SUCCESS
;
385 /******************************************************************************
386 * GetEventLogInformation [ADVAPI32.@]
389 * hEventLog [I] Handle to event log
390 * dwInfoLevel [I] Level of event log information to return
391 * lpBuffer [O] Buffer that receives the event log information
392 * cbBufSize [I] Size of the lpBuffer buffer
393 * pcbBytesNeeded [O] Required buffer size
396 GetEventLogInformation(IN HANDLE hEventLog
,
397 IN DWORD dwInfoLevel
,
400 OUT LPDWORD pcbBytesNeeded
)
404 if (dwInfoLevel
!= EVENTLOG_FULL_INFO
)
406 SetLastError(ERROR_INVALID_LEVEL
);
412 Status
= ElfrGetLogInformation(hEventLog
,
418 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
420 Status
= I_RpcMapWin32Status(RpcExceptionCode());
424 if (!NT_SUCCESS(Status
))
426 SetLastError(RtlNtStatusToDosError(Status
));
434 /******************************************************************************
435 * GetNumberOfEventLogRecords [ADVAPI32.@]
442 GetNumberOfEventLogRecords(IN HANDLE hEventLog
,
443 OUT PDWORD NumberOfRecords
)
448 TRACE("%p, %p\n", hEventLog
, NumberOfRecords
);
452 SetLastError(ERROR_INVALID_PARAMETER
);
458 Status
= ElfrNumberOfRecords(hEventLog
,
461 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
463 Status
= I_RpcMapWin32Status(RpcExceptionCode());
467 if (!NT_SUCCESS(Status
))
469 SetLastError(RtlNtStatusToDosError(Status
));
473 *NumberOfRecords
= Records
;
479 /******************************************************************************
480 * GetOldestEventLogRecord [ADVAPI32.@]
487 GetOldestEventLogRecord(IN HANDLE hEventLog
,
488 OUT PDWORD OldestRecord
)
493 TRACE("%p, %p\n", hEventLog
, OldestRecord
);
497 SetLastError(ERROR_INVALID_PARAMETER
);
503 Status
= ElfrOldestRecord(hEventLog
,
506 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
508 Status
= I_RpcMapWin32Status(RpcExceptionCode());
512 if (!NT_SUCCESS(Status
))
514 SetLastError(RtlNtStatusToDosError(Status
));
518 *OldestRecord
= Oldest
;
524 /******************************************************************************
525 * NotifyChangeEventLog [ADVAPI32.@]
532 NotifyChangeEventLog(IN HANDLE hEventLog
,
535 /* Use ElfrChangeNotify */
537 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
542 /******************************************************************************
543 * OpenBackupEventLogA [ADVAPI32.@]
546 OpenBackupEventLogA(IN LPCSTR lpUNCServerName
,
547 IN LPCSTR lpFileName
)
549 ANSI_STRING FileName
;
550 IELF_HANDLE LogHandle
;
553 TRACE("%s, %s\n", lpUNCServerName
, lpFileName
);
555 RtlInitAnsiString(&FileName
, lpFileName
);
559 Status
= ElfrOpenBELA((LPSTR
)lpUNCServerName
,
560 (PRPC_STRING
)&FileName
,
565 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
567 Status
= I_RpcMapWin32Status(RpcExceptionCode());
571 if (!NT_SUCCESS(Status
))
573 SetLastError(RtlNtStatusToDosError(Status
));
577 return (HANDLE
)LogHandle
;
581 /******************************************************************************
582 * OpenBackupEventLogW [ADVAPI32.@]
589 OpenBackupEventLogW(IN LPCWSTR lpUNCServerName
,
590 IN LPCWSTR lpFileName
)
592 UNICODE_STRING FileName
;
593 IELF_HANDLE LogHandle
;
596 TRACE("%s, %s\n", debugstr_w(lpUNCServerName
), debugstr_w(lpFileName
));
598 RtlInitUnicodeString(&FileName
, lpFileName
);
602 Status
= ElfrOpenBELW((LPWSTR
)lpUNCServerName
,
603 (PRPC_UNICODE_STRING
)&FileName
,
608 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
610 Status
= I_RpcMapWin32Status(RpcExceptionCode());
614 if (!NT_SUCCESS(Status
))
616 SetLastError(RtlNtStatusToDosError(Status
));
620 return (HANDLE
)LogHandle
;
624 /******************************************************************************
625 * OpenEventLogA [ADVAPI32.@]
627 * Opens a handle to the specified event log.
630 * lpUNCServerName [I] UNC name of the server on which the event log is
632 * lpSourceName [I] Name of the log.
635 * Success: Handle to an event log.
639 OpenEventLogA(IN LPCSTR lpUNCServerName
,
640 IN LPCSTR lpSourceName
)
643 ANSI_STRING SourceName
;
644 IELF_HANDLE LogHandle
= NULL
;
647 TRACE("%s, %s\n", lpUNCServerName
, lpSourceName
);
649 if (lpSourceName
== NULL
)
651 SetLastError(ERROR_INVALID_PARAMETER
);
655 if (lpUNCServerName
== NULL
|| *lpUNCServerName
== 0)
656 UNCServerName
= NULL
;
658 UNCServerName
= (LPSTR
)lpUNCServerName
;
660 RtlInitAnsiString(&SourceName
, lpSourceName
);
664 Status
= ElfrOpenELA(UNCServerName
,
665 (PRPC_STRING
)&SourceName
,
671 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
673 Status
= I_RpcMapWin32Status(RpcExceptionCode());
677 if (!NT_SUCCESS(Status
))
679 SetLastError(RtlNtStatusToDosError(Status
));
683 return (HANDLE
)LogHandle
;
687 /******************************************************************************
688 * OpenEventLogW [ADVAPI32.@]
695 OpenEventLogW(IN LPCWSTR lpUNCServerName
,
696 IN LPCWSTR lpSourceName
)
698 LPWSTR UNCServerName
;
699 UNICODE_STRING SourceName
;
700 IELF_HANDLE LogHandle
;
703 TRACE("%s, %s\n", debugstr_w(lpUNCServerName
), debugstr_w(lpSourceName
));
705 if (lpSourceName
== NULL
)
707 SetLastError(ERROR_INVALID_PARAMETER
);
711 if (lpUNCServerName
== NULL
|| *lpUNCServerName
== 0)
712 UNCServerName
= NULL
;
714 UNCServerName
= (LPWSTR
)lpUNCServerName
;
716 RtlInitUnicodeString(&SourceName
, lpSourceName
);
720 Status
= ElfrOpenELW(UNCServerName
,
721 (PRPC_UNICODE_STRING
)&SourceName
,
727 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
729 Status
= I_RpcMapWin32Status(RpcExceptionCode());
733 if (!NT_SUCCESS(Status
))
735 SetLastError(RtlNtStatusToDosError(Status
));
739 return (HANDLE
)LogHandle
;
742 /******************************************************************************
743 * QueryAllTracesW [ADVAPI32.@]
745 * Query information for started event trace sessions
748 ULONG WINAPI
QueryAllTracesW( PEVENT_TRACE_PROPERTIES
* parray
, ULONG arraycount
, PULONG psessioncount
)
750 FIXME("(%p, %d, %p) stub\n", parray
, arraycount
, psessioncount
);
752 if (psessioncount
) *psessioncount
= 0;
753 return ERROR_SUCCESS
;
756 /******************************************************************************
757 * QueryAllTracesA [ADVAPI32.@]
759 * See QueryAllTracesW.
761 ULONG WINAPI
QueryAllTracesA( PEVENT_TRACE_PROPERTIES
* parray
, ULONG arraycount
, PULONG psessioncount
)
763 FIXME("(%p, %d, %p) stub\n", parray
, arraycount
, psessioncount
);
765 if (psessioncount
) *psessioncount
= 0;
766 return ERROR_SUCCESS
;
769 /******************************************************************************
770 * ReadEventLogA [ADVAPI32.@]
773 ReadEventLogA(IN HANDLE hEventLog
,
774 IN DWORD dwReadFlags
,
775 IN DWORD dwRecordOffset
,
777 IN DWORD nNumberOfBytesToRead
,
778 OUT DWORD
*pnBytesRead
,
779 OUT DWORD
*pnMinNumberOfBytesNeeded
)
782 DWORD bytesRead
, minNumberOfBytesNeeded
;
784 TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n",
785 hEventLog
, dwReadFlags
, dwRecordOffset
, lpBuffer
,
786 nNumberOfBytesToRead
, pnBytesRead
, pnMinNumberOfBytesNeeded
);
788 if(!pnBytesRead
|| !pnMinNumberOfBytesNeeded
)
790 SetLastError(ERROR_INVALID_PARAMETER
);
794 /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from
795 trying to access a null pointer */
798 nNumberOfBytesToRead
= 0;
803 Status
= ElfrReadELA(hEventLog
,
806 nNumberOfBytesToRead
,
809 &minNumberOfBytesNeeded
);
811 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
813 Status
= I_RpcMapWin32Status(RpcExceptionCode());
817 *pnBytesRead
= (DWORD
)bytesRead
;
818 *pnMinNumberOfBytesNeeded
= (DWORD
)minNumberOfBytesNeeded
;
820 if (!NT_SUCCESS(Status
))
822 SetLastError(RtlNtStatusToDosError(Status
));
830 /******************************************************************************
831 * ReadEventLogW [ADVAPI32.@]
838 * nNumberOfBytesToRead []
840 * pnMinNumberOfBytesNeeded []
843 ReadEventLogW(IN HANDLE hEventLog
,
844 IN DWORD dwReadFlags
,
845 IN DWORD dwRecordOffset
,
847 IN DWORD nNumberOfBytesToRead
,
848 OUT DWORD
*pnBytesRead
,
849 OUT DWORD
*pnMinNumberOfBytesNeeded
)
852 DWORD bytesRead
, minNumberOfBytesNeeded
;
854 TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n",
855 hEventLog
, dwReadFlags
, dwRecordOffset
, lpBuffer
,
856 nNumberOfBytesToRead
, pnBytesRead
, pnMinNumberOfBytesNeeded
);
858 if(!pnBytesRead
|| !pnMinNumberOfBytesNeeded
)
860 SetLastError(ERROR_INVALID_PARAMETER
);
864 /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from
865 trying to access a null pointer */
868 nNumberOfBytesToRead
= 0;
873 Status
= ElfrReadELW(hEventLog
,
876 nNumberOfBytesToRead
,
879 &minNumberOfBytesNeeded
);
881 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
883 Status
= I_RpcMapWin32Status(RpcExceptionCode());
887 *pnBytesRead
= (DWORD
)bytesRead
;
888 *pnMinNumberOfBytesNeeded
= (DWORD
)minNumberOfBytesNeeded
;
890 if (!NT_SUCCESS(Status
))
892 SetLastError(RtlNtStatusToDosError(Status
));
900 /******************************************************************************
901 * RegisterEventSourceA [ADVAPI32.@]
904 RegisterEventSourceA(IN LPCSTR lpUNCServerName
,
905 IN LPCSTR lpSourceName
)
907 ANSI_STRING SourceName
;
908 IELF_HANDLE LogHandle
;
911 TRACE("%s, %s\n", lpUNCServerName
, lpSourceName
);
913 RtlInitAnsiString(&SourceName
, lpSourceName
);
917 Status
= ElfrRegisterEventSourceA((LPSTR
)lpUNCServerName
,
918 (PRPC_STRING
)&SourceName
,
924 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
926 Status
= I_RpcMapWin32Status(RpcExceptionCode());
930 if (!NT_SUCCESS(Status
))
932 SetLastError(RtlNtStatusToDosError(Status
));
936 return (HANDLE
)LogHandle
;
940 /******************************************************************************
941 * RegisterEventSourceW [ADVAPI32.@]
942 * Returns a registered handle to an event log
945 * lpUNCServerName [I] Server name for source
946 * lpSourceName [I] Source name for registered handle
953 RegisterEventSourceW(IN LPCWSTR lpUNCServerName
,
954 IN LPCWSTR lpSourceName
)
956 UNICODE_STRING SourceName
;
957 IELF_HANDLE LogHandle
;
960 TRACE("%s, %s\n", debugstr_w(lpUNCServerName
), debugstr_w(lpSourceName
));
962 RtlInitUnicodeString(&SourceName
, lpSourceName
);
966 Status
= ElfrRegisterEventSourceW((LPWSTR
)lpUNCServerName
,
967 (PRPC_UNICODE_STRING
)&SourceName
,
973 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
975 Status
= I_RpcMapWin32Status(RpcExceptionCode());
979 if (!NT_SUCCESS(Status
))
981 SetLastError(RtlNtStatusToDosError(Status
));
985 return (HANDLE
)LogHandle
;
989 /******************************************************************************
990 * ReportEventA [ADVAPI32.@]
993 ReportEventA(IN HANDLE hEventLog
,
1000 IN LPCSTR
*lpStrings
,
1001 IN LPVOID lpRawData
)
1004 ANSI_STRING
*Strings
;
1005 ANSI_STRING ComputerName
;
1007 CHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
1010 TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n",
1011 hEventLog
, wType
, wCategory
, dwEventID
, lpUserSid
,
1012 wNumStrings
, dwDataSize
, lpStrings
, lpRawData
);
1014 Strings
= HeapAlloc(GetProcessHeap(),
1016 wNumStrings
* sizeof(ANSI_STRING
));
1019 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1023 for (i
= 0; i
< wNumStrings
; i
++)
1024 RtlInitAnsiString(&Strings
[i
], lpStrings
[i
]);
1026 dwSize
= MAX_COMPUTERNAME_LENGTH
+ 1;
1027 GetComputerNameA(szComputerName
, &dwSize
);
1028 RtlInitAnsiString(&ComputerName
, szComputerName
);
1032 Status
= ElfrReportEventA(hEventLog
,
1033 0, /* FIXME: Time */
1039 (PRPC_STRING
) &ComputerName
,
1041 (PRPC_STRING
*) &Strings
,
1047 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1049 Status
= I_RpcMapWin32Status(RpcExceptionCode());
1053 HeapFree(GetProcessHeap(), 0, Strings
);
1055 if (!NT_SUCCESS(Status
))
1057 SetLastError(RtlNtStatusToDosError(Status
));
1065 /******************************************************************************
1066 * ReportEventW [ADVAPI32.@]
1080 ReportEventW(IN HANDLE hEventLog
,
1085 IN WORD wNumStrings
,
1086 IN DWORD dwDataSize
,
1087 IN LPCWSTR
*lpStrings
,
1088 IN LPVOID lpRawData
)
1091 UNICODE_STRING
*Strings
;
1092 UNICODE_STRING ComputerName
;
1094 WCHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
1097 TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n",
1098 hEventLog
, wType
, wCategory
, dwEventID
, lpUserSid
,
1099 wNumStrings
, dwDataSize
, lpStrings
, lpRawData
);
1101 Strings
= HeapAlloc(GetProcessHeap(),
1103 wNumStrings
* sizeof(UNICODE_STRING
));
1106 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1110 for (i
= 0; i
< wNumStrings
; i
++)
1111 RtlInitUnicodeString(&Strings
[i
], lpStrings
[i
]);
1113 dwSize
= MAX_COMPUTERNAME_LENGTH
+ 1;
1114 GetComputerNameW(szComputerName
, &dwSize
);
1115 RtlInitUnicodeString(&ComputerName
, szComputerName
);
1119 Status
= ElfrReportEventW(hEventLog
,
1120 0, /* FIXME: Time */
1126 (PRPC_UNICODE_STRING
) &ComputerName
,
1128 (PRPC_UNICODE_STRING
*) &Strings
,
1134 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1136 Status
= I_RpcMapWin32Status(RpcExceptionCode());
1140 HeapFree(GetProcessHeap(), 0, Strings
);
1142 if (!NT_SUCCESS(Status
))
1144 SetLastError(RtlNtStatusToDosError(Status
));