ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2006
----- 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
357 discussions
Start a n
N
ew thread
[weiden] 24583: Minor simplification
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 18:26:41 2006 New Revision: 24583 URL:
http://svn.reactos.org/svn/reactos?rev=24583&view=rev
Log: Minor simplification Modified: trunk/reactos/ntoskrnl/se/sd.c Modified: trunk/reactos/ntoskrnl/se/sd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/sd.c?rev=24583…
============================================================================== --- trunk/reactos/ntoskrnl/se/sd.c (original) +++ trunk/reactos/ntoskrnl/se/sd.c Fri Oct 20 18:26:41 2006 @@ -411,9 +411,8 @@ { /* first only probe and copy until the control field of the descriptor to determine whether it's a self-relative descriptor */ - DescriptorSize = (ULONG)((ULONG_PTR)&OriginalSecurityDescriptor->Control - - (ULONG_PTR)OriginalSecurityDescriptor) + - sizeof(OriginalSecurityDescriptor->Control); + DescriptorSize = FIELD_OFFSET(SECURITY_DESCRIPTOR, + Owner); ProbeForRead(OriginalSecurityDescriptor, DescriptorSize, sizeof(ULONG));
18 years, 2 months
1
0
0
0
[weiden] 24582: Prefer inline probing macros for base types
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 18:20:27 2006 New Revision: 24582 URL:
http://svn.reactos.org/svn/reactos?rev=24582&view=rev
Log: Prefer inline probing macros for base types Modified: trunk/reactos/ntoskrnl/se/sd.c Modified: trunk/reactos/ntoskrnl/se/sd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/sd.c?rev=24582…
============================================================================== --- trunk/reactos/ntoskrnl/se/sd.c (original) +++ trunk/reactos/ntoskrnl/se/sd.c Fri Oct 20 18:20:27 2006 @@ -541,10 +541,7 @@ /* securely access the buffers! */ \ _SEH_TRY \ { \ - ProbeForRead(&SidType->SubAuthorityCount, \ - sizeof(SidType->SubAuthorityCount), \ - 1); \ - SidType##SAC = SidType->SubAuthorityCount; \ + SidType##SAC = ProbeForReadUchar(&SidType->SubAuthorityCount); \ SidType##Size = RtlLengthRequiredSid(SidType##SAC); \ DescriptorSize += ROUND_UP(SidType##Size, sizeof(ULONG)); \ ProbeForRead(SidType, \ @@ -574,6 +571,8 @@ DetermineSIDSize(Owner); DetermineSIDSize(Group); +#undef DetermineSIDSize + /* determine the size of the ACLs */ #define DetermineACLSize(AclType, AclFlag) \ do { \ @@ -587,10 +586,7 @@ /* securely access the buffers! */ \ _SEH_TRY \ { \ - ProbeForRead(&AclType->AclSize, \ - sizeof(AclType->AclSize), \ - 1); \ - AclType##Size = AclType->AclSize; \ + AclType##Size = ProbeForReadUshort(&AclType->AclSize); \ DescriptorSize += ROUND_UP(AclType##Size, sizeof(ULONG)); \ ProbeForRead(AclType, \ AclType##Size, \ @@ -622,6 +618,8 @@ DetermineACLSize(Sacl, SACL); DetermineACLSize(Dacl, DACL); +#undef DetermineACLSize + /* allocate enough memory to store a complete copy of a self-relative security descriptor */ NewDescriptor = ExAllocatePool(PoolType, @@ -663,6 +661,8 @@ CopySID(Owner); CopySID(Group); +#undef CopySID + #define CopyACL(Type) \ do { \ if(DescriptorCopy.Type != NULL) \ @@ -683,6 +683,8 @@ CopyACL(Sacl); CopyACL(Dacl); + +#undef CopyACL } _SEH_HANDLE {
18 years, 2 months
1
0
0
0
[weiden] 24581: Fix integer overflow vulnerability in NtPrivilegeCheck
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 18:10:53 2006 New Revision: 24581 URL:
http://svn.reactos.org/svn/reactos?rev=24581&view=rev
Log: Fix integer overflow vulnerability in NtPrivilegeCheck Modified: trunk/reactos/ntoskrnl/se/priv.c Modified: trunk/reactos/ntoskrnl/se/priv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/priv.c?rev=245…
============================================================================== --- trunk/reactos/ntoskrnl/se/priv.c (original) +++ trunk/reactos/ntoskrnl/se/priv.c Fri Oct 20 18:10:53 2006 @@ -292,7 +292,7 @@ NTSTATUS STDCALL NtPrivilegeCheck (IN HANDLE ClientToken, IN PPRIVILEGE_SET RequiredPrivileges, - IN PBOOLEAN Result) + OUT PBOOLEAN Result) { PLUID_AND_ATTRIBUTES Privileges; PTOKEN Token; @@ -313,16 +313,26 @@ _SEH_TRY { ProbeForWrite(RequiredPrivileges, - sizeof(PRIVILEGE_SET), + FIELD_OFFSET(PRIVILEGE_SET, + Privilege), sizeof(ULONG)); PrivilegeCount = RequiredPrivileges->PrivilegeCount; PrivilegeControl = RequiredPrivileges->Control; + /* Check PrivilegeCount to avoid an integer overflow! */ + if (FIELD_OFFSET(PRIVILEGE_SET, + Privilege[PrivilegeCount]) / + sizeof(RequiredPrivileges->Privilege[0]) != PrivilegeCount) + { + Status = STATUS_INVALID_PARAMETER; + _SEH_LEAVE; + } + /* probe all of the array */ ProbeForWrite(RequiredPrivileges, - sizeof(FIELD_OFFSET(PRIVILEGE_SET, - Privilege[PrivilegeCount])), + FIELD_OFFSET(PRIVILEGE_SET, + Privilege[PrivilegeCount]), sizeof(ULONG)); ProbeForWriteBoolean(Result);
18 years, 2 months
1
0
0
0
[weiden] 24580: Fix returning the context of the current thread in NtGetContextThread
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 17:45:52 2006 New Revision: 24580 URL:
http://svn.reactos.org/svn/reactos?rev=24580&view=rev
Log: Fix returning the context of the current thread in NtGetContextThread Modified: trunk/reactos/ntoskrnl/ps/debug.c Modified: trunk/reactos/ntoskrnl/ps/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/debug.c?rev=24…
============================================================================== --- trunk/reactos/ntoskrnl/ps/debug.c (original) +++ trunk/reactos/ntoskrnl/ps/debug.c Fri Oct 20 17:45:52 2006 @@ -174,8 +174,7 @@ Size = sizeof(CONTEXT); /* Read the flags */ - ProbeForReadUlong(&ThreadContext->ContextFlags); - Flags = ThreadContext->ContextFlags; + Flags = ProbeForReadUlong(&ThreadContext->ContextFlags); /* Check if the caller wanted extended registers */ if ((Flags & CONTEXT_EXTENDED_REGISTERS) != @@ -256,10 +255,18 @@ FALSE, NULL); } - + } + + _SEH_TRY + { /* Copy the context */ - RtlMoveMemory(ThreadContext, &GetSetContext.Context, Size); - } + RtlCopyMemory(ThreadContext, &GetSetContext.Context, Size); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; /* Return status */ return Status; @@ -285,8 +292,7 @@ Size = sizeof(CONTEXT); /* Read the flags */ - ProbeForReadUlong(&ThreadContext->ContextFlags); - Flags = ThreadContext->ContextFlags; + Flags = ProbeForReadUlong(&ThreadContext->ContextFlags); /* Check if the caller wanted extended registers */ if ((Flags & CONTEXT_EXTENDED_REGISTERS) != @@ -304,7 +310,7 @@ } /* Copy the context */ - RtlMoveMemory(&GetSetContext.Context, ThreadContext, Size); + RtlCopyMemory(&GetSetContext.Context, ThreadContext, Size); } _SEH_HANDLE {
18 years, 2 months
1
0
0
0
[weiden] 24579: Use inline probing macro for handle variables
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 17:33:24 2006 New Revision: 24579 URL:
http://svn.reactos.org/svn/reactos?rev=24579&view=rev
Log: Use inline probing macro for handle variables Modified: trunk/reactos/ntoskrnl/dbgk/debug.c Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Fri Oct 20 17:33:24 2006 @@ -708,7 +708,7 @@ _SEH_TRY { /* Probe the handle */ - ProbeForWrite(DebugHandle, sizeof(HANDLE), sizeof(ULONG)); + ProbeForWriteHandle(DebugHandle); } _SEH_HANDLE {
18 years, 2 months
1
0
0
0
[weiden] 24578: - Some minor Nt stub fixes - Fix compilation with GCC4
by weiden@svn.reactos.org
Author: weiden Date: Fri Oct 20 17:19:13 2006 New Revision: 24578 URL:
http://svn.reactos.org/svn/reactos?rev=24578&view=rev
Log: - Some minor Nt stub fixes - Fix compilation with GCC4 Modified: trunk/reactos/include/ndk/rtltypes.h trunk/reactos/ntoskrnl/dbgk/debug.c trunk/reactos/ntoskrnl/ob/obhandle.c trunk/reactos/ntoskrnl/ob/oblife.c trunk/reactos/subsystems/win32/win32k/objects/dibobj.c Modified: trunk/reactos/include/ndk/rtltypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtltypes.h?rev…
============================================================================== --- trunk/reactos/include/ndk/rtltypes.h (original) +++ trunk/reactos/include/ndk/rtltypes.h Fri Oct 20 17:19:13 2006 @@ -471,6 +471,7 @@ // // Routines and callbacks for the RTL AVL/Generic Table package // +#if defined(NTOS_MODE_USER) || (!defined(NTOS_MODE_USER) && !defined(_NTIFS_)) typedef NTSTATUS (NTAPI *PRTL_AVL_MATCH_FUNCTION)( struct _RTL_AVL_TABLE *Table, @@ -515,6 +516,7 @@ struct _RTL_AVL_TABLE *Table, PVOID Buffer ); +#endif // // RTL Query Registry callback Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Fri Oct 20 17:19:13 2006 @@ -793,6 +793,7 @@ /* Probe the handle */ ProbeForRead(AppClientId, sizeof(CLIENT_ID), sizeof(ULONG)); ClientId = *AppClientId; + AppClientId = &ClientId; } _SEH_HANDLE { @@ -838,7 +839,7 @@ /* Compare process ID */ if (DebugEvent->ClientId.UniqueProcess == - ClientId.UniqueProcess) + AppClientId->UniqueProcess) { /* Check if we already found a match */ if (NeedsWake) @@ -853,7 +854,7 @@ /* Compare thread ID and flag */ if ((DebugEvent->ClientId.UniqueThread == - ClientId.UniqueThread) && (DebugEvent->Flags & 1)) + AppClientId->UniqueThread) && (DebugEvent->Flags & 1)) { /* Remove the event from the list */ RemoveEntryList(NextEntry); @@ -1034,7 +1035,19 @@ PreviousMode); /* Return required length to user-mode */ - if (ReturnLength) *ReturnLength = sizeof(*DebugInfo); + if (ReturnLength) + { + _SEH_TRY + { + ProbeForWriteUlong(ReturnLength); + *ReturnLength = sizeof(*DebugInfo); + } + _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } if (!NT_SUCCESS(Status)) return Status; /* Open the Object */ @@ -1096,13 +1109,18 @@ RtlZeroMemory(&WaitStateChange, sizeof(WaitStateChange)); /* Check if we came with a timeout from user mode */ - if ((Timeout) && (PreviousMode != KernelMode)) + if (PreviousMode != KernelMode) { _SEH_TRY { - /* Make a copy on the stack */ - SafeTimeOut = ProbeForReadLargeInteger(Timeout); - Timeout = &SafeTimeOut; + if (Timeout) + { + /* Make a copy on the stack */ + SafeTimeOut = ProbeForReadLargeInteger(Timeout); + Timeout = &SafeTimeOut; + } + + ProbeForWrite(StateChange, sizeof(*StateChange), sizeof(ULONG)); } _SEH_HANDLE { @@ -1114,12 +1132,6 @@ /* Query the current time */ KeQuerySystemTime(&StartTime); - } - - /* Check if the call is from user mode */ - if (PreviousMode == UserMode) - { - /* FIXME: Probe the state change structure */ } /* Get the debug object */ @@ -1268,9 +1280,18 @@ ObDereferenceObject(DebugObject); /* Return our wait state change structure */ - RtlMoveMemory(StateChange, - &WaitStateChange, - sizeof(DBGUI_WAIT_STATE_CHANGE)); + _SEH_TRY + { + RtlCopyMemory(StateChange, + &WaitStateChange, + sizeof(DBGUI_WAIT_STATE_CHANGE)); + } + _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + return Status; } 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 (original) +++ trunk/reactos/ntoskrnl/ob/obhandle.c Fri Oct 20 17:19:13 2006 @@ -147,7 +147,7 @@ ObpDeleteNameCheck(ObjectBody); /* Decrease the total number of handles for this type */ - InterlockedDecrement(&ObjectType->TotalNumberOfHandles); + InterlockedDecrement((PLONG)&ObjectType->TotalNumberOfHandles); OBTRACE(OB_HANDLE_DEBUG, "%s - Decremented count for: %p. HC LC %lx %lx\n", __FUNCTION__, @@ -388,7 +388,7 @@ } /* Increase total number of handles */ - InterlockedIncrement(&ObjectType->TotalNumberOfHandles); + InterlockedIncrement((PLONG)&ObjectType->TotalNumberOfHandles); OBTRACE(OB_HANDLE_DEBUG, "%s - Incremented count for: %p. Reason: %lx HC LC %lx %lx\n", __FUNCTION__, @@ -494,7 +494,7 @@ } /* Increase total number of handles */ - InterlockedIncrement(&ObjectType->TotalNumberOfHandles); + InterlockedIncrement((PLONG)&ObjectType->TotalNumberOfHandles); OBTRACE(OB_HANDLE_DEBUG, "%s - Incremented count for: %p. UNNAMED HC LC %lx %lx\n", __FUNCTION__, Modified: trunk/reactos/ntoskrnl/ob/oblife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblife.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/ob/oblife.c (original) +++ trunk/reactos/ntoskrnl/ob/oblife.c Fri Oct 20 17:19:13 2006 @@ -71,7 +71,7 @@ } /* Decrease the total */ - InterlockedDecrement(&ObjectType->TotalNumberOfObjects); + InterlockedDecrement((PLONG)&ObjectType->TotalNumberOfObjects); /* Check if we have create info */ if (Header->Flags & OB_FLAG_CREATE_INFO) Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c Fri Oct 20 17:19:13 2006 @@ -724,7 +724,7 @@ { if (data->bmiHeader.biSize == sizeof(BITMAPINFOHEADER)) { - RGBQUAD *rgb = data->bmiColors; + const RGBQUAD *rgb = data->bmiColors; DWORD col = RGB( rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue ); // Check if the first color of the colormap is black
18 years, 2 months
1
0
0
0
[ion] 24577: - Implement DbgkpConvertKernelToUserStateChange. I just remembered that there's actually 3 debug subsystems in NT: Win32, Native and Kernel, so this structure will still need to be heavily parsed at the Win32 level (in kernel32) before user-mode debuggers can work (so I'll have to write a small native-mode debugger test app to test this implementation first). - Implement DbgkpMarkProcessPeb.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 20 10:12:54 2006 New Revision: 24577 URL:
http://svn.reactos.org/svn/reactos?rev=24577&view=rev
Log: - Implement DbgkpConvertKernelToUserStateChange. I just remembered that there's actually 3 debug subsystems in NT: Win32, Native and Kernel, so this structure will still need to be heavily parsed at the Win32 level (in kernel32) before user-mode debuggers can work (so I'll have to write a small native-mode debugger test app to test this implementation first). - Implement DbgkpMarkProcessPeb. Modified: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c trunk/reactos/ntoskrnl/dbgk/debug.c Modified: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkutil.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/dbgkutil.c (original) +++ trunk/reactos/ntoskrnl/dbgk/dbgkutil.c Fri Oct 20 10:12:54 2006 @@ -1,13 +1,12 @@ /* - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/dbgk/dbgkutil.c * PURPOSE: User-Mode Debugging Support, Internal Debug Functions. - * - * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ -/* INCLUDES *****************************************************************/ +/* INCLUDES ******************************************************************/ #include <ntoskrnl.h> #define NDEBUG @@ -19,39 +18,7 @@ NTAPI DbgkCreateThread(PVOID StartAddress) { -#if 0 - LPC_DBG_MESSAGE Message; - LPC_DBG_MESSAGE Reply; - NTSTATUS Status; - - if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL) - { - return; - } - - Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE); - Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) - - sizeof(LPC_MESSAGE); - Message.Type = DBG_EVENT_CREATE_THREAD; - Message.Status = STATUS_SUCCESS; - Message.Data.CreateThread.Reserved = 0; - Message.Data.CreateThread.StartAddress = StartAddress; - - /* FIXME: Freeze all threads in process */ - - /* Send the message to the process's debug port and wait for a reply */ - Status = - LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort, - &Message, - &Reply); - if (!NT_SUCCESS(Status)) - { - return; - } - - /* FIXME: Examine reply */ - return; -#endif + /* FIXME */ } VOID Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Fri Oct 20 10:12:54 2006 @@ -1,10 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Kernel - * FILE: ntoskrnl/dbgk/debug.c + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/dbgk/dbgkobj.c * PURPOSE: User-Mode Debugging Support, Debug Object Management. - * - * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES ******************************************************************/ @@ -318,16 +317,144 @@ DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, IN PDEBUG_EVENT DebugEvent) { - /* FIXME: TODO */ - return; + /* Start by copying the client ID */ + WaitStateChange->AppClientId = DebugEvent->ClientId; + + /* Now check which kind of event this was */ + switch (DebugEvent->ApiMsg.ApiNumber) + { + /* New process */ + case DbgKmCreateProcessApi: + + /* Set the right native code */ + WaitStateChange->NewState = DbgCreateProcessStateChange; + + /* Copy the information */ + WaitStateChange->StateInfo.CreateProcessInfo.NewProcess = + DebugEvent->ApiMsg.CreateProcess; + + /* Clear the file handle for us */ + DebugEvent->ApiMsg.CreateProcess.FileHandle = NULL; + break; + + /* New thread */ + case DbgKmCreateThreadApi: + + /* Set the right native code */ + WaitStateChange->NewState = DbgCreateThreadStateChange; + + /* Copy information */ + WaitStateChange->StateInfo.CreateThread.NewThread.StartAddress = + DebugEvent->ApiMsg.CreateThread.StartAddress; + WaitStateChange->StateInfo.CreateThread.NewThread.SubSystemKey = + DebugEvent->ApiMsg.CreateThread.SubSystemKey; + break; + + /* Exception (or breakpoint/step) */ + case DbgKmExceptionApi: + + /* Look at the exception code */ + if (DebugEvent->ApiMsg.Exception.ExceptionRecord.ExceptionCode == + STATUS_BREAKPOINT) + { + /* Update this as a breakpoint exception */ + WaitStateChange->NewState = DbgBreakpointStateChange; + } + else if (DebugEvent->ApiMsg.Exception.ExceptionRecord.ExceptionCode == + STATUS_SINGLE_STEP) + { + /* Update this as a single step exception */ + WaitStateChange->NewState = DbgSingleStepStateChange; + } + else + { + /* Otherwise, set default exception */ + WaitStateChange->NewState = DbgExceptionStateChange; + } + + /* Copy the exception record */ + WaitStateChange->StateInfo.Exception.ExceptionRecord = + DebugEvent->ApiMsg.Exception.ExceptionRecord; + break; + + /* Process exited */ + case DbgKmExitProcessApi: + + /* Set the right native code and copy the exit code */ + WaitStateChange->NewState = DbgExitProcessStateChange; + WaitStateChange->StateInfo.ExitProcess.ExitStatus = + DebugEvent->ApiMsg.ExitProcess.ExitStatus; + break; + + /* Thread exited */ + case DbgKmExitThreadApi: + + /* Set the right native code */ + WaitStateChange->NewState = DbgExitThreadStateChange; + WaitStateChange->StateInfo.ExitThread.ExitStatus = + DebugEvent->ApiMsg.ExitThread.ExitStatus; + break; + + /* DLL Load */ + case DbgKmLoadDllApi: + + /* Set the native code */ + WaitStateChange->NewState = DbgLoadDllStateChange; + + /* Copy the data */ + WaitStateChange->StateInfo.LoadDll = DebugEvent->ApiMsg.LoadDll; + + /* Clear the file handle for us */ + DebugEvent->ApiMsg.LoadDll.FileHandle = NULL; + break; + + /* DLL Unload */ + case DbgKmUnloadDllApi: + + /* Set the native code and copy the address */ + WaitStateChange->NewState = DbgUnloadDllStateChange; + WaitStateChange->StateInfo.UnloadDll.BaseAddress = + DebugEvent->ApiMsg.UnloadDll.BaseAddress; + break; + + default: + + /* Shouldn't happen */ + ASSERT(FALSE); + } } VOID NTAPI DbgkpMarkProcessPeb(IN PEPROCESS Process) { - /* FIXME: TODO */ - return; + KAPC_STATE ApcState; + PAGED_CODE(); + + /* Acquire process rundown */ + if (!ExAcquireRundownProtection(&Process->RundownProtect)) return; + + /* Make sure we have a PEB */ + if (Process->Peb) + { + /* Attach to the process */ + KeStackAttachProcess(&Process->Pcb, &ApcState); + + /* Acquire the debug port mutex */ + ExAcquireFastMutex(&DbgkpProcessDebugPortMutex); + + /* Set the IsBeingDebugged member of the PEB */ + Process->Peb->BeingDebugged = (Process->DebugPort) ? TRUE: FALSE; + + /* Release lock */ + ExReleaseFastMutex(&DbgkpProcessDebugPortMutex); + + /* Detach from the process */ + KeUnstackDetachProcess(&ApcState); + } + + /* Release rundown protection */ + ExReleaseRundownProtection(&Process->RundownProtect); } VOID
18 years, 2 months
1
0
0
0
[ion] 24576: - Fix kernel symbol loading.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 20 09:41:01 2006 New Revision: 24576 URL:
http://svn.reactos.org/svn/reactos?rev=24576&view=rev
Log: - Fix kernel symbol loading. Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.…
============================================================================== --- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c (original) +++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c Fri Oct 20 09:41:01 2006 @@ -595,13 +595,13 @@ BOOLEAN IsRaw; PLIST_ENTRY ListHead, NextEntry; PLDR_DATA_TABLE_ENTRY LdrEntry; + PUNICODE_STRING ModuleName = FileName; UNICODE_STRING NtosSymName = RTL_CONSTANT_STRING(L"ntoskrnl.sym"); UNICODE_STRING NtosName = RTL_CONSTANT_STRING(L"ntoskrnl.exe"); - DPRINT("KdbSymProcessBootSymbols(%wZ)\n", FileName); if (RtlEqualUnicodeString(FileName, &NtosSymName, TRUE)) { - FileName = &NtosName; + ModuleName = &NtosName; IsRaw = TRUE; } else @@ -609,7 +609,7 @@ IsRaw = FALSE; } - ModuleObject = LdrGetModuleObject(FileName); + ModuleObject = LdrGetModuleObject(ModuleName); if (ModuleObject != NULL) { @@ -647,6 +647,7 @@ if (IsRaw) { + DPRINT1("Data: %p %p %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->FullDllName); if (! RosSymCreateFromRaw(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&ModuleObject->PatchInformation))
18 years, 2 months
1
0
0
0
[ion] 24575: - Define DBGKM_APINUMBER - Implement DbgkpSendApiMessageLpc, DbgkpSendApiMessage, DbgkCopyProcessDebugPort, DbgkForwardException, DbgkFreeDebugEvent, DbgpWakeTarget. - Close original handle in DbgkOpenHandles.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 20 09:16:04 2006 New Revision: 24575 URL:
http://svn.reactos.org/svn/reactos?rev=24575&view=rev
Log: - Define DBGKM_APINUMBER - Implement DbgkpSendApiMessageLpc, DbgkpSendApiMessage, DbgkCopyProcessDebugPort, DbgkForwardException, DbgkFreeDebugEvent, DbgpWakeTarget. - Close original handle in DbgkOpenHandles. Modified: trunk/reactos/include/ndk/dbgktypes.h trunk/reactos/ntoskrnl/dbgk/dbgkutil.c trunk/reactos/ntoskrnl/dbgk/debug.c trunk/reactos/ntoskrnl/include/internal/dbgk.h trunk/reactos/ntoskrnl/include/internal/ps.h Modified: trunk/reactos/include/ndk/dbgktypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/dbgktypes.h?re…
============================================================================== --- trunk/reactos/include/ndk/dbgktypes.h (original) +++ trunk/reactos/include/ndk/dbgktypes.h Fri Oct 20 09:16:04 2006 @@ -41,6 +41,22 @@ DebugObjectUnusedInformation, DebugObjectKillProcessOnExitInformation } DEBUGOBJECTINFOCLASS, *PDEBUGOBJECTINFOCLASS; + +// +// Debug Message API Number +// +typedef enum _DBGKM_APINUMBER +{ + DbgKmExceptionApi = 0, + DbgKmCreateThreadApi = 1, + DbgKmCreateProcessApi = 2, + DbgKmExitThreadApi = 3, + DbgKmExitProcessApi = 4, + DbgKmLoadDllApi = 5, + DbgKmUnloadDllApi = 6, + DbgKmErrorReportApi = 7, + DbgKmMaxApiNumber = 8, +} DBGKM_APINUMBER; // // Debug Object Information Structures @@ -173,7 +189,7 @@ typedef struct _DBGKM_MSG { PORT_MESSAGE h; - ULONG ApiNumber; + DBGKM_APINUMBER ApiNumber; ULONG ReturnedStatus; union { Modified: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkutil.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/dbgkutil.c (original) +++ trunk/reactos/ntoskrnl/dbgk/dbgkutil.c Fri Oct 20 09:16:04 2006 @@ -68,4 +68,18 @@ /* FIXME */ } +VOID +NTAPI +DbgkpSuspendProcess(VOID) +{ + +} + +VOID +NTAPI +DbgkpResumeProcess(VOID) +{ + +} + /* EOF */ Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Fri Oct 20 09:16:04 2006 @@ -26,12 +26,127 @@ /* PRIVATE FUNCTIONS *********************************************************/ +NTSTATUS +NTAPI +DbgkpQueueMessage(IN PEPROCESS Process, + IN PETHREAD Thread, + IN PDBGKM_MSG Message, + IN ULONG Flags, + IN PDEBUG_OBJECT TargetObject OPTIONAL) +{ + /* FIXME: TODO */ + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +DbgkpSendApiMessageLpc(IN OUT PDBGKM_MSG Message, + IN PVOID Port, + IN BOOLEAN SuspendProcess) +{ + NTSTATUS Status; + UCHAR Buffer[PORT_MAXIMUM_MESSAGE_LENGTH]; + PAGED_CODE(); + + /* Suspend process if required */ + if (SuspendProcess) DbgkpSuspendProcess(); + + /* Set return status */ + Message->ReturnedStatus = STATUS_PENDING; + + /* Set create process reported state */ + PsGetCurrentProcess()->CreateReported = TRUE; + + /* Send the LPC command */ +#if 0 + Status = LpcRequestWaitReplyPort(Port, + (PPORT_MESSAGE)Message, + (PPORT_MESSAGE)&Buffer[0]); +#else + Status = STATUS_UNSUCCESSFUL; +#endif + + /* Flush the instruction cache */ + ZwFlushInstructionCache(NtCurrentProcess(), NULL, 0); + + /* Copy the buffer back */ + if (NT_SUCCESS(Status)) RtlMoveMemory(Message, Buffer, sizeof(DBGKM_MSG)); + + /* Resume the process if it was suspended */ + if (SuspendProcess) DbgkpResumeProcess(); + return Status; +} + +NTSTATUS +NTAPI +DbgkpSendApiMessage(IN OUT PDBGKM_MSG ApiMsg, + IN ULONG Flags) +{ + NTSTATUS Status; + PAGED_CODE(); + + /* Suspend process if required */ + if (Flags) DbgkpSuspendProcess(); + + /* Set return status */ + ApiMsg->ReturnedStatus = STATUS_PENDING; + + /* Set create process reported state */ + PsGetCurrentProcess()->CreateReported = TRUE; + + /* Send the LPC command */ + Status = DbgkpQueueMessage(PsGetCurrentProcess(), + PsGetCurrentThread(), + ApiMsg, + 0, + NULL); + + /* Flush the instruction cache */ + ZwFlushInstructionCache(NtCurrentProcess(), NULL, 0); + + /* Resume the process if it was suspended */ + if (Flags) DbgkpResumeProcess(); + return Status; +} + VOID NTAPI DbgkCopyProcessDebugPort(IN PEPROCESS Process, IN PEPROCESS Parent) { - /* FIXME: Implement */ + PDEBUG_OBJECT DebugObject; + PAGED_CODE(); + + /* Clear this process's port */ + Process->DebugPort = NULL; + + /* Check if the parent has one */ + if (!Parent->DebugPort) return; + + /* It does, acquire the mutex */ + ExAcquireFastMutex(&DbgkpProcessDebugPortMutex); + + /* Make sure it still has one, and that we should inherit */ + DebugObject = Parent->DebugPort; + if ((DebugObject) && !(Process->NoDebugInherit)) + { + /* Acquire the debug object's lock */ + ExAcquireFastMutex(&DebugObject->Mutex); + + /* Make sure the debugger is active */ + if (!DebugObject->DebuggerInactive) + { + /* Reference the object and set it */ + ObReferenceObject(DebugObject); + Process->DebugPort = DebugObject; + } + + /* Release the debug object */ + ExReleaseFastMutex(&DebugObject->Mutex); + } + + /* Release the port mutex */ + ExReleaseFastMutex(&DbgkpProcessDebugPortMutex); } BOOLEAN @@ -40,16 +155,131 @@ IN BOOLEAN DebugPort, IN BOOLEAN SecondChance) { - /* FIXME: Implement */ - return FALSE; + DBGKM_MSG ApiMessage; + PDBGKM_EXCEPTION DbgKmException = &ApiMessage.Exception; + NTSTATUS Status; + PEPROCESS Process = PsGetCurrentProcess(); + PVOID Port; + BOOLEAN UseLpc = FALSE; + PAGED_CODE(); + + /* Setup the API Message */ + ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 | + (8 + sizeof(DBGKM_EXCEPTION)); + ApiMessage.h.u2.ZeroInit = LPC_DEBUG_EVENT; + ApiMessage.ApiNumber = DbgKmExceptionApi; + + /* Check if this is to be sent on the debug port */ + if (DebugPort) + { + /* Use the debug port, onless the thread is being hidden */ + Port = PsGetCurrentThread()->HideFromDebugger ? + NULL : Process->DebugPort; + } + else + { + /* Otherwise, use the exception port */ + Port = Process->ExceptionPort; + ApiMessage.h.u2.ZeroInit = LPC_EXCEPTION; + UseLpc = TRUE; + } + + /* Break out if there's no port */ + if (!Port) return FALSE; + + /* Fill out the exception information */ + DbgKmException->ExceptionRecord = *ExceptionRecord; + DbgKmException->FirstChance = !SecondChance; + + /* Check if we should use LPC */ + if (UseLpc) + { + /* Send the message on the LPC Port */ + Status = DbgkpSendApiMessageLpc(&ApiMessage, Port, DebugPort); + } + else + { + /* Use native debug object */ + Status = DbgkpSendApiMessage(&ApiMessage, DebugPort); + } + + /* Check if we failed, and for a debug port, also check the return status */ + if (!(NT_SUCCESS(Status)) || + ((DebugPort) && + (!(NT_SUCCESS(ApiMessage.ReturnedStatus)) || + (ApiMessage.ReturnedStatus == DBG_EXCEPTION_NOT_HANDLED)))) + { + /* Fail */ + return FALSE; + } + + /* Otherwise, we're ok */ + return TRUE; } VOID NTAPI +DbgkpFreeDebugEvent(IN PDEBUG_EVENT DebugEvent) +{ + PHANDLE Handle = NULL; + PAGED_CODE(); + + /* Check if this event had a file handle */ + switch (DebugEvent->ApiMsg.ApiNumber) + { + /* Create process has a handle */ + case DbgKmCreateProcessApi: + + /* Get the pointer */ + Handle = &DebugEvent->ApiMsg.CreateProcess.FileHandle; + + /* As does DLL load */ + case DbgKmLoadDllApi: + + /* Get the pointer */ + Handle = &DebugEvent->ApiMsg.LoadDll.FileHandle; + + default: + break; + } + + /* Close the handle if it exsts */ + if ((Handle) && (*Handle)) ObCloseHandle(*Handle, KernelMode); + + /* Dereference process and thread and free the event */ + ObDereferenceObject(DebugEvent->Process); + ObDereferenceObject(DebugEvent->Thread); + ExFreePool(DebugEvent); +} + +VOID +NTAPI DbgkpWakeTarget(IN PDEBUG_EVENT DebugEvent) { - /* FIXME: TODO */ - return; + PETHREAD Thread = DebugEvent->Thread; + PAGED_CODE(); + + /* Check if we have to wake the thread */ + if (DebugEvent->Flags & 20) PsResumeThread(Thread, NULL); + + /* Check if we had locked the thread */ + if (DebugEvent->Flags & 8) + { + /* Unlock it */ + ExReleaseRundownProtection(&Thread->RundownProtect); + } + + /* Check if we have to wake up the event */ + if (DebugEvent->Flags & 2) + { + /* Signal the continue event */ + KeSetEvent(&DebugEvent->ContinueEvent, IO_NO_INCREMENT, FALSE); + } + else + { + /* Otherwise, free the debug event */ + DbgkpFreeDebugEvent(DebugEvent); + } } NTSTATUS @@ -87,6 +317,14 @@ NTAPI DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, IN PDEBUG_EVENT DebugEvent) +{ + /* FIXME: TODO */ + return; +} + +VOID +NTAPI +DbgkpMarkProcessPeb(IN PEPROCESS Process) { /* FIXME: TODO */ return; @@ -187,6 +425,10 @@ 0, DUPLICATE_SAME_ACCESS, KernelMode); + if (NT_SUCCESS(Status)) *DupHandle = NULL; + + /* Close the original handle */ + ObCloseHandle(Handle, KernelMode); } } @@ -199,14 +441,6 @@ /* Sanity check */ ASSERT(IsListEmpty(&DebugObject->EventList)); -} - -VOID -NTAPI -DbgkpMarkProcessPeb(IN PEPROCESS Process) -{ - /* FIXME: TODO */ - return; } VOID Modified: trunk/reactos/ntoskrnl/include/internal/dbgk.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/dbgk.h (original) +++ trunk/reactos/ntoskrnl/include/internal/dbgk.h Fri Oct 20 09:16:04 2006 @@ -17,6 +17,18 @@ NTAPI DbgkExitThread( IN NTSTATUS ExitStatus +); + +VOID +NTAPI +DbgkpSuspendProcess( + VOID +); + +VOID +NTAPI +DbgkpResumeProcess( + VOID ); VOID Modified: trunk/reactos/ntoskrnl/include/internal/ps.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ps.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ps.h Fri Oct 20 09:16:04 2006 @@ -330,6 +330,16 @@ NTAPI PspDeleteJob( IN PVOID ObjectBody +); + +// +// State routines +// +NTSTATUS +NTAPI +PsResumeThread( + IN PETHREAD Thread, + OUT PULONG PreviousCount OPTIONAL ); //
18 years, 2 months
1
0
0
0
[ion] 24574: - Fixup DEBUG_OBJECT definition. - Implement DbgkpCloseObject. - Implement DbgkpOpenHandles. - Fix various bugs in the code and flag usage. - Enable calling DbgkClearProcessDebugObject when terminating a process.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 20 00:08:52 2006 New Revision: 24574 URL:
http://svn.reactos.org/svn/reactos?rev=24574&view=rev
Log: - Fixup DEBUG_OBJECT definition. - Implement DbgkpCloseObject. - Implement DbgkpOpenHandles. - Fix various bugs in the code and flag usage. - Enable calling DbgkClearProcessDebugObject when terminating a process. Modified: trunk/reactos/include/ndk/dbgktypes.h trunk/reactos/ntoskrnl/dbgk/debug.c trunk/reactos/ntoskrnl/include/internal/dbgk.h trunk/reactos/ntoskrnl/include/internal/ke_x.h trunk/reactos/ntoskrnl/include/internal/ob.h trunk/reactos/ntoskrnl/include/internal/ps.h trunk/reactos/ntoskrnl/ps/kill.c trunk/reactos/ntoskrnl/ps/process.c Modified: trunk/reactos/include/ndk/dbgktypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/dbgktypes.h?re…
============================================================================== --- trunk/reactos/include/ndk/dbgktypes.h (original) +++ trunk/reactos/include/ndk/dbgktypes.h Fri Oct 20 00:08:52 2006 @@ -55,11 +55,11 @@ // // Debug Object // -typedef struct _DBGK_DEBUG_OBJECT -{ - KEVENT Event; +typedef struct _DEBUG_OBJECT +{ + KEVENT EventsPresent; FAST_MUTEX Mutex; - LIST_ENTRY StateEventListEntry; + LIST_ENTRY EventList; union { ULONG Flags; @@ -69,7 +69,7 @@ UCHAR KillProcessOnExit:1; }; }; -} DBGK_DEBUG_OBJECT, *PDBGK_DEBUG_OBJECT; +} DEBUG_OBJECT, *PDEBUG_OBJECT; #endif Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Fri Oct 20 00:08:52 2006 @@ -14,7 +14,7 @@ #include <internal/debug.h> POBJECT_TYPE DbgkDebugObjectType; -KGUARDED_MUTEX DbgkpProcessDebugPortMutex; +FAST_MUTEX DbgkpProcessDebugPortMutex; GENERIC_MAPPING DbgkDebugObjectMapping = { @@ -28,25 +28,272 @@ VOID NTAPI +DbgkCopyProcessDebugPort(IN PEPROCESS Process, + IN PEPROCESS Parent) +{ + /* FIXME: Implement */ +} + +BOOLEAN +NTAPI +DbgkForwardException(IN PEXCEPTION_RECORD ExceptionRecord, + IN BOOLEAN DebugPort, + IN BOOLEAN SecondChance) +{ + /* FIXME: Implement */ + return FALSE; +} + +VOID +NTAPI +DbgkpWakeTarget(IN PDEBUG_EVENT DebugEvent) +{ + /* FIXME: TODO */ + return; +} + +NTSTATUS +NTAPI +DbgkpPostFakeProcessCreateMessages(IN PEPROCESS Process, + IN PDEBUG_OBJECT DebugObject, + IN PETHREAD *LastThread) +{ + /* FIXME: Implement */ + *LastThread = NULL; + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +DbgkpSetProcessDebugObject(IN PEPROCESS Process, + IN PDEBUG_OBJECT DebugObject, + IN NTSTATUS MsgStatus, + IN PETHREAD LastThread) +{ + /* FIXME: TODO */ + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +DbgkClearProcessDebugObject(IN PEPROCESS Process, + IN PDEBUG_OBJECT SourceDebugObject) +{ + /* FIXME: TODO */ + return STATUS_UNSUCCESSFUL; +} + +VOID +NTAPI +DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, + IN PDEBUG_EVENT DebugEvent) +{ + /* FIXME: TODO */ + return; +} + +VOID +NTAPI +DbgkpOpenHandles(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, + IN PEPROCESS Process, + IN PETHREAD Thread) +{ + NTSTATUS Status; + HANDLE Handle; + PHANDLE DupHandle; + PAGED_CODE(); + + /* Check which state this is */ + switch (WaitStateChange->NewState) + { + /* New thread */ + case DbgCreateThreadStateChange: + + /* Get handle to thread */ + Status = ObOpenObjectByPointer(Thread, + 0, + NULL, + THREAD_ALL_ACCESS, + PsThreadType, + KernelMode, + &Handle); + if (NT_SUCCESS(Status)) + { + /* Save the thread handle */ + WaitStateChange-> + StateInfo.CreateThread.HandleToThread = Handle; + } + return; + + /* New process */ + case DbgCreateProcessStateChange: + + /* Get handle to thread */ + Status = ObOpenObjectByPointer(Thread, + 0, + NULL, + THREAD_ALL_ACCESS, + PsThreadType, + KernelMode, + &Handle); + if (NT_SUCCESS(Status)) + { + /* Save the thread handle */ + WaitStateChange-> + StateInfo.CreateProcessInfo.HandleToThread = Handle; + } + + /* Get handle to process */ + Status = ObOpenObjectByPointer(Process, + 0, + NULL, + PROCESS_ALL_ACCESS, + PsProcessType, + KernelMode, + &Handle); + if (NT_SUCCESS(Status)) + { + /* Save the process handle */ + WaitStateChange-> + StateInfo.CreateProcessInfo.HandleToProcess = Handle; + } + + /* Fall through to duplicate file handle */ + DupHandle = &WaitStateChange-> + StateInfo.CreateProcessInfo.NewProcess.FileHandle; + break; + + /* DLL Load */ + case DbgLoadDllStateChange: + + /* Fall through to duplicate file handle */ + DupHandle = &WaitStateChange->StateInfo.LoadDll.FileHandle; + + /* Anything else has no handles */ + default: + return; + } + + /* If we got here, then we have to duplicate a handle, possibly */ + Handle = *DupHandle; + if (Handle) + { + /* Duplicate it */ + Status = ObDuplicateObject(PsGetCurrentProcess(), + Handle, + PsGetCurrentProcess(), + DupHandle, + 0, + 0, + DUPLICATE_SAME_ACCESS, + KernelMode); + } +} + +VOID +NTAPI DbgkpDeleteObject(IN PVOID Object) { - PDBGK_DEBUG_OBJECT DebugObject = Object; + PDEBUG_OBJECT DebugObject = Object; PAGED_CODE(); /* Sanity check */ - ASSERT(IsListEmpty(&DebugObject->StateEventListEntry)); + ASSERT(IsListEmpty(&DebugObject->EventList)); } VOID NTAPI -DbgkpCloseObject(IN PEPROCESS Process OPTIONAL, +DbgkpMarkProcessPeb(IN PEPROCESS Process) +{ + /* FIXME: TODO */ + return; +} + +VOID +NTAPI +DbgkpCloseObject(IN PEPROCESS OwnerProcess OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount, IN ULONG SystemHandleCount) { - /* FIXME: Implement */ - ASSERT(FALSE); + PDEBUG_OBJECT DebugObject = ObjectBody; + PEPROCESS Process = NULL; + BOOLEAN DebugPortCleared = FALSE; + PLIST_ENTRY DebugEventList; + PDEBUG_EVENT DebugEvent; + + /* If this isn't the last handle, do nothing */ + if (HandleCount > 1) return; + + /* Otherwise, lock the debug object */ + ExAcquireFastMutex(&DebugObject->Mutex); + + /* Set it as inactive */ + DebugObject->DebuggerInactive = TRUE; + + /* Remove it from the debug event list */ + DebugEventList = DebugObject->EventList.Flink; + InitializeListHead(&DebugObject->EventList); + + /* Release the lock */ + ExReleaseFastMutex(&DebugObject->Mutex); + + /* Signal the wait event */ + KeSetEvent(&DebugObject->EventsPresent, IO_NO_INCREMENT, FALSE); + + /* Start looping each process */ + while ((Process = PsGetNextProcess(Process))) + { + /* Check if the process has us as their debug port */ + if (Process->DebugPort == DebugObject) + { + /* Acquire the process debug port lock */ + ExAcquireFastMutex(&DbgkpProcessDebugPortMutex); + + /* Check if it's still us */ + if (Process->DebugPort == DebugObject) + { + /* Clear it and remember */ + Process->DebugPort = NULL; + DebugPortCleared = TRUE; + } + + /* Release the port lock */ + ExReleaseFastMutex(&DbgkpProcessDebugPortMutex); + + /* Check if we cleared the debug port */ + if (DebugPortCleared) + { + /* Mark this in the PEB */ + DbgkpMarkProcessPeb(OwnerProcess); + + /* Check if we terminate on exit */ + if (DebugObject->KillProcessOnExit) + { + /* Terminate the process */ + PsTerminateProcess(OwnerProcess, STATUS_DEBUGGER_INACTIVE); + } + + /* Dereference the debug object */ + ObDereferenceObject(DebugObject); + } + } + } + + /* Loop debug events */ + while (DebugEventList != &DebugObject->EventList) + { + /* Get the debug event */ + DebugEvent = CONTAINING_RECORD(DebugEventList, DEBUG_EVENT, EventList); + + /* Go to the next entry */ + DebugEventList = DebugEventList->Flink; + + /* Wake it up */ + DebugEvent->Status = STATUS_DEBUGGER_INACTIVE; + DbgkpWakeTarget(DebugEvent); + } } VOID @@ -59,13 +306,13 @@ PAGED_CODE(); /* Initialize the process debug port mutex */ - KeInitializeGuardedMutex(&DbgkpProcessDebugPortMutex); - - /* Create the Event Pair Object Type */ + ExInitializeFastMutex(&DbgkpProcessDebugPortMutex); + + /* Create the Debug Object Type */ RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer)); RtlInitUnicodeString(&Name, L"DebugObject"); ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); - ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(DBGK_DEBUG_OBJECT); + ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(DEBUG_OBJECT); ObjectTypeInitializer.GenericMapping = DbgkDebugObjectMapping; ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = DEBUG_OBJECT_WAIT_STATE_CHANGE; @@ -78,83 +325,6 @@ &DbgkDebugObjectType); } -VOID -NTAPI -DbgkCopyProcessDebugPort(IN PEPROCESS Process, - IN PEPROCESS Parent) -{ - /* FIXME: Implement */ -} - -BOOLEAN -NTAPI -DbgkForwardException(IN PEXCEPTION_RECORD ExceptionRecord, - IN BOOLEAN DebugPort, - IN BOOLEAN SecondChance) -{ - /* FIXME: Implement */ - return FALSE; -} - -VOID -NTAPI -DbgkpWakeTarget(IN PDEBUG_EVENT DebugEvent) -{ - /* FIXME: TODO */ - return; -} - -NTSTATUS -NTAPI -DbgkpPostFakeProcessCreateMessages(IN PEPROCESS Process, - IN PDBGK_DEBUG_OBJECT DebugObject, - IN PETHREAD *LastThread) -{ - /* FIXME: Implement */ - *LastThread = NULL; - return STATUS_UNSUCCESSFUL; -} - -NTSTATUS -NTAPI -DbgkpSetProcessDebugObject(IN PEPROCESS Process, - IN PDBGK_DEBUG_OBJECT DebugObject, - IN NTSTATUS MsgStatus, - IN PETHREAD LastThread) -{ - /* FIXME: TODO */ - return STATUS_UNSUCCESSFUL; -} - -NTSTATUS -NTAPI -DbgkClearProcessDebugObject(IN PEPROCESS Process, - IN PDBGK_DEBUG_OBJECT SourceDebugObject) -{ - /* FIXME: TODO */ - return STATUS_UNSUCCESSFUL; -} - -VOID -NTAPI -DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, - IN PDEBUG_EVENT DebugEvent) -{ - /* FIXME: TODO */ - return; -} - -VOID -NTAPI -DbgkpOpenHandles(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, - IN PEPROCESS Process, - IN PETHREAD Thread) -{ - /* FIXME: TODO */ - return; -} - - /* PUBLIC FUNCTIONS **********************************************************/ NTSTATUS @@ -165,7 +335,7 @@ IN BOOLEAN KillProcessOnExit) { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; HANDLE hDebug; NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); @@ -193,7 +363,7 @@ ObjectAttributes, PreviousMode, NULL, - sizeof(PDBGK_DEBUG_OBJECT), + sizeof(PDEBUG_OBJECT), 0, 0, (PVOID*)&DebugObject); @@ -203,10 +373,10 @@ ExInitializeFastMutex(&DebugObject->Mutex); /* Initialize the State Event List */ - InitializeListHead(&DebugObject->StateEventListEntry); + InitializeListHead(&DebugObject->EventList); /* Initialize the Debug Object's Wait Event */ - KeInitializeEvent(&DebugObject->Event, NotificationEvent, 0); + KeInitializeEvent(&DebugObject->EventsPresent, NotificationEvent, 0); /* Set the Flags */ DebugObject->KillProcessOnExit = KillProcessOnExit; @@ -245,7 +415,7 @@ IN NTSTATUS ContinueStatus) { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; NTSTATUS Status = STATUS_SUCCESS; PDEBUG_EVENT DebugEvent = NULL, DebugEventToWake = NULL; PLIST_ENTRY ListHead, NextEntry; @@ -296,7 +466,7 @@ ExAcquireFastMutex(&DebugObject->Mutex); /* Loop the state list */ - ListHead = &DebugObject->StateEventListEntry; + ListHead = &DebugObject->EventList; NextEntry = ListHead->Flink; while (ListHead != NextEntry) { @@ -371,7 +541,7 @@ IN HANDLE DebugHandle) { PEPROCESS Process; - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); PETHREAD LastThread; NTSTATUS Status; @@ -435,7 +605,7 @@ IN HANDLE DebugHandle) { PEPROCESS Process; - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); NTSTATUS Status; @@ -487,7 +657,7 @@ IN ULONG DebugInformationLength, OUT PULONG ReturnLength OPTIONAL) { - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; PDEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION DebugInfo = DebugInformation; @@ -522,12 +692,12 @@ if (DebugInfo->KillProcessOnExit) { /* Enable killing the process */ - DebugObject->Flags |= 2; + DebugObject->KillProcessOnExit = TRUE; } else { /* Disable */ - DebugObject->Flags &= ~2; + DebugObject->KillProcessOnExit = FALSE; } /* Release the mutex */ @@ -555,7 +725,7 @@ PETHREAD Thread; BOOLEAN GotEvent; LARGE_INTEGER NewTime; - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; DBGUI_WAIT_STATE_CHANGE WaitStateChange; NTSTATUS Status = STATUS_SUCCESS; PDEBUG_EVENT DebugEvent, DebugEvent2; @@ -628,7 +798,7 @@ ExAcquireFastMutex(&DebugObject->Mutex); /* Check if a debugger is connected */ - if (DebugObject->Flags & 1) + if (DebugObject->DebuggerInactive) { /* Not connected */ Status = STATUS_DEBUGGER_INACTIVE; @@ -636,7 +806,7 @@ else { /* Loop the events */ - ListHead = &DebugObject->StateEventListEntry; + ListHead = &DebugObject->EventList; NextEntry = ListHead->Flink; while (ListHead != NextEntry) { @@ -702,7 +872,7 @@ else { /* Unsignal the event */ - DebugObject->Event.Header.SignalState = 0; + DebugObject->EventsPresent.Header.SignalState = 0; Status = STATUS_SUCCESS; } } Modified: trunk/reactos/ntoskrnl/include/internal/dbgk.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/dbgk.h (original) +++ trunk/reactos/ntoskrnl/include/internal/dbgk.h Fri Oct 20 00:08:52 2006 @@ -3,15 +3,21 @@ VOID NTAPI -DbgkCreateThread(PVOID StartAddress); +DbgkCreateThread( + IN PVOID StartAddress +); VOID NTAPI -DbgkExitProcess(IN NTSTATUS ExitStatus); +DbgkExitProcess( + IN NTSTATUS ExitStatus +); VOID NTAPI -DbgkExitThread(IN NTSTATUS ExitStatus); +DbgkExitThread( + IN NTSTATUS ExitStatus +); VOID NTAPI @@ -28,6 +34,13 @@ IN BOOLEAN SecondChance ); +NTSTATUS +NTAPI +DbgkClearProcessDebugObject( + IN PEPROCESS Process, + IN PDEBUG_OBJECT SourceDebugObject +); + extern POBJECT_TYPE DbgkDebugObjectType; #endif Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke_x.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke_x.h Fri Oct 20 00:08:52 2006 @@ -57,15 +57,15 @@ // #define KeEnterCriticalRegion() \ { \ - PKTHREAD Thread = KeGetCurrentThread(); \ + PKTHREAD _Thread = KeGetCurrentThread(); \ \ /* Sanity checks */ \ - ASSERT(Thread == KeGetCurrentThread()); \ - ASSERT((Thread->KernelApcDisable <= 0) && \ - (Thread->KernelApcDisable != -32768)); \ + ASSERT(_Thread == KeGetCurrentThread()); \ + ASSERT((_Thread->KernelApcDisable <= 0) && \ + (_Thread->KernelApcDisable != -32768)); \ \ /* Disable Kernel APCs */ \ - Thread->KernelApcDisable--; \ + _Thread->KernelApcDisable--; \ } // @@ -73,21 +73,21 @@ // #define KeLeaveCriticalRegion() \ { \ - PKTHREAD Thread = KeGetCurrentThread(); \ + PKTHREAD _Thread = KeGetCurrentThread(); \ \ /* Sanity checks */ \ - ASSERT(Thread == KeGetCurrentThread()); \ - ASSERT(Thread->KernelApcDisable < 0); \ + ASSERT(_Thread == KeGetCurrentThread()); \ + ASSERT(_Thread->KernelApcDisable < 0); \ \ /* Enable Kernel APCs */ \ - Thread->KernelApcDisable++; \ + _Thread->KernelApcDisable++; \ \ /* Check if Kernel APCs are now enabled */ \ - if (!(Thread->KernelApcDisable)) \ + if (!(_Thread->KernelApcDisable)) \ { \ /* Check if we need to request an APC Delivery */ \ - if (!(IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) && \ - !(Thread->KernelApcDisable)) \ + if (!(IsListEmpty(&_Thread->ApcState.ApcListHead[KernelMode])) && \ + !(_Thread->KernelApcDisable)) \ { \ /* Check for the right environment */ \ KiCheckForKernelApcDelivery(); \ Modified: trunk/reactos/ntoskrnl/include/internal/ob.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ob.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ob.h Fri Oct 20 00:08:52 2006 @@ -238,6 +238,19 @@ IN PEPROCESS Process ); +NTSTATUS +NTAPI +ObDuplicateObject( + IN PEPROCESS SourceProcess, + IN HANDLE SourceHandle, + IN PEPROCESS TargetProcess OPTIONAL, + IN PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + IN ULONG Options, + IN KPROCESSOR_MODE PreviousMode +); + // // DOS Devices Functions // Modified: trunk/reactos/ntoskrnl/include/internal/ps.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ps.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ps.h Fri Oct 20 00:08:52 2006 @@ -235,6 +235,13 @@ PspExitProcess( IN BOOLEAN LastThread, IN PEPROCESS Process +); + +NTSTATUS +NTAPI +PsTerminateProcess( + IN PEPROCESS Process, + IN NTSTATUS ExitStatus ); VOID Modified: trunk/reactos/ntoskrnl/ps/kill.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=245…
============================================================================== --- trunk/reactos/ntoskrnl/ps/kill.c (original) +++ trunk/reactos/ntoskrnl/ps/kill.c Fri Oct 20 00:08:52 2006 @@ -116,6 +116,15 @@ /* Return success*/ PSREFTRACE(Process); return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +PsTerminateProcess(IN PEPROCESS Process, + IN NTSTATUS ExitStatus) +{ + /* Call the internal API */ + return PspTerminateProcess(Process, ExitStatus); } VOID @@ -1116,7 +1125,8 @@ /* Check for the DBG_TERMINATE_PROCESS exit code */ if (ExitStatus == DBG_TERMINATE_PROCESS) { - /* FIXME: Disable debugging on this process */ + /* Disable debugging on this process */ + DbgkClearProcessDebugObject(Process, NULL); } } /* Make sure that we got a handle */ 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 (original) +++ trunk/reactos/ntoskrnl/ps/process.c Fri Oct 20 00:08:52 2006 @@ -362,7 +362,7 @@ HANDLE hProcess; PEPROCESS Process, Parent; PEPORT ExceptionPortObject; - PDBGK_DEBUG_OBJECT DebugObject; + PDEBUG_OBJECT DebugObject; PSECTION_OBJECT SectionObject; NTSTATUS Status, AccessStatus; PHYSICAL_ADDRESS DirectoryTableBase = {{0}};
18 years, 2 months
1
0
0
0
← Newer
1
...
8
9
10
11
12
13
14
...
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200