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
October 2018
----- 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
21 participants
354 discussions
Start a n
N
ew thread
01/01: [NETCFGX] Implement the Min and Max options for int, long and word parameters.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=debb1e521a2feb5d98e51…
commit debb1e521a2feb5d98e51dfbdc0bd0b3082c59bd Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sun Oct 14 21:02:45 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sun Oct 14 21:02:45 2018 +0200 [NETCFGX] Implement the Min and Max options for int, long and word parameters. CORE-15095 --- dll/win32/netcfgx/propertypage.c | 85 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/dll/win32/netcfgx/propertypage.c b/dll/win32/netcfgx/propertypage.c index b069cf6062..abf44daa0d 100644 --- a/dll/win32/netcfgx/propertypage.c +++ b/dll/win32/netcfgx/propertypage.c @@ -43,6 +43,8 @@ typedef struct _PARAMETER INT iBase; INT iStep; + LONG lMin; + LONG lMax; } PARAMETER, *PPARAMETER; typedef struct _PARAMETER_ARRAY @@ -199,6 +201,41 @@ GetIntValue( } +static DWORD +GetLongValue( + _In_ HKEY hKey, + _In_ PWSTR pValueName, + _In_ LONG lDefault, + _Out_ PLONG pValue) +{ + WCHAR szBuffer[24]; + DWORD dwLength = 0; + DWORD dwRegType; + PWSTR ptr = NULL; + + dwLength = sizeof(szBuffer); + RegQueryValueExW(hKey, + pValueName, + NULL, + &dwRegType, + (LPBYTE)szBuffer, + &dwLength); + + if (dwRegType == REG_SZ && dwLength >= sizeof(WCHAR)) + { + *pValue = wcstol(szBuffer, &ptr, 10); + if (*pValue == 0 && ptr != NULL) + *pValue = lDefault; + } + else + { + *pValue = lDefault; + } + + return ERROR_SUCCESS; +} + + static DWORD GetEnumOptions( @@ -350,6 +387,7 @@ BuildParameterArray( DWORD dwSubKeys, dwMaxSubKeyLen, dwKeyLen, dwIndex; PWSTR pszType = NULL; LONG lError; + LONG lDefaultMin, lDefaultMax; BOOL ret = FALSE; hDriverKey = SetupDiOpenDevRegKey(DeviceInfoSet, @@ -493,7 +531,38 @@ BuildParameterArray( ParamArray->Array[dwIndex].Type == WORD_TYPE || ParamArray->Array[dwIndex].Type == DWORD_TYPE) { - /* FIXME: Read Min and Max values */ + if (ParamArray->Array[dwIndex].Type == INT_TYPE) + { + lDefaultMin = -32768L; //MIN_SHORT; + lDefaultMax = 32767L; //MAX_SHORT; + } + else if (ParamArray->Array[dwIndex].Type == LONG_TYPE) + { + lDefaultMin = (-2147483647L - 1); // MIN_LONG; + lDefaultMax = 2147483647L; // MAX_LONG; + } + else if (ParamArray->Array[dwIndex].Type == WORD_TYPE) + { + lDefaultMin = 0L; + lDefaultMax = 65535L; // MAX_WORD; + } +#if 0 + else if (ParamArray->Array[dwIndex].Type == DWORD_TYPE) + { + lDefaultMin = 0; + lDefaultMax = 4294967295; //MAX_DWORD; + } +#endif + + GetLongValue(hParamKey, + L"Min", + lDefaultMin, + &ParamArray->Array[dwIndex].lMin); + + GetLongValue(hParamKey, + L"Max", + lDefaultMax, + &ParamArray->Array[dwIndex].lMax); GetIntValue(hParamKey, L"Base", @@ -692,14 +761,24 @@ DisplayParameter( ShowWindow(GetDlgItem(hwnd, IDC_PROPERTY_VALUE_LIST), SW_HIDE); hwndControl = GetDlgItem(hwnd, IDC_PROPERTY_VALUE_UPDN); - EnableWindow(hwndControl, Parameter->bPresent); - ShowWindow(hwndControl, SW_SHOW); + + if (Parameter->Type != DWORD_TYPE) + { + EnableWindow(hwndControl, Parameter->bPresent); + ShowWindow(hwndControl, SW_SHOW); + } if (Parameter->Type == WORD_TYPE || Parameter->Type == DWORD_TYPE) SendMessage(hwndControl, UDM_SETBASE, Parameter->iBase, 0); else SendMessage(hwndControl, UDM_SETBASE, 10, 0); + if (Parameter->Type != DWORD_TYPE) + { + TRACE("SetMin %ld SetMax %ld\n", Parameter->lMin, Parameter->lMax); + SendMessage(hwndControl, UDM_SETRANGE32, Parameter->lMin, Parameter->lMax); + } + hwndControl = GetDlgItem(hwnd, IDC_PROPERTY_VALUE_EDIT); EnableWindow(hwndControl, Parameter->bPresent); ShowWindow(hwndControl, SW_SHOW);
6 years, 2 months
1
0
0
0
01/01: [NEWDEV] Add InstallDevInstEx
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=731ef01361938138d7566…
commit 731ef01361938138d7566a18955a7fbb77485f52 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sun Oct 14 18:17:42 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sun Oct 14 18:19:52 2018 +0200 [NEWDEV] Add InstallDevInstEx --- dll/win32/newdev/newdev.c | 23 ++++++++++++++++++++--- dll/win32/newdev/newdev.spec | 2 +- sdk/include/reactos/dll/newdevp.h | 9 +++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dll/win32/newdev/newdev.c b/dll/win32/newdev/newdev.c index 1b30c96dd5..960f75212d 100644 --- a/dll/win32/newdev/newdev.c +++ b/dll/win32/newdev/newdev.c @@ -807,17 +807,19 @@ cleanup: BOOL WINAPI -InstallDevInst( +InstallDevInstEx( IN HWND hWndParent, IN LPCWSTR InstanceId, IN BOOL bUpdate, - OUT LPDWORD lpReboot) + OUT LPDWORD lpReboot, + IN DWORD Unknown) { PDEVINSTDATA DevInstData = NULL; BOOL ret; BOOL retval = FALSE; - TRACE("InstllDevInst(%p, %s, %d, %p)\n", hWndParent, debugstr_w(InstanceId), bUpdate, lpReboot); + TRACE("InstllDevInstEx(%p, %s, %d, %p, %lx)\n", + hWndParent, debugstr_w(InstanceId), bUpdate, lpReboot, Unknown); DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA)); if (!DevInstData) @@ -916,6 +918,21 @@ cleanup: } +/* + * @implemented + */ +BOOL +WINAPI +InstallDevInst( + IN HWND hWndParent, + IN LPCWSTR InstanceId, + IN BOOL bUpdate, + OUT LPDWORD lpReboot) +{ + return InstallDevInstEx(hWndParent, InstanceId, bUpdate, lpReboot, 0); +} + + /* * @implemented */ diff --git a/dll/win32/newdev/newdev.spec b/dll/win32/newdev/newdev.spec index 56e3d1b4ea..58af6c4171 100644 --- a/dll/win32/newdev/newdev.spec +++ b/dll/win32/newdev/newdev.spec @@ -1,7 +1,7 @@ @ stdcall ClientSideInstallW(ptr ptr wstr long) @ stdcall DevInstallW(ptr ptr wstr long) @ stdcall InstallDevInst(ptr wstr long ptr) -@ stub InstallDevInstEx +@ stdcall InstallDevInstEx(ptr wstr long ptr long) @ stdcall InstallNewDevice(ptr ptr ptr) @ stub InstallSelectedDevice @ stdcall InstallSelectedDriverW(ptr ptr wstr long ptr) diff --git a/sdk/include/reactos/dll/newdevp.h b/sdk/include/reactos/dll/newdevp.h index 5ddcee203b..4967996a24 100644 --- a/sdk/include/reactos/dll/newdevp.h +++ b/sdk/include/reactos/dll/newdevp.h @@ -28,6 +28,15 @@ InstallDevInst( IN BOOL bUpdate, OUT LPDWORD lpReboot); +BOOL +WINAPI +InstallDevInstEx( + IN HWND hWndParent, + IN LPCWSTR InstanceId, + IN BOOL bUpdate, + OUT LPDWORD lpReboot, + IN DWORD Unknown); + #ifdef __cplusplus } #endif
6 years, 2 months
1
0
0
0
09/09: [MKHIVE] Return win32-like error codes for functions that expect to do so. Fix and comment out some unused ERROR_xxx/STATUS_xxx defines.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fc35f6eb4b09ce279931e…
commit fc35f6eb4b09ce279931eee31abd6e6f5a6bcd08 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 17:10:04 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 17:10:04 2018 +0200 [MKHIVE] Return win32-like error codes for functions that expect to do so. Fix and comment out some unused ERROR_xxx/STATUS_xxx defines. --- sdk/tools/mkhive/mkhive.h | 12 ++++---- sdk/tools/mkhive/registry.c | 74 ++++++++++++++++++++++----------------------- sdk/tools/mkhive/registry.h | 12 +++++--- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/sdk/tools/mkhive/mkhive.h b/sdk/tools/mkhive/mkhive.h index 2799020f0c..b516b650d9 100644 --- a/sdk/tools/mkhive/mkhive.h +++ b/sdk/tools/mkhive/mkhive.h @@ -42,13 +42,13 @@ // We only want to include host headers, so we define them manually #define STATUS_SUCCESS ((NTSTATUS)0x00000000) #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001) -#define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002) -#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000D) -#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017) -#define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A) +// #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002) +// #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000D) +// #define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017) +// #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A) #define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034) -#define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0) -#define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005) +// #define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0) +// #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005) unsigned char BitScanForward(ULONG * Index, unsigned long Mask); unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index f82d4e5c5b..d6a2028990 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -30,10 +30,7 @@ #define NDEBUG #include "mkhive.h" -/* DEFINITIONS AND DATA *****************************************************/ - -#define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017D) -#define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121) +/* DATA *********************************************************************/ typedef struct _REPARSE_POINT { @@ -396,10 +393,10 @@ RegpCreateOrOpenKey( IN BOOL Volatile, OUT PHKEY Key) { + NTSTATUS Status; PWSTR LocalKeyName; PWSTR End; UNICODE_STRING KeyString; - NTSTATUS Status; PREPARSE_POINT CurrentReparsePoint; PMEMKEY CurrentKey; PCMHIVE ParentRegistryHive; @@ -450,7 +447,7 @@ RegpCreateOrOpenKey( ParentKeyCell = (PCM_KEY_NODE)HvGetCell(&ParentRegistryHive->Hive, ParentCellOffset); if (!ParentKeyCell) - return STATUS_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; VERIFY_KEY_CELL(ParentKeyCell); @@ -484,15 +481,15 @@ RegpCreateOrOpenKey( } else // if (BlockOffset == HCELL_NIL) { - Status = STATUS_OBJECT_NAME_NOT_FOUND; // ERROR_PATH_NOT_FOUND; + Status = STATUS_OBJECT_NAME_NOT_FOUND; } HvReleaseCell(&ParentRegistryHive->Hive, ParentCellOffset); if (!NT_SUCCESS(Status)) { - DPRINT("RegpCreateOrOpenKey('%S'): Could not create or open subkey '%wZ'\n", KeyName, &KeyString); - return ERROR_UNSUCCESSFUL; + DPRINT("RegpCreateOrOpenKey('%S'): Could not create or open subkey '%wZ', Status 0x%08x\n", KeyName, &KeyString, Status); + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; } ParentCellOffset = BlockOffset; @@ -504,7 +501,7 @@ RegpCreateOrOpenKey( CurrentKey = CreateInMemoryStructure(ParentRegistryHive, ParentCellOffset); if (!CurrentKey) - return ERROR_OUTOFMEMORY; + return ERROR_NOT_ENOUGH_MEMORY; // STATUS_NO_MEMORY; *Key = MEMKEY_TO_HKEY(CurrentKey); @@ -557,6 +554,7 @@ RegDeleteKeyW( IN LPCWSTR lpSubKey) { LONG rc; + NTSTATUS Status; HKEY hTargetKey; PMEMKEY Key; // ParentKey PHHIVE Hive; @@ -564,8 +562,6 @@ RegDeleteKeyW( PCM_KEY_NODE Parent; HCELL_INDEX ParentCell; - NTSTATUS Status; - if (lpSubKey) { rc = RegOpenKeyW(hKey, lpSubKey, &hTargetKey); @@ -581,7 +577,7 @@ RegDeleteKeyW( if (hTargetKey == RootKey) { /* Fail */ - Status = STATUS_CANNOT_DELETE; + rc = ERROR_ACCESS_DENIED; // STATUS_CANNOT_DELETE; goto Quit; } @@ -593,7 +589,7 @@ RegDeleteKeyW( KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); if (!KeyNode) { - Status = ERROR_UNSUCCESSFUL; + rc = ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; goto Quit; } @@ -622,11 +618,16 @@ RegDeleteKeyW( HvReleaseCell(Hive, ParentCell); } } + else + { + /* Fail */ + rc = ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; + } } else { /* Fail */ - Status = STATUS_CANNOT_DELETE; + rc = ERROR_ACCESS_DENIED; // STATUS_CANNOT_DELETE; } /* Release the cell */ @@ -636,7 +637,7 @@ Quit: if (lpSubKey) RegCloseKey(hTargetKey); - return Status; + return rc; } LONG WINAPI @@ -675,7 +676,7 @@ RegSetValueExW( /* Special handling of registry links */ if (cbData != sizeof(PVOID)) - return STATUS_INVALID_PARAMETER; + return ERROR_INVALID_PARAMETER; // STATUS_INVALID_PARAMETER; DestKey = HKEY_TO_MEMKEY(*(PHKEY)lpData); @@ -683,20 +684,20 @@ RegSetValueExW( /* Create the link in registry hive (if applicable) */ if (Key->RegistryHive != DestKey->RegistryHive) - return STATUS_SUCCESS; + return ERROR_SUCCESS; DPRINT1("Save link to registry\n"); - return STATUS_NOT_IMPLEMENTED; + return ERROR_INVALID_FUNCTION; // STATUS_NOT_IMPLEMENTED; } if ((cbData & ~CM_KEY_VALUE_SPECIAL_SIZE) != cbData) - return STATUS_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; Hive = &Key->RegistryHive->Hive; KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); if (!KeyNode) - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); @@ -714,8 +715,7 @@ RegSetValueExW( /* Sanity check */ ASSERT(CellIndex == HCELL_NIL); /* Fail */ - // Status = STATUS_INSUFFICIENT_RESOURCES; - return ERROR_UNSUCCESSFUL; + Status = STATUS_INSUFFICIENT_RESOURCES; } if (CellIndex == HCELL_NIL) { @@ -738,7 +738,7 @@ RegSetValueExW( // /**/HvReleaseCell(Hive, CellIndex);/**/ if (!NT_SUCCESS(Status)) - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; /* Get size of the allocated cell (if any) */ if (!(ValueCell->DataLength & CM_KEY_VALUE_SPECIAL_SIZE) && @@ -746,7 +746,7 @@ RegSetValueExW( { DataCell = HvGetCell(Hive, ValueCell->Data); if (!DataCell) - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; DataCellSize = (ULONG)(-HvGetCellSize(Hive, DataCell)); } @@ -781,7 +781,7 @@ RegSetValueExW( if (NewOffset == HCELL_NIL) { DPRINT("HvAllocateCell() has failed!\n"); - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; } if (DataCell) @@ -873,7 +873,7 @@ RegQueryValueExW( KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, ParentKey->KeyCellOffset); if (!KeyNode) - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); @@ -881,7 +881,7 @@ RegQueryValueExW( RtlInitUnicodeString(&ValueNameString, lpValueName); CellIndex = CmpFindValueByName(Hive, KeyNode, &ValueNameString); if (CellIndex == HCELL_NIL) - return ERROR_FILE_NOT_FOUND; + return ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; /* Get the value cell */ ValueCell = HvGetCell(Hive, CellIndex); @@ -899,6 +899,8 @@ RegDeleteValueW( IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL) { + LONG rc; + NTSTATUS Status; PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey PHHIVE Hive = &Key->RegistryHive->Hive; PCM_KEY_NODE KeyNode; // ParentNode @@ -907,11 +909,9 @@ RegDeleteValueW( ULONG ChildIndex; UNICODE_STRING ValueNameString; - NTSTATUS Status; - KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); if (!KeyNode) - return ERROR_UNSUCCESSFUL; + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); @@ -928,7 +928,7 @@ RegDeleteValueW( } if (CellIndex == HCELL_NIL) { - Status = ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; + rc = ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; goto Quit; } @@ -945,7 +945,7 @@ RegDeleteValueW( if (!CmpMarkValueDataDirty(Hive, ValueCell)) { /* Not enough log space, fail */ - Status = STATUS_NO_LOG_SPACE; + rc = ERROR_NO_LOG_SPACE; // STATUS_NO_LOG_SPACE; goto Quit; } @@ -958,7 +958,7 @@ RegDeleteValueW( if (!NT_SUCCESS(Status)) { /* Set known error */ - Status = STATUS_INSUFFICIENT_RESOURCES; + rc = ERROR_NO_SYSTEM_RESOURCES; // STATUS_INSUFFICIENT_RESOURCES; goto Quit; } @@ -966,7 +966,7 @@ RegDeleteValueW( if (!CmpFreeValue(Hive, CellIndex)) { /* Failed to free the value, fail */ - Status = STATUS_INSUFFICIENT_RESOURCES; + rc = ERROR_NO_SYSTEM_RESOURCES; // STATUS_INSUFFICIENT_RESOURCES; goto Quit; } @@ -985,7 +985,7 @@ RegDeleteValueW( } /* Change default Status to success */ - Status = STATUS_SUCCESS; + rc = ERROR_SUCCESS; Quit: /* Check if we had a value */ @@ -1000,7 +1000,7 @@ Quit: if (KeyNode) HvReleaseCell(Hive, Key->KeyCellOffset); - return Status; + return rc; } diff --git a/sdk/tools/mkhive/registry.h b/sdk/tools/mkhive/registry.h index 9c46af4e60..f5ad0fe8fd 100644 --- a/sdk/tools/mkhive/registry.h +++ b/sdk/tools/mkhive/registry.h @@ -20,12 +20,16 @@ typedef struct _HIVE_LIST_ENTRY extern HIVE_LIST_ENTRY RegistryHives[]; #define ERROR_SUCCESS 0L -#define ERROR_UNSUCCESSFUL 1L +#define ERROR_INVALID_FUNCTION 1L #define ERROR_FILE_NOT_FOUND 2L -#define ERROR_OUTOFMEMORY 14L +#define ERROR_ACCESS_DENIED 5L +#define ERROR_NOT_ENOUGH_MEMORY 8L +#define ERROR_GEN_FAILURE 31L #define ERROR_INVALID_PARAMETER 87L -#define ERROR_MORE_DATA 234L -#define ERROR_NO_MORE_ITEMS 259L +// #define ERROR_MORE_DATA 234L +// #define ERROR_NO_MORE_ITEMS 259L +#define ERROR_NO_LOG_SPACE 1019L +#define ERROR_NO_SYSTEM_RESOURCES 1450L #define REG_NONE 0 #define REG_SZ 1
6 years, 2 months
1
0
0
0
08/09: [MKHIVE] Minor code formatting.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8f82b00fa6c89b4730111…
commit 8f82b00fa6c89b47301115d61e0d8371ae4f0863 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 16:28:13 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 16:28:13 2018 +0200 [MKHIVE] Minor code formatting. --- sdk/tools/mkhive/binhive.c | 4 ++-- sdk/tools/mkhive/cmi.c | 5 +++++ sdk/tools/mkhive/cmi.h | 2 ++ sdk/tools/mkhive/mkhive.c | 3 +++ sdk/tools/mkhive/mkhive.h | 1 + sdk/tools/mkhive/registry.c | 25 +++++++++++++++++++++++++ sdk/tools/mkhive/registry.h | 19 ------------------- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/sdk/tools/mkhive/binhive.c b/sdk/tools/mkhive/binhive.c index 3d99346d9a..6615649924 100644 --- a/sdk/tools/mkhive/binhive.c +++ b/sdk/tools/mkhive/binhive.c @@ -26,10 +26,10 @@ /* INCLUDES *****************************************************************/ -#include <stdio.h> - #include "mkhive.h" +/* FUNCTIONS ****************************************************************/ + BOOL ExportBinaryHive( IN PCSTR FileName, diff --git a/sdk/tools/mkhive/cmi.c b/sdk/tools/mkhive/cmi.c index 6856cd1902..3798f54f9c 100644 --- a/sdk/tools/mkhive/cmi.c +++ b/sdk/tools/mkhive/cmi.c @@ -25,9 +25,13 @@ * Herm�s B�lusca-Ma�to */ +/* INCLUDES *****************************************************************/ + #define NDEBUG #include "mkhive.h" +/* FUNCTIONS ****************************************************************/ + PVOID NTAPI CmpAllocate( @@ -422,6 +426,7 @@ CmiAddValueKey( { *pValueCell = NewValueCell; *pValueCellOffset = NewValueCellOffset; + Status = STATUS_SUCCESS; } return Status; diff --git a/sdk/tools/mkhive/cmi.h b/sdk/tools/mkhive/cmi.h index 88611c2d4c..b34b098483 100644 --- a/sdk/tools/mkhive/cmi.h +++ b/sdk/tools/mkhive/cmi.h @@ -24,6 +24,8 @@ * PROGRAMMER: Herv� Poussineau */ +#pragma once + #define VERIFY_KEY_CELL(key) NTSTATUS diff --git a/sdk/tools/mkhive/mkhive.c b/sdk/tools/mkhive/mkhive.c index 7458a5a71f..ab4342c9d9 100644 --- a/sdk/tools/mkhive/mkhive.c +++ b/sdk/tools/mkhive/mkhive.c @@ -26,6 +26,8 @@ * Hermès Bélusca-Maïto */ +/* INCLUDES *****************************************************************/ + #include <limits.h> #include <string.h> #include <stdio.h> @@ -48,6 +50,7 @@ #define DIR_SEPARATOR_STRING "\\" #endif +/* FUNCTIONS ****************************************************************/ void usage(void) { diff --git a/sdk/tools/mkhive/mkhive.h b/sdk/tools/mkhive/mkhive.h index 82c8ecc2c3..2799020f0c 100644 --- a/sdk/tools/mkhive/mkhive.h +++ b/sdk/tools/mkhive/mkhive.h @@ -67,6 +67,7 @@ VOID NTAPI RtlInitUnicodeString( IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString); + WCHAR NTAPI RtlUpcaseUnicodeChar( IN WCHAR Source); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 8fbc7d5b15..f82d4e5c5b 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -25,12 +25,35 @@ * Hermès Bélusca-Maïto */ +/* INCLUDES *****************************************************************/ + #define NDEBUG #include "mkhive.h" +/* DEFINITIONS AND DATA *****************************************************/ + #define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017D) #define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121) +typedef struct _REPARSE_POINT +{ + LIST_ENTRY ListEntry; + PCMHIVE SourceHive; + HCELL_INDEX SourceKeyCellOffset; + PCMHIVE DestinationHive; + HCELL_INDEX DestinationKeyCellOffset; +} REPARSE_POINT, *PREPARSE_POINT; + +typedef struct _MEMKEY +{ + /* Information on hard disk structure */ + HCELL_INDEX KeyCellOffset; + PCMHIVE RegistryHive; +} MEMKEY, *PMEMKEY; + +#define HKEY_TO_MEMKEY(hKey) ((PMEMKEY)(hKey)) +#define MEMKEY_TO_HKEY(memKey) ((HKEY)(memKey)) + static CMHIVE RootHive; static PMEMKEY RootKey; @@ -326,6 +349,7 @@ static UCHAR SystemSecurity[] = 0x01, 0x02, 0x00, 0x00 }; +/* GLOBALS ******************************************************************/ HIVE_LIST_ENTRY RegistryHives[/*MAX_NUMBER_OF_REGISTRY_HIVES*/] = { @@ -343,6 +367,7 @@ HIVE_LIST_ENTRY RegistryHives[/*MAX_NUMBER_OF_REGISTRY_HIVES*/] = }; C_ASSERT(_countof(RegistryHives) == MAX_NUMBER_OF_REGISTRY_HIVES); +/* FUNCTIONS ****************************************************************/ static PMEMKEY CreateInMemoryStructure( diff --git a/sdk/tools/mkhive/registry.h b/sdk/tools/mkhive/registry.h index 7712de9d55..9c46af4e60 100644 --- a/sdk/tools/mkhive/registry.h +++ b/sdk/tools/mkhive/registry.h @@ -7,25 +7,6 @@ #pragma once -typedef struct _REPARSE_POINT -{ - LIST_ENTRY ListEntry; - PCMHIVE SourceHive; - HCELL_INDEX SourceKeyCellOffset; - PCMHIVE DestinationHive; - HCELL_INDEX DestinationKeyCellOffset; -} REPARSE_POINT, *PREPARSE_POINT; - -typedef struct _MEMKEY -{ - /* Information on hard disk structure */ - HCELL_INDEX KeyCellOffset; - PCMHIVE RegistryHive; -} MEMKEY, *PMEMKEY; - -#define HKEY_TO_MEMKEY(hKey) ((PMEMKEY)(hKey)) -#define MEMKEY_TO_HKEY(memKey) ((HKEY)(memKey)) - typedef struct _HIVE_LIST_ENTRY { PCSTR HiveName;
6 years, 2 months
1
0
0
0
07/09: [MKHIVE] Implement RegDeleteKeyW() and RegDeleteValueW().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d91a47826e64e6766aae0…
commit d91a47826e64e6766aae069773d4a5470576fe59 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 15:31:12 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:57 2018 +0200 [MKHIVE] Implement RegDeleteKeyW() and RegDeleteValueW(). --- sdk/tools/mkhive/registry.c | 197 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 186 insertions(+), 11 deletions(-) diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index a3cc712184..8fbc7d5b15 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -25,14 +25,12 @@ * Hermès Bélusca-Maïto */ -/* - * TODO: - * - Implement RegDeleteKeyW() and RegDeleteValueW() - */ - #define NDEBUG #include "mkhive.h" +#define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017D) +#define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121) + static CMHIVE RootHive; static PMEMKEY RootKey; @@ -533,9 +531,87 @@ RegDeleteKeyW( IN HKEY hKey, IN LPCWSTR lpSubKey) { - DPRINT1("RegDeleteKeyW(0x%p, '%S') is UNIMPLEMENTED!\n", - hKey, (lpSubKey ? lpSubKey : L"")); - return ERROR_SUCCESS; + LONG rc; + HKEY hTargetKey; + PMEMKEY Key; // ParentKey + PHHIVE Hive; + PCM_KEY_NODE KeyNode; // ParentNode + PCM_KEY_NODE Parent; + HCELL_INDEX ParentCell; + + NTSTATUS Status; + + if (lpSubKey) + { + rc = RegOpenKeyW(hKey, lpSubKey, &hTargetKey); + if (rc != ERROR_SUCCESS) + return rc; + } + else + { + hTargetKey = hKey; + } + + /* Don't allow deleting the root */ + if (hTargetKey == RootKey) + { + /* Fail */ + Status = STATUS_CANNOT_DELETE; + goto Quit; + } + + /* Get the hive and node */ + Key = HKEY_TO_MEMKEY(hTargetKey); + Hive = &Key->RegistryHive->Hive; + + /* Get the key node */ + KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); + if (!KeyNode) + { + Status = ERROR_UNSUCCESSFUL; + goto Quit; + } + + ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); + + /* Check if we don't have any children */ + if (!(KeyNode->SubKeyCounts[Stable] + KeyNode->SubKeyCounts[Volatile]) && + !(KeyNode->Flags & KEY_NO_DELETE)) + { + /* Get the parent and free the cell */ + ParentCell = KeyNode->Parent; + Status = CmpFreeKeyByCell(Hive, Key->KeyCellOffset, TRUE); + if (NT_SUCCESS(Status)) + { + /* Get the parent node */ + Parent = (PCM_KEY_NODE)HvGetCell(Hive, ParentCell); + if (Parent) + { + /* Make sure we're dirty */ + ASSERT(HvIsCellDirty(Hive, ParentCell)); + + /* Update the write time */ + KeQuerySystemTime(&Parent->LastWriteTime); + + /* Release the cell */ + HvReleaseCell(Hive, ParentCell); + } + } + } + else + { + /* Fail */ + Status = STATUS_CANNOT_DELETE; + } + + /* Release the cell */ + HvReleaseCell(Hive, Key->KeyCellOffset); + +Quit: + if (lpSubKey) + RegCloseKey(hTargetKey); + + return Status; } LONG WINAPI @@ -798,9 +874,108 @@ RegDeleteValueW( IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL) { - DPRINT1("RegDeleteValueW(0x%p, '%S') is UNIMPLEMENTED!\n", - hKey, (lpValueName ? lpValueName : L"")); - return ERROR_UNSUCCESSFUL; + PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey + PHHIVE Hive = &Key->RegistryHive->Hive; + PCM_KEY_NODE KeyNode; // ParentNode + PCM_KEY_VALUE ValueCell; + HCELL_INDEX CellIndex; + ULONG ChildIndex; + UNICODE_STRING ValueNameString; + + NTSTATUS Status; + + KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); + if (!KeyNode) + return ERROR_UNSUCCESSFUL; + + ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); + + /* Initialize value name string */ + RtlInitUnicodeString(&ValueNameString, lpValueName); + if (!CmpFindNameInList(Hive, + &KeyNode->ValueList, + &ValueNameString, + &ChildIndex, + &CellIndex)) + { + /* Sanity check */ + ASSERT(CellIndex == HCELL_NIL); + } + if (CellIndex == HCELL_NIL) + { + Status = ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; + goto Quit; + } + + /* We found the value, mark all relevant cells dirty */ + HvMarkCellDirty(Hive, Key->KeyCellOffset, FALSE); + HvMarkCellDirty(Hive, KeyNode->ValueList.List, FALSE); + HvMarkCellDirty(Hive, CellIndex, FALSE); + + /* Get the key value */ + ValueCell = (PCM_KEY_VALUE)HvGetCell(Hive, CellIndex); + ASSERT(ValueCell); + + /* Mark it and all related data as dirty */ + if (!CmpMarkValueDataDirty(Hive, ValueCell)) + { + /* Not enough log space, fail */ + Status = STATUS_NO_LOG_SPACE; + goto Quit; + } + + /* Sanity checks */ + ASSERT(HvIsCellDirty(Hive, KeyNode->ValueList.List)); + ASSERT(HvIsCellDirty(Hive, CellIndex)); + + /* Remove the value from the child list */ + Status = CmpRemoveValueFromList(Hive, ChildIndex, &KeyNode->ValueList); + if (!NT_SUCCESS(Status)) + { + /* Set known error */ + Status = STATUS_INSUFFICIENT_RESOURCES; + goto Quit; + } + + /* Remove the value and its data itself */ + if (!CmpFreeValue(Hive, CellIndex)) + { + /* Failed to free the value, fail */ + Status = STATUS_INSUFFICIENT_RESOURCES; + goto Quit; + } + + /* Set the last write time */ + KeQuerySystemTime(&KeyNode->LastWriteTime); + + /* Sanity check */ + ASSERT(HvIsCellDirty(Hive, Key->KeyCellOffset)); + + /* Check if the value list is empty now */ + if (!KeyNode->ValueList.Count) + { + /* Then clear key node data */ + KeyNode->MaxValueNameLen = 0; + KeyNode->MaxValueDataLen = 0; + } + + /* Change default Status to success */ + Status = STATUS_SUCCESS; + +Quit: + /* Check if we had a value */ + if (ValueCell) + { + /* Release the child cell */ + ASSERT(CellIndex != HCELL_NIL); + HvReleaseCell(Hive, CellIndex); + } + + /* Release the parent cell, if any */ + if (KeyNode) + HvReleaseCell(Hive, Key->KeyCellOffset); + + return Status; }
6 years, 2 months
1
0
0
0
06/09: [MKHIVE] Minor improvements.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a44c10d5de75886fd98d…
commit 6a44c10d5de75886fd98d8e491c371b3832e1b27 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 15:26:30 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:54 2018 +0200 [MKHIVE] Minor improvements. - Fix a bug in RegpCreateOrOpenKey() when we attempt to open an non-existing (sub-)key. - Check failure of RegCreateKeyExW() in CreateSymLink(). - Remove unneeded includes. - Update few comments. --- sdk/tools/mkhive/registry.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 432b3df0cc..a3cc712184 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -30,10 +30,6 @@ * - Implement RegDeleteKeyW() and RegDeleteValueW() */ -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - #define NDEBUG #include "mkhive.h" @@ -463,11 +459,18 @@ RegpCreateOrOpenKey( Volatile, &BlockOffset); } + else // if (BlockOffset == HCELL_NIL) + { + Status = STATUS_OBJECT_NAME_NOT_FOUND; // ERROR_PATH_NOT_FOUND; + } HvReleaseCell(&ParentRegistryHive->Hive, ParentCellOffset); if (!NT_SUCCESS(Status)) + { + DPRINT("RegpCreateOrOpenKey('%S'): Could not create or open subkey '%wZ'\n", KeyName, &KeyString); return ERROR_UNSUCCESSFUL; + } ParentCellOffset = BlockOffset; if (End) @@ -711,7 +714,7 @@ RegSetValueExW( } -// Synced with freeldr/windows/registry.c +// Synced with freeldr/ntldr/registry.c static VOID RepGetValueData( @@ -750,7 +753,7 @@ RepGetValueData( } } -// Similar to RegQueryValue in freeldr/windows/registry.c +// Similar to RegQueryValue in freeldr/ntldr/registry.c LONG WINAPI RegQueryValueExW( IN HKEY hKey, @@ -878,6 +881,7 @@ CreateSymLink( // IN PCWSTR TargetKeyPath OPTIONAL, IN HKEY TargetKeyHandle) { + LONG rc; PMEMKEY LinkKey, TargetKey; PREPARSE_POINT ReparsePoint; @@ -888,15 +892,20 @@ CreateSymLink( if (LinkKeyPath && !(LinkKeyHandle && *LinkKeyHandle)) { /* Create the link key */ - RegCreateKeyExW(NULL, - LinkKeyPath, - 0, - NULL, - REG_OPTION_VOLATILE, - 0, - NULL, - (HKEY*)&LinkKey, - NULL); + rc = RegCreateKeyExW(NULL, + LinkKeyPath, + 0, + NULL, + REG_OPTION_VOLATILE, + 0, + NULL, + (PHKEY)&LinkKey, + NULL); + if (rc != ERROR_SUCCESS) + { + free(ReparsePoint); + return FALSE; + } } else if (LinkKeyHandle) {
6 years, 2 months
1
0
0
0
05/09: [MKHIVE] Simplify CmiAddValueKey() by using CmpAddValueToList().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ec3c61c23315e4f15b154…
commit ec3c61c23315e4f15b1541b2095d0a08e8305653 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 15:14:52 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:50 2018 +0200 [MKHIVE] Simplify CmiAddValueKey() by using CmpAddValueToList(). --- sdk/tools/mkhive/cmi.c | 88 +++++++++++++++++---------------------------- sdk/tools/mkhive/cmi.h | 1 + sdk/tools/mkhive/registry.c | 15 +++++++- 3 files changed, 47 insertions(+), 57 deletions(-) diff --git a/sdk/tools/mkhive/cmi.c b/sdk/tools/mkhive/cmi.c index 34f8580d82..6856cd1902 100644 --- a/sdk/tools/mkhive/cmi.c +++ b/sdk/tools/mkhive/cmi.c @@ -21,7 +21,8 @@ * PROJECT: ReactOS hive maker * FILE: tools/mkhive/cmi.c * PURPOSE: Registry file manipulation routines - * PROGRAMMER: Herv� Poussineau + * PROGRAMMERS: Herv� Poussineau + * Herm�s B�lusca-Ma�to */ #define NDEBUG @@ -343,62 +344,17 @@ NTSTATUS CmiAddValueKey( IN PCMHIVE RegistryHive, IN PCM_KEY_NODE Parent, + IN ULONG ChildIndex, IN PCUNICODE_STRING ValueName, OUT PCM_KEY_VALUE *pValueCell, OUT HCELL_INDEX *pValueCellOffset) { - PCELL_DATA ValueListCell; + NTSTATUS Status; + HSTORAGE_TYPE Storage; PCM_KEY_VALUE NewValueCell; - HCELL_INDEX ValueListCellOffset; HCELL_INDEX NewValueCellOffset; - ULONG CellSize; - HSTORAGE_TYPE Storage; - -#ifndef FIELD_SIZE -#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) -#endif Storage = (Parent->Flags & KEY_IS_VOLATILE) ? Volatile : Stable; - if (Parent->ValueList.List == HCELL_NIL) - { - /* Allocate some room for the value list */ - CellSize = FIELD_SIZE(CELL_DATA, u.KeyList) + (3 * sizeof(HCELL_INDEX)); - ValueListCellOffset = HvAllocateCell(&RegistryHive->Hive, CellSize, Storage, HCELL_NIL); - if (ValueListCellOffset == HCELL_NIL) - return STATUS_INSUFFICIENT_RESOURCES; - - ValueListCell = (PCELL_DATA)HvGetCell(&RegistryHive->Hive, ValueListCellOffset); - if (!ValueListCell) - { - HvFreeCell(&RegistryHive->Hive, ValueListCellOffset); - return STATUS_UNSUCCESSFUL; - } - - Parent->ValueList.List = ValueListCellOffset; - } - else - { - ValueListCell = (PCELL_DATA)HvGetCell(&RegistryHive->Hive, Parent->ValueList.List); - if (!ValueListCell) - return STATUS_UNSUCCESSFUL; - - CellSize = ABS_VALUE(HvGetCellSize(&RegistryHive->Hive, ValueListCell)); - - if (Parent->ValueList.Count >= CellSize / sizeof(HCELL_INDEX)) - { - CellSize *= 2; - ValueListCellOffset = HvReallocateCell(&RegistryHive->Hive, Parent->ValueList.List, CellSize); - if (ValueListCellOffset == HCELL_NIL) - return STATUS_INSUFFICIENT_RESOURCES; - - ValueListCell = (PCELL_DATA)HvGetCell(&RegistryHive->Hive, ValueListCellOffset); - if (!ValueListCell) - return STATUS_UNSUCCESSFUL; - - Parent->ValueList.List = ValueListCellOffset; - } - } - NewValueCellOffset = HvAllocateCell(&RegistryHive->Hive, FIELD_OFFSET(CM_KEY_VALUE, Name) + @@ -438,15 +394,35 @@ CmiAddValueKey( NewValueCell->DataLength = 0; NewValueCell->Data = HCELL_NIL; + HvMarkCellDirty(&RegistryHive->Hive, NewValueCellOffset, FALSE); - ValueListCell->u.KeyList[Parent->ValueList.Count] = NewValueCellOffset; - Parent->ValueList.Count++; + /* Check if we already have a value list */ + if (Parent->ValueList.Count) + { + /* Then make sure it's valid and dirty it */ + ASSERT(Parent->ValueList.List != HCELL_NIL); + HvMarkCellDirty(&RegistryHive->Hive, Parent->ValueList.List, FALSE); + } - HvMarkCellDirty(&RegistryHive->Hive, Parent->ValueList.List, FALSE); - HvMarkCellDirty(&RegistryHive->Hive, NewValueCellOffset, FALSE); + /* Add this value cell to the child list */ + Status = CmpAddValueToList(&RegistryHive->Hive, + NewValueCellOffset, + ChildIndex, + Storage, + &Parent->ValueList); - *pValueCell = NewValueCell; - *pValueCellOffset = NewValueCellOffset; + /* If we failed, free the entire cell, including the data */ + if (!NT_SUCCESS(Status)) + { + /* Overwrite the status with a known one */ + CmpFreeValue(&RegistryHive->Hive, NewValueCellOffset); + Status = STATUS_INSUFFICIENT_RESOURCES; + } + else + { + *pValueCell = NewValueCell; + *pValueCellOffset = NewValueCellOffset; + } - return STATUS_SUCCESS; + return Status; } diff --git a/sdk/tools/mkhive/cmi.h b/sdk/tools/mkhive/cmi.h index 2d1762392e..88611c2d4c 100644 --- a/sdk/tools/mkhive/cmi.h +++ b/sdk/tools/mkhive/cmi.h @@ -50,6 +50,7 @@ NTSTATUS CmiAddValueKey( IN PCMHIVE RegistryHive, IN PCM_KEY_NODE Parent, + IN ULONG ChildIndex, IN PCUNICODE_STRING ValueName, OUT PCM_KEY_VALUE *pValueCell, OUT HCELL_INDEX *pValueCellOffset); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index cd238dcd95..432b3df0cc 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -557,6 +557,7 @@ RegSetValueExW( PHHIVE Hive; PCM_KEY_NODE KeyNode; // ParentNode PCM_KEY_VALUE ValueCell; + ULONG ChildIndex; HCELL_INDEX CellIndex; UNICODE_STRING ValueNameString; @@ -600,12 +601,24 @@ RegSetValueExW( /* Initialize value name string */ RtlInitUnicodeString(&ValueNameString, lpValueName); - CellIndex = CmpFindValueByName(Hive, KeyNode, &ValueNameString); + if (!CmpFindNameInList(Hive, + &KeyNode->ValueList, + &ValueNameString, + &ChildIndex, + &CellIndex)) + { + /* Sanity check */ + ASSERT(CellIndex == HCELL_NIL); + /* Fail */ + // Status = STATUS_INSUFFICIENT_RESOURCES; + return ERROR_UNSUCCESSFUL; + } if (CellIndex == HCELL_NIL) { /* The value doesn't exist, create a new one */ Status = CmiAddValueKey(Key->RegistryHive, KeyNode, + ChildIndex, &ValueNameString, &ValueCell, &CellIndex);
6 years, 2 months
1
0
0
0
04/09: [MKHIVE] Sync a bit more of reginf.c with the corresponding setupapi code.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a965cf6e043f58031c3d3…
commit a965cf6e043f58031c3d320573d25a4180665ff4 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 00:32:26 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:46 2018 +0200 [MKHIVE] Sync a bit more of reginf.c with the corresponding setupapi code. --- sdk/tools/mkhive/reginf.c | 71 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/sdk/tools/mkhive/reginf.c b/sdk/tools/mkhive/reginf.c index 47f0d8525b..b630d7535d 100644 --- a/sdk/tools/mkhive/reginf.c +++ b/sdk/tools/mkhive/reginf.c @@ -34,19 +34,23 @@ #define NDEBUG #include "mkhive.h" -#define FLG_ADDREG_BINVALUETYPE 0x00000001 -#define FLG_ADDREG_NOCLOBBER 0x00000002 -#define FLG_ADDREG_DELVAL 0x00000004 -#define FLG_ADDREG_APPEND 0x00000008 -#define FLG_ADDREG_KEYONLY 0x00000010 -#define FLG_ADDREG_OVERWRITEONLY 0x00000020 -#define FLG_ADDREG_TYPE_SZ 0x00000000 -#define FLG_ADDREG_TYPE_MULTI_SZ 0x00010000 -#define FLG_ADDREG_TYPE_EXPAND_SZ 0x00020000 -#define FLG_ADDREG_TYPE_BINARY (0x00000000 | FLG_ADDREG_BINVALUETYPE) -#define FLG_ADDREG_TYPE_DWORD (0x00010000 | FLG_ADDREG_BINVALUETYPE) -#define FLG_ADDREG_TYPE_NONE (0x00020000 | FLG_ADDREG_BINVALUETYPE) -#define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE) +#define FLG_ADDREG_BINVALUETYPE 0x00000001 +#define FLG_ADDREG_NOCLOBBER 0x00000002 +#define FLG_ADDREG_DELVAL 0x00000004 +#define FLG_ADDREG_APPEND 0x00000008 +#define FLG_ADDREG_KEYONLY 0x00000010 +#define FLG_ADDREG_OVERWRITEONLY 0x00000020 +#define FLG_ADDREG_KEYONLY_COMMON 0x00002000 +#define FLG_DELREG_KEYONLY_COMMON FLG_ADDREG_KEYONLY_COMMON +#define FLG_ADDREG_DELREG_BIT 0x00008000 + +#define FLG_ADDREG_TYPE_SZ 0x00000000 +#define FLG_ADDREG_TYPE_MULTI_SZ 0x00010000 +#define FLG_ADDREG_TYPE_EXPAND_SZ 0x00020000 +#define FLG_ADDREG_TYPE_BINARY (0x00000000 | FLG_ADDREG_BINVALUETYPE) +#define FLG_ADDREG_TYPE_DWORD (0x00010000 | FLG_ADDREG_BINVALUETYPE) +#define FLG_ADDREG_TYPE_NONE (0x00020000 | FLG_ADDREG_BINVALUETYPE) +#define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE) static const WCHAR HKCR[] = {'H','K','C','R',0}; @@ -118,8 +122,8 @@ get_root_key(PWCHAR Name) static VOID append_multi_sz_value( IN HKEY KeyHandle, - IN PWCHAR ValueName, - IN PWCHAR Strings, + IN PCWSTR ValueName, + IN PCWSTR Strings, IN ULONG StringSize) // In characters { ULONG Size, Total; // In bytes @@ -194,7 +198,7 @@ done: static BOOL do_reg_operation( IN HKEY KeyHandle, - IN PWCHAR ValueName, + IN PCWSTR ValueName, IN PINFCONTEXT Context, IN ULONG Flags) { @@ -203,21 +207,21 @@ do_reg_operation( ULONG Size; LONG Error; - if (Flags & FLG_ADDREG_DELVAL) /* deletion */ + if (Flags & (FLG_ADDREG_DELREG_BIT | FLG_ADDREG_DELVAL)) /* deletion */ { - if (ValueName) + if (ValueName && *ValueName && !(Flags & FLG_DELREG_KEYONLY_COMMON)) { + // NOTE: We don't currently handle deleting sub-values inside multi-strings. RegDeleteValueW(KeyHandle, ValueName); } else { RegDeleteKeyW(KeyHandle, NULL); } - return TRUE; } - if (Flags & FLG_ADDREG_KEYONLY) + if (Flags & (FLG_ADDREG_KEYONLY | FLG_ADDREG_KEYONLY_COMMON)) return TRUE; if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY)) @@ -228,6 +232,7 @@ do_reg_operation( NULL, NULL, NULL); + if ((Error == ERROR_SUCCESS) && (Flags & FLG_ADDREG_NOCLOBBER)) return TRUE; @@ -390,7 +395,7 @@ do_reg_operation( * Called once for each AddReg and DelReg entry in a given section. */ static BOOL -registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) +registry_callback(HINF hInf, PCWSTR Section, BOOL Delete) { WCHAR Buffer[MAX_INF_STRING_LENGTH]; PWCHAR ValuePtr; @@ -405,30 +410,36 @@ registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) if (!Ok) return TRUE; /* Don't fail if the section isn't present */ - for (;Ok; Ok = (InfHostFindNextLine(Context, Context) == 0)) + for (Ok = TRUE; Ok; Ok = (InfHostFindNextLine(Context, Context) == 0)) { - /* get root */ + /* Get root */ if (InfHostGetStringField(Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL) != 0) continue; if (!get_root_key(Buffer)) continue; - /* get key */ + /* Get key */ Length = strlenW(Buffer); if (InfHostGetStringField(Context, 2, Buffer + Length, sizeof(Buffer)/sizeof(WCHAR) - (ULONG)Length, NULL) != 0) *Buffer = 0; DPRINT("KeyName: <%S>\n", Buffer); + /* Get flags */ + if (InfHostGetIntField(Context, 4, (INT*)&Flags) != 0) + Flags = 0; + if (Delete) { - Flags = FLG_ADDREG_DELVAL; + if (!Flags) + Flags = FLG_ADDREG_DELREG_BIT; + else if (!(Flags & FLG_ADDREG_DELREG_BIT)) + continue; /* ignore this entry */ } else { - /* get flags */ - if (InfHostGetIntField(Context, 4, (INT *)&Flags) != 0) - Flags = 0; + if (Flags & FLG_ADDREG_DELREG_BIT) + continue; /* ignore this entry */ } DPRINT("Flags: 0x%x\n", Flags); @@ -450,7 +461,7 @@ registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) } } - /* get value name */ + /* Get value name */ if (InfHostGetStringField(Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL) == 0) { ValuePtr = Buffer; @@ -460,7 +471,7 @@ registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) ValuePtr = NULL; } - /* and now do it */ + /* And now do it */ if (!do_reg_operation(KeyHandle, ValuePtr, Context, Flags)) { RegCloseKey(KeyHandle);
6 years, 2 months
1
0
0
0
03/09: [MKHIVE] Implement and use RegCloseKey().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=81d435a181db3d7d0b931…
commit 81d435a181db3d7d0b93149dd61c971f5a0147ae Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 00:29:04 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:41 2018 +0200 [MKHIVE] Implement and use RegCloseKey(). --- sdk/tools/mkhive/mkhive.h | 4 ++++ sdk/tools/mkhive/reginf.c | 3 +++ sdk/tools/mkhive/registry.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/sdk/tools/mkhive/mkhive.h b/sdk/tools/mkhive/mkhive.h index 517925a6b6..82c8ecc2c3 100644 --- a/sdk/tools/mkhive/mkhive.h +++ b/sdk/tools/mkhive/mkhive.h @@ -89,6 +89,10 @@ RegSetValueExW( IN const UCHAR* lpData, IN ULONG cbData); +LONG WINAPI +RegCloseKey( + IN HKEY hKey); + LONG WINAPI RegDeleteKeyW( IN HKEY hKey, diff --git a/sdk/tools/mkhive/reginf.c b/sdk/tools/mkhive/reginf.c index c6087a96ba..47f0d8525b 100644 --- a/sdk/tools/mkhive/reginf.c +++ b/sdk/tools/mkhive/reginf.c @@ -463,8 +463,11 @@ registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) /* and now do it */ if (!do_reg_operation(KeyHandle, ValuePtr, Context, Flags)) { + RegCloseKey(KeyHandle); return FALSE; } + + RegCloseKey(KeyHandle); } InfHostFreeContext(Context); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 1686fca08d..cd238dcd95 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -485,6 +485,18 @@ RegpCreateOrOpenKey( return ERROR_SUCCESS; } +LONG WINAPI +RegCloseKey( + IN HKEY hKey) +{ + PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey + + /* Free the object */ + free(Key); + + return ERROR_SUCCESS; +} + LONG WINAPI RegCreateKeyW( IN HKEY hKey, @@ -942,6 +954,8 @@ RegInitializeRegistry( CreateSymLink(L"Registry\\Machine\\SYSTEM\\CurrentControlSet", NULL, ControlSetKey); + RegCloseKey(ControlSetKey); + #if 0 /* Link SECURITY to SAM */ CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM", L"\\Registry\\Machine\\SAM\\SAM");
6 years, 2 months
1
0
0
0
02/09: [NTOS][MKHIVE] Minor code formatting.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4caf3913242a0c908c29e…
commit 4caf3913242a0c908c29e0cc34ea6464e8149f9d Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 01:20:31 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:34 2018 +0200 [NTOS][MKHIVE] Minor code formatting. --- ntoskrnl/config/cmapi.c | 6 +++--- sdk/tools/mkhive/registry.c | 50 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ntoskrnl/config/cmapi.c b/ntoskrnl/config/cmapi.c index 85723d1881..3b476d8c8e 100644 --- a/ntoskrnl/config/cmapi.c +++ b/ntoskrnl/config/cmapi.c @@ -982,7 +982,7 @@ CmDeleteValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb, } /* Get the key value */ - Value = (PCM_KEY_VALUE)HvGetCell(Hive,ChildCell); + Value = (PCM_KEY_VALUE)HvGetCell(Hive, ChildCell); ASSERT(Value); /* Mark it and all related data as dirty */ @@ -1851,7 +1851,7 @@ CmDeleteKey(IN PCM_KEY_BODY KeyBody) { /* Don't do it twice */ Status = STATUS_SUCCESS; - goto Quickie2; + goto Quickie; } /* Get the hive and node */ @@ -1925,7 +1925,7 @@ CmDeleteKey(IN PCM_KEY_BODY KeyBody) CmpUnlockHiveFlusher((PCMHIVE)Hive); /* Release the KCB locks */ -Quickie2: +Quickie: CmpReleaseTwoKcbLockByKey(Kcb->ConvKey, Kcb->ParentKcb->ConvKey); /* Release hive lock */ diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 17030bb209..1686fca08d 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -370,7 +370,7 @@ LIST_ENTRY CmiHiveListHead; LIST_ENTRY CmiReparsePointsHead; static LONG -RegpOpenOrCreateKey( +RegpCreateOrOpenKey( IN HKEY hParentKey, IN PCWSTR KeyName, IN BOOL AllowCreation, @@ -390,7 +390,7 @@ RegpOpenOrCreateKey( PCM_KEY_NODE SubKeyCell; HCELL_INDEX BlockOffset; - DPRINT("RegpCreateOpenKey('%S')\n", KeyName); + DPRINT("RegpCreateOrOpenKey('%S')\n", KeyName); if (*KeyName == OBJ_NAME_PATH_SEPARATOR) { @@ -491,26 +491,7 @@ RegCreateKeyW( IN LPCWSTR lpSubKey, OUT PHKEY phkResult) { - return RegpOpenOrCreateKey(hKey, lpSubKey, TRUE, FALSE, phkResult); -} - -LONG WINAPI -RegDeleteKeyW( - IN HKEY hKey, - IN LPCWSTR lpSubKey) -{ - DPRINT1("RegDeleteKeyW(0x%p, '%S') is UNIMPLEMENTED!\n", - hKey, (lpSubKey ? lpSubKey : L"")); - return ERROR_SUCCESS; -} - -LONG WINAPI -RegOpenKeyW( - IN HKEY hKey, - IN LPCWSTR lpSubKey, - OUT PHKEY phkResult) -{ - return RegpOpenOrCreateKey(hKey, lpSubKey, FALSE, FALSE, phkResult); + return RegpCreateOrOpenKey(hKey, lpSubKey, TRUE, FALSE, phkResult); } LONG WINAPI @@ -525,13 +506,32 @@ RegCreateKeyExW( OUT PHKEY phkResult, OUT LPDWORD lpdwDisposition OPTIONAL) { - return RegpOpenOrCreateKey(hKey, + return RegpCreateOrOpenKey(hKey, lpSubKey, TRUE, (dwOptions & REG_OPTION_VOLATILE) != 0, phkResult); } +LONG WINAPI +RegDeleteKeyW( + IN HKEY hKey, + IN LPCWSTR lpSubKey) +{ + DPRINT1("RegDeleteKeyW(0x%p, '%S') is UNIMPLEMENTED!\n", + hKey, (lpSubKey ? lpSubKey : L"")); + return ERROR_SUCCESS; +} + +LONG WINAPI +RegOpenKeyW( + IN HKEY hKey, + IN LPCWSTR lpSubKey, + OUT PHKEY phkResult) +{ + return RegpCreateOrOpenKey(hKey, lpSubKey, FALSE, FALSE, phkResult); +} + LONG WINAPI RegSetValueExW( IN HKEY hKey, @@ -785,9 +785,9 @@ ConnectRegistry( IN PCWSTR Path) { NTSTATUS Status; + LONG rc; PREPARSE_POINT ReparsePoint; PMEMKEY NewKey; - LONG rc; ReparsePoint = (PREPARSE_POINT)malloc(sizeof(*ReparsePoint)); if (!ReparsePoint) @@ -819,7 +819,7 @@ ConnectRegistry( if (!NT_SUCCESS(Status)) DPRINT1("Failed to add security for root key '%S'\n", Path); - /* Create key */ + /* Create the key */ rc = RegCreateKeyExW(RootKey, Path, 0,
6 years, 2 months
1
0
0
0
← Newer
1
...
19
20
21
22
23
24
25
...
36
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
Results per page:
10
25
50
100
200