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
2025
January
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 2014
----- 2025 -----
January 2025
----- 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
19 participants
730 discussions
Start a n
N
ew thread
[tkreuzer] 64450: [DLLEXPORT_TEST] Make it a DLL, not a static lib. Noticed by Thomas.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Oct 2 07:58:18 2014 New Revision: 64450 URL:
http://svn.reactos.org/svn/reactos?rev=64450&view=rev
Log: [DLLEXPORT_TEST] Make it a DLL, not a static lib. Noticed by Thomas. Modified: trunk/rostests/tests/dllexport/CMakeLists.txt Modified: trunk/rostests/tests/dllexport/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/CMakeList…
============================================================================== --- trunk/rostests/tests/dllexport/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/tests/dllexport/CMakeLists.txt [iso-8859-1] Thu Oct 2 07:58:18 2014 @@ -25,8 +25,8 @@ add_compile_flags("/Zc:wchar_t-") endif() -add_library(dllimport_test +add_library(dllimport_test SHARED dllimport_framedyn.cpp) set_module_type(dllimport_test win32dll ENTRYPOINT 0) -add_importlibs(dllimport_test framedyn) +add_importlibs(dllimport_test msvcrt framedyn) target_link_libraries(dllimport_test framedynex)
10 years, 3 months
1
0
0
0
[tkreuzer] 64449: [DLLEXPORT_TEST] Fix a typo
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Oct 2 07:30:59 2014 New Revision: 64449 URL:
http://svn.reactos.org/svn/reactos?rev=64449&view=rev
Log: [DLLEXPORT_TEST] Fix a typo Modified: trunk/rostests/tests/dllexport/CMakeLists.txt Modified: trunk/rostests/tests/dllexport/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/CMakeList…
============================================================================== --- trunk/rostests/tests/dllexport/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/tests/dllexport/CMakeLists.txt [iso-8859-1] Thu Oct 2 07:30:59 2014 @@ -25,7 +25,7 @@ add_compile_flags("/Zc:wchar_t-") endif() -add_executable(dllimport_test +add_library(dllimport_test dllimport_framedyn.cpp) set_module_type(dllimport_test win32dll ENTRYPOINT 0) add_importlibs(dllimport_test framedyn)
10 years, 3 months
1
0
0
0
[hpoussin] 64448: [MOUNTMGR] Misc fixes for IOCTLs
by hpoussin@svn.reactos.org
Author: hpoussin Date: Thu Oct 2 05:06:24 2014 New Revision: 64448 URL:
http://svn.reactos.org/svn/reactos?rev=64448&view=rev
Log: [MOUNTMGR] Misc fixes for IOCTLs Modified: trunk/reactos/drivers/filters/mountmgr/device.c trunk/reactos/drivers/filters/mountmgr/mountmgr.c Modified: trunk/reactos/drivers/filters/mountmgr/device.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/d…
============================================================================== --- trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] Thu Oct 2 05:06:24 2014 @@ -653,7 +653,7 @@ PMOUNTMGR_DRIVE_LETTER_TARGET DriveLetterTarget; MOUNTMGR_DRIVE_LETTER_INFORMATION DriveLetterInformation; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_DRIVE_LETTER_TARGET) || @@ -845,7 +845,7 @@ PSYMLINK_INFORMATION SymlinkInformation; PASSOCIATED_DEVICE_ENTRY AssociatedDevice; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input size */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_TARGET_NAME)) @@ -1075,7 +1075,7 @@ PMOUNTMGR_TARGET_NAME Target; PDEVICE_INFORMATION DeviceInformation; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_TARGET_NAME)) @@ -1119,7 +1119,7 @@ UNICODE_STRING SymbolicName; PMOUNTMGR_TARGET_NAME Target; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_TARGET_NAME)) @@ -1162,7 +1162,7 @@ PMOUNTMGR_MOUNT_POINT MountPoint; UNICODE_STRING SymbolicName, DeviceName; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input... */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_MOUNT_POINT)) @@ -1310,7 +1310,7 @@ PMOUNTMGR_MOUNT_POINTS MountPoints; UNICODE_STRING SymbolicName, DeviceName; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_MOUNT_POINT)) @@ -1489,7 +1489,7 @@ POBJECT_NAME_INFORMATION ObjectNameInfoPtr = NULL; UNICODE_STRING SourceVolumeName, TargetDeviceName; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); /* Validate input */ if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_VOLUME_MOUNT_POINT)) @@ -1722,7 +1722,7 @@ NTSTATUS Status, LockStatus; PDEVICE_EXTENSION DeviceExtension; - Stack = IoGetNextIrpStackLocation(Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); DeviceExtension = DeviceObject->DeviceExtension; KeWaitForSingleObject(&(DeviceExtension->DeviceLock), Executive, KernelMode, FALSE, NULL); Modified: trunk/reactos/drivers/filters/mountmgr/mountmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/m…
============================================================================== --- trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] Thu Oct 2 05:06:24 2014 @@ -1331,9 +1331,9 @@ DeviceInformation->SuggestedDriveLetter = 0; } /* Else, it's time to set up one */ - else if (!DeviceExtension->NoAutoMount && !DeviceInformation->Removable && - DeviceExtension->AutomaticDriveLetter && HasGptDriveLetter && - DeviceInformation->SuggestedDriveLetter && + else if ((DeviceExtension->NoAutoMount || DeviceInformation->Removable) && + DeviceExtension->AutomaticDriveLetter && + (HasGptDriveLetter || DeviceInformation->SuggestedDriveLetter) && !HasNoDriveLetterEntry(UniqueId)) { /* Create a new drive letter */
10 years, 3 months
1
0
0
0
[hbelusca] 64447: [NTVDM] - INT 21h, AH=59h (Get Extended Error Information) is unimplemented but is used by many applications. DPRINT a special message to remind that we need to implement it. - Im...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Oct 2 00:26:13 2014 New Revision: 64447 URL:
http://svn.reactos.org/svn/reactos?rev=64447&view=rev
Log: [NTVDM] - INT 21h, AH=59h (Get Extended Error Information) is unimplemented but is used by many applications. DPRINT a special message to remind that we need to implement it. - Implement INT 21h, AH=6Ch "Extended Open/Create". Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dosfiles.c Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
============================================================================== --- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Thu Oct 2 00:26:13 2014 @@ -2579,6 +2579,14 @@ break; } + /* Get Extended Error Information */ + case 0x59: + { + DPRINT1("INT 21h, AH = 59h, BX = %04Xh - Get Extended Error Information is UNIMPLEMENTED\n", + getBX()); + break; + } + /* Create Temporary File */ case 0x5A: { @@ -2775,6 +2783,10 @@ /* Extended Open/Create */ case 0x6C: { + WORD FileHandle; + WORD CreationStatus; + WORD ErrorCode; + /* Check for AL == 00 */ if (getAL() != 0x00) { @@ -2783,10 +2795,31 @@ break; } - // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // FIXME: Extend and merge DosOpenFile and DosCreateFile into - // a single wrapper around CreateFileA, which acts as: - //
http://www.ctyme.com/intr/rb-3179.htm
+ /* + * See Ralf Brown:
http://www.ctyme.com/intr/rb-3179.htm
+ * for the full detailed description. + * + * WARNING: BH contains some extended flags that are NOT SUPPORTED. + */ + + ErrorCode = DosCreateFileEx(&FileHandle, + &CreationStatus, + (LPCSTR)SEG_OFF_TO_PTR(getDS(), getSI()), + getBL(), + getDL(), + getCX()); + + if (ErrorCode == ERROR_SUCCESS) + { + Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF; + setCX(CreationStatus); + setAX(FileHandle); + } + else + { + Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF; + setAX(ErrorCode); + } break; } Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
============================================================================== --- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] Thu Oct 2 00:26:13 2014 @@ -192,11 +192,31 @@ WORD DosOpenHandle(HANDLE Handle); HANDLE DosGetRealHandle(WORD DosHandle); -WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD CreationFlags, WORD Attributes); -WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessShareModes); -WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead); -WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten); -WORD DosSeekFile(WORD FileHandle, LONG Offset, BYTE Origin, LPDWORD NewOffset); +WORD DosCreateFileEx(LPWORD Handle, + LPWORD CreationStatus, + LPCSTR FilePath, + BYTE AccessShareModes, + WORD CreateActionFlags, + WORD Attributes); +WORD DosCreateFile(LPWORD Handle, + LPCSTR FilePath, + DWORD CreationDisposition, + WORD Attributes); +WORD DosOpenFile(LPWORD Handle, + LPCSTR FilePath, + BYTE AccessShareModes); +WORD DosReadFile(WORD FileHandle, + LPVOID Buffer, + WORD Count, + LPWORD BytesRead); +WORD DosWriteFile(WORD FileHandle, + LPVOID Buffer, + WORD Count, + LPWORD BytesWritten); +WORD DosSeekFile(WORD FileHandle, + LONG Offset, + BYTE Origin, + LPDWORD NewOffset); BOOL DosFlushFileBuffers(WORD FileHandle); VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment); Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dosfiles.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
============================================================================== --- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Thu Oct 2 00:26:13 2014 @@ -12,36 +12,254 @@ #define NDEBUG #include "emulator.h" -// #include "callback.h" #include "dos.h" #include "dos/dem.h" #include "bios/bios.h" -/* PRIVATE VARIABLES **********************************************************/ - /* PUBLIC FUNCTIONS ***********************************************************/ -WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD CreationFlags, WORD Attributes) -{ +WORD DosCreateFileEx(LPWORD Handle, + LPWORD CreationStatus, + LPCSTR FilePath, + BYTE AccessShareModes, + WORD CreateActionFlags, + WORD Attributes) +{ + WORD LastError; HANDLE FileHandle; WORD DosHandle; - - DPRINT("DosCreateFile: FilePath \"%s\", CreationFlags 0x%04X, Attributes 0x%04X\n", - FilePath, - CreationFlags, - Attributes); + ACCESS_MASK AccessMode = 0; + DWORD ShareMode = 0; + DWORD CreationDisposition = 0; + BOOL InheritableFile = FALSE; + SECURITY_ATTRIBUTES SecurityAttributes; + + DPRINT1("DosCreateFileEx: FilePath \"%s\", AccessShareModes 0x%04X, CreateActionFlags 0x%04X, Attributes 0x%04X\n", + FilePath, AccessShareModes, CreateActionFlags, Attributes); + + // + // The article about OpenFile API:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).a…
+ // explains what are those AccessShareModes (see the uStyle flag). + // + + /* Parse the access mode */ + switch (AccessShareModes & 0x03) + { + /* Read-only */ + case 0: + AccessMode = GENERIC_READ; + break; + + /* Write only */ + case 1: + AccessMode = GENERIC_WRITE; + break; + + /* Read and write */ + case 2: + AccessMode = GENERIC_READ | GENERIC_WRITE; + break; + + /* Invalid */ + default: + return ERROR_INVALID_PARAMETER; + } + + /* Parse the share mode */ + switch ((AccessShareModes >> 4) & 0x07) + { + /* Compatibility mode */ + case 0: + ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; + break; + + /* No sharing "DenyAll" */ + case 1: + ShareMode = 0; + break; + + /* No write share "DenyWrite" */ + case 2: + ShareMode = FILE_SHARE_READ; + break; + + /* No read share "DenyRead" */ + case 3: + ShareMode = FILE_SHARE_WRITE; + break; + + /* Full share "DenyNone" */ + case 4: + ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + break; + + /* Invalid */ + default: + return ERROR_INVALID_PARAMETER; + } + + /* + * Parse the creation action flags: + * + * Bitfields for action: + * Bit(s) Description + * + * 7-4 Action if file does not exist. + * 0000 Fail + * 0001 Create + * + * 3-0 Action if file exists. + * 0000 Fail + * 0001 Open + * 0010 Replace/open + */ + switch (CreateActionFlags) + { + /* If the file exists, fail, otherwise, fail also */ + case 0x00: + // A special case is used after the call to CreateFileA if it succeeds, + // in order to close the opened handle and return an adequate error. + CreationDisposition = OPEN_EXISTING; + break; + + /* If the file exists, open it, otherwise, fail */ + case 0x01: + CreationDisposition = OPEN_EXISTING; + break; + + /* If the file exists, replace it, otherwise, fail */ + case 0x02: + CreationDisposition = TRUNCATE_EXISTING; + break; + + /* If the file exists, fail, otherwise, create it */ + case 0x10: + CreationDisposition = CREATE_NEW; + break; + + /* If the file exists, open it, otherwise, create it */ + case 0x11: + CreationDisposition = OPEN_ALWAYS; + break; + + /* If the file exists, replace it, otherwise, create it */ + case 0x12: + CreationDisposition = CREATE_ALWAYS; + break; + + /* Invalid */ + default: + return ERROR_INVALID_PARAMETER; + } + + /* Check for inheritance */ + InheritableFile = ((AccessShareModes & 0x80) == 0); + + /* Assign default security attributes to the file, and set the inheritance flag */ + SecurityAttributes.nLength = sizeof(SecurityAttributes); + SecurityAttributes.lpSecurityDescriptor = NULL; + SecurityAttributes.bInheritHandle = InheritableFile; + + /* Open the file */ + FileHandle = CreateFileA(FilePath, + AccessMode, + ShareMode, + &SecurityAttributes, + CreationDisposition, + Attributes, + NULL); + + LastError = (WORD)GetLastError(); + + if (FileHandle == INVALID_HANDLE_VALUE) + { + /* Return the error code */ + return LastError; + } + + /* + * Special case: CreateActionFlags == 0, we must fail because + * the file exists (if it didn't exist we already failed). + */ + if (CreateActionFlags == 0) + { + /* Close the file and return the error code */ + CloseHandle(FileHandle); + return ERROR_FILE_EXISTS; + } + + /* Set the creation status */ + switch (CreateActionFlags) + { + case 0x01: + *CreationStatus = 0x01; // The file was opened + break; + + case 0x02: + *CreationStatus = 0x03; // The file was replaced + break; + + case 0x10: + *CreationStatus = 0x02; // The file was created + break; + + case 0x11: + { + if (LastError == ERROR_ALREADY_EXISTS) + *CreationStatus = 0x01; // The file was opened + else + *CreationStatus = 0x02; // The file was created + + break; + } + + case 0x12: + { + if (LastError == ERROR_ALREADY_EXISTS) + *CreationStatus = 0x03; // The file was replaced + else + *CreationStatus = 0x02; // The file was created + + break; + } + } + + /* Open the DOS handle */ + DosHandle = DosOpenHandle(FileHandle); + + if (DosHandle == INVALID_DOS_HANDLE) + { + /* Close the file and return the error code */ + CloseHandle(FileHandle); + return ERROR_TOO_MANY_OPEN_FILES; + } + + /* It was successful */ + *Handle = DosHandle; + return ERROR_SUCCESS; +} + +WORD DosCreateFile(LPWORD Handle, + LPCSTR FilePath, + DWORD CreationDisposition, + WORD Attributes) +{ + HANDLE FileHandle; + WORD DosHandle; + + DPRINT("DosCreateFile: FilePath \"%s\", CreationDisposition 0x%04X, Attributes 0x%04X\n", + FilePath, CreationDisposition, Attributes); /* Create the file */ FileHandle = CreateFileA(FilePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, - CreationFlags, + CreationDisposition, Attributes, NULL); - if (FileHandle == INVALID_HANDLE_VALUE) { /* Return the error code */ @@ -53,10 +271,8 @@ if (DosHandle == INVALID_DOS_HANDLE) { - /* Close the handle */ + /* Close the file and return the error code */ CloseHandle(FileHandle); - - /* Return the error code */ return ERROR_TOO_MANY_OPEN_FILES; } @@ -65,7 +281,9 @@ return ERROR_SUCCESS; } -WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessShareModes) +WORD DosOpenFile(LPWORD Handle, + LPCSTR FilePath, + BYTE AccessShareModes) { HANDLE FileHandle; ACCESS_MASK AccessMode = 0; @@ -75,83 +293,67 @@ WORD DosHandle; DPRINT("DosOpenFile: FilePath \"%s\", AccessShareModes 0x%04X\n", - FilePath, - AccessShareModes); + FilePath, AccessShareModes); + + // + // The article about OpenFile API:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).a…
+ // explains what are those AccessShareModes (see the uStyle flag). + // /* Parse the access mode */ switch (AccessShareModes & 0x03) { + /* Read-only */ case 0: - { - /* Read-only */ AccessMode = GENERIC_READ; break; - } - + + /* Write only */ case 1: - { - /* Write only */ AccessMode = GENERIC_WRITE; break; - } - + + /* Read and write */ case 2: - { - /* Read and write */ AccessMode = GENERIC_READ | GENERIC_WRITE; break; - } - + + /* Invalid */ default: - { - /* Invalid */ return ERROR_INVALID_PARAMETER; - } } /* Parse the share mode */ switch ((AccessShareModes >> 4) & 0x07) { + /* Compatibility mode */ case 0: - { - /* Compatibility mode */ ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; break; - } - + + /* No sharing "DenyAll" */ case 1: - { - /* No sharing "DenyAll" */ ShareMode = 0; break; - } - + + /* No write share "DenyWrite" */ case 2: - { - /* No write share "DenyWrite" */ ShareMode = FILE_SHARE_READ; break; - } - + + /* No read share "DenyRead" */ case 3: - { - /* No read share "DenyRead" */ ShareMode = FILE_SHARE_WRITE; break; - } - + + /* Full share "DenyNone" */ case 4: - { - /* Full share "DenyNone" */ ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; break; - } - + + /* Invalid */ default: - { - /* Invalid */ return ERROR_INVALID_PARAMETER; - } } /* Check for inheritance */ @@ -170,7 +372,6 @@ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (FileHandle == INVALID_HANDLE_VALUE) { /* Return the error code */ @@ -182,10 +383,8 @@ if (DosHandle == INVALID_DOS_HANDLE) { - /* Close the handle */ + /* Close the file and return the error code */ CloseHandle(FileHandle); - - /* Return the error code */ return ERROR_TOO_MANY_OPEN_FILES; } @@ -194,7 +393,10 @@ return ERROR_SUCCESS; } -WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead) +WORD DosReadFile(WORD FileHandle, + LPVOID Buffer, + WORD Count, + LPWORD BytesRead) { WORD Result = ERROR_SUCCESS; DWORD BytesRead32 = 0; @@ -259,7 +461,10 @@ return Result; } -WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten) +WORD DosWriteFile(WORD FileHandle, + LPVOID Buffer, + WORD Count, + LPWORD BytesWritten) { WORD Result = ERROR_SUCCESS; DWORD BytesWritten32 = 0; @@ -317,7 +522,10 @@ return Result; } -WORD DosSeekFile(WORD FileHandle, LONG Offset, BYTE Origin, LPDWORD NewOffset) +WORD DosSeekFile(WORD FileHandle, + LONG Offset, + BYTE Origin, + LPDWORD NewOffset) { WORD Result = ERROR_SUCCESS; DWORD FilePointer;
10 years, 3 months
1
0
0
0
[hbelusca] 64446: [NTVDM]: Silence interrupt calls dprints.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Oct 2 00:03:55 2014 New Revision: 64446 URL:
http://svn.reactos.org/svn/reactos?rev=64446&view=rev
Log: [NTVDM]: Silence interrupt calls dprints. Modified: trunk/reactos/subsystems/ntvdm/cpu/bop.c trunk/reactos/subsystems/ntvdm/int32.c Modified: trunk/reactos/subsystems/ntvdm/cpu/bop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/bop.c…
============================================================================== --- trunk/reactos/subsystems/ntvdm/cpu/bop.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/ntvdm/cpu/bop.c [iso-8859-1] Thu Oct 2 00:03:55 2014 @@ -9,7 +9,7 @@ /* INCLUDES *******************************************************************/ -// #define NDEBUG +#define NDEBUG #include "emulator.h" #include "bop.h" @@ -44,7 +44,7 @@ if (BopProc[BopCode] != NULL) BopProc[BopCode](Stack); else - DPRINT("Invalid BOP code: 0x%02X\n", BopCode); + DPRINT1("Invalid BOP code: 0x%02X\n", BopCode); } /* EOF */ Modified: trunk/reactos/subsystems/ntvdm/int32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/int32.c?r…
============================================================================== --- trunk/reactos/subsystems/ntvdm/int32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/ntvdm/int32.c [iso-8859-1] Thu Oct 2 00:03:55 2014 @@ -9,7 +9,7 @@ /* INCLUDES *******************************************************************/ -// #define NDEBUG +#define NDEBUG #include "emulator.h" #include "int32.h"
10 years, 3 months
1
0
0
0
[jgardou] 64445: [ADVAPI32] - Fix a stupid crash I introduced in RegQueryValueExA - Reimplement RegEnumKeyExA as wrapper around RegEnumKeyExW - Implement RegEnumKeyExW for HKCR subkeys - Fix a few ...
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Oct 1 22:51:44 2014 New Revision: 64445 URL:
http://svn.reactos.org/svn/reactos?rev=64445&view=rev
Log: [ADVAPI32] - Fix a stupid crash I introduced in RegQueryValueExA - Reimplement RegEnumKeyExA as wrapper around RegEnumKeyExW - Implement RegEnumKeyExW for HKCR subkeys - Fix a few potential handle leaks CORE-8582 Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c trunk/reactos/dll/win32/advapi32/reg/reg.c trunk/reactos/dll/win32/advapi32/reg/reg.h Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Wed Oct 1 22:51:44 2014 @@ -263,7 +263,7 @@ } /* See if the subkey already exists in HKCU. */ - ErrorCode = RegOpenKeyExW(QueriedKey, lpSubKey, 0, KEY_READ, &TestKey); + ErrorCode = RegOpenKeyExW(QueriedKey, lpSubKey, 0, 0, &TestKey); if (ErrorCode != ERROR_FILE_NOT_FOUND) { if (ErrorCode == ERROR_SUCCESS) @@ -585,3 +585,217 @@ return ErrorCode; } + +/* HKCR version of RegEnumKeyExW */ +LONG +WINAPI +EnumHKCRKey( + _In_ HKEY hKey, + _In_ DWORD dwIndex, + _Out_ LPWSTR lpName, + _Inout_ LPDWORD lpcbName, + _Reserved_ LPDWORD lpReserved, + _Out_opt_ LPWSTR lpClass, + _Inout_opt_ LPDWORD lpcbClass, + _Out_opt_ PFILETIME lpftLastWriteTime) +{ + HKEY PreferredKey, FallbackKey; + DWORD NumPreferredSubKeys; + DWORD MaxFallbackSubKeyLen; + DWORD FallbackIndex; + WCHAR* FallbackSubKeyName = NULL; + LONG ErrorCode; + + ASSERT(IsHKCRKey(hKey)); + + /* Remove the HKCR flag while we're working */ + hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2); + + /* Get the preferred key */ + ErrorCode = GetPreferredHKCRKey(hKey, &PreferredKey); + if (ErrorCode != ERROR_SUCCESS) + { + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* Only the HKLM key exists */ + return RegEnumKeyExW( + hKey, + dwIndex, + lpName, + lpcbName, + lpReserved, + lpClass, + lpcbClass, + lpftLastWriteTime); + } + return ErrorCode; + } + + /* Get the fallback key */ + ErrorCode = GetFallbackHKCRKey(hKey, &FallbackKey, FALSE); + if (ErrorCode != ERROR_SUCCESS) + { + if (PreferredKey != hKey) + RegCloseKey(PreferredKey); + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* Only the HKCU key exists */ + return RegEnumKeyExW( + hKey, + dwIndex, + lpName, + lpcbName, + lpReserved, + lpClass, + lpcbClass, + lpftLastWriteTime); + } + return ErrorCode; + } + + /* Get some info on the HKCU side */ + ErrorCode = RegQueryInfoKeyW( + PreferredKey, + NULL, + NULL, + NULL, + &NumPreferredSubKeys, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + if (ErrorCode != ERROR_SUCCESS) + goto Exit; + + if (dwIndex < NumPreferredSubKeys) + { + /* HKCU side takes precedence */ + ErrorCode = RegEnumKeyExW( + PreferredKey, + dwIndex, + lpName, + lpcbName, + lpReserved, + lpClass, + lpcbClass, + lpftLastWriteTime); + goto Exit; + } + + /* Here it gets tricky. We must enumerate the values from the HKLM side, + * without reporting those which are present on the HKCU side */ + + /* Squash out the indices from HKCU */ + dwIndex -= NumPreferredSubKeys; + + /* Get some info */ + ErrorCode = RegQueryInfoKeyW( + FallbackKey, + NULL, + NULL, + NULL, + NULL, + &MaxFallbackSubKeyLen, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + if (ErrorCode != ERROR_SUCCESS) + { + ERR("Could not query info of key %p (Err: %d)\n", FallbackKey, ErrorCode); + goto Exit; + } + + ERR("Maxfallbacksubkeylen: %d\n", MaxFallbackSubKeyLen); + + /* Allocate our buffer */ + FallbackSubKeyName = RtlAllocateHeap( + RtlGetProcessHeap(), 0, (MaxFallbackSubKeyLen + 1) * sizeof(WCHAR)); + if (!FallbackSubKeyName) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + + /* We must begin at the very first subkey of the fallback key, + * and then see if we meet keys that already are in the preferred key. + * In that case, we must bump dwIndex, as otherwise we would enumerate a key we already + * saw in a previous call. + */ + FallbackIndex = 0; + while (TRUE) + { + HKEY PreferredSubKey; + DWORD FallbackSubkeyLen = MaxFallbackSubKeyLen; + + /* Try enumerating */ + ErrorCode = RegEnumKeyExW( + FallbackKey, + FallbackIndex, + FallbackSubKeyName, + &FallbackSubkeyLen, + NULL, + NULL, + NULL, + NULL); + if (ErrorCode != ERROR_SUCCESS) + { + /* Most likely ERROR_NO_MORE_ITEMS */ + ERR("Returning %d.\n", ErrorCode); + goto Exit; + } + FallbackSubKeyName[FallbackSubkeyLen] = L'\0'; + + /* See if there is such a value on HKCU side */ + ErrorCode = RegOpenKeyExW( + PreferredKey, + FallbackSubKeyName, + 0, + 0, + &PreferredSubKey); + + if (ErrorCode == ERROR_SUCCESS) + { + RegCloseKey(PreferredSubKey); + /* So we already enumerated it on HKCU side. */ + dwIndex++; + } + else if (ErrorCode != ERROR_FILE_NOT_FOUND) + { + ERR("Got error %d while querying for %s on HKCU side.\n", ErrorCode, FallbackSubKeyName); + goto Exit; + } + + /* See if we caught up */ + if (FallbackIndex == dwIndex) + break; + + FallbackIndex++; + } + + /* We can finally enumerate on the fallback side */ + ErrorCode = RegEnumKeyExW( + FallbackKey, + dwIndex, + lpName, + lpcbName, + lpReserved, + lpClass, + lpcbClass, + lpftLastWriteTime); + +Exit: + if (PreferredKey != hKey) + RegCloseKey(PreferredKey); + if (FallbackKey != hKey) + RegCloseKey(FallbackKey); + if (FallbackSubKeyName) + RtlFreeHeap(RtlGetProcessHeap(), 0, FallbackSubKeyName); + + return ErrorCode; +} Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 22:51:44 2014 @@ -1306,7 +1306,11 @@ } if (IsHKCRKey(ParentKey)) - return DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved); + { + LONG ErrorCode = DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved); + ClosePredefKey(ParentKey); + return ErrorCode; + } if (samDesired & KEY_WOW64_32KEY) ERR("Wow64 not yet supported!\n"); @@ -2442,166 +2446,81 @@ * * @implemented */ -LONG WINAPI -RegEnumKeyExA(HKEY hKey, - DWORD dwIndex, - LPSTR lpName, - LPDWORD lpcbName, - LPDWORD lpReserved, - LPSTR lpClass, - LPDWORD lpcbClass, - PFILETIME lpftLastWriteTime) -{ - union - { - KEY_NODE_INFORMATION Node; - KEY_BASIC_INFORMATION Basic; - } *KeyInfo; - - UNICODE_STRING StringU; - ANSI_STRING StringA; - LONG ErrorCode = ERROR_SUCCESS; - DWORD NameLength; - DWORD ClassLength = 0; - DWORD BufferSize; - ULONG ResultSize; - HANDLE KeyHandle; - NTSTATUS Status; - - TRACE("RegEnumKeyExA(hKey 0x%x, dwIndex %d, lpName 0x%x, *lpcbName %d, lpClass 0x%x, lpcbClass %d)\n", - hKey, dwIndex, lpName, *lpcbName, lpClass, lpcbClass ? *lpcbClass : 0); - - if ((lpClass) && (!lpcbClass)) - { - return ERROR_INVALID_PARAMETER; - } - - Status = MapDefaultKey(&KeyHandle, hKey); - if (!NT_SUCCESS(Status)) - { - return RtlNtStatusToDosError(Status); - } - +LONG +WINAPI +RegEnumKeyExA( + _In_ HKEY hKey, + _In_ DWORD dwIndex, + _Out_ LPSTR lpName, + _Inout_ LPDWORD lpcbName, + _Reserved_ LPDWORD lpReserved, + _Out_opt_ LPSTR lpClass, + _Inout_opt_ LPDWORD lpcbClass, + _Out_opt_ PFILETIME lpftLastWriteTime) +{ + WCHAR* NameBuffer = NULL; + WCHAR* ClassBuffer = NULL; + DWORD NameLength, ClassLength; + LONG ErrorCode; + + /* Allocate our buffers */ if (*lpcbName > 0) { - NameLength = min (*lpcbName - 1 , REG_MAX_NAME_SIZE) * sizeof (WCHAR); - } - else - { - NameLength = 0; + NameLength = *lpcbName; + NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbName * sizeof(WCHAR)); + if (NameBuffer == NULL) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } } if (lpClass) { if (*lpcbClass > 0) { - ClassLength = min (*lpcbClass -1, REG_MAX_NAME_SIZE) * sizeof(WCHAR); - } - else - { - ClassLength = 0; - } - - /* The class name should start at a dword boundary */ - BufferSize = ((sizeof(KEY_NODE_INFORMATION) + NameLength + 3) & ~3) + ClassLength; - } - else - { - BufferSize = sizeof(KEY_BASIC_INFORMATION) + NameLength; - } - - KeyInfo = RtlAllocateHeap (ProcessHeap, 0, BufferSize); - if (KeyInfo == NULL) - { - ErrorCode = ERROR_OUTOFMEMORY; - goto Cleanup; - } - - Status = NtEnumerateKey(KeyHandle, - (ULONG)dwIndex, - lpClass == NULL ? KeyBasicInformation : KeyNodeInformation, - KeyInfo, - BufferSize, - &ResultSize); - TRACE("NtEnumerateKey() returned status 0x%X\n", Status); - if (!NT_SUCCESS(Status)) - { - ErrorCode = RtlNtStatusToDosError (Status); - } - else - { - if (lpClass == NULL) - { - if (KeyInfo->Basic.NameLength > NameLength) + ClassLength = *lpcbClass; + ClassBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbClass * sizeof(WCHAR)); + if (ClassBuffer == NULL) { - ErrorCode = ERROR_BUFFER_OVERFLOW; + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; } - else - { - StringU.Buffer = KeyInfo->Basic.Name; - StringU.Length = KeyInfo->Basic.NameLength; - StringU.MaximumLength = KeyInfo->Basic.NameLength; - } - } - else - { - if (KeyInfo->Node.NameLength > NameLength || - KeyInfo->Node.ClassLength > ClassLength) - { - ErrorCode = ERROR_BUFFER_OVERFLOW; - } - else - { - StringA.Buffer = lpClass; - StringA.Length = 0; - StringA.MaximumLength = *lpcbClass; - StringU.Buffer = (PWCHAR)((ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset); - StringU.Length = KeyInfo->Node.ClassLength; - StringU.MaximumLength = KeyInfo->Node.ClassLength; - RtlUnicodeStringToAnsiString (&StringA, &StringU, FALSE); - lpClass[StringA.Length] = 0; - *lpcbClass = StringA.Length; - StringU.Buffer = KeyInfo->Node.Name; - StringU.Length = KeyInfo->Node.NameLength; - StringU.MaximumLength = KeyInfo->Node.NameLength; - } - } - - if (ErrorCode == ERROR_SUCCESS) - { - StringA.Buffer = lpName; - StringA.Length = 0; - StringA.MaximumLength = *lpcbName; - RtlUnicodeStringToAnsiString (&StringA, &StringU, FALSE); - lpName[StringA.Length] = 0; - *lpcbName = StringA.Length; - if (lpftLastWriteTime != NULL) - { - if (lpClass == NULL) - { - lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart; - lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart; - } - else - { - lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart; - lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart; - } - } - } - } - - /*TRACE("Key Namea0 Length %d\n", StringU.Length);*/ /* BUGBUG could be uninitialized */ - TRACE("Key Name1 Length %d\n", NameLength); - TRACE("Key Name Length %d\n", *lpcbName); - TRACE("Key Name %s\n", lpName); - - RtlFreeHeap(ProcessHeap, - 0, - KeyInfo); - -Cleanup: - ClosePredefKey(KeyHandle); + } + } + + /* Do the actual call */ + ErrorCode = RegEnumKeyExW( + hKey, + dwIndex, + NameBuffer, + lpcbName, + lpReserved, + ClassBuffer, + lpcbClass, + lpftLastWriteTime); + + if (ErrorCode != ERROR_SUCCESS) + goto Exit; + + /* Convert the strings */ + RtlUnicodeToMultiByteN(lpName, *lpcbName, 0, NameBuffer, *lpcbName * sizeof(WCHAR)); + /* NULL terminate if we can */ + if (NameLength > *lpcbName) + lpName[*lpcbName] = '\0'; + + if (lpClass) + { + RtlUnicodeToMultiByteN(lpClass, *lpcbClass, 0, NameBuffer, *lpcbClass * sizeof(WCHAR)); + if (ClassLength > *lpcbClass) + lpClass[*lpcbClass] = '\0'; + } + +Exit: + if (NameBuffer) + RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer); + if (ClassBuffer) + RtlFreeHeap(RtlGetProcessHeap(), 0, ClassBuffer); return ErrorCode; } @@ -2612,15 +2531,17 @@ * * @implemented */ -LONG WINAPI -RegEnumKeyExW(HKEY hKey, - DWORD dwIndex, - LPWSTR lpName, - LPDWORD lpcbName, - LPDWORD lpReserved, - LPWSTR lpClass, - LPDWORD lpcbClass, - PFILETIME lpftLastWriteTime) +LONG +WINAPI +RegEnumKeyExW( + _In_ HKEY hKey, + _In_ DWORD dwIndex, + _Out_ LPWSTR lpName, + _Inout_ LPDWORD lpcbName, + _Reserved_ LPDWORD lpReserved, + _Out_opt_ LPWSTR lpClass, + _Inout_opt_ LPDWORD lpcbClass, + _Out_opt_ PFILETIME lpftLastWriteTime) { union { @@ -2641,6 +2562,21 @@ if (!NT_SUCCESS(Status)) { return RtlNtStatusToDosError(Status); + } + + if (IsHKCRKey(KeyHandle)) + { + ErrorCode = EnumHKCRKey( + KeyHandle, + dwIndex, + lpName, + lpcbName, + lpReserved, + lpClass, + lpcbClass, + lpftLastWriteTime); + ClosePredefKey(KeyHandle); + return ErrorCode; } if (*lpcbName > 0) @@ -3419,7 +3355,11 @@ } if (IsHKCRKey(KeyHandle)) - return OpenHKCRKey(KeyHandle, lpSubKey, ulOptions, samDesired, phkResult); + { + ErrorCode = OpenHKCRKey(KeyHandle, lpSubKey, ulOptions, samDesired, phkResult); + ClosePredefKey(KeyHandle); + return ErrorCode; + } if (ulOptions & REG_OPTION_OPEN_LINK) Attributes |= OBJ_OPENLINK; @@ -4035,7 +3975,7 @@ ErrorCode = RegQueryValueExW(hkeyorg, nameW.Buffer, NULL, &LocalType, NULL, &BufferSize); if (ErrorCode != ERROR_SUCCESS) { - if (!data) + if ((!data) && count) *count = 0; RtlFreeUnicodeString(&nameW); return ErrorCode; Modified: trunk/reactos/dll/win32/advapi32/reg/reg.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] Wed Oct 1 22:51:44 2014 @@ -72,3 +72,15 @@ _In_ CONST BYTE* Data, _In_ DWORD DataSize); +LONG +WINAPI +EnumHKCRKey( + _In_ HKEY hKey, + _In_ DWORD dwIndex, + _Out_ LPWSTR lpName, + _Inout_ LPDWORD lpcbName, + _Reserved_ LPDWORD lpReserved, + _Out_opt_ LPWSTR lpClass, + _Inout_opt_ LPDWORD lpcbClass, + _Out_opt_ PFILETIME lpftLastWriteTime); +
10 years, 3 months
1
0
0
0
[jgardou] 64444: [ADVAPI32] - Add implementation of RegCreateKeyEx and RegSetValueEx for HKCR subkeys CORE-8582
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Oct 1 17:48:32 2014 New Revision: 64444 URL:
http://svn.reactos.org/svn/reactos?rev=64444&view=rev
Log: [ADVAPI32] - Add implementation of RegCreateKeyEx and RegSetValueEx for HKCR subkeys CORE-8582 Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c trunk/reactos/dll/win32/advapi32/reg/reg.c trunk/reactos/dll/win32/advapi32/reg/reg.h Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Wed Oct 1 17:48:32 2014 @@ -96,7 +96,8 @@ LONG GetFallbackHKCRKey( _In_ HKEY hKey, - _Out_ HKEY* MachineKey) + _Out_ HKEY* MachineKey, + _In_ BOOL MustCreate) { UNICODE_STRING KeyName; LPWSTR SubKeyName; @@ -135,13 +136,29 @@ return ErrorCode; } - /* Open the key. */ - ErrorCode = RegOpenKeyExW( - HKEY_LOCAL_MACHINE, - SubKeyName, - 0, - SamDesired, - MachineKey); + if (MustCreate) + { + ErrorCode = RegCreateKeyExW( + HKEY_LOCAL_MACHINE, + SubKeyName, + 0, + NULL, + 0, + SamDesired, + NULL, + MachineKey, + NULL); + } + else + { + /* Open the key. */ + ErrorCode = RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + SubKeyName, + 0, + SamDesired, + MachineKey); + } RtlFreeUnicodeString(&KeyName); @@ -197,6 +214,110 @@ return ErrorCode; } +/* HKCR version of RegCreateKeyExW. */ +LONG +WINAPI +CreateHKCRKey( + _In_ HKEY hKey, + _In_ LPCWSTR lpSubKey, + _In_ DWORD Reserved, + _In_opt_ LPWSTR lpClass, + _In_ DWORD dwOptions, + _In_ REGSAM samDesired, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _Out_ PHKEY phkResult, + _Out_opt_ LPDWORD lpdwDisposition) +{ + LONG ErrorCode; + HKEY QueriedKey, TestKey; + + ASSERT(IsHKCRKey(hKey)); + + /* Remove the HKCR flag while we're working */ + hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2); + + ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey); + + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* The current key doesn't exist on HKCU side, so we can only create it in HKLM */ + ErrorCode = RegCreateKeyExW( + hKey, + lpSubKey, + Reserved, + lpClass, + dwOptions, + samDesired, + lpSecurityAttributes, + phkResult, + lpdwDisposition); + if (ErrorCode == ERROR_SUCCESS) + MakeHKCRKey(phkResult); + return ErrorCode; + } + + if (ErrorCode != ERROR_SUCCESS) + { + /* Somehow we failed for another reason (maybe deleted key or whatever) */ + return ErrorCode; + } + + /* See if the subkey already exists in HKCU. */ + ErrorCode = RegOpenKeyExW(QueriedKey, lpSubKey, 0, KEY_READ, &TestKey); + if (ErrorCode != ERROR_FILE_NOT_FOUND) + { + if (ErrorCode == ERROR_SUCCESS) + { + /* Great. Close the test one and do the real create operation */ + RegCloseKey(TestKey); + ErrorCode = RegCreateKeyExW( + QueriedKey, + lpSubKey, + Reserved, + lpClass, + dwOptions, + samDesired, + lpSecurityAttributes, + phkResult, + lpdwDisposition); + if (ErrorCode == ERROR_SUCCESS) + MakeHKCRKey(phkResult); + } + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + + return ERROR_SUCCESS; + } + + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + + /* So we must do the create operation in HKLM, creating the missing parent keys if needed. */ + ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey, TRUE); + if (ErrorCode != ERROR_SUCCESS) + return ErrorCode; + + /* Do the key creation */ + ErrorCode = RegCreateKeyEx( + QueriedKey, + lpSubKey, + Reserved, + lpClass, + dwOptions, + samDesired, + lpSecurityAttributes, + phkResult, + lpdwDisposition); + + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + + if (ErrorCode == ERROR_SUCCESS) + MakeHKCRKey(phkResult); + + return ErrorCode; +} + /* Same as RegOpenKeyExW, but for HKEY_CLASSES_ROOT subkeys */ LONG WINAPI @@ -248,7 +369,7 @@ return ErrorCode; /* If we're here, we must open from HKLM key. */ - ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey); + ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey, FALSE); if (ErrorCode != ERROR_SUCCESS) { /* Maybe the key doesn't exist in the HKLM view */ @@ -313,7 +434,7 @@ return ErrorCode; /* If we're here, we must open from HKLM key. */ - ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey); + ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey, FALSE); if (ErrorCode != ERROR_SUCCESS) { /* Maybe the key doesn't exist in the HKLM view */ @@ -378,7 +499,7 @@ return ErrorCode; /* If we're here, we must open from HKLM key. */ - ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey); + ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey, FALSE); if (ErrorCode != ERROR_SUCCESS) { /* Maybe the key doesn't exist in the HKLM view */ @@ -395,3 +516,72 @@ return ErrorCode; } + +/* HKCR version of RegSetValueExW */ +LONG +WINAPI +SetHKCRValue( + _In_ HKEY hKey, + _In_ LPCWSTR Name, + _In_ DWORD Reserved, + _In_ DWORD Type, + _In_ CONST BYTE* Data, + _In_ DWORD DataSize) +{ + HKEY QueriedKey; + LONG ErrorCode; + + ASSERT(IsHKCRKey(hKey)); + + /* Remove the HKCR flag while we're working */ + hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2); + + ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey); + + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* The key doesn't exist on HKCU side, no chance to put a value in it */ + return RegSetValueExW(hKey, Name, Reserved, Type, Data, DataSize); + } + + if (ErrorCode != ERROR_SUCCESS) + { + /* Somehow we failed for another reason (maybe deleted key or whatever) */ + return ErrorCode; + } + + /* Check if the value already exists in the preferred key */ + ErrorCode = RegQueryValueExW(QueriedKey, Name, NULL, NULL, NULL, NULL); + if (ErrorCode != ERROR_FILE_NOT_FOUND) + { + if (ErrorCode == ERROR_SUCCESS) + { + /* Yes, so we have the right to modify it */ + ErrorCode = RegSetValueExW(QueriedKey, Name, Reserved, Type, Data, DataSize); + } + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + return ErrorCode; + } + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + + /* So we must set the value in the HKLM version */ + ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey); + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* No choice: put this in HKCU */ + return RegSetValueExW(hKey, Name, Reserved, Type, Data, DataSize); + } + else if (ErrorCode != ERROR_SUCCESS) + { + return ErrorCode; + } + + ErrorCode = RegSetValueExW(QueriedKey, Name, Reserved, Type, Data, DataSize); + + if (QueriedKey != hKey) + RegCloseKey(QueriedKey); + + return ErrorCode; +} Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 17:48:32 2014 @@ -1084,16 +1084,18 @@ * * @implemented */ -LONG WINAPI -RegCreateKeyExW(HKEY hKey, - LPCWSTR lpSubKey, - DWORD Reserved, - LPWSTR lpClass, - DWORD dwOptions, - REGSAM samDesired, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - PHKEY phkResult, - LPDWORD lpdwDisposition) +LONG +WINAPI +RegCreateKeyExW( + _In_ HKEY hKey, + _In_ LPCWSTR lpSubKey, + _In_ DWORD Reserved, + _In_opt_ LPWSTR lpClass, + _In_ DWORD dwOptions, + _In_ REGSAM samDesired, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _Out_ PHKEY phkResult, + _Out_opt_ LPDWORD lpdwDisposition) { UNICODE_STRING SubKeyString; UNICODE_STRING ClassString; @@ -1116,6 +1118,22 @@ } TRACE("ParentKey %p\n", ParentKey); + + if (IsHKCRKey(ParentKey)) + { + LONG ErrorCode = CreateHKCRKey( + ParentKey, + lpSubKey, + Reserved, + lpClass, + dwOptions, + samDesired, + lpSecurityAttributes, + phkResult, + lpdwDisposition); + ClosePredefKey(ParentKey); + return ErrorCode; + } if (dwOptions & REG_OPTION_OPEN_LINK) Attributes |= OBJ_OPENLINK; @@ -1143,9 +1161,6 @@ { return RtlNtStatusToDosError(Status); } - - if (IsHKCRKey(ParentKey)) - MakeHKCRKey(phkResult); return ERROR_SUCCESS; } @@ -4851,17 +4866,33 @@ * * @implemented */ -LONG WINAPI -RegSetValueExW(HKEY hKey, - LPCWSTR lpValueName, - DWORD Reserved, - DWORD dwType, - CONST BYTE* lpData, - DWORD cbData) +LONG +WINAPI +RegSetValueExW( + _In_ HKEY hKey, + _In_ LPCWSTR lpValueName, + _In_ DWORD Reserved, + _In_ DWORD dwType, + _In_ CONST BYTE* lpData, + _In_ DWORD cbData) { UNICODE_STRING ValueName; HANDLE KeyHandle; NTSTATUS Status; + + Status = MapDefaultKey(&KeyHandle, + hKey); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + if (IsHKCRKey(KeyHandle)) + { + LONG ErrorCode = SetHKCRValue(KeyHandle, lpValueName, Reserved, dwType, lpData, cbData); + ClosePredefKey(KeyHandle); + return ErrorCode; + } if (is_string(dwType) && (cbData != 0)) { @@ -4878,16 +4909,10 @@ } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - _SEH2_YIELD(return ERROR_NOACCESS); + ClosePredefKey(KeyHandle); + return ERROR_NOACCESS; } _SEH2_END; - } - - Status = MapDefaultKey(&KeyHandle, - hKey); - if (!NT_SUCCESS(Status)) - { - return RtlNtStatusToDosError(Status); } RtlInitUnicodeString(&ValueName, lpValueName); Modified: trunk/reactos/dll/win32/advapi32/reg/reg.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] Wed Oct 1 17:48:32 2014 @@ -21,6 +21,19 @@ { *hKey = (HKEY)((ULONG_PTR)(*hKey) | 0x2); } + +LONG +WINAPI +CreateHKCRKey( + _In_ HKEY hKey, + _In_ LPCWSTR lpSubKey, + _In_ DWORD Reserved, + _In_opt_ LPWSTR lpClass, + _In_ DWORD dwOptions, + _In_ REGSAM samDesired, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _Out_ PHKEY phkResult, + _Out_opt_ LPDWORD lpdwDisposition); LONG WINAPI @@ -49,3 +62,13 @@ _In_ LPBYTE Data, _In_ LPDWORD Count); +LONG +WINAPI +SetHKCRValue( + _In_ HKEY hKey, + _In_ LPCWSTR Name, + _In_ DWORD Reserved, + _In_ DWORD Type, + _In_ CONST BYTE* Data, + _In_ DWORD DataSize); +
10 years, 3 months
1
0
0
0
[jgardou] 64443: [ADVAPI32] - Implement RegQueryValueEx for HKCR subkeys CORE-8582
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Oct 1 17:48:26 2014 New Revision: 64443 URL:
http://svn.reactos.org/svn/reactos?rev=64443&view=rev
Log: [ADVAPI32] - Implement RegQueryValueEx for HKCR subkeys CORE-8582 Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c trunk/reactos/dll/win32/advapi32/reg/reg.c trunk/reactos/dll/win32/advapi32/reg/reg.h Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Wed Oct 1 17:48:26 2014 @@ -268,6 +268,7 @@ return ErrorCode; } +/* HKCR version of RegDeleteKeyExW */ LONG WINAPI DeleteHKCRKey( @@ -329,3 +330,68 @@ return ErrorCode; } + +/* HKCR version of RegQueryValueExW */ +LONG +WINAPI +QueryHKCRValue( + _In_ HKEY hKey, + _In_ LPCWSTR Name, + _In_ LPDWORD Reserved, + _In_ LPDWORD Type, + _In_ LPBYTE Data, + _In_ LPDWORD Count) +{ + HKEY QueriedKey; + LONG ErrorCode; + + ASSERT(IsHKCRKey(hKey)); + + /* Remove the HKCR flag while we're working */ + hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2); + + ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey); + + if (ErrorCode == ERROR_FILE_NOT_FOUND) + { + /* The key doesn't exist on HKCU side, no chance for a value in it */ + return RegQueryValueExW(hKey, Name, Reserved, Type, Data, Count); + } + + if (ErrorCode != ERROR_SUCCESS) + { + /* Somehow we failed for another reason (maybe deleted key or whatever) */ + return ErrorCode; + } + + ErrorCode = RegQueryValueExW(QueriedKey, Name, Reserved, Type, Data, Count); + + /* Close it if we must */ + if (QueriedKey != hKey) + { + /* The original key is on the machine view */ + RegCloseKey(QueriedKey); + } + + /* Anything else than ERROR_FILE_NOT_FOUND means that we found it, even if it is with failures. */ + if (ErrorCode != ERROR_FILE_NOT_FOUND) + return ErrorCode; + + /* If we're here, we must open from HKLM key. */ + ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey); + if (ErrorCode != ERROR_SUCCESS) + { + /* Maybe the key doesn't exist in the HKLM view */ + return ErrorCode; + } + + ErrorCode = RegQueryValueExW(QueriedKey, Name, Reserved, Type, Data, Count); + + /* Close it if we must */ + if (QueriedKey != hKey) + { + RegCloseKey(QueriedKey); + } + + return ErrorCode; +} Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 17:48:26 2014 @@ -4082,12 +4082,13 @@ */ LONG WINAPI -RegQueryValueExW(HKEY hkeyorg, - LPCWSTR name, - LPDWORD reserved, - LPDWORD type, - LPBYTE data, - LPDWORD count) +RegQueryValueExW( + _In_ HKEY hkeyorg, + _In_ LPCWSTR name, + _In_ LPDWORD reserved, + _In_ LPDWORD type, + _In_ LPBYTE data, + _In_ LPDWORD count) { HANDLE hkey; NTSTATUS status; @@ -4107,6 +4108,13 @@ if (!NT_SUCCESS(status)) { return RtlNtStatusToDosError(status); + } + + if (IsHKCRKey(hkey)) + { + LONG ErrorCode = QueryHKCRValue(hkey, name, reserved, type, data, count); + ClosePredefKey(hkey); + return ErrorCode; } RtlInitUnicodeString( &name_str, name ); Modified: trunk/reactos/dll/win32/advapi32/reg/reg.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.h [iso-8859-1] Wed Oct 1 17:48:26 2014 @@ -39,3 +39,13 @@ _In_ REGSAM RegSam, _In_ DWORD Reserved); +LONG +WINAPI +QueryHKCRValue( + _In_ HKEY hKey, + _In_ LPCWSTR Name, + _In_ LPDWORD Reserved, + _In_ LPDWORD Type, + _In_ LPBYTE Data, + _In_ LPDWORD Count); +
10 years, 3 months
1
0
0
0
[jgardou] 64442: [ADVAPI32] - Correctly use RtlCreateUnicodeStringFromAsciiz and check for its return value in various places. It allocates a buffer and initializes is it as empty even if the passe...
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Oct 1 17:48:17 2014 New Revision: 64442 URL:
http://svn.reactos.org/svn/reactos?rev=64442&view=rev
Log: [ADVAPI32] - Correctly use RtlCreateUnicodeStringFromAsciiz and check for its return value in various places. It allocates a buffer and initializes is it as empty even if the passed ASCII buffer is NULL. Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 17:48:17 2014 @@ -1039,8 +1039,26 @@ UNICODE_STRING ClassString; DWORD ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&ClassString, lpClass); - RtlCreateUnicodeStringFromAsciiz(&SubKeyString, (LPSTR)lpSubKey); + RtlInitEmptyUnicodeString(&ClassString, NULL, 0); + RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0); + + if (lpClass) + { + if (!RtlCreateUnicodeStringFromAsciiz(&ClassString, lpClass)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } + + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } ErrorCode = RegCreateKeyExW( hKey, @@ -1053,6 +1071,7 @@ phkResult, lpdwDisposition); +Exit: RtlFreeUnicodeString(&SubKeyString); RtlFreeUnicodeString(&ClassString); @@ -1222,7 +1241,13 @@ LONG ErrorCode; UNICODE_STRING SubKeyName; - RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey); + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, lpSubKey)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&SubKeyName, NULL, 0); ErrorCode = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved); @@ -3048,15 +3073,32 @@ UNICODE_STRING KeyName; LONG ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&KeyName, - (LPSTR)lpSubKey); - RtlCreateUnicodeStringFromAsciiz(&FileName, - (LPSTR)lpFile); + RtlInitEmptyUnicodeString(&KeyName, NULL, 0); + RtlInitEmptyUnicodeString(&FileName, NULL, 0); + + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&KeyName, lpSubKey)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } + + if (lpFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFile)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } ErrorCode = RegLoadKeyW(hKey, KeyName.Buffer, FileName.Buffer); +Exit: RtlFreeUnicodeString(&FileName); RtlFreeUnicodeString(&KeyName); @@ -3313,8 +3355,13 @@ TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n", hKey, lpSubKey, ulOptions, samDesired, phkResult); - RtlCreateUnicodeStringFromAsciiz(&SubKeyString, - (LPSTR)lpSubKey); + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0); ErrorCode = RegOpenKeyExW(hKey, SubKeyString.Buffer, ulOptions, samDesired, phkResult); @@ -3963,7 +4010,10 @@ return ERROR_INVALID_PARAMETER; if (name) - RtlCreateUnicodeStringFromAsciiz(&nameW, name); + { + if (!RtlCreateUnicodeStringFromAsciiz(&nameW, name)) + return ERROR_NOT_ENOUGH_MEMORY; + } else RtlInitEmptyUnicodeString(&nameW, NULL, 0); @@ -4205,18 +4255,43 @@ UNICODE_STRING OldFile; LONG ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&SubKey, - (PCSZ)lpSubKey); - RtlCreateUnicodeStringFromAsciiz(&OldFile, - (PCSZ)lpOldFile); - RtlCreateUnicodeStringFromAsciiz(&NewFile, - (PCSZ)lpNewFile); + RtlInitEmptyUnicodeString(&SubKey, NULL, 0); + RtlInitEmptyUnicodeString(&OldFile, NULL, 0); + RtlInitEmptyUnicodeString(&NewFile, NULL, 0); + + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKey, lpSubKey)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } + + if (lpOldFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&OldFile, lpOldFile)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } + + if (lpNewFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&NewFile, lpNewFile)) + { + ErrorCode = ERROR_NOT_ENOUGH_MEMORY; + goto Exit; + } + } ErrorCode = RegReplaceKeyW(hKey, SubKey.Buffer, NewFile.Buffer, OldFile.Buffer); +Exit: RtlFreeUnicodeString(&OldFile); RtlFreeUnicodeString(&NewFile); RtlFreeUnicodeString(&SubKey); @@ -4373,8 +4448,13 @@ UNICODE_STRING FileName; LONG ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&FileName, - (PCSZ)lpFile); + if (lpFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFile)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&FileName, NULL, 0); ErrorCode = RegRestoreKeyW(hKey, FileName.Buffer, @@ -4474,8 +4554,14 @@ UNICODE_STRING FileName; LONG ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&FileName, - (LPSTR)lpFile); + if (lpFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFile)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&FileName, NULL, 0); + ErrorCode = RegSaveKeyW(hKey, FileName.Buffer, lpSecurityAttributes); @@ -4579,8 +4665,14 @@ UNICODE_STRING FileName; LONG ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&FileName, - (LPSTR)lpFile); + if (lpFile) + { + if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFile)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&FileName, NULL, 0); + ErrorCode = RegSaveKeyExW(hKey, FileName.Buffer, lpSecurityAttributes, @@ -4917,8 +5009,13 @@ UNICODE_STRING KeyName; DWORD ErrorCode; - RtlCreateUnicodeStringFromAsciiz(&KeyName, - (LPSTR)lpSubKey); + if (lpSubKey) + { + if (!RtlCreateUnicodeStringFromAsciiz(&KeyName, lpSubKey)) + return ERROR_NOT_ENOUGH_MEMORY; + } + else + RtlInitEmptyUnicodeString(&KeyName, NULL, 0); ErrorCode = RegUnLoadKeyW(hKey, KeyName.Buffer);
10 years, 3 months
1
0
0
0
[jgardou] 64441: [ADVAPI32] - Rewrite RegQueryValueExA as a wrapper arount RegQueryValueExW CORE-8582
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Oct 1 17:48:04 2014 New Revision: 64441 URL:
http://svn.reactos.org/svn/reactos?rev=64441&view=rev
Log: [ADVAPI32] - Rewrite RegQueryValueExA as a wrapper arount RegQueryValueExW CORE-8582 Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Wed Oct 1 17:48:04 2014 @@ -3942,102 +3942,86 @@ */ LONG WINAPI -RegQueryValueExA(HKEY hkeyorg, - LPCSTR name, - LPDWORD reserved, - LPDWORD type, - LPBYTE data, - LPDWORD count) -{ - HANDLE hkey; - NTSTATUS status; - ANSI_STRING nameA; +RegQueryValueExA( + _In_ HKEY hkeyorg, + _In_ LPCSTR name, + _In_ LPDWORD reserved, + _Out_opt_ LPDWORD type, + _Out_opt_ LPBYTE data, + _Inout_opt_ LPDWORD count) +{ UNICODE_STRING nameW; - DWORD total_size, datalen = 0; - char buffer[256], *buf_ptr = buffer; - KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; - static const int info_size = offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ); - - TRACE("(%p,%s,%p,%p,%p,%p=%d)\n", - hkeyorg, debugstr_a(name), reserved, type, data, count, count ? *count : 0 ); - - if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; - status = MapDefaultKey(&hkey, hkeyorg); - if (!NT_SUCCESS(status)) - { - return RtlNtStatusToDosError(status); - } - - if (count) datalen = *count; - if (!data && count) *count = 0; - - RtlInitAnsiString( &nameA, name ); - if ((status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE ))) - { - ClosePredefKey(hkey); - return RtlNtStatusToDosError(status); - } - - status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, - buffer, sizeof(buffer), &total_size ); - if (status && status != STATUS_BUFFER_OVERFLOW) goto done; - - /* we need to fetch the contents for a string type even if not requested, - * because we need to compute the length of the ASCII string. */ - if (data || is_string(info->Type)) - { - /* retry with a dynamically allocated buffer */ - while (status == STATUS_BUFFER_OVERFLOW) - { - if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); - if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) - { - status = STATUS_NO_MEMORY; - goto done; - } - info = (KEY_VALUE_PARTIAL_INFORMATION *)buf_ptr; - status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, - buf_ptr, total_size, &total_size ); - } - - if (status) goto done; - - if (is_string(info->Type)) - { - DWORD len; - - RtlUnicodeToMultiByteSize( &len, (WCHAR *)(buf_ptr + info_size), - total_size - info_size ); - if (data && len) - { - if (len > datalen) status = STATUS_BUFFER_OVERFLOW; - else - { - RtlUnicodeToMultiByteN( (char*)data, len, NULL, (WCHAR *)(buf_ptr + info_size), - total_size - info_size ); - /* if the type is REG_SZ and data is not 0-terminated - * and there is enough space in the buffer NT appends a \0 */ - if (len < datalen && data[len-1]) data[len] = 0; - } - } - total_size = len + info_size; - } - else if (data) - { - if (total_size - info_size > datalen) status = STATUS_BUFFER_OVERFLOW; - else memcpy( data, buf_ptr + info_size, total_size - info_size ); - } - } - else status = STATUS_SUCCESS; - - if (type) *type = info->Type; - if (count) *count = total_size - info_size; - - done: - if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); - RtlFreeUnicodeString( &nameW ); - ClosePredefKey(hkey); - return RtlNtStatusToDosError(status); + DWORD DataLength; + DWORD ErrorCode; + DWORD BufferSize = 0; + WCHAR* Buffer; + CHAR* DataStr = (CHAR*)data; + DWORD LocalType; + + /* Validate those parameters, the rest will be done with the first RegQueryValueExW call */ + if ((data && !count) || reserved) + return ERROR_INVALID_PARAMETER; + + if (name) + RtlCreateUnicodeStringFromAsciiz(&nameW, name); + else + RtlInitEmptyUnicodeString(&nameW, NULL, 0); + + ErrorCode = RegQueryValueExW(hkeyorg, nameW.Buffer, NULL, &LocalType, NULL, &BufferSize); + if (ErrorCode != ERROR_SUCCESS) + { + if (!data) + *count = 0; + RtlFreeUnicodeString(&nameW); + return ErrorCode; + } + + /* See if we can directly handle the call without caring for conversion */ + if (!is_string(LocalType) || !count) + { + ErrorCode = RegQueryValueExW(hkeyorg, nameW.Buffer, reserved, type, data, count); + RtlFreeUnicodeString(&nameW); + return ErrorCode; + } + + /* Allocate a unicode string to get the data */ + Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferSize); + if (!Buffer) + { + RtlFreeUnicodeString(&nameW); + return ERROR_NOT_ENOUGH_MEMORY; + } + + ErrorCode = RegQueryValueExW(hkeyorg, nameW.Buffer, reserved, type, (LPBYTE)Buffer, &BufferSize); + if (ErrorCode != ERROR_SUCCESS) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + RtlFreeUnicodeString(&nameW); + return ErrorCode; + } + + /* We don't need this anymore */ + RtlFreeUnicodeString(&nameW); + + DataLength = *count; + RtlUnicodeToMultiByteSize(count, Buffer, BufferSize); + + if ((!data) || (DataLength < *count)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + return data ? ERROR_MORE_DATA : ERROR_SUCCESS; + } + + /* We can finally do the conversion */ + RtlUnicodeToMultiByteN(DataStr, DataLength, NULL, Buffer, BufferSize); + + /* NULL-terminate if there is enough room */ + if ((DataLength > *count) && (DataStr[*count - 1] != '\0')) + DataStr[*count] = '\0'; + + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + + return ERROR_SUCCESS; }
10 years, 3 months
1
0
0
0
← Newer
1
...
69
70
71
72
73
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Results per page:
10
25
50
100
200