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
September 2015
----- 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
17 participants
535 discussions
Start a n
N
ew thread
[ion] 69340: [NDK]: Add OB_FLAG_KERNEL_EXCLUSIVE and OBJ_KERNEL_EXCLUSIVE flags [NTOSKRNL]: Add a helper function such that user-mode cannot pass certain kernel-only object attributes to ObOpenObje...
by ion@svn.reactos.org
Author: ion Date: Thu Sep 24 02:40:30 2015 New Revision: 69340 URL:
http://svn.reactos.org/svn/reactos?rev=69340&view=rev
Log: [NDK]: Add OB_FLAG_KERNEL_EXCLUSIVE and OBJ_KERNEL_EXCLUSIVE flags [NTOSKRNL]: Add a helper function such that user-mode cannot pass certain kernel-only object attributes to ObOpenObjectByPointer. [NTOSKRNL]: Make \Device\PhysicalMemory OBJ_KERNEL_EXCLUSIVE [NTOSKRNL]: Deny access to user-mode when opening a handle to an object with OBJ_KERNEL_EXCLUSIVE [NTOSKRNL]: Fix NtOpenProcess, NtOpenThread, NtOpenThreadTokenEx, NtOpenProcessTokenEx to use the helper function. Should fix Rtl using OBJ_KERNEL_HANDLE in user-mode. Thanks to ThFabba for finding out these bugs, and the hbelusca for adding a missing check to NtOpenProcessTokenEx. Modified: trunk/reactos/include/ndk/obtypes.h trunk/reactos/ntoskrnl/include/internal/ob_x.h trunk/reactos/ntoskrnl/mm/section.c trunk/reactos/ntoskrnl/ob/obhandle.c trunk/reactos/ntoskrnl/ob/oblife.c trunk/reactos/ntoskrnl/ob/obname.c trunk/reactos/ntoskrnl/ps/process.c trunk/reactos/ntoskrnl/ps/security.c trunk/reactos/ntoskrnl/ps/thread.c trunk/reactos/ntoskrnl/se/token.c Modified: trunk/reactos/include/ndk/obtypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/obtypes.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/obtypes.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/obtypes.h [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -86,6 +86,12 @@ #else // +// Undocumented Attribute for Kernel-Only Access +// +#define OBJ_KERNEL_EXCLUSIVE 0x00010000L +#define OBJ_VALID_KERNEL_ATTRIBUTES (OBJ_VALID_ATTRIBUTES | \ + OBJ_KERNEL_EXCLUSIVE) +// // Object Flags // #define OB_FLAG_CREATE_INFO 0x01 @@ -96,6 +102,11 @@ #define OB_FLAG_SECURITY 0x20 #define OB_FLAG_SINGLE_PROCESS 0x40 #define OB_FLAG_DEFER_DELETE 0x80 + +// +// Object Flags encoded in "QueryReferences" field +// +#define OB_FLAG_KERNEL_EXCLUSIVE 0x40000000 #define OBJECT_TO_OBJECT_HEADER(o) \ CONTAINING_RECORD((o), OBJECT_HEADER, Body) Modified: trunk/reactos/ntoskrnl/include/internal/ob_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ob_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ob_x.h [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -16,6 +16,24 @@ #define OBP_LOCK_STATE_INITIALIZED 0xFFFF1234 #define OBP_NAME_LOOKASIDE_MAX_SIZE 248 + +FORCEINLINE +ULONG +ObpValidateAttributes(IN ULONG Attributes, + IN KPROCESSOR_MODE PreviousMode) +{ + if (PreviousMode == KernelMode) + { + /* For kernel, allow any valid attributes */ + return Attributes & OBJ_VALID_KERNEL_ATTRIBUTES; + } + else + { + /* For user, mask out kernel-only attributes */ + return (Attributes & OBJ_VALID_ATTRIBUTES) & + ~(OBJ_KERNEL_HANDLE); + } +} FORCEINLINE ULONG Modified: trunk/reactos/ntoskrnl/mm/section.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -2756,7 +2756,7 @@ SectionSize.QuadPart = 0xFFFFFFFF; InitializeObjectAttributes(&Obj, &Name, - OBJ_PERMANENT, + OBJ_PERMANENT | OBJ_KERNEL_EXCLUSIVE, NULL, NULL); Status = MmCreateSection((PVOID)&PhysSection, Modified: trunk/reactos/ntoskrnl/ob/obhandle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ob/obhandle.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/obhandle.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -807,6 +807,7 @@ KIRQL CalloutIrql; KPROCESSOR_MODE ProbeMode; ULONG Total; + POBJECT_HEADER_NAME_INFO NameInfo; PAGED_CODE(); /* Get the object header and type */ @@ -868,6 +869,16 @@ (OBJECT_HEADER_TO_EXCLUSIVE_PROCESS(ObjectHeader))) { /* Caller didn't want exclusive access, but the object is exclusive */ + Status = STATUS_ACCESS_DENIED; + goto Quickie; + } + + /* Check for exclusive kernel object */ + NameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader); + if ((NameInfo) && (NameInfo->QueryReferences & OB_FLAG_KERNEL_EXCLUSIVE) && + (ProbeMode != KernelMode)) + { + /* Caller is not kernel, but the object is kernel exclusive */ Status = STATUS_ACCESS_DENIED; goto Quickie; } Modified: trunk/reactos/ntoskrnl/ob/oblife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblife.c?rev=6…
============================================================================== --- trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -731,10 +731,10 @@ /* Check if this is a call with the special protection flag */ if ((PreviousMode == KernelMode) && (ObjectCreateInfo) && - (ObjectCreateInfo->Attributes & 0x10000)) + (ObjectCreateInfo->Attributes & OBJ_KERNEL_EXCLUSIVE)) { /* Set flag which will make the object protected from user-mode */ - NameInfo->QueryReferences |= 0x40000000; + NameInfo->QueryReferences |= OB_FLAG_KERNEL_EXCLUSIVE; } /* Set the header pointer */ Modified: trunk/reactos/ntoskrnl/ob/obname.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=6…
============================================================================== --- trunk/reactos/ntoskrnl/ob/obname.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/obname.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -261,14 +261,14 @@ ObpDeleteSymbolicLinkName(Object); } - /* Check if the magic protection flag is set */ + /* Check if the kernel exclusive is set */ ObjectNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader); if ((ObjectNameInfo) && - (ObjectNameInfo->QueryReferences & 0x40000000)) + (ObjectNameInfo->QueryReferences & OB_FLAG_KERNEL_EXCLUSIVE)) { /* Remove protection flag */ InterlockedExchangeAdd((PLONG)&ObjectNameInfo->QueryReferences, - -0x40000000); + -OB_FLAG_KERNEL_EXCLUSIVE); } /* Get the directory */ Modified: trunk/reactos/ntoskrnl/ps/process.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -1483,7 +1483,9 @@ sizeof(OBJECT_ATTRIBUTES), sizeof(ULONG)); HasObjectName = (ObjectAttributes->ObjectName != NULL); - Attributes = ObjectAttributes->Attributes; + + /* Validate user attributes */ + Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -1496,7 +1498,9 @@ { /* Otherwise just get the data directly */ HasObjectName = (ObjectAttributes->ObjectName != NULL); - Attributes = ObjectAttributes->Attributes; + + /* Still have to sanitize attributes */ + Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode); } /* Can't pass both, fail */ Modified: trunk/reactos/ntoskrnl/ps/security.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/security.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ps/security.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/security.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -370,6 +370,9 @@ } _SEH2_END; } + + /* Validate object attributes */ + HandleAttributes = ObpValidateAttributes(HandleAttributes, PreviousMode); /* Open the process token */ Status = PsOpenTokenOfProcess(ProcessHandle, &Token); Modified: trunk/reactos/ntoskrnl/ps/thread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=6…
============================================================================== --- trunk/reactos/ntoskrnl/ps/thread.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/thread.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -1054,7 +1054,9 @@ sizeof(OBJECT_ATTRIBUTES), sizeof(ULONG)); HasObjectName = (ObjectAttributes->ObjectName != NULL); - Attributes = ObjectAttributes->Attributes; + + /* Validate user attributes */ + Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -1067,7 +1069,9 @@ { /* Otherwise just get the data directly */ HasObjectName = (ObjectAttributes->ObjectName != NULL); - Attributes = ObjectAttributes->Attributes; + + /* Still have to sanitize attributes */ + Attributes = ObpValidateAttributes(ObjectAttributes->Attributes, PreviousMode); } /* Can't pass both, fail */ Modified: trunk/reactos/ntoskrnl/se/token.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/token.c?rev=69…
============================================================================== --- trunk/reactos/ntoskrnl/se/token.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/se/token.c [iso-8859-1] Thu Sep 24 02:40:30 2015 @@ -2952,10 +2952,12 @@ _SEH2_END; } + /* Validate object attributes */ + HandleAttributes = ObpValidateAttributes(HandleAttributes, PreviousMode); + /* * At first open the thread token for information access and verify - * that the token associated with thread is valid. - */ + * that the token associated with thread is valid. */ Status = ObReferenceObjectByHandle(ThreadHandle, THREAD_QUERY_INFORMATION, PsThreadType, PreviousMode, (PVOID*)&Thread,
9 years, 3 months
1
0
0
0
[hbelusca] 69339: [NTVDM] - Fix ZF and CF flags setting in function INT 2Fh, AX=1214h. - Use CreateEventW explicitely. - Set the VdmTaskEvent event at startup. This allows user input by default (ev...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 24 00:27:59 2015 New Revision: 69339 URL:
http://svn.reactos.org/svn/reactos?rev=69339&view=rev
Log: [NTVDM] - Fix ZF and CF flags setting in function INT 2Fh, AX=1214h. - Use CreateEventW explicitely. - Set the VdmTaskEvent event at startup. This allows user input by default (even if we don't run our own DOS) in NTVDM. Fixes keyboard input not working when testing boot&usage of MSDOS 6. Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.c Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] Thu Sep 24 00:27:59 2015 @@ -1015,7 +1015,7 @@ sizeof(*DosStartProc32.ComSpecInfo)); ASSERT(DosStartProc32.ComSpecInfo); - DosStartProc32.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + DosStartProc32.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); ASSERT(DosStartProc32.hEvent); #endif Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Thu Sep 24 00:27:59 2015 @@ -2184,8 +2184,16 @@ PVOID PointerFromFarPointer2 = SEG_OFF_TO_PTR(getES(), getDI()); BOOLEAN AreEqual = (PointerFromFarPointer1 == PointerFromFarPointer2); - setZF(AreEqual); - setCF(!AreEqual); + if (AreEqual) + { + Stack[STACK_FLAGS] |= EMULATOR_FLAG_ZF; + Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF; + } + else + { + Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_ZF; + Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF; + } break; } Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emul…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] Thu Sep 24 00:27:59 2015 @@ -475,7 +475,7 @@ /**************** ATTACH INPUT WITH CONSOLE *****************/ /* Create the task event */ - VdmTaskEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + VdmTaskEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ASSERT(VdmTaskEvent != NULL); /* Start the input thread */ @@ -486,6 +486,7 @@ EmulatorCleanup(); return FALSE; } + ResumeEventThread(); /************************************************************/ /* Initialize the VGA */
9 years, 3 months
1
0
0
0
[hbelusca] 69338: Fix build.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Sep 23 23:55:04 2015 New Revision: 69338 URL:
http://svn.reactos.org/svn/reactos?rev=69338&view=rev
Log: Fix build. Modified: trunk/reactos/ntoskrnl/ke/bug.c Modified: trunk/reactos/ntoskrnl/ke/bug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=6933…
============================================================================== --- trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] Wed Sep 23 23:55:04 2015 @@ -1405,7 +1405,8 @@ KeDeregisterNmiCallback(IN PVOID Handle) { KIRQL OldIrql; - PKNMI_HANDLER_CALLBACK NmiData, Previous; + PKNMI_HANDLER_CALLBACK NmiData; + PKNMI_HANDLER_CALLBACK* Previous; ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); /* Find in the list the NMI callback corresponding to the handle */
9 years, 3 months
1
0
0
0
[hbelusca] 69337: [NTOS]: Implement KeDeregisterNmiCallback. Aside question: we have a "nmidebug" driver in \drivers\base\. In it is a NMI callback "NmiDbgCallback". I was wondering what "((void(*)...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Sep 23 23:52:03 2015 New Revision: 69337 URL:
http://svn.reactos.org/svn/reactos?rev=69337&view=rev
Log: [NTOS]: Implement KeDeregisterNmiCallback. Aside question: we have a "nmidebug" driver in \drivers\base\. In it is a NMI callback "NmiDbgCallback". I was wondering what "((void(*)())&KiBugCheckData[4])();" should do, according to the surrounding code, since in some conditions this code path is actually run:
http://i.imgur.com/TUsEr5p.jpg
Modified: trunk/reactos/ntoskrnl/ke/bug.c Modified: trunk/reactos/ntoskrnl/ke/bug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=6933…
============================================================================== --- trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/bug.c [iso-8859-1] Wed Sep 23 23:52:03 2015 @@ -28,8 +28,10 @@ ULONG KiHardwareTrigger; PUNICODE_STRING KiBugCheckDriver; ULONG_PTR KiBugCheckData[5]; -PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead; + +PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL; KSPIN_LOCK KiNmiCallbackListLock; +#define TAG_KNMI 'IMNK' /* Bugzilla Reporting */ UNICODE_STRING KeRosProcessorName, KeRosBiosDate, KeRosBiosVersion; @@ -1374,9 +1376,7 @@ ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); /* Allocate NMI callback data */ - NmiData = ExAllocatePoolWithTag(NonPagedPool, - sizeof(KNMI_HANDLER_CALLBACK), - 'IMNK'); + NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI); if (!NmiData) return NULL; /* Fill in the information */ @@ -1402,10 +1402,42 @@ */ NTSTATUS NTAPI -KeDeregisterNmiCallback(PVOID Handle) -{ - UNIMPLEMENTED; - return STATUS_UNSUCCESSFUL; +KeDeregisterNmiCallback(IN PVOID Handle) +{ + KIRQL OldIrql; + PKNMI_HANDLER_CALLBACK NmiData, Previous; + ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); + + /* Find in the list the NMI callback corresponding to the handle */ + KiAcquireNmiListLock(&OldIrql); + Previous = &KiNmiCallbackListHead; + NmiData = *Previous; + while (NmiData) + { + if (NmiData->Handle == Handle) + { + /* The handle is the pointer to the callback itself */ + ASSERT(Handle == NmiData); + + /* Found it, remove from the list */ + *Previous = NmiData->Next; + break; + } + + /* Not found; try again */ + Previous = &NmiData->Next; + NmiData = *Previous; + } + KiReleaseNmiListLock(OldIrql); + + /* If we have found the entry, free it */ + if (NmiData) + { + ExFreePoolWithTag(NmiData, TAG_KNMI); + return STATUS_SUCCESS; + } + + return STATUS_INVALID_HANDLE; } /*
9 years, 3 months
1
0
0
0
[pschweitzer] 69336: [KMTESTS:IO] - Properly free handles in driver (spotted by Thomas) - Remove dead code in driver (spotted by Thomas) - Send an IOCTL to stop on symlinks to allow more precise tests
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Sep 23 21:30:22 2015 New Revision: 69336 URL:
http://svn.reactos.org/svn/reactos?rev=69336&view=rev
Log: [KMTESTS:IO] - Properly free handles in driver (spotted by Thomas) - Remove dead code in driver (spotted by Thomas) - Send an IOCTL to stop on symlinks to allow more precise tests Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.h trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.h URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
============================================================================== --- trunk/rostests/kmtests/ntos_io/IoCreateFile.h [iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_io/IoCreateFile.h [iso-8859-1] Wed Sep 23 21:30:22 2015 @@ -8,7 +8,7 @@ #ifndef _KMTEST_IOCREATEFILE_H_ #define _KMTEST_IOCREATEFILE_H_ -#define IOCTL_CREATE_SYMLINK 1 -#define IOCTL_CREATE_NO_SYMLINK 2 +#define IOCTL_CALL_CREATE 1 +#define IOCTL_DISABLE_SYMLINK 2 #endif /* !defined _KMTEST_IOCREATEFILE_H_ */ Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
============================================================================== --- trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c [iso-8859-1] Wed Sep 23 21:30:22 2015 @@ -57,6 +57,8 @@ PAGED_CODE(); } +static volatile long gNoLinks = FALSE; + static NTSTATUS TestIrpHandler( @@ -80,7 +82,7 @@ if (IoStack->MajorFunction == IRP_MJ_CREATE) { ok((IoStack->Parameters.Create.Options & FILE_OPEN_REPARSE_POINT) == 0, "FILE_OPEN_REPARSE_POINT set\n"); - ok((IoStack->Flags == 0) || (IoStack->Flags == SL_STOP_ON_SYMLINK), "IoStack->Flags = %lx\n", IoStack->Flags); + ok((IoStack->Flags == 0 && !gNoLinks) || (IoStack->Flags == SL_STOP_ON_SYMLINK && gNoLinks), "IoStack->Flags = %lx\n", IoStack->Flags); if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR)) { @@ -155,17 +157,8 @@ Status = STATUS_SUCCESS; } - if (Status == STATUS_PENDING) - { - IoMarkIrpPending(Irp); - IoCompleteRequest(Irp, IO_NO_INCREMENT); - Status = STATUS_PENDING; - } - else - { - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); return Status; } @@ -176,8 +169,7 @@ static NTSTATUS TestIoCreateFile( - IN PUNICODE_STRING Path, - IN BOOLEAN NoLinks) + IN PUNICODE_STRING Path) { OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; @@ -203,7 +195,7 @@ 0, CreateFileTypeNone, NULL, - IO_NO_PARAMETER_CHECKING | (NoLinks ? IO_STOP_ON_SYMLINK : 0)); + IO_NO_PARAMETER_CHECKING | (gNoLinks ? IO_STOP_ON_SYMLINK : 0)); if (NT_SUCCESS(Status)) { NTSTATUS IntStatus; @@ -222,7 +214,9 @@ "Expected: %wZ or %wZ. Opened: %wZ\n", &FileObjectFileName, &DocumentsAndSettings, &FileObject->FileName); ObDereferenceObject(FileObject); } - NtClose(Handle); + + IntStatus = ObCloseHandle(Handle, KernelMode); + ok_eq_hex(IntStatus, STATUS_SUCCESS); } return Status; @@ -243,8 +237,16 @@ switch (ControlCode) { - case IOCTL_CREATE_SYMLINK: - case IOCTL_CREATE_NO_SYMLINK: + case IOCTL_DISABLE_SYMLINK: + { + if (InterlockedExchange(&gNoLinks, TRUE) == TRUE) + { + Status = STATUS_UNSUCCESSFUL; + } + + break; + } + case IOCTL_CALL_CREATE: { ANSI_STRING Path; UNICODE_STRING PathW; @@ -256,7 +258,7 @@ Status = RtlAnsiStringToUnicodeString(&PathW, &Path, TRUE); ok_eq_hex(Status, STATUS_SUCCESS); - Status = TestIoCreateFile(&PathW, (ControlCode == IOCTL_CREATE_NO_SYMLINK)); + Status = TestIoCreateFile(&PathW); RtlFreeUnicodeString(&PathW); Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
============================================================================== --- trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c [iso-8859-1] Wed Sep 23 21:30:22 2015 @@ -21,18 +21,21 @@ KmtLoadDriver(L"IoCreateFile", FALSE); KmtOpenDriver(); - Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, NonSymlinkedFileName); + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, NonSymlinkedFileName); ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error); - Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, SymlinkedFileName); + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, SymlinkedFileName); ok(Error == ERROR_CANT_ACCESS_FILE, "Expected ERROR_CANT_ACCESS_FILE, got %lx\n", Error); /* FIXME */ - Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, MountedPointFileName); + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, MountedPointFileName); ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error); - Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, NonSymlinkedFileName); + Error = KmtSendToDriver(IOCTL_DISABLE_SYMLINK); ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error); - Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, SymlinkedFileName); + + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, NonSymlinkedFileName); + ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error); + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, SymlinkedFileName); ok(Error == ERROR_MR_MID_NOT_FOUND, "Expected ERROR_MR_MID_NOT_FOUND, got %lx\n", Error); - Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, MountedPointFileName); + Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, MountedPointFileName); ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error); KmtCloseDriver();
9 years, 3 months
1
0
0
0
[gedmurphy] 69335: [DEVMGR] List devices without names as 'Unknown Device'
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Wed Sep 23 21:24:06 2015 New Revision: 69335 URL:
http://svn.reactos.org/svn/reactos?rev=69335&view=rev
Log: [DEVMGR] List devices without names as 'Unknown Device' Modified: trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp trunk/reactos/dll/win32/devmgr_new/stdafx.h Modified: trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/CMake…
============================================================================== --- trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt [iso-8859-1] Wed Sep 23 21:24:06 2015 @@ -5,8 +5,8 @@ include_directories( ${REACTOS_SOURCE_DIR}/include/reactos/dll - ${REACTOS_SOURCE_DIR}/lib/atl - includes) + ${REACTOS_SOURCE_DIR}/lib/atl + includes) list(APPEND SOURCE stdafx.h Modified: trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/devmg…
============================================================================== --- trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp [iso-8859-1] Wed Sep 23 21:24:06 2015 @@ -116,6 +116,7 @@ &m_ClassGuid, &m_ClassImage); + // Get the description for the device ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst, @@ -136,11 +137,11 @@ } - // Cleanup if something failed if (cr != CR_SUCCESS) { - Cleanup(); - return false; + CAtlStringW str; + if (str.LoadStringW(g_hThisInstance, IDS_UNKNOWNDEVICE)) + StringCchCopyW(m_DisplayName, MAX_PATH, str.GetBuffer()); } return true; Modified: trunk/reactos/dll/win32/devmgr_new/stdafx.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/stdaf…
============================================================================== --- trunk/reactos/dll/win32/devmgr_new/stdafx.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr_new/stdafx.h [iso-8859-1] Wed Sep 23 21:24:06 2015 @@ -24,6 +24,8 @@ #define ERR printf #define FIXME printf +#define UNIMPLEMENTED +#define WINE_DEFAULT_DEBUG_CHANNEL(t) DWORD WINAPI pSetupGuidFromString(PCWSTR pString, LPGUID lpGUID);
9 years, 3 months
1
0
0
0
[gedmurphy] 69334: [DEVMGMT] - Fix devmgmt.exe to correctly build and link against devmgr.dll - This is a temp exe that just calls DeviceManager_ExecuteW. This will later be replaced by mmc.exe and...
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Wed Sep 23 20:30:32 2015 New Revision: 69334 URL:
http://svn.reactos.org/svn/reactos?rev=69334&view=rev
Log: [DEVMGMT] - Fix devmgmt.exe to correctly build and link against devmgr.dll - This is a temp exe that just calls DeviceManager_ExecuteW. This will later be replaced by mmc.exe and devmgmt.msc Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt [iso-8859-1] Wed Sep 23 20:30:32 2015 @@ -1,3 +1,7 @@ + +set_cpp(WITH_RTTI WITH_RUNTIME) + +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/dll) list(APPEND SOURCE devmgmt.cpp) Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp [iso-8859-1] Wed Sep 23 20:30:32 2015 @@ -1,7 +1,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <cfgmgr32.h> -#include <dll\devmgr\devmgr.h> +#include <devmgr\devmgr.h> int WINAPI wWinMain(HINSTANCE hThisInstance, @@ -16,6 +16,5 @@ { return GetLastError(); } - return 0; } Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== Binary files - no diff available.
9 years, 3 months
1
0
0
0
[gedmurphy] 69333: [ATL] Try to fix gcc build (without having a local install of gcc...)
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Wed Sep 23 20:12:44 2015 New Revision: 69333 URL:
http://svn.reactos.org/svn/reactos?rev=69333&view=rev
Log: [ATL] Try to fix gcc build (without having a local install of gcc...) Modified: trunk/reactos/lib/atl/atlcore.h Modified: trunk/reactos/lib/atl/atlcore.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlcore.h?rev=6933…
============================================================================== --- trunk/reactos/lib/atl/atlcore.h [iso-8859-1] (original) +++ trunk/reactos/lib/atl/atlcore.h [iso-8859-1] Wed Sep 23 20:12:44 2015 @@ -219,15 +219,18 @@ /// // String Resource helper functions // - +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4200) +#endif struct ATLSTRINGRESOURCEIMAGE { WORD nLength; WCHAR achString[]; }; +#ifdef _MSC_VER #pragma warning(pop) +#endif inline const ATLSTRINGRESOURCEIMAGE* _AtlGetStringResourceImage( _In_ HINSTANCE hInstance,
9 years, 3 months
1
0
0
0
[gedmurphy] 69332: [ATL] - Add support for CAtlString and all its supporting base classes. - It doesn't do much more than assign wchat_t arrarys and call LoadString, but it's a full base to start a...
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Wed Sep 23 20:05:31 2015 New Revision: 69332 URL:
http://svn.reactos.org/svn/reactos?rev=69332&view=rev
Log: [ATL] - Add support for CAtlString and all its supporting base classes. - It doesn't do much more than assign wchat_t arrarys and call LoadString, but it's a full base to start adding more methods as people decide to. Modified: trunk/reactos/lib/atl/atlcore.h trunk/reactos/lib/atl/atlsimpstr.h trunk/reactos/lib/atl/atlstr.h trunk/reactos/lib/atl/cstringt.h Modified: trunk/reactos/lib/atl/atlcore.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlcore.h?rev=6933…
============================================================================== --- trunk/reactos/lib/atl/atlcore.h [iso-8859-1] (original) +++ trunk/reactos/lib/atl/atlcore.h [iso-8859-1] Wed Sep 23 20:05:31 2015 @@ -204,8 +204,99 @@ { return m_hInstResource; } + + HINSTANCE SetResourceInstance(HINSTANCE hInst) + { + return static_cast< HINSTANCE >(InterlockedExchangePointer((void**)&m_hInstResource, hInst)); + } + + HINSTANCE GetHInstanceAt(int i); }; extern CAtlBaseModule _AtlBaseModule; + +/// +// String Resource helper functions +// + +#pragma warning(push) +#pragma warning(disable: 4200) +struct ATLSTRINGRESOURCEIMAGE +{ + WORD nLength; + WCHAR achString[]; +}; +#pragma warning(pop) + +inline const ATLSTRINGRESOURCEIMAGE* _AtlGetStringResourceImage( + _In_ HINSTANCE hInstance, + _In_ HRSRC hResource, + _In_ UINT id) +{ + const ATLSTRINGRESOURCEIMAGE* pImage; + const ATLSTRINGRESOURCEIMAGE* pImageEnd; + ULONG nResourceSize; + HGLOBAL hGlobal; + UINT iIndex; + + hGlobal = ::LoadResource(hInstance, hResource); + if (hGlobal == NULL) return NULL; + + pImage = (const ATLSTRINGRESOURCEIMAGE*)::LockResource(hGlobal); + if (pImage == NULL) return NULL; + + nResourceSize = ::SizeofResource(hInstance, hResource); + pImageEnd = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE(pImage) + nResourceSize); + iIndex = id & 0x000f; + + while ((iIndex > 0) && (pImage < pImageEnd)) + { + pImage = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE(pImage) + (sizeof(ATLSTRINGRESOURCEIMAGE) + (pImage->nLength * sizeof(WCHAR)))); + iIndex--; + } + + if (pImage >= pImageEnd) return NULL; + if (pImage->nLength == 0) return NULL; + + return pImage; +} + +inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( + _In_ HINSTANCE hInstance, + _In_ UINT id) throw() +{ + HRSRC hResource; + hResource = ::FindResourceW(hInstance, MAKEINTRESOURCEW((((id >> 4) + 1) & static_cast<WORD>(~0))), (LPWSTR)RT_STRING); + if (hResource == NULL) return NULL; + return _AtlGetStringResourceImage(hInstance, hResource, id); +} + +inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( + _In_ HINSTANCE hInstance, + _In_ UINT id, + _In_ WORD wLanguage) +{ + HRSRC hResource; + hResource = ::FindResourceExW(hInstance, (LPWSTR)RT_STRING, MAKEINTRESOURCEW((((id >> 4) + 1) & static_cast<WORD>(~0))), wLanguage); + if (hResource == NULL) return NULL; + return _AtlGetStringResourceImage(hInstance, hResource, id); +} + +inline HINSTANCE AtlFindStringResourceInstance( + UINT nID, + WORD wLanguage = 0) +{ + const ATLSTRINGRESOURCEIMAGE* strRes = NULL; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + + for (int i = 1; hInst != NULL && strRes == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + strRes = AtlGetStringResourceImage(hInst, nID, wLanguage); + if (strRes != NULL) return hInst; + } + + return NULL; +} + }; // namespace ATL Modified: trunk/reactos/lib/atl/atlsimpstr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlsimpstr.h?rev=6…
============================================================================== --- trunk/reactos/lib/atl/atlsimpstr.h [iso-8859-1] (original) +++ trunk/reactos/lib/atl/atlsimpstr.h [iso-8859-1] Wed Sep 23 20:05:31 2015 @@ -8,125 +8,388 @@ namespace ATL { - struct CStringData; - - __interface IAtlStringMgr - { - public: - - _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) - CStringData* Allocate( - _In_ int nAllocLength, - _In_ int nCharSize) throw(); - - void Free(_Inout_ CStringData* pData) throw(); - - virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) - CStringData* Reallocate( - _Inout_ CStringData* pData, - _In_ int nAllocLength, - _In_ int nCharSize) throw(); - - CStringData* GetNilString() throw(); - - IAtlStringMgr* Clone() throw(); - }; - - struct CStringData - { - IAtlStringMgr* pStringMgr; - int nDataLength; - int nAllocLength; - long nRefs; - - void* data() throw() - { - return (this + 1); - } - - void AddRef() throw() - { - ATLASSERT(nRefs > 0); - _InterlockedIncrement(&nRefs); - } - - void Release() throw() - { - ATLASSERT(nRefs != 0); - - if (_InterlockedDecrement(&nRefs) <= 0) - { - pStringMgr->Free(this); - } - } - }; - - template< typename BaseType = char > - class ChTraitsBase - { - public: - typedef char XCHAR; - typedef LPSTR PXSTR; - typedef LPCSTR PCXSTR; - typedef wchar_t YCHAR; - typedef LPWSTR PYSTR; - typedef LPCWSTR PCYSTR; - }; - - template<> - class ChTraitsBase< wchar_t > - { - public: - typedef wchar_t XCHAR; - typedef LPWSTR PXSTR; - typedef LPCWSTR PCXSTR; - typedef char YCHAR; - typedef LPSTR PYSTR; - typedef LPCSTR PCYSTR; - }; - - - - template< typename BaseType, bool t_bMFCDLL = false> - class CSimpleStringT - { - public: - typedef typename ChTraitsBase<BaseType>::XCHAR XCHAR; - typedef typename ChTraitsBase<BaseType>::PXSTR PXSTR; - typedef typename ChTraitsBase<BaseType>::PCXSTR PCXSTR; - typedef typename ChTraitsBase<BaseType>::YCHAR YCHAR; - typedef typename ChTraitsBase<BaseType>::PYSTR PYSTR; - typedef typename ChTraitsBase<BaseType>::PCYSTR PCYSTR; - - public: - explicit CSimpleStringT(_Inout_ IAtlStringMgr* pStringMgr) - { - ATLENSURE(pStringMgr != NULL); - CStringData* pData = pStringMgr->GetNilString(); - Attach(pData); - } - - CSimpleStringT(_In_ const CSimpleStringT& strSrc) - { - CStringData* pSrcData = strSrc.GetData(); - CStringData* pNewData = CloneData(pSrcData); +struct CStringData; + +__interface IAtlStringMgr +{ +public: + + _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) + CStringData* Allocate( + _In_ int nAllocLength, + _In_ int nCharSize + ); + + void Free( + _Inout_ CStringData* pData + ); + + virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) + CStringData* Reallocate( + _Inout_ CStringData* pData, + _In_ int nAllocLength, + _In_ int nCharSize + ); + + CStringData* GetNilString(void); + IAtlStringMgr* Clone(void); +}; + + +struct CStringData +{ + IAtlStringMgr* pStringMgr; + int nAllocLength; + int nDataLength; + long nRefs; + + void* data() throw() + { + return (this + 1); + } + + void AddRef() throw() + { + ATLASSERT(nRefs > 0); + _InterlockedIncrement(&nRefs); + } + + void Release() throw() + { + ATLASSERT(nRefs != 0); + + if (_InterlockedDecrement(&nRefs) <= 0) + { + pStringMgr->Free(this); + } + } + + bool IsLocked() const throw() + { + return (nRefs < 0); + } + + bool IsShared() const throw() + { + return (nRefs > 1); + } +}; + +class CNilStringData : + public CStringData +{ +public: + CNilStringData() throw() + { + pStringMgr = NULL; + nRefs = 2; + nDataLength = 0; + nAllocLength = 0; + achNil[0] = 0; + achNil[1] = 0; + } + + void SetManager(_In_ IAtlStringMgr* pMgr) throw() + { + ATLASSERT(pStringMgr == NULL); + pStringMgr = pMgr; + } + +public: + wchar_t achNil[2]; +}; + +template< typename BaseType = char > +class ChTraitsBase +{ +public: + typedef char XCHAR; + typedef LPSTR PXSTR; + typedef LPCSTR PCXSTR; + typedef wchar_t YCHAR; + typedef LPWSTR PYSTR; + typedef LPCWSTR PCYSTR; +}; + +template<> +class ChTraitsBase< wchar_t > +{ +public: + typedef wchar_t XCHAR; + typedef LPWSTR PXSTR; + typedef LPCWSTR PCXSTR; + typedef char YCHAR; + typedef LPSTR PYSTR; + typedef LPCSTR PCYSTR; +}; + + + +template< typename BaseType, bool t_bMFCDLL = false> +class CSimpleStringT +{ +private: + LPWSTR m_pszData; + +public: + typedef typename ChTraitsBase<BaseType>::XCHAR XCHAR; + typedef typename ChTraitsBase<BaseType>::PXSTR PXSTR; + typedef typename ChTraitsBase<BaseType>::PCXSTR PCXSTR; + typedef typename ChTraitsBase<BaseType>::YCHAR YCHAR; + typedef typename ChTraitsBase<BaseType>::PYSTR PYSTR; + typedef typename ChTraitsBase<BaseType>::PCYSTR PCYSTR; + +public: + explicit CSimpleStringT(_Inout_ IAtlStringMgr* pStringMgr) + { + CStringData* pData = pStringMgr->GetNilString(); + Attach(pData); + } + + CSimpleStringT(_In_ const CSimpleStringT& strSrc) + { + CStringData* pSrcData = strSrc.GetData(); + CStringData* pNewData = CloneData(pSrcData); + Attach(pNewData); + } + + CSimpleStringT(_In_ const CSimpleStringT<BaseType, !t_bMFCDLL>& strSrc) + { + CStringData* pSrcData = strSrc.GetData(); + CStringData* pNewData = CloneData(pSrcData); + Attach(pNewData); + } + + CSimpleStringT& operator=(_In_opt_z_ PCXSTR pszSrc) + { + SetString(pszSrc); + return *this; + } + + + operator PCXSTR() const throw() + { + return m_pszData; + } + + + void Empty() throw() + { + CStringData* pOldData = GetData(); + IAtlStringMgr* pStringMgr = pOldData->pStringMgr; + if (pOldData->nDataLength == 0) return; + + if (pOldData->IsLocked()) + { + SetLength(0); + } + else + { + pOldData->Release(); + CStringData* pNewData = pStringMgr->GetNilString(); Attach(pNewData); } - - CSimpleStringT(_In_ const CSimpleStringT<BaseType, !t_bMFCDLL>& strSrc) - { - CStringData* pSrcData = strSrc.GetData(); - CStringData* pNewData = CloneData(pSrcData); - Attach(pNewData); - } - - - operator PCXSTR() const throw() - { - return m_pszData; - } - - }; + } + + void SetString(_In_opt_z_ PCXSTR pszSrc) + { + SetString(pszSrc, StringLength(pszSrc)); + } + + void SetString(_In_reads_opt_(nLength) PCXSTR pszSrc, + _In_ int nLength) + { + if (nLength == 0) + { + Empty(); + } + else + { + UINT nOldLength = GetLength(); + UINT_PTR nOffset = pszSrc - GetString(); + + PXSTR pszBuffer = GetBuffer(nLength); + if (nOffset <= nOldLength) + { + CopyCharsOverlapped(pszBuffer, GetAllocLength(), + pszBuffer + nOffset, nLength); + } + else + { + CopyChars(pszBuffer, GetAllocLength(), pszSrc, nLength); + } + ReleaseBufferSetLength(nLength); + } + } + + static int __cdecl StringLength(_In_opt_z_ const wchar_t* psz) throw() + { + if (psz == NULL) return 0; + return (int)wcslen(psz); + } + + PXSTR GetBuffer() + { + CStringData* pData = GetData(); + if (pData->IsShared()) + { + // We should fork here + Fork(pData->nDataLength); + } + + return m_pszData; + } + + int GetAllocLength() const throw() + { + return GetData()->nAllocLength; + } + + int GetLength() const throw() + { + return GetData()->nDataLength; + } + + PCXSTR GetString() const throw() + { + return m_pszData; + } + + void ReleaseBufferSetLength(_In_ int nNewLength) + { + ATLASSERT(nNewLength >= 0); + SetLength(nNewLength); + } + + bool IsEmpty() const throw() + { + return (GetLength() == 0); + } + + _Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength) + { + return PrepareWrite(nMinBufferLength); + } + + CStringData* GetData() const throw() + { + return reinterpret_cast<CStringData*>(m_pszData) - 1; + } + + static void __cdecl CopyChars( + _Out_writes_to_(nDestLen, nChars) XCHAR* pchDest, + _In_ size_t nDestLen, + _In_reads_opt_(nChars) const XCHAR* pchSrc, + _In_ int nChars) throw() + { + memcpy(pchDest, pchSrc, nChars * sizeof(XCHAR)); + } + + static void __cdecl CopyCharsOverlapped( + _Out_writes_to_(nDestLen, nDestLen) XCHAR* pchDest, + _In_ size_t nDestLen, + _In_reads_(nChars) const XCHAR* pchSrc, + _In_ int nChars) throw() + { + memmove(pchDest, pchSrc, nChars * sizeof(XCHAR)); + } + + +private: + + void Attach(_Inout_ CStringData* pData) throw() + { + m_pszData = static_cast<PXSTR>(pData->data()); + } + __declspec(noinline) void Fork(_In_ int nLength) + { + CStringData* pOldData = GetData(); + int nOldLength = pOldData->nDataLength; + CStringData* pNewData = pOldData->pStringMgr->Clone()->Allocate(nLength, sizeof(XCHAR)); + if (pNewData == NULL) + { + throw; // ThrowMemoryException(); + } + int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1; + CopyChars(PXSTR(pNewData->data()), nCharsToCopy, + PCXSTR(pOldData->data()), nCharsToCopy); + pNewData->nDataLength = nOldLength; + pOldData->Release(); + Attach(pNewData); + } + + + PXSTR PrepareWrite(_In_ int nLength) + { + CStringData* pOldData = GetData(); + int nShared = 1 - pOldData->nRefs; + int nTooShort = pOldData->nAllocLength - nLength; + if ((nShared | nTooShort) < 0) + { + PrepareWrite2(nLength); + } + + return m_pszData; + } + void PrepareWrite2(_In_ int nLength) + { + CStringData* pOldData = GetData(); + if (pOldData->nDataLength > nLength) + { + nLength = pOldData->nDataLength; + } + if (pOldData->IsShared()) + { + Fork(nLength); + ATLASSERT(FALSE); + } + else if (pOldData->nAllocLength < nLength) + { + int nNewLength = pOldData->nAllocLength; + if (nNewLength > 1024 * 1024 * 1024) + { + nNewLength += 1024 * 1024; + } + else + { + nNewLength = nNewLength + nNewLength / 2; + } + if (nNewLength < nLength) + { + nNewLength = nLength; + } + Reallocate(nNewLength); + } + } + + void Reallocate(_In_ int nLength) + { + CStringData* pOldData = GetData(); + ATLASSERT(pOldData->nAllocLength < nLength); + IAtlStringMgr* pStringMgr = pOldData->pStringMgr; + if (pOldData->nAllocLength >= nLength || nLength <= 0) + { + return; + } + CStringData* pNewData = pStringMgr->Reallocate(pOldData, nLength, sizeof(XCHAR)); + if (pNewData == NULL) throw; + + Attach(pNewData); + } + + void SetLength(_In_ int nLength) + { + ATLASSERT(nLength >= 0); + ATLASSERT(nLength <= GetData()->nAllocLength); + + if (nLength < 0 || nLength > GetData()->nAllocLength) + throw; + + GetData()->nDataLength = nLength; + m_pszData[nLength] = 0; + } + +}; } #endif Modified: trunk/reactos/lib/atl/atlstr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlstr.h?rev=69332…
============================================================================== --- trunk/reactos/lib/atl/atlstr.h [iso-8859-1] (original) +++ trunk/reactos/lib/atl/atlstr.h [iso-8859-1] Wed Sep 23 20:05:31 2015 @@ -2,42 +2,128 @@ #define __ATLSTR_H__ #pragma once - -#ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) -#endif - #include <atlbase.h> #include <cstringt.h> namespace ATL { - template< typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>> - class StrTraitATL : - public StringIterator + +class CAtlStringMgr : public IAtlStringMgr +{ +protected: + IAtlMemMgr* m_MemMgr; + CNilStringData m_NilStrData; + +public: + CAtlStringMgr(_In_opt_ IAtlMemMgr* MemMgr = NULL): + m_MemMgr(MemMgr) { - public: - static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() - { - return(AtlFindStringResourceInstance(nID)); - } + m_NilStrData.SetManager(this); + } - static IAtlStringMgr* GetDefaultManager() throw() - { - return CAtlStringMgr::GetInstance(); - } - }; + virtual ~CAtlStringMgr(void) + { + } + + static IAtlStringMgr* GetInstance(void) + { + static CWin32Heap Win32Heap(::GetProcessHeap()); + static CAtlStringMgr StringMgr(&Win32Heap); + return &StringMgr; + } + + virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + NumChars * CharSize) CStringData* Allocate( + _In_ int NumChars, + _In_ int CharSize) + { + size_t SizeBytes; + CStringData* StrData; + + SizeBytes = sizeof(CStringData) + ((NumChars + 1) * CharSize); + + StrData = static_cast<CStringData*>(m_MemMgr->Allocate(SizeBytes)); + if (StrData == NULL) return NULL; + + StrData->pStringMgr = this; + StrData->nRefs = 1; + StrData->nAllocLength = NumChars; + StrData->nDataLength = 0; + + return StrData; + } + + virtual void Free(_In_ CStringData* StrData) + { + ATLASSERT(StrData->pStringMgr == this); + m_MemMgr->Free(StrData); + } + + virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nChars*nCharSize) CStringData* Reallocate( + _Inout_ _Post_readable_byte_size_(sizeof(CStringData)) CStringData* StrData, + _In_ int nChars, + _In_ int nCharSize) throw() + { + ATLASSERT(StrData->pStringMgr == this); + + CStringData* pNewData; + ULONG SizeBytes; + ULONG nDataBytes; + + nChars++; + nDataBytes = nChars * nCharSize; + SizeBytes = sizeof(CStringData) + nDataBytes; + + pNewData = static_cast< CStringData* >(m_MemMgr->Reallocate(StrData, SizeBytes)); + if (pNewData == NULL) return NULL; + + pNewData->nAllocLength = nChars - 1; + return pNewData; + } + virtual CStringData* GetNilString() throw() + { + m_NilStrData.AddRef(); + return &m_NilStrData; + } + virtual IAtlStringMgr* Clone() throw() + { + return this; + } + +private: + static bool StaticInitialize() + { + GetInstance(); + return true; + } +}; - template< typename _CharType = wchar_t> - class ChTraitsOS : - public ChTraitsBase<_CharType> +template<typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>> +class StrTraitATL : + public StringIterator +{ +public: + static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() { - protected: + return AtlFindStringResourceInstance(nID); + } - public: + static IAtlStringMgr* GetDefaultManager() throw() + { + return CAtlStringMgr::GetInstance(); + } +}; - }; + +template< typename _CharType = wchar_t> +class ChTraitsOS : + public ChTraitsBase<_CharType> +{ +protected: + +public: + +}; #ifndef _ATL_CSTRING_NO_CRT typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW; Modified: trunk/reactos/lib/atl/cstringt.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/cstringt.h?rev=693…
============================================================================== --- trunk/reactos/lib/atl/cstringt.h [iso-8859-1] (original) +++ trunk/reactos/lib/atl/cstringt.h [iso-8859-1] Wed Sep 23 20:05:31 2015 @@ -2,75 +2,122 @@ #define __CSTRINGT_H__ #pragma once - #include <atlsimpstr.h> #include <stddef.h> - #include <stdio.h> #include <wchar.h> - +#include <atlmem.h> namespace ATL { - template< typename _CharType = wchar_t> - class ChTraitsCRT : - public ChTraitsBase<_CharType> +inline UINT WINAPI _AtlGetConversionACP() throw() +{ +#ifdef _CONVERSION_DONT_USE_THREAD_LOCALE + return CP_ACP; +#else + return CP_THREAD_ACP; +#endif +} + + +template<typename _CharType = wchar_t> +class ChTraitsCRT : public ChTraitsBase<_CharType> +{ +public: + + static int __cdecl GetBaseTypeLength(_In_z_ LPCWSTR pszSource) throw() { - public: + return ::WideCharToMultiByte(_AtlGetConversionACP(), 0, pszSource, -1, NULL, 0, NULL, NULL) - 1; + } - }; + static int __cdecl GetBaseTypeLength( + _In_reads_(nLength) LPCWSTR pszSource, + _In_ int nLength) throw() + { + return ::WideCharToMultiByte(CP_THREAD_ACP, 0, pszSource, nLength, NULL, 0, NULL, NULL); + } + + static void __cdecl ConvertToBaseType( + _Out_writes_(nDestLength) LPWSTR pszDest, + _In_ int nDestLength, + _In_ LPCWSTR pszSrc, + _In_ int nSrcLength = -1) + { + if (nSrcLength == -1) + nSrcLength = 1 + GetBaseTypeLength(pszSrc); + + wmemcpy(pszDest, pszSrc, nSrcLength); + } +}; - namespace _CSTRING_IMPL_ +namespace _CSTRING_IMPL_ +{ + template <typename _CharType, class StringTraits> + struct _MFCDLLTraitsCheck { - template <typename _CharType, class StringTraits> - struct _MFCDLLTraitsCheck - { - const static bool c_bIsMFCDLLTraits = false; - }; + const static bool c_bIsMFCDLLTraits = false; + }; +} + + +template <typename BaseType, class StringTraits> +class CStringT : + public CSimpleStringT <BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> +{ +public: + typedef CSimpleStringT<BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> CThisSimpleString; + typedef StringTraits StrTraits; + typedef typename CThisSimpleString::XCHAR XCHAR; + typedef typename CThisSimpleString::PXSTR PXSTR; + typedef typename CThisSimpleString::PCXSTR PCXSTR; + typedef typename CThisSimpleString::YCHAR YCHAR; + typedef typename CThisSimpleString::PYSTR PYSTR; + typedef typename CThisSimpleString::PCYSTR PCYSTR; + +public: + CStringT() throw() : + CThisSimpleString(StringTraits::GetDefaultManager()) + { } - template< typename BaseType, class StringTraits> - class CStringT : - public CSimpleStringT <BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> + explicit CStringT( _In_ IAtlStringMgr* pStringMgr) throw() : + CThisSimpleString(pStringMgr) { - public: - typedef CSimpleStringT<BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> CThisSimpleString; - typedef StringTraits StrTraits; - typedef typename CThisSimpleString::XCHAR XCHAR; - typedef typename CThisSimpleString::PXSTR PXSTR; - typedef typename CThisSimpleString::PCXSTR PCXSTR; - typedef typename CThisSimpleString::YCHAR YCHAR; - typedef typename CThisSimpleString::PYSTR PYSTR; - typedef typename CThisSimpleString::PCYSTR PCYSTR; + } - public: - CStringT() throw() : - CThisSimpleString(StringTraits::GetDefaultManager()) - { - } - explicit CStringT( _In_ IAtlStringMgr* pStringMgr) throw() : - CThisSimpleString(pStringMgr) - { - } + static void __cdecl Construct(_In_ CStringT* pString) + { + new pString (CStringT); + } - CStringT(_In_ const VARIANT& varSrc); - CStringT( - _In_ const VARIANT& varSrc, - _In_ IAtlStringMgr* pStringMgr); + CStringT(_In_ const CStringT& strSrc) : + CThisSimpleString(strSrc) + { + } - static void __cdecl Construct(_In_ CStringT* pString) - { - new(pString)CStringT; - } + CStringT& operator=(_In_opt_z_ PCXSTR pszSrc) + { + CThisSimpleString::operator=(pszSrc); + return *this; + } - CStringT(_In_ const CStringT& strSrc) : - CThisSimpleString(strSrc) - { - } - }; + _Check_return_ BOOL LoadString(_In_ HINSTANCE hInstance, + _In_ UINT nID) + { + const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage(hInstance, nID); + if (pImage == NULL) return FALSE; + + int nLength = StringTraits::GetBaseTypeLength(pImage->achString, pImage->nLength); + PXSTR pszBuffer = GetBuffer(nLength); + StringTraits::ConvertToBaseType(pszBuffer, nLength, pImage->achString, pImage->nLength); + ReleaseBufferSetLength(nLength); + + return TRUE; + } +}; } //namespace ATL
9 years, 3 months
1
0
0
0
[tfaber] 69331: [NTDLL_APITEST] - Fix a test failure on WHS-Testbot
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Sep 23 15:53:24 2015 New Revision: 69331 URL:
http://svn.reactos.org/svn/reactos?rev=69331&view=rev
Log: [NTDLL_APITEST] - Fix a test failure on WHS-Testbot Modified: trunk/rostests/apitests/ntdll/NtOpenThreadToken.c Modified: trunk/rostests/apitests/ntdll/NtOpenThreadToken.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtOpenThre…
============================================================================== --- trunk/rostests/apitests/ntdll/NtOpenThreadToken.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/NtOpenThreadToken.c [iso-8859-1] Wed Sep 23 15:53:24 2015 @@ -25,7 +25,8 @@ TRUE, &TokenHandle); ok(Status == STATUS_NO_TOKEN, "Status = %lx\n", Status); - ok(TokenHandle == NULL, "TokenHandle = %p\n", TokenHandle); + ok(TokenHandle == (HANDLE)0x55555555 /* 2003 */ || + TokenHandle == NULL /* Win7 */, "TokenHandle = %p\n", TokenHandle); Status = RtlImpersonateSelf(SecurityImpersonation); ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
9 years, 3 months
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
54
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
Results per page:
10
25
50
100
200