ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
462 discussions
Start a n
N
ew thread
[ekohl] 72218: [LSASRV] Implement LsaIFree_LSAPR_CR_CIPHER_VALUE, LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER and LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST.
by ekohl@svn.reactos.org
Author: ekohl Date: Sun Aug 14 10:26:23 2016 New Revision: 72218 URL:
http://svn.reactos.org/svn/reactos?rev=72218&view=rev
Log: [LSASRV] Implement LsaIFree_LSAPR_CR_CIPHER_VALUE, LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER and LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST. Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.c trunk/reactos/dll/win32/lsasrv/lsasrv.spec Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] Sun Aug 14 10:26:23 2016 @@ -36,6 +36,16 @@ VOID NTAPI +LsaIFree_LSAPR_CR_CIPHER_VALUE( + IN PLSAPR_CR_CIPHER_VALUE Ptr) +{ + if (Ptr != NULL) + midl_user_free(Ptr); +} + + +VOID +NTAPI LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, IN PLSAPR_POLICY_INFORMATION PolicyInformation) { @@ -143,10 +153,61 @@ VOID NTAPI +LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER( + IN PLSAPR_PRIVILEGE_ENUM_BUFFER Ptr) +{ + ULONG i; + + if (Ptr != NULL) + { + if (Ptr->Privileges != NULL) + { + for (i = 0; i < Ptr->Entries; i++) + { + if (Ptr->Privileges[i].Name.Buffer != NULL) + midl_user_free(Ptr->Privileges[i].Name.Buffer); + } + + midl_user_free(Ptr->Privileges); + } + } +} + + +VOID +NTAPI LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr) { if (Ptr != NULL) { + midl_user_free(Ptr); + } +} + + +VOID +NTAPI +LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST( + IN PLSAPR_REFERENCED_DOMAIN_LIST Ptr) +{ + ULONG i; + + if (Ptr != NULL) + { + if (Ptr->Domains != NULL) + { + for (i = 0; i < Ptr->Entries; i++) + { + if (Ptr->Domains[i].Name.Buffer != NULL) + midl_user_free(Ptr->Domains[i].Name.Buffer); + + if (Ptr->Domains[i].Sid != NULL) + midl_user_free(Ptr->Domains[i].Sid); + } + + midl_user_free(Ptr->Domains); + } + midl_user_free(Ptr); } } Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.sp…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.spec [iso-8859-1] Sun Aug 14 10:26:23 2016 @@ -32,12 +32,12 @@ @ stub LsaIFree_LSAI_PRIVATE_DATA #DATA @ stub LsaIFree_LSAI_SECRET_ENUM_BUFFER @ stdcall LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER(ptr) - @ stub LsaIFree_LSAPR_CR_CIPHER_VALUE + @ stdcall LsaIFree_LSAPR_CR_CIPHER_VALUE(ptr) @ stub LsaIFree_LSAPR_POLICY_DOMAIN_INFORMATION @ stdcall LsaIFree_LSAPR_POLICY_INFORMATION(long ptr) - @ stub LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER + @ stdcall LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER(ptr) @ stdcall LsaIFree_LSAPR_PRIVILEGE_SET(ptr) - @ stub LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST + @ stdcall LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST(ptr) @ stub LsaIFree_LSAPR_SR_SECURITY_DESCRIPTOR @ stub LsaIFree_LSAPR_TRANSLATED_NAMES @ stub LsaIFree_LSAPR_TRANSLATED_SIDS
8 years, 4 months
1
0
0
0
[ekohl] 72217: [SYSSETUP] InstallPrivileges: - Use LsaAddAccountRights instead of LsaAddPrivilegesToAccount. This enables us to add privileges and user rights to a given account. - Identify SIDs by...
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Aug 13 19:25:31 2016 New Revision: 72217 URL:
http://svn.reactos.org/svn/reactos?rev=72217&view=rev
Log: [SYSSETUP] InstallPrivileges: - Use LsaAddAccountRights instead of LsaAddPrivilegesToAccount. This enables us to add privileges and user rights to a given account. - Identify SIDs by a leading asterisk. Account names do not start with an asterisk. defltws.inf: - Add user rights. - Add an asterisk before all SIDs. Modified: trunk/reactos/dll/win32/syssetup/security.c trunk/reactos/media/inf/defltws.inf Modified: trunk/reactos/dll/win32/syssetup/security.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/securit…
============================================================================== --- trunk/reactos/dll/win32/syssetup/security.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/security.c [iso-8859-1] Sat Aug 13 19:25:31 2016 @@ -279,11 +279,11 @@ WCHAR szSidString[256]; INFCONTEXT InfContext; DWORD i; - PRIVILEGE_SET PrivilegeSet; - PSID AccountSid; + PSID AccountSid = NULL; NTSTATUS Status; LSA_HANDLE PolicyHandle = NULL; - LSA_HANDLE AccountHandle; + LSA_UNICODE_STRING RightString; + PLSA_TRANSLATED_SID2 Sids = NULL; DPRINT("InstallPrivileges()\n"); @@ -301,7 +301,7 @@ Status = LsaOpenPolicy(NULL, &ObjectAttributes, - POLICY_CREATE_ACCOUNT, + POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES, &PolicyHandle); if (!NT_SUCCESS(Status)) { @@ -317,9 +317,6 @@ DPRINT1("SetupFindfirstLineW failed\n"); goto done; } - - PrivilegeSet.PrivilegeCount = 1; - PrivilegeSet.Control = 0; do { @@ -334,16 +331,6 @@ goto done; } DPRINT("Privilege: %S\n", szPrivilegeString); - - if (!LookupPrivilegeValueW(NULL, - szPrivilegeString, - &(PrivilegeSet.Privilege[0].Luid))) - { - DPRINT1("LookupPrivilegeNameW() failed\n"); - goto done; - } - - PrivilegeSet.Privilege[0].Attributes = 0; for (i = 0; i < SetupGetFieldCount(&InfContext); i++) { @@ -358,29 +345,47 @@ } DPRINT("SID: %S\n", szSidString); - if (!ConvertStringSidToSid(szSidString, &AccountSid)) + if (szSidString[0] == UNICODE_NULL) + continue; + + if (szSidString[0] == L'*') { - DPRINT1("ConvertStringSidToSid(%S) failed: %lu\n", szSidString, GetLastError()); + DPRINT("Account Sid: %S\n", &szSidString[1]); + + if (!ConvertStringSidToSid(&szSidString[1], &AccountSid)) + { + DPRINT1("ConvertStringSidToSid(%S) failed: %lu\n", szSidString, GetLastError()); + continue; + } + } + else + { + DPRINT("Account name: %S\n", szSidString); continue; + } - Status = LsaOpenAccount(PolicyHandle, - AccountSid, - ACCOUNT_VIEW | ACCOUNT_ADJUST_PRIVILEGES, - &AccountHandle); - if (NT_SUCCESS(Status)) + RtlInitUnicodeString(&RightString, szPrivilegeString); + Status = LsaAddAccountRights(PolicyHandle, + (AccountSid != NULL) ? AccountSid : Sids[0].Sid, + &RightString, + 1); + if (!NT_SUCCESS(Status)) { - Status = LsaAddPrivilegesToAccount(AccountHandle, - &PrivilegeSet); - if (!NT_SUCCESS(Status)) - { - DPRINT1("LsaAddPrivilegesToAccount() failed (Status %08lx)\n", Status); - } - - LsaClose(AccountHandle); + DPRINT1("LsaAddAccountRights() failed (Status %08lx)\n", Status); } - LocalFree(AccountSid); + if (Sids != NULL) + { + LsaFreeMemory(Sids); + Sids = NULL; + } + + if (AccountSid != NULL) + { + LocalFree(AccountSid); + AccountSid = NULL; + } } } Modified: trunk/reactos/media/inf/defltws.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/defltws.inf?rev=…
============================================================================== Binary files - no diff available.
8 years, 4 months
1
0
0
0
[ekohl] 72216: [LSASRV] Implement LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER and fix a typo.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Aug 13 17:15:04 2016 New Revision: 72216 URL:
http://svn.reactos.org/svn/reactos?rev=72216&view=rev
Log: [LSASRV] Implement LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER and fix a typo. Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.c trunk/reactos/dll/win32/lsasrv/lsasrv.spec Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.c [iso-8859-1] Sat Aug 13 17:15:04 2016 @@ -11,6 +11,28 @@ #include "lsasrv.h" /* FUNCTIONS ***************************************************************/ + +VOID +NTAPI +LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER( + IN PLSAPR_ACCOUNT_ENUM_BUFFER Ptr) +{ + ULONG i; + + if (Ptr == NULL) + return; + + if (Ptr->Information != NULL) + { + for (i = 0; i < Ptr->EntriesRead; i++) + midl_user_free(Ptr->Information[i].Sid); + + midl_user_free(Ptr->Information); + } + + midl_user_free(Ptr); +} + VOID NTAPI Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.sp…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.spec [iso-8859-1] Sat Aug 13 17:15:04 2016 @@ -31,9 +31,9 @@ @ stub LsaIFreeReturnBuffer @ stub LsaIFree_LSAI_PRIVATE_DATA #DATA @ stub LsaIFree_LSAI_SECRET_ENUM_BUFFER - @ stub LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER + @ stdcall LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER(ptr) @ stub LsaIFree_LSAPR_CR_CIPHER_VALUE - @ stub LsaIFree_LSAPR_POLICY_DOMIN_INFORMATION + @ stub LsaIFree_LSAPR_POLICY_DOMAIN_INFORMATION @ stdcall LsaIFree_LSAPR_POLICY_INFORMATION(long ptr) @ stub LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER @ stdcall LsaIFree_LSAPR_PRIVILEGE_SET(ptr)
8 years, 4 months
1
0
0
0
[ekohl] 72215: [LSASRV] - LsapRegQueryKeyInfo: Return the maximum sub key name length too. - LsarEnumerateAccounts: User the maximum sub key name length to allocate a large enough buffer instead of...
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Aug 13 16:26:23 2016 New Revision: 72215 URL:
http://svn.reactos.org/svn/reactos?rev=72215&view=rev
Log: [LSASRV] - LsapRegQueryKeyInfo: Return the maximum sub key name length too. - LsarEnumerateAccounts: User the maximum sub key name length to allocate a large enough buffer instead of using a fixed size one. - LsarAddAccountRights: Use the proper value size to retrieve the system access attribute. Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c trunk/reactos/dll/win32/lsasrv/lsasrv.h trunk/reactos/dll/win32/lsasrv/registry.c Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Sat Aug 13 16:26:23 2016 @@ -654,10 +654,11 @@ { LSAPR_ACCOUNT_ENUM_BUFFER EnumBuffer = {0, NULL}; PLSA_DB_OBJECT PolicyObject = NULL; - WCHAR AccountKeyName[64]; + PWSTR AccountKeyBuffer = NULL; HANDLE AccountsKeyHandle = NULL; HANDLE AccountKeyHandle; HANDLE SidKeyHandle; + ULONG AccountKeyBufferSize; ULONG EnumIndex; ULONG EnumCount; ULONG RequiredLength; @@ -693,6 +694,23 @@ if (!NT_SUCCESS(Status)) return Status; + Status = LsapRegQueryKeyInfo(AccountsKeyHandle, + NULL, + &AccountKeyBufferSize, + NULL); + if (!NT_SUCCESS(Status)) + { + ERR("LsapRegQueryKeyInfo returned 0x%08lx\n", Status); + return Status; + } + + AccountKeyBufferSize += sizeof(WCHAR); + AccountKeyBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AccountKeyBufferSize); + if (AccountKeyBuffer == NULL) + { + return STATUS_NO_MEMORY; + } + EnumIndex = *EnumerationContext; EnumCount = 0; RequiredLength = 0; @@ -701,16 +719,16 @@ { Status = LsapRegEnumerateSubKey(AccountsKeyHandle, EnumIndex, - 64 * sizeof(WCHAR), - AccountKeyName); + AccountKeyBufferSize, + AccountKeyBuffer); if (!NT_SUCCESS(Status)) break; TRACE("EnumIndex: %lu\n", EnumIndex); - TRACE("Account key name: %S\n", AccountKeyName); + TRACE("Account key name: %S\n", AccountKeyBuffer); Status = LsapRegOpenKey(AccountsKeyHandle, - AccountKeyName, + AccountKeyBuffer, KEY_READ, &AccountKeyHandle); TRACE("LsapRegOpenKey returned %08lX\n", Status); @@ -766,16 +784,16 @@ { Status = LsapRegEnumerateSubKey(AccountsKeyHandle, EnumIndex, - 64 * sizeof(WCHAR), - AccountKeyName); + AccountKeyBufferSize, + AccountKeyBuffer); if (!NT_SUCCESS(Status)) break; TRACE("EnumIndex: %lu\n", EnumIndex); - TRACE("Account key name: %S\n", AccountKeyName); + TRACE("Account key name: %S\n", AccountKeyBuffer); Status = LsapRegOpenKey(AccountsKeyHandle, - AccountKeyName, + AccountKeyBuffer, KEY_READ, &AccountKeyHandle); TRACE("LsapRegOpenKey returned %08lX\n", Status); @@ -845,6 +863,9 @@ } } + if (AccountKeyBuffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AccountKeyBuffer); + if (AccountsKeyHandle != NULL) LsapRegCloseKey(AccountsKeyHandle); @@ -2520,7 +2541,7 @@ if (ulNewRights > 0) { - Size = 0; + Size = sizeof(ACCESS_MASK); /* Get the system access flags, if the attribute exists */ Status = LsapGetObjectAttribute(AccountObject, Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sat Aug 13 16:26:23 2016 @@ -364,6 +364,7 @@ NTSTATUS LsapRegQueryKeyInfo(IN HANDLE KeyHandle, OUT PULONG SubKeyCount, + OUT PULONG MaxSubKeyNameLength, OUT PULONG ValueCount); NTSTATUS Modified: trunk/reactos/dll/win32/lsasrv/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/registry.…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/registry.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/registry.c [iso-8859-1] Sat Aug 13 16:26:23 2016 @@ -175,6 +175,7 @@ NTSTATUS LsapRegQueryKeyInfo(IN HANDLE KeyHandle, OUT PULONG SubKeyCount, + OUT PULONG MaxSubKeyNameLength, OUT PULONG ValueCount) { KEY_FULL_INFORMATION FullInfoBuffer; @@ -195,6 +196,9 @@ if (SubKeyCount != NULL) *SubKeyCount = FullInfoBuffer.SubKeys; + + if (MaxSubKeyNameLength != NULL) + *MaxSubKeyNameLength = FullInfoBuffer.MaxNameLen; if (ValueCount != NULL) *ValueCount = FullInfoBuffer.Values;
8 years, 4 months
1
0
0
0
[mjansen] 72214: [CRT][CRT_APITEST] Fix __getmainargs and __wgetmainargs parsing, verified with apitests. Patch by Yaroslav Veremenko. CORE-11673 #resolve #comment Thanks!
by mjansen@svn.reactos.org
Author: mjansen Date: Fri Aug 12 21:31:32 2016 New Revision: 72214 URL:
http://svn.reactos.org/svn/reactos?rev=72214&view=rev
Log: [CRT][CRT_APITEST] Fix __getmainargs and __wgetmainargs parsing, verified with apitests. Patch by Yaroslav Veremenko. CORE-11673 #resolve #comment Thanks! Added: trunk/rostests/apitests/crt/__getmainargs.c (with props) Modified: trunk/reactos/sdk/lib/crt/misc/getargs.c trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake trunk/rostests/apitests/crt/testlist.c Modified: trunk/reactos/sdk/lib/crt/misc/getargs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/crt/misc/getargs.c…
============================================================================== --- trunk/reactos/sdk/lib/crt/misc/getargs.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/crt/misc/getargs.c [iso-8859-1] Fri Aug 12 21:31:32 2016 @@ -181,16 +181,18 @@ */ void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode) { - int i, afterlastspace, ignorespace, doexpand; + int i, doexpand, slashesAdded, escapedQuote, inQuotes, bufferIndex; size_t len; - char* aNewCmdln; + char* buffer; /* missing threading init */ i = 0; - afterlastspace = 0; - ignorespace = 0; doexpand = expand_wildcards; + escapedQuote = FALSE; + slashesAdded = 0; + inQuotes = 0; + bufferIndex = 0; if (__argv && _environ) { @@ -203,58 +205,94 @@ __argc = 0; len = strlen(_acmdln); - - /* Allocate a temporary buffer to be used instead of the original _acmdln parameter. */ - aNewCmdln = strndup(_acmdln, len); - - while (aNewCmdln[i]) - { - if (aNewCmdln[i] == '"') - { - if(ignorespace) - { - ignorespace = 0; - } - else - { - ignorespace = 1; - doexpand = 0; - } - memmove(aNewCmdln + i, aNewCmdln + i + 1, len - i); - len--; - continue; - } - - if (aNewCmdln[i] == ' ' && !ignorespace) - { - aexpand(strndup(aNewCmdln + afterlastspace, i - afterlastspace), doexpand); - i++; - while (aNewCmdln[i] == ' ') - i++; - afterlastspace=i; - doexpand = expand_wildcards; - } - else - { - i++; - } - } - - if (aNewCmdln[afterlastspace] != 0) - { - aexpand(strndup(aNewCmdln + afterlastspace, i - afterlastspace), doexpand); + buffer = malloc(sizeof(char) * len); + + // Reference:
https://msdn.microsoft.com/en-us/library/a1y7w461(v=vs.71).aspx
+ while (TRUE) + { + // Arguments are delimited by white space, which is either a space or a tab. + if (i >= len || ((_acmdln[i] == ' ' || _acmdln[i] == '\t') && !inQuotes)) + { + aexpand(strndup(buffer, bufferIndex), doexpand); + // Copy the last element from buffer and quit the loop + if (i >= len) + { + break; + } + + while (_acmdln[i] == ' ' || _acmdln[i] == '\t') + ++i; + bufferIndex = 0; + slashesAdded = 0; + escapedQuote = FALSE; + continue; + } + + if (_acmdln[i] == '\\') + { + buffer[bufferIndex++] = _acmdln[i]; + ++slashesAdded; + ++i; + escapedQuote = FALSE; + continue; + } + + if (_acmdln[i] == '\"') + { + if (slashesAdded > 0) + { + if (slashesAdded % 2 == 0) + { + // If an even number of backslashes is followed by a double quotation mark, then one backslash (\) + // is placed in the argv array for every pair of backslashes (\\), and the double quotation mark (") + // is interpreted as a string delimiter. + bufferIndex -= slashesAdded / 2; + } + else + { + // If an odd number of backslashes is followed by a double quotation mark, then one backslash (\) + // is placed in the argv array for every pair of backslashes (\\) and the double quotation mark is + // interpreted as an escape sequence by the remaining backslash, causing a literal double quotation mark (") + // to be placed in argv. + bufferIndex -= slashesAdded / 2 + 1; + buffer[bufferIndex++] = '\"'; + slashesAdded = 0; + escapedQuote = TRUE; + ++i; + continue; + } + slashesAdded = 0; + } + else if (!inQuotes && i > 0 && _acmdln[i - 1] == '\"' && !escapedQuote) + { + buffer[bufferIndex++] = '\"'; + ++i; + escapedQuote = TRUE; + continue; + } + slashesAdded = 0; + escapedQuote = FALSE; + inQuotes = !inQuotes; + doexpand = inQuotes ? FALSE : expand_wildcards; + ++i; + continue; + } + + buffer[bufferIndex++] = _acmdln[i]; + slashesAdded = 0; + escapedQuote = FALSE; + ++i; } /* Free the temporary buffer. */ - free(aNewCmdln); - + free(buffer); HeapValidate(GetProcessHeap(), 0, NULL); *argc = __argc; if (__argv == NULL) { - __argv = (char**)malloc(sizeof(char*)); - __argv[0] = 0; + __argv = (char**)malloc(sizeof(char*)); + __argv[0] = 0; } *argv = __argv; *env = _environ; @@ -269,16 +307,18 @@ void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv, int expand_wildcards, int* new_mode) { - int i, afterlastspace, ignorespace, doexpand; + int i, doexpand, slashesAdded, escapedQuote, inQuotes, bufferIndex; size_t len; - wchar_t* wNewCmdln; + wchar_t* buffer; /* missing threading init */ i = 0; - afterlastspace = 0; - ignorespace = 0; doexpand = expand_wildcards; + escapedQuote = FALSE; + slashesAdded = 0; + inQuotes = 0; + bufferIndex = 0; if (__wargv && __winitenv) { @@ -291,58 +331,95 @@ __argc = 0; len = wcslen(_wcmdln); - - /* Allocate a temporary buffer to be used instead of the original _wcmdln parameter. */ - wNewCmdln = wcsndup(_wcmdln, len); - - while (wNewCmdln[i]) - { - if (wNewCmdln[i] == L'"') - { - if(ignorespace) - { - ignorespace = 0; - } - else - { - ignorespace = 1; - doexpand = 0; - } - memmove(wNewCmdln + i, wNewCmdln + i + 1, (len - i) * sizeof(wchar_t)); - len--; - continue; - } - - if (wNewCmdln[i] == L' ' && !ignorespace) - { - wexpand(wcsndup(wNewCmdln + afterlastspace, i - afterlastspace), doexpand); - i++; - while (wNewCmdln[i] == L' ') - i++; - afterlastspace=i; - doexpand = expand_wildcards; - } - else - { - i++; - } - } - - if (wNewCmdln[afterlastspace] != 0) - { - wexpand(wcsndup(wNewCmdln + afterlastspace, i - afterlastspace), doexpand); + buffer = malloc(sizeof(wchar_t) * len); + + // Reference:
https://msdn.microsoft.com/en-us/library/a1y7w461(v=vs.71).aspx
+ while (TRUE) + { + // Arguments are delimited by white space, which is either a space or a tab. + if (i >= len || ((_wcmdln[i] == ' ' || _wcmdln[i] == '\t') && !inQuotes)) + { + wexpand(wcsndup(buffer, bufferIndex), doexpand); + // Copy the last element from buffer and quit the loop + if (i >= len) + { + break; + } + + while (_wcmdln[i] == ' ' || _wcmdln[i] == '\t') + ++i; + bufferIndex = 0; + slashesAdded = 0; + escapedQuote = FALSE; + continue; + } + + if (_wcmdln[i] == '\\') + { + buffer[bufferIndex++] = _wcmdln[i]; + ++slashesAdded; + ++i; + escapedQuote = FALSE; + continue; + } + + if (_wcmdln[i] == '\"') + { + if (slashesAdded > 0) + { + if (slashesAdded % 2 == 0) + { + // If an even number of backslashes is followed by a double quotation mark, then one backslash (\) + // is placed in the argv array for every pair of backslashes (\\), and the double quotation mark (") + // is interpreted as a string delimiter. + bufferIndex -= slashesAdded / 2; + } + else + { + // If an odd number of backslashes is followed by a double quotation mark, then one backslash (\) + // is placed in the argv array for every pair of backslashes (\\) and the double quotation mark is + // interpreted as an escape sequence by the remaining backslash, causing a literal double quotation mark (") + // to be placed in argv. + bufferIndex -= slashesAdded / 2 + 1; + buffer[bufferIndex++] = '\"'; + slashesAdded = 0; + escapedQuote = TRUE; + ++i; + continue; + } + slashesAdded = 0; + } + else if (!inQuotes && i > 0 && _wcmdln[i - 1] == '\"' && !escapedQuote) + { + buffer[bufferIndex++] = '\"'; + ++i; + escapedQuote = TRUE; + continue; + } + slashesAdded = 0; + escapedQuote = FALSE; + inQuotes = !inQuotes; + doexpand = inQuotes ? FALSE : expand_wildcards; + ++i; + continue; + } + + buffer[bufferIndex++] = _wcmdln[i]; + slashesAdded = 0; + escapedQuote = FALSE; + ++i; } /* Free the temporary buffer. */ - free(wNewCmdln); + free(buffer); HeapValidate(GetProcessHeap(), 0, NULL); *argc = __argc; if (__wargv == NULL) { - __wargv = (wchar_t**)malloc(sizeof(wchar_t*)); - __wargv[0] = 0; + __wargv = (wchar_t**)malloc(sizeof(wchar_t*)); + __wargv[0] = 0; } *wargv = __wargv; *wenv = __winitenv; Added: trunk/rostests/apitests/crt/__getmainargs.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/__getmainarg…
============================================================================== --- trunk/rostests/apitests/crt/__getmainargs.c (added) +++ trunk/rostests/apitests/crt/__getmainargs.c [iso-8859-1] Fri Aug 12 21:31:32 2016 @@ -0,0 +1,100 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for __getmainargs and __wgetmainargs + * PROGRAMMER: Yaroslav Veremenko <yaroslav(a)veremenko.info> + */ + +#include <apitest.h> +#include <stdio.h> +#include <string.h> + + +const char **__p__acmdln(void); +void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode); +const wchar_t **__p__wcmdln(void); +void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv, int expand_wildcards, int* new_mode); + + +#define winetest_ok_str(x, y) \ + winetest_ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x) +#define winetest_ok_wstr(x, y) \ + winetest_ok(wcscmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", wine_dbgstr_w(y), wine_dbgstr_w(x)) +#define ok_argsA (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_argsA_imp +#define ok_argsW (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_argsW_imp + + +void +ok_argsA_imp(const char* input_args, const char* arg1, const char* arg2, const char* arg3) +{ + int argc = 0, mode = 0; + char** argv, **env; + + /* Remove cached argv, setup our input as program argument. */ + *__p___argv() = NULL; + *__p__acmdln() = input_args; + + /* Process the commandline stored in _acmdln */ + __getmainargs(&argc, &argv, &env, 0, &mode); + + winetest_ok(argc == 4, "Wrong value for argc, expected: 4, got: %d\n", argc); + if(argc != 4) + return; + + winetest_ok_str(argv[0], "test.exe"); + winetest_ok_str(argv[1], arg1); + winetest_ok_str(argv[2], arg2); + winetest_ok_str(argv[3], arg3); +} + +void +ok_argsW_imp(const wchar_t* input_args, const wchar_t* arg1, const wchar_t* arg2, const wchar_t* arg3) +{ + int argc = 0, mode = 0; + wchar_t** argv, **env; + + /* Remove cached wargv, setup our input as program argument. */ + *__p___wargv() = NULL; + *__p__wcmdln() = input_args; + + /* Process the commandline stored in _wcmdln */ + __wgetmainargs(&argc, &argv, &env, 0, &mode); + + winetest_ok(argc == 4, "Wrong value for argc, expected: 4, got: %d\n", argc); + if(argc != 4) + return; + + winetest_ok_wstr(argv[0], L"test.exe"); + winetest_ok_wstr(argv[1], arg1); + winetest_ok_wstr(argv[2], arg2); + winetest_ok_wstr(argv[3], arg3); +} + +START_TEST(__getmainargs) +{ + ok_argsA("test.exe \"a b c\" d e", "a b c", "d", "e"); + ok_argsA("test.exe \"ab\\\"c\" \"\\\\\" d", "ab\"c", "\\", "d"); + ok_argsA("test.exe a\\\\\\b d\"e f\"g h", "a\\\\\\b", "de fg", "h"); + ok_argsA("test.exe a\\\\\\\"b c d", "a\\\"b", "c", "d"); + ok_argsA("test.exe a\\\\\\\\\"b c\" d e", "a\\\\b c", "d", "e"); + ok_argsA("test.exe a b \"\"", "a", "b", ""); + ok_argsA("test.exe a \"\" b", "a", "", "b"); + ok_argsA("test.exe a \"b\"\" c", "a", "b\"", "c"); + ok_argsA("test.exe a \"b\\\"\" c", "a", "b\"", "c"); + ok_argsA("test.exe a \" b\\ \"\" c", "a", " b\\ \"", "c"); + ok_argsA("test.exe a \"b\\ \"\"\" c\" d", "a", "b\\ \" c", "d"); + ok_argsA("test.exe a \"b\\ \"\"\" \"c \"\"\"\" d", "a", "b\\ \" c", "\" d"); + + ok_argsW(L"test.exe \"a b c\" d e", L"a b c", L"d", L"e"); + ok_argsW(L"test.exe \"ab\\\"c\" \"\\\\\" d", L"ab\"c", L"\\", L"d"); + ok_argsW(L"test.exe a\\\\\\b d\"e f\"g h", L"a\\\\\\b", L"de fg", L"h"); + ok_argsW(L"test.exe a\\\\\\\"b c d", L"a\\\"b", L"c", L"d"); + ok_argsW(L"test.exe a\\\\\\\\\"b c\" d e", L"a\\\\b c", L"d", L"e"); + ok_argsW(L"test.exe a b \"\"", L"a", L"b", L""); + ok_argsW(L"test.exe a \"\" b", L"a", L"", L"b"); + ok_argsW(L"test.exe a \"b\"\" c", L"a", L"b\"", L"c"); + ok_argsW(L"test.exe a \"b\\\"\" c", L"a", L"b\"", L"c"); + ok_argsW(L"test.exe a \" b\\ \"\" c", L"a", L" b\\ \"", L"c"); + ok_argsW(L"test.exe a \"b\\ \"\"\" c\" d", L"a", L"b\\ \" c", L"d"); + ok_argsW(L"test.exe a \"b\\ \"\"\" \"c \"\"\"\" d", L"a", L"b\\ \" c", L"\" d"); +} Propchange: trunk/rostests/apitests/crt/__getmainargs.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/msvcrt_crt_a…
============================================================================== --- trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] (original) +++ trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] Fri Aug 12 21:31:32 2016 @@ -66,7 +66,7 @@ # __doserrno.c # __fpecode.c # __get_app_type.c -# __getmainargs.c + __getmainargs.c # __initenv # __iob_func.c # __isascii.c Modified: trunk/rostests/apitests/crt/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/testlist.c?r…
============================================================================== --- trunk/rostests/apitests/crt/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/crt/testlist.c [iso-8859-1] Fri Aug 12 21:31:32 2016 @@ -25,6 +25,7 @@ extern void func_wcsnlen(void); extern void func_wcstombs(void); extern void func_wcstoul(void); +extern void func___getmainargs(void); extern void func_static_construct(void); extern void func_static_init(void); @@ -50,6 +51,7 @@ #endif #if defined(TEST_STATIC_CRT) #elif defined(TEST_MSVCRT) + { "__getmainargs", func___getmainargs }, { "_vscprintf", func__vscprintf }, { "_vscwprintf", func__vscwprintf },
8 years, 4 months
1
0
0
0
[hbelusca] 72213: [EVENTLOG] - Use NT functions to retrieve timestamps for events. - Log kernel events with the current computer name. - Don't hardcode variables types for sizeofs. - Add type-check...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Aug 12 19:14:55 2016 New Revision: 72213 URL:
http://svn.reactos.org/svn/reactos?rev=72213&view=rev
Log: [EVENTLOG] - Use NT functions to retrieve timestamps for events. - Log kernel events with the current computer name. - Don't hardcode variables types for sizeofs. - Add type-checks for the data to be retrieved from the registry, and use default values in case the values do not exist or are invalid. - Use ULONG_PTR to perform pointer arithmetics. - Use string-safe functions for copy/concatenation. - Cache EventLog source for eventlog service self-logging. - Unlock the LogFile in LogfClearFile. - Fix rounding in LogfAllocAndBuildNewRecord. - Verify ELF handle validity in ElfrGetLogInformation. - Implement IELF_HANDLE_rundown to correctly cleanup ELF handles when client apps shut down. Adapt also the parameter of ElfDeleteEventLogHandle for reusing it there. - Update some code formatting. CORE-11842 #resolve I don't completely touch file.c as it contains most of my upcoming eventlog fixes... Modified: trunk/reactos/base/services/eventlog/eventlog.c trunk/reactos/base/services/eventlog/eventlog.h trunk/reactos/base/services/eventlog/eventsource.c trunk/reactos/base/services/eventlog/file.c trunk/reactos/base/services/eventlog/logport.c trunk/reactos/base/services/eventlog/rpc.c Modified: trunk/reactos/base/services/eventlog/eventlog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
============================================================================== --- trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -33,6 +33,8 @@ BOOL onLiveCD = FALSE; // On livecd events will go to debug output only HANDLE MyHeap = NULL; +PEVENTSOURCE EventLogSource = NULL; + /* FUNCTIONS ****************************************************************/ static VOID @@ -74,7 +76,6 @@ 0, EVENT_EventlogStopped, 0, NULL, 0, NULL); - /* Stop listening to incoming RPC messages */ RpcMgmtStopServerListening(NULL); UpdateServiceStatus(SERVICE_STOPPED); @@ -120,15 +121,13 @@ hThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) - PortThreadRoutine, + (LPTHREAD_START_ROUTINE)PortThreadRoutine, NULL, 0, NULL); - if (!hThread) { - DPRINT("Can't create PortThread\n"); + DPRINT("Cannot create PortThread\n"); return GetLastError(); } else @@ -136,15 +135,14 @@ hThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) - RpcThreadRoutine, + RpcThreadRoutine, NULL, 0, NULL); if (!hThread) { - DPRINT("Can't create RpcThread\n"); + DPRINT("Cannot create RpcThread\n"); return GetLastError(); } else @@ -165,14 +163,14 @@ DWORD dwType; LONG lResult = ERROR_SUCCESS; - ZeroMemory(&versionInfo, sizeof(OSVERSIONINFO)); - versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + ZeroMemory(&versionInfo, sizeof(versionInfo)); + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); /* Get version information */ if (!GetVersionExW(&versionInfo)) return; - ZeroMemory(szBuffer, 512 * sizeof(WCHAR)); + ZeroMemory(szBuffer, sizeof(szBuffer)); /* Write version into the buffer */ dwLength = swprintf(szBuffer, @@ -197,7 +195,7 @@ &hKey); if (lResult == ERROR_SUCCESS) { - dwValueLength = 512 - dwLength; + dwValueLength = ARRAYSIZE(szBuffer) - dwLength; lResult = RegQueryValueEx(hKey, L"CurrentType", NULL, @@ -268,7 +266,8 @@ } -PLOGFILE LoadLogFile(HKEY hKey, WCHAR * LogName) +static PLOGFILE +LoadLogFile(HKEY hKey, WCHAR* LogName) { DWORD MaxValueLen, ValueLen, Type, ExpandedLen; WCHAR *Buf = NULL, *Expanded = NULL; @@ -280,58 +279,81 @@ DPRINT("LoadLogFile: %S\n", LogName); - Result = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, &MaxValueLen, NULL, NULL); + Result = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, &MaxValueLen, NULL, NULL); if (Result != ERROR_SUCCESS) { - DPRINT1("RegQueryInfoKey failed: %lu\n", Result); + DPRINT1("RegQueryInfoKeyW failed: %lu\n", Result); return NULL; } + MaxValueLen = ROUND_DOWN(MaxValueLen, sizeof(WCHAR)); Buf = HeapAlloc(MyHeap, 0, MaxValueLen); if (!Buf) { - DPRINT1("Can't allocate heap!\n"); + DPRINT1("Cannot allocate heap!\n"); return NULL; } ValueLen = MaxValueLen; - - Result = RegQueryValueEx(hKey, - L"File", - NULL, - &Type, - (LPBYTE) Buf, - &ValueLen); - if (Result != ERROR_SUCCESS) - { - DPRINT1("RegQueryValueEx failed: %lu\n", Result); + Result = RegQueryValueExW(hKey, + L"File", + NULL, + &Type, + (LPBYTE)Buf, + &ValueLen); + /* + * If we failed, because the registry value was inexistent + * or the value type was incorrect, create a new "File" value + * that holds the default event log path. + */ + if ((Result != ERROR_SUCCESS) || (Type != REG_EXPAND_SZ && Type != REG_SZ)) + { + MaxValueLen = (wcslen(L"%SystemRoot%\\System32\\Config\\") + + wcslen(LogName) + wcslen(L".evt") + 1) * sizeof(WCHAR); + + Expanded = HeapReAlloc(MyHeap, 0, Buf, MaxValueLen); + if (!Expanded) + { + DPRINT1("Cannot reallocate heap!\n"); + HeapFree(MyHeap, 0, Buf); + return NULL; + } + Buf = Expanded; + + StringCbCopyW(Buf, MaxValueLen, L"%SystemRoot%\\System32\\Config\\"); + StringCbCatW(Buf, MaxValueLen, LogName); + StringCbCatW(Buf, MaxValueLen, L".evt"); + + ValueLen = MaxValueLen; + Result = RegSetValueExW(hKey, + L"File", + 0, + REG_EXPAND_SZ, + (LPBYTE)Buf, + ValueLen); + if (Result != ERROR_SUCCESS) + { + DPRINT1("RegSetValueEx failed: %lu\n", Result); + HeapFree(MyHeap, 0, Buf); + return NULL; + } + } + + ExpandedLen = ExpandEnvironmentStringsW(Buf, NULL, 0); + Expanded = HeapAlloc(MyHeap, 0, ExpandedLen * sizeof(WCHAR)); + if (!Expanded) + { + DPRINT1("Cannot allocate heap!\n"); HeapFree(MyHeap, 0, Buf); return NULL; } - if (Type != REG_EXPAND_SZ && Type != REG_SZ) - { - DPRINT1("%S\\File - value of wrong type %x.\n", LogName, Type); - HeapFree(MyHeap, 0, Buf); - return NULL; - } - - ExpandedLen = ExpandEnvironmentStrings(Buf, NULL, 0); - Expanded = HeapAlloc(MyHeap, 0, ExpandedLen * sizeof(WCHAR)); - if (!Expanded) - { - DPRINT1("Can't allocate heap!\n"); - HeapFree(MyHeap, 0, Buf); - return NULL; - } - - ExpandEnvironmentStrings(Buf, Expanded, ExpandedLen); - - if (!RtlDosPathNameToNtPathName_U(Expanded, &FileName, - NULL, NULL)) - { - DPRINT1("Can't convert path!\n"); + ExpandEnvironmentStringsW(Buf, Expanded, ExpandedLen); + + if (!RtlDosPathNameToNtPathName_U(Expanded, &FileName, NULL, NULL)) + { + DPRINT1("Cannot convert path!\n"); HeapFree(MyHeap, 0, Expanded); HeapFree(MyHeap, 0, Buf); return NULL; @@ -339,25 +361,47 @@ DPRINT("%S -> %S\n", Buf, Expanded); - ValueLen = sizeof(ULONG); - Result = RegQueryValueEx(hKey, - L"MaxSize", - NULL, - &Type, - (LPBYTE)&ulMaxSize, - &ValueLen); - if (Result != ERROR_SUCCESS) + ValueLen = sizeof(ulMaxSize); + Result = RegQueryValueExW(hKey, + L"MaxSize", + NULL, + &Type, + (LPBYTE)&ulMaxSize, + &ValueLen); + if ((Result != ERROR_SUCCESS) || (Type != REG_DWORD)) + { ulMaxSize = 512 * 1024; /* 512 kBytes */ - ValueLen = sizeof(ULONG); - Result = RegQueryValueEx(hKey, - L"Retention", - NULL, - &Type, - (LPBYTE)&ulRetention, - &ValueLen); - if (Result != ERROR_SUCCESS) + Result = RegSetValueExW(hKey, + L"MaxSize", + 0, + REG_DWORD, + (LPBYTE)&ulMaxSize, + sizeof(ulMaxSize)); + } + + ValueLen = sizeof(ulRetention); + Result = RegQueryValueExW(hKey, + L"Retention", + NULL, + &Type, + (LPBYTE)&ulRetention, + &ValueLen); + if ((Result != ERROR_SUCCESS) || (Type != REG_DWORD)) + { + /* On Windows 2003 it is 604800 (secs) == 7 days */ ulRetention = 0; + + Result = RegSetValueExW(hKey, + L"Retention", + 0, + REG_DWORD, + (LPBYTE)&ulRetention, + sizeof(ulRetention)); + } + + // TODO: Add, or use, default values for "AutoBackupLogFiles" (REG_DWORD) + // and "CustomSD" (REG_SZ). Status = LogfCreate(&pLogf, LogName, &FileName, ulMaxSize, ulRetention, TRUE, FALSE); if (!NT_SUCCESS(Status)) @@ -365,47 +409,44 @@ DPRINT1("Failed to create %S! (Status %08lx)\n", Expanded, Status); } + HeapFree(MyHeap, 0, Expanded); HeapFree(MyHeap, 0, Buf); - HeapFree(MyHeap, 0, Expanded); return pLogf; } -BOOL LoadLogFiles(HKEY eventlogKey) +static BOOL +LoadLogFiles(HKEY eventlogKey) { LONG Result; DWORD MaxLognameLen, LognameLen; WCHAR *Buf = NULL; - INT i; + DWORD dwIndex; PLOGFILE pLogFile; - Result = RegQueryInfoKey(eventlogKey, - NULL, NULL, NULL, NULL, - &MaxLognameLen, - NULL, NULL, NULL, NULL, NULL, NULL); + Result = RegQueryInfoKeyW(eventlogKey, NULL, NULL, NULL, NULL, &MaxLognameLen, + NULL, NULL, NULL, NULL, NULL, NULL); if (Result != ERROR_SUCCESS) { - DPRINT1("RegQueryInfoKey failed: %lu\n", Result); + DPRINT1("RegQueryInfoKeyW failed: %lu\n", Result); return FALSE; } MaxLognameLen++; Buf = HeapAlloc(MyHeap, 0, MaxLognameLen * sizeof(WCHAR)); - if (!Buf) { - DPRINT1("Error: can't allocate heap!\n"); + DPRINT1("Error: cannot allocate heap!\n"); return FALSE; } - i = 0; LognameLen = MaxLognameLen; - - while (RegEnumKeyEx(eventlogKey, - i, - Buf, - &LognameLen, - NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + dwIndex = 0; + while (RegEnumKeyExW(eventlogKey, + dwIndex, + Buf, + &LognameLen, + NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { HKEY SubKey; @@ -431,15 +472,17 @@ } RegCloseKey(SubKey); + LognameLen = MaxLognameLen; - i++; + dwIndex++; } HeapFree(MyHeap, 0, Buf); return TRUE; } -INT wmain() + +int wmain(int argc, WCHAR* argv[]) { WCHAR LogPath[MAX_PATH]; INT RetCode = 0; @@ -458,9 +501,9 @@ goto bye_bye; } - GetWindowsDirectory(LogPath, MAX_PATH); - - if (GetDriveType(LogPath) == DRIVE_CDROM) + GetWindowsDirectoryW(LogPath, MAX_PATH); + + if (GetDriveTypeW(LogPath) == DRIVE_CDROM) { DPRINT("LiveCD detected\n"); onLiveCD = TRUE; @@ -475,7 +518,7 @@ if (Result != ERROR_SUCCESS) { - DPRINT1("Fatal error: can't open eventlog registry key.\n"); + DPRINT1("Fatal error: cannot open eventlog registry key.\n"); RetCode = 1; goto bye_bye; } @@ -483,9 +526,15 @@ LoadLogFiles(elogKey); } + EventLogSource = GetEventSourceByName(L"EventLog"); + if (!EventLogSource) + { + DPRINT1("No EventLog source available, the EventLog service will not be able to log its own events.\n"); + } + StartServiceCtrlDispatcher(ServiceTable); - bye_bye: +bye_bye: LogfCloseAll(); if (MyHeap) @@ -494,40 +543,10 @@ return RetCode; } -VOID EventTimeToSystemTime(DWORD EventTime, SYSTEMTIME * pSystemTime) -{ - SYSTEMTIME st1970 = { 1970, 1, 0, 1, 0, 0, 0, 0 }; - FILETIME ftLocal; - union - { - FILETIME ft; - ULONGLONG ll; - } u1970, uUCT; - - uUCT.ft.dwHighDateTime = 0; - uUCT.ft.dwLowDateTime = EventTime; - SystemTimeToFileTime(&st1970, &u1970.ft); - uUCT.ll = uUCT.ll * 10000000 + u1970.ll; - FileTimeToLocalFileTime(&uUCT.ft, &ftLocal); - FileTimeToSystemTime(&ftLocal, pSystemTime); -} - -VOID SystemTimeToEventTime(SYSTEMTIME * pSystemTime, DWORD * pEventTime) -{ - SYSTEMTIME st1970 = { 1970, 1, 0, 1, 0, 0, 0, 0 }; - union - { - FILETIME ft; - ULONGLONG ll; - } Time, u1970; - - SystemTimeToFileTime(pSystemTime, &Time.ft); - SystemTimeToFileTime(&st1970, &u1970.ft); - *pEventTime = (DWORD)((Time.ll - u1970.ll) / 10000000ull); -} - VOID PRINT_HEADER(PEVENTLOGHEADER header) { + ULONG Flags = header->Flags; + DPRINT("HeaderSize = %lu\n", header->HeaderSize); DPRINT("Signature = 0x%x\n", header->Signature); DPRINT("MajorVersion = %lu\n", header->MajorVersion); @@ -540,10 +559,30 @@ DPRINT("Retention = 0x%x\n", header->Retention); DPRINT("EndHeaderSize = %lu\n", header->EndHeaderSize); DPRINT("Flags: "); - if (header->Flags & ELF_LOGFILE_HEADER_DIRTY) DPRINT("ELF_LOGFILE_HEADER_DIRTY"); - if (header->Flags & ELF_LOGFILE_HEADER_WRAP) DPRINT("| ELF_LOGFILE_HEADER_WRAP "); - if (header->Flags & ELF_LOGFILE_LOGFULL_WRITTEN) DPRINT("| ELF_LOGFILE_LOGFULL_WRITTEN "); - if (header->Flags & ELF_LOGFILE_ARCHIVE_SET) DPRINT("| ELF_LOGFILE_ARCHIVE_SET "); + if (Flags & ELF_LOGFILE_HEADER_DIRTY) + { + DPRINT("ELF_LOGFILE_HEADER_DIRTY"); + Flags &= ~ELF_LOGFILE_HEADER_DIRTY; + } + if (Flags) DPRINT(" | "); + if (Flags & ELF_LOGFILE_HEADER_WRAP) + { + DPRINT("ELF_LOGFILE_HEADER_WRAP"); + Flags &= ~ELF_LOGFILE_HEADER_WRAP; + } + if (Flags) DPRINT(" | "); + if (Flags & ELF_LOGFILE_LOGFULL_WRITTEN) + { + DPRINT("ELF_LOGFILE_LOGFULL_WRITTEN"); + Flags &= ~ELF_LOGFILE_LOGFULL_WRITTEN; + } + if (Flags) DPRINT(" | "); + if (Flags & ELF_LOGFILE_ARCHIVE_SET) + { + DPRINT("ELF_LOGFILE_ARCHIVE_SET"); + Flags &= ~ELF_LOGFILE_ARCHIVE_SET; + } + if (Flags) DPRINT(" | 0x%x", Flags); DPRINT("\n"); } @@ -551,21 +590,24 @@ { UINT i; WCHAR *str; - SYSTEMTIME time; + LARGE_INTEGER SystemTime; + TIME_FIELDS Time; DPRINT("Length = %lu\n", pRec->Length); DPRINT("Reserved = 0x%x\n", pRec->Reserved); DPRINT("RecordNumber = %lu\n", pRec->RecordNumber); - EventTimeToSystemTime(pRec->TimeGenerated, &time); + RtlSecondsSince1970ToTime(pRec->TimeGenerated, &SystemTime); + RtlTimeToTimeFields(&SystemTime, &Time); DPRINT("TimeGenerated = %hu.%hu.%hu %hu:%hu:%hu\n", - time.wDay, time.wMonth, time.wYear, - time.wHour, time.wMinute, time.wSecond); - - EventTimeToSystemTime(pRec->TimeWritten, &time); + Time.Day, Time.Month, Time.Year, + Time.Hour, Time.Minute, Time.Second); + + RtlSecondsSince1970ToTime(pRec->TimeWritten, &SystemTime); + RtlTimeToTimeFields(&SystemTime, &Time); DPRINT("TimeWritten = %hu.%hu.%hu %hu:%hu:%hu\n", - time.wDay, time.wMonth, time.wYear, - time.wHour, time.wMinute, time.wSecond); + Time.Day, Time.Month, Time.Year, + Time.Hour, Time.Minute, Time.Second); DPRINT("EventID = %lu\n", pRec->EventID); @@ -600,17 +642,17 @@ DPRINT("DataLength = %lu\n", pRec->DataLength); DPRINT("DataOffset = %lu\n", pRec->DataOffset); - DPRINT("SourceName: %S\n", (WCHAR *) (((PBYTE) pRec) + sizeof(EVENTLOGRECORD))); - - i = (lstrlenW((WCHAR *) (((PBYTE) pRec) + sizeof(EVENTLOGRECORD))) + 1) * + DPRINT("SourceName: %S\n", (WCHAR *) ((ULONG_PTR)pRec + sizeof(EVENTLOGRECORD))); + + i = (lstrlenW((WCHAR *) ((ULONG_PTR)pRec + sizeof(EVENTLOGRECORD))) + 1) * sizeof(WCHAR); - DPRINT("ComputerName: %S\n", (WCHAR *) (((PBYTE) pRec) + sizeof(EVENTLOGRECORD) + i)); + DPRINT("ComputerName: %S\n", (WCHAR *) ((ULONG_PTR)pRec + sizeof(EVENTLOGRECORD) + i)); if (pRec->StringOffset < pRec->Length && pRec->NumStrings) { DPRINT("Strings:\n"); - str = (WCHAR *) (((PBYTE) pRec) + pRec->StringOffset); + str = (WCHAR *) ((ULONG_PTR)pRec + pRec->StringOffset); for (i = 0; i < pRec->NumStrings; i++) { DPRINT("[%u] %S\n", i, str); @@ -618,5 +660,5 @@ } } - DPRINT("Length2 = %lu\n", *(PDWORD) (((PBYTE) pRec) + pRec->Length - 4)); -} + DPRINT("Length2 = %lu\n", *(PDWORD) ((ULONG_PTR)pRec + pRec->Length - 4)); +} Modified: trunk/reactos/base/services/eventlog/eventlog.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
============================================================================== --- trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -11,12 +11,18 @@ #include <stdarg.h> +/* PSDK/NDK Headers */ #define WIN32_NO_STATUS - #include <windef.h> #include <winbase.h> + +#define NTOS_MODE_USER #include <ndk/rtlfuncs.h> #include <ndk/obfuncs.h> + +#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l)) +#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + #include <eventlogrpc_s.h> #include <strsafe.h> @@ -26,21 +32,21 @@ IO_ERROR_LOG_MESSAGE Message; } IO_ERROR_LPC, *PIO_ERROR_LPC; -#define MAJORVER 1 -#define MINORVER 1 /* * Our file format will be compatible with NT's */ +#define MAJORVER 1 +#define MINORVER 1 #define LOGFILE_SIGNATURE 0x654c664c /* * Flags used in logfile header */ -#define ELF_LOGFILE_HEADER_DIRTY 1 -#define ELF_LOGFILE_HEADER_WRAP 2 +#define ELF_LOGFILE_HEADER_DIRTY 1 +#define ELF_LOGFILE_HEADER_WRAP 2 #define ELF_LOGFILE_LOGFULL_WRITTEN 4 -#define ELF_LOGFILE_ARCHIVE_SET 8 +#define ELF_LOGFILE_ARCHIVE_SET 8 /* FIXME: MSDN reads that the following two structs are in winnt.h. Are they? */ typedef struct _EVENTLOGHEADER @@ -114,22 +120,38 @@ WCHAR szName[1]; } LOGHANDLE, *PLOGHANDLE; + +/* eventlog.c */ +extern HANDLE MyHeap; +extern PEVENTSOURCE EventLogSource; + +VOID PRINT_HEADER(PEVENTLOGHEADER header); +VOID PRINT_RECORD(PEVENTLOGRECORD pRec); + + +/* eventsource.c */ +VOID InitEventSourceList(VOID); + +BOOL +LoadEventSources(HKEY hKey, + PLOGFILE pLogFile); + +PEVENTSOURCE +GetEventSourceByName(LPCWSTR Name); + + /* file.c */ VOID LogfListInitialize(VOID); -PLOGFILE LogfListHead(VOID); - -INT LogfListItemCount(VOID); - -PLOGFILE LogfListItemByIndex(INT Index); - -PLOGFILE LogfListItemByName(WCHAR * Name); - -INT LogfListItemIndexByName(WCHAR * Name); - -VOID LogfListAddItem(PLOGFILE Item); - -VOID LogfListRemoveItem(PLOGFILE Item); +DWORD LogfListItemCount(VOID); + +PLOGFILE LogfListItemByIndex(DWORD Index); + +PLOGFILE LogfListItemByName(LPCWSTR Name); + +// DWORD LogfListItemIndexByName(WCHAR * Name); + + DWORD LogfReadEvent(PLOGFILE LogFile, DWORD Flags, @@ -171,61 +193,34 @@ DWORD LogfGetCurrentRecord(PLOGFILE LogFile); -ULONG LogfOffsetByNumber(PLOGFILE LogFile, - DWORD RecordNumber); - -BOOL LogfAddOffsetInformation(PLOGFILE LogFile, - ULONG ulNumber, - ULONG ulOffset); - -BOOL LogfDeleteOffsetInformation(PLOGFILE LogFile, - ULONG ulNumber); - -PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize, - DWORD dwRecordNumber, - WORD wType, - WORD wCategory, - DWORD dwEventId, - LPCWSTR SourceName, - LPCWSTR ComputerName, - DWORD dwSidLength, - PSID lpUserSid, - WORD wNumStrings, - WCHAR * lpStrings, - DWORD dwDataSize, - LPVOID lpRawData); +PBYTE +LogfAllocAndBuildNewRecord(PULONG lpRecSize, + ULONG dwRecordNumber, // FIXME! + USHORT wType, + USHORT wCategory, + ULONG dwEventId, + PCWSTR SourceName, + PCWSTR ComputerName, + ULONG dwSidLength, + PSID lpUserSid, + USHORT wNumStrings, + WCHAR* lpStrings, + ULONG dwDataSize, + PVOID lpRawData); + +static __inline void LogfFreeRecord(LPVOID Rec) +{ + HeapFree(MyHeap, 0, Rec); +} VOID -LogfReportEvent(WORD wType, - WORD wCategory, - DWORD dwEventId, - WORD wNumStrings, - WCHAR *lpStrings, - DWORD dwDataSize, - LPVOID lpRawData); - -/* eventlog.c */ -extern HANDLE MyHeap; - -VOID PRINT_HEADER(PEVENTLOGHEADER header); - -VOID PRINT_RECORD(PEVENTLOGRECORD pRec); - -VOID EventTimeToSystemTime(DWORD EventTime, - SYSTEMTIME * SystemTime); - -VOID SystemTimeToEventTime(SYSTEMTIME * pSystemTime, - DWORD * pEventTime); - -/* eventsource.c */ -VOID InitEventSourceList(VOID); - -BOOL -LoadEventSources(HKEY hKey, - PLOGFILE pLogFile); - -PEVENTSOURCE -GetEventSourceByName(LPCWSTR Name); +LogfReportEvent(USHORT wType, + USHORT wCategory, + ULONG dwEventId, + USHORT wNumStrings, + WCHAR* lpStrings, + ULONG dwDataSize, + PVOID lpRawData); /* logport.c */ @@ -238,9 +233,4 @@ /* rpc.c */ DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter); -static __inline void LogfFreeRecord(LPVOID Rec) -{ - HeapFree(MyHeap, 0, Rec); -} - #endif /* __EVENTLOG_H__ */ Modified: trunk/reactos/base/services/eventlog/eventsource.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
============================================================================== --- trunk/reactos/base/services/eventlog/eventsource.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/eventsource.c [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -70,7 +70,7 @@ NULL, NULL, NULL, NULL, NULL); if (Result != ERROR_SUCCESS) { - DPRINT1("RegQueryInfoKey failed: %lu\n", Result); + DPRINT1("RegQueryInfoKeyW failed: %lu\n", Result); return FALSE; } @@ -81,12 +81,11 @@ Buf = HeapAlloc(MyHeap, 0, dwMaxSubKeyLength * sizeof(WCHAR)); if (!Buf) { - DPRINT1("Error: can't allocate heap!\n"); + DPRINT1("Error: cannot allocate heap!\n"); return FALSE; } dwEventSourceNameLength = dwMaxSubKeyLength; - dwIndex = 0; while (RegEnumKeyExW(hKey, dwIndex, @@ -127,7 +126,7 @@ GetEventSourceByName(LPCWSTR Name) { PLIST_ENTRY CurrentEntry; - PEVENTSOURCE Result = NULL; + PEVENTSOURCE Item, Result = NULL; DPRINT("GetEventSourceByName(%S)\n", Name); EnterCriticalSection(&EventSourceListCs); @@ -135,9 +134,9 @@ CurrentEntry = EventSourceListHead.Flink; while (CurrentEntry != &EventSourceListHead) { - PEVENTSOURCE Item = CONTAINING_RECORD(CurrentEntry, - EVENTSOURCE, - EventSourceListEntry); + Item = CONTAINING_RECORD(CurrentEntry, + EVENTSOURCE, + EventSourceListEntry); DPRINT("Item->szName: %S\n", Item->szName); // if ((*(Item->szName) != 0) && !_wcsicmp(Item->szName, Name)) Modified: trunk/reactos/base/services/eventlog/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/fil…
============================================================================== --- trunk/reactos/base/services/eventlog/file.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/file.c [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -4,24 +4,253 @@ * FILE: base/services/eventlog/file.c * PURPOSE: Event logging service * COPYRIGHT: Copyright 2005 Saveliy Tretiakov - Michael Martin + * Michael Martin */ -/* INCLUDES *****************************************************************/ +/* INCLUDES ******************************************************************/ #include "eventlog.h" #include <ndk/iofuncs.h> +#include <ndk/kefuncs.h> #define NDEBUG #include <debug.h> -/* GLOBALS ******************************************************************/ +/* LOG FILE LIST - GLOBALS ***************************************************/ static LIST_ENTRY LogFileListHead; static CRITICAL_SECTION LogFileListCs; -/* FUNCTIONS ****************************************************************/ +/* LOG FILE LIST - FUNCTIONS *************************************************/ + +VOID LogfCloseAll(VOID) +{ + EnterCriticalSection(&LogFileListCs); + + while (!IsListEmpty(&LogFileListHead)) + { + LogfClose(CONTAINING_RECORD(LogFileListHead.Flink, LOGFILE, ListEntry), TRUE); + } + + LeaveCriticalSection(&LogFileListCs); + + DeleteCriticalSection(&LogFileListCs); +} + +VOID LogfListInitialize(VOID) +{ + InitializeCriticalSection(&LogFileListCs); + InitializeListHead(&LogFileListHead); +} + +PLOGFILE LogfListItemByName(LPCWSTR Name) +{ + PLIST_ENTRY CurrentEntry; + PLOGFILE Item, Result = NULL; + + EnterCriticalSection(&LogFileListCs); + + CurrentEntry = LogFileListHead.Flink; + while (CurrentEntry != &LogFileListHead) + { + Item = CONTAINING_RECORD(CurrentEntry, + LOGFILE, + ListEntry); + + if (Item->LogName && !lstrcmpi(Item->LogName, Name)) + { + Result = Item; + break; + } + + CurrentEntry = CurrentEntry->Flink; + } + + LeaveCriticalSection(&LogFileListCs); + return Result; +} + +#if 0 +/* Index starting from 1 */ +DWORD LogfListItemIndexByName(WCHAR * Name) +{ + PLIST_ENTRY CurrentEntry; + DWORD Result = 0; + DWORD i = 1; + + EnterCriticalSection(&LogFileListCs); + + CurrentEntry = LogFileListHead.Flink; + while (CurrentEntry != &LogFileListHead) + { + PLOGFILE Item = CONTAINING_RECORD(CurrentEntry, + LOGFILE, + ListEntry); + + if (Item->LogName && !lstrcmpi(Item->LogName, Name)) + { + Result = i; + break; + } + + CurrentEntry = CurrentEntry->Flink; + i++; + } + + LeaveCriticalSection(&LogFileListCs); + return Result; +} +#endif + +/* Index starting from 1 */ +PLOGFILE LogfListItemByIndex(DWORD Index) +{ + PLIST_ENTRY CurrentEntry; + PLOGFILE Result = NULL; + DWORD i = 1; + + EnterCriticalSection(&LogFileListCs); + + CurrentEntry = LogFileListHead.Flink; + while (CurrentEntry != &LogFileListHead) + { + if (i == Index) + { + Result = CONTAINING_RECORD(CurrentEntry, LOGFILE, ListEntry); + break; + } + + CurrentEntry = CurrentEntry->Flink; + i++; + } + + LeaveCriticalSection(&LogFileListCs); + return Result; +} + +DWORD LogfListItemCount(VOID) +{ + PLIST_ENTRY CurrentEntry; + DWORD i = 0; + + EnterCriticalSection(&LogFileListCs); + + CurrentEntry = LogFileListHead.Flink; + while (CurrentEntry != &LogFileListHead) + { + CurrentEntry = CurrentEntry->Flink; + i++; + } + + LeaveCriticalSection(&LogFileListCs); + return i; +} + +static VOID +LogfListAddItem(PLOGFILE Item) +{ + EnterCriticalSection(&LogFileListCs); + InsertTailList(&LogFileListHead, &Item->ListEntry); + LeaveCriticalSection(&LogFileListCs); +} + +static VOID +LogfListRemoveItem(PLOGFILE Item) +{ + EnterCriticalSection(&LogFileListCs); + RemoveEntryList(&Item->ListEntry); + LeaveCriticalSection(&LogFileListCs); +} + + +/* FUNCTIONS *****************************************************************/ + +/* Returns 0 if nothing is found */ +static ULONG +LogfOffsetByNumber(PLOGFILE LogFile, + DWORD RecordNumber) +{ + DWORD i; + + for (i = 0; i < LogFile->OffsetInfoNext; i++) + { + if (LogFile->OffsetInfo[i].EventNumber == RecordNumber) + return LogFile->OffsetInfo[i].EventOffset; + } + return 0; +} + +DWORD LogfGetOldestRecord(PLOGFILE LogFile) +{ + return LogFile->Header.OldestRecordNumber; +} + +DWORD LogfGetCurrentRecord(PLOGFILE LogFile) +{ + return LogFile->Header.CurrentRecordNumber; +} + +static BOOL +LogfAddOffsetInformation(PLOGFILE LogFile, + ULONG ulNumber, + ULONG ulOffset) +{ + LPVOID NewOffsetInfo; + + if (LogFile->OffsetInfoNext == LogFile->OffsetInfoSize) + { + NewOffsetInfo = HeapReAlloc(MyHeap, + HEAP_ZERO_MEMORY, + LogFile->OffsetInfo, + (LogFile->OffsetInfoSize + 64) * + sizeof(EVENT_OFFSET_INFO)); + + if (!NewOffsetInfo) + { + DPRINT1("Cannot reallocate heap.\n"); + return FALSE; + } + + LogFile->OffsetInfo = (PEVENT_OFFSET_INFO)NewOffsetInfo; + LogFile->OffsetInfoSize += 64; + } + + LogFile->OffsetInfo[LogFile->OffsetInfoNext].EventNumber = ulNumber; + LogFile->OffsetInfo[LogFile->OffsetInfoNext].EventOffset = ulOffset; + LogFile->OffsetInfoNext++; + + return TRUE; +} + +static BOOL +LogfDeleteOffsetInformation(PLOGFILE LogFile, + ULONG ulNumber) +{ + DWORD i; + + /* + * As the offset information is listed in increasing order, and we want + * to keep the list without holes, we demand that ulNumber is the first + * element in the list. + */ + if (ulNumber != LogFile->OffsetInfo[0].EventNumber) + return FALSE; + + /* + * RtlMoveMemory(&LogFile->OffsetInfo[0], + * &LogFile->OffsetInfo[1], + * sizeof(EVENT_OFFSET_INFO) * (LogFile->OffsetInfoNext - 1)); + */ + for (i = 0; i < LogFile->OffsetInfoNext - 1; i++) + { + LogFile->OffsetInfo[i].EventNumber = LogFile->OffsetInfo[i + 1].EventNumber; + LogFile->OffsetInfo[i].EventOffset = LogFile->OffsetInfo[i + 1].EventOffset; + } + LogFile->OffsetInfoNext--; + + return TRUE; +} static NTSTATUS LogfInitializeNew(PLOGFILE LogFile, @@ -466,141 +695,6 @@ return; } -VOID LogfCloseAll(VOID) -{ - while (!IsListEmpty(&LogFileListHead)) - { - LogfClose(LogfListHead(), TRUE); - } - - DeleteCriticalSection(&LogFileListCs); -} - -VOID LogfListInitialize(VOID) -{ - InitializeCriticalSection(&LogFileListCs); - InitializeListHead(&LogFileListHead); -} - -PLOGFILE LogfListHead(VOID) -{ - return CONTAINING_RECORD(LogFileListHead.Flink, LOGFILE, ListEntry); -} - -PLOGFILE LogfListItemByName(WCHAR * Name) -{ - PLIST_ENTRY CurrentEntry; - PLOGFILE Result = NULL; - - EnterCriticalSection(&LogFileListCs); - - CurrentEntry = LogFileListHead.Flink; - while (CurrentEntry != &LogFileListHead) - { - PLOGFILE Item = CONTAINING_RECORD(CurrentEntry, - LOGFILE, - ListEntry); - - if (Item->LogName && !lstrcmpi(Item->LogName, Name)) - { - Result = Item; - break; - } - - CurrentEntry = CurrentEntry->Flink; - } - - LeaveCriticalSection(&LogFileListCs); - return Result; -} - -/* Index starting from 1 */ -INT LogfListItemIndexByName(WCHAR * Name) -{ - PLIST_ENTRY CurrentEntry; - INT Result = 0; - INT i = 1; - - EnterCriticalSection(&LogFileListCs); - - CurrentEntry = LogFileListHead.Flink; - while (CurrentEntry != &LogFileListHead) - { - PLOGFILE Item = CONTAINING_RECORD(CurrentEntry, - LOGFILE, - ListEntry); - - if (Item->LogName && !lstrcmpi(Item->LogName, Name)) - { - Result = i; - break; - } - - CurrentEntry = CurrentEntry->Flink; - i++; - } - - LeaveCriticalSection(&LogFileListCs); - return Result; -} - -/* Index starting from 1 */ -PLOGFILE LogfListItemByIndex(INT Index) -{ - PLIST_ENTRY CurrentEntry; - PLOGFILE Result = NULL; - INT i = 1; - - EnterCriticalSection(&LogFileListCs); - - CurrentEntry = LogFileListHead.Flink; - while (CurrentEntry != &LogFileListHead) - { - if (i == Index) - { - Result = CONTAINING_RECORD(CurrentEntry, LOGFILE, ListEntry); - break; - } - - CurrentEntry = CurrentEntry->Flink; - i++; - } - - LeaveCriticalSection(&LogFileListCs); - return Result; -} - -INT LogfListItemCount(VOID) -{ - PLIST_ENTRY CurrentEntry; - INT i = 0; - - EnterCriticalSection(&LogFileListCs); - - CurrentEntry = LogFileListHead.Flink; - while (CurrentEntry != &LogFileListHead) - { - CurrentEntry = CurrentEntry->Flink; - i++; - } - - LeaveCriticalSection(&LogFileListCs); - return i; -} - -VOID LogfListAddItem(PLOGFILE Item) -{ - EnterCriticalSection(&LogFileListCs); - InsertTailList(&LogFileListHead, &Item->ListEntry); - LeaveCriticalSection(&LogFileListCs); -} - -VOID LogfListRemoveItem(PLOGFILE Item) -{ - EnterCriticalSection(&LogFileListCs); - RemoveEntryList(&Item->ListEntry); - LeaveCriticalSection(&LogFileListCs); -} static BOOL ReadAnsiLogEntry(HANDLE hFile, @@ -930,7 +1024,7 @@ { DWORD dwWritten; DWORD dwRead; - SYSTEMTIME st; + LARGE_INTEGER SystemTime; EVENTLOGEOF EofRec; PEVENTLOGRECORD RecBuf; LARGE_INTEGER logFileSize; @@ -940,10 +1034,10 @@ if (!Buffer) return FALSE; - GetSystemTime(&st); - SystemTimeToEventTime(&st, &((PEVENTLOGRECORD) Buffer)->TimeWritten); - RtlAcquireResourceExclusive(&LogFile->Lock, TRUE); + + NtQuerySystemTime(&SystemTime); + RtlTimeToSecondsSince1970(&SystemTime, &((PEVENTLOGRECORD)Buffer)->TimeWritten); if (!GetFileSizeEx(LogFile->hFile, &logFileSize)) { @@ -1111,7 +1205,6 @@ return TRUE; } - NTSTATUS LogfClearFile(PLOGFILE LogFile, PUNICODE_STRING BackupFileName) @@ -1123,12 +1216,11 @@ if (BackupFileName->Length > 0) { /* Write a backup file */ - Status = LogfBackupFile(LogFile, - BackupFileName); + Status = LogfBackupFile(LogFile, BackupFileName); if (!NT_SUCCESS(Status)) { DPRINT1("LogfBackupFile failed (Status: 0x%08lx)\n", Status); - return Status; + goto Quit; } } @@ -1140,11 +1232,10 @@ DPRINT1("LogfInitializeNew failed (Status: 0x%08lx)\n", Status); } +Quit: RtlReleaseResource(&LogFile->Lock); - return Status; } - NTSTATUS LogfBackupFile(PLOGFILE LogFile, @@ -1347,134 +1438,84 @@ } -/* Returns 0 if nothing found. */ -ULONG LogfOffsetByNumber(PLOGFILE LogFile, DWORD RecordNumber) -{ - DWORD i; - - for (i = 0; i < LogFile->OffsetInfoNext; i++) - { - if (LogFile->OffsetInfo[i].EventNumber == RecordNumber) - return LogFile->OffsetInfo[i].EventOffset; - } - return 0; -} - -DWORD LogfGetOldestRecord(PLOGFILE LogFile) -{ - return LogFile->Header.OldestRecordNumber; -} - -DWORD LogfGetCurrentRecord(PLOGFILE LogFile) -{ - return LogFile->Header.CurrentRecordNumber; -} - -BOOL LogfDeleteOffsetInformation(PLOGFILE LogFile, ULONG ulNumber) -{ - DWORD i; - - if (ulNumber != LogFile->OffsetInfo[0].EventNumber) - { - return FALSE; - } - - for (i = 0; i < LogFile->OffsetInfoNext - 1; i++) - { - LogFile->OffsetInfo[i].EventNumber = LogFile->OffsetInfo[i + 1].EventNumber; - LogFile->OffsetInfo[i].EventOffset = LogFile->OffsetInfo[i + 1].EventOffset; - } - LogFile->OffsetInfoNext--; - return TRUE; -} - -BOOL LogfAddOffsetInformation(PLOGFILE LogFile, ULONG ulNumber, ULONG ulOffset) -{ - LPVOID NewOffsetInfo; - - if (LogFile->OffsetInfoNext == LogFile->OffsetInfoSize) - { - NewOffsetInfo = HeapReAlloc(MyHeap, - HEAP_ZERO_MEMORY, - LogFile->OffsetInfo, - (LogFile->OffsetInfoSize + 64) * - sizeof(EVENT_OFFSET_INFO)); - - if (!NewOffsetInfo) - { - DPRINT1("Can't reallocate heap.\n"); - return FALSE; - } - - LogFile->OffsetInfo = (PEVENT_OFFSET_INFO) NewOffsetInfo; - LogFile->OffsetInfoSize += 64; - } - - LogFile->OffsetInfo[LogFile->OffsetInfoNext].EventNumber = ulNumber; - LogFile->OffsetInfo[LogFile->OffsetInfoNext].EventOffset = ulOffset; - LogFile->OffsetInfoNext++; - - return TRUE; -} - -PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize, - DWORD dwRecordNumber, - WORD wType, - WORD wCategory, - DWORD dwEventId, - LPCWSTR SourceName, - LPCWSTR ComputerName, - DWORD dwSidLength, - PSID lpUserSid, - WORD wNumStrings, - WCHAR * lpStrings, - DWORD dwDataSize, - LPVOID lpRawData) +PBYTE +LogfAllocAndBuildNewRecord(PULONG lpRecSize, + ULONG dwRecordNumber, // FIXME! + USHORT wType, + USHORT wCategory, + ULONG dwEventId, + PCWSTR SourceName, + PCWSTR ComputerName, + ULONG dwSidLength, + PSID lpUserSid, + USHORT wNumStrings, + WCHAR* lpStrings, + ULONG dwDataSize, + PVOID lpRawData) { DWORD dwRecSize; PEVENTLOGRECORD pRec; - SYSTEMTIME SysTime; + LARGE_INTEGER SystemTime; WCHAR *str; UINT i, pos; PBYTE Buffer; dwRecSize = - sizeof(EVENTLOGRECORD) + (lstrlenW(ComputerName) + - lstrlenW(SourceName) + 2) * sizeof(WCHAR); - - if (dwRecSize % 4 != 0) - dwRecSize += 4 - (dwRecSize % 4); + sizeof(EVENTLOGRECORD) + (lstrlenW(SourceName) + + lstrlenW(ComputerName) + 2) * sizeof(WCHAR); + + /* Align on DWORD boundary for the SID */ + dwRecSize = ROUND_UP(dwRecSize, sizeof(ULONG)); dwRecSize += dwSidLength; + /* Add the sizes for the strings array */ for (i = 0, str = lpStrings; i < wNumStrings; i++) { dwRecSize += (lstrlenW(str) + 1) * sizeof(WCHAR); str += lstrlenW(str) + 1; } + /* Add the data size */ dwRecSize += dwDataSize; - if (dwRecSize % 4 != 0) - dwRecSize += 4 - (dwRecSize % 4); - - dwRecSize += 4; + + /* Align on DWORD boundary for the full structure */ + dwRecSize = ROUND_UP(dwRecSize, sizeof(ULONG)); + + /* Size of the trailing 'Length' member */ + dwRecSize += sizeof(ULONG); Buffer = HeapAlloc(MyHeap, HEAP_ZERO_MEMORY, dwRecSize); - if (!Buffer) { - DPRINT1("Can't allocate heap!\n"); + DPRINT1("Cannot allocate heap!\n"); return NULL; } - pRec = (PEVENTLOGRECORD) Buffer; + pRec = (PEVENTLOGRECORD)Buffer; pRec->Length = dwRecSize; pRec->Reserved = LOGFILE_SIGNATURE; + + // FIXME: The problem with this technique is that it is possible + // to allocate different records with the same number. Suppose that + // two concurrent events writes happen for the same log, and the + // execution goes inside this function. The callers of this function + // have normally retrieved the 'CurrentRecordNumber' of this log, where + // the access to the log was non locked and no write operation happened + // in between. Then we have two different records for the same log with + // the very same record number, that will be written later. It is only in + // 'LogfWriteRecord' that the 'CurrentRecordNumber' is incremented!! + // + // Therefore we need to rewrite those functions. This function must + // not take any "precomputed" record number. It should attribute a new + // record number under lock, and then increment it atomically, so that + // all event records have unique record numbers. pRec->RecordNumber = dwRecordNumber; - GetSystemTime(&SysTime); - SystemTimeToEventTime(&SysTime, &pRec->TimeGenerated); - SystemTimeToEventTime(&SysTime, &pRec->TimeWritten); + NtQuerySystemTime(&SystemTime); + RtlTimeToSecondsSince1970(&SystemTime, &pRec->TimeGenerated); + // FIXME: Already done in LogfWriteRecord. Is it needed to do that here first?? + RtlTimeToSecondsSince1970(&SystemTime, &pRec->TimeWritten); pRec->EventID = dwEventId; pRec->EventType = wType; @@ -1487,11 +1528,10 @@ lstrcpyW((WCHAR *) (Buffer + pos), ComputerName); pos += (lstrlenW(ComputerName) + 1) * sizeof(WCHAR); + /* Align on DWORD boundary for the SID */ + pos = ROUND_UP(pos, sizeof(ULONG)); + pRec->UserSidOffset = pos; - - if (pos % 4 != 0) - pos += 4 - (pos % 4); - if (dwSidLength) { CopyMemory(Buffer + pos, lpUserSid, dwSidLength); @@ -1517,53 +1557,49 @@ pos += dwDataSize; } - if (pos % 4 != 0) - pos += 4 - (pos % 4); - + /* Align on DWORD boundary for the full structure */ + pos = ROUND_UP(pos, sizeof(ULONG)); + + /* Initialize the trailing 'Length' member */ *((PDWORD) (Buffer + pos)) = dwRecSize; *lpRecSize = dwRecSize; return Buffer; } - VOID -LogfReportEvent(WORD wType, - WORD wCategory, - DWORD dwEventId, - WORD wNumStrings, - WCHAR *lpStrings, - DWORD dwDataSize, - LPVOID lpRawData) +LogfReportEvent(USHORT wType, + USHORT wCategory, + ULONG dwEventId, + USHORT wNumStrings, + WCHAR* lpStrings, + ULONG dwDataSize, + PVOID lpRawData) { WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1; - PEVENTSOURCE pEventSource = NULL; PBYTE logBuffer; DWORD lastRec; DWORD recSize; DWORD dwError; + if (!EventLogSource) + return; + if (!GetComputerNameW(szComputerName, &dwComputerNameLength)) { - szComputerName[0] = 0; - } - - pEventSource = GetEventSourceByName(L"EventLog"); - if (pEventSource == NULL) - { - return; - } - - lastRec = LogfGetCurrentRecord(pEventSource->LogFile); + szComputerName[0] = L'\0'; + } + + lastRec = LogfGetCurrentRecord(EventLogSource->LogFile); logBuffer = LogfAllocAndBuildNewRecord(&recSize, - lastRec, + lastRec, // FIXME! wType, wCategory, dwEventId, - pEventSource->szName, - (LPCWSTR)szComputerName, + EventLogSource->szName, + szComputerName, 0, NULL, wNumStrings, @@ -1571,10 +1607,10 @@ dwDataSize, lpRawData); - dwError = LogfWriteData(pEventSource->LogFile, recSize, logBuffer); + dwError = LogfWriteData(EventLogSource->LogFile, recSize, logBuffer); if (!dwError) { - DPRINT1("ERROR WRITING TO EventLog %S\n", pEventSource->LogFile->FileName); + DPRINT1("ERROR WRITING TO EventLog %S\n", EventLogSource->LogFile->FileName); } LogfFreeRecord(logBuffer); Modified: trunk/reactos/base/services/eventlog/logport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/log…
============================================================================== --- trunk/reactos/base/services/eventlog/logport.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/logport.c [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -18,8 +18,8 @@ /* GLOBALS ******************************************************************/ -HANDLE ConnectPortHandle = NULL; -HANDLE MessagePortHandle = NULL; +static HANDLE ConnectPortHandle = NULL; +static HANDLE MessagePortHandle = NULL; extern BOOL onLiveCD; /* FUNCTIONS ****************************************************************/ @@ -70,7 +70,6 @@ } Status = NtListenPort(ConnectPortHandle, &Request); - if (!NT_SUCCESS(Status)) { DPRINT1("NtListenPort() failed (Status %lx)\n", Status); @@ -79,7 +78,6 @@ Status = NtAcceptConnectPort(&MessagePortHandle, ConnectPortHandle, NULL, TRUE, NULL, NULL); - if (!NT_SUCCESS(Status)) { DPRINT1("NtAcceptConnectPort() failed (Status %lx)\n", Status); @@ -93,7 +91,7 @@ goto ByeBye; } - ByeBye: +ByeBye: if (!NT_SUCCESS(Status)) { if (ConnectPortHandle != NULL) @@ -114,6 +112,8 @@ DWORD dwRecSize; NTSTATUS Status; PLOGFILE SystemLog = NULL; + WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1; DPRINT("ProcessPortMessage() called\n"); @@ -150,18 +150,27 @@ Message = (PIO_ERROR_LOG_MESSAGE) & Request.Message; ulRecNum = SystemLog ? SystemLog->Header.CurrentRecordNumber : 0; - pRec = (PEVENTLOGRECORD) LogfAllocAndBuildNewRecord(&dwRecSize, - ulRecNum, Message->Type, Message->EntryData.EventCategory, - Message->EntryData.ErrorCode, - (WCHAR *) (((PBYTE) Message) + Message->DriverNameOffset), - L"MyComputer", /* FIXME */ - 0, - NULL, - Message->EntryData.NumberOfStrings, - (WCHAR *) (((PBYTE) Message) + Message->EntryData.StringOffset), - Message->EntryData.DumpDataSize, - (LPVOID) (((PBYTE) Message) + sizeof(IO_ERROR_LOG_PACKET) - - sizeof(ULONG))); + if (!GetComputerNameW(szComputerName, &dwComputerNameLength)) + { + szComputerName[0] = L'\0'; + } + + // TODO: Log more information?? + + pRec = (PEVENTLOGRECORD) LogfAllocAndBuildNewRecord( + &dwRecSize, + ulRecNum, // FIXME! + Message->Type, + Message->EntryData.EventCategory, + Message->EntryData.ErrorCode, + (WCHAR *) ((ULONG_PTR)Message + Message->DriverNameOffset), // FIXME: Use DriverNameLength too! + szComputerName, + 0, + NULL, + Message->EntryData.NumberOfStrings, + (WCHAR *) ((ULONG_PTR)Message + Message->EntryData.StringOffset), + Message->EntryData.DumpDataSize, + (LPVOID) ((ULONG_PTR)Message + FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData))); if (pRec == NULL) { Modified: trunk/reactos/base/services/eventlog/rpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc…
============================================================================== --- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Fri Aug 12 19:14:55 2016 @@ -5,6 +5,7 @@ * PURPOSE: Event logging service * COPYRIGHT: Copyright 2005 Saveliy Tretiakov * Copyright 2008 Michael Martin + * Copyright 2010-2011 Eric Kohl */ /* INCLUDES *****************************************************************/ @@ -49,27 +50,31 @@ static NTSTATUS -ElfCreateEventLogHandle(PLOGHANDLE *LogHandle, - LPCWSTR Name, - BOOL Create) -{ +ElfCreateEventLogHandle(PLOGHANDLE* LogHandle, + PUNICODE_STRING LogName, + BOOLEAN Create) +{ + NTSTATUS Status = STATUS_SUCCESS; PLOGHANDLE lpLogHandle; PLOGFILE currentLogFile = NULL; - INT i, LogsActive; + DWORD i, LogsActive; PEVENTSOURCE pEventSource; - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("ElfCreateEventLogHandle(Name: %S)\n", Name); - - lpLogHandle = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGHANDLE) - + ((wcslen(Name) + 1) * sizeof(WCHAR))); + + DPRINT("ElfCreateEventLogHandle(Name: %wZ)\n", LogName); + + *LogHandle = NULL; + + i = (LogName->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR); + lpLogHandle = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + FIELD_OFFSET(LOGHANDLE, szName[i])); if (!lpLogHandle) { DPRINT1("Failed to allocate Heap!\n"); return STATUS_NO_MEMORY; } - wcscpy(lpLogHandle->szName, Name); + StringCchCopy(lpLogHandle->szName, i, LogName->Buffer); /* Get the number of Log Files the EventLog service found */ LogsActive = LogfListItemCount(); @@ -81,9 +86,9 @@ } /* If Creating, default to the Application Log in case we fail, as documented on MSDN */ - if (Create == TRUE) - { - pEventSource = GetEventSourceByName(Name); + if (Create) + { + pEventSource = GetEventSourceByName(LogName->Buffer); DPRINT("EventSource: %p\n", pEventSource); if (pEventSource) { @@ -106,9 +111,9 @@ { currentLogFile = LogfListItemByIndex(i); - if (_wcsicmp(Name, currentLogFile->LogName) == 0) + if (_wcsicmp(LogName->Buffer, currentLogFile->LogName) == 0) { - lpLogHandle->LogFile = LogfListItemByIndex(i); + lpLogHandle->LogFile = currentLogFile; lpLogHandle->CurrentRecord = LogfGetOldestRecord(lpLogHandle->LogFile); break; } @@ -150,14 +155,15 @@ static NTSTATUS -ElfCreateBackupLogHandle(PLOGHANDLE *LogHandle, +ElfCreateBackupLogHandle(PLOGHANDLE* LogHandle, PUNICODE_STRING FileName) { + NTSTATUS Status = STATUS_SUCCESS; PLOGHANDLE lpLogHandle; - NTSTATUS Status = STATUS_SUCCESS; - DPRINT("ElfCreateBackupLogHandle(FileName: %wZ)\n", FileName); + + *LogHandle = NULL; lpLogHandle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LOGHANDLE)); if (lpLogHandle == NULL) @@ -202,7 +208,8 @@ } -PLOGHANDLE ElfGetLogHandleEntryByHandle(IELF_HANDLE EventLogHandle) +static PLOGHANDLE +ElfGetLogHandleEntryByHandle(IELF_HANDLE EventLogHandle) { PLIST_ENTRY CurrentEntry; PLOGHANDLE lpLogHandle; @@ -224,38 +231,38 @@ static NTSTATUS -ElfDeleteEventLogHandle(IELF_HANDLE LogHandle) +ElfDeleteEventLogHandle(PIELF_HANDLE LogHandle) { PLOGHANDLE lpLogHandle; + + lpLogHandle = ElfGetLogHandleEntryByHandle(*LogHandle); + if (!lpLogHandle) + return STATUS_INVALID_HANDLE; + + RemoveEntryList(&lpLogHandle->LogHandleListEntry); + LogfClose(lpLogHandle->LogFile, FALSE); + + HeapFree(GetProcessHeap(), 0, lpLogHandle); + + *LogHandle = NULL; + + return STATUS_SUCCESS; +} + + +/* Function 0 */ +NTSTATUS +ElfrClearELFW( + IELF_HANDLE LogHandle, + PRPC_UNICODE_STRING BackupFileName) +{ + PLOGHANDLE lpLogHandle; + + DPRINT("ElfrClearELFW()\n"); lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } - - RemoveEntryList(&lpLogHandle->LogHandleListEntry); - LogfClose(lpLogHandle->LogFile, FALSE); - - HeapFree(GetProcessHeap(), 0, lpLogHandle); - - return STATUS_SUCCESS; -} - -/* Function 0 */ -NTSTATUS ElfrClearELFW( - IELF_HANDLE LogHandle, - PRPC_UNICODE_STRING BackupFileName) -{ - PLOGHANDLE lpLogHandle; - - DPRINT("ElfrClearELFW()\n"); - - lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); - if (!lpLogHandle) - { - return STATUS_INVALID_HANDLE; - } /* Fail, if the log file is a backup file */ if (lpLogHandle->Flags & LOG_HANDLE_BACKUP_FILE) @@ -267,7 +274,8 @@ /* Function 1 */ -NTSTATUS ElfrBackupELFW( +NTSTATUS +ElfrBackupELFW( IELF_HANDLE LogHandle, PRPC_UNICODE_STRING BackupFileName) { @@ -277,9 +285,7 @@ lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } return LogfBackupFile(lpLogHandle->LogFile, (PUNICODE_STRING)BackupFileName); @@ -287,25 +293,28 @@ /* Function 2 */ -NTSTATUS ElfrCloseEL( - IELF_HANDLE *LogHandle) -{ - return ElfDeleteEventLogHandle(*LogHandle); +NTSTATUS +ElfrCloseEL( + PIELF_HANDLE LogHandle) +{ + return ElfDeleteEventLogHandle(LogHandle); } /* Function 3 */ -NTSTATUS ElfrDeregisterEventSource( - IELF_HANDLE *LogHandle) -{ - return ElfDeleteEventLogHandle(*LogHandle); +NTSTATUS +ElfrDeregisterEventSource( + PIELF_HANDLE LogHandle) +{ + return ElfDeleteEventLogHandle(LogHandle); } /* Function 4 */ -NTSTATUS ElfrNumberOfRecords( - IELF_HANDLE LogHandle, - DWORD *NumberOfRecords) +NTSTATUS +ElfrNumberOfRecords( + IELF_HANDLE LogHandle, + PULONG NumberOfRecords) { PLOGHANDLE lpLogHandle; PLOGFILE lpLogFile; @@ -314,9 +323,10 @@ lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } + + if (!NumberOfRecords) + return STATUS_INVALID_PARAMETER; lpLogFile = lpLogHandle->LogFile; @@ -332,22 +342,19 @@ /* Function 5 */ -NTSTATUS ElfrOldestRecord( - IELF_HANDLE LogHandle, - DWORD *OldestRecordNumber) +NTSTATUS +ElfrOldestRecord( + IELF_HANDLE LogHandle, + PULONG OldestRecordNumber) { PLOGHANDLE lpLogHandle; lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } if (!OldestRecordNumber) - { - return STATUS_INVALID_PARAMETER; - } + return STATUS_INVALID_PARAMETER; *OldestRecordNumber = LogfGetOldestRecord(lpLogHandle->LogFile); @@ -356,26 +363,26 @@ /* Function 6 */ -NTSTATUS ElfrChangeNotify( +NTSTATUS +ElfrChangeNotify( IELF_HANDLE LogHandle, RPC_CLIENT_ID ClientId, - DWORD Event) -{ - DPRINT("ElfrChangeNotify()"); - + ULONG Event) +{ UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } /* Function 7 */ -NTSTATUS ElfrOpenELW( +NTSTATUS +ElfrOpenELW( EVENTLOG_HANDLE_W UNCServerName, PRPC_UNICODE_STRING ModuleName, PRPC_UNICODE_STRING RegModuleName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { if ((MajorVersion != 1) || (MinorVersion != 1)) return STATUS_INVALID_PARAMETER; @@ -384,24 +391,25 @@ if (RegModuleName->Length > 0) return STATUS_INVALID_PARAMETER; - /*FIXME: UNCServerName must specify the server */ - - /*FIXME: Must verify that caller has read access */ - - return ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle, - ModuleName->Buffer, + /* FIXME: UNCServerName must specify the server */ + + /* FIXME: Must verify that caller has read access */ + + return ElfCreateEventLogHandle((PLOGHANDLE*)LogHandle, + (PUNICODE_STRING)ModuleName, FALSE); } /* Function 8 */ -NTSTATUS ElfrRegisterEventSourceW( +NTSTATUS +ElfrRegisterEventSourceW( EVENTLOG_HANDLE_W UNCServerName, PRPC_UNICODE_STRING ModuleName, PRPC_UNICODE_STRING RegModuleName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { DPRINT("ElfrRegisterEventSourceW()\n"); @@ -412,49 +420,51 @@ if (RegModuleName->Length > 0) return STATUS_INVALID_PARAMETER; - DPRINT("ModuleName: %S\n", ModuleName->Buffer); - - /*FIXME: UNCServerName must specify the server or empty for local */ - - /*FIXME: Must verify that caller has write access */ - - return ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle, - ModuleName->Buffer, + DPRINT("ModuleName: %wZ\n", ModuleName); + + /* FIXME: UNCServerName must specify the server or empty for local */ + + /* FIXME: Must verify that caller has write access */ + + return ElfCreateEventLogHandle((PLOGHANDLE*)LogHandle, + (PUNICODE_STRING)ModuleName, TRUE); } /* Function 9 */ -NTSTATUS ElfrOpenBELW( +NTSTATUS +ElfrOpenBELW( EVENTLOG_HANDLE_W UNCServerName, PRPC_UNICODE_STRING BackupFileName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { DPRINT("ElfrOpenBELW(%wZ)\n", BackupFileName); if ((MajorVersion != 1) || (MinorVersion != 1)) return STATUS_INVALID_PARAMETER; - /*FIXME: UNCServerName must specify the server */ - - /*FIXME: Must verify that caller has read access */ - - return ElfCreateBackupLogHandle((PLOGHANDLE *)LogHandle, + /* FIXME: UNCServerName must specify the server */ + + /* FIXME: Must verify that caller has read access */ + + return ElfCreateBackupLogHandle((PLOGHANDLE*)LogHandle, (PUNICODE_STRING)BackupFileName); } /* Function 10 */ -NTSTATUS ElfrReadELW( - IELF_HANDLE LogHandle, - DWORD ReadFlags, - DWORD RecordOffset, +NTSTATUS +ElfrReadELW( + IELF_HANDLE LogHandle, + ULONG ReadFlags, + ULONG RecordOffset, RULONG NumberOfBytesToRead, - BYTE *Buffer, - DWORD *NumberOfBytesRead, - DWORD *MinNumberOfBytesNeeded) + PBYTE Buffer, + PULONG NumberOfBytesRead, + PULONG MinNumberOfBytesNeeded) { PLOGHANDLE lpLogHandle; DWORD dwError; @@ -462,9 +472,7 @@ lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } if (!Buffer) return STATUS_INVALID_PARAMETER; @@ -479,11 +487,16 @@ RecordNumber = RecordOffset; } - dwError = LogfReadEvent(lpLogHandle->LogFile, ReadFlags, &RecordNumber, - NumberOfBytesToRead, Buffer, NumberOfBytesRead, MinNumberOfBytesNeeded, + dwError = LogfReadEvent(lpLogHandle->LogFile, + ReadFlags, + &RecordNumber, + NumberOfBytesToRead, + Buffer, + NumberOfBytesRead, + MinNumberOfBytesNeeded, FALSE); - /* Update the handles CurrentRecord if success*/ + /* Update the handle's CurrentRecord if success */ if (dwError == ERROR_SUCCESS) { lpLogHandle->CurrentRecord = RecordNumber; @@ -498,21 +511,22 @@ /* Function 11 */ -NTSTATUS ElfrReportEventW( - IELF_HANDLE LogHandle, - DWORD Time, +NTSTATUS +ElfrReportEventW( + IELF_HANDLE LogHandle, + ULONG Time, USHORT EventType, USHORT EventCategory, - DWORD EventID, + ULONG EventID, USHORT NumStrings, - DWORD DataSize, + ULONG DataSize, PRPC_UNICODE_STRING ComputerName, PRPC_SID UserSID, PRPC_UNICODE_STRING Strings[], - BYTE *Data, + PBYTE Data, USHORT Flags, - DWORD *RecordNumber, - DWORD *TimeWritten) + PULONG RecordNumber, + PULONG TimeWritten) { USHORT i; PBYTE LogBuffer; @@ -527,15 +541,11 @@ lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } /* Flags must be 0 */ if (Flags) - { - return STATUS_INVALID_PARAMETER; - } + return STATUS_INVALID_PARAMETER; lastRec = LogfGetCurrentRecord(lpLogHandle->LogFile); @@ -571,7 +581,7 @@ DPRINT1("Type %hu: %wZ\n", EventType, Strings[i]); break; } - dwStringsSize += Strings[i]->Length + sizeof UNICODE_NULL; + dwStringsSize += Strings[i]->Length + sizeof(UNICODE_NULL); } lpStrings = HeapAlloc(GetProcessHeap(), 0, dwStringsSize); @@ -583,16 +593,16 @@ for (i = 0; i < NumStrings; i++) { - CopyMemory(lpStrings + pos, Strings[i]->Buffer, Strings[i]->Length); + RtlCopyMemory(lpStrings + pos, Strings[i]->Buffer, Strings[i]->Length); pos += Strings[i]->Length / sizeof(WCHAR); lpStrings[pos] = UNICODE_NULL; - pos += sizeof UNICODE_NULL / sizeof(WCHAR); + pos += sizeof(UNICODE_NULL) / sizeof(WCHAR); } if (UserSID) dwUserSidLength = FIELD_OFFSET(SID, SubAuthority[UserSID->SubAuthorityCount]); LogBuffer = LogfAllocAndBuildNewRecord(&recSize, - lastRec, + lastRec, // FIXME! EventType, EventCategory, EventID, @@ -620,7 +630,8 @@ /* Function 12 */ -NTSTATUS ElfrClearELFA( +NTSTATUS +ElfrClearELFA( IELF_HANDLE LogHandle, PRPC_STRING BackupFileName) { @@ -643,7 +654,8 @@ /* Function 13 */ -NTSTATUS ElfrBackupELFA( +NTSTATUS +ElfrBackupELFA( IELF_HANDLE LogHandle, PRPC_STRING BackupFileName) { @@ -666,13 +678,14 @@ /* Function 14 */ -NTSTATUS ElfrOpenELA( +NTSTATUS +ElfrOpenELA( EVENTLOG_HANDLE_A UNCServerName, PRPC_STRING ModuleName, PRPC_STRING RegModuleName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { UNICODE_STRING ModuleNameW; NTSTATUS Status; @@ -690,8 +703,8 @@ /* FIXME: Must verify that caller has read access */ - Status = ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle, - ModuleNameW.Buffer, + Status = ElfCreateEventLogHandle((PLOGHANDLE*)LogHandle, + &ModuleNameW, FALSE); RtlFreeUnicodeString(&ModuleNameW); @@ -701,13 +714,14 @@ /* Function 15 */ -NTSTATUS ElfrRegisterEventSourceA( +NTSTATUS +ElfrRegisterEventSourceA( EVENTLOG_HANDLE_A UNCServerName, PRPC_STRING ModuleName, PRPC_STRING RegModuleName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { UNICODE_STRING ModuleNameW; NTSTATUS Status; @@ -736,8 +750,8 @@ /* FIXME: Must verify that caller has write access */ - Status = ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle, - ModuleNameW.Buffer, + Status = ElfCreateEventLogHandle((PLOGHANDLE*)LogHandle, + &ModuleNameW, TRUE); RtlFreeUnicodeString(&ModuleNameW); @@ -747,12 +761,13 @@ /* Function 16 */ -NTSTATUS ElfrOpenBELA( +NTSTATUS +ElfrOpenBELA( EVENTLOG_HANDLE_A UNCServerName, PRPC_STRING BackupFileName, - DWORD MajorVersion, - DWORD MinorVersion, - IELF_HANDLE *LogHandle) + ULONG MajorVersion, + ULONG MinorVersion, + PIELF_HANDLE LogHandle) { UNICODE_STRING BackupFileNameW; NTSTATUS Status; @@ -774,11 +789,11 @@ return STATUS_INVALID_PARAMETER; } - /*FIXME: UNCServerName must specify the server */ - - /*FIXME: Must verify that caller has read access */ - - Status = ElfCreateBackupLogHandle((PLOGHANDLE *)LogHandle, + /* FIXME: UNCServerName must specify the server */ + + /* FIXME: Must verify that caller has read access */ + + Status = ElfCreateBackupLogHandle((PLOGHANDLE*)LogHandle, &BackupFileNameW); RtlFreeUnicodeString(&BackupFileNameW); @@ -788,14 +803,15 @@ /* Function 17 */ -NTSTATUS ElfrReadELA( - IELF_HANDLE LogHandle, - DWORD ReadFlags, - DWORD RecordOffset, +NTSTATUS +ElfrReadELA( + IELF_HANDLE LogHandle, + ULONG ReadFlags, + ULONG RecordOffset, RULONG NumberOfBytesToRead, - BYTE *Buffer, - DWORD *NumberOfBytesRead, - DWORD *MinNumberOfBytesNeeded) + PBYTE Buffer, + PULONG NumberOfBytesRead, + PULONG MinNumberOfBytesNeeded) { PLOGHANDLE lpLogHandle; DWORD dwError; @@ -803,9 +819,7 @@ lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); if (!lpLogHandle) - { return STATUS_INVALID_HANDLE; - } if (!Buffer) return STATUS_INVALID_PARAMETER; @@ -829,7 +843,7 @@ MinNumberOfBytesNeeded, TRUE); - /* Update the handles CurrentRecord if success*/ + /* Update the handle's CurrentRecord if success */ if (dwError == ERROR_SUCCESS) { lpLogHandle->CurrentRecord = RecordNumber; @@ -844,21 +858,22 @@ /* Function 18 */ -NTSTATUS ElfrReportEventA( - IELF_HANDLE LogHandle, - DWORD Time, +NTSTATUS +ElfrReportEventA( + IELF_HANDLE LogHandle, + ULONG Time, USHORT EventType, USHORT EventCategory, - DWORD EventID, + ULONG EventID, USHORT NumStrings, - DWORD DataSize, + ULONG DataSize, PRPC_STRING ComputerName, PRPC_SID UserSID, PRPC_STRING Strings[], - BYTE *Data, + PBYTE Data, USHORT Flags, - DWORD *RecordNumber, - DWORD *TimeWritten) + PULONG RecordNumber, + PULONG TimeWritten) { UNICODE_STRING ComputerNameW; PUNICODE_STRING *StringsArrayW = NULL; @@ -891,7 +906,7 @@ { StringsArrayW = HeapAlloc(MyHeap, HEAP_ZERO_MEMORY, - NumStrings * sizeof (PUNICODE_STRING)); + NumStrings * sizeof(PUNICODE_STRING)); if (StringsArrayW == NULL) { Status = STATUS_NO_MEMORY; @@ -964,7 +979,8 @@ /* Function 19 */ -NTSTATUS ElfrRegisterClusterSvc( +NTSTATUS +ElfrRegisterClusterSvc( handle_t BindingHandle) { UNIMPLEMENTED; @@ -973,7 +989,8 @@ /* Function 20 */ -NTSTATUS ElfrDeregisterClusterSvc( +NTSTATUS +ElfrDeregisterClusterSvc( handle_t BindingHandle) { UNIMPLEMENTED; @@ -982,7 +999,8 @@ /* Function 21 */ -NTSTATUS ElfrWriteClusterEvents( +NTSTATUS +ElfrWriteClusterEvents( handle_t BindingHandle) { UNIMPLEMENTED; @@ -991,16 +1009,20 @@ /* Function 22 */ -NTSTATUS ElfrGetLogInformation( - IELF_HANDLE LogHandle, - DWORD InfoLevel, - BYTE *Buffer, - DWORD cbBufSize, - DWORD *pcbBytesNeeded) +NTSTATUS +ElfrGetLogInformation( + IELF_HANDLE LogHandle, + ULONG InfoLevel, + PBYTE Buffer, + ULONG cbBufSize, + PULONG pcbBytesNeeded) { NTSTATUS Status = STATUS_SUCCESS; - - /* FIXME: check handle first */ + PLOGHANDLE lpLogHandle; + + lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); + if (!lpLogHandle) + return STATUS_INVALID_HANDLE; switch (InfoLevel) { @@ -1011,10 +1033,16 @@ *pcbBytesNeeded = sizeof(EVENTLOG_FULL_INFORMATION); if (cbBufSize < sizeof(EVENTLOG_FULL_INFORMATION)) { - return STATUS_BUFFER_TOO_SMALL; + Status = STATUS_BUFFER_TOO_SMALL; + break; } - efi->dwFull = 0; /* FIXME */ + /* + * FIXME. To check whether an event log is "full" one needs + * to compare its current size with respect to the maximum + * size threshold "MaxSize" contained in its header. + */ + efi->dwFull = 0; } break; @@ -1028,7 +1056,8 @@ /* Function 23 */ -NTSTATUS ElfrFlushEL( +NTSTATUS +ElfrFlushEL( IELF_HANDLE LogHandle) { UNIMPLEMENTED; @@ -1037,22 +1066,23 @@ /* Function 24 */ -NTSTATUS ElfrReportEventAndSourceW( - IELF_HANDLE LogHandle, - DWORD Time, +NTSTATUS +ElfrReportEventAndSourceW( + IELF_HANDLE LogHandle, + ULONG Time, USHORT EventType, USHORT EventCategory, ULONG EventID, PRPC_UNICODE_STRING SourceName, USHORT NumStrings, - DWORD DataSize, + ULONG DataSize, PRPC_UNICODE_STRING ComputerName, PRPC_SID UserSID, PRPC_UNICODE_STRING Strings[], - BYTE *Data, + PBYTE Data, USHORT Flags, - DWORD *RecordNumber, - DWORD *TimeWritten) + PULONG RecordNumber, + PULONG TimeWritten) { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; @@ -1073,4 +1103,6 @@ void __RPC_USER IELF_HANDLE_rundown(IELF_HANDLE LogHandle) { -} + /* Close the handle */ + ElfDeleteEventLogHandle(&LogHandle); // ElfrCloseEL(&LogHandle); +}
8 years, 4 months
1
0
0
0
[hbelusca] 72212: [EVENTLOG]: Fix also ElfrChangeNotify here. Addendum to r72211. Must fix the build. CORE-11839
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Aug 12 17:25:36 2016 New Revision: 72212 URL:
http://svn.reactos.org/svn/reactos?rev=72212&view=rev
Log: [EVENTLOG]: Fix also ElfrChangeNotify here. Addendum to r72211. Must fix the build. CORE-11839 Modified: trunk/reactos/base/services/eventlog/rpc.c Modified: trunk/reactos/base/services/eventlog/rpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc…
============================================================================== --- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Fri Aug 12 17:25:36 2016 @@ -357,7 +357,7 @@ /* Function 6 */ NTSTATUS ElfrChangeNotify( - IELF_HANDLE *LogHandle, + IELF_HANDLE LogHandle, RPC_CLIENT_ID ClientId, DWORD Event) {
8 years, 4 months
1
0
0
0
[hbelusca] 72211: [SDK:IDL]: Fix the event log RPC IDL file definitions: - ElfrChangeNotify takes a IELF_HANDLE handle as its first parameter, not a pointer to it. - Since we already use NT-like ty...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Aug 12 17:22:15 2016 New Revision: 72211 URL:
http://svn.reactos.org/svn/reactos?rev=72211&view=rev
Log: [SDK:IDL]: Fix the event log RPC IDL file definitions: - ElfrChangeNotify takes a IELF_HANDLE handle as its first parameter, not a pointer to it. - Since we already use NT-like types (especially for USHORT variables), do the same for the other parameters (DWORD -> ULONG), and also use the Pxxx for pointers to xxx. - Use Windows 2003 maximum size (0x3FFFF) for the event data to be written, instead of the Vista+ limit that is much smaller (0xF000). See also revisions r72207 and r72209. CORE-11839 #resolve Modified: trunk/reactos/sdk/include/reactos/idl/eventlogrpc.idl Modified: trunk/reactos/sdk/include/reactos/idl/eventlogrpc.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/ev…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/eventlogrpc.idl [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/eventlogrpc.idl [iso-8859-1] Fri Aug 12 17:22:15 2016 @@ -8,7 +8,9 @@ typedef long NTSTATUS; cpp_quote("#endif") -#define MAX_BATCH_BUFF 0x0007FFFF +#define MAX_STRINGS 0x00000100 +#define MAX_SINGLE_EVENT 0x0003FFFF // On Vista+ this is reduced to 0x0000F000 +#define MAX_BATCH_BUFF 0x0007FFFF typedef [range(0, MAX_BATCH_BUFF)] unsigned long RULONG; typedef struct _RPC_STRING { @@ -23,8 +25,8 @@ typedef [handle, unique] LPSTR EVENTLOG_HANDLE_A; typedef struct _RPC_CLIENT_ID { - DWORD UniqueProcess; - DWORD UniqueThread; + ULONG UniqueProcess; + ULONG UniqueThread; } RPC_CLIENT_ID, *PRPC_CLIENT_ID; [ @@ -51,80 +53,80 @@ /* Function 2 */ NTSTATUS ElfrCloseEL( - [in, out] IELF_HANDLE *LogHandle); + [in, out] PIELF_HANDLE LogHandle); /* Function 3 */ NTSTATUS ElfrDeregisterEventSource( - [in, out] IELF_HANDLE *LogHandle); + [in, out] PIELF_HANDLE LogHandle); /* Function 4 */ NTSTATUS ElfrNumberOfRecords( [in] IELF_HANDLE LogHandle, - [out] DWORD *NumberOfRecords); + [out] PULONG NumberOfRecords); /* Function 5 */ NTSTATUS ElfrOldestRecord( [in] IELF_HANDLE LogHandle, - [out] DWORD *OldestRecordNumber); + [out] PULONG OldestRecordNumber); /* Function 6 */ NTSTATUS ElfrChangeNotify( - [in] IELF_HANDLE *LogHandle, + [in] IELF_HANDLE LogHandle, [in] RPC_CLIENT_ID ClientId, - [in] DWORD Event); + [in] ULONG Event); /* Function 7 */ NTSTATUS ElfrOpenELW( [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */ [in] PRPC_UNICODE_STRING ModuleName, [in] PRPC_UNICODE_STRING RegModuleName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 8 */ NTSTATUS ElfrRegisterEventSourceW( [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */ [in] PRPC_UNICODE_STRING ModuleName, [in] PRPC_UNICODE_STRING RegModuleName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 9 */ NTSTATUS ElfrOpenBELW( [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */ [in] PRPC_UNICODE_STRING BackupFileName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 10 */ NTSTATUS ElfrReadELW( [in] IELF_HANDLE LogHandle, - [in] DWORD ReadFlags, - [in] DWORD RecordOffset, + [in] ULONG ReadFlags, + [in] ULONG RecordOffset, [in] RULONG NumberOfBytesToRead, - [out, size_is(NumberOfBytesToRead)] BYTE *Buffer, - [out] DWORD *NumberOfBytesRead, - [out] DWORD *MinNumberOfBytesNeeded); + [out, size_is(NumberOfBytesToRead)] PBYTE Buffer, + [out] PULONG NumberOfBytesRead, + [out] PULONG MinNumberOfBytesNeeded); /* Function 11 */ NTSTATUS ElfrReportEventW( [in] IELF_HANDLE LogHandle, - [in] DWORD Time, + [in] ULONG Time, [in] USHORT EventType, [in] USHORT EventCategory, - [in] DWORD EventID, - [in/*, max_is(256)*/] USHORT NumStrings, - [in, range(0, 61440)] DWORD DataSize, + [in] ULONG EventID, + [in, range(0, MAX_STRINGS)] USHORT NumStrings, + [in, range(0, MAX_SINGLE_EVENT)] ULONG DataSize, [in] PRPC_UNICODE_STRING ComputerName, [in, unique] PRPC_SID UserSID, [in, size_is(NumStrings), unique] PRPC_UNICODE_STRING Strings[*], - [in, size_is(DataSize), unique] BYTE *Data, + [in, size_is(DataSize), unique] PBYTE Data, [in] USHORT Flags, - [in, out, unique] DWORD *RecordNumber, - [in, out, unique] DWORD *TimeWritten); + [in, out, unique] PULONG RecordNumber, + [in, out, unique] PULONG TimeWritten); /* Function 12 */ NTSTATUS ElfrClearELFA( @@ -141,53 +143,53 @@ [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */ [in] PRPC_STRING ModuleName, [in] PRPC_STRING RegModuleName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 15 */ NTSTATUS ElfrRegisterEventSourceA( [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */ [in] PRPC_STRING ModuleName, [in] PRPC_STRING RegModuleName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 16 */ NTSTATUS ElfrOpenBELA( [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */ [in] PRPC_STRING BackupFileName, - [in] DWORD MajorVersion, - [in] DWORD MinorVersion, - [out] IELF_HANDLE* LogHandle); + [in] ULONG MajorVersion, + [in] ULONG MinorVersion, + [out] PIELF_HANDLE LogHandle); /* Function 17 */ NTSTATUS ElfrReadELA( [in] IELF_HANDLE LogHandle, - [in] DWORD ReadFlags, - [in] DWORD RecordOffset, + [in] ULONG ReadFlags, + [in] ULONG RecordOffset, [in] RULONG NumberOfBytesToRead, - [out, size_is(NumberOfBytesToRead)] BYTE *Buffer, - [out] DWORD *NumberOfBytesRead, - [out] DWORD *MinNumberOfBytesNeeded); + [out, size_is(NumberOfBytesToRead)] PBYTE Buffer, + [out] PULONG NumberOfBytesRead, + [out] PULONG MinNumberOfBytesNeeded); /* Function 18 */ NTSTATUS ElfrReportEventA( [in] IELF_HANDLE LogHandle, - [in] DWORD Time, + [in] ULONG Time, [in] USHORT EventType, [in] USHORT EventCategory, - [in] DWORD EventID, - [in/*, max_is(256)*/] USHORT NumStrings, - [in, range(0, 61440)] DWORD DataSize, + [in] ULONG EventID, + [in, range(0, MAX_STRINGS)] USHORT NumStrings, + [in, range(0, MAX_SINGLE_EVENT)] ULONG DataSize, [in] PRPC_STRING ComputerName, [in, unique] PRPC_SID UserSID, [in, size_is(NumStrings), unique] PRPC_STRING Strings[*], - [in, size_is(DataSize), unique] BYTE *Data, + [in, size_is(DataSize), unique] PBYTE Data, [in] USHORT Flags, - [in, out, unique] DWORD *RecordNumber, - [in, out, unique] DWORD *TimeWritten); + [in, out, unique] PULONG RecordNumber, + [in, out, unique] PULONG TimeWritten); /* Function 19 */ NTSTATUS ElfrRegisterClusterSvc( @@ -204,10 +206,10 @@ /* Function 22 */ NTSTATUS ElfrGetLogInformation( [in] IELF_HANDLE LogHandle, - [in] DWORD InfoLevel, - [out, size_is(cbBufSize)] BYTE *Buffer, - [in, range(0, 1024)] DWORD cbBufSize, - [out] DWORD *pcbBytesNeeded); + [in] ULONG InfoLevel, + [out, size_is(cbBufSize)] PBYTE Buffer, + [in, range(0, 1024)] ULONG cbBufSize, + [out] PULONG pcbBytesNeeded); /* Function 23 */ NTSTATUS ElfrFlushEL( @@ -216,18 +218,18 @@ /* Function 24 */ NTSTATUS ElfrReportEventAndSourceW( [in] IELF_HANDLE LogHandle, - [in] DWORD Time, + [in] ULONG Time, [in] USHORT EventType, [in] USHORT EventCategory, [in] ULONG EventID, [in] PRPC_UNICODE_STRING SourceName, - [in/*, max_is(256)*/] USHORT NumStrings, - [in, range(0, 61440)] DWORD DataSize, + [in, range(0, MAX_STRINGS)] USHORT NumStrings, + [in, range(0, MAX_SINGLE_EVENT)] ULONG DataSize, [in] PRPC_UNICODE_STRING ComputerName, [in, unique] PRPC_SID UserSID, [in, size_is(NumStrings), unique] PRPC_UNICODE_STRING Strings[*], - [in, size_is(DataSize), unique] BYTE *Data, + [in, size_is(DataSize), unique] PBYTE Data, [in] USHORT Flags, - [in, out, unique] DWORD *RecordNumber, - [in, out, unique] DWORD *TimeWritten); + [in, out, unique] PULONG RecordNumber, + [in, out, unique] PULONG TimeWritten); }
8 years, 4 months
1
0
0
0
[hbelusca] 72210: [SDK]: Move some event log flags to the correct header (from winbase.h to winnt.h). CORE-11839
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Aug 12 14:24:55 2016 New Revision: 72210 URL:
http://svn.reactos.org/svn/reactos?rev=72210&view=rev
Log: [SDK]: Move some event log flags to the correct header (from winbase.h to winnt.h). CORE-11839 Modified: trunk/reactos/sdk/include/psdk/winbase.h trunk/reactos/sdk/include/xdk/winnt_old.h Modified: trunk/reactos/sdk/include/psdk/winbase.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winbase.h…
============================================================================== --- trunk/reactos/sdk/include/psdk/winbase.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winbase.h [iso-8859-1] Fri Aug 12 14:24:55 2016 @@ -387,16 +387,7 @@ #define PURGE_RXABORT 2 #define PURGE_TXCLEAR 4 #define PURGE_RXCLEAR 8 -#define EVENTLOG_SUCCESS 0 -#define EVENTLOG_FORWARDS_READ 4 -#define EVENTLOG_BACKWARDS_READ 8 -#define EVENTLOG_SEEK_READ 2 -#define EVENTLOG_SEQUENTIAL_READ 1 -#define EVENTLOG_ERROR_TYPE 1 -#define EVENTLOG_WARNING_TYPE 2 -#define EVENTLOG_INFORMATION_TYPE 4 -#define EVENTLOG_AUDIT_SUCCESS 8 -#define EVENTLOG_AUDIT_FAILURE 16 + #define FORMAT_MESSAGE_ALLOCATE_BUFFER 256 #define FORMAT_MESSAGE_IGNORE_INSERTS 512 #define FORMAT_MESSAGE_FROM_STRING 1024 Modified: trunk/reactos/sdk/include/xdk/winnt_old.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/xdk/winnt_old.…
============================================================================== --- trunk/reactos/sdk/include/xdk/winnt_old.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/xdk/winnt_old.h [iso-8859-1] Fri Aug 12 14:24:55 2016 @@ -2543,24 +2543,49 @@ struct _EXCEPTION_POINTERS *ExceptionInfo ); + +#define EVENTLOG_SEQUENTIAL_READ 1 +#define EVENTLOG_SEEK_READ 2 +#define EVENTLOG_FORWARDS_READ 4 +#define EVENTLOG_BACKWARDS_READ 8 + +#define EVENTLOG_SUCCESS 0 +#define EVENTLOG_ERROR_TYPE 1 +#define EVENTLOG_WARNING_TYPE 2 +#define EVENTLOG_INFORMATION_TYPE 4 +#define EVENTLOG_AUDIT_SUCCESS 8 +#define EVENTLOG_AUDIT_FAILURE 16 + typedef struct _EVENTLOGRECORD { - DWORD Length; + DWORD Length; /* Length of full record, including the data portion */ DWORD Reserved; DWORD RecordNumber; DWORD TimeGenerated; DWORD TimeWritten; DWORD EventID; WORD EventType; - WORD NumStrings; + WORD NumStrings; /* Number of strings in the 'Strings' array */ WORD EventCategory; WORD ReservedFlags; DWORD ClosingRecordNumber; DWORD StringOffset; DWORD UserSidLength; DWORD UserSidOffset; - DWORD DataLength; - DWORD DataOffset; + DWORD DataLength; /* Length of the data portion */ + DWORD DataOffset; /* Offset from beginning of record */ +/* + * Length-varying data: + * + * WCHAR SourceName[]; + * WCHAR ComputerName[]; + * SID UserSid; // Must be aligned on a DWORD boundary + * WCHAR Strings[]; + * BYTE Data[]; + * CHAR Pad[]; // Padding for DWORD boundary + * DWORD Length; // Same as the first 'Length' member at the beginning + */ } EVENTLOGRECORD, *PEVENTLOGRECORD; + typedef struct _OSVERSIONINFOA { DWORD dwOSVersionInfoSize;
8 years, 4 months
1
0
0
0
[hbelusca] 72209: [ADVAPI32_APITEST]: Addendum to r72207: - Fix the tests so that they test what they have to test, on ReactOS & Windows 2k3/XP. (Note that here, ReactOS used the more restrained ev...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Aug 12 13:38:49 2016 New Revision: 72209 URL:
http://svn.reactos.org/svn/reactos?rev=72209&view=rev
Log: [ADVAPI32_APITEST]: Addendum to r72207: - Fix the tests so that they test what they have to test, on ReactOS & Windows 2k3/XP. (Note that here, ReactOS used the more restrained event size limitations of Vista+ compared to those of Win2k3. I choose to test, and will implement, the size limitations of Win2k3.) - Choose a different name for the test such that it doesn't collide with the 'eventlog' test from advapi32_winetest. CORE-11838 CORE-11839 Modified: trunk/rostests/apitests/advapi32/eventlog.c trunk/rostests/apitests/advapi32/testlist.c Modified: trunk/rostests/apitests/advapi32/eventlog.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/eventlo…
============================================================================== --- trunk/rostests/apitests/advapi32/eventlog.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/eventlog.c [iso-8859-1] Fri Aug 12 13:38:49 2016 @@ -17,7 +17,7 @@ /* Input */ ULONG MaxDataSize; - /* Output for Windows <= 2k3 / Windows Vista+ */ + /* Output for Windows <= 2k3 | Windows Vista+ (or "old" ReactOS) */ struct { BOOL Success; @@ -39,8 +39,8 @@ { 0x3FF68, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } }, /* Show that the maximum data size for an event can be as big as 0x3FFFF */ - { 0x3FFFE, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, - { 0x3FFFF, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x3FFFE, { {TRUE, ERROR_SUCCESS /* or FALSE, ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x3FFFF, { {TRUE, ERROR_SUCCESS /* or FALSE, ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, { 0x40000, { {FALSE, RPC_X_BAD_STUB_DATA}, {FALSE, RPC_S_INVALID_BOUND} } }, }; @@ -73,13 +73,12 @@ if (LastError == ERROR_ENVVAR_NOT_FOUND) LastError = ERROR_SUCCESS; - ok((LastError == Tests[i].Result[0].LastError) || - broken(LastError == ERROR_INVALID_PARAMETER /* For Win2k3, see above */) || - broken(LastError == Tests[i].Result[1].LastError /* For Vista+ */), - "ReportEventW(%u) last error was %lu, expected %lu\n", i, LastError, Tests[i].Result[0].LastError); - - ok((Success == Tests[i].Result[0].Success) || broken(Success == Tests[i].Result[1].Success /* For Vista+ */), - "ReportEventW(%u) returned 0x%x, expected %s\n", i, Success, (Tests[i].Result[0].Success ? "TRUE" : "FALSE")); + ok( ( (Success == Tests[i].Result[0].Success) && (LastError == Tests[i].Result[0].LastError) ) || + broken( (Success == FALSE) && (LastError == ERROR_INVALID_PARAMETER) /* For Win2k3, see above */) // || + // broken( (Success == Tests[i].Result[1].Success) && (LastError == Tests[i].Result[1].LastError) /* For Vista+ */) + , + "ReportEventW(%u) returned 0x%x with last error %lu, expected %s with last error %lu\n", + i, Success, LastError, (Tests[i].Result[0].Success ? "TRUE" : "FALSE"), Tests[i].Result[0].LastError); HeapFree(GetProcessHeap(), 0, Data); } Modified: trunk/rostests/apitests/advapi32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
============================================================================== --- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Fri Aug 12 13:38:49 2016 @@ -19,7 +19,7 @@ { { "CreateService", func_CreateService }, { "DuplicateTokenEx", func_DuplicateTokenEx }, - { "eventlog", func_eventlog }, + { "eventlog_supp", func_eventlog }, { "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT }, { "IsTextUnicode" , func_IsTextUnicode }, { "LockDatabase" , func_LockDatabase },
8 years, 4 months
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
47
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Results per page:
10
25
50
100
200