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
February 2005
----- 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
23 participants
411 discussions
Start a n
N
ew thread
[weiden] 13556: don't leak a reference to the timer object when copying to the buffer failed in NtQueryTimer() and don't use uninitialized variable in NtSetTimer()
by weiden@svn.reactos.com
don't leak a reference to the timer object when copying to the buffer failed in NtQueryTimer() and don't use uninitialized variable in NtSetTimer() Modified: trunk/reactos/ntoskrnl/ex/timer.c _____ Modified: trunk/reactos/ntoskrnl/ex/timer.c --- trunk/reactos/ntoskrnl/ex/timer.c 2005-02-14 07:46:14 UTC (rev 13555) +++ trunk/reactos/ntoskrnl/ex/timer.c 2005-02-14 11:46:17 UTC (rev 13556) @@ -483,22 +483,27 @@ /* Check for Success */ if(NT_SUCCESS(Status)) { - /* Return the Basic Information */ - _SEH_TRY { - - /* FIXME: Interrupt correction based on Interrupt Time */ - DPRINT("Returning Information for Timer: %x. Time Remaining: %d\n", Timer, Timer->KeTimer.DueTime.QuadPart); - BasicInfo->TimeRemaining.QuadPart = Timer->KeTimer.DueTime.QuadPart; - BasicInfo->SignalState = KeReadStateTimer(&Timer->KeTimer); - ObDereferenceObject(Timer); + switch(TimerInformationClass) { + case TimerBasicInformation: { + /* Return the Basic Information */ + _SEH_TRY { - if(ReturnLength != NULL) { - *ReturnLength = sizeof(TIMER_BASIC_INFORMATION); - } + /* FIXME: Interrupt correction based on Interrupt Time */ + DPRINT("Returning Information for Timer: %x. Time Remaining: %d\n", Timer, Timer->KeTimer.DueTime.QuadPart); + BasicInfo->TimeRemaining.QuadPart = Timer->KeTimer.DueTime.QuadPart; + BasicInfo->SignalState = KeReadStateTimer(&Timer->KeTimer); + + if(ReturnLength != NULL) { + *ReturnLength = sizeof(TIMER_BASIC_INFORMATION); + } + + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + } + } - } _SEH_HANDLE { - Status = _SEH_GetExceptionCode(); - } _SEH_END; + ObDereferenceObject(Timer); } /* Return Status */ @@ -517,7 +522,7 @@ { PETIMER Timer; KIRQL OldIrql; - BOOLEAN KillTimer; + BOOLEAN KillTimer = FALSE; BOOLEAN State; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PETHREAD CurrentThread = PsGetCurrentThread();
19 years, 10 months
1
0
0
0
[gvg] 13555: netzimme@netscape.net
by gvg@svn.reactos.com
netzimme(a)netscape.net Make RTL8029 work with NE2000 driver Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c _____ Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c --- trunk/reactos/drivers/net/ndis/ndis/miniport.c 2005-02-14 05:36:04 UTC (rev 13554) +++ trunk/reactos/drivers/net/ndis/ndis/miniport.c 2005-02-14 07:46:14 UTC (rev 13555) @@ -603,7 +603,7 @@ Adapter->NdisMiniportBlock.MiniportAdapterContext, Oid, Adapter->QueryBuffer, - Size, + Adapter->QueryBufferLength, BytesWritten, &BytesNeeded); }
19 years, 10 months
1
0
0
0
[ion] 13554: Reimplemented Kernel and Executive Timers. Use Microsoft documented structures, added locks to protect against race conditions, use dispatcher database, implement new features like wake timers, use thread timer lists, simplify timer list, add more comments and debug info, actually add apc/dpc functions which do what the should do, fix a couple of bugs, simplfiy absolute vs relative timers. I will do more testing and see wether an experimental Timer Tree patch (which greatly speeds u
by ion@svn.reactos.com
Reimplemented Kernel and Executive Timers. Use Microsoft documented structures, added locks to protect against race conditions, use dispatcher database, implement new features like wake timers, use thread timer lists, simplify timer list, add more comments and debug info, actually add apc/dpc functions which do what the should do, fix a couple of bugs, simplfiy absolute vs relative timers. I will do more testing and see wether an experimental Timer Tree patch (which greatly speeds up timer processing) is necessary. Modified: trunk/reactos/include/ddk/kefuncs.h Modified: trunk/reactos/ntoskrnl/Makefile Modified: trunk/reactos/ntoskrnl/ex/timer.c Modified: trunk/reactos/ntoskrnl/include/internal/ke.h Added: trunk/reactos/ntoskrnl/ke/clock.c Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c Modified: trunk/reactos/ntoskrnl/ke/kthread.c Modified: trunk/reactos/ntoskrnl/ke/profile.c Modified: trunk/reactos/ntoskrnl/ke/timer.c Modified: trunk/reactos/ntoskrnl/ke/wait.c _____ Modified: trunk/reactos/include/ddk/kefuncs.h --- trunk/reactos/include/ddk/kefuncs.h 2005-02-14 00:32:09 UTC (rev 13553) +++ trunk/reactos/include/ddk/kefuncs.h 2005-02-14 05:36:04 UTC (rev 13554) @@ -246,6 +246,12 @@ VOID ); +ULONGLONG +STDCALL +KeQueryInterruptTime( + VOID + ); + VOID STDCALL KeRaiseIrql ( _____ Modified: trunk/reactos/ntoskrnl/Makefile --- trunk/reactos/ntoskrnl/Makefile 2005-02-14 00:32:09 UTC (rev 13553) +++ trunk/reactos/ntoskrnl/Makefile 2005-02-14 05:36:04 UTC (rev 13554) @@ -96,6 +96,7 @@ ke/apc.o \ ke/bug.o \ ke/catch.o \ + ke/clock.o \ ke/critical.o \ ke/dpc.o \ ke/device.o \ _____ Modified: trunk/reactos/ntoskrnl/ex/timer.c --- trunk/reactos/ntoskrnl/ex/timer.c 2005-02-14 00:32:09 UTC (rev 13553) +++ trunk/reactos/ntoskrnl/ex/timer.c 2005-02-14 05:36:04 UTC (rev 13554) @@ -5,7 +5,8 @@ * FILE: ntoskrnl/ex/timer.c * PURPOSE: User-mode timers * - * PROGRAMMERS: David Welch (welch(a)mcmail.com) + * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - Reimplemented + * David Welch (welch(a)mcmail.com) */ /* INCLUDES *****************************************************************/ @@ -13,528 +14,665 @@ #include <ntoskrnl.h> #include <internal/debug.h> - /* TYPES ********************************************************************/ -typedef struct _NTTIMER -{ - KTIMER Timer; - KDPC Dpc; - KAPC Apc; - BOOLEAN Running; -} NTTIMER, *PNTTIMER; +/* Executive Timer Object */ +typedef struct _ETIMER { + KTIMER KeTimer; + KAPC TimerApc; + KDPC TimerDpc; + LIST_ENTRY ActiveTimerListEntry; + KSPIN_LOCK Lock; + LONG Period; + BOOLEAN ApcAssociated; + BOOLEAN WakeTimer; + LIST_ENTRY WakeTimerListEntry; +} ETIMER, *PETIMER; - /* GLOBALS ******************************************************************/ +/* Timer Object Type */ POBJECT_TYPE ExTimerType = NULL; +KSPIN_LOCK ExpWakeListLock; +LIST_ENTRY ExpWakeList; + +/* Timer Mapping */ static GENERIC_MAPPING ExpTimerMapping = { - STANDARD_RIGHTS_READ | TIMER_QUERY_STATE, - STANDARD_RIGHTS_WRITE | TIMER_MODIFY_STATE, - STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, - TIMER_ALL_ACCESS}; + STANDARD_RIGHTS_READ | TIMER_QUERY_STATE, + STANDARD_RIGHTS_WRITE | TIMER_MODIFY_STATE, + STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, + TIMER_ALL_ACCESS +}; -static const INFORMATION_CLASS_INFO ExTimerInfoClass[] = -{ - ICI_SQ_SAME( sizeof(TIMER_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), /* TimerBasicInformation */ +/* Timer Information Classes */ +static const INFORMATION_CLASS_INFO ExTimerInfoClass[] = { + + /* TimerBasicInformation */ + ICI_SQ_SAME( sizeof(TIMER_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), }; /* FUNCTIONS *****************************************************************/ -NTSTATUS STDCALL -ExpCreateTimer(PVOID ObjectBody, - PVOID Parent, - PWSTR RemainingPath, - POBJECT_ATTRIBUTES ObjectAttributes) -{ - DPRINT("ExpCreateTimer(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - return(STATUS_SUCCESS); -} - - -VOID STDCALL +VOID +STDCALL ExpDeleteTimer(PVOID ObjectBody) { - KIRQL OldIrql; - PNTTIMER Timer = ObjectBody; + KIRQL OldIrql; + PETIMER Timer = ObjectBody; - DPRINT("ExpDeleteTimer()\n"); + DPRINT("ExpDeleteTimer(Timer: %x)\n", Timer); - OldIrql = KeRaiseIrqlToDpcLevel(); + /* Lock the Wake List */ + KeAcquireSpinLock(&ExpWakeListLock, &OldIrql); + + /* Check if it has a Wait List */ + if (!IsListEmpty(&Timer->WakeTimerListEntry)) { + + /* Remove it from the Wait List */ + DPRINT("Removing wake list\n"); + RemoveEntryList(&Timer->WakeTimerListEntry); + } + + /* Release the Wake List */ + KeReleaseSpinLock(&ExpWakeListLock, OldIrql); - KeCancelTimer(&Timer->Timer); - KeRemoveQueueDpc(&Timer->Dpc); - KeRemoveQueueApc(&Timer->Apc); - Timer->Running = FALSE; - - KeLowerIrql(OldIrql); + /* Tell the Kernel to cancel the Timer */ + DPRINT("Cancelling Timer\n"); + KeCancelTimer(&Timer->KeTimer); } - -VOID STDCALL +VOID +STDCALL ExpTimerDpcRoutine(PKDPC Dpc, - PVOID DeferredContext, - PVOID SystemArgument1, - PVOID SystemArgument2) + PVOID DeferredContext, + PVOID SystemArgument1, + PVOID SystemArgument2) { - PNTTIMER Timer; + PETIMER Timer; + KIRQL OldIrql; - DPRINT("ExpTimerDpcRoutine()\n"); + DPRINT("ExpTimerDpcRoutine(Dpc: %x)\n", Dpc); - Timer = (PNTTIMER)DeferredContext; + /* Get the Timer Object */ + Timer = (PETIMER)DeferredContext; - if ( Timer->Running ) - { - KeInsertQueueApc(&Timer->Apc, - SystemArgument1, - SystemArgument2, - IO_NO_INCREMENT); - } + /* Lock the Timer */ + KeAcquireSpinLock(&Timer->Lock, &OldIrql); + + /* Queue the APC */ + if(Timer->ApcAssociated) { + + DPRINT("Queuing APC\n"); + KeInsertQueueApc(&Timer->TimerApc, + SystemArgument1, + SystemArgument2, + IO_NO_INCREMENT); + } + + /* Release the Timer */ + KeReleaseSpinLock(&Timer->Lock, OldIrql); } -VOID STDCALL +VOID +STDCALL ExpTimerApcKernelRoutine(PKAPC Apc, - PKNORMAL_ROUTINE* NormalRoutine, - PVOID* NormalContext, - PVOID* SystemArgument1, - PVOID* SystemArguemnt2) + PKNORMAL_ROUTINE* NormalRoutine, + PVOID* NormalContext, + PVOID* SystemArgument1, + PVOID* SystemArguemnt2) { - DPRINT("ExpTimerApcKernelRoutine()\n"); - + PETIMER Timer; + PETHREAD CurrentThread = PsGetCurrentThread(); + KIRQL OldIrql; + + /* We need to find out which Timer we are */ + Timer = CONTAINING_RECORD(Apc, ETIMER, TimerApc); + DPRINT("ExpTimerApcKernelRoutine(Apc: %x. Timer: %x)\n", Apc, Timer); + + /* Lock the Timer */ + KeAcquireSpinLock(&Timer->Lock, &OldIrql); + + /* Lock the Thread's Active Timer List*/ + KeAcquireSpinLockAtDpcLevel(&CurrentThread->ActiveTimerListLock); + + /* + * Make sure that the Timer is still valid, and that it belongs to this thread + * Remove it if it's not periodic + */ + if ((Timer->ApcAssociated) && + (&CurrentThread->Tcb == Timer->TimerApc.Thread) && + (!Timer->Period)) { + + /* Remove it from the Active Timers List */ + DPRINT("Removing Timer\n"); + RemoveEntryList(&Timer->ActiveTimerListEntry); + + /* Disable it */ + Timer->ApcAssociated = FALSE; + + /* Release spinlocks */ + KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock); + KeReleaseSpinLock(&Timer->Lock, OldIrql); + + /* Dereference the Timer Object */ + ObDereferenceObject(Timer); + return; + } + + /* Release spinlocks */ + KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock); + KeReleaseSpinLock(&Timer->Lock, OldIrql); } - -VOID INIT_FUNCTION +VOID +INIT_FUNCTION ExpInitializeTimerImplementation(VOID) { - ASSERT(!ExTimerType) - ExTimerType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); + DPRINT("ExpInitializeTimerImplementation()\n"); + + /* Allocate Memory for the Timer */ + ExTimerType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); - RtlpCreateUnicodeString(&ExTimerType->TypeName, L"Timer", NonPagedPool); - - ExTimerType->Tag = TAG('T', 'I', 'M', 'T'); - ExTimerType->PeakObjects = 0; - ExTimerType->PeakHandles = 0; - ExTimerType->TotalObjects = 0; - ExTimerType->TotalHandles = 0; - ExTimerType->PagedPoolCharge = 0; - ExTimerType->NonpagedPoolCharge = sizeof(NTTIMER); - ExTimerType->Mapping = &ExpTimerMapping; - ExTimerType->Dump = NULL; - ExTimerType->Open = NULL; - ExTimerType->Close = NULL; - ExTimerType->Delete = ExpDeleteTimer; - ExTimerType->Parse = NULL; - ExTimerType->Security = NULL; - ExTimerType->QueryName = NULL; - ExTimerType->OkayToClose = NULL; - ExTimerType->Create = ExpCreateTimer; - ExTimerType->DuplicationNotify = NULL; - - ObpCreateTypeObject(ExTimerType); + /* Create the Executive Timer Object */ + RtlpCreateUnicodeString(&ExTimerType->TypeName, L"Timer", NonPagedPool); + ExTimerType->Tag = TAG('T', 'I', 'M', 'T'); + ExTimerType->PeakObjects = 0; + ExTimerType->PeakHandles = 0; + ExTimerType->TotalObjects = 0; + ExTimerType->TotalHandles = 0; + ExTimerType->PagedPoolCharge = 0; + ExTimerType->NonpagedPoolCharge = sizeof(ETIMER); + ExTimerType->Mapping = &ExpTimerMapping; + ExTimerType->Dump = NULL; + ExTimerType->Open = NULL; + ExTimerType->Close = NULL; + ExTimerType->Delete = ExpDeleteTimer; + ExTimerType->Parse = NULL; + ExTimerType->Security = NULL; + ExTimerType->QueryName = NULL; + ExTimerType->OkayToClose = NULL; + ExTimerType->Create = NULL; + ExTimerType->DuplicationNotify = NULL; + ObpCreateTypeObject(ExTimerType); + + /* Initialize the Wait List and Lock */ + KeInitializeSpinLock(&ExpWakeListLock); + InitializeListHead(&ExpWakeList); } -NTSTATUS STDCALL +NTSTATUS +STDCALL NtCancelTimer(IN HANDLE TimerHandle, - OUT PBOOLEAN CurrentState OPTIONAL) + OUT PBOOLEAN CurrentState OPTIONAL) { - PNTTIMER Timer; - KPROCESSOR_MODE PreviousMode; - NTSTATUS Status = STATUS_SUCCESS; + PETIMER Timer; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + NTSTATUS Status = STATUS_SUCCESS; + BOOLEAN State; + KIRQL OldIrql; + BOOLEAN KillTimer = FALSE; + PETHREAD TimerThread; - PreviousMode = ExGetPreviousMode(); + DPRINT("NtCancelTimer(0x%x, 0x%x)\n", TimerHandle, CurrentState); - DPRINT("NtCancelTimer(0x%x, 0x%x)\n", TimerHandle, CurrentState); - - if(CurrentState != NULL && PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForWrite(CurrentState, - sizeof(BOOLEAN), - sizeof(BOOLEAN)); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + /* Check Parameter Validity */ + if(CurrentState != NULL && PreviousMode != KernelMode) { + _SEH_TRY { + ProbeForWrite(CurrentState, + sizeof(BOOLEAN), + sizeof(BOOLEAN)); + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; - if(!NT_SUCCESS(Status)) - { - return Status; - } - } + if(!NT_SUCCESS(Status)) { + return Status; + } + } - Status = ObReferenceObjectByHandle(TimerHandle, - TIMER_ALL_ACCESS, - ExTimerType, - PreviousMode, - (PVOID*)&Timer, - NULL); - if(NT_SUCCESS(Status)) - { - BOOLEAN State; - KIRQL OldIrql = KeRaiseIrqlToDpcLevel(); + /* Get the Timer Object */ + Status = ObReferenceObjectByHandle(TimerHandle, + TIMER_ALL_ACCESS, + ExTimerType, + PreviousMode, + (PVOID*)&Timer, + NULL); + + /* Check for success */ + if(NT_SUCCESS(Status)) { + + DPRINT("Timer Referencced: %x\n", Timer); + + /* Lock the Timer */ + KeAcquireSpinLock(&Timer->Lock, &OldIrql); + + /* Check if it's enabled */ + if (Timer->ApcAssociated) { + + /* + * First, remove it from the Thread's Active List + * Get the Thread. + */ + TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb); + DPRINT("Removing from Thread: %x\n", TimerThread); + + /* Lock its active list */ + KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock); + + /* Remove it */ + RemoveEntryList(&TimerThread->ActiveTimerListHead); + + /* Unlock the list */ + KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock); + + /* Cancel the Timer */ + KeCancelTimer(&Timer->KeTimer); + KeRemoveQueueDpc(&Timer->TimerDpc); + KeRemoveQueueApc(&Timer->TimerApc); + Timer->ApcAssociated = FALSE; + KillTimer = TRUE; + + } else { + + /* If timer was disabled, we still need to cancel it */ + DPRINT("APC was not Associated. Cancelling Timer\n"); + KeCancelTimer(&Timer->KeTimer); + } + + /* Read the old State */ + State = KeReadStateTimer(&Timer->KeTimer); + + /* Dereference the Object */ + ObDereferenceObject(Timer); + + /* Unlock the Timer */ + KeReleaseSpinLock(&Timer->Lock, OldIrql); + + /* Dereference if it was previously enabled */ + if (KillTimer) ObDereferenceObject(Timer); + DPRINT1("Timer disabled\n"); - State = KeCancelTimer(&Timer->Timer); - KeRemoveQueueDpc(&Timer->Dpc); - KeRemoveQueueApc(&Timer->Apc); - Timer->Running = FALSE; + /* Make sure it's safe to write to the handle */ + if(CurrentState != NULL) { + _SEH_TRY { + *CurrentState = State; + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + } + } - KeLowerIrql(OldIrql); - ObDereferenceObject(Timer); - - if(CurrentState != NULL) - { - _SEH_TRY - { - *CurrentState = State; - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - } - } - - return Status; + /* Return to Caller */ + return Status; } -NTSTATUS STDCALL +NTSTATUS +STDCALL NtCreateTimer(OUT PHANDLE TimerHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN TIMER_TYPE TimerType) + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN TIMER_TYPE TimerType) { - PNTTIMER Timer; - HANDLE hTimer; - KPROCESSOR_MODE PreviousMode; - NTSTATUS Status = STATUS_SUCCESS; + PETIMER Timer; + HANDLE hTimer; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("NtCreateTimer()\n"); + DPRINT("NtCreateTimer(Handle: %x, Type: %d)\n", TimerHandle, TimerType); + + /* Check Parameter Validity */ + if (PreviousMode != KernelMode) { + _SEH_TRY { + ProbeForWrite(TimerHandle, + sizeof(HANDLE), + sizeof(ULONG)); + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + + if(!NT_SUCCESS(Status)) { + return Status; + } + } + + /* Create the Object */ + Status = ObCreateObject(PreviousMode, + ExTimerType, + ObjectAttributes, + PreviousMode, + NULL, + sizeof(ETIMER), + 0, + 0, + (PVOID*)&Timer); - PreviousMode = ExGetPreviousMode(); - - if(PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForWrite(TimerHandle, - sizeof(HANDLE), - sizeof(ULONG)); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + /* Check for Success */ + if(NT_SUCCESS(Status)) { + + /* Initialize the Kernel Timer */ + DPRINT("Initializing Timer: %x\n", Timer); + KeInitializeTimerEx(&Timer->KeTimer, TimerType); - if(!NT_SUCCESS(Status)) - { - return Status; - } - } + /* Initialize the Timer Lock */ + KeInitializeSpinLock(&Timer->Lock); + + /* Initialize the DPC */ + KeInitializeDpc(&Timer->TimerDpc, ExpTimerDpcRoutine, Timer); - Status = ObCreateObject(PreviousMode, - ExTimerType, - ObjectAttributes, - PreviousMode, - NULL, - sizeof(NTTIMER), - 0, - 0, - (PVOID*)&Timer); - if(NT_SUCCESS(Status)) - { - KeInitializeTimerEx(&Timer->Timer, - TimerType); + /* Set Initial State */ + Timer->ApcAssociated = FALSE; + InitializeListHead(&Timer->WakeTimerListEntry); + Timer->WakeTimer = FALSE; + + /* Insert the Timer */ + Status = ObInsertObject((PVOID)Timer, + NULL, + DesiredAccess, + 0, + NULL, + &hTimer); + DPRINT("Timer Inserted\n"); - KeInitializeDpc(&Timer->Dpc, - &ExpTimerDpcRoutine, - Timer); + + /* Make sure it's safe to write to the handle */ + _SEH_TRY { + *TimerHandle = hTimer; + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + } - Timer->Running = FALSE; - - Status = ObInsertObject ((PVOID)Timer, - NULL, - DesiredAccess, - 0, - NULL, - &hTimer); - ObDereferenceObject(Timer); - - if(NT_SUCCESS(Status)) - { - _SEH_TRY - { - *TimerHandle = hTimer; - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - } - } - - return Status; + /* Return to Caller */ + return Status; } -NTSTATUS STDCALL +NTSTATUS +STDCALL NtOpenTimer(OUT PHANDLE TimerHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes) + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes) { - HANDLE hTimer; - KPROCESSOR_MODE PreviousMode; - NTSTATUS Status = STATUS_SUCCESS; + HANDLE hTimer; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("NtOpenTimer()\n"); + DPRINT("NtOpenTimer(TimerHandle: %x)\n", TimerHandle); - PreviousMode = ExGetPreviousMode(); + /* Check Parameter Validity */ + if (PreviousMode != KernelMode) { + _SEH_TRY { + ProbeForWrite(TimerHandle, + sizeof(HANDLE), + sizeof(ULONG)); + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + + if(!NT_SUCCESS(Status)) { + return Status; + } + } - if(PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForWrite(TimerHandle, - sizeof(HANDLE), - sizeof(ULONG)); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + /* Open the Timer */ + Status = ObOpenObjectByName(ObjectAttributes, + ExTimerType, + NULL, + PreviousMode, + DesiredAccess, + NULL, + &hTimer); + + /* Check for success */ + if(NT_SUCCESS(Status)) { + + /* Make sure it's safe to write to the handle */ + _SEH_TRY { + *TimerHandle = hTimer; + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + } - if(!NT_SUCCESS(Status)) - { - return Status; - } - } - - Status = ObOpenObjectByName(ObjectAttributes, - ExTimerType, - NULL, - PreviousMode, - DesiredAccess, - NULL, - &hTimer); - if(NT_SUCCESS(Status)) - { - _SEH_TRY - { - *TimerHandle = hTimer; - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - } - - return Status; + /* Return to Caller */ + return Status; } -NTSTATUS STDCALL +NTSTATUS +STDCALL NtQueryTimer(IN HANDLE TimerHandle, - IN TIMER_INFORMATION_CLASS TimerInformationClass, - OUT PVOID TimerInformation, - IN ULONG TimerInformationLength, - OUT PULONG ReturnLength OPTIONAL) + IN TIMER_INFORMATION_CLASS TimerInformationClass, + OUT PVOID TimerInformation, + IN ULONG TimerInformationLength, + OUT PULONG ReturnLength OPTIONAL) { - PNTTIMER Timer; - KPROCESSOR_MODE PreviousMode; - NTSTATUS Status = STATUS_SUCCESS; + PETIMER Timer; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + NTSTATUS Status = STATUS_SUCCESS; + PTIMER_BASIC_INFORMATION BasicInfo = (PTIMER_BASIC_INFORMATION)TimerInformation; - PreviousMode = ExGetPreviousMode(); + DPRINT("NtQueryTimer(TimerHandle: %x, Class: %d)\n", TimerHandle, TimerInformationClass); + + /* Check Validity */ + DefaultQueryInfoBufferCheck(TimerInformationClass, + ExTimerInfoClass, + TimerInformation, + TimerInformationLength, + ReturnLength, + PreviousMode, + &Status); + if(!NT_SUCCESS(Status)) { + + DPRINT1("NtQueryTimer() failed, Status: 0x%x\n", Status); + return Status; + } - DefaultQueryInfoBufferCheck(TimerInformationClass, - ExTimerInfoClass, - TimerInformation, - TimerInformationLength, - ReturnLength, - PreviousMode, - &Status); - if(!NT_SUCCESS(Status)) - { - DPRINT1("NtQueryTimer() failed, Status: 0x%x\n", Status); - return Status; - } + /* Get the Timer Object */ + Status = ObReferenceObjectByHandle(TimerHandle, + TIMER_QUERY_STATE, + ExTimerType, + PreviousMode, + (PVOID*)&Timer, + NULL); + + /* Check for Success */ + if(NT_SUCCESS(Status)) { + + /* Return the Basic Information */ + _SEH_TRY { + + /* FIXME: Interrupt correction based on Interrupt Time */ + DPRINT("Returning Information for Timer: %x. Time Remaining: %d\n", Timer, Timer->KeTimer.DueTime.QuadPart); + BasicInfo->TimeRemaining.QuadPart = Timer->KeTimer.DueTime.QuadPart; + BasicInfo->SignalState = KeReadStateTimer(&Timer->KeTimer); + ObDereferenceObject(Timer); - Status = ObReferenceObjectByHandle(TimerHandle, - TIMER_QUERY_STATE, - ExTimerType, - PreviousMode, - (PVOID*)&Timer, - NULL); - if(NT_SUCCESS(Status)) - { - switch(TimerInformationClass) - { - case TimerBasicInformation: - { - PTIMER_BASIC_INFORMATION BasicInfo = (PTIMER_BASIC_INFORMATION)TimerInformation; - - _SEH_TRY - { - /* FIXME - interrupt correction */ - BasicInfo->TimeRemaining.QuadPart = Timer->Timer.DueTime.QuadPart; - BasicInfo->SignalState = (BOOLEAN)Timer->Timer.Header.SignalState; - - if(ReturnLength != NULL) - { - *ReturnLength = sizeof(TIMER_BASIC_INFORMATION); - } - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - break; - } - - default: - Status = STATUS_NOT_IMPLEMENTED; - break; - } - - ObDereferenceObject(Timer); - } - - return Status; + if(ReturnLength != NULL) { + *ReturnLength = sizeof(TIMER_BASIC_INFORMATION); + } + + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + } + + /* Return Status */ + return Status; } - -NTSTATUS STDCALL +NTSTATUS +STDCALL NtSetTimer(IN HANDLE TimerHandle, - IN PLARGE_INTEGER DueTime, - IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, - IN PVOID TimerContext OPTIONAL, - IN BOOLEAN ResumeTimer, - IN LONG Period OPTIONAL, - OUT PBOOLEAN PreviousState OPTIONAL) + IN PLARGE_INTEGER DueTime, + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, + IN PVOID TimerContext OPTIONAL, + IN BOOLEAN WakeTimer, + IN LONG Period OPTIONAL, + OUT PBOOLEAN PreviousState OPTIONAL) { - PNTTIMER Timer; - BOOLEAN Result; - BOOLEAN State; - LARGE_INTEGER TimerDueTime; - KPROCESSOR_MODE PreviousMode; - NTSTATUS Status = STATUS_SUCCESS; + PETIMER Timer; + KIRQL OldIrql; + BOOLEAN KillTimer; + BOOLEAN State; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + PETHREAD CurrentThread = PsGetCurrentThread(); + NTSTATUS Status = STATUS_SUCCESS; + LARGE_INTEGER TimerDueTime; + PETHREAD TimerThread; - DPRINT("NtSetTimer()\n"); + DPRINT("NtSetTimer(TimerHandle: %x, DueTime: %d, Apc: %x, Period: %d)\n", TimerHandle, DueTime->QuadPart, TimerApcRoutine, Period); - PreviousMode = ExGetPreviousMode(); + /* Check Parameter Validity */ + if (PreviousMode != KernelMode) { + _SEH_TRY { + ProbeForRead(DueTime, + sizeof(LARGE_INTEGER), + sizeof(ULONG)); + TimerDueTime = *DueTime; + + if(PreviousState != NULL) { + ProbeForWrite(PreviousState, + sizeof(BOOLEAN), + sizeof(BOOLEAN)); + } + + } _SEH_HANDLE { + Status = _SEH_GetExceptionCode(); + } _SEH_END; + + if(!NT_SUCCESS(Status)) { + return Status; + } + } + + /* Get the Timer Object */ + Status = ObReferenceObjectByHandle(TimerHandle, + TIMER_ALL_ACCESS, + ExTimerType, + PreviousMode, + (PVOID*)&Timer, + NULL); + + /* Check status */ + if (NT_SUCCESS(Status)) { + + /* Lock the Timer */ + DPRINT("Timer Referencced: %x\n", Timer); + KeAcquireSpinLock(&Timer->Lock, &OldIrql); + + /* Cancel Running Timer */ + if (Timer->ApcAssociated) { + + /* + * First, remove it from the Thread's Active List + * Get the Thread. + */ + TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb); + DPRINT("Thread already running. Removing from Thread: %x\n", TimerThread); + + /* Lock its active list */ + KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock); + + /* Remove it */ + RemoveEntryList(&TimerThread->ActiveTimerListHead); + + /* Unlock the list */ + KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock); + + /* Cancel the Timer */ + KeCancelTimer(&Timer->KeTimer); + KeRemoveQueueDpc(&Timer->TimerDpc); + KeRemoveQueueApc(&Timer->TimerApc); + Timer->ApcAssociated = FALSE; + KillTimer = TRUE; + + } else { + + /* If timer was disabled, we still need to cancel it */ + DPRINT("No APCs. Simply cancelling\n"); + KeCancelTimer(&Timer->KeTimer); + } + + /* Read the State */ + State = KeReadStateTimer(&Timer->KeTimer); - if(PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForRead(DueTime, - sizeof(LARGE_INTEGER), - sizeof(ULONG)); - TimerDueTime = *DueTime; + /* Handle Wake Timers */ + DPRINT("Doing Wake Semantics\n"); + KeAcquireSpinLockAtDpcLevel(&ExpWakeListLock); + if (WakeTimer) { + + /* Insert it into the list */ + InsertTailList(&ExpWakeList, &Timer->WakeTimerListEntry); + + } else { + [truncated at 1000 lines; 1995 more skipped]
19 years, 10 months
1
0
0
0
[weiden] 13553: probe pointers in NtCreateToken. Still needs some work as access to the buffers needs to be secured
by weiden@svn.reactos.com
probe pointers in NtCreateToken. Still needs some work as access to the buffers needs to be secured Modified: trunk/reactos/ntoskrnl/se/token.c _____ Modified: trunk/reactos/ntoskrnl/se/token.c --- trunk/reactos/ntoskrnl/se/token.c 2005-02-14 00:28:12 UTC (rev 13552) +++ trunk/reactos/ntoskrnl/se/token.c 2005-02-14 00:32:09 UTC (rev 13553) @@ -1588,7 +1588,7 @@ NTSTATUS STDCALL -NtCreateToken(OUT PHANDLE UnsafeTokenHandle, +NtCreateToken(OUT PHANDLE TokenHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN TOKEN_TYPE TokenType, @@ -1602,14 +1602,64 @@ IN PTOKEN_DEFAULT_DACL TokenDefaultDacl, IN PTOKEN_SOURCE TokenSource) { - HANDLE TokenHandle; + HANDLE hToken; PTOKEN AccessToken; - NTSTATUS Status; LUID TokenId; LUID ModifiedId; PVOID EndMem; ULONG uLength; ULONG i; + KPROCESSOR_MODE PreviousMode; + NTSTATUS Status = STATUS_SUCCESS; + + PreviousMode = ExGetPreviousMode(); + + if(PreviousMode != KernelMode) + { + _SEH_TRY + { + ProbeForWrite(TokenHandle, + sizeof(HANDLE), + sizeof(ULONG)); + ProbeForRead(AuthenticationId, + sizeof(LUID), + sizeof(ULONG)); + ProbeForRead(ExpirationTime, + sizeof(LARGE_INTEGER), + sizeof(ULONG)); + ProbeForRead(TokenUser, + sizeof(TOKEN_USER), + sizeof(ULONG)); + ProbeForRead(TokenGroups, + sizeof(TOKEN_GROUPS), + sizeof(ULONG)); + ProbeForRead(TokenPrivileges, + sizeof(TOKEN_PRIVILEGES), + sizeof(ULONG)); + ProbeForRead(TokenOwner, + sizeof(TOKEN_OWNER), + sizeof(ULONG)); + ProbeForRead(TokenPrimaryGroup, + sizeof(TOKEN_PRIMARY_GROUP), + sizeof(ULONG)); + ProbeForRead(TokenDefaultDacl, + sizeof(TOKEN_DEFAULT_DACL), + sizeof(ULONG)); + ProbeForRead(TokenSource, + sizeof(TOKEN_SOURCE), + sizeof(ULONG)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if(!NT_SUCCESS(Status)) + { + return Status; + } + } Status = ZwAllocateLocallyUniqueId(&TokenId); if (!NT_SUCCESS(Status)) @@ -1619,10 +1669,10 @@ if (!NT_SUCCESS(Status)) return(Status); - Status = ObCreateObject(ExGetPreviousMode(), + Status = ObCreateObject(PreviousMode, SepTokenObjectType, ObjectAttributes, - ExGetPreviousMode(), + PreviousMode, NULL, sizeof(TOKEN), 0, @@ -1634,19 +1684,6 @@ return(Status); } - Status = ObInsertObject ((PVOID)AccessToken, - NULL, - DesiredAccess, - 0, - NULL, - &TokenHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT1("ObInsertObject() failed (Status %lx)\n"); - ObDereferenceObject (AccessToken); - return Status; - } - RtlCopyLuid(&AccessToken->TokenSource.SourceIdentifier, &TokenSource->SourceIdentifier); memcpy(AccessToken->TokenSource.SourceName, @@ -1740,22 +1777,33 @@ TokenDefaultDacl->DefaultDacl->AclSize); } + Status = ObInsertObject ((PVOID)AccessToken, + NULL, + DesiredAccess, + 0, + NULL, + &hToken); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ObInsertObject() failed (Status %lx)\n", Status); + } + ObDereferenceObject(AccessToken); if (NT_SUCCESS(Status)) { - Status = MmCopyToCaller(UnsafeTokenHandle, - &TokenHandle, - sizeof(HANDLE)); + _SEH_TRY + { + *TokenHandle = hToken; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; } - if (!NT_SUCCESS(Status)) - { - ZwClose(TokenHandle); - return(Status); - } - - return(STATUS_SUCCESS); + return Status; }
19 years, 10 months
1
0
0
0
[weiden] 13552: secure access to buffers in NtAllocateLocallyUniqueId
by weiden@svn.reactos.com
secure access to buffers in NtAllocateLocallyUniqueId Modified: trunk/reactos/ntoskrnl/include/internal/ex.h Modified: trunk/reactos/ntoskrnl/se/luid.c Modified: trunk/reactos/ntoskrnl/se/token.c _____ Modified: trunk/reactos/ntoskrnl/include/internal/ex.h --- trunk/reactos/ntoskrnl/include/internal/ex.h 2005-02-13 23:10:36 UTC (rev 13551) +++ trunk/reactos/ntoskrnl/include/internal/ex.h 2005-02-14 00:28:12 UTC (rev 13552) @@ -120,6 +120,9 @@ NTSTATUS ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation); +NTSTATUS +ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);; + #define InterlockedDecrementUL(Addend) \ (ULONG)InterlockedDecrement((PLONG)(Addend)) _____ Modified: trunk/reactos/ntoskrnl/se/luid.c --- trunk/reactos/ntoskrnl/se/luid.c 2005-02-13 23:10:36 UTC (rev 13551) +++ trunk/reactos/ntoskrnl/se/luid.c 2005-02-14 00:28:12 UTC (rev 13552) @@ -15,7 +15,6 @@ /* GLOBALS *******************************************************************/ -static KSPIN_LOCK LuidLock; static LARGE_INTEGER LuidIncrement; static LARGE_INTEGER LuidValue; @@ -26,34 +25,79 @@ { LUID DummyLuidValue = SYSTEM_LUID; - KeInitializeSpinLock(&LuidLock); LuidValue.u.HighPart = DummyLuidValue.HighPart; LuidValue.u.LowPart = DummyLuidValue.LowPart; LuidIncrement.QuadPart = 1; } +NTSTATUS +ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) +{ + LARGE_INTEGER NewLuid, PrevLuid; + + /* atomically increment the luid */ + do + { + PrevLuid = (volatile LARGE_INTEGER)LuidValue; + NewLuid = RtlLargeIntegerAdd(PrevLuid, + LuidIncrement); + } while(ExfInterlockedCompareExchange64(&LuidValue.QuadPart, + &NewLuid.QuadPart, + &PrevLuid.QuadPart) != PrevLuid.QuadPart); + + LocallyUniqueId->LowPart = NewLuid.u.LowPart; + LocallyUniqueId->HighPart = NewLuid.u.HighPart; + + return STATUS_SUCCESS; +} + + /* * @implemented */ NTSTATUS STDCALL NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) { - LARGE_INTEGER ReturnedLuid; - KIRQL Irql; + LUID NewLuid; + KPROCESSOR_MODE PreviousMode; + NTSTATUS Status = STATUS_SUCCESS; + + PreviousMode = ExGetPreviousMode(); + + if(PreviousMode != KernelMode) + { + _SEH_TRY + { + ProbeForWrite(LocallyUniqueId, + sizeof(LUID), + sizeof(ULONG)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if(!NT_SUCCESS(Status)) + { + return Status; + } + } - KeAcquireSpinLock(&LuidLock, - &Irql); - ReturnedLuid = LuidValue; - LuidValue = RtlLargeIntegerAdd(LuidValue, - LuidIncrement); - KeReleaseSpinLock(&LuidLock, - Irql); + Status = ExpAllocateLocallyUniqueId(&NewLuid); - LocallyUniqueId->LowPart = ReturnedLuid.u.LowPart; - LocallyUniqueId->HighPart = ReturnedLuid.u.HighPart; + _SEH_TRY + { + *LocallyUniqueId = NewLuid; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - return(STATUS_SUCCESS); + return Status; } _____ Modified: trunk/reactos/ntoskrnl/se/token.c --- trunk/reactos/ntoskrnl/se/token.c 2005-02-13 23:10:36 UTC (rev 13551) +++ trunk/reactos/ntoskrnl/se/token.c 2005-02-14 00:28:12 UTC (rev 13552) @@ -1415,21 +1415,21 @@ return(Status); } - Status = NtAllocateLocallyUniqueId(&AccessToken->TokenId); + Status = ExpAllocateLocallyUniqueId(&AccessToken->TokenId); if (!NT_SUCCESS(Status)) { ObDereferenceObject(AccessToken); return(Status); } - Status = NtAllocateLocallyUniqueId(&AccessToken->ModifiedId); + Status = ExpAllocateLocallyUniqueId(&AccessToken->ModifiedId); if (!NT_SUCCESS(Status)) { ObDereferenceObject(AccessToken); return(Status); } - Status = NtAllocateLocallyUniqueId(&AccessToken->AuthenticationId); + Status = ExpAllocateLocallyUniqueId(&AccessToken->AuthenticationId); if (!NT_SUCCESS(Status)) { ObDereferenceObject(AccessToken);
19 years, 10 months
1
0
0
0
[gvg] 13551: Sync to Wine-20050211
by gvg@svn.reactos.com
Sync to Wine-20050211 James Hawkins <truiken(a)gmail.com> - Properly implement DllCanUnloadNow ref counting. Make sure the mozilla control is ready to unload as well. - Use Interlocked* instead of ++/-- in AddRef/Release. - Use only stored result of Interlocked* in AddRef/Release. - Expand TRACEs to display the ref count. Mike McCormack <mike(a)codeweavers.com> - Stub definition for OpenUrl. Modified: trunk/reactos/lib/shdocvw/classinfo.c Modified: trunk/reactos/lib/shdocvw/events.c Modified: trunk/reactos/lib/shdocvw/factory.c Modified: trunk/reactos/lib/shdocvw/misc.c Modified: trunk/reactos/lib/shdocvw/oleobject.c Modified: trunk/reactos/lib/shdocvw/persist.c Modified: trunk/reactos/lib/shdocvw/shdocvw.h Modified: trunk/reactos/lib/shdocvw/shdocvw.spec Modified: trunk/reactos/lib/shdocvw/shdocvw_main.c Modified: trunk/reactos/lib/shdocvw/webbrowser.c _____ Modified: trunk/reactos/lib/shdocvw/classinfo.c --- trunk/reactos/lib/shdocvw/classinfo.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/classinfo.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -38,27 +38,25 @@ static HRESULT WINAPI WBPCI_QueryInterface(LPPROVIDECLASSINFO iface, REFIID riid, LPVOID *ppobj) { - IProvideClassInfoImpl *This = (IProvideClassInfoImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBPCI_AddRef(LPPROVIDECLASSINFO iface) { - IProvideClassInfoImpl *This = (IProvideClassInfoImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBPCI_Release(LPPROVIDECLASSINFO iface) { - IProvideClassInfoImpl *This = (IProvideClassInfoImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /* Return an ITypeInfo interface to retrieve type library info about @@ -82,7 +80,7 @@ WBPCI_GetClassInfo }; -IProvideClassInfoImpl SHDOCVW_ProvideClassInfo = { &WBPCI_Vtbl, 1 }; +IProvideClassInfoImpl SHDOCVW_ProvideClassInfo = { &WBPCI_Vtbl}; /********************************************************************** @@ -93,27 +91,25 @@ static HRESULT WINAPI WBPCI2_QueryInterface(LPPROVIDECLASSINFO2 iface, REFIID riid, LPVOID *ppobj) { - IProvideClassInfo2Impl *This = (IProvideClassInfo2Impl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBPCI2_AddRef(LPPROVIDECLASSINFO2 iface) { - IProvideClassInfo2Impl *This = (IProvideClassInfo2Impl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBPCI2_Release(LPPROVIDECLASSINFO2 iface) { - IProvideClassInfo2Impl *This = (IProvideClassInfo2Impl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /* Return an ITypeInfo interface to retrieve type library info about @@ -167,4 +163,4 @@ WBPCI2_GetGUID }; -IProvideClassInfo2Impl SHDOCVW_ProvideClassInfo2 = { &WBPCI2_Vtbl, 1 }; +IProvideClassInfo2Impl SHDOCVW_ProvideClassInfo2 = { &WBPCI2_Vtbl}; _____ Modified: trunk/reactos/lib/shdocvw/events.c --- trunk/reactos/lib/shdocvw/events.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/events.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -38,27 +38,25 @@ static HRESULT WINAPI WBCPC_QueryInterface(LPCONNECTIONPOINTCONTAINER iface, REFIID riid, LPVOID *ppobj) { - IConnectionPointContainerImpl *This = (IConnectionPointContainerImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBCPC_AddRef(LPCONNECTIONPOINTCONTAINER iface) { - IConnectionPointContainerImpl *This = (IConnectionPointContainerImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBCPC_Release(LPCONNECTIONPOINTCONTAINER iface) { - IConnectionPointContainerImpl *This = (IConnectionPointContainerImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /* Get a list of connection points inside this container. */ @@ -112,7 +110,7 @@ WBCPC_FindConnectionPoint }; -IConnectionPointContainerImpl SHDOCVW_ConnectionPointContainer = { &WBCPC_Vtbl, 1 }; +IConnectionPointContainerImpl SHDOCVW_ConnectionPointContainer = {&WBCPC_Vtbl}; /********************************************************************** @@ -122,27 +120,25 @@ static HRESULT WINAPI WBCP_QueryInterface(LPCONNECTIONPOINT iface, REFIID riid, LPVOID *ppobj) { - IConnectionPointImpl *This = (IConnectionPointImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBCP_AddRef(LPCONNECTIONPOINT iface) { - IConnectionPointImpl *This = (IConnectionPointImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBCP_Release(LPCONNECTIONPOINT iface) { - IConnectionPointImpl *This = (IConnectionPointImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } static HRESULT WINAPI WBCP_GetConnectionInterface(LPCONNECTIONPOINT iface, IID* pIId) @@ -209,4 +205,4 @@ WBCP_EnumConnections }; -IConnectionPointImpl SHDOCVW_ConnectionPoint = { &WBCP_Vtbl, 1 }; +IConnectionPointImpl SHDOCVW_ConnectionPoint = {&WBCP_Vtbl}; _____ Modified: trunk/reactos/lib/shdocvw/factory.c --- trunk/reactos/lib/shdocvw/factory.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/factory.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -36,16 +36,10 @@ static HRESULT WINAPI WBCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - - TRACE ("\n"); - - /* - * Perform a sanity check on the parameters. - */ - if ((This == NULL) || (ppobj == NULL) ) - return E_INVALIDARG; - + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } @@ -54,10 +48,9 @@ */ static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } /*********************************************************************** * @@ -65,11 +58,9 @@ */ static ULONG WINAPI WBCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /*********************************************************************** * @@ -104,8 +95,13 @@ */ static HRESULT WINAPI WBCF_LockServer(LPCLASSFACTORY iface, BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p)->(%d),stub!\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + SHDOCVW_LockModule(); + else + SHDOCVW_UnlockModule(); + return S_OK; } @@ -118,4 +114,4 @@ WBCF_LockServer }; -IClassFactoryImpl SHDOCVW_ClassFactory = { &WBCF_Vtbl, 1 }; +IClassFactoryImpl SHDOCVW_ClassFactory = {&WBCF_Vtbl}; _____ Modified: trunk/reactos/lib/shdocvw/misc.c --- trunk/reactos/lib/shdocvw/misc.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/misc.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -32,27 +32,25 @@ static HRESULT WINAPI WBQA_QueryInterface(LPQUICKACTIVATE iface, REFIID riid, LPVOID *ppobj) { - IQuickActivateImpl *This = (IQuickActivateImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBQA_AddRef(LPQUICKACTIVATE iface) { - IQuickActivateImpl *This = (IQuickActivateImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBQA_Release(LPQUICKACTIVATE iface) { - IQuickActivateImpl *This = (IQuickActivateImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /* Alternative interface for quicker, easier activation of a control. */ @@ -90,4 +88,12 @@ WBQA_GetContentExtent }; -IQuickActivateImpl SHDOCVW_QuickActivate = { &WBQA_Vtbl, 1 }; +IQuickActivateImpl SHDOCVW_QuickActivate = {&WBQA_Vtbl}; + +/********************************************************************** + * OpenURL (SHDOCVW.@) + */ +void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd) +{ + FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(lpcstrUrl), nShowCmd); +} _____ Modified: trunk/reactos/lib/shdocvw/oleobject.c --- trunk/reactos/lib/shdocvw/oleobject.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/oleobject.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -143,10 +143,9 @@ */ static ULONG WINAPI WBOOBJ_AddRef(LPOLEOBJECT iface) { - IOleObjectImpl *This = (IOleObjectImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } /*********************************************************************** * @@ -154,11 +153,9 @@ */ static ULONG WINAPI WBOOBJ_Release(LPOLEOBJECT iface) { - IOleObjectImpl *This = (IOleObjectImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /*********************************************************************** * @@ -438,7 +435,7 @@ WBOOBJ_SetColorScheme }; -IOleObjectImpl SHDOCVW_OleObject = { &WBOOBJ_Vtbl, 1 }; +IOleObjectImpl SHDOCVW_OleObject = {&WBOOBJ_Vtbl}; /********************************************************************** @@ -448,27 +445,25 @@ static HRESULT WINAPI WBOIPO_QueryInterface(LPOLEINPLACEOBJECT iface, REFIID riid, LPVOID *ppobj) { - IOleInPlaceObjectImpl *This = (IOleInPlaceObjectImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBOIPO_AddRef(LPOLEINPLACEOBJECT iface) { - IOleInPlaceObjectImpl *This = (IOleInPlaceObjectImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBOIPO_Release(LPOLEINPLACEOBJECT iface) { - IOleInPlaceObjectImpl *This = (IOleInPlaceObjectImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } static HRESULT WINAPI WBOIPO_GetWindow(LPOLEINPLACEOBJECT iface, HWND* phwnd) @@ -540,7 +535,7 @@ WBOIPO_ReactivateAndUndo }; -IOleInPlaceObjectImpl SHDOCVW_OleInPlaceObject = { &WBOIPO_Vtbl, 1 }; +IOleInPlaceObjectImpl SHDOCVW_OleInPlaceObject = {&WBOIPO_Vtbl}; /********************************************************************** @@ -550,27 +545,25 @@ static HRESULT WINAPI WBOC_QueryInterface(LPOLECONTROL iface, REFIID riid, LPVOID *ppobj) { - IOleControlImpl *This = (IOleControlImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBOC_AddRef(LPOLECONTROL iface) { - IOleControlImpl *This = (IOleControlImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBOC_Release(LPOLECONTROL iface) { - IOleControlImpl *This = (IOleControlImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } static HRESULT WINAPI WBOC_GetControlInfo(LPOLECONTROL iface, LPCONTROLINFO pCI) @@ -612,4 +605,4 @@ WBOC_FreezeEvents }; -IOleControlImpl SHDOCVW_OleControl = { &WBOC_Vtbl, 1 }; +IOleControlImpl SHDOCVW_OleControl = {&WBOC_Vtbl}; _____ Modified: trunk/reactos/lib/shdocvw/persist.c --- trunk/reactos/lib/shdocvw/persist.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/persist.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -30,27 +30,25 @@ static HRESULT WINAPI WBPS_QueryInterface(LPPERSISTSTORAGE iface, REFIID riid, LPVOID *ppobj) { - IPersistStorageImpl *This = (IPersistStorageImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBPS_AddRef(LPPERSISTSTORAGE iface) { - IPersistStorageImpl *This = (IPersistStorageImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBPS_Release(LPPERSISTSTORAGE iface) { - IPersistStorageImpl *This = (IPersistStorageImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } static HRESULT WINAPI WBPS_GetClassID(LPPERSISTSTORAGE iface, CLSID *pClassID) @@ -107,7 +105,7 @@ WBPS_SaveCompleted }; -IPersistStorageImpl SHDOCVW_PersistStorage = { &WBPS_Vtbl, 1 }; +IPersistStorageImpl SHDOCVW_PersistStorage = {&WBPS_Vtbl}; /********************************************************************** @@ -117,27 +115,25 @@ static HRESULT WINAPI WBPSI_QueryInterface(LPPERSISTSTREAMINIT iface, REFIID riid, LPVOID *ppobj) { - IPersistStreamInitImpl *This = (IPersistStreamInitImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WBPSI_AddRef(LPPERSISTSTREAMINIT iface) { - IPersistStreamInitImpl *This = (IPersistStreamInitImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WBPSI_Release(LPPERSISTSTREAMINIT iface) { - IPersistStreamInitImpl *This = (IPersistStreamInitImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } static HRESULT WINAPI WBPSI_GetClassID(LPPERSISTSTREAMINIT iface, CLSID *pClassID) @@ -195,4 +191,4 @@ WBPSI_InitNew }; -IPersistStreamInitImpl SHDOCVW_PersistStreamInit = { &WBPSI_Vtbl, 1 }; +IPersistStreamInitImpl SHDOCVW_PersistStreamInit = {&WBPSI_Vtbl}; _____ Modified: trunk/reactos/lib/shdocvw/shdocvw.h --- trunk/reactos/lib/shdocvw/shdocvw.h 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/shdocvw.h 2005-02-13 23:10:36 UTC (rev 13551) @@ -190,4 +190,11 @@ extern IConnectionPointImpl SHDOCVW_ConnectionPoint; +/********************************************************************** + * Dll lifetime tracking declaration for shdocvw.dll + */ +extern LONG SHDOCVW_refCount; +static inline void SHDOCVW_LockModule() { InterlockedIncrement( &SHDOCVW_refCount ); } +static inline void SHDOCVW_UnlockModule() { InterlockedDecrement( &SHDOCVW_refCount ); } + #endif /* __WINE_SHDOCVW_H */ _____ Modified: trunk/reactos/lib/shdocvw/shdocvw.spec --- trunk/reactos/lib/shdocvw/shdocvw.spec 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/shdocvw.spec 2005-02-13 23:10:36 UTC (rev 13551) @@ -121,7 +121,7 @@ @ stub ImportPrivacySettings @ stub InstallReg_RunDLL @ stub IEWriteErrorLog -@ stub OpenURL +@ stdcall OpenURL(long long str long) @ stub SHGetIDispatchForFolder @ stdcall SetQueryNetSessionCount(long) @ stub SoftwareUpdateMessageBox _____ Modified: trunk/reactos/lib/shdocvw/shdocvw_main.c --- trunk/reactos/lib/shdocvw/shdocvw_main.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/shdocvw_main.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -47,6 +47,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); +LONG SHDOCVW_refCount = 0; + static const WCHAR szMozDlPath[] = { 'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\', 's','h','d','o','c','v','w',0 @@ -55,6 +57,7 @@ DEFINE_GUID( CLSID_MozillaBrowser, 0x1339B54C,0x3453,0x11D2,0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00); typedef HRESULT (WINAPI *fnGetClassObject)(REFCLSID rclsid, REFIID iid, LPVOID *ppv); +typedef HRESULT (WINAPI *fnCanUnloadNow)(void); HINSTANCE shdocvw_hinstance = 0; static HMODULE SHDOCVW_hshell32 = 0; @@ -127,8 +130,21 @@ */ HRESULT WINAPI SHDOCVW_DllCanUnloadNow(void) { - FIXME("(void): stub\n"); + HRESULT moz_can_unload = S_FALSE; + fnCanUnloadNow pCanUnloadNow; + if (hMozCtl) + { + pCanUnloadNow = (fnCanUnloadNow) + GetProcAddress(hMozCtl, "DllCanUnloadNow"); + moz_can_unload = pCanUnloadNow(); + } + else + moz_can_unload = S_OK; + + if (moz_can_unload == S_OK && SHDOCVW_refCount == 0) + return S_OK; + return S_FALSE; } @@ -145,6 +161,8 @@ static HRESULT WINAPI dlQueryInterface( IBindStatusCallback* This, REFIID riid, void** ppvObject ) { + if (ppvObject == NULL) return E_POINTER; + if( IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IBindStatusCallback)) { @@ -158,6 +176,9 @@ static ULONG WINAPI dlAddRef( IBindStatusCallback* iface ) { IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface; + + SHDOCVW_LockModule(); + return InterlockedIncrement( &This->ref ); } @@ -165,11 +186,15 @@ { IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface; DWORD ref = InterlockedDecrement( &This->ref ); + if( !ref ) { DestroyWindow( This->hDialog ); HeapFree( GetProcessHeap(), 0, This ); } + + SHDOCVW_UnlockModule(); + return ref; } _____ Modified: trunk/reactos/lib/shdocvw/webbrowser.c --- trunk/reactos/lib/shdocvw/webbrowser.c 2005-02-13 23:03:17 UTC (rev 13550) +++ trunk/reactos/lib/shdocvw/webbrowser.c 2005-02-13 23:10:36 UTC (rev 13551) @@ -29,27 +29,25 @@ static HRESULT WINAPI WB_QueryInterface(IWebBrowser *iface, REFIID riid, LPVOID *ppobj) { - IWebBrowserImpl *This = (IWebBrowserImpl *)iface; + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); - FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj); + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WB_AddRef(IWebBrowser *iface) { - IWebBrowserImpl *This = (IWebBrowserImpl *)iface; + SHDOCVW_LockModule(); - TRACE("\n"); - return ++(This->ref); + return 2; /* non-heap based object */ } static ULONG WINAPI WB_Release(IWebBrowser *iface) { - IWebBrowserImpl *This = (IWebBrowserImpl *)iface; + SHDOCVW_UnlockModule(); - /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + return 1; /* non-heap based object */ } /* IDispatch methods */ @@ -277,4 +275,4 @@ WB_get_Busy }; -IWebBrowserImpl SHDOCVW_WebBrowser = { &WB_Vtbl, 1 }; +IWebBrowserImpl SHDOCVW_WebBrowser = {&WB_Vtbl};
19 years, 10 months
1
0
0
0
[ea] 13550: Resource script uses the new generic rc script.
by ea@svn.reactos.com
Resource script uses the new generic rc script. Modified: trunk/posix/server/misc/psxss.rc _____ Modified: trunk/posix/server/misc/psxss.rc --- trunk/posix/server/misc/psxss.rc 2005-02-13 23:01:33 UTC (rev 13549) +++ trunk/posix/server/misc/psxss.rc 2005-02-13 23:03:17 UTC (rev 13550) @@ -1,39 +1,4 @@ -#include <defines.h> -#include <reactos/resource.h> - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -VS_VERSION_INFO VERSIONINFO - FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUI LD - PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUI LD - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", RES_STR_COMPANY_NAME - VALUE "FileDescription", "POSIX+ Environment Subsystem Server\0" - VALUE "FileVersion", RES_STR_FILE_VERSION - VALUE "InternalName", "psxss\0" - VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT - VALUE "OriginalFilename", "psxss.exe\0" - VALUE "ProductName", RES_STR_PRODUCT_NAME - VALUE "ProductVersion", RES_STR_PRODUCT_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -/* EOF */ +#define REACTOS_STR_FILE_DESCRIPTION "POSIX+ Environment Subsystem Server\0" +#define REACTOS_STR_INTERNAL_NAME "psxss\0" +#define REACTOS_STR_ORIGINAL_FILENAME "psxss.exe\0" +#include <reactos/version.rc>
19 years, 10 months
1
0
0
0
[weiden] 13549: don't return value of uninitialized variable
by weiden@svn.reactos.com
don't return value of uninitialized variable Modified: trunk/reactos/drivers/fs/ntfs/fcb.c _____ Modified: trunk/reactos/drivers/fs/ntfs/fcb.c --- trunk/reactos/drivers/fs/ntfs/fcb.c 2005-02-13 22:56:12 UTC (rev 13548) +++ trunk/reactos/drivers/fs/ntfs/fcb.c 2005-02-13 23:01:33 UTC (rev 13549) @@ -254,6 +254,7 @@ KEBUGCHECK(0); } #else + Status = STATUS_SUCCESS; CcInitializeCacheMap(FileObject, (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize), FALSE,
19 years, 10 months
1
0
0
0
[weiden] 13548: don't return value of uninitialized variable
by weiden@svn.reactos.com
don't return value of uninitialized variable Modified: trunk/reactos/drivers/fs/cdfs/fcb.c _____ Modified: trunk/reactos/drivers/fs/cdfs/fcb.c --- trunk/reactos/drivers/fs/cdfs/fcb.c 2005-02-13 22:55:28 UTC (rev 13547) +++ trunk/reactos/drivers/fs/cdfs/fcb.c 2005-02-13 22:56:12 UTC (rev 13548) @@ -250,6 +250,7 @@ KEBUGCHECK(0); } #else + Status = STATUS_SUCCESS; CcInitializeCacheMap(FileObject, (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize), FALSE,
19 years, 10 months
1
0
0
0
[ea] 13547: SM - some more work
by ea@svn.reactos.com
SM - some more work Modified: trunk/reactos/subsys/smss/client.c Modified: trunk/reactos/subsys/smss/init.c Modified: trunk/reactos/subsys/smss/smapi.c Modified: trunk/reactos/subsys/smss/smss.c Modified: trunk/reactos/subsys/smss/smss.h _____ Modified: trunk/reactos/subsys/smss/client.c --- trunk/reactos/subsys/smss/client.c 2005-02-13 22:54:35 UTC (rev 13546) +++ trunk/reactos/subsys/smss/client.c 2005-02-13 22:55:28 UTC (rev 13547) @@ -27,20 +27,12 @@ #include <ntos.h> #include "smss.h" +#define NDEBUG +#include <debug.h> + /* Private ADT */ -typedef struct _SM_CLIENT_DATA -{ - USHORT SubsystemId; - BOOL Initialized; - HANDLE ServerProcess; - HANDLE ApiPort; - HANDLE SbApiPort; - struct _SM_CLIENT_DATA * Next; - -} SM_CLIENT_DATA, *PSM_CLIENT_DATA; - struct _SM_CLIENT_DIRECTORY { RTL_CRITICAL_SECTION Lock; @@ -55,6 +47,7 @@ NTSTATUS SmInitializeClientManagement (VOID) { + DPRINT("SM: %s called\n", __FUNCTION__); RtlInitializeCriticalSection(& SmpClientDirectory.Lock); SmpClientDirectory.Count = 0; SmpClientDirectory.Client = NULL; @@ -64,22 +57,24 @@ /********************************************************************** * SmpLookupClient/1 */ -PSM_CLIENT_DATA STDCALL +static PSM_CLIENT_DATA STDCALL SmpLookupClient (USHORT SubsystemId) { PSM_CLIENT_DATA Client = NULL; + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); if (SmpClientDirectory.Count > 0) { - RtlEnterCriticalSection (& SmpClientDirectory.Lock); Client = SmpClientDirectory.Client; - while (NULL != Client->Next) + while (NULL != Client) { if (SubsystemId == Client->SubsystemId) break; Client = Client->Next; } - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); } + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); return Client; } @@ -87,14 +82,17 @@ * SmpCreateClient/1 */ NTSTATUS STDCALL -SmpCreateClient(SM_PORT_MESSAGE Request) +SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData) { PSM_CLIENT_DATA pClient = NULL; + PSM_CONNECT_DATA ConnectData = (PSM_CONNECT_DATA) ((PBYTE) Request) + sizeof (LPC_REQUEST); + DPRINT("SM: %s called\n", __FUNCTION__); + /* * Check if a client for the ID already exist. */ - if (SmpLookupClient(0)) //FIXME + if (SmpLookupClient(ConnectData->Subsystem)) { DbgPrint("SMSS: %s: attempt to register again subsystem %d.\n",__FUNCTION__,0); return STATUS_UNSUCCESSFUL; @@ -105,11 +103,15 @@ pClient = RtlAllocateHeap (SmpHeap, HEAP_ZERO_MEMORY, sizeof (SM_CLIENT_DATA)); - if (NULL == pClient) return STATUS_NO_MEMORY; + if (NULL == pClient) + { + DPRINT("SM: %s: out of memory!\n",__FUNCTION__); + return STATUS_NO_MEMORY; + } /* * Initialize the client data */ -// pClient->SubsystemId = Request->Subsystem; + pClient->SubsystemId = ConnectData->Subsystem; pClient->Initialized = FALSE; // TODO /* @@ -128,8 +130,10 @@ pCD = pCD->Next); pCD->Next = pClient; } + pClient->Next = NULL; ++ SmpClientDirectory.Count; RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + if (ClientData) *ClientData = pClient; return STATUS_SUCCESS; } @@ -137,8 +141,10 @@ * SmpDestroyClient/1 */ NTSTATUS STDCALL -SmpDestroyClient (ULONG SubsystemId) +SmDestroyClient (ULONG SubsystemId) { + DPRINT("SM: %s called\n", __FUNCTION__); + RtlEnterCriticalSection (& SmpClientDirectory.Lock); /* TODO */ RtlLeaveCriticalSection (& SmpClientDirectory.Lock); _____ Modified: trunk/reactos/subsys/smss/init.c --- trunk/reactos/subsys/smss/init.c 2005-02-13 22:54:35 UTC (rev 13546) +++ trunk/reactos/subsys/smss/init.c 2005-02-13 22:55:28 UTC (rev 13547) @@ -98,7 +98,7 @@ }; NTSTATUS -InitSessionManager(HANDLE Children[]) +InitSessionManager(VOID) { int i; NTSTATUS Status; _____ Modified: trunk/reactos/subsys/smss/smapi.c --- trunk/reactos/subsys/smss/smapi.c 2005-02-13 22:54:35 UTC (rev 13546) +++ trunk/reactos/subsys/smss/smapi.c 2005-02-13 22:55:28 UTC (rev 13547) @@ -1,19 +1,16 @@ /* $Id$ * + * smapi.c - \SmApiPort LPC port message management + * * Reactos Session Manager * - * */ -/*#include <ddk/ntddk.h> -#include <ntdll/rtl.h>*/ -#define NTOS_MODE_USER -#include <ntos.h> -#include <sm/api.h> +#include "smss.h" #include <rosrtl/string.h> -#include "smss.h" #define NDEBUG +#include <debug.h> /* GLOBAL VARIABLES *********************************************************/ @@ -26,20 +23,20 @@ SMAPI(SmInvalid) { - DbgPrint("SMSS: %s called\n",__FUNCTION__); + DPRINT("SM: %s called\n",__FUNCTION__); Request->Status = STATUS_NOT_IMPLEMENTED; return STATUS_SUCCESS; } SMAPI(SmCompSes) { - DbgPrint("SMSS: %s called\n",__FUNCTION__); + DPRINT("SM: %s called\n",__FUNCTION__); Request->Status = STATUS_NOT_IMPLEMENTED; return STATUS_SUCCESS; } SMAPI(SmExecPgm) { - DbgPrint("SMSS: %s called\n",__FUNCTION__); + DPRINT("SM: %s called\n",__FUNCTION__); Request->Status = STATUS_NOT_IMPLEMENTED; return STATUS_SUCCESS; } @@ -67,8 +64,54 @@ NTSTATUS STDCALL SmpHandleConnectionRequest (HANDLE Port, PSM_PORT_MESSAGE Request) { - DbgPrint("SMSS: %s called\n",__FUNCTION__); - return STATUS_SUCCESS; + NTSTATUS Status = STATUS_SUCCESS; + PSM_CLIENT_DATA ClientData = NULL; + PVOID Context = NULL; + + DPRINT("SM: %s called\n",__FUNCTION__); + + Status = SmCreateClient (Request, & ClientData); + if(STATUS_SUCCESS == Status) + { +#ifdef __USE_NT_LPC__ + Status = NtAcceptConnectPort (& ClientData->ApiPort, + Context, + SmApiPort, + TRUE, //accept + NULL, + NULL); +#else + Status = NtAcceptConnectPort (& ClientData->ApiPort, + Context, + (PLPC_MESSAGE) Request, + TRUE, //accept + NULL, + NULL); +#endif + if(NT_SUCCESS(Status)) + { + Status = NtCompleteConnectPort(ClientData->ApiPort); + } + return STATUS_SUCCESS; + } else { + /* Reject the subsystem */ +#ifdef __USE_NT_LPC__ + Status = NtAcceptConnectPort (& ClientData->ApiPort, + Context, + SmApiPort, + FALSE, //reject + NULL, + NULL); +#else + Status = NtAcceptConnectPort (& ClientData->ApiPort, + Context, + (PLPC_MESSAGE) Request, + FALSE, //reject + NULL, + NULL); +#endif + } + return Status; } /********************************************************************** @@ -82,23 +125,25 @@ SmpApiThread(HANDLE Port) { NTSTATUS Status = STATUS_SUCCESS; - ULONG Unknown = 0; + PVOID Unknown = NULL; PLPC_MESSAGE Reply = NULL; SM_PORT_MESSAGE Request = {{0}}; - DbgPrint("SMSS: %s running.\n",__FUNCTION__); + DPRINT("SM: %s running\n",__FUNCTION__); while (TRUE) { - DbgPrint("SMSS: %s: waiting for message\n",__FUNCTION__); + DPRINT("SM: %s: waiting for message\n",__FUNCTION__); Status = NtReplyWaitReceivePort(Port, - & Unknown, + (PULONG) & Unknown, Reply, (PLPC_MESSAGE) & Request); if (NT_SUCCESS(Status)) { - DbgPrint("SMSS: %s: message received\n",__FUNCTION__); + DPRINT("SM: %s: message received (type=%d)\n", + __FUNCTION__, + PORT_MESSAGE_TYPE(Request)); switch (Request.Header.MessageType) { _____ Modified: trunk/reactos/subsys/smss/smss.c --- trunk/reactos/subsys/smss/smss.c 2005-02-13 22:54:35 UTC (rev 13546) +++ trunk/reactos/subsys/smss/smss.c 2005-02-13 22:55:28 UTC (rev 13547) @@ -36,7 +36,7 @@ { NTSTATUS Status; - Status = InitSessionManager(Children); + Status = InitSessionManager(); if (!NT_SUCCESS(Status)) { int i; _____ Modified: trunk/reactos/subsys/smss/smss.h --- trunk/reactos/subsys/smss/smss.h 2005-02-13 22:54:35 UTC (rev 13546) +++ trunk/reactos/subsys/smss/smss.h 2005-02-13 22:55:28 UTC (rev 13547) @@ -4,15 +4,16 @@ #define NTOS_MODE_USER #include <ntos.h> #include <sm/api.h> +#include <sm/helper.h> #define CHILD_CSRSS 0 #define CHILD_WINLOGON 1 /* init.c */ -extern HANDLE SmpHeap; -NTSTATUS InitSessionManager(HANDLE Children[]); +NTSTATUS InitSessionManager(VOID); /* initheap.c */ +extern HANDLE SmpHeap; NTSTATUS SmCreateHeap(VOID); /* initenv.c */ @@ -53,9 +54,20 @@ VOID STDCALL SmpApiThread(HANDLE Port); /* client.c */ +typedef struct _SM_CLIENT_DATA +{ + USHORT SubsystemId; + BOOL Initialized; + HANDLE ServerProcess; + HANDLE ApiPort; + HANDLE SbApiPort; + WCHAR SbApiPortName [SM_SB_NAME_MAX_LENGTH]; + struct _SM_CLIENT_DATA * Next; + +} SM_CLIENT_DATA, *PSM_CLIENT_DATA; NTSTATUS SmInitializeClientManagement(VOID); -NTSTATUS STDCALL SmpCreateClient(SM_PORT_MESSAGE); -NTSTATUS STDCALL SmpDestroyClient(ULONG); +NTSTATUS STDCALL SmCreateClient(PSM_PORT_MESSAGE,PSM_CLIENT_DATA*); +NTSTATUS STDCALL SmDestroyClient(ULONG); /* debug.c */ extern HANDLE DbgSsApiPort;
19 years, 10 months
1
0
0
0
← Newer
1
...
21
22
23
24
25
26
27
...
42
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
Results per page:
10
25
50
100
200