[ros-diffs] [jimtabor] 74543: [NtGDI] - Implement internal functions for setting and retrieving DC origin. Related to CORE-13110. - Code fix ups.
Author: jimtabor Date: Sun May 14 01:00:27 2017 New Revision: 74543 URL: http://svn.reactos.org/svn/reactos?rev=74543=rev Log: [NtGDI] - Implement internal functions for setting and retrieving DC origin. Related to CORE-13110. - Code fix ups. Modified: trunk/reactos/win32ss/gdi/ntgdi/coord.c trunk/reactos/win32ss/gdi/ntgdi/coord.h trunk/reactos/win32ss/gdi/ntgdi/dcutil.c Modified: trunk/reactos/win32ss/gdi/ntgdi/coord.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/coord.c?rev=74543=74542=74543=diff == --- trunk/reactos/win32ss/gdi/ntgdi/coord.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/coord.c [iso-8859-1] Sun May 14 01:00:27 2017 @@ -1337,6 +1337,56 @@ BOOL WINAPI +GreSetDCOrg( +_In_ HDC hdc, +_In_ LONG x, +_In_ LONG y, +_In_opt_ PRECTL Rect) +{ +PDC dc; + +dc = DC_LockDc(hdc); +if (!dc) return FALSE; + +/* Set DC Origin */ +dc->ptlDCOrig.x = x; +dc->ptlDCOrig.y = y; + +/* Recalculate Fill Origin */ +dc->ptlFillOrigin.x = dc->dclevel.ptlBrushOrigin.x + x; +dc->ptlFillOrigin.y = dc->dclevel.ptlBrushOrigin.y + y; + +/* Set DC Window Rectangle */ +if (Rect) +dc->erclWindow = *Rect; + +DC_UnlockDc(dc); +return TRUE; +} + +BOOL +WINAPI +GreGetDCOrgEx( +_In_ HDC hdc, +_Out_ PPOINTL Point, +_Out_ PRECTL Rect) +{ +PDC dc; + +dc = DC_LockDc(hdc); +if (!dc) return FALSE; + +/* Retrieve DC Window Rectangle without a check */ +*Rect = dc->erclWindow; + +DC_UnlockDc(dc); + +/* Use default call for DC Origin and parameter checking */ +return GreGetDCPoint( hdc, GdiGetDCOrg, Point); +} + +BOOL +WINAPI GreGetWindowExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize) Modified: trunk/reactos/win32ss/gdi/ntgdi/coord.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/coord.h?rev=74543=74542=74543=diff == --- trunk/reactos/win32ss/gdi/ntgdi/coord.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/coord.h [iso-8859-1] Sun May 14 01:00:27 2017 @@ -166,3 +166,5 @@ BOOL WINAPI GreGetWindowExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize); BOOL WINAPI GreGetViewportExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize); BOOL FASTCALL GreSetViewportOrgEx(HDC,int,int,LPPOINT); +BOOL WINAPI GreGetDCOrgEx(_In_ HDC, _Out_ PPOINTL, _Out_ PRECTL); +BOOL WINAPI GreSetDCOrg(_In_ HDC, _In_ LONG, _In_ LONG, _In_opt_ PRECTL); Modified: trunk/reactos/win32ss/gdi/ntgdi/dcutil.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcutil.c?rev=74543=74542=74543=diff == --- trunk/reactos/win32ss/gdi/ntgdi/dcutil.c[iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dcutil.c[iso-8859-1] Sun May 14 01:00:27 2017 @@ -396,8 +396,8 @@ pdc->erclWindow = rclWnd; pdc->erclClip = rclClip; /* Might be an InitDC or DCE... */ -pdc->ptlFillOrigin.x = pdc->dcattr.VisRectRegion.Rect.right; -pdc->ptlFillOrigin.y = pdc->dcattr.VisRectRegion.Rect.bottom; +pdc->ptlFillOrigin.x = pdc->dcattr.ptlBrushOrigin.x; +pdc->ptlFillOrigin.y = pdc->dcattr.ptlBrushOrigin.y; return TRUE; }
[ros-diffs] [ion] 74542: [BOOTLIB]: Implement MmMdTruncateDescriptors [BOOTLIB]: Implement MmPaTruncateMemory and call it during paging initialization to remove > 4GB memory.c [BOOTLIB]: Implement Blp
Author: ion Date: Sun May 14 00:39:30 2017 New Revision: 74542 URL: http://svn.reactos.org/svn/reactos?rev=74542=rev Log: [BOOTLIB]: Implement MmMdTruncateDescriptors [BOOTLIB]: Implement MmPaTruncateMemory and call it during paging initialization to remove > 4GB memory.c [BOOTLIB]: Implement BlpMmInitializeConstraints if those BCD options are used. Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/mm/descriptor.c trunk/reactos/boot/environ/lib/mm/i386/mmx86.c trunk/reactos/boot/environ/lib/mm/pagealloc.c Modified: trunk/reactos/boot/environ/include/bl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?rev=74542=74541=74542=diff == --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun May 14 00:39:30 2017 @@ -2088,6 +2088,13 @@ _In_ ULONG Flags ); +NTSTATUS +MmMdTruncateDescriptors ( +_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, +_In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, +_In_ ULONGLONG BasePage +); + VOID MmMdRemoveDescriptorFromList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, @@ -2122,6 +2129,11 @@ ); /* PAGE ALLOCATOR ROUTINES ***/ + +NTSTATUS +MmPaTruncateMemory ( +_In_ ULONGLONG BasePage +); NTSTATUS BlMmAllocatePhysicalPages( Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descriptor.c?rev=74542=74541=74542=diff == --- trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun May 14 00:39:30 2017 @@ -406,6 +406,82 @@ /* Increment the count and return the descriptor */ MmGlobalMemoryDescriptorsUsed++; return MemoryDescriptor; +} + +NTSTATUS +MmMdTruncateDescriptors ( +_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, +_In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, +_In_ ULONGLONG BasePage +) +{ +PLIST_ENTRY ListHead, NextEntry; +PBL_MEMORY_DESCRIPTOR Descriptor, NewDescriptor; +ULONGLONG FoundEndPage; + +/* Search the descriptor list */ +ListHead = MdList->First; +NextEntry = ListHead->Flink; +while (NextEntry != ListHead) +{ +/* Get the current descriptor */ +Descriptor = CONTAINING_RECORD(NextEntry, + BL_MEMORY_DESCRIPTOR, + ListEntry); + +/* Go to the next entry in case we have to remove */ +NextEntry = NextEntry->Flink; + +/* Don't touch anything else but free RAM */ +if (((Descriptor->Type >> BL_MEMORY_CLASS_SHIFT) == BlSystemClass) && +(Descriptor->Type != BlConventionalMemory)) +{ +continue; +} + +/* Check if this page is within the descriptor's region */ +FoundEndPage = Descriptor->BasePage + Descriptor->PageCount; +if (BasePage > Descriptor->BasePage) +{ +/* Check if it doesn't go beyond the descriptor */ +if (BasePage < FoundEndPage) +{ +/* Create a new descriptor to describe this region */ +EfiPrintf(L"Truncating descriptor type %lx base: %llx end: %llx\r\n", + Descriptor->Type, Descriptor->BasePage, FoundEndPage); +NewDescriptor = MmMdInitByteGranularDescriptor(Descriptor->Flags, + Descriptor->Type, + BasePage, + 0, + FoundEndPage - BasePage); +if (!NewDescriptor) +{ +return STATUS_NO_MEMORY; +} + +/* Cut off this descriptor to make it shorter */ +Descriptor->PageCount = BasePage - Descriptor->BasePage; + +/* Add the region to the new list */ +MmMdAddDescriptorToList(NewList, +NewDescriptor, +BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG); +} +} +else +{ +/* This whole descriptor covers the truncated area */ +EfiPrintf(L"Truncating descriptor type %lx base: %llx end: %llx\r\n", + Descriptor->Type, Descriptor->BasePage, FoundEndPage); +MmMdRemoveDescriptorFromList(MdList, Descriptor); +MmMdAddDescriptorToList(NewList, +Descriptor, +
[ros-diffs] [ion] 74541: [BOOTLIB]: Complete implementation of MmMdRemoveRegionFromMdlEx
Author: ion Date: Sun May 14 00:11:48 2017 New Revision: 74541 URL: http://svn.reactos.org/svn/reactos?rev=74541=rev Log: [BOOTLIB]: Complete implementation of MmMdRemoveRegionFromMdlEx Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descriptor.c?rev=74541=74540=74541=diff == --- trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sun May 14 00:11:48 2017 @@ -390,6 +390,7 @@ if (MmGlobalMemoryDescriptorsUsed >= MmGlobalMemoryDescriptorCount) { EfiPrintf(L"Out of descriptors!\r\n"); +EfiStall(100); return NULL; } @@ -409,9 +410,9 @@ BOOLEAN MmMdpTruncateDescriptor ( -__in PBL_MEMORY_DESCRIPTOR_LIST MdList, -__in PBL_MEMORY_DESCRIPTOR MemoryDescriptor, -__in ULONG Flags +_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, +_In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, +_In_ ULONG Flags ) { PBL_MEMORY_DESCRIPTOR NextDescriptor, PreviousDescriptor; @@ -435,12 +436,14 @@ if ((PreviousEntry != MdList->First) && (MemoryDescriptor->BasePage < PreviousEndPage)) { EfiPrintf(L"Overlap detected -- this is unexpected on x86/x64 platforms\r\n"); +EfiStall(100); } /* Check for forward overlap */ if ((NextEntry != MdList->First) && (NextDescriptor->BasePage < EndPage)) { EfiPrintf(L"Overlap detected -- this is unexpected on x86/x64 platforms\r\n"); +EfiStall(100); } /* Nothing to do */ @@ -449,9 +452,9 @@ BOOLEAN MmMdpCoalesceDescriptor ( -__in PBL_MEMORY_DESCRIPTOR_LIST MdList, -__in PBL_MEMORY_DESCRIPTOR MemoryDescriptor, -__in ULONG Flags +_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, +_In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, +_In_ ULONG Flags ) { PBL_MEMORY_DESCRIPTOR NextDescriptor, PreviousDescriptor; @@ -623,28 +626,25 @@ BOOLEAN HaveNewList, UseVirtualPage; NTSTATUS Status; PLIST_ENTRY ListHead, NextEntry; -PBL_MEMORY_DESCRIPTOR Descriptor; -//BL_MEMORY_DESCRIPTOR NewDescriptor; +PBL_MEMORY_DESCRIPTOR Descriptor, NewDescriptor, ListDescriptor; +BL_MEMORY_DESCRIPTOR OldDescriptor; ULONGLONG RegionSize; -ULONGLONG FoundBasePage, FoundEndPage, FoundPageCount, EndPage; +ULONGLONG FoundBasePage, FoundEndPage, FoundPageCount, EndPage, VirtualPage; /* Set initial status */ Status = STATUS_SUCCESS; +ListDescriptor = NULL; +NewDescriptor = NULL; +HaveNewList = FALSE; /* Check if removed descriptors should go into a new list */ if (NewMdList != NULL) { /* Initialize it */ -MmMdInitializeListHead(NewMdList); -NewMdList->Type = MdList->Type; +MmMdInitializeList(NewMdList, MdList->Type, NULL); /* Remember for later */ HaveNewList = TRUE; -} -else -{ -/* For later */ -HaveNewList = FALSE; } /* Is the region being removed physical? */ @@ -684,7 +684,7 @@ EndPage = PageCount + BasePage; /* Make a copy of the original descriptor */ -//NewDescriptor = *Descriptor; // FIXME: Need to use this somewhere... +OldDescriptor = *Descriptor; /* Check if the region to be removed starts after the found region starts */ if ((BasePage > FoundBasePage) || (FoundBasePage >= EndPage)) @@ -695,13 +695,14 @@ /* Check if the found region starts after the region or ends before the region */ if ((FoundBasePage >= BasePage) || (EndPage >= FoundEndPage)) { -/* This descriptor doesn't cover any part of the range -- nothing to do */ -NOTHING; +/* This is a fully-mapped descriptor -- change nothing */ +OldDescriptor.PageCount = 0; } else { /* This descriptor fully covers the entire allocation */ FoundBasePage = Descriptor->BasePage; +VirtualPage = Descriptor->VirtualPage; FoundPageCount = BasePage - FoundBasePage; /* This is how many pages we will eat away from the descriptor */ @@ -710,29 +711,40 @@ /* Update the descriptor to account for the consumed pages */ Descriptor->BasePage += RegionSize; Descriptor->PageCount -= RegionSize; -if (Descriptor->VirtualPage) +if (VirtualPage) { Descriptor->VirtualPage += RegionSize; }
[ros-diffs] [tfaber] 74540: [MKHIVE] - Fail when something goes wrong instead of pretending everything's peachy. CORE-13241 #resolve
Author: tfaber Date: Sat May 13 22:47:59 2017 New Revision: 74540 URL: http://svn.reactos.org/svn/reactos?rev=74540=rev Log: [MKHIVE] - Fail when something goes wrong instead of pretending everything's peachy. CORE-13241 #resolve Modified: trunk/reactos/sdk/tools/mkhive/mkhive.c trunk/reactos/sdk/tools/mkhive/reginf.c Modified: trunk/reactos/sdk/tools/mkhive/mkhive.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/mkhive.c?rev=74540=74539=74540=diff == --- trunk/reactos/sdk/tools/mkhive/mkhive.c [iso-8859-1] (original) +++ trunk/reactos/sdk/tools/mkhive/mkhive.c [iso-8859-1] Sat May 13 22:47:59 2017 @@ -101,7 +101,10 @@ for (i = 2; i < argc; i++) { convert_path (FileName, argv[i]); -ImportRegistryFile (FileName); +if (!ImportRegistryFile (FileName)) +{ +return 1; +} } convert_path (FileName, argv[1]); Modified: trunk/reactos/sdk/tools/mkhive/reginf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/reginf.c?rev=74540=74539=74540=diff == --- trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] (original) +++ trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] Sat May 13 22:47:59 2017 @@ -501,11 +501,15 @@ if (!registry_callback (hInf, (PWCHAR)DelReg, TRUE)) { DPRINT1 ("registry_callback() for DelReg failed\n"); +InfHostCloseFile (hInf); +return FALSE; } if (!registry_callback (hInf, (PWCHAR)AddReg, FALSE)) { DPRINT1 ("registry_callback() for AddReg failed\n"); +InfHostCloseFile (hInf); +return FALSE; } InfHostCloseFile (hInf);
[ros-diffs] [tkreuzer] 74539: [NTOSKRNL] Improve S-List-Fault detection in KiTrap0EHandler to handle usermode faults as well.
Author: tkreuzer Date: Sat May 13 20:07:39 2017 New Revision: 74539 URL: http://svn.reactos.org/svn/reactos?rev=74539=rev Log: [NTOSKRNL] Improve S-List-Fault detection in KiTrap0EHandler to handle usermode faults as well. Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c?rev=74539=74538=74539=diff == --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Sat May 13 20:07:39 2017 @@ -15,6 +15,8 @@ VOID __cdecl KiFastCallEntry(VOID); VOID __cdecl KiFastCallEntryWithSingleStep(VOID); +extern PVOID KeUserPopEntrySListFault; +extern PVOID KeUserPopEntrySListResume; extern PVOID FrRestore; VOID FASTCALL Ke386LoadFpuState(IN PFX_SAVE_AREA SaveArea); @@ -1240,10 +1242,46 @@ TrapFrame); } -/* Check for S-LIST fault in kernel mode */ -if (TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault) -{ -PSLIST_HEADER SListHeader; +/* Check for S-List fault + + Explanation: An S-List fault can occur due to a race condition between 2 + threads simultaneously trying to pop an element from the S-List. After + thread 1 has read the pointer to the top element on the S-List it is + preempted and thread 2 calls InterlockedPopEntrySlist on the same S-List, + removing the top element and freeing it's memory. After that thread 1 + resumes and tries to read the address of the Next pointer from the top + element, which it assumes will be the next top element. + But since that memory has been freed, we get a page fault. To handle this + race condition, we let thread 1 repeat the operation. + We do NOT invoke the page fault handler in this case, since we do not + want to trigger any side effects, like paging or a guard page fault. + + Sequence of operations: + + Thread 1 : mov eax, [ebp] <= eax now points to the first element + Thread 1 : mov edx, [ebp + 4] <= edx is loaded with Depth and Sequence +*** preempted *** + Thread 2 : calls InterlockedPopEntrySlist, changing the top element + Thread 2 : frees the memory of the element that was popped +*** preempted *** + Thread 1 : checks if eax is NULL + Thread 1 : InterlockedPopEntrySListFault: mov ebx, [eax] <= faults + +To be sure that we are dealing with exactly the case described above, we +check whether the ListHeader has changed. If Thread 2 only popped one +entry, the Next field in the S-List-header has changed. +If after thread 1 has faulted, thread 2 allocates a new element, by +chance getting the same address as the previously freed element and +pushes it on the list again, we will see the same top element, but the +Sequence member of the S-List header has changed. Therefore we check +both fields to make sure we catch any concurrent modification of the +S-List-header. +*/ +if ((TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault) || +(TrapFrame->Eip == (ULONG_PTR)KeUserPopEntrySListFault)) +{ +ULARGE_INTEGER SListHeader; +PVOID ResumeAddress; /* Sanity check that the assembly is correct: This must be mov ebx, [eax] @@ -1255,30 +1293,50 @@ (((UCHAR*)TrapFrame->Eip)[4] == 0x4D) && (((UCHAR*)TrapFrame->Eip)[5] == 0x00)); -/* Get the pointer to the SLIST_HEADER */ -SListHeader = (PSLIST_HEADER)TrapFrame->Ebp; - -/* Check if the Next member of the SLIST_HEADER was changed */ -if (SListHeader->Next.Next != (PSLIST_ENTRY)TrapFrame->Eax) -{ +/* Check if this is a user fault */ +if (TrapFrame->Eip == (ULONG_PTR)KeUserPopEntrySListFault) +{ +/* EBP points to the S-List-header. Copy it inside SEH, to protect + against a bogus pointer from user mode */ +_SEH2_TRY +{ +ProbeForRead((PVOID)TrapFrame->Ebp, + sizeof(ULARGE_INTEGER), + TYPE_ALIGNMENT(SLIST_HEADER)); +SListHeader = *(PULARGE_INTEGER)TrapFrame->Ebp; +} +_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) +{ +/* The S-List pointer is not valid! */ +goto NotSListFault; +} +_SEH2_END; +ResumeAddress = KeUserPopEntrySListResume; +} +else +{ +SListHeader = *(PULARGE_INTEGER)TrapFrame->Ebp; +ResumeAddress = ExpInterlockedPopEntrySListResume; +} + +/* Check if either the Next pointer or the
[ros-diffs] [hbelusca] 74538: Addendum to r74528 (and close the opened file handle only on success).
Author: hbelusca Date: Sat May 13 20:04:11 2017 New Revision: 74538 URL: http://svn.reactos.org/svn/reactos?rev=74538=rev Log: Addendum to r74528 (and close the opened file handle only on success). Modified: branches/setup_improvements/base/setup/usetup/filesup.c Modified: branches/setup_improvements/base/setup/usetup/filesup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/filesup.c?rev=74538=74537=74538=diff == --- branches/setup_improvements/base/setup/usetup/filesup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/filesup.c [iso-8859-1] Sat May 13 20:04:11 2017 @@ -105,8 +105,7 @@ HANDLE FileHandle; NTSTATUS Status; -RtlInitUnicodeString(, - PathName); +RtlInitUnicodeString(, PathName); InitializeObjectAttributes(, , @@ -120,14 +119,10 @@ , 0, FILE_SYNCHRONOUS_IO_NONALERT); -if (!NT_SUCCESS(Status)) -{ -return FALSE; -} - -NtClose(FileHandle); - -return TRUE; +if (NT_SUCCESS(Status)) +NtClose(FileHandle); + +return NT_SUCCESS(Status); } @@ -523,8 +518,8 @@ , 0, FILE_SYNCHRONOUS_IO_NONALERT); - -NtClose(FileHandle); +if (NT_SUCCESS(Status)) +NtClose(FileHandle); return NT_SUCCESS(Status); }
[ros-diffs] [tfaber] 74537: [CMAKE] - Only call mkhive once, as it always generates all 6 binary hives (and if you don't give it all inf files, some of the hives will end up empty). - Remove no longer
Author: tfaber Date: Sat May 13 19:54:51 2017 New Revision: 74537 URL: http://svn.reactos.org/svn/reactos?rev=74537=rev Log: [CMAKE] - Only call mkhive once, as it always generates all 6 binary hives (and if you don't give it all inf files, some of the hives will end up empty). - Remove no longer needed dependency of efisys on bcd_hive CORE-13241 Modified: trunk/reactos/boot/CMakeLists.txt trunk/reactos/sdk/cmake/CMakeMacros.cmake Modified: trunk/reactos/boot/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/CMakeLists.txt?rev=74537=74536=74537=diff == --- trunk/reactos/boot/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/CMakeLists.txt [iso-8859-1] Sat May 13 19:54:51 2017 @@ -17,7 +17,7 @@ add_custom_target(efisys COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $ EFI/BOOT/boot${EFI_PLATFORM_ID}.efi -DEPENDS native-fatten fat bootmgfw bcd_hive +DEPENDS native-fatten fat bootmgfw VERBATIM) Modified: trunk/reactos/sdk/cmake/CMakeMacros.cmake URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/cmake/CMakeMacros.cmake?rev=74537=74536=74537=diff == --- trunk/reactos/sdk/cmake/CMakeMacros.cmake [iso-8859-1] (original) +++ trunk/reactos/sdk/cmake/CMakeMacros.cmake [iso-8859-1] Sat May 13 19:54:51 2017 @@ -774,6 +774,7 @@ ${CMAKE_BINARY_DIR}/boot/bootdata/security ${CMAKE_BINARY_DIR}/boot/bootdata/software ${CMAKE_BINARY_DIR}/boot/bootdata/system +${CMAKE_BINARY_DIR}/boot/bootdata/BCD COMMAND native-mkhive ${CMAKE_BINARY_DIR}/boot/bootdata ${_livecd_inf_files} DEPENDS native-mkhive ${_livecd_inf_files}) @@ -782,7 +783,8 @@ ${CMAKE_BINARY_DIR}/boot/bootdata/default ${CMAKE_BINARY_DIR}/boot/bootdata/security ${CMAKE_BINARY_DIR}/boot/bootdata/software -${CMAKE_BINARY_DIR}/boot/bootdata/system) +${CMAKE_BINARY_DIR}/boot/bootdata/system +${CMAKE_BINARY_DIR}/boot/bootdata/BCD) add_cd_file( FILE ${CMAKE_BINARY_DIR}/boot/bootdata/sam @@ -794,18 +796,9 @@ DESTINATION reactos/system32/config FOR livecd) -# BCD Hive -add_custom_command( -OUTPUT ${CMAKE_BINARY_DIR}/boot/bootdata/BCD -COMMAND native-mkhive ${CMAKE_BINARY_DIR}/boot/bootdata ${CMAKE_BINARY_DIR}/boot/bootdata/hivebcd_utf16.inf -DEPENDS native-mkhive ${CMAKE_SOURCE_DIR}/boot/bootdata/hivebcd.inf) - -add_custom_target(bcd_hive -DEPENDS ${CMAKE_BINARY_DIR}/boot/bootdata/BCD) - add_cd_file( FILE ${CMAKE_BINARY_DIR}/boot/bootdata/BCD -TARGET bcd_hive +TARGET livecd_hives DESTINATION efi/boot NO_CAB FOR bootcd regtest livecd)
[ros-diffs] [ion] 74536: [BOOTLIB]: Separate free and zero memory, and code vs data runtime data, as newer bootlibs do. [BOOTLIB]: Fix bugs in MmMdpHasPrecedence and cleanup. [BOOTLIB]: Fix bug in MmM
Author: ion Date: Sat May 13 19:32:26 2017 New Revision: 74536 URL: http://svn.reactos.org/svn/reactos?rev=74536=rev Log: [BOOTLIB]: Separate free and zero memory, and code vs data runtime data, as newer bootlibs do. [BOOTLIB]: Fix bugs in MmMdpHasPrecedence and cleanup. [BOOTLIB]: Fix bug in MmMdFreeDescriptor. [BOOTLIB]: Cleanup MmMdpSaveCurrentListPointer. [BOOTLIB]: Fix bug in MmMdpCoalesceDescriptor. [BOOTLIB]: Fix multiple bugs in MmMdAddDescriptorToList, and cleanup. Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/firmware/efi/firmware.c trunk/reactos/boot/environ/lib/mm/descriptor.c trunk/reactos/boot/environ/lib/mm/i386/mmx86.c Modified: trunk/reactos/boot/environ/include/bl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?rev=74536=74535=74536=diff == --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sat May 13 19:32:26 2017 @@ -329,12 +329,14 @@ BlUnusableMemory = 0xF002, BlReservedMemory = 0xF003, BlEfiBootMemory = 0xF004, -BlEfiRuntimeMemory = 0xF006, +BlConventionalZeroedMemory = 0xF05, +BlEfiRuntimeCodeMemory = 0xF006, BlAcpiReclaimMemory = 0xF008, BlAcpiNvsMemory = 0xF009, BlDeviceIoMemory = 0xF00A, BlDevicePortMemory = 0xF00B, BlPalMemory = 0xF00C, +BlEfiRuntimeDataMemory = 0xF00E, } BL_MEMORY_TYPE; typedef enum _BL_MEMORY_ATTR Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/efi/firmware.c?rev=74536=74535=74536=diff == --- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Sat May 13 19:32:26 2017 @@ -1343,8 +1343,11 @@ break; case EfiRuntimeServicesCode: +OsType = BlEfiRuntimeCodeMemory; +break; + case EfiRuntimeServicesData: -OsType = BlEfiRuntimeMemory; +OsType = BlEfiRuntimeDataMemory; break; case EfiConventionalMemory: Modified: trunk/reactos/boot/environ/lib/mm/descriptor.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/descriptor.c?rev=74536=74535=74536=diff == --- trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/mm/descriptor.c [iso-8859-1] Sat May 13 19:32:26 2017 @@ -26,13 +26,38 @@ BlDeviceIoMemory, BlDevicePortMemory, BlPalMemory, -BlEfiRuntimeMemory, +BlEfiRuntimeCodeMemory, +BlEfiRuntimeDataMemory, BlAcpiNvsMemory, BlAcpiReclaimMemory, -BlEfiBootMemory +BlEfiBootMemory, +BlConventionalMemory, +BlConventionalZeroedMemory }; /* FUNCTIONS */ + +LONG +MmMdpLookupTypePrecedenceIndex ( +_In_ BL_MEMORY_TYPE Type +) +{ +ULONG i; + +/* Check the precedence array */ +for (i = 0; i < RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence); i++) +{ +/* Check for a match */ +if (MmPlatformMemoryTypePrecedence[i] == Type) +{ +/* Return the index */ +return i; +} +} + +/* Invalid index type */ +return -1; +} /* The order is Conventional > Other > System > Loader > Application */ BOOLEAN @@ -44,14 +69,14 @@ BL_MEMORY_CLASS Class1, Class2; ULONG i, j; +/* It isn't free RAM, but the comparator is -- it succeeds it */ +if (Type2 == BlConventionalMemory) +{ +return TRUE; +} + /* Descriptor is free RAM -- it precedes */ if (Type1 == BlConventionalMemory) -{ -return TRUE; -} - -/* It isn't free RAM, but the comparator is -- it succeeds it */ -if (Type2 == BlConventionalMemory) { return FALSE; } @@ -77,55 +102,30 @@ /* Descriptor is system class */ if (Class1 == BlSystemClass) { -/* And so is the other guy... */ -if (Class2 == BlSystemClass) -{ -i = 0; -j = 0; - -/* Scan for the descriptor's system precedence index */ -do -{ -if (MmPlatformMemoryTypePrecedence[j] == Type1) -{ -break; -} -} while (++j < RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence)); - -/* Use an invalid index if one wasn't found */ -if (j == RTL_NUMBER_OF(MmPlatformMemoryTypePrecedence)) -{ -j = 0x; -
[ros-diffs] [mjansen] 74535: [APPHELP][SHIMLIB] Forward some events to loaded shims. CORE-11329
Author: mjansen Date: Sat May 13 18:49:27 2017 New Revision: 74535 URL: http://svn.reactos.org/svn/reactos?rev=74535=rev Log: [APPHELP][SHIMLIB] Forward some events to loaded shims. CORE-11329 Added: trunk/reactos/dll/appcompat/apphelp/shimeng.c (with props) Removed: trunk/reactos/dll/appcompat/shims/shimlib/shimdbgsupp.c Modified: trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt trunk/reactos/dll/appcompat/apphelp/apphelp.spec trunk/reactos/dll/appcompat/shims/shimlib/CMakeLists.txt trunk/reactos/dll/appcompat/shims/shimlib/shimlib.h Modified: trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt?rev=74535=74534=74535=diff == --- trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt [iso-8859-1] Sat May 13 18:49:27 2017 @@ -15,6 +15,7 @@ sdbread.c sdbstringtable.c sdbwrite.c +shimeng.c apphelp.spec apphelp.h ${CMAKE_CURRENT_BINARY_DIR}/apphelp_stubs.c) Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apphelp.spec?rev=74535=74534=74535=diff == --- trunk/reactos/dll/appcompat/apphelp/apphelp.spec[iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/apphelp.spec[iso-8859-1] Sat May 13 18:49:27 2017 @@ -157,17 +157,19 @@ @ stdcall SdbWriteStringTag(ptr long wstr) @ stub SdbWriteStringTagDirect @ stdcall SdbWriteWORDTag(ptr long long) -@ stub SE_DllLoaded -@ stub SE_DllUnloaded +@ stdcall SE_DllLoaded(ptr) +@ stdcall SE_DllUnloaded(ptr) +@ stub SE_DynamicShim +@ stub SE_DynamicUnshim +@ stdcall SE_InstallAfterInit(ptr ptr) +@ stdcall SE_InstallBeforeInit(ptr ptr) +@ stdcall SE_IsShimDll(ptr) +@ stdcall SE_ProcessDying() @ stub SE_GetHookAPIs @ stub SE_GetMaxShimCount @ stub SE_GetProcAddressLoad @ stub SE_GetShimCount -@ stub SE_InstallAfterInit -@ stub SE_InstallBeforeInit -@ stub SE_IsShimDll @ stub SE_LdrEntryRemoved -@ stub SE_ProcessDying @ stub SetPermLayers @ cdecl ShimDbgPrint(long str str) @ stub ShimDumpCache Added: trunk/reactos/dll/appcompat/apphelp/shimeng.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/shimeng.c?rev=74535 == --- trunk/reactos/dll/appcompat/apphelp/shimeng.c (added) +++ trunk/reactos/dll/appcompat/apphelp/shimeng.c [iso-8859-1] Sat May 13 18:49:27 2017 @@ -0,0 +1,163 @@ +/* + * Copyright 2015-2017 Mark Jansen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define WIN32_NO_STATUS +#include "windows.h" +#include "ntndk.h" +#include "shimlib.h" +#include + +HANDLE g_pShimEngModHandle = 0; + + +ULONG g_ShimEngDebugLevel = 0x; + + + + +VOID SeiInitDebugSupport(VOID) +{ +static const UNICODE_STRING DebugKey = RTL_CONSTANT_STRING(L"SHIMENG_DEBUG_LEVEL"); +UNICODE_STRING DebugValue; +NTSTATUS Status; +ULONG NewLevel = 0; +WCHAR Buffer[40]; + +RtlInitEmptyUnicodeString(, Buffer, sizeof(Buffer)); + +Status = RtlQueryEnvironmentVariable_U(NULL, , ); + +if (NT_SUCCESS(Status)) +{ +if (!NT_SUCCESS(RtlUnicodeStringToInteger(, 10, ))) +NewLevel = 0; +} +g_ShimEngDebugLevel = NewLevel; +} + + +/** + * Outputs diagnostic info. + * + * @param [in] Level The level to log this message with, choose any of [SHIM_ERR, + * SHIM_WARN, SHIM_INFO]. + * @param [in] FunctionNameThe function this log should be attributed to. + * @param [in] Format The format string. + * @param ... Variable arguments providing additional information. + * + * @return Success: TRUE Failure: FALSE. + */ +BOOL WINAPIV SeiDbgPrint(SEI_LOG_LEVEL Level, PCSTR Function, PCSTR Format, ...) +{ +char Buffer[512]; +char* Current = Buffer; +const char* LevelStr; +size_t Length = sizeof(Buffer); +va_list ArgList; +HRESULT hr; + +if (g_ShimEngDebugLevel
[ros-diffs] [mjansen] 74534: [NDK][RTL] Make the Name argument in RtlQueryEnvironmentVariable_U const.
Author: mjansen Date: Sat May 13 17:26:59 2017 New Revision: 74534 URL: http://svn.reactos.org/svn/reactos?rev=74534=rev Log: [NDK][RTL] Make the Name argument in RtlQueryEnvironmentVariable_U const. Modified: trunk/reactos/sdk/include/ndk/rtlfuncs.h trunk/reactos/sdk/lib/rtl/env.c Modified: trunk/reactos/sdk/include/ndk/rtlfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ndk/rtlfuncs.h?rev=74534=74533=74534=diff == --- trunk/reactos/sdk/include/ndk/rtlfuncs.h[iso-8859-1] (original) +++ trunk/reactos/sdk/include/ndk/rtlfuncs.h[iso-8859-1] Sat May 13 17:26:59 2017 @@ -2967,7 +2967,7 @@ NTAPI RtlQueryEnvironmentVariable_U( _In_opt_ PWSTR Environment, -_In_ PUNICODE_STRING Name, +_In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value ); Modified: trunk/reactos/sdk/lib/rtl/env.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/env.c?rev=74534=74533=74534=diff == --- trunk/reactos/sdk/lib/rtl/env.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/env.c [iso-8859-1] Sat May 13 17:26:59 2017 @@ -508,7 +508,7 @@ */ NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(PWSTR Environment, - PUNICODE_STRING Name, + PCUNICODE_STRING Name, PUNICODE_STRING Value) { NTSTATUS Status;
[ros-diffs] [tfaber] 74533: [0.4.5] - Set version number to final release
Author: tfaber Date: Sat May 13 16:42:08 2017 New Revision: 74533 URL: http://svn.reactos.org/svn/reactos?rev=74533=rev Log: [0.4.5] - Set version number to final release Modified: branches/ros-branch-0_4_5/reactos/sdk/include/reactos/version.cmake Modified: branches/ros-branch-0_4_5/reactos/sdk/include/reactos/version.cmake URL: http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_5/reactos/sdk/include/reactos/version.cmake?rev=74533=74532=74533=diff == --- branches/ros-branch-0_4_5/reactos/sdk/include/reactos/version.cmake [iso-8859-1] (original) +++ branches/ros-branch-0_4_5/reactos/sdk/include/reactos/version.cmake [iso-8859-1] Sat May 13 16:42:08 2017 @@ -25,7 +25,7 @@ set(KERNEL_VERSION_BUILD_TYPE "") # KERNEL_VERSION_RELEASE_TYPE is "RC1", "RC2" or "" (for the final one) -set(KERNEL_VERSION_RELEASE_TYPE "RC2") +set(KERNEL_VERSION_RELEASE_TYPE "") set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}") if(KERNEL_VERSION_PATCH_LEVEL)
[ros-diffs] [hbelusca] 74532: [USETUP]: Further improvements: - Comment more some of the fields in the PARTENTRY, DISKETNRY and PARTLIST structures; - Remove the redundant members "SystemDisk", "Origi
Author: hbelusca Date: Sat May 13 16:40:30 2017 New Revision: 74532 URL: http://svn.reactos.org/svn/reactos?rev=74532=rev Log: [USETUP]: Further improvements: - Comment more some of the fields in the PARTENTRY, DISKETNRY and PARTLIST structures; - Remove the redundant members "SystemDisk", "OriginalSystemDisk" and "TempDisk" in PARTLIST as these can be consistently deduced from the corresponding (Original)(System)(Temp)Partition members (note that we however keep "CurrentDisk" alongside "CurrentPartition", see the comment in the code why we do it so). - Adjust the rest of the code to take the removal of the redundant members into account. The 2nd parameter of GetNextUnformattedPartition() and GetNextUncheckedPartition() are now really optional. - Introduce a SetPartitionType() helper to simplify the code that sets the partition type, which also automatically adjusts other internal variables of said partition in accordance. - "Mounted" logical drives can have assigned letters too, registered in \DosDevices\. Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c branches/setup_improvements/base/setup/usetup/partlist.c branches/setup_improvements/base/setup/usetup/partlist.h Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/interface/usetup.c?rev=74532=74531=74532=diff == --- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Sat May 13 16:40:30 2017 @@ -2590,9 +2590,7 @@ /* Find or set the active system partition */ CheckActiveSystemPartition(PartitionList, FileSystemList); - -if (PartitionList->SystemDisk == NULL || -PartitionList->SystemPartition == NULL) +if (PartitionList->SystemPartition == NULL) { /* FIXME: show an error dialog */ return QUIT_PAGE; @@ -2604,7 +2602,6 @@ case Start: if (PartitionList->CurrentPartition != PartitionList->SystemPartition) { -PartitionList->TempDisk = PartitionList->SystemDisk; PartitionList->TempPartition = PartitionList->SystemPartition; PartitionList->TempPartition->NeedsCheck = TRUE; @@ -2613,7 +2610,6 @@ } else { -PartitionList->TempDisk = PartitionList->CurrentDisk; PartitionList->TempPartition = PartitionList->CurrentPartition; PartitionList->TempPartition->NeedsCheck = TRUE; @@ -2623,7 +2619,6 @@ break; case FormatSystemPartition: -PartitionList->TempDisk = PartitionList->CurrentDisk; PartitionList->TempPartition = PartitionList->CurrentPartition; PartitionList->TempPartition->NeedsCheck = TRUE; @@ -2633,7 +2628,7 @@ case FormatInstallPartition: if (GetNextUnformattedPartition(PartitionList, ->TempDisk, +NULL, >TempPartition)) { PartitionList->FormatState = FormatOtherPartition; @@ -2650,7 +2645,7 @@ case FormatOtherPartition: if (GetNextUnformattedPartition(PartitionList, ->TempDisk, +NULL, >TempPartition)) { PartitionList->FormatState = FormatOtherPartition; @@ -2671,8 +2666,8 @@ return QUIT_PAGE; } -DiskEntry = PartitionList->TempDisk; PartEntry = PartitionList->TempPartition; +DiskEntry = PartEntry->DiskEntry; /* Adjust disk size */ DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; @@ -2903,15 +2898,14 @@ MUIDisplayPage(FORMAT_PARTITION_PAGE); if (PartitionList == NULL || -PartitionList->TempDisk == NULL || PartitionList->TempPartition == NULL) { /* FIXME: show an error dialog */ return QUIT_PAGE; } -DiskEntry = PartitionList->TempDisk; PartEntry = PartitionList->TempPartition; +DiskEntry = PartEntry->DiskEntry; while (TRUE) { @@ -2937,7 +2931,7 @@ if (PartEntry->SectorCount.QuadPart < 8192) { /* FAT12 CHS partition (disk is smaller than 4.1MB) */ -PartEntry->PartitionType = PARTITION_FAT_12; +SetPartitionType(PartEntry, PARTITION_FAT_12); } else if (PartEntry->StartSector.QuadPart < 1450560) { @@ -2946,17 +2940,17 @@ if
[ros-diffs] [hbelusca] 74531: [USETUP]: Code improvements: - Use explicit ansi string safe functions (where they are used ansi, but not explicitely); - Add (old-school) function parameters annotations
Author: hbelusca Date: Sat May 13 16:32:53 2017 New Revision: 74531 URL: http://svn.reactos.org/svn/reactos?rev=74531=rev Log: [USETUP]: Code improvements: - Use explicit ansi string safe functions (where they are used ansi, but not explicitely); - Add (old-school) function parameters annotations; - Use PARTITION_ENTRY_UNUSED where needed (instead of hardcoding its value); - Turn some functions static to this module; - Turn the 2nd parameter of both GetNextUnformattedPartition() and GetNextUncheckedPartition() optional (for next commit); - Improve some comments; - Use NT types. Modified: branches/setup_improvements/base/setup/usetup/partlist.c branches/setup_improvements/base/setup/usetup/partlist.h Modified: branches/setup_improvements/base/setup/usetup/partlist.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/partlist.c?rev=74531=74530=74531=diff == --- branches/setup_improvements/base/setup/usetup/partlist.c[iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/partlist.c[iso-8859-1] Sat May 13 16:32:53 2017 @@ -173,19 +173,19 @@ VOID GetPartTypeStringFromPartitionType( -UCHAR partitionType, -PCHAR strPartType, -DWORD cchPartType) +IN UCHAR partitionType, +OUT PCHAR strPartType, +IN ULONG cchPartType) { /* Determine partition type */ if (IsContainerPartition(partitionType)) { -StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_EXTENDED_PARTITION)); +StringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_EXTENDED_PARTITION)); } else if (partitionType == PARTITION_ENTRY_UNUSED) { -StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_FORMATUNUSED)); +StringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_FORMATUNUSED)); } else { @@ -196,13 +196,13 @@ { if (partitionType == PartitionTypes[i].Type) { -StringCchCopy(strPartType, cchPartType, PartitionTypes[i].Description); +StringCchCopyA(strPartType, cchPartType, PartitionTypes[i].Description); return; } } /* We are here because the partition type is unknown */ -StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_FORMATUNKNOWN)); +StringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_FORMATUNKNOWN)); } } @@ -252,7 +252,6 @@ return Temp * Alignment; } - ULONGLONG AlignUp( IN ULONGLONG Value, @@ -281,7 +280,7 @@ static VOID GetDriverName( -PDISKENTRY DiskEntry) +IN PDISKENTRY DiskEntry) { RTL_QUERY_REGISTRY_TABLE QueryTable[2]; WCHAR KeyName[32]; @@ -316,7 +315,7 @@ static VOID AssignDriveLetters( -PPARTLIST List) +IN PPARTLIST List) { PDISKENTRY DiskEntry; PPARTENTRY PartEntry; @@ -395,7 +394,7 @@ } -NTSTATUS +static NTSTATUS NTAPI DiskIdentifierQueryRoutine( PWSTR ValueName, @@ -425,7 +424,7 @@ } -NTSTATUS +static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine( PWSTR ValueName, @@ -469,7 +468,7 @@ } -NTSTATUS +static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine( PWSTR ValueName, @@ -521,7 +520,7 @@ static VOID EnumerateBiosDiskEntries( -PPARTLIST PartList) +IN PPARTLIST PartList) { RTL_QUERY_REGISTRY_TABLE QueryTable[3]; WCHAR Name[120]; @@ -662,16 +661,16 @@ static VOID AddPartitionToDisk( -ULONG DiskNumber, -PDISKENTRY DiskEntry, -ULONG PartitionIndex, -BOOLEAN LogicalPartition) +IN ULONG DiskNumber, +IN PDISKENTRY DiskEntry, +IN ULONG PartitionIndex, +IN BOOLEAN LogicalPartition) { PPARTITION_INFORMATION PartitionInfo; PPARTENTRY PartEntry; PartitionInfo = >LayoutBuffer->PartitionEntry[PartitionIndex]; -if (PartitionInfo->PartitionType == 0 || +if (PartitionInfo->PartitionType == PARTITION_ENTRY_UNUSED || (LogicalPartition == TRUE && IsContainerPartition(PartitionInfo->PartitionType))) return; @@ -772,7 +771,7 @@ static VOID ScanForUnpartitionedDiskSpace( -PDISKENTRY DiskEntry) +IN PDISKENTRY DiskEntry) { ULONGLONG LastStartSector; ULONGLONG LastSectorCount; @@ -787,7 +786,7 @@ { DPRINT1("No primary partition!\n"); -/* Create a partition table that represents the empty disk */ +/* Create a partition entry that represents the empty disk */ NewPartEntry = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, sizeof(PARTENTRY)); @@ -905,7 +904,7 @@ { DPRINT1("No logical partition!\n"); -/* Create a partition table entry that represents the empty extended partition */ +/* Create a partition entry that represents the empty
[ros-diffs] [hbelusca] 74530: [USETUP]: Code formatting only.
Author: hbelusca Date: Sat May 13 16:23:08 2017 New Revision: 74530 URL: http://svn.reactos.org/svn/reactos?rev=74530=rev Log: [USETUP]: Code formatting only. Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/interface/usetup.c?rev=74530=74529=74530=diff == --- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Sat May 13 16:23:08 2017 @@ -1604,32 +1604,32 @@ } else if (PartitionList->CurrentPartition->LogicalPartition) { - if (PartitionList->CurrentPartition->IsPartitioned) - { - CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION)); - } - else - { - CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL)); - } +if (PartitionList->CurrentPartition->IsPartitioned) +{ +CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION)); +} +else +{ + CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL)); +} } else { - if (PartitionList->CurrentPartition->IsPartitioned) - { - if (IsContainerPartition(PartitionList->CurrentPartition->PartitionType)) - { - CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION)); - } - else - { - CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION)); - } - } - else - { - CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION)); - } +if (PartitionList->CurrentPartition->IsPartitioned) +{ +if (IsContainerPartition(PartitionList->CurrentPartition->PartitionType)) +{ + CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION)); +} +else +{ + CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION)); +} +} +else +{ + CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION)); +} } CONSOLE_ConInKey(Ir); @@ -1661,7 +1661,7 @@ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ { if (IsContainerPartition(PartitionList->CurrentPartition->PartitionType)) -continue; //return SELECT_PARTITION_PAGE; +continue; // return SELECT_PARTITION_PAGE; if (PartitionList->CurrentPartition == NULL || PartitionList->CurrentPartition->IsPartitioned == FALSE) @@ -2674,7 +2674,7 @@ DiskEntry = PartitionList->TempDisk; PartEntry = PartitionList->TempPartition; -/* adjust disk size */ +/* Adjust disk size */ DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; if (DiskSize >= 10737418240) /* 10 GB */ { @@ -2687,7 +2687,7 @@ DiskUnit = MUIGetString(STRING_MB); } -/* adjust partition size */ +/* Adjust partition size */ PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; if (PartSize >= 10737418240) /* 10 GB */ { @@ -2700,7 +2700,7 @@ PartUnit = MUIGetString(STRING_MB); } -/* adjust partition type */ +/* Adjust partition type */ GetPartTypeStringFromPartitionType(PartEntry->PartitionType, PartTypeString, ARRAYSIZE(PartTypeString)); @@ -2728,7 +2728,6 @@ CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT)); - PartEntry->AutoCreate = FALSE; } else if (PartEntry->New == TRUE) @@ -2853,7 +2852,7 @@ { if (!FileSystemList->Selected->FormatFunc) { - return SELECT_FILE_SYSTEM_PAGE; +return SELECT_FILE_SYSTEM_PAGE; } else {
[ros-diffs] [hbelusca] 74529: [USETUP]: On-going improvements for filesystem utility functions: - Introduce code that detects the filesystem of a (mounted?) partition, using NtQueryVolumeInformationFi
Author: hbelusca Date: Sat May 13 16:20:10 2017 New Revision: 74529 URL: http://svn.reactos.org/svn/reactos?rev=74529=rev Log: [USETUP]: On-going improvements for filesystem utility functions: - Introduce code that detects the filesystem of a (mounted?) partition, using NtQueryVolumeInformationFile with FileFsAttributeInformation class, aka. rely on ReactOS itself (kernel, storage stack, filesystem drivers...) to recognize the FS on a partition that should normally be seen by the system. This currently half-works for whatever reason (to be insvestigated), while it works on Windows. - Fix few comments & a function parameter name. - Use NT string pointer types. Modified: branches/setup_improvements/base/setup/usetup/fslist.c branches/setup_improvements/base/setup/usetup/fslist.h Modified: branches/setup_improvements/base/setup/usetup/fslist.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/fslist.c?rev=74529=74528=74529=diff == --- branches/setup_improvements/base/setup/usetup/fslist.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/fslist.c [iso-8859-1] Sat May 13 16:20:10 2017 @@ -35,7 +35,7 @@ VOID FS_AddProvider( IN OUT PFILE_SYSTEM_LIST List, -IN LPCWSTR FileSystemName, +IN PCWSTR FileSystemName, IN FORMATEX FormatFunc, IN CHKDSKEX ChkdskFunc) { @@ -69,7 +69,7 @@ PFILE_SYSTEM_ITEM GetFileSystemByName( IN PFILE_SYSTEM_LIST List, -IN LPWSTR FileSystemName) +IN PWSTR FileSystemName) { PLIST_ENTRY ListEntry; PFILE_SYSTEM_ITEM Item; @@ -87,6 +87,80 @@ return NULL; } +#if 0 // FIXME: To be fully enabled when our storage stack & al. will work better! + +/* NOTE: Ripped & adapted from base/system/autochk/autochk.c */ +static NTSTATUS +_MyGetFileSystem( +IN struct _PARTENTRY* PartEntry, +IN OUT PWSTR FileSystemName, +IN SIZE_T FileSystemNameSize) +{ +NTSTATUS Status; +HANDLE FileHandle; +IO_STATUS_BLOCK IoStatusBlock; +PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute; +UCHAR Buffer[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + MAX_PATH * sizeof(WCHAR)]; + +OBJECT_ATTRIBUTES ObjectAttributes; +UNICODE_STRING PartitionRootPath; +WCHAR PathBuffer[MAX_PATH]; + +FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer; + +/* Set PartitionRootPath */ +swprintf(PathBuffer, + // L"\\Device\\Harddisk%lu\\Partition%lu", // Should work! But because ReactOS sucks atm. it actually doesn't work!! + L"\\Device\\Harddisk%lu\\Partition%lu\\", // HACK: Use this as a temporary hack! + PartEntry->DiskEntry->DiskNumber, + PartEntry->PartitionNumber); +RtlInitUnicodeString(, PathBuffer); +DPRINT("PartitionRootPath: %wZ\n", ); + +/* Open the partition */ +InitializeObjectAttributes(, + , + OBJ_CASE_INSENSITIVE, + NULL, + NULL); +Status = NtOpenFile(, // PartitionHandle, +FILE_GENERIC_READ /* | SYNCHRONIZE */, +, +, +FILE_SHARE_READ, +0 /* FILE_SYNCHRONOUS_IO_NONALERT */); +if (!NT_SUCCESS(Status)) +{ +DPRINT1("Failed to open partition %wZ, Status 0x%08lx\n", , Status); +return Status; +} + +/* Retrieve the FS attributes */ +Status = NtQueryVolumeInformationFile(FileHandle, + , + FileFsAttribute, + sizeof(Buffer), + FileFsAttributeInformation); +NtClose(FileHandle); + +if (!NT_SUCCESS(Status)) +{ +DPRINT1("NtQueryVolumeInformationFile failed for partition %wZ, Status 0x%08lx\n", , Status); +return Status; +} + +if (FileSystemNameSize * sizeof(WCHAR) < FileFsAttribute->FileSystemNameLength + sizeof(WCHAR)) +return STATUS_BUFFER_TOO_SMALL; + +RtlCopyMemory(FileSystemName, + FileFsAttribute->FileSystemName, + FileFsAttribute->FileSystemNameLength); +FileSystemName[FileFsAttribute->FileSystemNameLength / sizeof(WCHAR)] = UNICODE_NULL; + +return STATUS_SUCCESS; +} + +#endif PFILE_SYSTEM_ITEM GetFileSystem( @@ -94,7 +168,11 @@ IN struct _PARTENTRY* PartEntry) { PFILE_SYSTEM_ITEM CurrentFileSystem; -LPWSTR FileSystemName = NULL; +PWSTR FileSystemName = NULL; +#if 0 // For code temporarily disabled below +NTSTATUS Status; +WCHAR FsRecFileSystemName[MAX_PATH]; +#endif CurrentFileSystem = PartEntry->FileSystem; @@ -105,6 +183,26 @@ DPRINT1("File system not found, try to guess one...\n"); CurrentFileSystem = NULL; + +#if 0 //
[ros-diffs] [hbelusca] 74528: Code simplifications.
Author: hbelusca Date: Sat May 13 16:13:49 2017 New Revision: 74528 URL: http://svn.reactos.org/svn/reactos?rev=74528=rev Log: Code simplifications. Modified: branches/setup_improvements/base/setup/usetup/filesup.c Modified: branches/setup_improvements/base/setup/usetup/filesup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/filesup.c?rev=74528=74527=74528=diff == --- branches/setup_improvements/base/setup/usetup/filesup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/filesup.c [iso-8859-1] Sat May 13 16:13:49 2017 @@ -509,8 +509,7 @@ wcscat(FullName, FileName); } -RtlInitUnicodeString(, - FullName); +RtlInitUnicodeString(, FullName); InitializeObjectAttributes(, , @@ -524,14 +523,10 @@ , 0, FILE_SYNCHRONOUS_IO_NONALERT); -if (!NT_SUCCESS(Status)) -{ - return FALSE; -} NtClose(FileHandle); -return TRUE; +return NT_SUCCESS(Status); } /* EOF */
[ros-diffs] [hbelusca] 74527: [USETUP]: Add code that attempts to detect NT 5.x operating systems (MS Windows <= 2k3, ReactOS) installations. Heavily work in progress. The ultimate aim with this, is t
Author: hbelusca Date: Sat May 13 16:13:19 2017 New Revision: 74527 URL: http://svn.reactos.org/svn/reactos?rev=74527=rev Log: [USETUP]: Add code that attempts to detect NT 5.x operating systems (MS Windows <= 2k3, ReactOS) installations. Heavily work in progress. The ultimate aim with this, is to be able to select an existing installation of ReactOS for upgrading. The user then could either select one, or skip this step and select a different disk/partition where to install ReactOS. Added: branches/setup_improvements/base/setup/usetup/osdetect.c (with props) Modified: branches/setup_improvements/base/setup/usetup/CMakeLists.txt Modified: branches/setup_improvements/base/setup/usetup/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/CMakeLists.txt?rev=74527=74526=74527=diff == --- branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] Sat May 13 16:13:19 2017 @@ -28,6 +28,7 @@ inffile.c inicache.c mui.c +osdetect.c partlist.c progress.c registry.c Added: branches/setup_improvements/base/setup/usetup/osdetect.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/usetup/osdetect.c?rev=74527 == --- branches/setup_improvements/base/setup/usetup/osdetect.c(added) +++ branches/setup_improvements/base/setup/usetup/osdetect.c[iso-8859-1] Sat May 13 16:13:19 2017 @@ -0,0 +1,676 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS text-mode setup + * FILE:base/setup/usetup/osdetect.c + * PURPOSE: NT 5.x family (MS Windows <= 2003, and ReactOS) + * operating systems detection code. + * PROGRAMMER: Hermes Belusca-Maito (hermes.belu...@sfr.fr) + */ + +#include "usetup.h" + +#include +#include + +#define NDEBUG +#include + + +/* GLOBALS **/ + +extern PPARTLIST PartitionList; + + +/* VERSION RESOURCE API **/ + +/* + * NT-oriented version resource management, adapted from dll/win32/version. + * We only deal with 32-bit PE executables. + */ + +NTSTATUS +NtGetVersionResource( +IN PVOID BaseAddress, +OUT PVOID* Resource, +OUT PULONG ResourceSize OPTIONAL) +{ +// #define RT_VERSION MAKEINTRESOURCE(16) // See winuser.h +#define VS_VERSION_INFO 1 // See psdk/verrsrc.h +#define VS_FILE_INFORT_VERSION + +NTSTATUS Status; +LDR_RESOURCE_INFO ResourceInfo; +PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry; +PVOID Data = NULL; +ULONG Size = 0; + +/* Try to find the resource */ +ResourceInfo.Type = 16; // RT_VERSION; +ResourceInfo.Name = VS_VERSION_INFO; // MAKEINTRESOURCEW(VS_VERSION_INFO); +ResourceInfo.Language = 0; // Don't care about the language + +Status = LdrFindResource_U(BaseAddress, + , + RESOURCE_DATA_LEVEL, + ); +if (!NT_SUCCESS(Status)) +{ +DPRINT1("NtGetVersionResource: Version resource not found, Status 0x%08lx\n", Status); +return Status; +} + +/* Access the resource */ +Status = LdrAccessResource(BaseAddress, + ResourceDataEntry, + , + ); +if (!NT_SUCCESS(Status)) +{ +DPRINT1("NtGetVersionResource: Cannot access Version resource, Status 0x%08lx\n", Status); +return Status; +} + +*Resource = Data; +if (ResourceSize) *ResourceSize = Size; + +return STATUS_SUCCESS; +} + +/* NOTE: the xxx_STRUCT16 version differs by storing strings in ANSI, not in UNICODE */ +typedef struct _VS_VERSION_INFO_STRUCT32 +{ +WORD wLength; +WORD wValueLength; +WORD wType; /* 1:Text, 0:Binary */ +WCHAR szKey[1]; +#if 0 /* variable length structure */ +/* DWORD aligned */ +BYTE Value[]; +/* DWORD aligned */ +VS_VERSION_INFO_STRUCT32 Children[]; +#endif +} VS_VERSION_INFO_STRUCT32, *PVS_VERSION_INFO_STRUCT32; +typedef const VS_VERSION_INFO_STRUCT32 *PCVS_VERSION_INFO_STRUCT32; + +#define DWORD_ALIGN( base, ptr ) \ +( (ULONG_PTR)(base) + ULONG_PTR)(ptr) - (ULONG_PTR)(base)) + 3) & ~3) ) + +#define VersionInfo32_Value( ver ) \ +DWORD_ALIGN( (ver), (ver)->szKey + wcslen((ver)->szKey) + 1 ) + +#define VersionInfo32_Children( ver ) \ +(PCVS_VERSION_INFO_STRUCT32)( VersionInfo32_Value( ver ) + \ + ( ( (ver)->wValueLength * \ + ((ver)->wType? 2 : 1) + 3 ) & ~3 ) ) + +#define VersionInfo32_Next( ver ) \ +
[ros-diffs] [hbelusca] 74526: Create a branch for ROS setup improvements.
Author: hbelusca Date: Sat May 13 16:07:53 2017 New Revision: 74526 URL: http://svn.reactos.org/svn/reactos?rev=74526=rev Log: Create a branch for ROS setup improvements. Added: branches/setup_improvements/ (props changed) - copied from r74525, trunk/reactos/ Propchange: branches/setup_improvements/ -- --- svn:ignore (added) +++ svn:ignore Sat May 13 16:07:53 2017 @@ -0,0 +1,14 @@ +*.iso +makefile.auto +makefile-*.auto +config-*.rbuild +obj-* +output-* +reactos +reactos.* +RosBE-Logs +*.sln +*.ncb +*.suo +versionreport.xml +config.rbuild Propchange: branches/setup_improvements/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Sat May 13 16:07:53 2017 @@ -0,0 +1,25 @@ +/branches/GSoC_2011/GSoC_Network:51548 +/branches/GSoC_2011/GSoC_TcpIpDriver:51550 +/branches/GSoC_2011/TcpIpDriver:51551-53074,53076-53119 +/branches/GSoC_2016/AHCI:71203-73603 +/branches/GSoC_2016/USB:72365-73604 +/branches/GSoC_Network:51545-51546 +/branches/cmake-bringup:50484,50693,50719,51544-52564 +/branches/colins-printing-for-freedom/reactos:67543-68405,68407-68414,68417-70595 +/branches/condrv_restructure:63104-65657 +/branches/header-work:45691-47721 +/branches/kd++:58883-58973 +/branches/kernel-fun/reactos:62291,62294,62301-62302,62304,62321-62322,62353,62531-62532,62853,64152,64173-64174,65253 +/branches/ntvdm:59241-63176 +/branches/reactos-yarotows:45219-46371,46373-48025,48027-49273 +/branches/reactx/reactos:49994-49995 +/branches/ros-amd64-bringup:36852 +/branches/ros-amd64-bringup/reactos:34711-34712,34741,34743,34770,34780-34782,34803,34812,34839,34842,34864,34870,34874,34877,34908-34909,34917,34965,35323-35324,35347-35348,35361,35436,35509,35515,35588,35655,35683,35739,35746,35762,35771,35777,35781,35789,35805,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36011-36013,36172,36360,36380,36388-36389,36393,36397,36443,36445,36475,36502-36503,36505,36570,36614,36852,36898-36899,36930,36936,36949,36951,36958,36961,36964,36969,36972,36987-36988,36990,36992,37019,37322-37323,37333-37334,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38092,38100,38148-38151,38264-38265,38268,38355,39151,39333,39335,39345,39639,40120,40122-40123,40125,40127-40128,40155,40247,40324,40608,40753,40926-40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41070,41082-41086,41097-41098,41101,41449,41479-41480,41483-41485,41499-41500,41502,41531,41536,41540,41546-4 1547,41549,43080,43426,43451,43454,43506,43566,43574,43598,43600-43602,43604-43605,43677,43682,43757,43775,43836,43838-43840,43852,43857-43858,43860,43905-43907,43952,43954,43965,43969,43979,43981,43992,44002,44036-44037,44039-44040,44044-44045,44053,44065,44095,44123,44143-44144,44205,44238,44257,44259,44294,44338-44339,44385,44389,44391,44426,44460,44467-44468,44470-44471,44499,44501,44503-44504,44506,44510-44512,44521,44523-44526,44530,44540,44601,44634,44639,44772,44818,45124,45126-45127,45430,46394,46404,46478,46511,46523-46524,46526,46534-46535,46537-46539,46589,46805,46868,47472,47846-47847,47878,47882 +/branches/ros-branch-0_3_15-lt2013:59059 +/branches/ros-csrss:57561-58762 +/branches/shell-experiments:61927-65494 +/branches/shell32_new-bringup:51893-53652,53661,53700 +/branches/tcp-rewrite-branch:48720,48840-48841,49424-49426,49454 +/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 +/branches/usb-bringup-trunk:55019-55543,55548-4,6-55567 +/branches/wlan-bringup:54809-54998 Propchange: branches/setup_improvements/ -- tsvn:logminsize = 10
[ros-diffs] [tthompson] 74525: [NTFS] - Fix a bug with last commit, as spotted by Pierre.
Author: tthompson Date: Sat May 13 09:17:06 2017 New Revision: 74525 URL: http://svn.reactos.org/svn/reactos?rev=74525=rev Log: [NTFS] - Fix a bug with last commit, as spotted by Pierre. Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c?rev=74525=74524=74525=diff == --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] Sat May 13 09:17:06 2017 @@ -437,7 +437,7 @@ if (!NT_SUCCESS(Status)) { DPRINT1("ERROR: Unable to migrate resident attribute!\n"); -if(AttribData != NULL) +if (AttribDataSize.QuadPart > 0) ExFreePoolWithTag(AttribData, TAG_NTFS); return Status; }
[ros-diffs] [tthompson] 74524: [NTFS] - Expand support for resizing resident attributes and fix NtfsAllocateClusters(). -Modify SetAttributeDataLength() to allow a resident attribute to migrate to non
Author: tthompson Date: Sat May 13 08:56:54 2017 New Revision: 74524 URL: http://svn.reactos.org/svn/reactos?rev=74524=rev Log: [NTFS] - Expand support for resizing resident attributes and fix NtfsAllocateClusters(). -Modify SetAttributeDataLength() to allow a resident attribute to migrate to non-resident if the attribute grows too large to remain resident. -Fix values returned by NtfsAllocateClusters() in case of error; return error codes, not 0. Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/volinfo.c Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c?rev=74524=74523=74524=diff == --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] Sat May 13 08:56:54 2017 @@ -356,8 +356,106 @@ if (MaxValueLength < DataSize->LowPart || NextAttribute->Type != AttributeEnd) { -DPRINT1("FIXME: Need to convert attribute to non-resident!\n"); -return STATUS_NOT_IMPLEMENTED; +// convert attribute to non-resident +PNTFS_ATTR_RECORD Destination = (PNTFS_ATTR_RECORD)((ULONG_PTR)FileRecord + AttrOffset); +LARGE_INTEGER AttribDataSize; +PVOID AttribData; +ULONG EndAttributeOffset; +ULONG LengthWritten; + +DPRINT1("Converting attribute to non-resident.\n"); + +AttribDataSize.QuadPart = AttrContext->Record.Resident.ValueLength; + +// Is there existing data we need to back-up? +if (AttribDataSize.QuadPart > 0) +{ +AttribData = ExAllocatePoolWithTag(NonPagedPool, AttribDataSize.QuadPart, TAG_NTFS); +if (AttribData == NULL) +{ +DPRINT1("ERROR: Couldn't allocate memory for attribute data. Can't migrate to non-resident!\n"); +return STATUS_INSUFFICIENT_RESOURCES; +} + +// read data to temp buffer +Status = ReadAttribute(Fcb->Vcb, AttrContext, 0, AttribData, AttribDataSize.QuadPart); +if (!NT_SUCCESS(Status)) +{ +DPRINT1("ERROR: Unable to read attribute before migrating!\n"); +ExFreePoolWithTag(AttribData, TAG_NTFS); +return Status; +} +} + +// Start by turning this attribute into a 0-length, non-resident attribute, then enlarge it. + +// Zero out the NonResident structure +RtlZeroMemory(>Record.NonResident.LowestVCN, + FIELD_OFFSET(NTFS_ATTR_RECORD, NonResident.CompressedSize) - FIELD_OFFSET(NTFS_ATTR_RECORD, NonResident.LowestVCN)); +RtlZeroMemory(>NonResident.LowestVCN, + FIELD_OFFSET(NTFS_ATTR_RECORD, NonResident.CompressedSize) - FIELD_OFFSET(NTFS_ATTR_RECORD, NonResident.LowestVCN)); + +// update the mapping pairs offset, which will be 0x40 + length in bytes of the name +AttrContext->Record.NonResident.MappingPairsOffset = Destination->NonResident.MappingPairsOffset = 0x40 + (Destination->NameLength * 2); + +// mark the attribute as non-resident +AttrContext->Record.IsNonResident = Destination->IsNonResident = 1; + +// update the end of the file record +// calculate position of end markers (1 byte for empty data run) +EndAttributeOffset = AttrOffset + AttrContext->Record.NonResident.MappingPairsOffset + 1; +EndAttributeOffset = ALIGN_UP_BY(EndAttributeOffset, 8); + +// Update the length +Destination->Length = EndAttributeOffset - AttrOffset; +AttrContext->Record.Length = Destination->Length; + +// Update the file record end +SetFileRecordEnd(FileRecord, + (PNTFS_ATTR_RECORD)((ULONG_PTR)FileRecord + EndAttributeOffset), + FILE_RECORD_END); + +// update file record on disk +Status = UpdateFileRecord(Fcb->Vcb, AttrContext->FileMFTIndex, FileRecord); +if (!NT_SUCCESS(Status)) +