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
November 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
16 participants
324 discussions
Start a n
N
ew thread
[ion] 24737: - FSTUB Patch for Mount Manager Support, Part 1: - Create new /fstub directory in the kernel tree and move iomgr's xhal functions there. - Delete disk.c entirely from iomgr.c and spread it across fstub. - Entirely reimplement from scratch IoWritePartitionTable, IoReadPartitionTable, IoSetPartitionInformation, HalExamineMbr. Lots of bug fixes in terms of wrong assumptions and compatibility with weird partition tables. - Fix prototype of IoAssignDriveLetters, but for now, keep the old
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:51:06 2006 New Revision: 24737 URL:
http://svn.reactos.org/svn/reactos?rev=24737&view=rev
Log: - FSTUB Patch for Mount Manager Support, Part 1: - Create new /fstub directory in the kernel tree and move iomgr's xhal functions there. - Delete disk.c entirely from iomgr.c and spread it across fstub. - Entirely reimplement from scratch IoWritePartitionTable, IoReadPartitionTable, IoSetPartitionInformation, HalExamineMbr. Lots of bug fixes in terms of wrong assumptions and compatibility with weird partition tables. - Fix prototype of IoAssignDriveLetters, but for now, keep the old code (xHalIoAssignDriveLetters) because this has not been rewritten yet. - Move some functions to fstubex.c for future implementation, and some to volume.c. Move the HAL table to halstub.c - Make use of the hal.h file commited earlier. - Move IoAssignDriveLetters from halfuncs to iofuncs.h - Implement missing functions in HAL (IoRead/Write/Set PartitionInfo) and make them call into the ntoskrnl exports. Added: trunk/reactos/ntoskrnl/fstub/ trunk/reactos/ntoskrnl/fstub/disksup.c trunk/reactos/ntoskrnl/fstub/fstubex.c trunk/reactos/ntoskrnl/fstub/halstub.c Modified: trunk/reactos/hal/hal/hal.c trunk/reactos/hal/hal/hal.def trunk/reactos/hal/halx86/generic/drive.c trunk/reactos/hal/halx86/include/hal.h trunk/reactos/include/ndk/halfuncs.h trunk/reactos/include/ndk/iofuncs.h trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h trunk/reactos/ntoskrnl/io/iomgr/disk.c trunk/reactos/ntoskrnl/io/iomgr/volume.c trunk/reactos/ntoskrnl/ntoskrnl.def trunk/reactos/ntoskrnl/ntoskrnl.rbuild [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/hal/hal/hal.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/hal/hal.c?rev=24737&r1…
Modified: trunk/reactos/hal/hal/hal.def URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/hal/hal.def?rev=24737&…
Modified: trunk/reactos/hal/halx86/generic/drive.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/drive.c…
Modified: trunk/reactos/hal/halx86/include/hal.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/hal.h?r…
Modified: trunk/reactos/include/ndk/halfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/halfuncs.h?rev…
Modified: trunk/reactos/include/ndk/iofuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/iofuncs.h?rev=…
Added: trunk/reactos/ntoskrnl/fstub/disksup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/disksup.c?r…
Added: trunk/reactos/ntoskrnl/fstub/fstubex.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/fstubex.c?r…
Added: trunk/reactos/ntoskrnl/fstub/halstub.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/halstub.c?r…
Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
Modified: trunk/reactos/ntoskrnl/io/iomgr/disk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/disk.c?r…
Modified: trunk/reactos/ntoskrnl/io/iomgr/volume.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/volume.c…
Modified: trunk/reactos/ntoskrnl/ntoskrnl.def URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.def?rev=…
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
18 years, 1 month
1
0
0
0
[ion] 24736: - Move out SEH-support routines from ntoskrnl/rtl to lib/rtl - Re-implement the routines in intel syntax and also cleanup the formatting. - Also re-implement the way the routines work, by following Matt Pietrek's c code that he wrote in one of his articles after looking at the disassembly. - Also used a patch for mingw found on Google which contained some implementations in C. - New changes mostly add protection during unwinding, faster speed, and add implementations for __except_ha
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:43:43 2006 New Revision: 24736 URL:
http://svn.reactos.org/svn/reactos?rev=24736&view=rev
Log: - Move out SEH-support routines from ntoskrnl/rtl to lib/rtl - Re-implement the routines in intel syntax and also cleanup the formatting. - Also re-implement the way the routines work, by following Matt Pietrek's c code that he wrote in one of his articles after looking at the disassembly. - Also used a patch for mingw found on Google which contained some implementations in C. - New changes mostly add protection during unwinding, faster speed, and add implementations for __except_handler2 and _abnormal_termination which were not previously present. Added: trunk/reactos/lib/rtl/i386/seh.s Removed: trunk/reactos/ntoskrnl/rtl/i386/ Modified: trunk/reactos/lib/rtl/i386/except_asm.s trunk/reactos/lib/rtl/rtl.rbuild trunk/reactos/ntoskrnl/ntoskrnl.rbuild Modified: trunk/reactos/lib/rtl/i386/except_asm.s URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/i386/except_asm.s?…
============================================================================== --- trunk/reactos/lib/rtl/i386/except_asm.s (original) +++ trunk/reactos/lib/rtl/i386/except_asm.s Mon Nov 13 01:43:43 2006 @@ -1,10 +1,9 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS NT Library - * FILE: lib/rtl/i386/except.S + * PROJECT: ReactOS Runtime Library (RTL) + * FILE: lib/rtl/i386/except_asm.S * PURPOSE: User-mode exception support for IA-32 * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - * Casper S. Hornstrup (chorns(a)users.sourceforge.net) */ /* INCLUDES ******************************************************************/ @@ -16,7 +15,7 @@ #define ExceptionNestedException 2 #define ExceptionCollidedUnwind 3 -/* FUNCTIONS ****************************************************************/ +/* FUNCTIONS *****************************************************************/ .func RtlpGetExceptionList@0 .globl _RtlpGetExceptionList@0 Added: trunk/reactos/lib/rtl/i386/seh.s URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/i386/seh.s?rev=247…
============================================================================== --- trunk/reactos/lib/rtl/i386/seh.s (added) +++ trunk/reactos/lib/rtl/i386/seh.s Mon Nov 13 01:43:43 2006 @@ -1,0 +1,468 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT + * FILE: lib/crt/misc/i386/seh.S + * PURPOSE: SEH Support for the CRT + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <ndk/asm.h> +.intel_syntax noprefix + +#define DISPOSITION_DISMISS 0 +#define DISPOSITION_CONTINUE_SEARCH 1 +#define DISPOSITION_COLLIDED_UNWIND 3 + +/* GLOBALS *******************************************************************/ + +.globl __global_unwind2 +.globl __local_unwind2 +.globl __abnormal_termination +.globl __except_handler2 +.globl __except_handler3 + +/* FUNCTIONS *****************************************************************/ + +.func unwind_handler +_unwind_handler: + + /* Check if we were unwinding and continue search if not */ + mov ecx, [esp+4] + test dword ptr [ecx+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + mov eax, DISPOSITION_CONTINUE_SEARCH + jz unwind_handler_return + + /* We have a collision, do a local unwind */ + mov eax, [esp+20] + push ebp + mov ebp, [eax+16] + mov edx, [eax+40] + push edx + mov edx, [eax+36] + push edx + call __local_unwind2 + add esp, 8 + pop ebp + + /* Set new try level */ + mov eax, [esp+8] + mov edx, [esp+16] + mov [edx], eax + + /* Return collided unwind */ + mov eax, DISPOSITION_COLLIDED_UNWIND + +unwind_handler_return: + ret +.endfunc + +.func _global_unwind2 +__global_unwind2: + + /* Create stack and save all registers */ + push ebp + mov ebp, esp + push ebx + push esi + push edi + push ebp + + /* Call unwind */ + push 0 + push 0 + push glu_return + push [ebp+8] + call _RtlUnwind@16 + +glu_return: + /* Restore registers and return */ + pop ebp + pop esi + pop edi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +.func _abnormal_termination +__abnormal_termination: + + /* Assume false */ + xor eax, eax + + /* Check if the handler is the unwind handler */ + mov ecx, fs:0 + cmp dword ptr [ecx+4], offset _unwind_handler + jne short ab_return + + /* Get the try level */ + mov edx, [ecx+12] + mov edx, [edx+12] + + /* Compare it */ + cmp [ecx+8], edx + jne ab_return + + /* Return true */ + mov eax, 1 + + /* Return */ +ab_return: + ret +.endfunc + +.func _local_unwind2 +__local_unwind2: + + /* Save volatiles */ + push ebx + push esi + push edi + + /* Get the exception registration */ + mov eax, [esp+16] + + /* Setup SEH to protect the unwind */ + push ebp + push eax + push -2 + push offset _unwind_handler + push fs:0 + mov fs:0, esp + +unwind_loop: + /* Get the exception registration and try level */ + mov eax, [esp+36] + mov ebx, [eax+8] + mov esi, [eax+12] + + /* Validate the unwind */ + cmp esi, -1 + je unwind_return + cmp dword ptr [esp+40], -1 + je unwind_ok + cmp esi, [esp+40] + jbe unwind_return + +unwind_ok: + /* Get the new enclosing level and save it */ + lea esi, [esi+esi*2] + mov ecx, [ebx+esi*4] + mov [esp+8], ecx + mov [eax+12], ecx + + /* Check the filter type */ + cmp dword ptr [ebx+esi*4+4], 0 + jnz __NLG_Return2 + + /* FIXME: NLG Notification */ + + /* Call the handler */ + call dword ptr [ebx+esi*4+8] + +__NLG_Return2: + /* Unwind again */ + jmp unwind_loop + +unwind_return: + /* Cleanup SEH */ + pop fs:0 + add esp, 16 + pop edi + pop esi + pop ebx + ret +.endfunc + +.func _except_handler2 +__except_handler2: + + /* Setup stack and save volatiles */ + push ebp + mov ebp, esp + sub esp, 8 + push ebx + push esi + push edi + push ebp + + /* Clear direction flag */ + cld + + /* Get exception registration and record */ + mov ebx, [ebp+12] + mov eax, [ebp+8] + + /* Check if this is an unwind */ + test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + jnz except_unwind2 + + /* Save exception pointers structure */ + mov [ebp-8], eax + mov eax, [ebp+16] + mov [ebp-4], eax + lea eax, [ebp-8] + mov [ebx+20], eax + + /* Get the try level and scope table */ + mov esi, [ebx+12] + mov esi, [ebx+8] + +except_loop2: + /* Validate try level */ + cmp esi, -1 + je except_search2 + + /* Check if this is the termination handler */ + lea ecx, [esi+esi*2] + cmp dword ptr [edi+ecx*4+4], 0 + jz except_continue2 + + /* Save registers and call filter, then restore them */ + push esi + push ebp + mov ebp, [ebx+16] + call dword ptr [edi+ecx*4+4] + pop ebp + pop esi + + /* Restore ebx and check the result */ + mov ebx, [ebp+12] + or eax, eax + jz except_continue2 + jz except_dismiss2 + + /* So this is an accept, call the termination handlers */ + mov edi, [ebx+8] + push ebx + call __global_unwind2 + add esp, 4 + + /* Restore ebp */ + mov ebp, [ebx+16] + + /* Do local unwind */ + push esi + push ebx + call __local_unwind2 + add esp, 8 + + /* Set new try level */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4] + mov [ebx+12], eax + + /* Call except handler */ + call [edi+ecx*4+8] + +except_continue2: + /* Reload try level and except again */ + mov edi, [ebx+8] + lea ecx, [esi+esi*2] + mov esi, [edi+ecx*4] + jmp except_loop2 + +except_dismiss2: + /* Dismiss it */ + mov eax, DISPOSITION_DISMISS + jmp except_return2 + +except_search2: + /* Continue searching */ + mov eax, DISPOSITION_CONTINUE_SEARCH + jmp except_return2 + + /* Do local unwind */ +except_unwind2: + push ebp + mov ebp, [ebx+16] + push -1 + push ebx + call __local_unwind2 + add esp, 8 + + /* Retore EBP and set return disposition */ + pop ebp + mov eax, DISPOSITION_CONTINUE_SEARCH + +except_return2: + /* Restore registers and stack */ + pop ebp + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +.func _except_handler3 +__except_handler3: + + /* Setup stack and save volatiles */ + push ebp + mov ebp, esp + sub esp, 8 + push ebx + push esi + push edi + push ebp + + /* Clear direction flag */ + cld + + /* Get exception registration and record */ + mov ebx, [ebp+12] + mov eax, [ebp+8] + + /* Check if this is an unwind */ + test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + jnz except_unwind3 + + /* Save exception pointers structure */ + mov [ebp-8], eax + mov eax, [ebp+16] + mov [ebp-4], eax + lea eax, [ebp-8] + mov [ebx-4], eax + + /* Get the try level and scope table */ + mov esi, [ebx+12] + mov esi, [ebx+8] + + /* FIXME: Validate the SEH exception */ + +except_loop3: + /* Validate try level */ + cmp esi, -1 + je except_search3 + + /* Check if this is the termination handler */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4+4] + or eax, eax + jz except_continue3 + + /* Save registers clear them all */ + push esi + push ebp + lea ebp, [ebx+16] + xor ebx, ebx + xor ecx, ecx + xor edx, edx + xor esi, esi + xor edi, edi + + /* Call the filter and restore our registers */ + call eax + pop ebp + pop esi + + /* Restore ebx and check the result */ + mov ebx, [ebp+12] + or eax, eax + jz except_continue3 + jz except_dismiss3 + + /* So this is an accept, call the termination handlers */ + mov edi, [ebx+8] + push ebx + call __global_unwind2 + add esp, 4 + + /* Restore ebp */ + lea ebp, [ebx+16] + + /* Do local unwind */ + push esi + push ebx + call __local_unwind2 + add esp, 8 + + /* FIXME: Do NLG Notification */ + + /* Set new try level */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4] + mov [ebx+12], eax + + /* Clear registers and call except handler */ + mov eax, [edi+ecx*4+8] + xor ebx, ebx + xor ecx, ecx + xor edx, edx + xor esi, esi + xor edi, edi + call eax + +except_continue3: + /* Reload try level and except again */ + mov edi, [ebx+8] + lea ecx, [esi+esi*2] + mov esi, [edi+ecx*4] + jmp except_loop3 + +except_dismiss3: + /* Dismiss it */ + mov eax, DISPOSITION_DISMISS + jmp except_return3 + +except_search3: + /* Continue searching */ + mov eax, DISPOSITION_CONTINUE_SEARCH + jmp except_return3 + + /* Do local unwind */ +except_unwind3: + push ebp + mov ebp, [ebx+16] + push -1 + push ebx + call __local_unwind2 + add esp, 8 + + /* Retore EBP and set return disposition */ + pop ebp + mov eax, DISPOSITION_CONTINUE_SEARCH + +except_return3: + /* Restore registers and stack */ + pop ebp + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +// +// +// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME +// +// +.func RtlpGetStackLimits@8 +.globl _RtlpGetStackLimits@8 +_RtlpGetStackLimits@8: + + /* Get the current thread */ + mov eax, [fs:KPCR_CURRENT_THREAD] + + /* Get the stack limits */ + mov ecx, [eax+KTHREAD_STACK_LIMIT] + mov edx, [eax+KTHREAD_INITIAL_STACK] + sub edx, SIZEOF_FX_SAVE_AREA + + /* Return them */ + mov eax, [esp+4] + mov [eax], ecx + + mov eax, [esp+8] + mov [eax], edx + + /* return */ + ret 8 +.endfunc Modified: trunk/reactos/lib/rtl/rtl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/rtl.rbuild?rev=247…
============================================================================== --- trunk/reactos/lib/rtl/rtl.rbuild (original) +++ trunk/reactos/lib/rtl/rtl.rbuild Mon Nov 13 01:43:43 2006 @@ -35,6 +35,7 @@ <file>rtlmem.s</file> <file>pow_asm.s</file> <file>res_asm.s</file> + <file>seh.s</file> <file>sin_asm.s</file> <file>sqrt_asm.s</file> <file>tan_asm.s</file> Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Mon Nov 13 01:43:43 2006 @@ -326,12 +326,6 @@ <file>win32.c</file> </directory> <directory name="rtl"> - <if property="ARCH" value="i386"> - <directory name="i386"> - <file>exception.c</file> - <file>seh.s</file> - </directory> - </if> <file>libsupp.c</file> <file>misc.c</file> <file>strtok.c</file>
18 years, 1 month
1
0
0
0
[ion] 24735: - Implement IoSetCompletionRoutineEx, which is a safe way to set completion routines that almost all newer drivers will be using (XP+).
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:39:09 2006 New Revision: 24735 URL:
http://svn.reactos.org/svn/reactos?rev=24735&view=rev
Log: - Implement IoSetCompletionRoutineEx, which is a safe way to set completion routines that almost all newer drivers will be using (XP+). Modified: trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/io/iomgr/iocomp.c Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/io.h (original) +++ trunk/reactos/ntoskrnl/include/internal/io.h Mon Nov 13 01:39:09 2006 @@ -228,6 +228,16 @@ PVOID Context; IO_STATUS_BLOCK IoStatus; } IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET; + +// +// I/O Completion Context for IoSetIoCompletionRoutineEx +// +typedef struct _IO_UNLOAD_SAFE_COMPLETION_CONTEXT +{ + PDEVICE_OBJECT DeviceObject; + PVOID Context; + PIO_COMPLETION_ROUTINE CompletionRoutine; +} IO_UNLOAD_SAFE_COMPLETION_CONTEXT, *PIO_UNLOAD_SAFE_COMPLETION_CONTEXT; // // I/O Wrapper around the Executive Work Item Modified: trunk/reactos/ntoskrnl/io/iomgr/iocomp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iocomp.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iocomp.c (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iocomp.c Mon Nov 13 01:39:09 2006 @@ -33,6 +33,32 @@ /* PRIVATE FUNCTIONS *********************************************************/ +NTSTATUS +NTAPI +IopUnloadSafeCompletion(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + NTSTATUS Status; + PIO_UNLOAD_SAFE_COMPLETION_CONTEXT UnsafeContext = + (PIO_UNLOAD_SAFE_COMPLETION_CONTEXT)Context; + + /* Reference the device object */ + ObReferenceObject(UnsafeContext->DeviceObject); + + /* Call the completion routine */ + Status= UnsafeContext->CompletionRoutine(DeviceObject, + Irp, + UnsafeContext->Context); + + /* Dereference the device object */ + ObDereferenceObject(UnsafeContext->DeviceObject); + + /* Free our context */ + ExFreePool(UnsafeContext); + return Status; +} + VOID NTAPI IopFreeIoCompletionPacket(PIO_COMPLETION_PACKET Packet) @@ -187,7 +213,7 @@ } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI @@ -199,8 +225,27 @@ IN BOOLEAN InvokeOnError, IN BOOLEAN InvokeOnCancel) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PIO_UNLOAD_SAFE_COMPLETION_CONTEXT UnloadContext; + + /* Allocate the context */ + UnloadContext = ExAllocatePoolWithTag(NonPagedPool, + sizeof(*UnloadContext), + TAG('I', 'o', 'U', 's')); + if (!UnloadContext) return STATUS_INSUFFICIENT_RESOURCES; + + /* Set up the context */ + UnloadContext->DeviceObject = DeviceObject; + UnloadContext->Context = Context; + UnloadContext->CompletionRoutine = CompletionRoutine; + + /* Now set the completion routine */ + IoSetCompletionRoutine(Irp, + IopUnloadSafeCompletion, + UnloadContext, + InvokeOnSuccess, + InvokeOnError, + InvokeOnCancel); + return STATUS_SUCCESS; } NTSTATUS
18 years, 1 month
1
0
0
0
[ion] 24734: - Argh, another forgotten file. Too many local changes :(
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:37:52 2006 New Revision: 24734 URL:
http://svn.reactos.org/svn/reactos?rev=24734&view=rev
Log: - Argh, another forgotten file. Too many local changes :( Modified: trunk/reactos/ntoskrnl/include/internal/ps.h 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 Mon Nov 13 01:37:52 2006 @@ -366,6 +366,7 @@ PspLoadImageNotifyRoutine[PSP_MAX_LOAD_IMAGE_NOTIFY]; extern PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine; extern ULONG PspThreadNotifyRoutineCount; +extern BOOLEAN PsImageNotifyEnabled; extern PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout; extern PKWIN32_THREAD_CALLOUT PspW32ThreadCallout; extern PVOID PspSystemDllEntryPoint; @@ -378,6 +379,7 @@ extern GENERIC_MAPPING PspJobMapping; extern POBJECT_TYPE PsJobType; extern LARGE_INTEGER ShortPsLockDelay; +extern UNICODE_STRING PsNtDllPathName; extern LIST_ENTRY PriorityListHead[MAXIMUM_PRIORITY]; //
18 years, 1 month
1
0
0
0
[ion] 24733: - Apologies, forgot these two files for the Dbgk patch. - Adds PsNtDllPathName constant string since we use it in two place (PsLocateSystemDll and DbgkpCreateThread). - Adds PsImageNotifyEnabled boolean flag and sets it to true (although it should only be when a routine is installed, but ROS doesn't do this yet.
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:36:21 2006 New Revision: 24733 URL:
http://svn.reactos.org/svn/reactos?rev=24733&view=rev
Log: - Apologies, forgot these two files for the Dbgk patch. - Adds PsNtDllPathName constant string since we use it in two place (PsLocateSystemDll and DbgkpCreateThread). - Adds PsImageNotifyEnabled boolean flag and sets it to true (although it should only be when a routine is installed, but ROS doesn't do this yet. Modified: trunk/reactos/ntoskrnl/ps/notify.c trunk/reactos/ntoskrnl/ps/psmgr.c Modified: trunk/reactos/ntoskrnl/ps/notify.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/notify.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/ps/notify.c (original) +++ trunk/reactos/ntoskrnl/ps/notify.c Mon Nov 13 01:36:21 2006 @@ -11,10 +11,11 @@ #include <ntoskrnl.h> #define NDEBUG -#include <internal/debug.h> +#include <debug.h> /* GLOBALS *******************************************************************/ +BOOLEAN PsImageNotifyEnabled = TRUE; ULONG PspThreadNotifyRoutineCount; PCREATE_THREAD_NOTIFY_ROUTINE PspThreadNotifyRoutine[PSP_MAX_CREATE_THREAD_NOTIFY]; Modified: trunk/reactos/ntoskrnl/ps/psmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=24…
============================================================================== --- trunk/reactos/ntoskrnl/ps/psmgr.c (original) +++ trunk/reactos/ntoskrnl/ps/psmgr.c Mon Nov 13 01:36:21 2006 @@ -46,6 +46,9 @@ ANSI_STRING FastName = RTL_CONSTANT_STRING("KiFastSystemCall"); ANSI_STRING FastReturnName = RTL_CONSTANT_STRING("KiFastSystemCallRet"); ANSI_STRING InterruptName = RTL_CONSTANT_STRING("KiIntSystemCall"); + +UNICODE_STRING PsNtDllPathName = + RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll"); PHANDLE_TABLE PspCidTable; @@ -159,7 +162,6 @@ NTAPI PsLocateSystemDll(VOID) { - UNICODE_STRING DllName = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll"); OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; HANDLE FileHandle, SectionHandle; @@ -168,7 +170,11 @@ ULONG HardErrorResponse; /* Locate and open NTDLL to determine ImageBase and LdrStartup */ - InitializeObjectAttributes(&ObjectAttributes, &DllName, 0, NULL, NULL); + InitializeObjectAttributes(&ObjectAttributes, + &PsNtDllPathName, + 0, + NULL, + NULL); Status = ZwOpenFile(&FileHandle, FILE_READ_ACCESS, &ObjectAttributes, @@ -186,7 +192,7 @@ if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) { /* Raise a hard error */ - HardErrorParameters = (ULONG_PTR)&DllName; + HardErrorParameters = (ULONG_PTR)&PsNtDllPathName; NtRaiseHardError(Status, 1, 1,
18 years, 1 month
1
0
0
0
[ion] 24732: - Implement MmAddVerifierThunks, MmIsDriverVerifying, MmIsVerifierEnabled. - Not used by anything, these are for 3rd-party drivers and Driver Verifier.
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:34:28 2006 New Revision: 24732 URL:
http://svn.reactos.org/svn/reactos?rev=24732&view=rev
Log: - Implement MmAddVerifierThunks, MmIsDriverVerifying, MmIsVerifierEnabled. - Not used by anything, these are for 3rd-party drivers and Driver Verifier. Modified: trunk/reactos/ntoskrnl/mm/verifier.c Modified: trunk/reactos/ntoskrnl/mm/verifier.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/verifier.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/mm/verifier.c (original) +++ trunk/reactos/ntoskrnl/mm/verifier.c Mon Nov 13 01:34:28 2006 @@ -1,63 +1,190 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/mm/verifier.c - * PURPOSE: Driver Verifier functions - * - * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - */ +/* +* PROJECT: ReactOS Kernel +* LICENSE: GPL - See COPYING in the top level directory +* FILE: ntoskrnl/mm/verifier.c +* PURPOSE: Mm Driver Verifier Routines +* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ -/* INCLUDES *****************************************************************/ +/* INCLUDES ******************************************************************/ #include <ntoskrnl.h> +#define NDEBUG #include <internal/debug.h> +/* GLOBALS *******************************************************************/ -/* FUNCTIONS *****************************************************************/ +MM_DRIVER_VERIFIER_DATA MmVerifierData; +LIST_ENTRY MiVerifierDriverAddedThunkListHead; +KMUTANT MmSystemLoadLock; +ULONG MiActiveVerifierThunks; +extern LIST_ENTRY ModuleListHead; + +/* PRIVATE FUNCTIONS *********************************************************/ + +PLDR_DATA_TABLE_ENTRY +NTAPI +MiLookupDataTableEntry(IN PVOID Address) +{ + PLDR_DATA_TABLE_ENTRY LdrEntry, FoundEntry = NULL; + PLIST_ENTRY NextEntry; + PAGED_CODE(); + + /* Loop entries */ + NextEntry = ModuleListHead.Flink; + do + { + /* Get the loader entry */ + LdrEntry = CONTAINING_RECORD(NextEntry, + LDR_DATA_TABLE_ENTRY, + InLoadOrderLinks); + + /* Check if the address matches */ + if ((Address >= LdrEntry->DllBase) && + (Address < (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage))) + { + /* Found a match */ + FoundEntry = LdrEntry; + break; + } + + /* Move on */ + NextEntry = NextEntry->Flink; + } while(NextEntry != &ModuleListHead); + + /* Return the entry */ + return FoundEntry; +} + +/* PUBLIC FUNCTIONS **********************************************************/ /* - * @unimplemented + * @implemented */ NTSTATUS -STDCALL -MmAddVerifierThunks ( - IN PVOID ThunkBuffer, - IN ULONG ThunkBufferSize - ) +NTAPI +MmAddVerifierThunks(IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PDRIVER_VERIFIER_THUNK_PAIRS ThunkPairs, DriverThunkTable; + ULONG ThunkCount; + PDRIVER_SPECIFIED_VERIFIER_THUNKS ThunkTable; + PLDR_DATA_TABLE_ENTRY LdrEntry; + PVOID ModuleBase, ModuleEnd; + ULONG i; + NTSTATUS Status = STATUS_SUCCESS; + PAGED_CODE(); + + /* Make sure the driver verifier is initialized */ + if (!MiVerifierDriverAddedThunkListHead.Flink) return STATUS_NOT_SUPPORTED; + + /* Get the thunk pairs and count them */ + ThunkPairs = (PDRIVER_VERIFIER_THUNK_PAIRS)ThunkBuffer; + ThunkCount = ThunkBufferSize / sizeof(DRIVER_VERIFIER_THUNK_PAIRS); + if (!ThunkCount) return STATUS_INVALID_PARAMETER_1; + + /* Now allocate our own thunk table */ + ThunkTable = ExAllocatePoolWithTag(PagedPool, + sizeof(DRIVER_SPECIFIED_VERIFIER_THUNKS) + + ThunkCount * + sizeof(DRIVER_VERIFIER_THUNK_PAIRS), + TAG('M', 'm', 'V', 't')); + if (!ThunkTable) return STATUS_INSUFFICIENT_RESOURCES; + + /* Now copy the driver-fed part */ + DriverThunkTable = (PDRIVER_VERIFIER_THUNK_PAIRS)(ThunkTable + 1); + RtlCopyMemory(DriverThunkTable, + ThunkPairs, + ThunkCount * sizeof(DRIVER_VERIFIER_THUNK_PAIRS)); + + /* Acquire the system load lock */ + KeEnterCriticalRegion(); + KeWaitForSingleObject(&MmSystemLoadLock, + WrVirtualMemory, + KernelMode, + FALSE, + NULL); + + /* Get the loader entry */ + LdrEntry = MiLookupDataTableEntry(DriverThunkTable->PristineRoutine); + if (!LdrEntry) + { + /* Fail */ + Status = STATUS_INVALID_PARAMETER_2; + goto Cleanup; + } + + /* Get driver base and end */ + ModuleBase = LdrEntry->DllBase; + ModuleEnd = (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage); + + /* Loop all the thunks */ + for (i = 0; i < ThunkCount; i++) + { + /* Make sure it's in the driver */ + if (((ULONG_PTR)DriverThunkTable->PristineRoutine < (ULONG_PTR)ModuleBase) || + ((ULONG_PTR)DriverThunkTable->PristineRoutine >= (ULONG_PTR)ModuleEnd)) + { + /* Nope, fail */ + Status = STATUS_INVALID_PARAMETER_2; + goto Cleanup; + } + } + + /* Otherwise, add this entry */ + ThunkTable->DataTableEntry = LdrEntry; + ThunkTable->NumberOfThunks = ThunkCount; + MiActiveVerifierThunks++; + InsertTailList(&MiVerifierDriverAddedThunkListHead, + &ThunkTable->ListEntry); + ThunkTable = NULL; + +Cleanup: + /* Release the lock */ + KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE); + KeLeaveCriticalRegion(); + + /* Free the table if we failed and return status */ + ExFreePool(ThunkTable); + return Status; } +/* + * @implemented + */ +LOGICAL +NTAPI +MmIsDriverVerifying(IN PDRIVER_OBJECT DriverObject) +{ + PLDR_DATA_TABLE_ENTRY LdrEntry; + + /* Get the loader entry */ + LdrEntry = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection; + if (!LdrEntry) return FALSE; + + /* Check if we're verifying or not */ + return (LdrEntry->Flags & LDRP_DRIVER_VERIFYING) ? TRUE: FALSE; +} /* - * @unimplemented - */ - -ULONG -STDCALL -MmIsDriverVerifying ( - IN struct _DRIVER_OBJECT *DriverObject - ) -{ - UNIMPLEMENTED; - return 0; -} - - -/* - * @unimplemented + * @implemented */ NTSTATUS -STDCALL -MmIsVerifierEnabled ( - OUT PULONG VerifierFlags - ) +NTAPI +MmIsVerifierEnabled(OUT PULONG VerifierFlags) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + /* Check if we've actually added anything to the list */ + if (MiVerifierDriverAddedThunkListHead.Flink) + { + /* We have, read the verifier level */ + *VerifierFlags = MmVerifierData.Level; + return STATUS_SUCCESS; + } + + /* Otherwise, we're disabled */ + *VerifierFlags = 0; + return STATUS_NOT_SUPPORTED; } /* EOF */
18 years, 1 month
1
0
0
0
[ion] 24731: - Fix flags in DbgkpSectionToFileHandle - Implement DbgkpCreateThread. - Implement DbgkpSetProcessDebugObject.
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:33:04 2006 New Revision: 24731 URL:
http://svn.reactos.org/svn/reactos?rev=24731&view=rev
Log: - Fix flags in DbgkpSectionToFileHandle - Implement DbgkpCreateThread. - Implement DbgkpSetProcessDebugObject. 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 Mon Nov 13 01:33:04 2006 @@ -10,7 +10,7 @@ #include <ntoskrnl.h> #define NDEBUG -#include <internal/debug.h> +#include <debug.h> /* FUNCTIONS *****************************************************************/ @@ -32,7 +32,9 @@ /* Initialize object attributes */ InitializeObjectAttributes(&ObjectAttributes, &FileName, - OBJ_CASE_INSENSITIVE, + OBJ_CASE_INSENSITIVE | + OBJ_FORCE_ACCESS_CHECK | + OBJ_KERNEL_HANDLE, NULL, NULL); @@ -84,7 +86,209 @@ NTAPI DbgkCreateThread(PVOID StartAddress) { - /* FIXME */ + PETHREAD Thread = PsGetCurrentThread(); + PEPROCESS Process = PsGetCurrentProcess(); + ULONG ProcessFlags; + IMAGE_INFO ImageInfo; + PIMAGE_NT_HEADERS NtHeader; + UNICODE_STRING ModuleName; + NTSTATUS Status; + PVOID DebugPort; + DBGKM_MSG ApiMessage; + PDBGKM_CREATE_THREAD CreateThread = &ApiMessage.CreateThread; + PDBGKM_CREATE_PROCESS CreateProcess = &ApiMessage.CreateProcess; + PDBGKM_LOAD_DLL LoadDll = &ApiMessage.LoadDll; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + PTEB Teb; + PAGED_CODE(); + + /* Check if this process has already been notified */ + ProcessFlags = InterlockedAnd(&Process->Flags, + PSF_CREATE_REPORTED_BIT | + PSF_IMAGE_NOTIFY_DONE_BIT); + if (!(ProcessFlags & PSF_IMAGE_NOTIFY_DONE_BIT) && (PsImageNotifyEnabled)) + { + /* It hasn't.. set up the image info for the process */ + ImageInfo.Properties = 0; + ImageInfo.ImageAddressingMode = IMAGE_ADDRESSING_MODE_32BIT; + ImageInfo.ImageBase = Process->SectionBaseAddress; + ImageInfo.ImageSize = 0; + ImageInfo.ImageSelector = 0; + ImageInfo.ImageSectionNumber = 0; + + /* Get the NT Headers */ + NtHeader = RtlImageNtHeader(Process->SectionBaseAddress); + if (NtHeader) + { + /* Set image size */ + ImageInfo.ImageSize = NtHeader->OptionalHeader.SizeOfImage; + } + + /* Get the image name */ + Status = MmGetFileNameForSection(Process->SectionObject, &ModuleName); + if (NT_SUCCESS(Status)) + { + /* Call the notify routines and free the name */ + PspRunLoadImageNotifyRoutines(&ModuleName, + Process->UniqueProcessId, + &ImageInfo); + ExFreePool(ModuleName.Buffer); + } + else + { + /* Call the notify routines */ + PspRunLoadImageNotifyRoutines(NULL, + Process->UniqueProcessId, + &ImageInfo); + } + + /* Setup the info for ntdll.dll */ + ImageInfo.Properties = 0; + ImageInfo.ImageAddressingMode = IMAGE_ADDRESSING_MODE_32BIT; + ImageInfo.ImageBase = PspSystemDllBase; + ImageInfo.ImageSize = 0; + ImageInfo.ImageSelector = 0; + ImageInfo.ImageSectionNumber = 0; + + /* Get the NT Headers */ + NtHeader = RtlImageNtHeader(PspSystemDllBase); + if (NtHeader) + { + /* Set image size */ + ImageInfo.ImageSize = NtHeader->OptionalHeader.SizeOfImage; + } + + /* Call the notify routines */ + RtlInitUnicodeString(&ModuleName, + L"\\SystemRoot\\System32\\ntdll.dll"); + PspRunLoadImageNotifyRoutines(&ModuleName, + Process->UniqueProcessId, + &ImageInfo); + } + + /* Fail if we have no port */ + DebugPort = Process->DebugPort; + if (DebugPort) return; + + /* Check if create was not already reported */ + if (!(ProcessFlags & PSF_CREATE_REPORTED_BIT)) + { + /* Setup the information structure for the new thread */ + CreateThread->SubSystemKey = 0; + CreateThread->StartAddress = NULL; + + /* And for the new process */ + CreateProcess->SubSystemKey = 0; + CreateProcess->FileHandle = DbgkpSectionToFileHandle(Process-> + SectionObject); + CreateProcess->BaseOfImage = Process->SectionBaseAddress; + CreateProcess->DebugInfoFileOffset = 0; + CreateProcess->DebugInfoSize = 0; + + /* Get the NT Header */ + NtHeader = RtlImageNtHeader(Process->SectionBaseAddress); + if (NtHeader) + { + /* Fill out data from the header */ + CreateThread->StartAddress = (PVOID)((ULONG_PTR)NtHeader-> + OptionalHeader.ImageBase + + NtHeader->OptionalHeader. + AddressOfEntryPoint); + CreateProcess->DebugInfoFileOffset = NtHeader->FileHeader. + PointerToSymbolTable; + CreateProcess->DebugInfoSize = NtHeader->FileHeader. + NumberOfSymbols; + } + + /* Setup the API Message */ + ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 | + (8 + sizeof(DBGKM_CREATE_PROCESS)); + ApiMessage.h.u2.ZeroInit = LPC_DEBUG_EVENT; + ApiMessage.ApiNumber = DbgKmCreateProcessApi; + + /* Send the message */ + DbgkpSendApiMessage(&ApiMessage, FALSE); + + /* Close the handle */ + ObCloseHandle(CreateProcess->FileHandle, KernelMode); + + /* Setup the parameters */ + LoadDll->BaseOfDll = PspSystemDllBase; + LoadDll->DebugInfoFileOffset = 0; + LoadDll->DebugInfoSize = 0; + LoadDll->NamePointer = NULL; + + /* Get the NT Headers */ + NtHeader = RtlImageNtHeader(PspSystemDllBase); + if (NtHeader) + { + /* Fill out debug information */ + LoadDll->DebugInfoFileOffset = NtHeader-> + FileHeader.PointerToSymbolTable; + LoadDll->DebugInfoSize = NtHeader->FileHeader.NumberOfSymbols; + } + + /* Get the TEB */ + Teb = Thread->Tcb.Teb; + if (Teb) + { + /* Copy the system library name and link to it */ + wcsncpy(Teb->StaticUnicodeBuffer, + L"ntdll.dll", + sizeof(Teb->StaticUnicodeBuffer)); + Teb->Tib.ArbitraryUserPointer = Teb->StaticUnicodeBuffer; + + /* Return it in the debug event as well */ + LoadDll->NamePointer = Teb->Tib.ArbitraryUserPointer; + } + + /* Get a handle */ + InitializeObjectAttributes(&ObjectAttributes, + &PsNtDllPathName, + OBJ_CASE_INSENSITIVE | + OBJ_KERNEL_HANDLE | + OBJ_FORCE_ACCESS_CHECK, + NULL, + NULL); + Status = ZwOpenFile(&LoadDll->FileHandle, + GENERIC_READ | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_DELETE | + FILE_SHARE_READ | + FILE_SHARE_WRITE, + FILE_SYNCHRONOUS_IO_NONALERT); + if (NT_SUCCESS(Status)) + { + /* Setup the API Message */ + ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 | + (8 + sizeof(DBGKM_LOAD_DLL)); + ApiMessage.h.u2.ZeroInit = LPC_DEBUG_EVENT; + ApiMessage.ApiNumber = DbgKmLoadDllApi; + + /* Send the message */ + DbgkpSendApiMessage(&ApiMessage, TRUE); + + /* Close the handle */ + ObCloseHandle(LoadDll->FileHandle, KernelMode); + } + } + else + { + /* Otherwise, do it just for the thread */ + CreateThread->SubSystemKey = 0; + CreateThread->StartAddress = NULL; + + /* Setup the API Message */ + ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 | + (8 + sizeof(DBGKM_CREATE_THREAD)); + ApiMessage.h.u2.ZeroInit = LPC_DEBUG_EVENT; + ApiMessage.ApiNumber = DbgKmCreateThreadApi; + + /* Send the message */ + DbgkpSendApiMessage(&ApiMessage, TRUE); + } } 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 Mon Nov 13 01:33:04 2006 @@ -32,26 +32,6 @@ }; /* PRIVATE FUNCTIONS *********************************************************/ - -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; -} NTSTATUS NTAPI @@ -967,6 +947,159 @@ DebugEvent->Status = STATUS_DEBUGGER_INACTIVE; DbgkpWakeTarget(DebugEvent); } +} + +NTSTATUS +NTAPI +DbgkpSetProcessDebugObject(IN PEPROCESS Process, + IN PDEBUG_OBJECT DebugObject, + IN NTSTATUS MsgStatus, + IN PETHREAD LastThread) +{ + NTSTATUS Status; + LIST_ENTRY TempList; + BOOLEAN GlobalHeld = FALSE; + PETHREAD ThisThread, FirstThread; + PLIST_ENTRY NextEntry; + PAGED_CODE(); + + /* Initialize the temporary list */ + InitializeListHead(&TempList); + + /* Check if we have a success message */ + if (NT_SUCCESS(MsgStatus)) + { + /* Then default to STATUS_SUCCESS */ + Status = STATUS_SUCCESS; + } + else + { + /* No last thread, and set the failure code */ + LastThread = NULL; + Status = MsgStatus; + } + + /* Now check what status we have here */ + if (NT_SUCCESS(Status)) + { + /* Acquire the global lock */ + GlobalHeld = TRUE; + ExAcquireFastMutex(&DbgkpProcessDebugPortMutex); + + /* Check if we already have a port */ + if (Process->DebugPort) + { + /* Set failure */ + Status = STATUS_PORT_ALREADY_SET; + } + else + { +ThreadScan: + /* Otherwise, set the port and reference the thread */ + Process->DebugPort = DebugObject; + ObReferenceObject(LastThread); + + /* Get the next thread */ + ThisThread = PsGetNextProcessThread(Process, LastThread); + if (ThisThread) + { + /* Clear the debug port and release the lock */ + Process->DebugPort = NULL; + ExReleaseFastMutex(&DbgkpProcessDebugPortMutex); + GlobalHeld = FALSE; + + /* Dereference the thread */ + ObDereferenceObject(LastThread); + + /* Post fake messages */ + Status = DbgkpPostFakeThreadMessages(Process, + DebugObject, + ThisThread, + &FirstThread, + &LastThread); + if (!NT_SUCCESS(Status)) + { + /* Clear the last thread */ + LastThread = NULL; + } + else + { + /* Dereference the first thread and re-acquire the lock */ + ObDereferenceObject(FirstThread); + GlobalHeld = TRUE; + ExAcquireFastMutex(&DbgkpProcessDebugPortMutex); + + /* Check if we should loop again */ + if (!Process->DebugPort) goto ThreadScan; + + /* Otherwise, we already have a port */ + Status = STATUS_PORT_ALREADY_SET; + } + } + } + } + + /* Acquire the debug object's lock */ + ExAcquireFastMutex(&DebugObject->Mutex); + + /* Check our status here */ + if (NT_SUCCESS(Status)) + { + /* Check if we're disconnected */ + if (DebugObject->DebuggerInactive) + { + /* Set status */ + Process->DebugPort = NULL; + Status = STATUS_DEBUGGER_INACTIVE; + } + else + { + /* Set the process flags */ + InterlockedOr(&Process->Flags, PSF_NO_DEBUG_INHERIT_BIT | + PSF_CREATE_REPORTED_BIT); + + /* Reference the debug object */ + ObDereferenceObject(DebugObject); + } + } + + /* Loop the events list */ + NextEntry = DebugObject->EventList.Flink; + while (NextEntry != &DebugObject->EventList) + { + /* FIXME: TODO */ + KEBUGCHECK(0); + } + + /* Release the debug object */ + ExReleaseFastMutex(&DebugObject->Mutex); + + /* Release the global lock if acquired */ + if (GlobalHeld) ExReleaseFastMutex(&DbgkpProcessDebugPortMutex); + + /* Check if there's a thread to dereference */ + if (LastThread) ObDereferenceObject(LastThread); + + /* Loop our temporary list */ + NextEntry = TempList.Flink; + while (NextEntry != &TempList) + { + /* FIXME: TODO */ + KEBUGCHECK(0); + } + + /* Check if we got here through success and mark the PEB, then return */ + if (NT_SUCCESS(Status)) DbgkpMarkProcessPeb(Process); + return Status; +} + +NTSTATUS +NTAPI +DbgkClearProcessDebugObject(IN PEPROCESS Process, + IN PDEBUG_OBJECT SourceDebugObject) +{ + /* FIXME: TODO */ + return STATUS_UNSUCCESSFUL; } VOID
18 years, 1 month
1
0
0
0
[ion] 24730: - Cleanup fastio.c - Implement FsRtlMdlReadDev (this function is not called, no risk of regressions). - Move FsRtlAcquireFileExclusive and FsRtlReleaseFileExclusive from filelock.c to fastio.c. - Bugfix these functions to actually call FsRtlEnter/ExitFileSystem. - Huge cleanusp of filelock.c, but no code changes, except the usage of some simpler macros provided by NTIFS.H (with equivalent code).
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:31:45 2006 New Revision: 24730 URL:
http://svn.reactos.org/svn/reactos?rev=24730&view=rev
Log: - Cleanup fastio.c - Implement FsRtlMdlReadDev (this function is not called, no risk of regressions). - Move FsRtlAcquireFileExclusive and FsRtlReleaseFileExclusive from filelock.c to fastio.c. - Bugfix these functions to actually call FsRtlEnter/ExitFileSystem. - Huge cleanusp of filelock.c, but no code changes, except the usage of some simpler macros provided by NTIFS.H (with equivalent code). Modified: trunk/reactos/ntoskrnl/fs/fastio.c trunk/reactos/ntoskrnl/fs/filelock.c Modified: trunk/reactos/ntoskrnl/fs/fastio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fs/fastio.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/fs/fastio.c (original) +++ trunk/reactos/ntoskrnl/fs/fastio.c Mon Nov 13 01:31:45 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/fs/fastio.c * PURPOSE: File System Routines which support Fast I/O or Cc Access. - * - * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - */ - -/* INCLUDES ****************************************************************/ + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +/* INCLUDES ******************************************************************/ #include <ntoskrnl.h> #define NDEBUG @@ -19,6 +18,7 @@ extern ULONG CcFastReadResourceMiss; extern ULONG CcFastReadWait; extern ULONG CcFastReadNoWait; +ULONG CcFastMdlReadNotPossible; /* FUNCTIONS *****************************************************************/ @@ -26,8 +26,8 @@ * @implemented */ VOID -STDCALL -FsRtlIncrementCcFastReadResourceMiss( VOID ) +NTAPI +FsRtlIncrementCcFastReadResourceMiss(VOID) { CcFastReadResourceMiss++; } @@ -36,8 +36,8 @@ * @implemented */ VOID -STDCALL -FsRtlIncrementCcFastReadNotPossible( VOID ) +NTAPI +FsRtlIncrementCcFastReadNotPossible(VOID) { CcFastReadNotPossible++; } @@ -46,8 +46,8 @@ * @implemented */ VOID -STDCALL -FsRtlIncrementCcFastReadWait( VOID ) +NTAPI +FsRtlIncrementCcFastReadWait(VOID) { CcFastReadWait++; } @@ -56,86 +56,53 @@ * @implemented */ VOID -STDCALL -FsRtlIncrementCcFastReadNoWait( VOID ) +NTAPI +FsRtlIncrementCcFastReadNoWait(VOID) { CcFastReadNoWait++; } /* - * NAME EXPORTED - * FsRtlCopyRead@32 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * NOTE - * From Bo Branten's ntifs.h v12. - * * @unimplemented */ BOOLEAN -STDCALL -FsRtlCopyRead(IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, +NTAPI +FsRtlCopyRead(IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject) + IN PDEVICE_OBJECT DeviceObject) { UNIMPLEMENTED; return FALSE; } /* - * NAME EXPORTED - * FsRtlCopyWrite@32 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * NOTE - * From Bo Branten's ntifs.h v12. - * * @unimplemented */ BOOLEAN -STDCALL -FsRtlCopyWrite(IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, +NTAPI +FsRtlCopyWrite(IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject) + IN PDEVICE_OBJECT DeviceObject) { UNIMPLEMENTED; return FALSE; } /* - * NAME EXPORTED - * FsRtlGetFileSize@8 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * * @implemented */ NTSTATUS -STDCALL +NTAPI FsRtlGetFileSize(IN PFILE_OBJECT FileObject, IN OUT PLARGE_INTEGER FileSize) { @@ -182,19 +149,10 @@ } /* - * NAME EXPORTED - * FsRtlMdlRead@24 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @implemented - */ -BOOLEAN -STDCALL + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -244,19 +202,10 @@ } /* - * NAME EXPORTED - * FsRtlMdlReadComplete@8 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @implemented - */ -BOOLEAN -STDCALL + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject, IN OUT PMDL MdlChain) { @@ -291,25 +240,11 @@ return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject); } - -/* - * NAME EXPORTED - * FsRtlMdlReadCompleteDev@12 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * NOTE - * From Bo Branten's ntifs.h v13. - * (CcMdlReadCompleteDev declared in internal/cc.h) - * - * @implemented - */ -BOOLEAN -STDCALL +/* + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject, IN PMDL MdlChain, IN PDEVICE_OBJECT DeviceObject) @@ -320,19 +255,10 @@ } /* - * NAME EXPORTED - * FsRtlMdlReadDev@28 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @unimplemented - */ -BOOLEAN -STDCALL + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlReadDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -341,25 +267,115 @@ OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject) { - UNIMPLEMENTED; - return FALSE; -} - - -/* - * NAME EXPORTED - * FsRtlMdlWriteComplete@12 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @implemented - */ -BOOLEAN -STDCALL + PFSRTL_COMMON_FCB_HEADER FcbHeader; + BOOLEAN Result = TRUE; + LARGE_INTEGER Offset; + PFAST_IO_DISPATCH FastIoDispatch; + PDEVICE_OBJECT Device; + PAGED_CODE(); + + /* No actual read */ + if (!Length) + { + /* Return success */ + IoStatus->Status = STATUS_SUCCESS; + IoStatus->Information = 0; + return TRUE; + } + + /* Sanity check */ + ASSERT(MAXLONGLONG - FileOffset->QuadPart >= (LONGLONG)Length); + + /* Get the offset and FCB header */ + Offset.QuadPart = FileOffset->QuadPart + Length; + FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext; + + /* Enter the FS */ + FsRtlEnterFileSystem(); + CcFastMdlReadWait++; + + /* Lock the FCB */ + ExAcquireResourceShared(FcbHeader->Resource, TRUE); + + /* Check if this is a fast I/O cached file */ + if (!(FileObject->PrivateCacheMap) || + (FcbHeader->IsFastIoPossible == FastIoIsNotPossible)) + { + /* It's not, so fail */ + CcFastMdlReadNotPossible += 1; + Result = FALSE; + goto Cleanup; + } + + /* Check if we need to find out if fast I/O is available */ + if (FcbHeader->IsFastIoPossible == FastIoIsQuestionable) + { + /* Sanity check */ + ASSERT(!KeIsExecutingDpc()); + + /* Get the Fast I/O table */ + Device = IoGetRelatedDeviceObject(FileObject); + FastIoDispatch = Device->DriverObject->FastIoDispatch; + + /* Sanity check */ + ASSERT(FastIoDispatch != NULL); + ASSERT(FastIoDispatch->FastIoCheckIfPossible != NULL); + + /* Ask the driver if we can do it */ + if (!FastIoDispatch->FastIoCheckIfPossible(FileObject, + FileOffset, + Length, + TRUE, + LockKey, + TRUE, + IoStatus, + Device)) + { + /* It's not, fail */ + CcFastMdlReadNotPossible += 1; + Result = FALSE; + goto Cleanup; + } + } + + /* Check if we read too much */ + if (Offset.QuadPart > FcbHeader->FileSize.QuadPart) + { + /* We did, check if the file offset is past the end */ + if (FileOffset->QuadPart >= FcbHeader->FileSize.QuadPart) + { + /* Set end of file */ + IoStatus->Status = STATUS_END_OF_FILE; + IoStatus->Information = 0; + goto Cleanup; + } + + /* Otherwise, just normalize the length */ + Length = (ULONG)(FcbHeader->FileSize.QuadPart - FileOffset->QuadPart); + } + + /* Set this as top-level IRP */ + PsGetCurrentThread()->TopLevelIrp = FSRTL_FAST_IO_TOP_LEVEL_IRP; + + /* Attempt a read */ + CcMdlRead(FileObject, FileOffset, Length, MdlChain, IoStatus); + FileObject->Flags |= FO_FILE_FAST_IO_READ; + + /* Remove the top-level IRP flag */ + PsGetCurrentThread()->TopLevelIrp = 0; + + /* Return to caller */ +Cleanup: + ExReleaseResourceLite(FcbHeader->Resource); + FsRtlExitFileSystem(); + return Result; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain) @@ -400,19 +416,10 @@ } /* - * NAME EXPORTED - * FsRtlMdlWriteCompleteDev@16 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @implemented - */ -BOOLEAN -STDCALL + * @implemented + */ +BOOLEAN +NTAPI FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, @@ -423,25 +430,15 @@ return TRUE; } - -/* - * NAME EXPORTED - * FsRtlPrepareMdlWrite@24 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus) { @@ -487,23 +484,14 @@ } /* - * NAME EXPORTED - * FsRtlPrepareMdlWriteDev@28 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * * @unimplemented */ BOOLEAN -STDCALL -FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, +NTAPI +FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject) @@ -512,4 +500,79 @@ return FALSE; } +/* +* @implemented +*/ +VOID +NTAPI +FsRtlAcquireFileExclusive(IN PFILE_OBJECT FileObject) +{ + PFAST_IO_DISPATCH FastDispatch; + PDEVICE_OBJECT DeviceObject; + PFSRTL_COMMON_FCB_HEADER FcbHeader; + + /* Get the Device Object and fast dispatch */ + DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); + FastDispatch = DeviceObject->DriverObject->FastIoDispatch; + + /* Check if we have to do a Fast I/O Dispatch */ + if ((FastDispatch) && (FastDispatch->AcquireFileForNtCreateSection)) + { + /* Enter the file system and call it */ + FsRtlEnterFileSystem(); + FastDispatch->AcquireFileForNtCreateSection(FileObject); + return; + } + + /* Get the FCB Header */ + FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext; + if (FcbHeader->Resource) + { + /* Use a Resource Acquire */ + FsRtlEnterFileSystem(); + ExAcquireResourceExclusive(FcbHeader->Resource, TRUE); + } + + /* All done, return */ + return; +} + +/* +* @implemented +*/ +VOID +NTAPI +FsRtlReleaseFile(IN PFILE_OBJECT FileObject) +{ + PFAST_IO_DISPATCH FastDispatch; + PDEVICE_OBJECT DeviceObject; + PFSRTL_COMMON_FCB_HEADER FcbHeader; + + /* Get the Device Object */ + DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); + + FastDispatch = DeviceObject->DriverObject->FastIoDispatch; + + /* Check if we have to do a Fast I/O Dispatch */ + if ((FastDispatch) && (FastDispatch->ReleaseFileForNtCreateSection)) + { + /* Call the release function and exit the file system */ + FastDispatch->ReleaseFileForNtCreateSection(FileObject); + FsRtlExitFileSystem(); + return; + } + + /* Get the FCB Header */ + FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext; + if (FcbHeader->Resource) + { + /* Use a Resource release */ + ExReleaseResourceLite(FcbHeader->Resource); + FsRtlExitFileSystem(); + } + + /* All done, return */ + return; +} + /* EOF */ Modified: trunk/reactos/ntoskrnl/fs/filelock.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fs/filelock.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/fs/filelock.c (original) +++ trunk/reactos/ntoskrnl/fs/filelock.c Mon Nov 13 01:31:45 2006 @@ -25,14 +25,10 @@ NPAGED_LOOKASIDE_LIST LockTocLookaside; PAGED_LOOKASIDE_LIST LockLookaside; - - __inline BOOLEAN -IsOverlappingLock( - PFILE_LOCK_INFO Lock, - PLARGE_INTEGER StartOffset, - PLARGE_INTEGER EndOffset - ) +IsOverlappingLock(PFILE_LOCK_INFO Lock, + PLARGE_INTEGER StartOffset, + PLARGE_INTEGER EndOffset) { if ((ULONGLONG)StartOffset->QuadPart > (ULONGLONG)Lock->EndingByte.QuadPart) { @@ -47,13 +43,10 @@ return TRUE; } - __inline BOOLEAN -IsSurroundingLock( - PFILE_LOCK_INFO Lock, - PLARGE_INTEGER StartOffset, - PLARGE_INTEGER EndOffset - ) +IsSurroundingLock(PFILE_LOCK_INFO Lock, + PLARGE_INTEGER StartOffset, + PLARGE_INTEGER EndOffset) { if ((ULONGLONG)StartOffset->QuadPart >= (ULONGLONG)Lock->StartingByte.QuadPart && (ULONGLONG)EndOffset->QuadPart <= (ULONGLONG)Lock->EndingByte.QuadPart) @@ -64,58 +57,72 @@ return FALSE; } - -/********************************************************************** - * NAME PRIVATE - * FsRtlpInitFileLockingImplementation - * - */ VOID -STDCALL INIT_FUNCTION +NTAPI FsRtlInitSystem(VOID) { - ExInitializeNPagedLookasideList( &LockTocLookaside, + /* Initialize the list for all lock information structures */ + ExInitializeNPagedLookasideList(&LockTocLookaside, NULL, NULL, 0, sizeof(FILE_LOCK_TOC), IFS_POOL_TAG, - 0 - ); - - ExInitializeNPagedLookasideList( &GrantedLookaside, + 0); + + /* Initialize the list for granted locks */ + ExInitializeNPagedLookasideList(&GrantedLookaside, NULL, NULL, 0, sizeof(FILE_LOCK_GRANTED), IFS_POOL_TAG, - 0 - ); - - ExInitializePagedLookasideList( &LockLookaside, + 0); + + /* Initialize the list for lock allocations */ + ExInitializePagedLookasideList(&LockLookaside, NULL, NULL, 0, sizeof(FILE_LOCK), IFS_POOL_TAG, - 0 - ); - - ExInitializeFastMutex(&LockTocMutex); - -} - -/********************************************************************** - * NAME PRIVATE - * FsRtlpFileLockCancelRoutine - * - */ + 0); + + /* Initialize the lock information mutex */ + ExInitializeFastMutex(&LockTocMutex); +} + +VOID +NTAPI +FsRtlCompleteLockIrpReal(IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteRoutine, + IN PVOID Context, + IN PIRP Irp, + IN NTSTATUS Status, + OUT PNTSTATUS NewStatus, + IN PFILE_OBJECT FileObject OPTIONAL) +{ + /* Check if we have a complete routine */ + if (CompleteRoutine) + { + /* Check if we have a file object */ + if (FileObject) FileObject->LastLock = NULL; + + /* Set the I/O Status and do completion */ + Irp->IoStatus.Status = Status; + *NewStatus = CompleteRoutine(Context, Irp); + } + else + { + /* Otherwise do a normal I/O complete request */ + FsRtlCompleteRequest(Irp, Status); + *NewStatus = Status; + } +} + VOID STDCALL -FsRtlpFileLockCancelRoutine( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp - ) +FsRtlpFileLockCancelRoutine(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { KIRQL oldIrql; PKSPIN_LOCK SpinLock; @@ -135,28 +142,17 @@ Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); - -} - -/********************************************************************** - * NAME PRIVATE - * FsRtlpCheckLockForReadOrWriteAccess - * - * Return: - * TRUE: can read/write - * FALSE: can't read/write - */ +} + BOOLEAN FASTCALL -FsRtlpCheckLockForReadOrWriteAccess( - IN PFILE_LOCK FileLock, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN ULONG Key, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process, - IN BOOLEAN Read - ) +FsRtlpCheckLockForReadOrWriteAccess(IN PFILE_LOCK FileLock, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process, + IN BOOLEAN Read) { KIRQL oldirql; PFILE_LOCK_TOC LockToc; @@ -212,1163 +208,920 @@ return TRUE; } - -/********************************************************************** - * NAME EXPORTED - * FsRtlCheckLockForReadAccess - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlCheckLockForReadAccess ( - IN PFILE_LOCK FileLock, - IN PIRP Irp - ) -{ - PIO_STACK_LOCATION Stack; - LARGE_INTEGER LocalLength; - - Stack = IoGetCurrentIrpStackLocation(Irp); - - LocalLength.u.LowPart = Stack->Parameters.Read.Length; - LocalLength.u.HighPart = 0; - - return FsRtlpCheckLockForReadOrWriteAccess( FileLock, - &Stack->Parameters.Read.ByteOffset, - &LocalLength, - Stack->Parameters.Read.Key, - Stack->FileObject, - IoGetRequestorProcess(Irp), - TRUE /* Read */ - ); -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlCheckLockForWriteAccess - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlCheckLockForWriteAccess ( - IN PFILE_LOCK FileLock, - IN PIRP Irp - ) -{ - PIO_STACK_LOCATION Stack; - LARGE_INTEGER LocalLength; - - Stack = IoGetCurrentIrpStackLocation(Irp); - - LocalLength.u.LowPart = Stack->Parameters.Read.Length; - LocalLength.u.HighPart = 0; - - return FsRtlpCheckLockForReadOrWriteAccess( FileLock, - &Stack->Parameters.Write.ByteOffset, - &LocalLength, - Stack->Parameters.Write.Key, - Stack->FileObject, - IoGetRequestorProcess(Irp), - FALSE /* Read */ - ); - -} - - - - -/********************************************************************** - * NAME EXPORTED - * FsRtlFastCheckLockForRead - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlFastCheckLockForRead ( - IN PFILE_LOCK FileLock, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN ULONG Key, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process - ) -{ - return FsRtlpCheckLockForReadOrWriteAccess( FileLock, - FileOffset, - Length, - Key, - FileObject, - Process, - TRUE /* Read */ - ); -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlFastCheckLockForWrite - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlFastCheckLockForWrite ( - IN PFILE_LOCK FileLock, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN ULONG Key, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process - ) -{ - return FsRtlpCheckLockForReadOrWriteAccess( FileLock, - FileOffset, - Length, - Key, - FileObject, - Process, - FALSE /* Read */ - ); -} - - - -/********************************************************************** - * NAME PRIVATE - * FsRtlpFastUnlockAllByKey - * - */ NTSTATUS FASTCALL -FsRtlpFastUnlockAllByKey( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process, - IN ULONG Key, - IN BOOLEAN UseKey, - IN PVOID Context OPTIONAL - ) -{ - KIRQL oldirql; - PFILE_LOCK_TOC LockToc; - PFILE_LOCK_GRANTED Granted, tmp; - BOOLEAN Unlock = FALSE; - //must make local copy since FILE_LOCK struct is allowed to be paged - BOOLEAN GotUnlockRoutine; - LIST_ENTRY UnlockedListHead; - PLIST_ENTRY EnumEntry; - - ASSERT(FileLock); - LockToc = FileLock->LockInformation; - - if (LockToc == NULL) - { - return STATUS_RANGE_NOT_LOCKED; - } - - InitializeListHead(&UnlockedListHead); - GotUnlockRoutine = FileLock->UnlockRoutine != NULL; - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - - LIST_FOR_EACH_SAFE(Granted, tmp, &LockToc->GrantedListHead, FILE_LOCK_GRANTED, ListEntry) - { - - if (Granted->Lock.ProcessId == Process && - Granted->Lock.FileObject == FileObject && - (!UseKey || (UseKey && Granted->Lock.Key == Key)) ) - { - RemoveEntryList(&Granted->ListEntry); - Unlock = TRUE; - - if (GotUnlockRoutine) - { - /* - Put on unlocked list and call unlock routine for them afterwards. - This way we don't have to restart enum after each call - */ - InsertHeadList(&UnlockedListHead,&Granted->ListEntry); - } - else - { +FsRtlpFastUnlockAllByKey(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process, + IN ULONG Key, + IN BOOLEAN UseKey, + IN PVOID Context OPTIONAL) +{ + KIRQL oldirql; + PFILE_LOCK_TOC LockToc; + PFILE_LOCK_GRANTED Granted, tmp; + BOOLEAN Unlock = FALSE; + //must make local copy since FILE_LOCK struct is allowed to be paged + BOOLEAN GotUnlockRoutine; + LIST_ENTRY UnlockedListHead; + PLIST_ENTRY EnumEntry; + + ASSERT(FileLock); + LockToc = FileLock->LockInformation; + + if (LockToc == NULL) + { + return STATUS_RANGE_NOT_LOCKED; + } + + InitializeListHead(&UnlockedListHead); + GotUnlockRoutine = FileLock->UnlockRoutine != NULL; + KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); + + LIST_FOR_EACH_SAFE(Granted, tmp, &LockToc->GrantedListHead, FILE_LOCK_GRANTED, ListEntry) + { + + if (Granted->Lock.ProcessId == Process && + Granted->Lock.FileObject == FileObject && + (!UseKey || (UseKey && Granted->Lock.Key == Key)) ) + { + RemoveEntryList(&Granted->ListEntry); + Unlock = TRUE; + + if (GotUnlockRoutine) + { + /* + Put on unlocked list and call unlock routine for them afterwards. + This way we don't have to restart enum after each call + */ + InsertHeadList(&UnlockedListHead,&Granted->ListEntry); + } + else + { + ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); + } + } + } + + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + + if (Unlock) + { + //call unlock routine for each unlocked lock (if any) + while (!IsListEmpty(&UnlockedListHead)) + { + EnumEntry = RemoveTailList(&UnlockedListHead); + Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED, ListEntry); + + FileLock->UnlockRoutine(Granted->UnlockContext, &Granted->Lock); ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); - } - } - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - - if (Unlock) - { - //call unlock routine for each unlocked lock (if any) - while (!IsListEmpty(&UnlockedListHead)) - { - EnumEntry = RemoveTailList(&UnlockedListHead); - Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED, ListEntry); - - FileLock->UnlockRoutine(Granted->UnlockContext, &Granted->Lock); - ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); - } - - //NOTE: holding spinlock while calling this - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); - - if (IsListEmpty(&LockToc->GrantedListHead)) - { - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; - } - else - { - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - } - - return STATUS_SUCCESS; - } - - return STATUS_RANGE_NOT_LOCKED; -} - -/********************************************************************** - * NAME EXPORTED - * FsRtlFastUnlockAll - * - * @implemented - */ -NTSTATUS -STDCALL -FsRtlFastUnlockAll /*ByProcess*/ ( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process, - IN PVOID Context OPTIONAL - ) -{ - return FsRtlpFastUnlockAllByKey( FileLock, - FileObject, - Process, - 0, /* Key is ignored */ - FALSE, /* Do NOT use Key */ - Context - ); -} - -/********************************************************************** - * NAME EXPORTED - * FsRtlFastUnlockAllByKey - * - * @implemented - */ -NTSTATUS -STDCALL -FsRtlFastUnlockAllByKey ( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PEPROCESS Process, - IN ULONG Key, - IN PVOID Context OPTIONAL - ) -{ - return FsRtlpFastUnlockAllByKey( FileLock, - FileObject, - Process, - Key, - TRUE, /* Use Key */ - Context - ); -} - - -/********************************************************************** - * NAME PRIVATE - * FsRtlpAddLock - * - * NOTE - * Spinlock held at entry !! - */ + } + + //NOTE: holding spinlock while calling this + KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); + FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); + + if (IsListEmpty(&LockToc->GrantedListHead)) + { + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; + } + else + { + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + } + + return STATUS_SUCCESS; + } + + return STATUS_RANGE_NOT_LOCKED; +} + BOOLEAN FASTCALL -FsRtlpAddLock( - IN PFILE_LOCK_TOC LockToc, - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN PEPROCESS Process, - IN ULONG Key, - IN BOOLEAN ExclusiveLock, - IN PVOID Context - ) -{ - PFILE_LOCK_GRANTED Granted; - LARGE_INTEGER EndOffset; - - EndOffset.QuadPart = FileOffset->QuadPart + Length->QuadPart - 1; - - //loop and try to find conflicking locks - LIST_FOR_EACH(Granted, &LockToc->GrantedListHead, FILE_LOCK_GRANTED, ListEntry) - { - if (IsOverlappingLock(&Granted->Lock, FileOffset, &EndOffset)) - { - //we found a locks that overlap with the new lock - - //if both locks are shared, we might have a fast path outa here... - if (!Granted->Lock.ExclusiveLock && !ExclusiveLock) - { - //if existing lock surround new lock, we know that no other exclusive lock - //may overlap with our new lock;-D - if (IsSurroundingLock(&Granted->Lock, FileOffset, &EndOffset)) +FsRtlpAddLock(IN PFILE_LOCK_TOC LockToc, + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN PEPROCESS Process, + IN ULONG Key, + IN BOOLEAN ExclusiveLock, + IN PVOID Context) +{ + PFILE_LOCK_GRANTED Granted; + LARGE_INTEGER EndOffset; + + EndOffset.QuadPart = FileOffset->QuadPart + Length->QuadPart - 1; + + //loop and try to find conflicking locks + LIST_FOR_EACH(Granted, &LockToc->GrantedListHead, FILE_LOCK_GRANTED, ListEntry) + { + if (IsOverlappingLock(&Granted->Lock, FileOffset, &EndOffset)) + { + //we found a locks that overlap with the new lock + + //if both locks are shared, we might have a fast path outa here... + if (!Granted->Lock.ExclusiveLock && !ExclusiveLock) { - break; + //if existing lock surround new lock, we know that no other exclusive lock + //may overlap with our new lock;-D + if (IsSurroundingLock(&Granted->Lock, FileOffset, &EndOffset)) + { + break; + } + + //else keep locking for conflicts + continue; } - //else keep locking for conflicts - continue; - } - - //we found a conflict: - //we want shared access to an excl. lock OR exlc. access to a shared lock - return FALSE; - } - } - - Granted = ExAllocateFromNPagedLookasideList(&GrantedLookaside); - - //starting offset - Granted->Lock.StartingByte = *FileOffset; - Granted->Lock.Length = *Length; - Granted->Lock.ExclusiveLock = ExclusiveLock; - Granted->Lock.Key = Key; - Granted->Lock.FileObject = FileObject; - Granted->Lock.ProcessId = Process; - //ending offset - Granted->Lock.EndingByte = EndOffset; - Granted->UnlockContext = Context; - - InsertHeadList(&LockToc->GrantedListHead,&Granted->ListEntry); - return TRUE; -} - - - -/********************************************************************** - * NAME PRIVATE - * FsRtlpCompletePendingLocks - * - * NOTE - * Spinlock held at entry !! - */ + //we found a conflict: + //we want shared access to an excl. lock OR exlc. access to a shared lock + return FALSE; + } + } + + Granted = ExAllocateFromNPagedLookasideList(&GrantedLookaside); + + //starting offset + Granted->Lock.StartingByte = *FileOffset; + Granted->Lock.Length = *Length; + Granted->Lock.ExclusiveLock = ExclusiveLock; + Granted->Lock.Key = Key; + Granted->Lock.FileObject = FileObject; + Granted->Lock.ProcessId = Process; + //ending offset + Granted->Lock.EndingByte = EndOffset; + Granted->UnlockContext = Context; + + InsertHeadList(&LockToc->GrantedListHead,&Granted->ListEntry); + return TRUE; +} + VOID FASTCALL -FsRtlpCompletePendingLocks( - IN PFILE_LOCK FileLock, - IN PFILE_LOCK_TOC LockToc, - IN OUT PKIRQL oldirql, - IN PVOID Context - ) -{ - //walk pending list, FIFO order, try 2 complete locks - PLIST_ENTRY EnumEntry; - PIRP Irp, tmp; - PIO_STACK_LOCATION Stack; - LIST_ENTRY CompletedListHead; - - InitializeListHead(&CompletedListHead); - - LIST_FOR_EACH_SAFE(Irp, tmp, &LockToc->PendingListHead, IRP, Tail.Overlay.ListEntry) - { - Stack = IoGetCurrentIrpStackLocation(Irp); - if (FsRtlpAddLock(LockToc, - Stack->FileObject, - &Stack->Parameters.LockControl.ByteOffset, - Stack->Parameters.LockControl.Length, - IoGetRequestorProcess(Irp), - Stack->Parameters.LockControl.Key, - Stack->Flags & SL_EXCLUSIVE_LOCK, - Irp->Tail.Overlay.DriverContext[2] //Context - ) ) - { - RemoveEntryList(&Irp->Tail.Overlay.ListEntry); - - if (!IoSetCancelRoutine(Irp, NULL)) - { - //irp is canceled and cancelroutine will run when we release the lock - InitializeListHead(&Irp->Tail.Overlay.ListEntry); - continue; - } - - /* - Put on completed list and complete them all afterwards. - This way we don't have to restart enum after each completion. - */ - InsertHeadList(&CompletedListHead, &Irp->Tail.Overlay.ListEntry); - } - } - - KeReleaseSpinLock(&LockToc->SpinLock, *oldirql); - - //complete irp's (if any) - while (!IsListEmpty(&CompletedListHead)) - { - EnumEntry = RemoveTailList(&CompletedListHead); - - Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); - - Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = 0; - - if (FileLock->CompleteLockIrpRoutine) - { - if (FileLock->CompleteLockIrpRoutine(Context, Irp)!=STATUS_SUCCESS) - { - Stack = IoGetCurrentIrpStackLocation(Irp); - - //revert - FsRtlpUnlockSingle ( FileLock, - Stack->FileObject, - &Stack->Parameters.LockControl.ByteOffset, - Stack->Parameters.LockControl.Length, - IoGetRequestorProcess(Irp), - Stack->Parameters.LockControl.Key, - NULL, /* unused context */ - FALSE /* don't call unlock copletion rout.*/ - ); - } - } - else - { - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - - } - - KeAcquireSpinLock(&LockToc->SpinLock, oldirql); -} - - - -/********************************************************************** - * NAME PRIVATE - * FsRtlpUnlockSingle - * - */ +FsRtlpCompletePendingLocks(IN PFILE_LOCK FileLock, + IN PFILE_LOCK_TOC LockToc, + IN OUT PKIRQL oldirql, + IN PVOID Context) +{ + //walk pending list, FIFO order, try 2 complete locks + PLIST_ENTRY EnumEntry; + PIRP Irp, tmp; + PIO_STACK_LOCATION Stack; + LIST_ENTRY CompletedListHead; + + InitializeListHead(&CompletedListHead); + + LIST_FOR_EACH_SAFE(Irp, tmp, &LockToc->PendingListHead, IRP, Tail.Overlay.ListEntry) + { + Stack = IoGetCurrentIrpStackLocation(Irp); + if (FsRtlpAddLock(LockToc, + Stack->FileObject, + &Stack->Parameters.LockControl.ByteOffset, + Stack->Parameters.LockControl.Length, + IoGetRequestorProcess(Irp), + Stack->Parameters.LockControl.Key, + Stack->Flags & SL_EXCLUSIVE_LOCK, + Irp->Tail.Overlay.DriverContext[2] //Context + ) ) + { + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); + + if (!IoSetCancelRoutine(Irp, NULL)) + { + //irp is canceled and cancelroutine will run when we release the lock + InitializeListHead(&Irp->Tail.Overlay.ListEntry); + continue; + } + + /* + Put on completed list and complete them all afterwards. + This way we don't have to restart enum after each completion. + */ + InsertHeadList(&CompletedListHead, &Irp->Tail.Overlay.ListEntry); + } + } + + KeReleaseSpinLock(&LockToc->SpinLock, *oldirql); + + //complete irp's (if any) + while (!IsListEmpty(&CompletedListHead)) + { + EnumEntry = RemoveTailList(&CompletedListHead); + + Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); + + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + + if (FileLock->CompleteLockIrpRoutine) + { + if (FileLock->CompleteLockIrpRoutine(Context, Irp)!=STATUS_SUCCESS) + { + Stack = IoGetCurrentIrpStackLocation(Irp); + + //revert + FsRtlpUnlockSingle ( FileLock, + Stack->FileObject, + &Stack->Parameters.LockControl.ByteOffset, + Stack->Parameters.LockControl.Length, + IoGetRequestorProcess(Irp), + Stack->Parameters.LockControl.Key, + NULL, /* unused context */ + FALSE /* don't call unlock copletion rout.*/ + ); + } + } + else + { + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + } + + KeAcquireSpinLock(&LockToc->SpinLock, oldirql); +} + NTSTATUS FASTCALL -FsRtlpUnlockSingle( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN PEPROCESS Process, - IN ULONG Key, - IN PVOID Context OPTIONAL, - IN BOOLEAN CallUnlockRoutine - ) -{ - KIRQL oldirql; - PFILE_LOCK_TOC LockToc; - PFILE_LOCK_GRANTED Granted, tmp; - - ASSERT(FileLock); - LockToc = FileLock->LockInformation; - - if (LockToc == NULL) - { - return STATUS_RANGE_NOT_LOCKED; - } - - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql ); - - LIST_FOR_EACH_SAFE(Granted, tmp, &LockToc->GrantedListHead, FILE_LOCK_GRANTED,ListEntry) - { - - //must be exact match - if (FileOffset->QuadPart == Granted->Lock.StartingByte.QuadPart && - Length->QuadPart == Granted->Lock.Length.QuadPart && - Granted->Lock.ProcessId == Process && - Granted->Lock.FileObject == FileObject && - Granted->Lock.Key == Key) - { - RemoveEntryList(&Granted->ListEntry); - FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); - - if (IsListEmpty(&LockToc->GrantedListHead)) - { +FsRtlpUnlockSingle(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN PEPROCESS Process, + IN ULONG Key, + IN PVOID Context OPTIONAL, + IN BOOLEAN CallUnlockRoutine) +{ + KIRQL oldirql; + PFILE_LOCK_TOC LockToc; + PFILE_LOCK_GRANTED Granted, tmp; + + ASSERT(FileLock); + LockToc = FileLock->LockInformation; + + if (LockToc == NULL) + { + return STATUS_RANGE_NOT_LOCKED; + } + + KeAcquireSpinLock(&LockToc->SpinLock, &oldirql ); + + LIST_FOR_EACH_SAFE(Granted, tmp, &LockToc->GrantedListHead, FILE_LOCK_GRANTED,ListEntry) + { + + //must be exact match + if (FileOffset->QuadPart == Granted->Lock.StartingByte.QuadPart && + Length->QuadPart == Granted->Lock.Length.QuadPart && + Granted->Lock.ProcessId == Process && + Granted->Lock.FileObject == FileObject && + Granted->Lock.Key == Key) + { + RemoveEntryList(&Granted->ListEntry); + FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); + + if (IsListEmpty(&LockToc->GrantedListHead)) + { + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + + FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; //paged data + } + else + { + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + } + + if (FileLock->UnlockRoutine && CallUnlockRoutine) + { + FileLock->UnlockRoutine(Granted->UnlockContext, &Granted->Lock); + } + + ExFreeToNPagedLookasideList(&GrantedLookaside, Granted); + + return STATUS_SUCCESS; + } + } + + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); + + return STATUS_RANGE_NOT_LOCKED; + +} + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +PFILE_LOCK_INFO +NTAPI +FsRtlGetNextFileLock(IN PFILE_LOCK FileLock, + IN BOOLEAN Restart) +{ + /* + Messy enumeration of granted locks. + What our last ptr. in LastReturnedLock points at, might have been freed between + calls, so we have to scan thru the list every time, searching for our last lock. + If it's not there anymore, restart the enumeration... + */ + KIRQL oldirql; + PLIST_ENTRY EnumEntry; + PFILE_LOCK_GRANTED Granted; + PFILE_LOCK_TOC LockToc; + BOOLEAN FoundPrevious = FALSE; + //must make local copy since FILE_LOCK struct is allowed to be in paged mem + FILE_LOCK_INFO LocalLastReturnedLockInfo; + PVOID LocalLastReturnedLock; + + ASSERT(FileLock); + LockToc = FileLock->LockInformation; + if (LockToc == NULL) + { + return NULL; + } + + LocalLastReturnedLock = FileLock->LastReturnedLock; + + KeAcquireSpinLock(&LockToc->SpinLock,&oldirql); + +restart:; + + EnumEntry = LockToc->GrantedListHead.Flink; + + if (Restart) + { + if (EnumEntry != &LockToc->GrantedListHead) + { + Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED,ListEntry); + LocalLastReturnedLockInfo = Granted->Lock; + KeReleaseSpinLock(&LockToc->SpinLock,oldirql); + + FileLock->LastReturnedLockInfo = LocalLastReturnedLockInfo; + FileLock->LastReturnedLock = EnumEntry; + return &FileLock->LastReturnedLockInfo; + } + else + { + KeReleaseSpinLock(&LockToc->SpinLock,oldirql); + return NULL; + } + } + + //else: continue enum + while (EnumEntry != &LockToc->GrantedListHead) + { + //found previous lock? + if (EnumEntry == LocalLastReturnedLock) + { + FoundPrevious = TRUE; + //get next + EnumEntry = EnumEntry->Flink; + if (EnumEntry != &LockToc->GrantedListHead) + { + Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED,ListEntry); + LocalLastReturnedLockInfo = Granted->Lock; + KeReleaseSpinLock(&LockToc->SpinLock,oldirql); + + FileLock->LastReturnedLockInfo = LocalLastReturnedLockInfo; + FileLock->LastReturnedLock = EnumEntry; + return &FileLock->LastReturnedLockInfo; + } + break; + } + EnumEntry = EnumEntry->Flink; + } + + if (!FoundPrevious) + { + //got here? uh no, didn't find our last lock..must have been freed...restart + Restart = TRUE; + goto restart; + } + + KeReleaseSpinLock(&LockToc->SpinLock,oldirql); + + return NULL;//no (more) locks +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlPrivateLock(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN PEPROCESS Process, + IN ULONG Key, + IN BOOLEAN FailImmediately, //seems meaningless for fast io + IN BOOLEAN ExclusiveLock, + OUT PIO_STATUS_BLOCK IoStatus, + IN PIRP Irp OPTIONAL, + IN PVOID Context OPTIONAL, + IN BOOLEAN AlreadySynchronized) +{ + PFILE_LOCK_TOC LockToc; + KIRQL oldirql; + + ASSERT(FileLock); + if (FileLock->LockInformation == NULL) + { + ExAcquireFastMutex(&LockTocMutex); + //still NULL? + if (FileLock->LockInformation == NULL) + { + FileLock->LockInformation = ExAllocateFromNPagedLookasideList(&LockTocLookaside); + LockToc = FileLock->LockInformation; + KeInitializeSpinLock(&LockToc->SpinLock); + InitializeListHead(&LockToc->GrantedListHead); + InitializeListHead(&LockToc->PendingListHead); + } + ExReleaseFastMutex(&LockTocMutex); + } + + LockToc = FileLock->LockInformation; + KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); + + //try add new lock (while holding spin lock) + if (FsRtlpAddLock(LockToc, + FileObject, + FileOffset, + Length, + Process, + Key, + ExclusiveLock, + Context + ) ) + { + IoStatus->Status = STATUS_SUCCESS; + } + else if (Irp && !FailImmediately) + { + //failed + irp + no fail = make. pending + + Irp->Tail.Overlay.DriverContext[3] = &LockToc->SpinLock; + Irp->Tail.Overlay.DriverContext[2] = Context; + + (void)IoSetCancelRoutine(Irp, FsRtlpFileLockCancelRoutine); + if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) + { + //irp was canceled KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; //paged data - } - else - { - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - } - - if (FileLock->UnlockRoutine && CallUnlockRoutine) - { - FileLock->UnlockRoutine(Granted->UnlockContext, &Granted->Lock); - } - - ExFreeToNPagedLookasideList(&GrantedLookaside, Granted); - - return STATUS_SUCCESS; - } - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - - return STATUS_RANGE_NOT_LOCKED; - -} - - - -/********************************************************************** - * NAME EXPORTED - * FsRtlFastUnlockSingle - * + Irp->IoStatus.Status = STATUS_CANCELLED; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return TRUE; + } + + IoMarkIrpPending(Irp); + Irp->IoStatus.Status = IoStatus->Status = STATUS_PENDING; + Irp->IoStatus.Information = 0; + InsertHeadList(&LockToc->PendingListHead,&Irp->Tail.Overlay.ListEntry); + + } + else + { + IoStatus->Status = STATUS_LOCK_NOT_GRANTED; + } + + KeReleaseSpinLock(&LockToc->SpinLock, oldirql); //fires cancel routine + + //never pending if no irp;-) + ASSERT(!(IoStatus->Status == STATUS_PENDING && !Irp)); + + if (IoStatus->Status != STATUS_PENDING) + { + if (IoStatus->Status == STATUS_SUCCESS) + { + FsRtlAreThereCurrentFileLocks(FileLock) = TRUE; + } + + if (Irp) + { + Irp->IoStatus.Status = IoStatus->Status; + Irp->IoStatus.Information = 0; + if (FileLock->CompleteLockIrpRoutine) + { + if (FileLock->CompleteLockIrpRoutine(Context,Irp)!=STATUS_SUCCESS) + { + //CompleteLockIrpRoutine complain: revert changes + FsRtlpUnlockSingle( FileLock, + FileObject, + FileOffset, + Length, + Process, + Key, + NULL, /* context */ + FALSE /* don't call unlock copletion routine */ + ); + } + } + else + { + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + } + } + + //NOTE: only fast io seems to care about this return value + return (IoStatus->Status == STATUS_SUCCESS || FailImmediately); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + LARGE_INTEGER LocalLength; + + /* Get the I/O Stack location and length */ + Stack = IoGetCurrentIrpStackLocation(Irp); + LocalLength.QuadPart = Stack->Parameters.Read.Length; + + /* Call the internal API */ + return FsRtlpCheckLockForReadOrWriteAccess(FileLock, + &Stack->Parameters. + Read.ByteOffset, + &LocalLength, + Stack->Parameters.Read.Key, + Stack->FileObject, + IoGetRequestorProcess(Irp), + TRUE); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlCheckLockForWriteAccess(IN PFILE_LOCK FileLock, + IN PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + LARGE_INTEGER LocalLength; + + /* Get the I/O Stack location and length */ + Stack = IoGetCurrentIrpStackLocation(Irp); + LocalLength.QuadPart = Stack->Parameters.Read.Length; + + /* Call the internal API */ + return FsRtlpCheckLockForReadOrWriteAccess(FileLock, + &Stack->Parameters. + Read.ByteOffset, + &LocalLength, + Stack->Parameters.Read.Key, + Stack->FileObject, + IoGetRequestorProcess(Irp), + FALSE); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlFastCheckLockForRead(IN PFILE_LOCK FileLock, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process) +{ + /* Call the internal API */ + return FsRtlpCheckLockForReadOrWriteAccess(FileLock, + FileOffset, + Length, + Key, + FileObject, + Process, + TRUE); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlFastCheckLockForWrite(IN PFILE_LOCK FileLock, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process) +{ + /* Call the internal API */ + return FsRtlpCheckLockForReadOrWriteAccess(FileLock, + FileOffset, + Length, + Key, + FileObject, + Process, + FALSE); +} + +/* * @implemented */ NTSTATUS -STDCALL -FsRtlFastUnlockSingle ( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN PEPROCESS Process, - IN ULONG Key, - IN PVOID Context OPTIONAL, - IN BOOLEAN AlreadySynchronized - ) -{ - return FsRtlpUnlockSingle( FileLock, +NTAPI +FsRtlFastUnlockSingle(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + IN PEPROCESS Process, + IN ULONG Key, + IN PVOID Context OPTIONAL, + IN BOOLEAN AlreadySynchronized) +{ + /* Call the internal API */ + return FsRtlpUnlockSingle(FileLock, FileObject, FileOffset, Length, Process, Key, Context, - TRUE /* call unlock copletion routine */ - ); -} - -/********************************************************************** - * NAME EXPORTED - * FsRtlpDumpFileLocks - * - * NOTE: used for testing and debugging - */ -VOID -FASTCALL -FsRtlpDumpFileLocks( - IN PFILE_LOCK FileLock - ) -{ - KIRQL oldirql; - PFILE_LOCK_TOC LockToc; - PFILE_LOCK_GRANTED Granted; - PIRP Irp; - PIO_STACK_LOCATION Stack; - - ASSERT(FileLock); - LockToc = FileLock->LockInformation; - - if (LockToc == NULL) - { - DPRINT1("No file locks\n"); - return; - } - - DPRINT1("Dumping granted file locks, FIFO order\n"); - - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - - LIST_FOR_EACH(Granted, &LockToc->GrantedListHead, FILE_LOCK_GRANTED , ListEntry) - { - DPRINT1("%s, start: %I64x, len: %I64x, end: %I64x, key: %i, proc: 0x%p, fob: 0x%p\n", - Granted->Lock.ExclusiveLock ? "EXCL" : "SHRD", - Granted->Lock.StartingByte.QuadPart, - Granted->Lock.Length.QuadPart, - Granted->Lock.EndingByte.QuadPart, - Granted->Lock.Key, - Granted->Lock.ProcessId, - Granted->Lock.FileObject - ); - - } - - DPRINT1("Dumping pending file locks, FIFO order\n"); - - LIST_FOR_EACH(Irp, &LockToc->PendingListHead, IRP , Tail.Overlay.ListEntry) - { - Stack = IoGetCurrentIrpStackLocation(Irp); - - DPRINT1("%s, start: %I64x, len: %I64x, end: %I64x, key: %i, proc: 0x%p, fob: 0x%p\n", - (Stack->Flags & SL_EXCLUSIVE_LOCK) ? "EXCL" : "SHRD", - Stack->Parameters.LockControl.ByteOffset.QuadPart, - Stack->Parameters.LockControl.Length->QuadPart, - Stack->Parameters.LockControl.ByteOffset.QuadPart + Stack->Parameters.LockControl.Length->QuadPart - 1, - Stack->Parameters.LockControl.Key, - IoGetRequestorProcess(Irp), - Stack->FileObject - ); - - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); -} - - - -/********************************************************************** - * NAME EXPORTED - * FsRtlGetNextFileLock - * - * RETURN VALUE - * NULL if no more locks. - * - * @implemented - */ -PFILE_LOCK_INFO -STDCALL -FsRtlGetNextFileLock ( - IN PFILE_LOCK FileLock, - IN BOOLEAN Restart - ) -{ - /* - Messy enumeration of granted locks. - What our last ptr. in LastReturnedLock points at, might have been freed between - calls, so we have to scan thru the list every time, searching for our last lock. - If it's not there anymore, restart the enumeration... - */ - KIRQL oldirql; - PLIST_ENTRY EnumEntry; - PFILE_LOCK_GRANTED Granted; - PFILE_LOCK_TOC LockToc; - BOOLEAN FoundPrevious = FALSE; - //must make local copy since FILE_LOCK struct is allowed to be in paged mem - FILE_LOCK_INFO LocalLastReturnedLockInfo; - PVOID LocalLastReturnedLock; - - ASSERT(FileLock); - LockToc = FileLock->LockInformation; - if (LockToc == NULL) - { - return NULL; - } - - LocalLastReturnedLock = FileLock->LastReturnedLock; - - KeAcquireSpinLock(&LockToc->SpinLock,&oldirql); - -restart:; - - EnumEntry = LockToc->GrantedListHead.Flink; - - if (Restart) - { - if (EnumEntry != &LockToc->GrantedListHead) - { - Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED,ListEntry); - LocalLastReturnedLockInfo = Granted->Lock; - KeReleaseSpinLock(&LockToc->SpinLock,oldirql); - - FileLock->LastReturnedLockInfo = LocalLastReturnedLockInfo; - FileLock->LastReturnedLock = EnumEntry; - return &FileLock->LastReturnedLockInfo; - } - else - { - KeReleaseSpinLock(&LockToc->SpinLock,oldirql); - return NULL; - } - } - - //else: continue enum - while (EnumEntry != &LockToc->GrantedListHead) - { - //found previous lock? - if (EnumEntry == LocalLastReturnedLock) - { - FoundPrevious = TRUE; - //get next - EnumEntry = EnumEntry->Flink; - if (EnumEntry != &LockToc->GrantedListHead) - { - Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED,ListEntry); - LocalLastReturnedLockInfo = Granted->Lock; - KeReleaseSpinLock(&LockToc->SpinLock,oldirql); - - FileLock->LastReturnedLockInfo = LocalLastReturnedLockInfo; - FileLock->LastReturnedLock = EnumEntry; - return &FileLock->LastReturnedLockInfo; - } - break; - } - EnumEntry = EnumEntry->Flink; - } - - if (!FoundPrevious) - { - //got here? uh no, didn't find our last lock..must have been freed...restart - Restart = TRUE; - goto restart; - } - - KeReleaseSpinLock(&LockToc->SpinLock,oldirql); - - return NULL;//no (more) locks -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlInitializeFileLock - * - * NOTE - * Called when creating/allocating/initializing FCB - * - * @implemented - */ -VOID -STDCALL -FsRtlInitializeFileLock ( - IN PFILE_LOCK FileLock, - IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, - IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL - ) -{ - - FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; - FileLock->CompleteLockIrpRoutine = CompleteLockIrpRoutine; - FileLock->UnlockRoutine = UnlockRoutine; - FileLock->LockInformation = NULL; - -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlPrivateLock - * - * @implemented - */ -BOOLEAN -STDCALL -FsRtlPrivateLock ( - IN PFILE_LOCK FileLock, - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - IN PEPROCESS Process, - IN ULONG Key, - IN BOOLEAN FailImmediately, //seems meaningless for fast io - IN BOOLEAN ExclusiveLock, - OUT PIO_STATUS_BLOCK IoStatus, - IN PIRP Irp OPTIONAL, - IN PVOID Context OPTIONAL, - IN BOOLEAN AlreadySynchronized - ) -{ - PFILE_LOCK_TOC LockToc; - KIRQL oldirql; - - ASSERT(FileLock); - if (FileLock->LockInformation == NULL) - { - ExAcquireFastMutex(&LockTocMutex); - //still NULL? - if (FileLock->LockInformation == NULL) - { - FileLock->LockInformation = ExAllocateFromNPagedLookasideList(&LockTocLookaside); - LockToc = FileLock->LockInformation; - KeInitializeSpinLock(&LockToc->SpinLock); - InitializeListHead(&LockToc->GrantedListHead); - InitializeListHead(&LockToc->PendingListHead); - } - ExReleaseFastMutex(&LockTocMutex); - } - - LockToc = FileLock->LockInformation; - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - - //try add new lock (while holding spin lock) - if (FsRtlpAddLock(LockToc, - FileObject, - FileOffset, - Length, - Process, - Key, - ExclusiveLock, - Context - ) ) - { - IoStatus->Status = STATUS_SUCCESS; - } - else if (Irp && !FailImmediately) - { - //failed + irp + no fail = make. pending - - Irp->Tail.Overlay.DriverContext[3] = &LockToc->SpinLock; - Irp->Tail.Overlay.DriverContext[2] = Context; - - (void)IoSetCancelRoutine(Irp, FsRtlpFileLockCancelRoutine); - if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) - { - //irp was canceled - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - - Irp->IoStatus.Status = STATUS_CANCELLED; - Irp->IoStatus.Information = 0; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - - return TRUE; - } - - IoMarkIrpPending(Irp); - Irp->IoStatus.Status = IoStatus->Status = STATUS_PENDING; - Irp->IoStatus.Information = 0; - InsertHeadList(&LockToc->PendingListHead,&Irp->Tail.Overlay.ListEntry); - - } - else - { - IoStatus->Status = STATUS_LOCK_NOT_GRANTED; - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); //fires cancel routine - - //never pending if no irp;-) - ASSERT(!(IoStatus->Status == STATUS_PENDING && !Irp)); - - if (IoStatus->Status != STATUS_PENDING) - { - if (IoStatus->Status == STATUS_SUCCESS) - { - FsRtlAreThereCurrentFileLocks(FileLock) = TRUE; - } - - if (Irp) - { - Irp->IoStatus.Status = IoStatus->Status; - Irp->IoStatus.Information = 0; - if (FileLock->CompleteLockIrpRoutine) - { - if (FileLock->CompleteLockIrpRoutine(Context,Irp)!=STATUS_SUCCESS) - { - //CompleteLockIrpRoutine complain: revert changes - FsRtlpUnlockSingle( FileLock, + TRUE); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process, + IN PVOID Context OPTIONAL) +{ + /* Call the generic function by process */ + return FsRtlpFastUnlockAllByKey(FileLock, FileObject, - FileOffset, - Length, + Process, + 0, + FALSE, + Context); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +FsRtlFastUnlockAllByKey(IN PFILE_LOCK FileLock, + IN PFILE_OBJECT FileObject, + IN PEPROCESS Process, + IN ULONG Key, + IN PVOID Context OPTIONAL) +{ + /* Call the generic function by key */ + return FsRtlpFastUnlockAllByKey(FileLock, + FileObject, Process, Key, - NULL, /* context */ - FALSE /* don't call unlock copletion routine */ - ); - } - } - else - { - IoCompleteRequest(Irp, IO_NO_INCREMENT); - } - } - } - - //NOTE: only fast io seems to care about this return value - return (IoStatus->Status == STATUS_SUCCESS || FailImmediately); - -} - - - -/********************************************************************** - * NAME EXPORTED - * FsRtlProcessFileLock - * + TRUE, + Context); +} + +/* * @implemented */ NTSTATUS -STDCALL -FsRtlProcessFileLock ( - IN PFILE_LOCK FileLock, - IN PIRP Irp, - IN PVOID Context OPTIONAL - ) -{ - PIO_STACK_LOCATION Stack; - NTSTATUS Status; - IO_STATUS_BLOCK LocalIoStatus; - - ASSERT(FileLock); - Stack = IoGetCurrentIrpStackLocation(Irp); - Irp->IoStatus.Information = 0; - - switch(Stack->MinorFunction) - { - case IRP_MN_LOCK: - //ret: BOOLEAN - FsRtlPrivateLock( FileLock, - Stack->FileObject, - &Stack->Parameters.LockControl.ByteOffset, //not pointer! - Stack->Parameters.LockControl.Length, - IoGetRequestorProcess(Irp), - Stack->Parameters.LockControl.Key, - Stack->Flags & SL_FAIL_IMMEDIATELY, - Stack->Flags & SL_EXCLUSIVE_LOCK, - &LocalIoStatus, - Irp, - Context, - FALSE); - - return LocalIoStatus.Status; - - case IRP_MN_UNLOCK_SINGLE: - Status = FsRtlFastUnlockSingle ( FileLock, - Stack->FileObject, - &Stack->Parameters.LockControl.ByteOffset, - Stack->Parameters.LockControl.Length, - IoGetRequestorProcess(Irp), - Stack->Parameters.LockControl.Key, - Context, - FALSE); - break; - - case IRP_MN_UNLOCK_ALL: - Status = FsRtlFastUnlockAll( FileLock, - Stack->FileObject, - IoGetRequestorProcess(Irp), - Context ); - break; - - case IRP_MN_UNLOCK_ALL_BY_KEY: - Status = FsRtlFastUnlockAllByKey ( FileLock, - Stack->FileObject, - IoGetRequestorProcess(Irp), - Stack->Parameters.LockControl.Key, - Context ); - - break; - - default: - Irp->IoStatus.Status = Status = STATUS_INVALID_DEVICE_REQUEST; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Status; - } - - - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = 0; - - IoCompleteRequest(Irp,IO_NO_INCREMENT); - - return Status; -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlUninitializeFileLock - * +NTAPI +FsRtlProcessFileLock(IN PFILE_LOCK FileLock, + IN PIRP Irp, + IN PVOID Context OPTIONAL) +{ + PIO_STACK_LOCATION IoStackLocation; + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + + /* Get the I/O Stack location */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + ASSERT(IoStackLocation->MajorFunction == IRP_MJ_LOCK_CONTROL); + + /* Clear the I/O status block and check what function this is */ + IoStatusBlock.Information = 0; + switch(IoStackLocation->MinorFunction) + { + /* A lock */ + case IRP_MN_LOCK: + + /* Call the private lock routine */ + FsRtlPrivateLock(FileLock, + IoStackLocation->FileObject, + &IoStackLocation-> + Parameters.LockControl.ByteOffset, + IoStackLocation->Parameters.LockControl.Length, + IoGetRequestorProcess(Irp), + IoStackLocation->Parameters.LockControl.Key, + IoStackLocation->Flags & SL_FAIL_IMMEDIATELY, + IoStackLocation->Flags & SL_EXCLUSIVE_LOCK, + &IoStatusBlock, + Irp, + Context, + FALSE); + break; + + /* A single unlock */ + case IRP_MN_UNLOCK_SINGLE: + + /* Call fast unlock */ + IoStatusBlock.Status = + FsRtlFastUnlockSingle(FileLock, + IoStackLocation->FileObject, + &IoStackLocation->Parameters.LockControl. + ByteOffset, + IoStackLocation->Parameters.LockControl. + Length, + IoGetRequestorProcess(Irp), + IoStackLocation->Parameters.LockControl. + Key, + Context, + FALSE); + + /* Complete the IRP */ + FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatusBlock.Status, + &Status, + NULL); + break; + + /* Total unlock */ + case IRP_MN_UNLOCK_ALL: + + /* Do a fast unlock */ + IoStatusBlock.Status = FsRtlFastUnlockAll(FileLock, + IoStackLocation-> + FileObject, + IoGetRequestorProcess(Irp), + Context); + + /* Complete the IRP */ + FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatusBlock.Status, + &Status, + NULL); + break; + + /* Unlock by key */ + case IRP_MN_UNLOCK_ALL_BY_KEY: + + /* Do it */ + IoStatusBlock.Status = + FsRtlFastUnlockAllByKey(FileLock, + IoStackLocation->FileObject, + IoGetRequestorProcess(Irp), + IoStackLocation->Parameters. + LockControl.Key, + Context); + + /* Complete the IRP */ + FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatusBlock.Status, + &Status, + NULL); + break; + + /* Invalid request */ + default: + + /* Complete it */ + FsRtlCompleteRequest(Irp, STATUS_INVALID_DEVICE_REQUEST); + IoStatusBlock.Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + + /* Return the status */ + return IoStatusBlock.Status; +} + +/* * @implemented */ VOID -STDCALL -FsRtlUninitializeFileLock ( - IN PFILE_LOCK FileLock - ) -{ - PFILE_LOCK_TOC LockToc; - PIRP Irp; - PFILE_LOCK_GRANTED Granted; - PLIST_ENTRY EnumEntry; - KIRQL oldirql; - - ASSERT(FileLock); - if (FileLock->LockInformation == NULL) - { - return; - } - - LockToc = FileLock->LockInformation; - - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - - //remove and free granted locks - while (!IsListEmpty(&LockToc->GrantedListHead)) - { - EnumEntry = RemoveTailList(&LockToc->GrantedListHead); - Granted = CONTAINING_RECORD(EnumEntry, FILE_LOCK_GRANTED, ListEntry); - ExFreeToNPagedLookasideList(&GrantedLookaside, Granted); - } - - //remove, complete and free all pending locks - while (!IsListEmpty(&LockToc->PendingListHead)) - { - EnumEntry = RemoveTailList(&LockToc->PendingListHead); - Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); - - if (!IoSetCancelRoutine(Irp, NULL)) - { - //The cancel routine will be called. When we release the lock it will complete the irp. - InitializeListHead(&Irp->Tail.Overlay.ListEntry); - continue; - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - - Irp->IoStatus.Status = STATUS_RANGE_NOT_LOCKED; - Irp->IoStatus.Information = 0; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - - KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - - } - - KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - - ExFreeToNPagedLookasideList(&LockTocLookaside, LockToc); - - FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; - FileLock->LockInformation = NULL; - -} - - -/********************************************************************** - * NAME EXPORTED - * FsRtlAllocateFileLock - * - * NOTE - * Only present in NT 5.0 or later. - * FCB FILE_LOCK struct should/is acording to DDK allocated from paged pool! - * +NTAPI +FsRtlInitializeFileLock (IN PFILE_LOCK FileLock, + IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, + IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL) +{ + /* Setup the lock */ + FileLock->FastIoIsQuestionable = FALSE; + FileLock->CompleteLockIrpRoutine = CompleteLockIrpRoutine; + FileLock->UnlockRoutine = UnlockRoutine; + FileLock->LockInformation = NULL; +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock) +{ + PFILE_LOCK_TOC LockToc; + PIRP Irp; + PFILE_LOCK_GRANTED Granted; + PLIST_ENTRY EnumEntry; + KIRQL OldIrql; + + /* Get the lock information */ + LockToc = FileLock->LockInformation; + if (!FileLock->LockInformation) return; + + /* Acquire the lock queue */ + KeAcquireSpinLock(&LockToc->SpinLock, &OldIrql); + + /* Loop the lock tree */ + while (!IsListEmpty(&LockToc->GrantedListHead)) + { + /* Get the entry */ + EnumEntry = RemoveTailList(&LockToc->GrantedListHead); + + /* Get the granted lock and free it */ + Granted = CONTAINING_RECORD(EnumEntry, FILE_LOCK_GRANTED, ListEntry); + ExFreeToNPagedLookasideList(&GrantedLookaside, Granted); + } + + /* Loop the waiting locks */ + while (!IsListEmpty(&LockToc->PendingListHead)) + { + /* Get the entry and IRP */ + EnumEntry = RemoveTailList(&LockToc->PendingListHead); + Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); + + /* Release the lock */ + KeReleaseSpinLock(&LockToc->SpinLock, OldIrql); + + /* Acquire cancel spinlock and clear the cancel routine */ + IoAcquireCancelSpinLock(&Irp->CancelIrql); + IoSetCancelRoutine(Irp, NULL); + IoReleaseCancelSpinLock(Irp->CancelIrql); + + /* Complete the IRP */ + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_RANGE_NOT_LOCKED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + /* Acquire the lock again */ + KeAcquireSpinLock(&LockToc->SpinLock, &OldIrql); + } + + /* Release the lock and free it */ + KeReleaseSpinLock(&LockToc->SpinLock, OldIrql); + ExFreeToNPagedLookasideList(&LockTocLookaside, LockToc); + + /* Remove the lock information pointer */ + FileLock->LockInformation = NULL; +} + +/* * @implemented */ PFILE_LOCK -STDCALL -FsRtlAllocateFileLock( - IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, - IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL - ) -{ - PFILE_LOCK FileLock; - - FileLock = ExAllocateFromPagedLookasideList(&LockLookaside); - - FsRtlInitializeFileLock(FileLock, - CompleteLockIrpRoutine, - UnlockRoutine - ); - - return FileLock; -} - -/********************************************************************** - * NAME EXPORTED - * FsRtlFreeFileLock - * - * NOTE - * Only present in NT 5.0 or later. - * FCB FILE_LOCK struct should/is acording to DDK allocated from paged pool! - * +NTAPI +FsRtlAllocateFileLock(IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, + IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL) +{ + PFILE_LOCK FileLock; + + /* Try to allocate it */ + FileLock = ExAllocateFromPagedLookasideList(&LockLookaside); + if (FileLock) + { + /* Initialize it */ + FsRtlInitializeFileLock(FileLock, + CompleteLockIrpRoutine, + UnlockRoutine); + } + + /* Return the lock */ + return FileLock; +} + +/* * @implemented */ VOID -STDCALL -FsRtlFreeFileLock( - IN PFILE_LOCK FileLock - ) -{ - ASSERT(FileLock); - - FsRtlUninitializeFileLock(FileLock); - ExFreeToPagedLookasideList(&LockLookaside, FileLock); -} - -/* - * @implemented - */ -VOID -STDCALL -FsRtlAcquireFileExclusive( - IN PFILE_OBJECT FileObject - ) -{ - PFAST_IO_DISPATCH FastDispatch; - PDEVICE_OBJECT DeviceObject; - PFSRTL_COMMON_FCB_HEADER FcbHeader; - - /* Get the Device Object */ - DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); - - /* Check if we have to do a Fast I/O Dispatch */ - if ((FastDispatch = DeviceObject->DriverObject->FastIoDispatch)) { - - /* Call the Fast I/O Routine */ - if (FastDispatch->AcquireFileForNtCreateSection) { - FastDispatch->AcquireFileForNtCreateSection(FileObject); - } - - return; - } - - /* Do a normal acquire */ - if ((FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)) { - - /* Use a Resource Acquire */ - ExAcquireResourceExclusive(FcbHeader->Resource, TRUE); - - return; - } - - /* Return...is there some kind of failure we should raise?? */ - return; -} - -/* - * @implemented - */ -VOID -STDCALL -FsRtlReleaseFile( - IN PFILE_OBJECT FileObject - ) -{ - PFAST_IO_DISPATCH FastDispatch; - PDEVICE_OBJECT DeviceObject; - PFSRTL_COMMON_FCB_HEADER FcbHeader; - - /* Get the Device Object */ - DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); - - /* Check if we have to do a Fast I/O Dispatch */ - if ((FastDispatch = DeviceObject->DriverObject->FastIoDispatch)) { - - /* Use Fast I/O */ - if (FastDispatch->ReleaseFileForNtCreateSection) { - FastDispatch->ReleaseFileForNtCreateSection(FileObject); - } - - return; - } - - /* Do a normal acquire */ - if ((FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)) { - - /* Use a Resource Release */ - ExReleaseResourceLite(FcbHeader->Resource); - - return; - } - - /* Return...is there some kind of failure we should raise?? */ - return; -} - +NTAPI +FsRtlFreeFileLock(IN PFILE_LOCK FileLock) +{ + /* Uninitialize and free the lock */ + FsRtlUninitializeFileLock(FileLock); + ExFreeToPagedLookasideList(&LockLookaside, FileLock); +} /* EOF */
18 years, 1 month
1
0
0
0
[ion] 24729: - Add CcFastMdlReadWait extern to ntifs.h - Add FsRtlCompleteRequest macro to ntifs.h - Add LDRP_DRIVER_VERIFYING flag to ldrtypes.h - Add MM_DRIVER_VERIFIER_DATA and DRIVER_SPECIFIED_DRIVER_THUNKS to mmtypes.h - Add MAXLONGLONG to ntdef.h.
by ion@svn.reactos.org
Author: ion Date: Mon Nov 13 01:27:10 2006 New Revision: 24729 URL:
http://svn.reactos.org/svn/reactos?rev=24729&view=rev
Log: - Add CcFastMdlReadWait extern to ntifs.h - Add FsRtlCompleteRequest macro to ntifs.h - Add LDRP_DRIVER_VERIFYING flag to ldrtypes.h - Add MM_DRIVER_VERIFIER_DATA and DRIVER_SPECIFIED_DRIVER_THUNKS to mmtypes.h - Add MAXLONGLONG to ntdef.h. Modified: trunk/reactos/include/ddk/ntifs.h trunk/reactos/include/ndk/ldrtypes.h trunk/reactos/include/ndk/mmtypes.h trunk/reactos/include/psdk/ntdef.h Modified: trunk/reactos/include/ddk/ntifs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ntifs.h?rev=24…
============================================================================== --- trunk/reactos/include/ddk/ntifs.h (original) +++ trunk/reactos/include/ddk/ntifs.h Mon Nov 13 01:27:10 2006 @@ -2006,6 +2006,8 @@ (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ ) +extern ULONG CcFastMdlReadWait; + NTKERNELAPI BOOLEAN NTAPI @@ -2578,6 +2580,11 @@ FsRtlDoesNameContainWildCards ( IN PUNICODE_STRING Name ); + +#define FsRtlCompleteRequest(IRP,STATUS) { \ + (IRP)->IoStatus.Status = (STATUS); \ + IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ +} #define FsRtlEnterFileSystem KeEnterCriticalRegion Modified: trunk/reactos/include/ndk/ldrtypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/ldrtypes.h?rev…
============================================================================== --- trunk/reactos/include/ndk/ldrtypes.h (original) +++ trunk/reactos/include/ndk/ldrtypes.h Mon Nov 13 01:27:10 2006 @@ -49,6 +49,7 @@ #define LDRP_IMAGE_NOT_AT_BASE 0x00200000 #define LDRP_COR_IMAGE 0x00400000 #define LDR_COR_OWNS_UNMAP 0x00800000 +#define LDRP_DRIVER_VERIFYING 0x02000000 #define LDRP_REDIRECTED 0x10000000 // Modified: trunk/reactos/include/ndk/mmtypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/mmtypes.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/mmtypes.h (original) +++ trunk/reactos/include/ndk/mmtypes.h Mon Nov 13 01:27:10 2006 @@ -607,6 +607,50 @@ } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION; // +// Driver Verifier Data +// +typedef struct _MM_DRIVER_VERIFIER_DATA +{ + ULONG Level; + ULONG RaiseIrqls; + ULONG AcquireSpinLocks; + ULONG SynchronizeExecutions; + ULONG AllocationsAttempted; + ULONG AllocationsSucceeded; + ULONG AllocationsSucceededSpecialPool; + ULONG AllocationsWithNoTag; + ULONG TrimRequests; + ULONG Trims; + ULONG AllocationsFailed; + ULONG AllocationsFailedDeliberately; + ULONG Loads; + ULONG Unloads; + ULONG UnTrackedPool; + ULONG UserTrims; + ULONG CurrentPagedPoolAllocations; + ULONG CurrentNonPagedPoolAllocations; + ULONG PeakPagedPoolAllocations; + ULONG PeakNonPagedPoolAllocations; + ULONG PagedBytes; + ULONG NonPagedBytes; + ULONG PeakPagedBytes; + ULONG PeakNonPagedBytes; + ULONG BurstAllocationsFailedDeliberately; + ULONG SessionTrims; + ULONG Reserved[2]; +} MM_DRIVER_VERIFIER_DATA, *PMM_DRIVER_VERIFIER_DATA; + +// +// Internal Driver Verifier Table Data +// +typedef struct _DRIVER_SPECIFIED_VERIFIER_THUNKS +{ + LIST_ENTRY ListEntry; + PLDR_DATA_TABLE_ENTRY DataTableEntry; + ULONG NumberOfThunks; +} DRIVER_SPECIFIED_VERIFIER_THUNKS, *PDRIVER_SPECIFIED_VERIFIER_THUNKS; + +// // Default heap size values. For user mode, these values are copied to a new // process's PEB by the kernel in MmCreatePeb. In kernel mode, RtlCreateHeap // reads these variables directly. Modified: trunk/reactos/include/psdk/ntdef.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntdef.h?rev=2…
============================================================================== --- trunk/reactos/include/psdk/ntdef.h (original) +++ trunk/reactos/include/psdk/ntdef.h Mon Nov 13 01:27:10 2006 @@ -105,7 +105,7 @@ #define MAXUCHAR 0xff #define MAXUSHORT 0xffff #define MAXULONG 0xffffffff - +#define MAXLONGLONG (0x7fffffffffffffffLL) #define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1] #endif /* _NTDEF_H */
18 years, 1 month
1
0
0
0
[gedmurphy] 24728: - fix a bug freeing memory for floating windows. - ShowHideWindow needs no more than a Window handle
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Sun Nov 12 23:13:39 2006 New Revision: 24728 URL:
http://svn.reactos.org/svn/reactos?rev=24728&view=rev
Log: - fix a bug freeing memory for floating windows. - ShowHideWindow needs no more than a Window handle Modified: trunk/reactos/base/applications/imagesoft/floatwindow.c trunk/reactos/base/applications/imagesoft/mainwnd.c trunk/reactos/base/applications/imagesoft/precomp.h Modified: trunk/reactos/base/applications/imagesoft/floatwindow.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/floatwindow.c (original) +++ trunk/reactos/base/applications/imagesoft/floatwindow.c Sun Nov 12 23:13:39 2006 @@ -40,12 +40,12 @@ BOOL -ShowHideWindow(PFLT_WND FltInfo) -{ - if (IsWindowVisible(FltInfo->hSelf)) - return ShowWindow(FltInfo->hSelf, SW_HIDE); +ShowHideWindow(HWND hwnd) +{ + if (IsWindowVisible(hwnd)) + return ShowWindow(hwnd, SW_HIDE); else - return ShowWindow(FltInfo->hSelf, SW_SHOW); + return ShowWindow(hwnd, SW_SHOW); } @@ -447,13 +447,13 @@ break; case WM_CLOSE: - ShowHideWindow(FltInfo); + ShowHideWindow(FltInfo->hSelf); break; case WM_COMMAND: { if (LOWORD(wParam) == IDCANCEL) - ShowHideWindow(FltInfo); + ShowHideWindow(FltInfo->hSelf); switch(LOWORD(wParam)) { Modified: trunk/reactos/base/applications/imagesoft/mainwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/mainwnd.c (original) +++ trunk/reactos/base/applications/imagesoft/mainwnd.c Sun Nov 12 23:13:39 2006 @@ -378,10 +378,10 @@ { SIZE Size; BOOL Vert; - DWORD dwStyle = SendMessage(rbi->hwndChild, - TB_GETSTYLE, - 0, - 0); + DWORD dwStyle = (DWORD)SendMessage(rbi->hwndChild, + TB_GETSTYLE, + 0, + 0); switch (DockTo) { case LEFT_DOCK: @@ -613,7 +613,7 @@ ID_TOOLS, MF_CHECKED); - ShowHideWindow(Info->fltTools); + ShowHideWindow(Info->fltTools->hSelf); } } @@ -642,10 +642,10 @@ HeapFree(ProcessHeap, 0, Info->fltTools); if (Info->fltColors != NULL) - HeapFree(ProcessHeap, 0, Info->fltTools); + HeapFree(ProcessHeap, 0, Info->fltColors); if (Info->fltHistory != NULL) - HeapFree(ProcessHeap, 0, Info->fltTools); + HeapFree(ProcessHeap, 0, Info->fltHistory); } @@ -893,7 +893,7 @@ { UINT uCheck = MF_CHECKED; - if (ShowHideWindow(Info->fltTools)) + if (ShowHideWindow(Info->fltTools->hSelf)) uCheck = MF_UNCHECKED; CheckMenuItem(hMenu, @@ -911,7 +911,7 @@ { UINT uCheck = MF_CHECKED; - if (ShowHideWindow(Info->fltColors)) + if (ShowHideWindow(Info->fltColors->hSelf)) uCheck = MF_UNCHECKED; CheckMenuItem(hMenu, @@ -929,7 +929,7 @@ { UINT uCheck = MF_CHECKED; - if (ShowHideWindow(Info->fltHistory)) + if (ShowHideWindow(Info->fltHistory->hSelf)) uCheck = MF_UNCHECKED; CheckMenuItem(hMenu, Modified: trunk/reactos/base/applications/imagesoft/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
============================================================================== --- trunk/reactos/base/applications/imagesoft/precomp.h (original) +++ trunk/reactos/base/applications/imagesoft/precomp.h Sun Nov 12 23:13:39 2006 @@ -388,7 +388,7 @@ BOOL FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info); BOOL InitFloatWndClass(VOID); VOID UninitFloatWndImpl(VOID); -BOOL ShowHideWindow(PFLT_WND FltInfo); +BOOL ShowHideWindow(HWND hwnd); /* font.c */ VOID FillFontStyleComboList(HWND hwndCombo);
18 years, 1 month
1
0
0
0
← Newer
1
...
25
26
27
28
29
30
31
32
33
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
Results per page:
10
25
50
100
200