[ros-diffs] [reactos] 01/01: [KMTEST] Test what happens when CcSetFileSizes is called with data still mapped at the tail od the file
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6929451500abaa7fadbb1c58de102a792e7ae27e commit 6929451500abaa7fadbb1c58de102a792e7ae27e Author: Jérôme Gardou AuthorDate: Mon Nov 9 10:37:10 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 22 11:35:30 2020 +0100 [KMTEST] Test what happens when CcSetFileSizes is called with data still mapped at the tail od the file --- .../rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c | 23 -- .../rostests/kmtests/ntos_cc/CcSetFileSizes_user.c | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c index 3d23ab54bec..241312c12c5 100644 --- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c @@ -178,7 +178,7 @@ PerformTest( Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; Fcb->Header.ValidDataLength.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; -if ((TestId > 1 && TestId < 4) || TestId == 5) +if ((TestId > 1 && TestId < 4) || TestId >= 5) { Fcb->Header.AllocationSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; } @@ -315,6 +315,25 @@ PerformTest( } } } +else if (TestId == 6) +{ +Offset.QuadPart = 0; +KmtStartSeh(); +Ret = CcMapData(TestFileObject, , VACB_MAPPING_GRANULARITY - PAGE_SIZE, MAP_WAIT, , (PVOID *)); +KmtEndSeh(STATUS_SUCCESS); + +if (!skip(Ret == TRUE, "CcMapData failed\n")) +{ +ok_eq_ulong(Buffer[(VACB_MAPPING_GRANULARITY - PAGE_SIZE - sizeof(ULONG)) / sizeof(ULONG)], 0xBABABABA); +} + +KmtStartSeh(); +CcSetFileSizes(TestFileObject, ); +KmtEndSeh(STATUS_SUCCESS); + +if (Ret == TRUE) +CcUnpinData(Bcb); +} } } } @@ -379,7 +398,7 @@ TestMessageHandler( ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); PerformTest(*(PULONG)Buffer, DeviceObject); break; - + case IOCTL_FINISH_TEST: ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); CleanupTest(*(PULONG)Buffer, DeviceObject); diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c index d472c5ecc98..67bcc1df89e 100644 --- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c +++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c @@ -24,8 +24,9 @@ START_TEST(CcSetFileSizes) * 3: copy read - FS & AS * 4: dirty VACB - only FS * 5: dirty VACB - FS & AS + * 6: CcSetFileSizes with mapped data at tail of file */ -for (TestId = 0; TestId < 6; ++TestId) +for (TestId = 0; TestId < 7; ++TestId) { Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId); ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);
[ros-diffs] [reactos] 01/01: [KMTESTS] Add more tests for CcMapData & CcPinRead
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=115b8290cd77d5f0919378e49df1e76f87b3bea5 commit 115b8290cd77d5f0919378e49df1e76f87b3bea5 Author: Jérôme Gardou AuthorDate: Fri Dec 18 15:23:22 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 22 11:03:51 2020 +0100 [KMTESTS] Add more tests for CcMapData & CcPinRead Those show the shortcomings of the current implementation in ReactOS --- modules/rostests/kmtests/ntos_cc/CcMapData_drv.c | 48 +++-- modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c | 130 +++ 2 files changed, 146 insertions(+), 32 deletions(-) diff --git a/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c b/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c index 12e8286b936..5e43eb77408 100644 --- a/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c @@ -371,28 +371,58 @@ PerformTest( } else if (TestId == 4) { +FileSizes.AllocationSize.QuadPart += VACB_MAPPING_GRANULARITY; +CcSetFileSizes(TestFileObject, ); + /* Map after EOF */ Ret = FALSE; Offset.QuadPart = FileSizes.FileSize.QuadPart + 0x1000; KmtStartSeh(); -Ret = CcMapData(TestFileObject, , 0x1000, 0, , (PVOID *)); +Ret = CcMapData(TestFileObject, , 0x1000, MAP_WAIT, , (PVOID *)); KmtEndSeh(STATUS_SUCCESS); -ok(Ret == FALSE, "CcMapData succeed\n"); +ok(Ret == TRUE, "CcMapData failed\n"); if (Ret) { CcUnpinData(Bcb); } -/* Map a VACB after EOF */ +/* Map a VACB after EOF. */ Ret = FALSE; Offset.QuadPart = FileSizes.FileSize.QuadPart + 0x1000 + VACB_MAPPING_GRANULARITY; KmtStartSeh(); -Ret = CcMapData(TestFileObject, , 0x1000, 0, , (PVOID *)); -KmtEndSeh(STATUS_ACCESS_VIOLATION); -ok(Ret == FALSE, "CcMapData succeed\n"); +Ret = CcMapData(TestFileObject, , 0x1000, MAP_WAIT, , (PVOID *)); +KmtEndSeh(STATUS_SUCCESS); +ok(Ret == TRUE, "CcMapData failed\n"); + +if (Ret) +{ +CcUnpinData(Bcb); +} + +/* Map after Allocation */ +Ret = FALSE; +Offset.QuadPart = FileSizes.AllocationSize.QuadPart + 0x1000; + +KmtStartSeh(); +Ret = CcMapData(TestFileObject, , 0x1000, MAP_WAIT, , (PVOID *)); +KmtEndSeh(STATUS_SUCCESS); +ok(Ret == TRUE, "CcMapData failed\n"); + +if (Ret) +{ +CcUnpinData(Bcb); +} + +Ret = FALSE; +Offset.QuadPart = FileSizes.AllocationSize.QuadPart + 0x1000 + VACB_MAPPING_GRANULARITY; + +KmtStartSeh(); +Ret = CcMapData(TestFileObject, , 0x1000, MAP_WAIT, , (PVOID *)); +KmtEndSeh(STATUS_SUCCESS); +ok(Ret == TRUE, "CcMapData failed\n"); if (Ret) { @@ -404,9 +434,9 @@ PerformTest( Offset.QuadPart = 0x0; KmtStartSeh(); -Ret = CcMapData(TestFileObject, , 0x1000 + VACB_MAPPING_GRANULARITY, 0, , (PVOID *)); +Ret = CcMapData(TestFileObject, , 0x1000 + VACB_MAPPING_GRANULARITY, MAP_WAIT, , (PVOID *)); KmtEndSeh(STATUS_SUCCESS); -ok(Ret == FALSE, "CcMapData succeed\n"); +ok(Ret == TRUE, "CcMapData failed\n"); if (Ret) { @@ -475,7 +505,7 @@ TestMessageHandler( ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); PerformTest(*(PULONG)Buffer, DeviceObject); break; - + case IOCTL_FINISH_TEST: ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); CleanupTest(*(PULONG)Buffer, DeviceObject); diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c index 40a802b566e..3f18625d893 100644 --- a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c @@ -36,6 +36,9 @@ static BOOLEAN TestWriteCalled = FALSE; static ULONGLONG Memory = 0; static BOOLEAN TS = FALSE; +LARGE_INTEGER WriteOffset; +ULONG WriteLength; + NTSTATUS
[ros-diffs] [reactos] 01/01: [NTOS:IO] Do not set Shared property of the file if we are failing in IoCheckShareAccess
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1d1dba51db2208e300570c58ffe2272e0c34a1a8 commit 1d1dba51db2208e300570c58ffe2272e0c34a1a8 Author: Jérôme Gardou AuthorDate: Mon Dec 14 15:51:15 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 22 11:05:00 2020 +0100 [NTOS:IO] Do not set Shared property of the file if we are failing in IoCheckShareAccess --- ntoskrnl/io/iomgr/file.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 5004938c099..548c7f28db7 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -3429,11 +3429,6 @@ IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE) != 0; SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE) != 0; -/* Set them */ -FileObject->SharedRead = SharedRead; -FileObject->SharedWrite = SharedWrite; -FileObject->SharedDelete = SharedDelete; - /* Check if the shared access is violated */ if ((ReadAccess && (ShareAccess->SharedRead < ShareAccess->OpenCount)) || @@ -3449,6 +3444,11 @@ IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, return STATUS_SHARING_VIOLATION; } +/* Set them */ +FileObject->SharedRead = SharedRead; +FileObject->SharedWrite = SharedWrite; +FileObject->SharedDelete = SharedDelete; + /* It's not, check if caller wants us to update it */ if (Update) {
[ros-diffs] [reactos] 01/01: [NTOS:IO] Do not pass bogus file offset to the FS in NtReadFile & NtWriteFile
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a6c0af2e218cba4dc6f1a9b2254f9a37a997ff6a commit a6c0af2e218cba4dc6f1a9b2254f9a37a997ff6a Author: Jérôme Gardou AuthorDate: Fri Dec 18 17:21:01 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 22 11:02:33 2020 +0100 [NTOS:IO] Do not pass bogus file offset to the FS in NtReadFile & NtWriteFile --- ntoskrnl/io/iomgr/iofunc.c | 17 + 1 file changed, 17 insertions(+) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 627ff9644b3..62c7799e47a 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -2776,6 +2776,14 @@ NtReadFile(IN HANDLE FileHandle, if (Key) CapturedKey = *Key; } +/* Check for invalid offset */ +if ((CapturedByteOffset.QuadPart < 0) && (CapturedByteOffset.QuadPart != -2)) +{ +/* -2 is FILE_USE_FILE_POINTER_POSITION */ +ObDereferenceObject(FileObject); +return STATUS_INVALID_PARAMETER; +} + /* Check for event */ if (Event) { @@ -3827,6 +3835,15 @@ NtWriteFile(IN HANDLE FileHandle, if (Key) CapturedKey = *Key; } +/* Check for invalid offset */ +if (CapturedByteOffset.QuadPart < -2) +{ +/* -1 is FILE_WRITE_TO_END_OF_FILE */ +/* -2 is FILE_USE_FILE_POINTER_POSITION */ +ObDereferenceObject(FileObject); +return STATUS_INVALID_PARAMETER; +} + /* Check if this is an append operation */ if ((ObjectHandleInfo.GrantedAccess & (FILE_APPEND_DATA | FILE_WRITE_DATA)) == FILE_APPEND_DATA)
[ros-diffs] [reactos] 01/01: [NTOS:IO] Validate input parameters in NtQueryDirectoryFile
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ef4c7ae978a6937442854ead4a1a1c942f1edcd2 commit ef4c7ae978a6937442854ead4a1a1c942f1edcd2 Author: Jérôme Gardou AuthorDate: Thu Dec 10 11:30:01 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 22 11:06:38 2020 +0100 [NTOS:IO] Validate input parameters in NtQueryDirectoryFile It turns out this is not the job of the FS driver --- ntoskrnl/io/iomgr/iofunc.c | 20 1 file changed, 20 insertions(+) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 62c7799e47a..80814a70ba3 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -2052,6 +2052,26 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, _SEH2_END; } +/* Check input parameters */ + +switch (FileInformationClass) +{ +#define CHECK_LENGTH(class, struct) \ +case class: \ +if (Length < sizeof(struct)) \ +return STATUS_INFO_LENGTH_MISMATCH; \ +break +CHECK_LENGTH(FileDirectoryInformation, FILE_DIRECTORY_INFORMATION); +CHECK_LENGTH(FileFullDirectoryInformation, FILE_FULL_DIR_INFORMATION); +CHECK_LENGTH(FileIdFullDirectoryInformation, FILE_ID_FULL_DIR_INFORMATION); +CHECK_LENGTH(FileNamesInformation, FILE_NAMES_INFORMATION); +CHECK_LENGTH(FileBothDirectoryInformation, FILE_BOTH_DIR_INFORMATION); +CHECK_LENGTH(FileIdBothDirectoryInformation, FILE_ID_BOTH_DIR_INFORMATION); +default: +break; +#undef CHECK_LENGTH +} + /* Get File Object */ Status = ObReferenceObjectByHandle(FileHandle, FILE_LIST_DIRECTORY,
[ros-diffs] [reactos] 01/01: [NTOS:MM] Fix more 64 bit arithmetics
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96ae15ac4bfa3c43fe08aa959f58fd8a1449e8e0 commit 96ae15ac4bfa3c43fe08aa959f58fd8a1449e8e0 Author: Jérôme Gardou AuthorDate: Tue Dec 15 10:07:27 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Dec 15 10:08:25 2020 +0100 [NTOS:MM] Fix more 64 bit arithmetics --- ntoskrnl/mm/ARM3/section.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 347f3ca4074..02ead9a70a5 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1299,6 +1299,14 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, { /* The caller did not, so pick a 64K aligned view size based on the offset */ SectionOffset->LowPart &= ~(_64K - 1); + +/* Make sure that we will not overflow */ +if ((Section->SizeOfSection.QuadPart - SectionOffset->QuadPart) > MAXLONG_PTR) +{ +MiDereferenceControlArea(ControlArea); +return STATUS_INVALID_VIEW_SIZE; +} + *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart); } else @@ -1306,6 +1314,13 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* A size was specified, align it to a 64K boundary */ *ViewSize += SectionOffset->LowPart & (_64K - 1); +/* Check for overflow or huge value */ +if ((*ViewSize < (SectionOffset->LowPart & (_64K - 1))) || ((*ViewSize) > MAXLONG_PTR)) +{ +MiDereferenceControlArea(ControlArea); +return STATUS_INVALID_VIEW_SIZE; +} + /* Align the offset as well to make this an aligned map */ SectionOffset->LowPart &= ~((ULONG)_64K - 1); } @@ -1313,13 +1328,6 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* We must be dealing with a 64KB aligned offset. This is a Windows ASSERT */ ASSERT((SectionOffset->LowPart & ((ULONG)_64K - 1)) == 0); -/* It's illegal to try to map more than overflows a LONG_PTR */ -if (*ViewSize >= MAXLONG_PTR) -{ -MiDereferenceControlArea(ControlArea); -return STATUS_INVALID_VIEW_SIZE; -} - /* Windows ASSERTs for this flag */ ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0); @@ -1535,7 +1543,10 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment, SizeLimit <<= PAGE_SHIFT; /* Fail if this size is too big */ -if (MaximumSize->QuadPart > SizeLimit) return STATUS_SECTION_TOO_BIG; +if (MaximumSize->QuadPart > SizeLimit) +{ +return STATUS_SECTION_TOO_BIG; +} /* Calculate how many Prototype PTEs will be needed */ PteCount = (PFN_COUNT)((MaximumSize->QuadPart + PAGE_SIZE - 1) >> PAGE_SHIFT); @@ -1592,7 +1603,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment, /* Save some extra accounting data for the segment as well */ NewSegment->u1.CreatingProcess = PsGetCurrentProcess(); -NewSegment->SizeOfSegment = PteCount * PAGE_SIZE; +NewSegment->SizeOfSegment = ((ULONGLONG)PteCount) * PAGE_SIZE; NewSegment->TotalNumberOfPtes = PteCount; NewSegment->NonExtendedPtes = PteCount;
[ros-diffs] [reactos] 16/19: [GITHUB] Add CLang build action
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=597660a4b764e2d94f7a9cfadaf1b2189c00f760 commit 597660a4b764e2d94f7a9cfadaf1b2189c00f760 Author: Jérôme Gardou AuthorDate: Tue Nov 10 09:20:04 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [GITHUB] Add CLang build action --- .github/workflows/build.yml | 42 ++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3c56f1c208..080bf8b4769 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,48 @@ jobs: name: reactos-gcc-i386-${{github.sha}} path: build/livecd.iso + build-clang-i386: +name: Clang (i386) +runs-on: ubuntu-latest +steps: + - name: Install RosBE +run: | + wget https://svn.reactos.org/storage/vperevertkin/rosbe-ci.tar.zst + mkdir ${{github.workspace}}/rosbe + tar -I zstd -xvf rosbe-ci.tar.zst --directory ${{github.workspace}}/rosbe + - name: Install other packages +run: | + sudo apt install ccache + sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" + sudo apt install clang-11 + - uses: actions/checkout@v2 +with: + path: src + - name: Set up cache for ccache +uses: actions/cache@v2 +with: + path: ccache + key: ccache-clang-i386-${{github.sha}} + restore-keys: | +ccache-clang-i386- + - name: Set ccache settings +run: | + echo "CCACHE_BASEDIR=${{github.workspace}}" >> $GITHUB_ENV + echo "CCACHE_DIR=${{github.workspace}}/ccache" >> $GITHUB_ENV + echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV + echo "CCACHE_SLOPPINESS=time_macros" >> $GITHUB_ENV + - name: Configure +run: | + mkdir build + echo 'cd ${{github.workspace}}/build && cmake ${{github.workspace}}/src -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-clang.cmake -DARCH:STRING=i386 -DENABLE_CCACHE=1 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 -DCLANG_VERSION=11' > commands + ${{github.workspace}}/rosbe/RosBE.sh < commands + - name: Build +run: | + echo 'cd ${{github.workspace}}/build && cmake --build .' > commands + ${{github.workspace}}/rosbe/RosBE.sh < commands + - name: Print ccache statistics +run: ccache -s + build-clang-cl-i386: name: Clang-CL (i386) runs-on: windows-latest
[ros-diffs] [reactos] 09/19: [CRT] Use ASM aliases for CLang builds
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=281389b7e73970fb93b075adc3335a8090cc77fa commit 281389b7e73970fb93b075adc3335a8090cc77fa Author: Jérôme Gardou AuthorDate: Mon Nov 9 12:54:06 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CRT] Use ASM aliases for CLang builds --- sdk/lib/crt/stdlib/rot.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/lib/crt/stdlib/rot.c b/sdk/lib/crt/stdlib/rot.c index 3c4b613a3a6..51a6a6c0218 100644 --- a/sdk/lib/crt/stdlib/rot.c +++ b/sdk/lib/crt/stdlib/rot.c @@ -19,8 +19,16 @@ #pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr) #endif -unsigned int _rotr( unsigned int value, int shift ); -unsigned long _lrotr(unsigned long value, int shift); +#if defined (__clang__) && !defined(_MSC_VER) +#define ASM_ALIAS __asm__ +#else +#define ASM_ALIAS(x) +#endif + +unsigned int _rotr( unsigned int value, int shift ) ASM_ALIAS("__rotr"); +unsigned long _lrotr(unsigned long value, int shift) ASM_ALIAS("__lrotr"); +unsigned int _rotl( unsigned int value, int shift ) ASM_ALIAS("__rotl"); +unsigned long _lrotl( unsigned long value, int shift ) ASM_ALIAS("__lrotl"); /* * @implemented
[ros-diffs] [reactos] 13/19: [ATL] Declare pointer as return type for functions returning pointers
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b0abd14b03f7c737148b96d96f9c25a15d192119 commit b0abd14b03f7c737148b96d96f9c25a15d192119 Author: Jérôme Gardou AuthorDate: Mon Nov 9 15:59:55 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [ATL] Declare pointer as return type for functions returning pointers --- sdk/lib/atl/atlpath.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/lib/atl/atlpath.h b/sdk/lib/atl/atlpath.h index 7f476d45239..942b47f638f 100644 --- a/sdk/lib/atl/atlpath.h +++ b/sdk/lib/atl/atlpath.h @@ -23,10 +23,10 @@ class CPathT // const inline BOOL PathFileExistsX(LPCSTR pszPath) { return PathFileExistsA(pszPath); } inline BOOL PathFileExistsX(LPCWSTR pszPath) { return PathFileExistsW(pszPath); } -inline int PathFindExtensionX(LPCSTR pszPath) { return PathFindExtensionA(pszPath); } -inline int PathFindExtensionX(LPCWSTR pszPath) { return PathFindExtensionW(pszPath); } -inline int PathFindFileNameX(LPCSTR pszPath) { return PathFindFileNameA(pszPath); } -inline int PathFindFileNameX(LPCWSTR pszPath) { return PathFindFileNameW(pszPath); } +inline LPCSTR PathFindExtensionX(LPCSTR pszPath) { return PathFindExtensionA(pszPath); } +inline LPCWSTR PathFindExtensionX(LPCWSTR pszPath) { return PathFindExtensionW(pszPath); } +inline LPCSTR PathFindFileNameX(LPCSTR pszPath) { return PathFindFileNameA(pszPath); } +inline LPCWSTR PathFindFileNameX(LPCWSTR pszPath) { return PathFindFileNameW(pszPath); } inline int PathGetDriveNumberX(LPCSTR pszPath) { return PathGetDriveNumberA(pszPath); } inline int PathGetDriveNumberX(LPCWSTR pszPath) { return PathGetDriveNumberW(pszPath); } inline BOOL PathIsDirectoryX(LPCSTR pszPath) { return PathIsDirectoryA(pszPath); } @@ -49,8 +49,8 @@ class CPathT inline BOOL PathIsUNCServerShareX(LPCWSTR pszPath) { return PathIsUNCServerShareW(pszPath); } inline BOOL PathMatchSpecX(LPCSTR pszPath, LPCSTR pszSpec) { return PathMatchSpecA(pszPath, pszSpec); } inline BOOL PathMatchSpecX(LPCWSTR pszPath, LPCWSTR pszSpec) { return PathMatchSpecW(pszPath, pszSpec); } -inline int PathSkipRootX(LPCSTR pszPath) { return PathSkipRootA(pszPath); } -inline int PathSkipRootX(LPCWSTR pszPath) { return PathSkipRootW(pszPath); } +inline LPCSTR PathSkipRootX(LPCSTR pszPath) { return PathSkipRootA(pszPath); } +inline LPCWSTR PathSkipRootX(LPCWSTR pszPath) { return PathSkipRootW(pszPath); } // non-const inline void PathAddBackslashX(LPSTR pszPath) { PathAddBackslashA(pszPath); }
[ros-diffs] [reactos] 10/19: [MSVCRT] make some functions static
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2c4c25e468e5bbc04594c66483a2f6eb81aff591 commit 2c4c25e468e5bbc04594c66483a2f6eb81aff591 Author: Jérôme Gardou AuthorDate: Mon Nov 9 12:54:46 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [MSVCRT] make some functions static --- dll/win32/msvcrt/stubs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dll/win32/msvcrt/stubs.c b/dll/win32/msvcrt/stubs.c index e120a130cc8..72b3091 100644 --- a/dll/win32/msvcrt/stubs.c +++ b/dll/win32/msvcrt/stubs.c @@ -96,7 +96,7 @@ typedef struct __crt_locale_data_public unsigned int _locale_lc_codepage; } __crt_locale_data_public; -__inline +static __crt_locale_data_public* __CRTDECL __acrt_get_locale_data_prefix( @@ -106,7 +106,7 @@ __acrt_get_locale_data_prefix( return (__crt_locale_data_public*)_TypedLocalePointers->locinfo; } -__inline +static int __CRTDECL __acrt_locale_get_ctype_array_value( @@ -137,7 +137,7 @@ const unsigned short* __cdecl __pctype_func(void); #define __chvalidchk(a, b) (__acrt_locale_get_ctype_array_value(__PCTYPE_FUNC, (a), (b))) #endif -__inline +static int __CRTDECL _chvalidchk_l( @@ -158,7 +158,7 @@ _chvalidchk_l( #endif } -__inline +static int __CRTDECL _ischartype_l(
[ros-diffs] [reactos] 14/19: [RAPPS] Do not implicitly cast pointer to BOOL
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7a52db76c5fe24f71c66231bebabac3af7a8f5ab commit 7a52db76c5fe24f71c66231bebabac3af7a8f5ab Author: Jérôme Gardou AuthorDate: Mon Nov 9 16:05:12 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [RAPPS] Do not implicitly cast pointer to BOOL --- base/applications/rapps/include/rosui.h | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base/applications/rapps/include/rosui.h b/base/applications/rapps/include/rosui.h index 0aaf303b017..4402b26f28b 100644 --- a/base/applications/rapps/include/rosui.h +++ b/base/applications/rapps/include/rosui.h @@ -96,9 +96,13 @@ public: BOOL RemoveAt(INT i) { -T* ptr = (T*) DPA_GetPtr(m_hDpa, i); -OnRemoveItem(ptr); -return DPA_DeletePtr(m_hDpa, i); +PVOID ptr = DPA_DeletePtr(m_hDpa, i); +if (ptr != NULL) +{ +OnRemoveItem(reinterpret_cast(ptr)); +return TRUE; +} +return FALSE; } BOOL Clear()
[ros-diffs] [reactos] 15/19: [NTOSKRNL] DO not disable optimisations when compiling with CLang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e7071e8fbb3e321579d12d4390f41ad110e8427 commit 9e7071e8fbb3e321579d12d4390f41ad110e8427 Author: Jérôme Gardou AuthorDate: Mon Nov 9 17:01:07 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NTOSKRNL] DO not disable optimisations when compiling with CLang --- ntoskrnl/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 84125c75c9b..fd093c6ca06 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -43,8 +43,10 @@ if(MSVC) add_target_link_flags(ntoskrnl "/SECTION:.rsrc,!DP") #Accessed from bugcheck code add_target_link_flags(ntoskrnl "/SECTION:INIT,ERWD") else() -if(GDB) +if(GDB AND NOT CLANG) # Completely disable optimizations when debugging the kernel +# Not for CLang, which fails as following in _SEH2_EXCEPT macro: +# error: inline assembly requires more registers than available target_compile_options(ntoskrnl PRIVATE -O0) set_image_base(ntoskrnl 0x0080) else()
[ros-diffs] [reactos] 17/19: [NCFTP] declare DisposeWinsock as static
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=13dad0231a91ada4735d63c08c6354d9c016e815 commit 13dad0231a91ada4735d63c08c6354d9c016e815 Author: Jérôme Gardou AuthorDate: Tue Nov 10 14:25:54 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NCFTP] declare DisposeWinsock as static --- modules/rosapps/applications/net/ncftp/ncftp/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rosapps/applications/net/ncftp/ncftp/main.c b/modules/rosapps/applications/net/ncftp/ncftp/main.c index 418aa60a53c..189202d711b 100644 --- a/modules/rosapps/applications/net/ncftp/ncftp/main.c +++ b/modules/rosapps/applications/net/ncftp/ncftp/main.c @@ -24,7 +24,7 @@ WSADATA wsaData; int wsaInit = 0; - __inline void DisposeWinsock(int aUNUSED) { if (wsaInit > 0) WSACleanup(); wsaInit--; } + static __inline void DisposeWinsock(int aUNUSED) { if (wsaInit > 0) WSACleanup(); wsaInit--; } #else # define DisposeWinsock(a) #endif
[ros-diffs] [reactos] 19/19: [PARTMGR] Use FORCEINLINE
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6488440a6a9abee129512a3717a8b81f0951e395 commit 6488440a6a9abee129512a3717a8b81f0951e395 Author: Jérôme Gardou AuthorDate: Mon Nov 16 14:27:47 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [PARTMGR] Use FORCEINLINE --- drivers/storage/partmgr/partmgr.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/storage/partmgr/partmgr.h b/drivers/storage/partmgr/partmgr.h index 05a0ee6bbbd..71eccfb8823 100644 --- a/drivers/storage/partmgr/partmgr.h +++ b/drivers/storage/partmgr/partmgr.h @@ -139,7 +139,7 @@ IssueSyncIoControlRequest( _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl); -inline +FORCEINLINE BOOLEAN VerifyIrpOutBufferSize( _In_ PIRP Irp, @@ -154,7 +154,7 @@ VerifyIrpOutBufferSize( return TRUE; } -inline +FORCEINLINE BOOLEAN VerifyIrpInBufferSize( _In_ PIRP Irp, @@ -169,7 +169,7 @@ VerifyIrpInBufferSize( return TRUE; } -inline +FORCEINLINE VOID PartMgrAcquireLayoutLock( _In_ PFDO_EXTENSION FDOExtension) @@ -179,7 +179,7 @@ PartMgrAcquireLayoutLock( KeWaitForSingleObject(>SyncEvent, Executive, KernelMode, FALSE, NULL); } -inline +FORCEINLINE VOID PartMgrReleaseLayoutLock( _In_ PFDO_EXTENSION FDOExtension)
[ros-diffs] [reactos] 18/19: [SDK] Use FORCEINLINE instead of inline
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=02f4c755b8147b26d6855ee26f81081bc824b300 commit 02f4c755b8147b26d6855ee26f81081bc824b300 Author: Jérôme Gardou AuthorDate: Mon Nov 16 14:27:24 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [SDK] Use FORCEINLINE instead of inline --- sdk/include/reactos/debug/driverdbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/reactos/debug/driverdbg.h b/sdk/include/reactos/debug/driverdbg.h index 963236e503f..c25e5fdcc97 100644 --- a/sdk/include/reactos/debug/driverdbg.h +++ b/sdk/include/reactos/debug/driverdbg.h @@ -8,7 +8,7 @@ #ifndef _DBG_DRIVERDBG_H_ #define _DBG_DRIVERDBG_H_ -inline +FORCEINLINE PCHAR GetIRPMinorFunctionString( UCHAR MinorFunction)
[ros-diffs] [reactos] 01/19: [CMAKE] Fix use of CLang - Updated toolchain file - set GCC variable when using CLang in "GCC mode" - Properly retrieve GCC support libraries - Various flags needed to get
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=edc1f3ca56bb67213c613e7215ad6e44d8075bc6 commit edc1f3ca56bb67213c613e7215ad6e44d8075bc6 Author: Jérôme Gardou AuthorDate: Thu Sep 10 23:23:14 2020 +0200 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CMAKE] Fix use of CLang - Updated toolchain file - set GCC variable when using CLang in "GCC mode" - Properly retrieve GCC support libraries - Various flags needed to get this going --- CMakeLists.txt | 5 +-- sdk/cmake/CMakeMacros.cmake | 5 ++- sdk/cmake/config.cmake | 7 +++- sdk/cmake/gcc.cmake | 45 + toolchain-clang.cmake | 81 + 5 files changed, 90 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 103b1c5bf90..e3dff10c6c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,8 @@ add_definitions(-D__REACTOS__) # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime. file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR}) -if (GCC AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")) +if (GCC AND ((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") +OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0" # Thankfully, GCC has this add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=) add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=) @@ -63,7 +64,7 @@ else() string(LENGTH ${_PATH_PREFIX} _PATH_PREFIX_LENGTH) string(LENGTH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_LENGTH) math(EXPR REACTOS_SOURCE_DIR_LENGTH "${REACTOS_SOURCE_DIR_LENGTH} + 1") -add_compile_definitions("__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]") + add_compile_definitions("$<$:__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]>") endif() if(MSVC_IDE) diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 6458e75fdaf..6c72d553c22 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -705,7 +705,10 @@ endfunction() function(get_defines OUTPUT_VAR) get_directory_property(_defines COMPILE_DEFINITIONS) foreach(arg ${_defines}) -list(APPEND __tmp_var -D${arg}) +# Skip generator expressions +if (NOT arg MATCHES [[^\$<.*>$]]) +list(APPEND __tmp_var -D${arg}) +endif() endforeach() set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE) endfunction() diff --git a/sdk/cmake/config.cmake b/sdk/cmake/config.cmake index 01c1ac760db..37a6f949901 100644 --- a/sdk/cmake/config.cmake +++ b/sdk/cmake/config.cmake @@ -40,7 +40,12 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(GCC TRUE CACHE BOOL "The compiler is GCC") set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang") -set(GCC FALSE CACHE BOOL "The compiler is GCC") +# We can use LLVM Clang mimicking CL or GCC. Account for this +if (MSVC) +set(GCC FALSE CACHE BOOL "The compiler is GCC") +else() +set(GCC TRUE CACHE BOOL "The compiler is GCC") +endif() set(CLANG TRUE CACHE BOOL "The compiler is LLVM Clang") elseif(MSVC) # aka CMAKE_C_COMPILER_ID STEQUAL "MSVC" set(GCC FALSE CACHE BOOL "The compiler is GCC") diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 5fac4f059f4..278e8b5f092 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -45,10 +45,18 @@ add_compile_options(-pipe -fms-extensions -fno-strict-aliasing) # The case for C++ is handled through the reactos_c++ INTERFACE library add_compile_options("$<$>:-nostdinc>") -add_compile_options(-mstackrealign -fno-aggressive-loop-optimizations) +add_compile_options(-mstackrealign) -if(CMAKE_C_COMPILER_ID STREQUAL "Clang") +if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") +add_compile_options(-fno-aggressive-loop-optimizations) +if (DBG) +add_compile_options("$<$:-Wold-style-declaration>") +endif() +else() add_compile_options("$<$:-std=gnu99;-Wno-microsoft>") +add_compile_options(-Wno-pragma-pack) +add_compile_options(-fno-associative-math) +add_compile_options(-fcommon) set(CMAKE_LINK_DEF_FILE_FLAG "") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") set(CMAKE_LINK_LIBRARY_SUFFIX "") @@ -62,12 +70,6 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_DEBUG &qu
[ros-diffs] [reactos] 02/19: [CRT] Fix intrinsics definition with clang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f96e47db439ec7eb867e9cf7f52086cad20c76c1 commit f96e47db439ec7eb867e9cf7f52086cad20c76c1 Author: Jérôme Gardou AuthorDate: Thu Sep 10 23:24:59 2020 +0200 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CRT] Fix intrinsics definition with clang --- sdk/include/crt/mingw32/intrin.h | 22 +- sdk/include/crt/mingw32/intrin_x86.h | 50 +-- sdk/include/crt/xmmintrin.h | 57 ++-- 3 files changed, 84 insertions(+), 45 deletions(-) diff --git a/sdk/include/crt/mingw32/intrin.h b/sdk/include/crt/mingw32/intrin.h index d1377939f46..c7c6b6a0d29 100644 --- a/sdk/include/crt/mingw32/intrin.h +++ b/sdk/include/crt/mingw32/intrin.h @@ -30,13 +30,21 @@ #ifndef RC_INVOKED -#ifdef __clang__ -#define __INTRIN_INLINE __forceinline -#define HAS_BUILTIN(x) __has_builtin(x) -#else -#define HAS_BUILTIN(x) 0 -#define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) -#define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL +#ifndef __INTRIN_INLINE +# ifdef __clang__ +#define __ATTRIBUTE_ARTIFICIAL +# else +#define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) +# endif +# define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL +#endif + +#ifndef HAS_BUILTIN +# ifdef __clang__ +#define HAS_BUILTIN(x) __has_builtin(x) +# else +#define HAS_BUILTIN(x) 0 +# endif #endif #ifndef _SIZE_T_DEFINED diff --git a/sdk/include/crt/mingw32/intrin_x86.h b/sdk/include/crt/mingw32/intrin_x86.h index 424bbc61d06..600402bce66 100644 --- a/sdk/include/crt/mingw32/intrin_x86.h +++ b/sdk/include/crt/mingw32/intrin_x86.h @@ -133,15 +133,19 @@ __INTRIN_INLINE void __faststorefence(void) #if (__GNUC__ * 1 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 +#if !HAS_BUILTIN(_InterlockedCompareExchange8) __INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * Destination, char Exchange, char Comperand) { return __sync_val_compare_and_swap(Destination, Comperand, Exchange); } +#endif +#if !HAS_BUILTIN(_InterlockedCompareExchange16) __INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * Destination, short Exchange, short Comperand) { return __sync_val_compare_and_swap(Destination, Comperand, Exchange); } +#endif #if !HAS_BUILTIN(_InterlockedCompareExchange) __INTRIN_INLINE long __cdecl _InterlockedCompareExchange(volatile long * Destination, long Exchange, long Comperand) @@ -157,19 +161,23 @@ __INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * Dest } #endif +#if !HAS_BUILTIN(_InterlockedExchange8) __INTRIN_INLINE char _InterlockedExchange8(volatile char * Target, char Value) { /* NOTE: __sync_lock_test_and_set would be an acquire barrier, so we force a full barrier */ __sync_synchronize(); return __sync_lock_test_and_set(Target, Value); } +#endif +#if !HAS_BUILTIN(_InterlockedExchange16) __INTRIN_INLINE short _InterlockedExchange16(volatile short * Target, short Value) { /* NOTE: __sync_lock_test_and_set would be an acquire barrier, so we force a full barrier */ __sync_synchronize(); return __sync_lock_test_and_set(Target, Value); } +#endif #if !HAS_BUILTIN(_InterlockedExchange) __INTRIN_INLINE long __cdecl _InterlockedExchange(volatile long * Target, long Value) @@ -198,15 +206,19 @@ __INTRIN_INLINE long long _InterlockedExchange64(volatile long long * Target, lo } #endif +#if !HAS_BUILTIN(_InterlockedExchangeAdd8) __INTRIN_INLINE char _InterlockedExchangeAdd8(char volatile * Addend, char Value) { return __sync_fetch_and_add(Addend, Value); } +#endif +#if !HAS_BUILTIN(_InterlockedExchangeAdd16) __INTRIN_INLINE short _InterlockedExchangeAdd16(volatile short * Addend, short Value) { return __sync_fetch_and_add(Addend, Value); } +#endif #if !HAS_BUILTIN(_InterlockedExchangeAdd) __INTRIN_INLINE long __cdecl _InterlockedExchangeAdd(volatile long * Addend, long Value) @@ -222,20 +234,26 @@ __INTRIN_INLINE long long _InterlockedExchangeAdd64(volatile long long * Addend, } #endif +#if !HAS_BUILTIN(_InterlockedAnd8) __INTRIN_INLINE char _InterlockedAnd8(volatile char * value, char mask) { return __sync_fetch_and_and(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedAnd16) __INTRIN_INLINE short _InterlockedAnd16(volatile short * value, short mask) { return __sync_fetch_and_and(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedAnd) __INTRIN_INLINE long _InterlockedAnd(volatile long * value, long mask) { return __sync_fetch_and_and(value, mask); } +#endif #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedAnd64(volatile long long * value, long long mask) @@ -244,20 +262
[ros-diffs] [reactos] 07/19: [STORAHCI] Use FORCEINLINE instead of __inline
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1f8db9824e0edf1aa522537cbde575c17dbef9c3 commit 1f8db9824e0edf1aa522537cbde575c17dbef9c3 Author: Jérôme Gardou AuthorDate: Mon Nov 9 09:45:03 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [STORAHCI] Use FORCEINLINE instead of __inline --- drivers/storage/port/storahci/storahci.c | 4 ++-- drivers/storage/port/storahci/storahci.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/storage/port/storahci/storahci.c b/drivers/storage/port/storahci/storahci.c index ed94f1d3e87..bf4c96d04c1 100644 --- a/drivers/storage/port/storahci/storahci.c +++ b/drivers/storage/port/storahci/storahci.c @@ -2559,7 +2559,7 @@ RemoveQueue ( * return SrbExtension * */ -__inline +FORCEINLINE PAHCI_SRB_EXTENSION GetSrbExtension ( __in PSCSI_REQUEST_BLOCK Srb @@ -2615,4 +2615,4 @@ AhciGetLba ( } return lba; -}// -- AhciGetLba(); \ No newline at end of file +}// -- AhciGetLba(); diff --git a/drivers/storage/port/storahci/storahci.h b/drivers/storage/port/storahci/storahci.h index fba3f2d4be5..40c08f2f462 100644 --- a/drivers/storage/port/storahci/storahci.h +++ b/drivers/storage/port/storahci/storahci.h @@ -645,7 +645,7 @@ RemoveQueue ( __inout PAHCI_QUEUE Queue ); -__inline +FORCEINLINE PAHCI_SRB_EXTENSION GetSrbExtension( __in PSCSI_REQUEST_BLOCK Srb
[ros-diffs] [reactos] 03/19: [CRT] Fix __forceinline definition for clang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3936c3f19ec17028f3ba74bac0e1839305462181 commit 3936c3f19ec17028f3ba74bac0e1839305462181 Author: Jérôme Gardou AuthorDate: Fri Nov 6 17:27:32 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CRT] Fix __forceinline definition for clang --- sdk/include/crt/_mingw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/crt/_mingw.h b/sdk/include/crt/_mingw.h index 06a304d9605..a0da23de0f2 100644 --- a/sdk/include/crt/_mingw.h +++ b/sdk/include/crt/_mingw.h @@ -193,7 +193,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ # ifdef __cplusplus # define __forceinline inline __attribute__((__always_inline__)) # else -# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# if (( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) || defined(__clang__)) # define __forceinline extern inline __attribute__((__always_inline__,__gnu_inline__)) # else # define __forceinline extern __inline__ __attribute__((__always_inline__))
[ros-diffs] [reactos] 08/19: [NFS41_DRIVER] Use GNU89 standard when compiling with CLang.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=567a5231d5a8b00327146e651464ff4ef791013b commit 567a5231d5a8b00327146e651464ff4ef791013b Author: Jérôme Gardou AuthorDate: Mon Nov 9 12:04:25 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NFS41_DRIVER] Use GNU89 standard when compiling with CLang. --- drivers/filesystems/nfs/CMakeLists.txt | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/filesystems/nfs/CMakeLists.txt b/drivers/filesystems/nfs/CMakeLists.txt index 9845ef76814..3d05ff676c6 100644 --- a/drivers/filesystems/nfs/CMakeLists.txt +++ b/drivers/filesystems/nfs/CMakeLists.txt @@ -14,10 +14,14 @@ set_module_type(nfs41_driver kernelmodedriver) target_link_libraries(nfs41_driver ntoskrnl_vista rdbsslib rxce copysup memcmp ${PSEH_LIB}) add_importlibs(nfs41_driver ntoskrnl hal) -if(USE_CLANG_CL OR (NOT MSVC)) +if(GCC OR CLANG) target_compile_options(nfs41_driver PRIVATE "-Wno-switch") -if(USE_CLANG_CL) +if(CLANG) target_compile_options(nfs41_driver PRIVATE "-Wno-unused-value") +if(GCC) +# When CLang mimicks GCC, it uses C17 as default, which breaks __inline +target_compile_options(nfs41_driver PRIVATE "-std=gnu89") +endif() endif() endif()
[ros-diffs] [reactos] 05/19: [NDIS] Use FORCEINLINE instead of __inline
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=378642eb4f4ea1122e41bf61bd7323f0fb9d5ccb commit 378642eb4f4ea1122e41bf61bd7323f0fb9d5ccb Author: Jérôme Gardou AuthorDate: Mon Nov 9 09:15:57 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NDIS] Use FORCEINLINE instead of __inline --- drivers/network/ndis/ndis/buffer.c | 8 +--- drivers/network/ndis/ndis/misc.c | 10 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/network/ndis/ndis/buffer.c b/drivers/network/ndis/ndis/buffer.c index 4c00fa96d6f..f03f52ae94d 100644 --- a/drivers/network/ndis/ndis/buffer.c +++ b/drivers/network/ndis/ndis/buffer.c @@ -10,7 +10,9 @@ #include -__inline ULONG SkipToOffset( +FORCEINLINE +ULONG +SkipToOffset( IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, @@ -481,7 +483,7 @@ NdisAllocatePacketPoolEx( NumberOfDescriptors = 0x; } -Length = sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + +Length = sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + sizeof(NDIS_PACKET_EXTENSION) + ProtocolReservedLength; Size = sizeof(NDISI_PACKET_POOL) + Length * NumberOfDescriptors; @@ -1163,7 +1165,7 @@ EXPORT NdisPacketSize( IN UINT ProtocolReservedSize) { -return sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + +return sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + sizeof(NDIS_PACKET_EXTENSION) + ProtocolReservedSize; } diff --git a/drivers/network/ndis/ndis/misc.c b/drivers/network/ndis/ndis/misc.c index 19755c5ed87..71e64c12cde 100644 --- a/drivers/network/ndis/ndis/misc.c +++ b/drivers/network/ndis/ndis/misc.c @@ -125,14 +125,14 @@ typedef struct _NDIS_HANDLE_OBJECT PVOID MapBuffer; } NDIS_HANDLE_OBJECT, *PNDIS_HANDLE_OBJECT; -__inline +FORCEINLINE PNDIS_HANDLE_OBJECT NDIS_HANDLE_TO_POBJECT ( NDIS_HANDLE handle ) { return (PNDIS_HANDLE_OBJECT)handle; } -__inline +FORCEINLINE NDIS_HANDLE NDIS_POBJECT_TO_HANDLE ( PNDIS_HANDLE_OBJECT obj ) { @@ -289,7 +289,7 @@ NdisOpenFile( FILE_SYNCHRONOUS_IO_NONALERT, // ULONG CreateOptions 0, // PVOID EaBuffer 0 ); // ULONG EaLength - + if ( !NT_SUCCESS(*Status) ) { NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x) Name %wZ\n", *Status, FileName)); @@ -346,7 +346,7 @@ NdisGetCurrentProcessorCounts( { NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); -ExGetCurrentProcessorCounts( (PULONG) pIdleCount, (PULONG) pKernelAndUser, (PULONG) pIndex); +ExGetCurrentProcessorCounts( (PULONG) pIdleCount, (PULONG) pKernelAndUser, (PULONG) pIndex); } @@ -356,7 +356,7 @@ NdisGetCurrentProcessorCounts( VOID EXPORT NdisGetSystemUpTime(OUT PULONG pSystemUpTime) -{ +{ ULONG Increment; LARGE_INTEGER TickCount;
[ros-diffs] [reactos] 04/19: [MSVCRTEX] Add some floating point functions for CLang build
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15c9f63b659fbd3d688e4f22e925fe89d656304f commit 15c9f63b659fbd3d688e4f22e925fe89d656304f Author: Jérôme Gardou AuthorDate: Fri Nov 6 21:39:00 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [MSVCRTEX] Add some floating point functions for CLang build Clang makes optimisations requiring functions not present in msvcrt --- sdk/lib/crt/math/i386/exp2_asm.s | 38 ++ sdk/lib/crt/msvcrtex.cmake | 9 + 2 files changed, 47 insertions(+) diff --git a/sdk/lib/crt/math/i386/exp2_asm.s b/sdk/lib/crt/math/i386/exp2_asm.s new file mode 100644 index 000..d2ab14d63b1 --- /dev/null +++ b/sdk/lib/crt/math/i386/exp2_asm.s @@ -0,0 +1,38 @@ +#include + +PUBLIC _exp2 + +/* FUNCTIONS ***/ +.code + +_exp2: +push ebp +mov ebp, esp + +fld qword ptr [ebp + 8] +fxam +fstsw ax +fwait +sahf +jnp .not_inf +jnc .not_inf +test ah, 2 +jz .done +fstp st +fldz +jmp .done +.not_inf: +fst st(1) +frndint +fxch st(1) +fsub st, st(1) +f2xm1 +fld1 +faddp st(1), st +fscale +fstp st(1) +.done: +pop ebp +ret + +END diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 593622e277d..0b6bff8520d 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -58,6 +58,15 @@ if(ARCH STREQUAL "i386") math/i386/cipow.c math/i386/cisin.c math/i386/cisqrt.c) +if (GCC AND CLANG) +# CLang performs some optimisations requiring those funtions +list(APPEND MSVCRTEX_ASM_SOURCE +math/i386/ceilf.S +math/i386/exp2_asm.s +math/i386/floorf.S) +list(APPEND MSVCRTEX_SOURCE +math/i386/sqrtf.c) +endif() elseif(ARCH STREQUAL "amd64") list(APPEND MSVCRTEX_ASM_SOURCE except/amd64/chkstk_ms.s)
[ros-diffs] [reactos] 06/19: [NTOSKRNL] Link memcmp to the import lib when using CLang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e00922a0fe09687bbd7518aa95a9142e457d82d3 commit e00922a0fe09687bbd7518aa95a9142e457d82d3 Author: Jérôme Gardou AuthorDate: Mon Nov 9 09:41:48 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NTOSKRNL] Link memcmp to the import lib when using CLang CLang performs some optimisations on e.g. strcmp, but memcmp is not exported by ntoskrnl --- ntoskrnl/CMakeLists.txt | 5 + 1 file changed, 5 insertions(+) diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 13ca75e351a..84125c75c9b 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -12,6 +12,11 @@ set(NTKRNLMP_ASM_SOURCE ${ASM_SOURCE}) spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB) add_asm_files(ntoskrnl_asm ${NTOSKRNL_ASM_SOURCE}) +if (GCC AND CLANG) +# Clang optimises strcmp calls to memcmp. +target_link_libraries(libntoskrnl INTERFACE memcmp) +endif() + list(APPEND PCH_SKIP_SOURCE guid.c)
[ros-diffs] [reactos] 11/19: [CDFS] Use GNU89 standard when using CLang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cab3e62f0ee6746b067fbdf8ec174b308e714dcd commit cab3e62f0ee6746b067fbdf8ec174b308e714dcd Author: Jérôme Gardou AuthorDate: Mon Nov 9 13:28:08 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CDFS] Use GNU89 standard when using CLang --- drivers/filesystems/cdfs/CMakeLists.txt | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/filesystems/cdfs/CMakeLists.txt b/drivers/filesystems/cdfs/CMakeLists.txt index 2f1d4526c3e..3e35991bfa0 100644 --- a/drivers/filesystems/cdfs/CMakeLists.txt +++ b/drivers/filesystems/cdfs/CMakeLists.txt @@ -38,3 +38,9 @@ target_link_libraries(cdfs ${PSEH_LIB} memcmp) add_importlibs(cdfs ntoskrnl hal) add_cd_file(TARGET cdfs DESTINATION reactos/system32/drivers NO_CAB FOR all) add_registry_inf(cdfs_reg.inf) + +if (CLANG AND GCC) +# Make __inline work as expected +target_compile_options(cdfs PRIVATE -std=gnu89) +endif() +
[ros-diffs] [reactos] 12/19: [EXT2FS] Use GNU89 standard when using CLang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f424d524882efbd06e85aad1e36fbd7aa8bb60ce commit f424d524882efbd06e85aad1e36fbd7aa8bb60ce Author: Jérôme Gardou AuthorDate: Mon Nov 9 13:28:34 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 16 16:58:10 2020 +0100 [EXT2FS] Use GNU89 standard when using CLang --- drivers/filesystems/ext2/CMakeLists.txt | 31 --- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/filesystems/ext2/CMakeLists.txt b/drivers/filesystems/ext2/CMakeLists.txt index 38851437730..dbd8cc84925 100644 --- a/drivers/filesystems/ext2/CMakeLists.txt +++ b/drivers/filesystems/ext2/CMakeLists.txt @@ -92,23 +92,32 @@ if(USE_CLANG_CL) set_property(SOURCE src/create.c src/fileinfo.c src/memory.c src/read.c APPEND_STRING PROPERTY COMPILE_FLAGS " /fallback") endif() -if(MSVC AND (NOT USE_CLANG_CL)) +if(MSVC) # Disable warnings: "unreferenced local variable", "initialized, but not used variable", "benign include" -remove_target_compile_option(ext2fs "/we4101") -remove_target_compile_option(ext2fs "/we4189") -target_compile_options(ext2fs PRIVATE /wd4189 /wd4142 /wd4101) +if (NOT CLANG) +remove_target_compile_option(ext2fs "/we4101") +remove_target_compile_option(ext2fs "/we4189") +target_compile_options(ext2fs PRIVATE /wd4189 /wd4142 /wd4101) +endif() else() -target_compile_options(ext2fs PRIVATE -Wno-pointer-sign -Wno-unused-function) -target_compile_options(ext2fs PRIVATE -Wno-unused-variable -Wno-missing-braces) -if(USE_CLANG_CL) -target_compile_options(ext2fs PRIVATE -Wno-unused-value -Wno-parentheses-equality) -target_compile_options(ext2fs PRIVATE -Wno-incompatible-pointer-types-discards-qualifiers) -target_compile_options(ext2fs PRIVATE "-Wno-#pragma-messages;-Wno-cast-calling-convention") -else() +target_compile_options(ext2fs PRIVATE +-Wno-pointer-sign -Wno-unused-function +-Wno-unused-variable -Wno-missing-braces) +if (NOT CLANG) target_compile_options(ext2fs PRIVATE -Wno-unused-but-set-variable) endif() endif() +if(CLANG) +target_compile_options(ext2fs PRIVATE +-Wno-unused-value -Wno-parentheses-equality +-Wno-incompatible-pointer-types-discards-qualifiers +"-Wno-#pragma-messages;-Wno-cast-calling-convention") +if (GCC) +target_compile_options(ext2fs PRIVATE -std=gnu89) +endif() +endif() + target_link_libraries(ext2fs memcmp ${PSEH_LIB}) add_definitions(-D__KERNEL__ -D_CRT_NO_POSIX_ERROR_CODES) set_module_type(ext2fs kernelmodedriver)
[ros-diffs] [reactos] 01/01: [CMAKE/WIDL] Fix build
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=acfff0919ebacc028f5000bbe8a7c0c7f3457772 commit acfff0919ebacc028f5000bbe8a7c0c7f3457772 Author: Jérôme Gardou AuthorDate: Fri Nov 20 10:12:31 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Nov 20 10:12:31 2020 +0100 [CMAKE/WIDL] Fix build --- sdk/cmake/widl-support.cmake | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/cmake/widl-support.cmake b/sdk/cmake/widl-support.cmake index 1b55d21b226..dbd5f3a73ab 100644 --- a/sdk/cmake/widl-support.cmake +++ b/sdk/cmake/widl-support.cmake @@ -79,10 +79,10 @@ function(add_rpc_files __type) get_defines(DEFINES) # Is it a client or server module? if(__type STREQUAL "server") -set(__server_client -Oif -s -o) +set(__server_client -Oif -s) set(__suffix _s) elseif(__type STREQUAL "client") -set(__server_client -Oif -c -o) +set(__server_client -Oif -c) set(__suffix _c) else() message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files") @@ -92,7 +92,9 @@ function(add_rpc_files __type) set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix}) add_custom_command( OUTPUT ${__name}.c ${__name}.h -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -H ${__name}.h ${__server_client} ${__name}.c ${FILE} +# We generate the two files in two passes because WIDL doesn't cope with being given two absolute paths as output +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__server_client} -o ${__name}.c -H ${__name}.h ${FILE} +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__server_client} -h -H ${__name}.h ${FILE} DEPENDS ${FILE} native-widl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach()
[ros-diffs] [reactos] 01/01: [CMAKE/WIDL] Run widl from the source directory
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b587e7b32eccdb85ee1865c5e7e241abe8580f20 commit b587e7b32eccdb85ee1865c5e7e241abe8580f20 Author: Jérôme Gardou AuthorDate: Fri Nov 20 09:47:33 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Nov 20 09:47:33 2020 +0100 [CMAKE/WIDL] Run widl from the source directory This dramatically improves ccache direct hit rate as now the generated files are identical across build trees --- sdk/cmake/widl-support.cmake | 46 ++-- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/sdk/cmake/widl-support.cmake b/sdk/cmake/widl-support.cmake index 267459383ba..1b55d21b226 100644 --- a/sdk/cmake/widl-support.cmake +++ b/sdk/cmake/widl-support.cmake @@ -32,8 +32,9 @@ function(add_idl_headers TARGET) set(HEADER ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} -DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl) +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${FILE} +DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} native-widl +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND HEADERS ${HEADER}) endforeach() add_custom_target(${TARGET} DEPENDS ${HEADERS}) @@ -56,18 +57,21 @@ function(add_rpcproxy_files) set(EXTRA_DEP ${REACTOS_SOURCE_DIR}/sdk/include/psdk/${SPLIT_FILE}) endif() endif() -list(APPEND IDLS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) +list(APPEND IDLS ${FILE}) +list(APPEND IDL_DEPS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -h -H ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} -DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP} native-widl) +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -h -H ${NAME}_p.h ${FILE} +DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP} native-widl +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach() # Extra pass to generate dlldata add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS} -DEPENDS ${IDLS} native-widl) +DEPENDS ${IDL_DEPS} native-widl +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endfunction() function(add_rpc_files __type) @@ -86,32 +90,25 @@ function(add_rpc_files __type) foreach(FILE ${ARGN}) get_filename_component(__name ${FILE} NAME_WE) set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix}) -if(NOT IS_ABSOLUTE ${FILE}) -set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) -endif() add_custom_command( OUTPUT ${__name}.c ${__name}.h COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -H ${__name}.h ${__server_client} ${__name}.c ${FILE} -DEPENDS ${FILE} native-widl) +DEPENDS ${FILE} native-widl +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach() endfunction() function(generate_idl_iids) foreach(IDL_FILE ${ARGN}) get_filename_component(FILE ${IDL_FILE} NAME) -if(FILE STREQUAL "${IDL_FILE}") -set(IDL_FILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}") -else() -set(IDL_FILE_FULL ${IDL_FILE}) -endif() get_includes(INCLUDES) get_defines(DEFINES) get_filename_component(NAME ${IDL_FILE} NAME_WE) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -u -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL} -DEPENDS ${IDL_FILE_FULL} native-widl) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c PROPERTIES GENERATED TRUE) +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -u -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE} +DEPENDS ${IDL_FILE_FULL} native-widl +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach() endfunction() @@ -127,19 +124,14 @@ function(add_iid_library TARGET) endfunction() function(add_idl_reg_script IDL_FILE) -get_filename_component(FILE ${IDL_FILE} NAME) -
[ros-diffs] [reactos] 01/01: [CMAKE/WIDL] Fix build (try 2)
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8297109b95afd989ed5a7c1796e2a2e444e1421b commit 8297109b95afd989ed5a7c1796e2a2e444e1421b Author: Jérôme Gardou AuthorDate: Fri Nov 20 10:17:43 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Nov 20 10:17:43 2020 +0100 [CMAKE/WIDL] Fix build (try 2) --- sdk/cmake/widl-support.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/cmake/widl-support.cmake b/sdk/cmake/widl-support.cmake index dbd5f3a73ab..972011f3d9e 100644 --- a/sdk/cmake/widl-support.cmake +++ b/sdk/cmake/widl-support.cmake @@ -61,7 +61,9 @@ function(add_rpcproxy_files) list(APPEND IDL_DEPS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -h -H ${NAME}_p.h ${FILE} +# We generate the two files in two passes because WIDL doesn't cope with being given two absolute paths as output +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -H ${NAME}_p.h ${FILE} +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -h -H ${NAME}_p.h ${FILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP} native-widl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach()
[ros-diffs] [reactos] 01/02: [CMAKE] Fix host tools dependency tracking
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72d94714241006190741e47ecc9020503d977d37 commit 72d94714241006190741e47ecc9020503d977d37 Author: Jérôme Gardou AuthorDate: Fri Nov 20 19:54:54 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Nov 20 19:57:48 2020 +0100 [CMAKE] Fix host tools dependency tracking --- sdk/cmake/host-tools.cmake | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/cmake/host-tools.cmake b/sdk/cmake/host-tools.cmake index dedcb11a4c5..08e91da0216 100644 --- a/sdk/cmake/host-tools.cmake +++ b/sdk/cmake/host-tools.cmake @@ -15,9 +15,10 @@ function(setup_host_tools) ExternalProject_Add(host-tools SOURCE_DIR ${REACTOS_SOURCE_DIR} PREFIX ${REACTOS_BINARY_DIR}/host-tools -INSTALL_DIR ${REACTOS_BINARY_DIR}/host-tools -CMAKE_ARGS -UCMAKE_TOOLCHAIN_FILE -DARCH:STRING=${ARCH} -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools +BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools/bin +CMAKE_ARGS -UCMAKE_TOOLCHAIN_FILE -DARCH:STRING=${ARCH} -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools -DTOOLS_FOLDER=${REACTOS_BINARY_DIR}/host-tools/bin BUILD_ALWAYS TRUE +INSTALL_COMMAND ${CMAKE_COMMAND} -E true BUILD_BYPRODUCTS ${HOST_TOOLS_OUTPUT} ) @@ -26,6 +27,6 @@ function(setup_host_tools) foreach(_tool ${HOST_TOOLS}) add_executable(native-${_tool} IMPORTED) set_target_properties(native-${_tool} PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${_tool}${HOST_EXE_SUFFIX}) -add_dependencies(native-${_tool} host-tools) +add_dependencies(native-${_tool} host-tools ${INSTALL_DIR}/bin/${_tool}${HOST_EXE_SUFFIX}) endforeach() endfunction()
[ros-diffs] [reactos] 02/02: [VMAKE/WIDL] Properly fix build (try 3)
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f54c7b646ced236fdd8fb4f16b144469df14c8dc commit f54c7b646ced236fdd8fb4f16b144469df14c8dc Author: Jérôme Gardou AuthorDate: Fri Nov 20 19:56:56 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Nov 20 19:57:48 2020 +0100 [VMAKE/WIDL] Properly fix build (try 3) --- sdk/cmake/widl-support.cmake | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sdk/cmake/widl-support.cmake b/sdk/cmake/widl-support.cmake index 972011f3d9e..1ad152b22a2 100644 --- a/sdk/cmake/widl-support.cmake +++ b/sdk/cmake/widl-support.cmake @@ -61,9 +61,9 @@ function(add_rpcproxy_files) list(APPEND IDL_DEPS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h -# We generate the two files in two passes because WIDL doesn't cope with being given two absolute paths as output +# We generate the two files in two passes because WIDL accepts only one custom file name as output COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c -H ${NAME}_p.h ${FILE} -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -p -h -H ${NAME}_p.h ${FILE} +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h ${FILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${EXTRA_DEP} native-widl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach() @@ -79,24 +79,25 @@ endfunction() function(add_rpc_files __type) get_includes(INCLUDES) get_defines(DEFINES) +set(__additional_flags -Oif) # Is it a client or server module? if(__type STREQUAL "server") -set(__server_client -Oif -s) +set(__server_client -s) set(__suffix _s) elseif(__type STREQUAL "client") -set(__server_client -Oif -c) +set(__server_client -c) set(__suffix _c) else() message(FATAL_ERROR "Please pass either server or client as argument to add_rpc_files") endif() foreach(FILE ${ARGN}) get_filename_component(__name ${FILE} NAME_WE) -set(__name ${CMAKE_CURRENT_BINARY_DIR}/${__name}${__suffix}) +set(__name ${__name}${__suffix}) add_custom_command( -OUTPUT ${__name}.c ${__name}.h -# We generate the two files in two passes because WIDL doesn't cope with being given two absolute paths as output -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__server_client} -o ${__name}.c -H ${__name}.h ${FILE} -COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__server_client} -h -H ${__name}.h ${FILE} +OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h +# We generate the two files in two passes because WIDL accepts only one custom file name as output +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__additional_flags} ${__server_client} -o ${CMAKE_CURRENT_BINARY_DIR}/${__name}.c -H ${__name}.h ${FILE} +COMMAND native-widl ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${__additional_flags} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${__name}.h ${FILE} DEPENDS ${FILE} native-widl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach()
[ros-diffs] [reactos] 01/01: [KDGDB] Always use kernel stack to get stack frame
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3acbec4851c99911b65741a3fe191bb9d066cf9a commit 3acbec4851c99911b65741a3fe191bb9d066cf9a Author: Jérôme Gardou AuthorDate: Fri Nov 6 09:38:17 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 9 10:47:05 2020 +0100 [KDGDB] Always use kernel stack to get stack frame --- drivers/base/kdgdb/i386_sup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/kdgdb/i386_sup.c b/drivers/base/kdgdb/i386_sup.c index 0a357a149f0..82492d415a3 100644 --- a/drivers/base/kdgdb/i386_sup.c +++ b/drivers/base/kdgdb/i386_sup.c @@ -100,6 +100,7 @@ thread_to_reg(PETHREAD Thread, enum reg_name reg_name, unsigned short* size) return NULL; } } +#if 0 else if (Thread->Tcb.TrapFrame) { PKTRAP_FRAME TrapFrame = Thread->Tcb.TrapFrame; @@ -128,6 +129,7 @@ thread_to_reg(PETHREAD Thread, enum reg_name reg_name, unsigned short* size) KDDBGPRINT("Unhandled regname: %d.\n", reg_name); } } +#endif else { static PULONG Esp; @@ -213,7 +215,7 @@ gdb_send_registers(void) } } } - + return finish_gdb_packet(); }
[ros-diffs] [reactos] 01/01: |CMAKE] Use RULE_LAUNCH_COMPILE property to handle ccache
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf04126e025fdcabe360822d3d2fbc68b1841a50 commit bf04126e025fdcabe360822d3d2fbc68b1841a50 Author: Jérôme Gardou AuthorDate: Mon Nov 9 10:06:44 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Nov 9 10:47:19 2020 +0100 |CMAKE] Use RULE_LAUNCH_COMPILE property to handle ccache --- CMakeLists.txt| 1 + sdk/cmake/gcc.cmake | 4 ++-- toolchain-clang.cmake | 6 -- toolchain-gcc.cmake | 6 -- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f81d9274381..103b1c5bf90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to if(ENABLE_CCACHE) message(WARNING "-- Disabling precompiled headers support (ccache).") option(PCH "Whether to use precompiled headers" OFF) +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) elseif(GCC) message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.") option(PCH "Whether to use precompiled headers" OFF) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 216c24c54a4..5fac4f059f4 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -246,9 +246,9 @@ if((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND set(_compress_debug_sections_flag "-Wa,--compress-debug-sections") endif() -set(CMAKE_C_COMPILE_OBJECT "${CCACHE} ${_compress_debug_sections_flag} -o -c ") +set(CMAKE_C_COMPILE_OBJECT " ${_compress_debug_sections_flag} -o -c ") # FIXME: Once the GCC toolchain bugs are fixed, add _compress_debug_sections_flag to CXX too -set(CMAKE_CXX_COMPILE_OBJECT "${CCACHE} -o -c ") +set(CMAKE_CXX_COMPILE_OBJECT " -o -c ") set(CMAKE_ASM_COMPILE_OBJECT " ${_compress_debug_sections_flag} -x assembler-with-cpp -o -I${REACTOS_SOURCE_DIR}/sdk/include/asm -I${REACTOS_BINARY_DIR}/sdk/include/asm -D__ASM__ -c ") set(CMAKE_RC_COMPILE_OBJECT " -O coff -DRC_INVOKED -D__WIN32__=1 -D__FLAT__=1 ${I18N_DEFS} ") diff --git a/toolchain-clang.cmake b/toolchain-clang.cmake index af3caeccda4..da3ffc782e7 100644 --- a/toolchain-clang.cmake +++ b/toolchain-clang.cmake @@ -24,12 +24,6 @@ if(NOT DEFINED MINGW_TOOLCHAIN_SUFFIX) set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix") endif() -if(ENABLE_CCACHE) -set(CCACHE "ccache" CACHE STRING "ccache") -else() -set(CCACHE "" CACHE STRING "ccache") -endif() - # The name of the target operating system set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR i686) diff --git a/toolchain-gcc.cmake b/toolchain-gcc.cmake index d2801733ec4..276225ec663 100644 --- a/toolchain-gcc.cmake +++ b/toolchain-gcc.cmake @@ -30,12 +30,6 @@ if(NOT DEFINED MINGW_TOOLCHAIN_SUFFIX) set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix") endif() -if(ENABLE_CCACHE) -set(CCACHE "ccache" CACHE STRING "ccache") -else() -set(CCACHE "" CACHE STRING "ccache") -endif() - # The name of the target operating system set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR i686)
[ros-diffs] [reactos] 01/05: [CRTDLL] Make this a stand-alone CRT DLL
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c321d3e88bdd5400285f0610067f97d2c176addf commit c321d3e88bdd5400285f0610067f97d2c176addf Author: Jérôme Gardou AuthorDate: Thu Oct 22 12:25:19 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Oct 22 18:07:27 2020 +0200 [CRTDLL] Make this a stand-alone CRT DLL Because CRTs must be isolated from each other. This basically reverts commit f0c91ae --- dll/win32/crtdll/CMakeLists.txt |7 +- dll/win32/crtdll/crtdll.spec| 1054 +++ 2 files changed, 528 insertions(+), 533 deletions(-) diff --git a/dll/win32/crtdll/CMakeLists.txt b/dll/win32/crtdll/CMakeLists.txt index c40dda200e5..b2d01cc5a4b 100644 --- a/dll/win32/crtdll/CMakeLists.txt +++ b/dll/win32/crtdll/CMakeLists.txt @@ -19,12 +19,7 @@ list(APPEND SOURCE add_library(crtdll MODULE ${SOURCE}) set_module_type(crtdll win32dll ENTRYPOINT DllMain 12) -target_link_libraries(crtdll crt wine) - -if(MSVC) -add_importlibs(crtdll msvcrt) -target_link_libraries(crtdll oldnames) -endif() +target_link_libraries(crtdll crt wine ${PSEH_LIB}) add_importlibs(crtdll kernel32 ntdll) add_cd_file(TARGET crtdll DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/crtdll/crtdll.spec b/dll/win32/crtdll/crtdll.spec index 749140e7faa..0b8e0f74225 100644 --- a/dll/win32/crtdll/crtdll.spec +++ b/dll/win32/crtdll/crtdll.spec @@ -1,528 +1,528 @@ -# Old C runtime library. All functions provided by msvcrt +# Old C runtime library. - @ cdecl ??2@YAPAXI@Z(long) msvcrt.??2@YAPAXI@Z - @ cdecl ??3@YAXPAX@Z(ptr) msvcrt.??3@YAXPAX@Z - @ cdecl ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z(ptr) msvcrt.?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z - @ cdecl _CIacos() msvcrt._CIacos - @ cdecl _CIasin() msvcrt._CIasin - @ cdecl _CIatan() msvcrt._CIatan - @ cdecl _CIatan2() msvcrt._CIatan2 - @ cdecl _CIcos() msvcrt._CIcos - @ cdecl _CIcosh() msvcrt._CIcosh - @ cdecl _CIexp() msvcrt._CIexp - @ cdecl _CIfmod() msvcrt._CIfmod - @ cdecl _CIlog() msvcrt._CIlog - @ cdecl _CIlog10() msvcrt._CIlog10 - @ cdecl _CIpow() msvcrt._CIpow - @ cdecl _CIsin() msvcrt._CIsin - @ cdecl _CIsinh() msvcrt._CIsinh - @ cdecl _CIsqrt() msvcrt._CIsqrt - @ cdecl _CItan() msvcrt._CItan - @ cdecl _CItanh() msvcrt._CItanh - @ extern _HUGE_dll msvcrt._HUGE - @ cdecl _XcptFilter() msvcrt._XcptFilter - @ cdecl __GetMainArgs(ptr ptr ptr long) - @ extern __argc_dll msvcrt.__argc - @ extern __argv_dll msvcrt.__argv - @ cdecl __dllonexit(ptr ptr ptr) msvcrt.__dllonexit - @ cdecl __doserrno() msvcrt.__doserrno - @ cdecl __fpecode() msvcrt.__fpecode - @ cdecl __isascii(long) msvcrt.__isascii - @ cdecl __iscsym(long) msvcrt.__iscsym - @ cdecl __iscsymf(long) msvcrt.__iscsymf - @ extern __mb_cur_max_dll msvcrt.__mb_cur_max - @ cdecl __pxcptinfoptrs() msvcrt.__pxcptinfoptrs - @ cdecl __threadhandle() msvcrt.__threadhandle - @ cdecl __threadid() msvcrt.__threadid - @ cdecl __toascii(long) msvcrt.__toascii - @ cdecl _abnormal_termination() msvcrt._abnormal_termination - @ cdecl _access(str long) msvcrt._access - @ extern _acmdln_dll msvcrt._acmdln - @ extern _aexit_rtn_dll msvcrt._aexit_rtn - @ cdecl _amsg_exit(long) msvcrt._amsg_exit - @ cdecl _assert(str str long) msvcrt._assert - @ extern _basemajor_dll CRTDLL__basemajor_dll - @ extern _baseminor_dll CRTDLL__baseminor_dll - @ extern _baseversion_dll CRTDLL__baseversion_dll - @ cdecl _beep(long long) msvcrt._beep - @ cdecl _beginthread(ptr long ptr) msvcrt._beginthread - @ cdecl _c_exit() msvcrt._c_exit - @ cdecl _cabs(long) msvcrt._cabs - @ cdecl _cexit() msvcrt._cexit - @ cdecl _cgets(str) msvcrt._cgets - @ cdecl _chdir(str) msvcrt._chdir - @ cdecl _chdrive(long) msvcrt._chdrive - @ cdecl _chgsign( double ) msvcrt._chgsign - @ cdecl _chmod(str long) msvcrt._chmod - @ cdecl _chsize(long long) msvcrt._chsize - @ cdecl _clearfp() msvcrt._clearfp - @ cdecl _close(long) msvcrt._close - @ cdecl _commit(long) msvcrt._commit - @ extern _commode_dll msvcrt._commode - @ cdecl _control87(long long) msvcrt._control87 - @ cdecl _controlfp(long long) msvcrt._controlfp - @ cdecl _copysign( double double ) msvcrt._copysign - @ varargs _cprintf(str) msvcrt._cprintf - @ extern _cpumode_dll CRTDLL__cpumode_dll - @ cdecl _cputs(str) msvcrt._cputs - @ cdecl _creat(str long) msvcrt._creat - @ varargs _cscanf(str) msvcrt._cscanf - @ extern _ctype msvcrt._ctype - @ cdecl _cwait(ptr long long) msvcrt._cwait - @ extern _daylight_dll msvcrt._daylight - @ cdecl _dup(long) msvcrt._dup - @ cdecl _dup2(long long) msvcrt._dup2 - @ cdecl _ecvt( double long ptr ptr) msvcrt._ecvt - @ cdecl _endthread() msvcrt._endthread - @ extern _environ_dll msvcrt._environ - @ cdecl _eof(long) msvcrt._eof - @ cdecl _errno() msvcrt._errno - @ cdecl _except_handler2(ptr ptr ptr ptr) msvcrt._except_handler2 - @ varargs _execl(str str) msvcrt._execl - @ varargs _execle(str str) msvcrt._execle - @ varargs _execlp(str str) msvcrt
[ros-diffs] [reactos] 03/05: [CMAKE] Only link msvcrtex to win32cui, win32gui, win32dll, win32ocx and cpl modules
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c25e816bfff056baad76346cbd49835fc914ddd commit 5c25e816bfff056baad76346cbd49835fc914ddd Author: Jérôme Gardou AuthorDate: Thu Oct 22 15:12:49 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Oct 22 18:07:27 2020 +0200 [CMAKE] Only link msvcrtex to win32cui, win32gui, win32dll, win32ocx and cpl modules --- sdk/cmake/CMakeMacros.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 26337a0713e..f4d7cb1f1b1 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -533,7 +533,8 @@ function(add_importlibs _module) foreach(LIB ${ARGN}) if("${LIB}" MATCHES "msvcrt") target_compile_definitions(${_module} PRIVATE _DLL __USE_CRTIMP) -target_link_libraries(${_module} msvcrtex) +# set_module_type might not have been called at this point, so use a generator expression +target_link_libraries(${_module} "$<$,win32gui;win32cui;win32dll;win32ocx;cpl>:msvcrtex>") endif() target_link_libraries(${_module} lib${LIB}) add_dependencies(${_module} lib${LIB})
[ros-diffs] [reactos] 04/05: [APISETS] Declare them as modules instead of win32dll
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bada20a361d385a779901c3fe0c40fe55dcde1d7 commit bada20a361d385a779901c3fe0c40fe55dcde1d7 Author: Jérôme Gardou AuthorDate: Thu Oct 22 15:15:46 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Oct 22 18:07:27 2020 +0200 [APISETS] Declare them as modules instead of win32dll --- dll/apisets/CMakeLists.txt| 2 +- dll/apisets/CMakeLists.txt.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/apisets/CMakeLists.txt b/dll/apisets/CMakeLists.txt index 27b82d2a281..a08f9f12d36 100644 --- a/dll/apisets/CMakeLists.txt +++ b/dll/apisets/CMakeLists.txt @@ -22,7 +22,7 @@ function (add_apiset apiset_name baseaddress) ${CMAKE_CURRENT_BINARY_DIR}/${apiset_name}.def) add_dependencies(${apiset_name} xdk) -set_module_type(${apiset_name} win32dll ENTRYPOINT 0 UNICODE IMAGEBASE ${baseaddress}) +set_module_type(${apiset_name} module UNICODE IMAGEBASE ${baseaddress}) if(NOT MSVC) target_compile_options(${apiset_name} PRIVATE -fno-builtin) diff --git a/dll/apisets/CMakeLists.txt.in b/dll/apisets/CMakeLists.txt.in index 69aaa9fa38d..12ca868f641 100644 --- a/dll/apisets/CMakeLists.txt.in +++ b/dll/apisets/CMakeLists.txt.in @@ -22,7 +22,7 @@ function (add_apiset apiset_name baseaddress) ${CMAKE_CURRENT_BINARY_DIR}/${apiset_name}.def) add_dependencies(${apiset_name} xdk) -set_module_type(${apiset_name} win32dll ENTRYPOINT 0 UNICODE IMAGEBASE ${baseaddress}) +set_module_type(${apiset_name} module UNICODE IMAGEBASE ${baseaddress}) if(NOT MSVC) target_compile_options(${apiset_name} PRIVATE -fno-builtin)
[ros-diffs] [reactos] 05/05: [CMAKE] Use an INTERFACE library to perform the msvcrt <-> msvcrtex binding
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=23e04ae1eec666118a2359a17fc442e0332c258b commit 23e04ae1eec666118a2359a17fc442e0332c258b Author: Jérôme Gardou AuthorDate: Thu Oct 22 16:29:40 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Oct 22 18:07:27 2020 +0200 [CMAKE] Use an INTERFACE library to perform the msvcrt <-> msvcrtex binding --- dll/win32/msvcrt/CMakeLists.txt | 14 +++--- sdk/cmake/CMakeMacros.cmake | 6 -- sdk/lib/crt/msvcrtex.cmake | 3 +++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dll/win32/msvcrt/CMakeLists.txt b/dll/win32/msvcrt/CMakeLists.txt index 2b558d18191..2e0c6625971 100644 --- a/dll/win32/msvcrt/CMakeLists.txt +++ b/dll/win32/msvcrt/CMakeLists.txt @@ -1,6 +1,14 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/crt/include) -spec2def(msvcrt.dll msvcrt.spec ADD_IMPORTLIB) +spec2def(msvcrt.dll msvcrt.spec) + +# The msvcrt <-> msvcrtex trick +generate_import_lib(libmsvcrt_real msvcrt.dll msvcrt.spec) +add_library(libmsvcrt INTERFACE) +target_compile_definitions(libmsvcrt INTERFACE _DLL __USE_CRTIMP) +# if the linked module is one of win32gui;win32cui;win32dll;win32ocx;cpl link it with msvcrtex, which itself is linked to libmsvcrt_real +# Otherwise, just link to libmsvcrt_real +target_link_libraries(libmsvcrt INTERFACE "$,win32gui;win32cui;win32dll;win32ocx;cpl>,msvcrtex,libmsvcrt_real>") add_definitions( -DUSE_MSVCRT_PREFIX @@ -26,8 +34,8 @@ target_link_libraries(msvcrt crt wine ${PSEH_LIB}) if(MSVC) # export of deleting destructor "name" -add_target_link_flags(msvcrt "/ignore:4102") -add_target_property(libmsvcrt STATIC_LIBRARY_FLAGS "/ignore:4102") +target_link_options(msvcrt PRIVATE "/ignore:4102") +set_property(TARGET libmsvcrt_real APPEND PROPERTY STATIC_LIBRARY_OPTIONS "/ignore:4102") endif() add_importlibs(msvcrt kernel32 ntdll) diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index f4d7cb1f1b1..6458e75fdaf 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -531,13 +531,7 @@ endif() function(add_importlibs _module) add_dependency_node(${_module}) foreach(LIB ${ARGN}) -if("${LIB}" MATCHES "msvcrt") -target_compile_definitions(${_module} PRIVATE _DLL __USE_CRTIMP) -# set_module_type might not have been called at this point, so use a generator expression -target_link_libraries(${_module} "$<$,win32gui;win32cui;win32dll;win32ocx;cpl>:msvcrtex>") -endif() target_link_libraries(${_module} lib${LIB}) -add_dependencies(${_module} lib${LIB}) add_dependency_edge(${_module} ${LIB}) endforeach() endfunction() diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 9d4182ffb4d..593622e277d 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -96,6 +96,9 @@ add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE}) add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm}) target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_) +# Link msvcrtex to the "real" msvcrt.dll library. See msvcrt.dll CMakeLists.txt to see what really happens here +target_link_libraries(msvcrtex libmsvcrt_real libkernel32) + if(GCC OR CLANG) target_compile_options(msvcrtex PRIVATE $<$:-Wno-main>) if(LTCG)
[ros-diffs] [reactos] 02/05: [CMAKE] Introduce the REACTOS_MODULE_TYPE target property
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=840fe4d6acf3e2899b6bb59a243985af91579325 commit 840fe4d6acf3e2899b6bb59a243985af91579325 Author: Jérôme Gardou AuthorDate: Thu Oct 22 15:12:02 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Oct 22 18:07:27 2020 +0200 [CMAKE] Introduce the REACTOS_MODULE_TYPE target property And set it in set_module_type function --- CMakeLists.txt | 7 +++ sdk/cmake/CMakeMacros.cmake | 3 +++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0ffe31e9d6..3f56a025651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,13 @@ else() set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) # Add our own target properties +# General module definitions +define_property(TARGET PROPERTY REACTOS_MODULE_TYPE +BRIEF_DOCS "The type of this module" +FULL_DOCS [[ +The type of this module. +One of "nativecui", "nativedll", "kernelmodedriver", "wdmdriver", "kerneldll", "win32cui", "win32gui", "win32dll", "win32ocx", "cpl" or "module"]]) + # C++ define_property(TARGET PROPERTY WITH_CXX_EXCEPTIONS BRIEF_DOCS "Enable C++ exceptions on this target" diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index e3ed4a00545..26337a0713e 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -567,6 +567,9 @@ function(set_module_type MODULE TYPE) message(FATAL_ERROR "Unknown type ${TYPE} for module ${MODULE}") endif() +# Set our target property +set_target_properties(${MODULE} PROPERTIES REACTOS_MODULE_TYPE ${TYPE}) + if(DEFINED __subsystem) set_subsystem(${MODULE} ${__subsystem}) endif()
[ros-diffs] [reactos] 12/12: Apply suggestions from code review
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ab825334dd321e24338c583835eb7b0b9e9add2d commit ab825334dd321e24338c583835eb7b0b9e9add2d Author: Jérôme Gardou AuthorDate: Fri Oct 16 15:57:20 2020 +0200 Commit: Jérôme Gardou CommitDate: Tue Oct 20 21:44:54 2020 +0200 Apply suggestions from code review Beautification and clarity Co-authored-by: Victor Perevertkin Co-authored-by: Hermès BÉLUSCA - MAÏTO --- base/services/tftpd/CMakeLists.txt | 2 +- dll/3rdparty/libxslt/CMakeLists.txt | 3 +-- sdk/lib/crt/msvcrtex.cmake | 6 +++--- sdk/lib/drivers/lwip/CMakeLists.txt | 2 +- sdk/tools/wpp/CMakeLists.txt| 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/base/services/tftpd/CMakeLists.txt b/base/services/tftpd/CMakeLists.txt index fb6ab01c67d..1b10567bd7f 100644 --- a/base/services/tftpd/CMakeLists.txt +++ b/base/services/tftpd/CMakeLists.txt @@ -4,6 +4,6 @@ set_module_type(tftpd win32cui) add_importlibs(tftpd advapi32 ws2_32 iphlpapi msvcrt kernel32) add_cd_file(TARGET tftpd DESTINATION reactos/system32 FOR all) -if((NOT MSVC) OR USE_CLANG_CL) +if(GCC OR CLANG) target_compile_options(tftpd PRIVATE -Wno-format-overflow) endif() diff --git a/dll/3rdparty/libxslt/CMakeLists.txt b/dll/3rdparty/libxslt/CMakeLists.txt index 5247b3efb7a..5a4910b6f3d 100644 --- a/dll/3rdparty/libxslt/CMakeLists.txt +++ b/dll/3rdparty/libxslt/CMakeLists.txt @@ -43,10 +43,9 @@ if(MSVC) add_importlibs(libxslt ntdll) endif() -if ((NOT MSVC) OR USE_CLANG_CL) +if(GCC OR CLANG) target_compile_options(libxslt PRIVATE -Wno-misleading-indentation -Wno-pointer-sign -Wno-unused-function) endif() add_pch(libxslt precomp.h SOURCE) add_cd_file(TARGET libxslt DESTINATION reactos/system32 FOR all) - diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index b55f53ce659..9d4182ffb4d 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -96,9 +96,9 @@ add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE}) add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm}) target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_) -if ((NOT MSVC) OR USE_CLANG_CL) +if(GCC OR CLANG) target_compile_options(msvcrtex PRIVATE $<$:-Wno-main>) -if (LTCG) +if(LTCG) target_compile_options(msvcrtex PRIVATE -fno-lto) endif() endif() @@ -107,7 +107,7 @@ set_source_files_properties(startup/crtdll.c PROPERTIES COMPILE_DEFINITIONS CRTD set_source_files_properties(startup/crtexe.c startup/wcrtexe.c PROPERTIES COMPILE_DEFINITIONS _M_CEE_PURE) -if (NOT MSVC) +if(NOT MSVC) target_link_libraries(msvcrtex oldnames) endif() diff --git a/sdk/lib/drivers/lwip/CMakeLists.txt b/sdk/lib/drivers/lwip/CMakeLists.txt index 4b70c3c472c..f2faa8db92e 100644 --- a/sdk/lib/drivers/lwip/CMakeLists.txt +++ b/sdk/lib/drivers/lwip/CMakeLists.txt @@ -62,6 +62,6 @@ add_library(lwip ${SOURCE}) add_dependencies(lwip bugcodes xdk) add_pch(lwip precomp.h SOURCE) -if((NOT MSVC) AND LTCG) +if((NOT MSVC) AND LTCG) target_compile_options(lwip PRIVATE -fno-builtin-malloc -fno-builtin-free) endif() diff --git a/sdk/tools/wpp/CMakeLists.txt b/sdk/tools/wpp/CMakeLists.txt index 0b68ae806cc..389b0c5130f 100644 --- a/sdk/tools/wpp/CMakeLists.txt +++ b/sdk/tools/wpp/CMakeLists.txt @@ -14,7 +14,7 @@ if(MSVC) # Disable warnings add_compile_options( -/wd4146 # " unary minus operator applied to unsigned type, result still unsigned" +/wd4146 # "unary minus operator applied to unsigned type, result still unsigned" /wd4244) # "'=': conversion from 'a' to 'b', possible loss of data" endif()
[ros-diffs] [reactos] 01/01: [NTOSKRNL] Completely disable optimizations when using GDB
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f26754e6dd25738522d5e1fe468e74cc398b9f47 commit f26754e6dd25738522d5e1fe468e74cc398b9f47 Author: Jérôme Gardou AuthorDate: Wed Oct 21 12:32:54 2020 +0200 Commit: Jérôme Gardou CommitDate: Wed Oct 21 13:11:20 2020 +0200 [NTOSKRNL] Completely disable optimizations when using GDB --- ntoskrnl/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 57a387ffa23..e1823f70019 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -39,6 +39,8 @@ if(MSVC) add_target_link_flags(ntoskrnl "/SECTION:INIT,D") else() if(GDB) +# Completely disable optimizations when debugging the kernel +target_compile_options(ntoskrnl PRIVATE -O0) set_image_base(ntoskrnl 0x0080) else() set_image_base(ntoskrnl 0x8080)
[ros-diffs] [reactos] 02/06: [MSVCRT_WINETEST] Unconditionally link against oldnames
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d53b03e676e5c9f846182c7e77ec7fb71c09e678 commit d53b03e676e5c9f846182c7e77ec7fb71c09e678 Author: Jérôme Gardou AuthorDate: Mon Nov 2 10:49:24 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [MSVCRT_WINETEST] Unconditionally link against oldnames --- modules/rostests/winetests/msvcrt/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rostests/winetests/msvcrt/CMakeLists.txt b/modules/rostests/winetests/msvcrt/CMakeLists.txt index 0574e646adf..2c4e7d581b0 100644 --- a/modules/rostests/winetests/msvcrt/CMakeLists.txt +++ b/modules/rostests/winetests/msvcrt/CMakeLists.txt @@ -36,9 +36,9 @@ endif() set_module_type(msvcrt_winetest win32cui) add_importlibs(msvcrt_winetest advapi32 msvcrt kernel32) +target_link_libraries(msvcrt_winetest oldnames) if(MSVC) -target_link_libraries(msvcrt_winetest oldnames) add_importlibs(msvcrt_winetest ntdll) endif()
[ros-diffs] [reactos] 03/06: [SPEC2DEF] Work-around a bug in MS linker handling of extern forwarders
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5387a7ccb2ed0dc5bc39ed3d946c0f761bcce37b commit 5387a7ccb2ed0dc5bc39ed3d946c0f761bcce37b Author: Jérôme Gardou AuthorDate: Wed Nov 25 14:26:53 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [SPEC2DEF] Work-around a bug in MS linker handling of extern forwarders --- sdk/tools/spec2def/spec2def.c | 21 + 1 file changed, 21 insertions(+) diff --git a/sdk/tools/spec2def/spec2def.c b/sdk/tools/spec2def/spec2def.c index 9fc4d8cda45..8eb12c1d84d 100644 --- a/sdk/tools/spec2def/spec2def.c +++ b/sdk/tools/spec2def/spec2def.c @@ -244,6 +244,18 @@ OutputLine_stub(FILE *file, EXPORT *pexp) int bRelay = 0; int bInPrototype = 0; +/* Workaround for forwarded externs. See here for an explanation: + * https://stackoverflow.com/questions/4060143/forwarding-data-in-a-dll */ +if (gbMSComp && +(pexp->nCallingConvention == CC_EXTERN) && +(pexp->strTarget.buf != NULL) && +(!!ScanToken(pexp->strTarget.buf, '.'))) +{ +fprintf(file, "#pragma comment(linker,\"/export:%s%.*s=%.*s,DATA\")\n\n", +gpszUnderscore, pexp->strName.len, pexp->strName.buf, pexp->strTarget.len, pexp->strTarget.buf); +return 0; +} + if (pexp->nCallingConvention != CC_STUB && (pexp->uFlags & FL_STUB) == 0) { @@ -736,6 +748,15 @@ OutputLine_def(FILE *fileDest, EXPORT *pexp) DbgPrint("OutputLine_def: skipping private export '%.*s'...\n", pexp->strName.len, pexp->strName.buf); return 1; } + +/* For MS linker, forwarded externs are managed via #pragma comment(linker,"/export:_data=org.data,DATA") */ +if (gbMSComp && !gbImportLib && (pexp->nCallingConvention == CC_EXTERN) && +(pexp->strTarget.buf != NULL) && !!ScanToken(pexp->strTarget.buf, '.')) +{ +DbgPrint("OutputLine_def: skipping forwarded extern export '%.*s' ->'%.*s'...\n", +pexp->strName.len, pexp->strName.buf, pexp->strTarget.len, pexp->strTarget.buf); +return 1; +} DbgPrint("OutputLine_def: '%.*s'...\n", pexp->strName.len, pexp->strName.buf); fprintf(fileDest, " ");
[ros-diffs] [reactos] 06/06: [CMAKE] Turn import libs into regular C static libs
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b96e88894a4d55f5e8b94430deeb0f086151b24f commit b96e88894a4d55f5e8b94430deeb0f086151b24f Author: Jérôme Gardou AuthorDate: Mon Nov 2 10:51:08 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [CMAKE] Turn import libs into regular C static libs Embed msvcrtex into libmsvcrt Idea taken from Thomas Faber --- dll/win32/msvcrt/CMakeLists.txt| 17 +-- sdk/cmake/gcc.cmake| 54 +++--- sdk/cmake/msvc.cmake | 59 ++ sdk/lib/crt/msvcrtex.cmake | 12 +--- sdk/lib/crt/oldnames.cmake | 19 ++-- win32ss/gdi/gdi32/CMakeLists.txt | 5 +++- win32ss/user/user32/CMakeLists.txt | 5 ++-- 7 files changed, 110 insertions(+), 61 deletions(-) diff --git a/dll/win32/msvcrt/CMakeLists.txt b/dll/win32/msvcrt/CMakeLists.txt index 2e0c6625971..61ae9432d74 100644 --- a/dll/win32/msvcrt/CMakeLists.txt +++ b/dll/win32/msvcrt/CMakeLists.txt @@ -1,14 +1,12 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/crt/include) -spec2def(msvcrt.dll msvcrt.spec) +spec2def(msvcrt.dll msvcrt.spec ADD_IMPORTLIB) -# The msvcrt <-> msvcrtex trick -generate_import_lib(libmsvcrt_real msvcrt.dll msvcrt.spec) -add_library(libmsvcrt INTERFACE) +# Let consumers of msvcrt have the right defines target_compile_definitions(libmsvcrt INTERFACE _DLL __USE_CRTIMP) -# if the linked module is one of win32gui;win32cui;win32dll;win32ocx;cpl link it with msvcrtex, which itself is linked to libmsvcrt_real -# Otherwise, just link to libmsvcrt_real -target_link_libraries(libmsvcrt INTERFACE "$,win32gui;win32cui;win32dll;win32ocx;cpl>,msvcrtex,libmsvcrt_real>") +# Embed msvcrtex into libmsvcrt +target_sources(libmsvcrt PRIVATE $) + add_definitions( -DUSE_MSVCRT_PREFIX @@ -35,7 +33,10 @@ target_link_libraries(msvcrt crt wine ${PSEH_LIB}) if(MSVC) # export of deleting destructor "name" target_link_options(msvcrt PRIVATE "/ignore:4102") -set_property(TARGET libmsvcrt_real APPEND PROPERTY STATIC_LIBRARY_OPTIONS "/ignore:4102") +set_property(TARGET libmsvcrt APPEND PROPERTY STATIC_LIBRARY_OPTIONS "/ignore:4102") +if(ARCH STREQUAL "i386") +target_sources(libmsvcrt PRIVATE $) +endif() endif() add_importlibs(msvcrt kernel32 ntdll) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 938bc0e2454..bec502d75c7 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -322,20 +322,52 @@ function(generate_import_lib _libname _dllname _spec_file) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def COMMAND native-spec2def -n=${_dllname} -a=${ARCH2} ${ARGN} --implib -d=${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def) - set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def PROPERTIES EXTERNAL_OBJECT TRUE) -# Create normal importlib -_add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def) -set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "IMPLIB" PREFIX "") - -# Create delayed importlib -_add_library(${_libname}_delayed STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def) -set_target_properties(${_libname}_delayed PROPERTIES LINKER_LANGUAGE "IMPLIB_DELAYED" PREFIX "") +# With this, we let DLLTOOL create an import library +set(LIBRARY_PRIVATE_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname}.dir) +add_custom_command( +OUTPUT ${LIBRARY_PRIVATE_DIR}/${_libname}.a +# ar just puts stuff into the archive, without looking twice. Just delete the lib, we're going to rebuild it anyway +COMMAND ${CMAKE_COMMAND} -E rm -f $ +COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def --kill-at --output-lib=${_libname}.a -t ${_libname} +DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def +WORKING_DIRECTORY ${LIBRARY_PRIVATE_DIR}) + +# We create a static library with the importlib thus created as object. AR will extract the obj files and archive it again as a thin lib +set_source_files_properties( +${LIBRARY_PRIVATE_DIR}/${_libname}.a +PROPERTIES +EXTERNAL_OBJECT TRUE) +_add_library(${_libname} STATIC EXCLUDE_FROM_ALL +${LIBRARY_PRIVATE_DIR}/${_libname}.a) +set_target_properties(${_libname} +PROPERTIES +LINKER_LANGUAGE "C" +PREFIX "") + +# Do the same with delay-import libs +set(LIBRARY_PRIVATE_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname}_delayed.dir) +add_
[ros-diffs] [reactos] 04/06: [CMAKE] Use -fcommon when using CLang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56e56f8eccc4e6d4678ab2723ece2981001715ca commit 56e56f8eccc4e6d4678ab2723ece2981001715ca Author: Jérôme Gardou AuthorDate: Tue Dec 22 12:32:45 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [CMAKE] Use -fcommon when using CLang --- sdk/cmake/msvc.cmake | 5 + 1 file changed, 5 insertions(+) diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake index a3048c34e1d..10beb82f704 100644 --- a/sdk/cmake/msvc.cmake +++ b/sdk/cmake/msvc.cmake @@ -55,6 +55,11 @@ if(ARCH STREQUAL "i386") endif() endif() +# CLang default to -fno-common from version 11 onward. We are not rady for this now +if (USE_CLANG_CL) +add_compile_options(-fcommon) +endif() + # VS 12+ requires /FS when used in parallel compilations if(NOT MSVC_IDE) add_compile_options(/FS)
[ros-diffs] [reactos] 05/06: [GITHUB] Get LLVM latest version from chocolatey repository
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cad583967ba462080a3f2ea16fbed8a9ecfd3b82 commit cad583967ba462080a3f2ea16fbed8a9ecfd3b82 Author: Jérôme Gardou AuthorDate: Tue Nov 24 18:30:40 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [GITHUB] Get LLVM latest version from chocolatey repository Also, explicitly set target in toolchain file to help CMake getting things right. --- .github/workflows/build.yml | 6 -- toolchain-msvc.cmake| 28 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b61db65ac0..fc5600f9200 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,7 +102,9 @@ jobs: runs-on: windows-latest steps: - name: Install packages - run: choco install ninja -y + run: | +choco install ninja -y +choco install --x86 -y llvm - name: Install Flex and Bison run: | curl -O https://svn.reactos.org/storage/vperevertkin/flexbison.7z @@ -121,7 +123,7 @@ jobs: run: | mkdir build cd build -$env:PATH = "$env:VCToolsInstallDir\..\..\Llvm\bin;$env:PATH" +$env:PATH = "${env:PROGRAMFILES(X86)}\llvm\bin;$env:PATH" cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=i386 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 -DUSE_CLANG_CL:BOOL=1 ${{github.workspace}}\src - name: Build working-directory: ${{github.workspace}}\build diff --git a/toolchain-msvc.cmake b/toolchain-msvc.cmake index f1ff2d77570..e30e075cba0 100644 --- a/toolchain-msvc.cmake +++ b/toolchain-msvc.cmake @@ -13,11 +13,38 @@ endif() set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR i686) +# set the generator platform +if (NOT DEFINED CMAKE_GENERATOR_PLATFORM) +if(ARCH STREQUAL "amd64") +set(CMAKE_GENERATOR_PLATFORM "x64") +elseif(ARCH STREQUAL "arm") +set(CMAKE_GENERATOR_PLATFORM "ARM") +elseif(ARCH STREQUAL "arm64") +set(CMAKE_GENERATOR_PLATFORM "ARM64") +else() +set(CMAKE_GENERATOR_PLATFORM "Win32") +endif() +endif() + if(USE_CLANG_CL) set(CMAKE_C_COMPILER clang-cl) set(CMAKE_CXX_COMPILER clang-cl) # Clang now defaults to lld-link which we're not compatible with yet set(CMAKE_LINKER link) +# Explicitly set target so CMake doesn't get confused +if (ARCH STREQUAL "amd64") +set(CMAKE_C_COMPILER_TARGET "x86_64-pc-windows-msvc") +set(CMAKE_CXX_COMPILER_TARGET "x86_64-pc-windows-msvc") +elseif(ARCH STREQUAL "arm") +set(CMAKE_C_COMPILER_TARGET "arm-pc-windows-msvc") +set(CMAKE_CXX_COMPILER_TARGET "arm-pc-windows-msvc") +elseif(ARCH STREQUAL "arm64") +set(CMAKE_C_COMPILER_TARGET "arm64-pc-windows-msvc") +set(CMAKE_CXX_COMPILER_TARGET "arm64-pc-windows-msvc") +else() +set(CMAKE_C_COMPILER_TARGET "i686-pc-windows-msvc") +set(CMAKE_CXX_COMPILER_TARGET "i686-pc-windows-msvc") +endif() else() set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl) @@ -35,6 +62,7 @@ else() set(CMAKE_ASM_COMPILER ml) endif() + set(CMAKE_C_STANDARD_LIBRARIES "" CACHE INTERNAL "") set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/overrides-msvc.cmake")
[ros-diffs] [reactos] 01/06: [FTP] Always link agains oldnames
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fcd9f318413550eaff4ce4f5c81de6ce959e11b commit 6fcd9f318413550eaff4ce4f5c81de6ce959e11b Author: Jérôme Gardou AuthorDate: Mon Nov 2 10:47:44 2020 +0100 Commit: Jérôme Gardou CommitDate: Mon Dec 28 12:13:30 2020 +0100 [FTP] Always link agains oldnames --- base/applications/network/ftp/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/applications/network/ftp/CMakeLists.txt b/base/applications/network/ftp/CMakeLists.txt index 2c52f4d4974..7609b313c35 100644 --- a/base/applications/network/ftp/CMakeLists.txt +++ b/base/applications/network/ftp/CMakeLists.txt @@ -1,6 +1,4 @@ -add_definitions(-Dlint) - list(APPEND SOURCE cmds.c cmdtab.c @@ -12,12 +10,14 @@ list(APPEND SOURCE precomp.h) add_executable(ftp ${SOURCE} ftp.rc) +target_compile_definitions(ftp PRIVATE lint) + set_module_type(ftp win32cui) add_importlibs(ftp ws2_32 iphlpapi msvcrt kernel32) +target_link_libraries(ftp oldnames) add_pch(ftp precomp.h SOURCE) if(MSVC) -target_link_libraries(ftp oldnames) add_importlibs(ftp ntdll) endif()
[ros-diffs] [reactos] 02/03: [CRT] Do not call atexit at process initialization
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6c6d9bee68bc0068cede58b41a575fd923b04e01 commit 6c6d9bee68bc0068cede58b41a575fd923b04e01 Author: Jérôme Gardou AuthorDate: Mon Dec 28 10:47:38 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Dec 30 19:03:52 2020 +0100 [CRT] Do not call atexit at process initialization There is no guarantee that the underlying APIs are initialized at this point CORE-17362 --- sdk/lib/crt/startup/crtexe.c | 12 +--- sdk/lib/crt/startup/gccmain.c | 2 -- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sdk/lib/crt/startup/crtexe.c b/sdk/lib/crt/startup/crtexe.c index efc29191191..a09d4b5b441 100644 --- a/sdk/lib/crt/startup/crtexe.c +++ b/sdk/lib/crt/startup/crtexe.c @@ -115,6 +115,10 @@ _CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init; extern int _MINGW_INSTALL_DEBUG_MATHERR; +#ifdef __GNUC__ +extern void __do_global_dtors(void); +#endif + static int __cdecl pre_c_init (void) { @@ -211,8 +215,6 @@ int __cdecl mainCRTStartup (void) return ret; } -void __call_atexit(); - static __declspec(noinline) int __cdecl @@ -326,7 +328,11 @@ __tmainCRTStartup (void) #endif mainret = main (argc, argv, envp); #endif -__call_atexit(); + +#ifdef __GNUC__ +__do_global_dtors(); +#endif + if (!managedapp) exit (mainret); diff --git a/sdk/lib/crt/startup/gccmain.c b/sdk/lib/crt/startup/gccmain.c index a1cd04b026e..3370a126947 100644 --- a/sdk/lib/crt/startup/gccmain.c +++ b/sdk/lib/crt/startup/gccmain.c @@ -43,8 +43,6 @@ __do_global_ctors (void) { __CTOR_LIST__[i] (); } - - atexit (__do_global_dtors); } static int initialized = 0;
[ros-diffs] [reactos] 03/03: [CRT] Fix _onexit
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8a6d65304483b2cea0fef4d7d35fa0b5b2a7db59 commit 8a6d65304483b2cea0fef4d7d35fa0b5b2a7db59 Author: Jérôme Gardou AuthorDate: Mon Dec 28 12:06:34 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Dec 30 19:03:52 2020 +0100 [CRT] Fix _onexit Avoid calling malloc in CR initialisation code. Have executables call msvcrt implementation, while the DLLs keep their own function tables CORE-17362 --- dll/win32/msvcrt/msvcrt.spec | 4 +-- sdk/lib/crt/startup/atonexit.c | 77 -- sdk/lib/crt/startup/crtdll.c | 15 +++- sdk/lib/crt/startup/crtexe.c | 2 +- 4 files changed, 53 insertions(+), 45 deletions(-) diff --git a/dll/win32/msvcrt/msvcrt.spec b/dll/win32/msvcrt/msvcrt.spec index 00bf4e65f3d..848e2602e45 100644 --- a/dll/win32/msvcrt/msvcrt.spec +++ b/dll/win32/msvcrt/msvcrt.spec @@ -883,7 +883,7 @@ @ stub -version=0x600+ -arch=i386 _msize_debug @ cdecl _nextafter(double double) @ stub -arch=x86_64 _nextafterf -@ cdecl _onexit(ptr) +@ extern _onexit # Declaring it as extern let us use the symbol from msvcrtex while having the __imp_ symbol defined in the import lib @ varargs _open(str long) @ cdecl _open_osfhandle(long long) @ extern _osplatform @@ -1293,7 +1293,7 @@ @ cdecl atan2(double double) @ cdecl -arch=x86_64,arm atan2f(long) @ cdecl -arch=x86_64,arm atanf(long) -@ extern atexit # <-- keep this as an extern, thank you +@ extern atexit # Declaring it as extern let us use the symbol from msvcrtex while having the __imp_ symbol defined in the import lib for those who really need it @ cdecl atof(str) @ cdecl atoi(str) @ cdecl atol(str) diff --git a/sdk/lib/crt/startup/atonexit.c b/sdk/lib/crt/startup/atonexit.c index 1774e90f1b3..ff6021aacfe 100644 --- a/sdk/lib/crt/startup/atonexit.c +++ b/sdk/lib/crt/startup/atonexit.c @@ -4,7 +4,6 @@ * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#undef CRTDLL #ifndef _DLL #define _DLL #endif @@ -20,7 +19,7 @@ void __cdecl _lock (int _File); void __cdecl _unlock (int _File); - + _PVFV *__onexitbegin; _PVFV *__onexitend; @@ -33,16 +32,19 @@ void __call_atexit(void) /* Note: should only be called with the exit lock held */ _PVFV *first, *last; -first = (_PVFV *)_decode_pointer(__onexitbegin); -last = (_PVFV *)_decode_pointer(__onexitend);; +if (!__onexitbegin) +return; -if (!first) return; +first = (_PVFV *)_decode_pointer(__onexitbegin); +last = (_PVFV *)_decode_pointer(__onexitend); while (--last >= first) if (*last) (**last)(); free(first); + +__onexitbegin = __onexitend = NULL; } /* Choose a different name to prevent name conflicts. The CRT one works fine. */ @@ -50,34 +52,45 @@ _onexit_t __cdecl _onexit(_onexit_t func); _onexit_t __cdecl _onexit(_onexit_t func) { - _PVFV *onexitbegin; - _PVFV *onexitend; - _onexit_t retval; - - onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin); - - if (onexitbegin == (_PVFV *) -1) -#ifdef __REACTOS__ - { - onexitbegin = (_PVFV *)calloc(32, sizeof(_onexit_t)); - if (onexitbegin == NULL) -return NULL; - __onexitbegin = _encode_pointer(onexitbegin); - __onexitend = _encode_pointer(onexitbegin + 32); - } -#else -return (* __MINGW_IMP_SYMBOL(_onexit)) (func); +_PVFV *onexitbegin; +_PVFV *onexitend; +_onexit_t retval; + +#ifndef CRTDLL +if (__onexitbegin == (_PVFV *) -1) +return (* __MINGW_IMP_SYMBOL(_onexit)) (func); #endif - _lock (_EXIT_LOCK1); - onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin); - onexitend = (_PVFV *) _decode_pointer (__onexitend); - - retval = __dllonexit (func, , ); - - __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin); - __onexitend = (_PVFV *) _encode_pointer (onexitend); - _unlock (_EXIT_LOCK1); - return retval; + +_lock (_EXIT_LOCK1); + +if (!__onexitbegin) +{ +/* First time we are called. Initialize our array */ +onexitbegin = calloc(1, sizeof(*onexitbegin)); +if (!onexitbegin) +{ +_unlock(_EXIT_LOCK1); +return NULL; +} +onexitend = onexitbegin; +} +else +{ +onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin); +onexitend = (_PVFV *) _decode_pointer (__onexitend); +} + +retval = __dllonexit (func, , ); + +if (retval != NULL) +{ +/* Update our globals in case of success */ +__onexitbegin = (_PVFV *) _encode_pointer (onexitbegin); +__onexitend = (_PVFV *) _encode_pointer (onexitend); +} + +_unlock (_EXIT_LOCK1); +return retval; } int __cdecl diff --git a/sdk/lib/crt/startup/crtdll.c b/sdk/lib/crt/startup/crtdll.c index afe23284f50..b9f5838b9fb 100644 --- a/sdk/lib/crt/startup/crtdll.c +++ b/sdk/lib/crt/startup/crtdll.c @@ -62,14 +62,8 @@ stat
[ros-diffs] [reactos] 01/03: [CRT] Format source a bit.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=26863538a4b5ee9a340b49070f67879328619401 commit 26863538a4b5ee9a340b49070f67879328619401 Author: Jérôme Gardou AuthorDate: Mon Dec 28 09:53:04 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Dec 30 19:03:52 2020 +0100 [CRT] Format source a bit. This is horrendous. --- sdk/lib/crt/startup/crtdll.c | 216 +-- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/sdk/lib/crt/startup/crtdll.c b/sdk/lib/crt/startup/crtdll.c index e52f240f2c5..afe23284f50 100644 --- a/sdk/lib/crt/startup/crtdll.c +++ b/sdk/lib/crt/startup/crtdll.c @@ -62,95 +62,95 @@ static int __cdecl pre_c_init (void) { - _PVFV *onexitbegin; +_PVFV *onexitbegin; - onexitbegin = (_PVFV *) malloc (32 * sizeof (_PVFV)); - __onexitend = __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin); +onexitbegin = (_PVFV *) malloc (32 * sizeof (_PVFV)); +__onexitend = __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin); - if (onexitbegin == NULL) -return 1; - *onexitbegin = (_PVFV) NULL; - return 0; +if (onexitbegin == NULL) +return 1; +*onexitbegin = (_PVFV) NULL; +return 0; } WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { - if (dwReason == DLL_PROCESS_DETACH) +if (dwReason == DLL_PROCESS_DETACH) { - if (__proc_attached > 0) - __proc_attached--; - else - return FALSE; +if (__proc_attached > 0) +__proc_attached--; +else +return FALSE; } - if (dwReason == DLL_PROCESS_ATTACH) +if (dwReason == DLL_PROCESS_ATTACH) { - void *lock_free = NULL; - void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; - int nested = FALSE; - - while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock, -fiberid, 0)) != 0) - { - if (lock_free == fiberid) - { - nested = TRUE; - break; - } - Sleep(1000); - } - if (__native_startup_state == __initializing) - { - _amsg_exit (31); - } - else if (__native_startup_state == __uninitialized) - { - __native_startup_state = __initializing; - - _initterm ((_PVFV *) (void *) __xi_a, (_PVFV *) (void *) __xi_z); - } - if (__native_startup_state == __initializing) - { - _initterm (__xc_a, __xc_z); - __native_startup_state = __initialized; - } - if (! nested) - { - (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); - } - if (__dyn_tls_init_callback != NULL) - { - __dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved); - } - __proc_attached++; +void *lock_free = NULL; +void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; +int nested = FALSE; + +while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock, +fiberid, 0)) != 0) +{ +if (lock_free == fiberid) +{ +nested = TRUE; +break; +} +Sleep(1000); +} +if (__native_startup_state == __initializing) +{ +_amsg_exit (31); +} +else if (__native_startup_state == __uninitialized) +{ +__native_startup_state = __initializing; + +_initterm ((_PVFV *) (void *) __xi_a, (_PVFV *) (void *) __xi_z); +} +if (__native_startup_state == __initializing) +{ +_initterm (__xc_a, __xc_z); +__native_startup_state = __initialized; +} +if (! nested) +{ +(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); +} +if (__dyn_tls_init_callback != NULL) +{ +__dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved); +} +__proc_attached++; } - else if (dwReason == DLL_PROCESS_DETACH) +else if (dwReason == DLL_PROCESS_DETACH) { - void *lock_free = NULL; - while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,(PVOID) 1, 0)) != 0) - { - Sleep(1000); - } - if (__native_startup_state != __initialized) - { - _amsg_exit (31); - } - else - { - _PVFV * onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin); - if (onexitbegin) - { - _PVFV *onexitend = (_PVFV *) _decode_pointer (__onexitend); - while (--onexitend >= onexitbegin) - if (*onexitend != NULL) - (**onexitend)
[ros-diffs] [reactos] 27/39: [WINESYNC] Properly handle the case when the file doesn't exist on ReactOS side
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=81c312d3e041671c89d85f92cfeb8e8f15e0e4f6 commit 81c312d3e041671c89d85f92cfeb8e8f15e0e4f6 Author: Jérôme Gardou AuthorDate: Tue Dec 8 18:10:27 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 11:03:13 2021 +0100 [WINESYNC] Properly handle the case when the file doesn't exist on ReactOS side --- sdk/tools/winesync/winesync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py index a890e2a773f..69f31601490 100644 --- a/sdk/tools/winesync/winesync.py +++ b/sdk/tools/winesync/winesync.py @@ -187,7 +187,8 @@ class wine_sync: if delta.status == pygit2.GIT_DELTA_DELETED: self.reactos_index.remove(old_reactos_path) -else: +# here we check if the file exists. We don't complain, because applying the patch already failed anyway +elif os.path.isfile(os.path.join(self.reactos_src, new_reactos_path)): self.reactos_index.add(new_reactos_path) complete_patch += blob_patch.text
[ros-diffs] [reactos] 39/39: [MEDIA] Update Winesync doc
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a853102a7bae039b8c313fb37afdc0ccfa2509a2 commit a853102a7bae039b8c313fb37afdc0ccfa2509a2 Author: Jérôme Gardou AuthorDate: Tue Dec 8 21:07:07 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 11:03:13 2021 +0100 [MEDIA] Update Winesync doc --- media/doc/WINESYNC.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/doc/WINESYNC.txt b/media/doc/WINESYNC.txt index 3273024a322..e84eeeac794 100644 --- a/media/doc/WINESYNC.txt +++ b/media/doc/WINESYNC.txt @@ -204,7 +204,7 @@ dll/win32/windowscodecsext# Synced to WineStaging-2.9 dll/win32/winemp3.acm # Synced to WineStaging-4.18 dll/win32/wing32 # Synced to WineStaging-3.3 dll/win32/winhttp # Synced to WineStaging-4.18 -dll/win32/wininet # Synced to WineStaging-4.18 +dll/win32/wininet # Synced to WineStaging-6.0rc1 dll/win32/winmm # Forked at Wine-20050628 dll/win32/winmm/midimap # Forked at Wine-20050628 dll/win32/winmm/wavemap # Forked at Wine-20050628
[ros-diffs] [reactos] 38/39: [WINESYNC]: wininet is now in sync with wine-staging wine-6.0-rc1
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c590d6ddadd1949c10b758d9afe2063d1a9836c8 commit c590d6ddadd1949c10b758d9afe2063d1a9836c8 Author: Jérôme Gardou AuthorDate: Tue Dec 8 18:34:46 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 11:03:13 2021 +0100 [WINESYNC]: wininet is now in sync with wine-staging wine-6.0-rc1 --- sdk/tools/winesync/wininet.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tools/winesync/wininet.cfg b/sdk/tools/winesync/wininet.cfg index 4c9385fe431..b6f5a87e7f7 100644 --- a/sdk/tools/winesync/wininet.cfg +++ b/sdk/tools/winesync/wininet.cfg @@ -5,4 +5,4 @@ files: include/wininet.h: sdk/include/psdk/wininet.h include/winineti.h: sdk/include/psdk/winineti.h tags: - wine: e88abf0dc4ae7ec6b2fd21130be09dadc478b9fc + wine: wine-6.0-rc1
[ros-diffs] [reactos] 02/39: [WINESYNC]: revert wine-staging patchset for wininet
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a3f32ff30864286a9c7480b617454bc77a56d3d commit 4a3f32ff30864286a9c7480b617454bc77a56d3d Author: Jérôme Gardou AuthorDate: Tue Dec 8 17:45:41 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 11:03:13 2021 +0100 [WINESYNC]: revert wine-staging patchset for wininet --- dll/win32/wininet/http.c | 196 +++--- modules/rostests/winetests/wininet/http.c | 282 + ...-wininet-tests-Add-more-tests-for-cookies.patch | 145 --- ...ts-Test-auth-credential-reusage-with-host.patch | 130 -- ...ts-Check-cookie-behaviour-when-overriding.patch | 132 -- ...trip-filename-if-no-path-is-set-in-cookie.patch | 82 -- ...lacing-header-fields-should-fail-if-they-.patch | 241 -- 7 files changed, 97 insertions(+), deletions(-) diff --git a/dll/win32/wininet/http.c b/dll/win32/wininet/http.c index 45036f2fe56..a4c793aaeac 100644 --- a/dll/win32/wininet/http.c +++ b/dll/win32/wininet/http.c @@ -766,18 +766,10 @@ static void HTTP_ProcessCookies( http_request_t *request ) int HeaderIndex; int numCookies = 0; LPHTTPHEADERW setCookieHeader; -WCHAR *path, *tmp; if(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES) return; -path = heap_strdupW(request->path); -if (!path) -return; - -tmp = strrchrW(path, '/'); -if (tmp && tmp[1]) tmp[1] = 0; - EnterCriticalSection( >headers_section ); while((HeaderIndex = HTTP_GetCustomHeaderIndex(request, szSet_Cookie, numCookies++, FALSE)) != -1) @@ -796,11 +788,10 @@ static void HTTP_ProcessCookies( http_request_t *request ) name = substr(setCookieHeader->lpszValue, data - setCookieHeader->lpszValue); data++; -set_cookie(substrz(request->server->name), substrz(path), name, substrz(data), INTERNET_COOKIE_HTTPONLY); +set_cookie(substrz(request->server->name), substrz(request->path), name, substrz(data), INTERNET_COOKIE_HTTPONLY); } LeaveCriticalSection( >headers_section ); -heap_free(path); } static void strip_spaces(LPWSTR start) @@ -6152,128 +6143,127 @@ static LPWSTR * HTTP_InterpretHttpHeader(LPCWSTR buffer) static DWORD HTTP_ProcessHeader(http_request_t *request, LPCWSTR field, LPCWSTR value, DWORD dwModifier) { -LPHTTPHEADERW lphttpHdr; +LPHTTPHEADERW lphttpHdr = NULL; INT index; BOOL request_only = !!(dwModifier & HTTP_ADDHDR_FLAG_REQ); -DWORD res = ERROR_SUCCESS; +DWORD res = ERROR_HTTP_INVALID_HEADER; TRACE("--> %s: %s - 0x%08x\n", debugstr_w(field), debugstr_w(value), dwModifier); EnterCriticalSection( >headers_section ); -index = HTTP_GetCustomHeaderIndex(request, field, 0, request_only); +/* REPLACE wins out over ADD */ +if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE) +dwModifier &= ~HTTP_ADDHDR_FLAG_ADD; + +if (dwModifier & HTTP_ADDHDR_FLAG_ADD) +index = -1; +else +index = HTTP_GetCustomHeaderIndex(request, field, 0, request_only); + if (index >= 0) { -lphttpHdr = >custHeaders[index]; - -/* replace existing header if FLAG_REPLACE is given */ -if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE) +if (dwModifier & HTTP_ADDHDR_FLAG_ADD_IF_NEW) { -HTTP_DeleteCustomHeader( request, index ); +LeaveCriticalSection( >headers_section ); +return ERROR_HTTP_INVALID_HEADER; +} +lphttpHdr = >custHeaders[index]; +} +else if (value) +{ +HTTPHEADERW hdr; -if (value && value[0]) -{ -HTTPHEADERW hdr; +hdr.lpszField = (LPWSTR)field; +hdr.lpszValue = (LPWSTR)value; +hdr.wFlags = hdr.wCount = 0; -hdr.lpszField = (LPWSTR)field; -hdr.lpszValue = (LPWSTR)value; -hdr.wFlags = hdr.wCount = 0; +if (dwModifier & HTTP_ADDHDR_FLAG_REQ) +hdr.wFlags |= HDR_ISREQUEST; -if (dwModifier & HTTP_ADDHDR_FLAG_REQ) -hdr.wFlags |= HDR_ISREQUEST; +res = HTTP_InsertCustomHeader(request, ); +LeaveCriticalSection( >headers_section ); +return res; +} +/* no value to delete */ +else +{ +LeaveCriticalSection( >headers_section ); +return ERROR_SUCCESS; +} -res = HTTP_InsertCustomHeader( request, ); -} +if (dwModifier & HTTP_ADDHDR_FLAG_REQ) + lphttpHdr->wFlags |= HDR_ISREQUEST; +else +lphttpHdr->wFlags &= ~HDR_ISREQUEST; -goto out; -} +if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE) +{ +HTTP_DeleteCustomHeader( request, index ); -/* do not add new header if FLA
[ros-diffs] [reactos] 01/39: [WINESYNC] Add wininet entry
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f997acf8e3564727a72cda37901469dce7b75f9c commit f997acf8e3564727a72cda37901469dce7b75f9c Author: Jérôme Gardou AuthorDate: Tue Dec 8 17:28:07 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 11:03:13 2021 +0100 [WINESYNC] Add wininet entry --- sdk/tools/winesync/wininet.cfg | 8 + ...-wininet-tests-Add-more-tests-for-cookies.patch | 145 + ...ts-Test-auth-credential-reusage-with-host.patch | 130 +++ ...ts-Check-cookie-behaviour-when-overriding.patch | 132 +++ ...trip-filename-if-no-path-is-set-in-cookie.patch | 82 +++ ...lacing-header-fields-should-fail-if-they-.patch | 241 + 6 files changed, 738 insertions(+) diff --git a/sdk/tools/winesync/wininet.cfg b/sdk/tools/winesync/wininet.cfg new file mode 100644 index 000..41556140139 --- /dev/null +++ b/sdk/tools/winesync/wininet.cfg @@ -0,0 +1,8 @@ +directories: + dlls/wininet: dll/win32/wininet + dlls/wininet/tests: modules/rostests/winetests/wininet +files: + include/wininet.h: sdk/include/psdk/wininet.h + include/winineti.h: sdk/include/psdk/winineti.h +tags: + wine: wine-4.18 diff --git a/sdk/tools/winesync/wininet_staging/0001-wininet-tests-Add-more-tests-for-cookies.patch b/sdk/tools/winesync/wininet_staging/0001-wininet-tests-Add-more-tests-for-cookies.patch new file mode 100644 index 000..110d815705a --- /dev/null +++ b/sdk/tools/winesync/wininet_staging/0001-wininet-tests-Add-more-tests-for-cookies.patch @@ -0,0 +1,145 @@ +From 915a805cabaec3cc265f4f8ad9f0005502f8fd24 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Fri, 15 May 2015 20:37:19 +0200 +Subject: [PATCH] wininet/tests: Add more tests for cookies. + +--- + modules/rostests/winetests/wininet/http.c | 92 +-- + 1 file changed, 89 insertions(+), 3 deletions(-) + +diff --git a/modules/rostests/winetests/wininet/http.c b/modules/rostests/winetests/wininet/http.c +index 90a38dc3a..55d51b299 100644 +--- a/modules/rostests/winetests/wininet/http.c b/modules/rostests/winetests/wininet/http.c +@@ -2068,6 +2068,14 @@ static const char largemsg[] = + "Content-Length: %I64u\r\n" + "\r\n"; + ++static const char okmsg_cookie_path[] = ++"HTTP/1.1 200 OK\r\n" ++"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n" ++"Server: winetest\r\n" ++"Content-Length: 0\r\n" ++"Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n" ++"\r\n"; ++ + static const char notokmsg[] = + "HTTP/1.1 400 Bad Request\r\n" + "Server: winetest\r\n" +@@ -2438,6 +2446,32 @@ static DWORD CALLBACK server_thread(LPVOID param) + else + send(c, noauthmsg, sizeof noauthmsg-1, 0); + } ++if (strstr(buffer, "/test_cookie_path1")) ++{ ++if (strstr(buffer, "subcookie=data")) ++ send(c, okmsg, sizeof okmsg-1, 0); ++ else ++ send(c, notokmsg, sizeof notokmsg-1, 0); ++} ++if (strstr(buffer, "/test_cookie_path2")) ++{ ++if (strstr(buffer, "subcookie2=data")) ++ send(c, okmsg, sizeof okmsg-1, 0); ++ else ++ send(c, notokmsg, sizeof notokmsg-1, 0); ++} ++if (strstr(buffer, "/test_cookie_set_path")) ++{ ++send(c, okmsg_cookie_path, sizeof okmsg_cookie_path-1, 0); ++} ++if (strstr(buffer, "/test_cookie_merge")) ++{ ++if (strstr(buffer, "subcookie=data") && ++!strstr(buffer, "manual_cookie=test")) ++ send(c, okmsg, sizeof okmsg-1, 0); ++ else ++ send(c, notokmsg, sizeof notokmsg-1, 0); ++} + if (strstr(buffer, "/test_host_override")) + { + if (strstr(buffer, host_header_override)) +@@ -3816,7 +3850,7 @@ static void test_cookie_header(int port) + HINTERNET ses, con, req; + DWORD size, error; + BOOL ret; +-char buffer[64]; ++char buffer[256]; + + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(ses != NULL, "InternetOpen failed\n"); +@@ -3844,7 +3878,7 @@ static void test_cookie_header(int port) + size = sizeof(buffer); + ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, , NULL); + ok(ret, "HttpQueryInfo failed: %u\n", GetLastError()); +-ok(!strcmp(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer); ++ok(!!strstr(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer); + + ret = HttpSendRequestA(req, NULL, 0, NULL, 0); +
[ros-diffs] [reactos] 01/01: [PSDK] Add more safe integer routines for LONGLONGs
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f3d3d7d48774fc9b997d57e2f4694ff6655d3ad commit 5f3d3d7d48774fc9b997d57e2f4694ff6655d3ad Author: Jérôme Gardou AuthorDate: Tue Dec 29 16:40:03 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 13:40:35 2021 +0100 [PSDK] Add more safe integer routines for LONGLONGs --- sdk/include/psdk/intsafe.h | 8 1 file changed, 8 insertions(+) diff --git a/sdk/include/psdk/intsafe.h b/sdk/include/psdk/intsafe.h index 10fb173beb5..2dc0954b152 100644 --- a/sdk/include/psdk/intsafe.h +++ b/sdk/include/psdk/intsafe.h @@ -382,6 +382,8 @@ DEFINE_SAFE_CONVERT_STOU(LongPtrToULong, LONG_PTR, ULONG) DEFINE_SAFE_CONVERT_STOU(LongPtrToUIntPtr, LONG_PTR, UINT_PTR) DEFINE_SAFE_CONVERT_STOU(LongPtrToULongPtr, LONG_PTR, ULONG_PTR) DEFINE_SAFE_CONVERT_STOU(LongPtrToULongLong, LONG_PTR, ULONGLONG) +DEFINE_SAFE_CONVERT_STOU(LongLongToULong, LONGLONG, ULONG) +DEFINE_SAFE_CONVERT_STOU(LongLongToULongPtr, LONGLONG, ULONG_PTR) #ifdef _CHAR_UNSIGNED DEFINE_SAFE_CONVERT_STOU(ShortToChar, SHORT, UINT8) DEFINE_SAFE_CONVERT_STOU(LongPtrToChar, LONG_PTR, UINT8) @@ -460,6 +462,9 @@ DEFINE_SAFE_CONVERT_STOS(LongPtrToChar, LONG_PTR, _INTSAFE_CHAR) #define RtlSIZETToULong RtlULongPtrToULong #define RtlSSIZETToULongLong RtlLongPtrToULongLong #define RtlSSIZETToULong RtlLongPtrToULong +#define RtlLongLongToSizeT RtlLongLongToUIntPtr +#define RtlLongLongToSSIZET RtlLongLongToLongPtr +#define RtlLongLongToSIZET RtlLongLongToULongPtr #ifdef _WIN64 #define RtlIntToUIntPtr RtlIntToULongLong #define RtlULongLongToIntPtr RtlULongLongToLongLong @@ -497,6 +502,9 @@ DEFINE_SAFE_CONVERT_STOS(LongPtrToChar, LONG_PTR, _INTSAFE_CHAR) #define SIZETToULong ULongPtrToULong #define SSIZETToULongLong LongPtrToULongLong #define SSIZETToULong LongPtrToULong +#define LongLongToSizeT LongLongToUIntPtr +#define LongLongToSSIZET LongLongToLongPtr +#define LongLongToSIZET LongLongToULongPtr #ifdef _WIN64 #define IntToUIntPtr IntToULongLong #define ULongLongToIntPtr ULongLongToLongLong
[ros-diffs] [reactos] 01/01: [CMAKE] Fix GCC -fstack-protector usage
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c8d07514c8e0bc235e180f6990f914ee86880f8c commit c8d07514c8e0bc235e180f6990f914ee86880f8c Author: Jérôme Gardou AuthorDate: Thu Dec 31 17:56:39 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Jan 5 13:38:57 2021 +0100 [CMAKE] Fix GCC -fstack-protector usage --- boot/environ/CMakeLists.txt| 4 +- boot/freeldr/freeldr/CMakeLists.txt| 4 +- dll/keyboard/CMakeLists.txt| 2 +- dll/ntdll/CMakeLists.txt | 10 dll/win32/msvcrt/CMakeLists.txt| 5 ++ drivers/storage/port/scsiport/CMakeLists.txt | 5 ++ .../apitests/win32u/win32u_ros/CMakeLists.txt | 6 +- ntoskrnl/CMakeLists.txt| 10 +++- ntoskrnl/ntkrnlmp/CMakeLists.txt | 2 +- sdk/cmake/gcc.cmake| 6 +- sdk/lib/crt/msvcrtex.cmake | 4 -- sdk/lib/gcc_ssp/CMakeLists.txt | 14 - sdk/lib/gcc_ssp/gcc_ssp.c | 66 ++ win32ss/CMakeLists.txt | 5 ++ win32ss/drivers/videoprt/CMakeLists.txt| 5 ++ 15 files changed, 117 insertions(+), 31 deletions(-) diff --git a/boot/environ/CMakeLists.txt b/boot/environ/CMakeLists.txt index 4f62a8b111b..05aa5b81ef9 100644 --- a/boot/environ/CMakeLists.txt +++ b/boot/environ/CMakeLists.txt @@ -105,7 +105,7 @@ target_link_libraries(bootmgfw bootlib cportlib cmlib rtl libcntpr) # dynamic analysis switches if(STACK_PROTECTOR) -target_link_libraries(bootmgfw gcc_ssp) +target_sources(bootmgfw PRIVATE $) endif() if(RUNTIME_CHECKS) @@ -153,7 +153,7 @@ target_link_libraries(rosload bootlib cportlib cmlib rtl libcntpr) # dynamic analysis switches if(STACK_PROTECTOR) -target_link_libraries(rosload gcc_ssp) +target_sources(rosload PRIVATE $) endif() if(RUNTIME_CHECKS) diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt index 87116af5978..95dc2e31224 100644 --- a/boot/freeldr/freeldr/CMakeLists.txt +++ b/boot/freeldr/freeldr/CMakeLists.txt @@ -312,8 +312,8 @@ target_link_libraries(freeldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr) # dynamic analysis switches if(STACK_PROTECTOR) -target_link_libraries(freeldr_pe gcc_ssp) -target_link_libraries(freeldr_pe_dbg gcc_ssp) +target_sources(freeldr_pe PRIVATE $) +target_sources(freeldr_pe_dbg PRIVATE $) endif() if(RUNTIME_CHECKS) diff --git a/dll/keyboard/CMakeLists.txt b/dll/keyboard/CMakeLists.txt index f728060633c..76cb12e1ea7 100644 --- a/dll/keyboard/CMakeLists.txt +++ b/dll/keyboard/CMakeLists.txt @@ -109,7 +109,7 @@ foreach(_keyboard_layout ${_keyboard_layouts}) # dynamic analysis switches if(STACK_PROTECTOR) -target_link_libraries(${_keyboard_layout} gcc_ssp) +target_compile_options(${_keyboard_layout} PRIVATE -fno-stack-protector) endif() if(RUNTIME_CHECKS) diff --git a/dll/ntdll/CMakeLists.txt b/dll/ntdll/CMakeLists.txt index 09e077cb4e6..ce1a8fcc67b 100644 --- a/dll/ntdll/CMakeLists.txt +++ b/dll/ntdll/CMakeLists.txt @@ -3,6 +3,11 @@ add_subdirectory(nt_0600) spec2def(ntdll.dll def/ntdll.spec ADD_IMPORTLIB) +# Embed RTC libs +if (STACK_PROTECTOR) +target_sources(libntdll PRIVATE $) +endif() + add_definitions( -D__NTDLL__ -D_NTOSKRNL_ @@ -60,6 +65,11 @@ if(MSVC) endif() target_link_libraries(ntdll rtl ntdllsys libcntpr uuid ${PSEH_LIB}) + +if (STACK_PROTECTOR) +target_sources(ntdll PRIVATE $) +endif() + add_pch(ntdll include/ntdll.h "${PCH_SKIP_SOURCE}") add_dependencies(ntdll ntstatus asm) add_cd_file(TARGET ntdll DESTINATION reactos/system32 NO_CAB FOR all) diff --git a/dll/win32/msvcrt/CMakeLists.txt b/dll/win32/msvcrt/CMakeLists.txt index 61ae9432d74..f2f922ed85f 100644 --- a/dll/win32/msvcrt/CMakeLists.txt +++ b/dll/win32/msvcrt/CMakeLists.txt @@ -7,6 +7,11 @@ target_compile_definitions(libmsvcrt INTERFACE _DLL __USE_CRTIMP) # Embed msvcrtex into libmsvcrt target_sources(libmsvcrt PRIVATE $) +# Embed RTC libs +if (STACK_PROTECTOR) +target_sources(libmsvcrt PRIVATE $) +target_link_libraries(libmsvcrt INTERFACE libkernel32) # For OutputDebugStringA +endif() add_definitions( -DUSE_MSVCRT_PREFIX diff --git a/drivers/storage/port/scsiport/CMakeLists.txt b/drivers/storage/port/scsiport/CMakeLists.txt index e0f3ce08a78..f4bbc0b48e8 100644 --- a/drivers/storage/port/scsiport/CMakeLists.txt +++ b/drivers/storage/port/scsiport/CMakeLists.txt @@ -1,6 +1,11 @@ spec2def(scsiport.sys scsiport.spec ADD_IMPORTLIB) +# Embed RTC libs +if (STACK_PROTECTOR) +target_sources(libscsiport PRIVATE $) +endif() + list(APPEND SOURCE fdo.c ioctl.c diff --git a/modules/rostests/apitests/win32u/win32u_ros/CMakeLists.txt b/modules/rostests/apitests/win32u/win32u_ros/CMakeLists.txt index e
[ros-diffs] [reactos] 01/02: [NTOS:MM] Allow "creating" a PDE in legacy Mm for foreign process
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57e8684bc60e9cf54105e0dcf6c3a13a621cde41 commit 57e8684bc60e9cf54105e0dcf6c3a13a621cde41 Author: Jérôme Gardou AuthorDate: Fri Jan 22 09:31:34 2021 +0100 Commit: Jérôme Gardou CommitDate: Fri Jan 22 09:32:36 2021 +0100 [NTOS:MM] Allow "creating" a PDE in legacy Mm for foreign process --- ntoskrnl/mm/i386/page.c | 35 +-- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index 336e65a3c45..83c52423d5a 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -219,10 +219,6 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PMMPDE PdeBase; ULONG PdeOffset = MiGetPdeOffset(Address); -/* Nobody but page fault should ask for creating the PDE, - * Which imples that Process is the current one */ -ASSERT(Create == FALSE); - PdeBase = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); if (PdeBase == NULL) { @@ -231,13 +227,32 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PointerPde = PdeBase + PdeOffset; if (PointerPde->u.Hard.Valid == 0) { -MmDeleteHyperspaceMapping(PdeBase); -return NULL; -} -else -{ -Pfn = PointerPde->u.Hard.PageFrameNumber; +KAPC_STATE ApcState; +NTSTATUS Status; + +if (!Create) +{ +MmDeleteHyperspaceMapping(PdeBase); +return NULL; +} + +KeStackAttachProcess(>Pcb, ); + +Status = MiDispatchFault(0x1, + MiAddressToPte(Address), + MiAddressToPde(Address), + NULL, + FALSE, + Process, + NULL, + NULL); + +KeUnstackDetachProcess(); +if (!NT_SUCCESS(Status)) +return NULL; } + +Pfn = PointerPde->u.Hard.PageFrameNumber; MmDeleteHyperspaceMapping(PdeBase); Pt = MmCreateHyperspaceMapping(Pfn); if (Pt == NULL)
[ros-diffs] [reactos] 02/02: [NTOS:MM] Get rid of "compatibility layer" for hyper space mappings
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0919324772d288d2ae54df460b97c4577cf7e812 commit 0919324772d288d2ae54df460b97c4577cf7e812 Author: Jérôme Gardou AuthorDate: Tue Dec 29 19:15:04 2020 +0100 Commit: Jérôme Gardou CommitDate: Fri Jan 22 09:33:06 2021 +0100 [NTOS:MM] Get rid of "compatibility layer" for hyper space mappings Let's call that a bug layer instead. --- ntoskrnl/include/internal/mm.h | 17 -- ntoskrnl/mm/ARM3/hypermap.c| 2 -- ntoskrnl/mm/i386/page.c| 77 +++--- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index e34f2fbb856..d1754ec4f5c 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -993,10 +993,6 @@ MmZeroPageThread( ); /* hypermap.c */ - -extern PEPROCESS HyperProcess; -extern KIRQL HyperIrql; - PVOID NTAPI MiMapPageInHyperSpace(IN PEPROCESS Process, @@ -1019,19 +1015,6 @@ NTAPI MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress, IN PFN_NUMBER NumberOfPages); -// -// ReactOS Compatibility Layer -// -FORCEINLINE -PVOID -MmCreateHyperspaceMapping(IN PFN_NUMBER Page) -{ -HyperProcess = (PEPROCESS)KeGetCurrentThread()->ApcState.Process; -return MiMapPageInHyperSpace(HyperProcess, Page, ); -} - -#define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql); - /* i386/page.c */ NTSTATUS diff --git a/ntoskrnl/mm/ARM3/hypermap.c b/ntoskrnl/mm/ARM3/hypermap.c index 6f7c32aa45e..4113814e6a6 100644 --- a/ntoskrnl/mm/ARM3/hypermap.c +++ b/ntoskrnl/mm/ARM3/hypermap.c @@ -20,8 +20,6 @@ PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte; PMMPTE MiFirstReservedZeroingPte; MMPTE HyperTemplatePte; -PEPROCESS HyperProcess; -KIRQL HyperIrql; /* PRIVATE FUNCTIONS **/ diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index 83c52423d5a..bcc2be911b1 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -134,12 +134,12 @@ ULONG MmProtectToValue[32] = /* FUNCTIONS ***/ -static BOOLEAN MmUnmapPageTable(PULONG Pt); +static BOOLEAN MmUnmapPageTable(PULONG Pt, KIRQL OldIrql); VOID -MiFlushTlb(PULONG Pt, PVOID Address) +MiFlushTlb(PULONG Pt, PVOID Address, KIRQL OldIrql) { -if ((Pt && MmUnmapPageTable(Pt)) || Address >= MmSystemRangeStart) +if ((Pt && MmUnmapPageTable(Pt, OldIrql)) || Address >= MmSystemRangeStart) { KeInvalidateTlbEntry(Address); } @@ -203,7 +203,7 @@ MiFillSystemPageDirectory(IN PVOID Base, IN SIZE_T NumberOfBytes); static PULONG -MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) +MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create, PKIRQL OldIrql) { PFN_NUMBER Pfn; PULONG Pt; @@ -219,7 +219,9 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PMMPDE PdeBase; ULONG PdeOffset = MiGetPdeOffset(Address); -PdeBase = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); +PdeBase = MiMapPageInHyperSpace(PsGetCurrentProcess(), + PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0]), +OldIrql); if (PdeBase == NULL) { KeBugCheck(MEMORY_MANAGEMENT); @@ -232,7 +234,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) if (!Create) { -MmDeleteHyperspaceMapping(PdeBase); +MiUnmapPageInHyperSpace(PsGetCurrentProcess(), PdeBase, *OldIrql); return NULL; } @@ -253,8 +255,8 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) } Pfn = PointerPde->u.Hard.PageFrameNumber; -MmDeleteHyperspaceMapping(PdeBase); -Pt = MmCreateHyperspaceMapping(Pfn); +MiUnmapPageInHyperSpace(PsGetCurrentProcess(), PdeBase, *OldIrql); +Pt = MiMapPageInHyperSpace(PsGetCurrentProcess(), Pfn, OldIrql); if (Pt == NULL) { KeBugCheck(MEMORY_MANAGEMENT); @@ -308,17 +310,15 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) return Pt; } -static BOOLEAN MmUnmapPageTable(PULONG Pt) +static BOOLEAN MmUnmapPageTable(PULONG Pt, KIRQL OldIrql) { if (!IS_HYPERSPACE(Pt)) { return TRUE; } -if (Pt) -{ -MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DO
[ros-diffs] [reactos] 01/01: [NTOS:MM] Fix compilation for amd64 port.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f63401060d2de91f68816fe5c8a15ee4e48b6573 commit f63401060d2de91f68816fe5c8a15ee4e48b6573 Author: Jérôme Gardou AuthorDate: Fri Jan 22 10:34:20 2021 +0100 Commit: Jérôme Gardou CommitDate: Fri Jan 22 10:34:20 2021 +0100 [NTOS:MM] Fix compilation for amd64 port. Addendum to 0919324772d288d2ae54df460b97c4577cf7e812 --- ntoskrnl/mm/amd64/page.c | 55 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/ntoskrnl/mm/amd64/page.c b/ntoskrnl/mm/amd64/page.c index 6b311fb34da..90a5d74b3b2 100644 --- a/ntoskrnl/mm/amd64/page.c +++ b/ntoskrnl/mm/amd64/page.c @@ -125,11 +125,11 @@ MiIsHyperspaceAddress(PVOID Address) } VOID -MiFlushTlb(PMMPTE Pte, PVOID Address) +MiFlushTlb(PMMPTE Pte, PVOID Address, KIRQL OldIrql) { if (MiIsHyperspaceAddress(Pte)) { -MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DOWN(Pte)); +MiUnmapPageInHyperSpace(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Pte), OldIrql); } else { @@ -142,16 +142,20 @@ PMMPTE MiGetPteForProcess( PEPROCESS Process, PVOID Address, -BOOLEAN Create) +BOOLEAN Create, +PKIRQL OldIrql +) { PMMPTE Pte; PMMPDE Pde; PMMPPE Ppe; PMMPXE Pxe; +*OldIrql = 0; /* Make sure the process is correct */ if (Address < MmSystemRangeStart) { +/* FIXME: Implement this case */ ASSERT(Process == PsGetCurrentProcess()); } else @@ -213,12 +217,13 @@ MiGetPteValueForProcess( { PMMPTE Pte; ULONG64 PteValue; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); PteValue = Pte ? Pte->u.Long : 0; if (MiIsHyperspaceAddress(Pte)) -MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DOWN(Pte)); +MiUnmapPageInHyperSpace(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Pte), OldIrql); return PteValue; } @@ -303,7 +308,7 @@ MmIsDisabledPage(PEPROCESS Process, PVOID Address) MMPTE Pte; Pte.u.Long = MiGetPteValueForProcess(Process, Address); -return (Pte.u.Hard.Valid == 0) && +return (Pte.u.Hard.Valid == 0) && (Pte.u.Trans.Transition == 0) && (Pte.u.Hard.PageFrameNumber != 0); } @@ -358,8 +363,9 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect) { PMMPTE Pte; MMPTE NewPte; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); ASSERT(Pte != NULL); NewPte = *Pte; @@ -368,7 +374,7 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect) InterlockedExchangePte(Pte, NewPte); -MiFlushTlb(Pte, Address); +MiFlushTlb(Pte, Address, OldIrql); } VOID @@ -376,8 +382,9 @@ NTAPI MmSetCleanPage(PEPROCESS Process, PVOID Address) { PMMPTE Pte; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); if (!Pte) { KeBugCheckEx(MEMORY_MANAGEMENT, 0x1234, (ULONG64)Address, 0, 0); @@ -390,7 +397,7 @@ MmSetCleanPage(PEPROCESS Process, PVOID Address) __invlpg(Address); } -MiFlushTlb(Pte, Address); +MiFlushTlb(Pte, Address, OldIrql); } VOID @@ -398,8 +405,9 @@ NTAPI MmSetDirtyPage(PEPROCESS Process, PVOID Address) { PMMPTE Pte; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); if (!Pte) { KeBugCheckEx(MEMORY_MANAGEMENT, 0x1234, (ULONG64)Address, 0, 0); @@ -412,7 +420,7 @@ MmSetDirtyPage(PEPROCESS Process, PVOID Address) __invlpg(Address); } -MiFlushTlb(Pte, Address); +MiFlushTlb(Pte, Address, OldIrql); } VOID @@ -426,8 +434,9 @@ MmDeleteVirtualMapping( PFN_NUMBER Pfn; PMMPTE Pte; MMPTE OldPte; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); if (Pte) { @@ -454,7 +463,7 @@ MmDeleteVirtualMapping( if (Page) *Page = Pfn; -MiFlushTlb(Pte, Address); +MiFlushTlb(Pte, Address, OldIrql); } VOID @@ -463,8 +472,9 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY* SwapEntry) { PMMPTE Pte; +KIRQL OldIrql; -Pte = MiGetPteForProcess(Process, Address, FALSE); +Pte = MiGetPteForProcess(Process, Address, FALSE, ); if (Pte == NULL) { *SwapEntry = 0; @@ -479,6 +489,9 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, *SwapEntry = Pte->u.Long >> 1; MI_ERASE_PTE(Pte); + +if (MiIsHyperspaceAddress(Pte)) +MiUnmapPageInHyperSpace(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Pte), Ol
[ros-diffs] [reactos] 01/01: [MSVCRTEX] Do not include _CI* math functions
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=af3527d4d2e616a6da82fcfe13734c9fd1239790 commit af3527d4d2e616a6da82fcfe13734c9fd1239790 Author: Jérôme Gardou AuthorDate: Thu Jan 21 09:43:04 2021 +0100 Commit: Jérôme Gardou CommitDate: Thu Jan 21 09:43:43 2021 +0100 [MSVCRTEX] Do not include _CI* math functions They are exported by msvcrt CORE-17423 --- sdk/lib/crt/msvcrtex.cmake | 7 --- 1 file changed, 7 deletions(-) diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 06bab6a5021..a9ebe297330 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -50,13 +50,6 @@ if(ARCH STREQUAL "i386") except/i386/chkstk_asm.s except/i386/chkstk_ms.s math/i386/alldiv_asm.s) -list(APPEND MSVCRTEX_SOURCE -math/i386/ci.c -math/i386/cicos.c -math/i386/cilog.c -math/i386/cipow.c -math/i386/cisin.c -math/i386/cisqrt.c) if (GCC AND CLANG) # CLang performs some optimisations requiring those funtions list(APPEND MSVCRTEX_ASM_SOURCE
[ros-diffs] [reactos] 01/01: [FASTFAT_NEW] Fix callback calling convention
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c9f15013735d51731801d27432d6f58f2ef4c5aa commit c9f15013735d51731801d27432d6f58f2ef4c5aa Author: Jérôme Gardou AuthorDate: Mon Dec 28 17:52:22 2020 +0100 Commit: Jérôme Gardou CommitDate: Thu Dec 31 17:14:04 2020 +0100 [FASTFAT_NEW] Fix callback calling convention --- drivers/filesystems/fastfat_new/fatprocs.h | 75 -- drivers/filesystems/fastfat_new/workque.c | 11 +++-- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/drivers/filesystems/fastfat_new/fatprocs.h b/drivers/filesystems/fastfat_new/fatprocs.h index 602f539cccb..f89f2325bee 100644 --- a/drivers/filesystems/fastfat_new/fatprocs.h +++ b/drivers/filesystems/fastfat_new/fatprocs.h @@ -104,7 +104,7 @@ typedef enum _TYPE_OF_OPEN { typedef BOOLEAN FINISHED; // -// Size (characters) of stack allocated name component buffers in +// Size (characters) of stack allocated name component buffers in // the create/rename paths. // @@ -125,7 +125,7 @@ FatExtendString( _Inout_ PVOID String, _In_ USHORT DesiredBufferSize, _In_ BOOLEAN FreeOldBuffer, -__out_opt PBOOLEAN NeedsFree +__out_opt PBOOLEAN NeedsFree ); VOID @@ -180,7 +180,7 @@ FatRemoveMcbEntry ( IN ULONG SectorCount ); - + // // File access check routine, implemented in AcChkSup.c // @@ -207,7 +207,7 @@ FatExplicitDeviceAccessGranted ( IN KPROCESSOR_MODE ProcessorMode ); - + // // Allocation support routines, implemented in AllocSup.c // @@ -389,7 +389,7 @@ FatLogOf( IN ULONG Value ); - + // // Buffer control routines for data caching, implemented in CacheSup.c // @@ -567,7 +567,7 @@ FatSyncUninitializeCacheMap ( IN PFILE_OBJECT FileObject ); - + // // Device I/O routines, implemented in DevIoSup.c // @@ -661,7 +661,7 @@ FatPerformDevIoCtrl ( IN ULONG IoControlCode, IN PDEVICE_OBJECT Device, IN PVOID InputBuffer OPTIONAL, -IN ULONG InputBufferLength, +IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, @@ -675,7 +675,7 @@ FatBuildZeroMdl ( __in ULONG Length ); - + // // Dirent support routines, implemented in DirSup.c // @@ -731,7 +731,7 @@ FatLocateDirent ( OUT PVBO ByteOffset, OUT PBOOLEAN FileNameDos OPTIONAL, IN OUT PUNICODE_STRING Lfn OPTIONAL, -IN OUT PUNICODE_STRING OrigLfn OPTIONAL +IN OUT PUNICODE_STRING OrigLfn OPTIONAL ); _Requires_lock_held_(_Global_critical_region_) @@ -849,7 +849,7 @@ FatUpdateDirentFromFcb ( #define FatDirectoryKey(FcbOrDcb) ((ULONGLONG)((FcbOrDcb)->CreationTime.QuadPart ^ (FcbOrDcb)->FirstClusterOfFile)) - + // // The following routines are used to access and manipulate the // clusters containing EA data in the ea data file. They are @@ -1029,7 +1029,7 @@ FatUnpinEaRange ( #define SizeOfFullEa(EA) (4+1+1+2+(EA)->EaNameLength+1+(EA)->EaValueLength) - + // // The following routines are used to manipulate the fscontext fields // of the file object, implemented in FilObSup.c @@ -1049,7 +1049,7 @@ typedef enum _TYPE_OF_OPEN { #endif typedef enum _FAT_FLUSH_TYPE { - + NoFlush = 0, Flush, FlushAndInvalidate, @@ -1089,7 +1089,7 @@ FatForceCacheMiss ( IN FAT_FLUSH_TYPE FlushType ); - + // // File system control routines, implemented in FsCtrl.c // @@ -1123,7 +1123,7 @@ FatUnlockVolumeInternal ( IN PFILE_OBJECT FileObject OPTIONAL ); - + // // Name support routines, implemented in NameSup.c // @@ -1326,13 +1326,13 @@ FatSpaceInName ( ); VOID -FatUnicodeRestoreShortNameCase( +FatUnicodeRestoreShortNameCase( IN PUNICODE_STRING ShortNameWithCase, IN BOOLEAN LowerCase8, IN BOOLEAN LowerCase3 ); - + // // Resources support routines/macros, implemented in ResrcSup.c // @@ -1661,7 +1661,7 @@ FatFilterCallbackAcquireForCreateSection ( #endif - + // // In-memory structure support routine, implemented in StrucSup.c // @@ -1704,7 +1704,7 @@ FatCreateFcb ( IN ULONG DirentOffsetWithinDirectory, IN PDIRENT Dirent, IN PUNICODE_STRING Lfn OPTIONAL, -IN PUNICODE_STRING OrigLfn OPTIONAL, +IN PUNICODE_STRING OrigLfn OPTIONAL, IN BOOLEAN IsPagingFile, IN BOOLEAN SingleResource ); @@ -1730,12 +1730,12 @@ PCCB FatCreateCcb ( IN PIRP_CONTEXT IrpContext ); - + VOID FatDeallocateCcbStrings( IN PCCB Ccb ); - + VOID FatDeleteCcb ( IN PIRP_CONTEXT IrpContext, @@ -1830,7 +1830,7 @@ FatPreallocateCloseContext ( ); PCLOSE_CONTEXT -FatAllocateCloseContext( +FatAllocateCloseContext( IN PVCB Vcb ); @@ -1847,7 +1847,7 @@ FatAllocateCloseContext( ((S) == STATUS_NO_MEDIA_IN_DEVICE) \ ) - + // // Routines to support managing file names Fcbs and Dcbs. //
[ros-diffs] [reactos] 01/01: [RTL] Fix a typo & remove useless cast
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d712c895fd8373eba1c0348add37be81982575cc commit d712c895fd8373eba1c0348add37be81982575cc Author: Jérôme Gardou AuthorDate: Mon Feb 1 09:08:13 2021 +0100 Commit: Jérôme Gardou CommitDate: Mon Feb 1 09:09:19 2021 +0100 [RTL] Fix a typo & remove useless cast --- sdk/lib/rtl/srw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/rtl/srw.c b/sdk/lib/rtl/srw.c index 8b5b47ce59f..68ac2614786 100644 --- a/sdk/lib/rtl/srw.c +++ b/sdk/lib/rtl/srw.c @@ -791,5 +791,5 @@ BOOLEAN NTAPI RtlTryAcquireSRWLockExclusive(PRTL_SRWLOCK SRWLock) { -return InterlockedCompareExchangePointer(>Ptr, (ULONG_PTR*)(ULONG_PTR)RTL_SRWLOCK_SHARED, 0) == 0; +return InterlockedCompareExchangePointer(>Ptr, (ULONG_PTR*)RTL_SRWLOCK_OWNED, 0) == 0; }
[ros-diffs] [reactos] 01/01: [NTOS:KE] Fix EIP only when the breakpoint is a break
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=158235bdd53577013cff990f554763ddda6ec6a4 commit 158235bdd53577013cff990f554763ddda6ec6a4 Author: Jérôme Gardou AuthorDate: Mon Feb 1 16:36:53 2021 +0100 Commit: Jérôme Gardou CommitDate: Mon Feb 1 16:39:39 2021 +0100 [NTOS:KE] Fix EIP only when the breakpoint is a break Fixes ntdll:exception winetest crash ROSTESTS-80 --- ntoskrnl/ke/i386/traphdlr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/ke/i386/traphdlr.c b/ntoskrnl/ke/i386/traphdlr.c index cf4dbdd92ee..1ae5bf02240 100644 --- a/ntoskrnl/ke/i386/traphdlr.c +++ b/ntoskrnl/ke/i386/traphdlr.c @@ -227,10 +227,10 @@ KiDebugHandler(IN PKTRAP_FRAME TrapFrame, /* Enable interrupts if the trap came from user-mode */ if (KiUserTrap(TrapFrame)) _enable(); -/* Dispatch the exception */ +/* Dispatch the exception. Fix EIP in case its a break breakpoint (sic) */ KiDispatchExceptionFromTrapFrame(STATUS_BREAKPOINT, 0, - TrapFrame->Eip - 1, + TrapFrame->Eip - (Parameter1 == BREAKPOINT_BREAK), 3, Parameter1, Parameter2,
[ros-diffs] [reactos] 01/01: [KMTESTS:NTOS_CC] Fix a test format
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe5e23e4705e48f9c45460646c171a53d3ea0a2c commit fe5e23e4705e48f9c45460646c171a53d3ea0a2c Author: Jérôme Gardou AuthorDate: Thu Dec 31 14:51:17 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Feb 2 10:18:52 2021 +0100 [KMTESTS:NTOS_CC] Fix a test format --- modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c index 3f18625d893..e9013529826 100644 --- a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c @@ -186,13 +186,13 @@ MapAndLockUserBuffer( return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority); } -#define ok_bcb(B, L, O) \ -{ \ -PPUBLIC_BCB public_bcb = (B); \ -ok(public_bcb->NodeTypeCode == 0x2FD, "Not a BCB: %x\n", public_bcb->NodeTypeCode); \ -ok(public_bcb->NodeByteSize == 0, "Invalid size: %d\n", public_bcb->NodeByteSize); \ -ok_eq_ulong(public_bcb->MappedLength, (L)); \ -ok_eq_longlong(public_bcb->MappedFileOffset.QuadPart, (O)); \ +#define ok_bcb(B, L, O) \ +{ \ +PPUBLIC_BCB public_bcb = (B); \ +ok(public_bcb->NodeTypeCode == 0x2FD, "Not a BCB: %04x\n", public_bcb->NodeTypeCode); \ +ok(public_bcb->NodeByteSize == 0, "Invalid size: %d\n", public_bcb->NodeByteSize);\ +ok_eq_ulong(public_bcb->MappedLength, (L)); \ +ok_eq_longlong(public_bcb->MappedFileOffset.QuadPart, (O)); \ } static
[ros-diffs] [reactos] 01/01: [NTOS:MM] Properly handle the 1-offset of paging files
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=857dd4ae36a55f8dcf122d904ee6993199909d8a commit 857dd4ae36a55f8dcf122d904ee6993199909d8a Author: Jérôme Gardou AuthorDate: Mon Dec 7 10:22:28 2020 +0100 Commit: Jérôme Gardou CommitDate: Tue Feb 2 10:17:28 2021 +0100 [NTOS:MM] Properly handle the 1-offset of paging files --- ntoskrnl/mm/pagefile.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/mm/pagefile.c b/ntoskrnl/mm/pagefile.c index b7d8c83e54e..37870520998 100644 --- a/ntoskrnl/mm/pagefile.c +++ b/ntoskrnl/mm/pagefile.c @@ -189,7 +189,7 @@ NTSTATUS NTAPI MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page) { -return MiReadPageFile(Page, FILE_FROM_ENTRY(SwapEntry), OFFSET_FROM_ENTRY(SwapEntry) - 1); +return MiReadPageFile(Page, FILE_FROM_ENTRY(SwapEntry), OFFSET_FROM_ENTRY(SwapEntry)); } NTSTATUS @@ -215,6 +215,9 @@ MiReadPageFile( return(STATUS_UNSUCCESSFUL); } +/* Normalize offset. */ +PageFileOffset--; + ASSERT(PageFileIndex < MAX_PAGING_FILES); PagingFile = MmPagingFile[PageFileIndex];
[ros-diffs] [reactos] 01/01: [KMTEST:NTOS_CC] Fix buffer size calculation
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a46ee7dafe39defcecdf812aed8d09cfab6f5e4e commit a46ee7dafe39defcecdf812aed8d09cfab6f5e4e Author: Jérôme Gardou AuthorDate: Mon Feb 1 10:42:37 2021 +0100 Commit: Jérôme Gardou CommitDate: Tue Feb 2 10:15:19 2021 +0100 [KMTEST:NTOS_CC] Fix buffer size calculation --- modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c index 241312c12c5..89bc3973cfb 100644 --- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c @@ -467,7 +467,7 @@ TestIrpHandler( if (Length > (Fcb->Header.FileSize.QuadPart - Offset.QuadPart)) { -RtlFillMemory(Buffer, Length - Fcb->Header.FileSize.QuadPart, 0xBD); +RtlFillMemory(Buffer, Length - (Fcb->Header.FileSize.QuadPart - Offset.QuadPart), 0xBD); } } else
[ros-diffs] [reactos] 01/01: [KMTESTS:NTOS_MM] Purge & flush cache when there is a data section object.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d52f937120b8e82838fb3e15ba3cf485d88e1d13 commit d52f937120b8e82838fb3e15ba3cf485d88e1d13 Author: Jérôme Gardou AuthorDate: Thu Feb 4 10:46:31 2021 +0100 Commit: Jérôme Gardou CommitDate: Thu Feb 4 10:50:59 2021 +0100 [KMTESTS:NTOS_MM] Purge & flush cache when there is a data section object. Those purge & flush the mapped sections too. That's what fastfat_new & other FS drivers do. --- modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c b/modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c index a547207f211..29415465c95 100644 --- a/modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c +++ b/modules/rostests/kmtests/ntos_mm/NtCreateSection_drv.c @@ -256,7 +256,7 @@ TestIrpHandler( { DPRINT1("Init\n"); -CcInitializeCacheMap(IoStack->FileObject, +CcInitializeCacheMap(IoStack->FileObject, (PCC_FILE_SIZES)>Header.AllocationSize, FALSE, , NULL); } @@ -299,7 +299,7 @@ TestIrpHandler( { DPRINT1("Init\n"); ok_eq_ulong(RtlCompareUnicodeString(>FileObject->FileName, , FALSE), 0); -CcInitializeCacheMap(IoStack->FileObject, +CcInitializeCacheMap(IoStack->FileObject, (PCC_FILE_SIZES)>Header.AllocationSize, FALSE, , Fcb); } @@ -417,7 +417,7 @@ TestIrpHandler( { LARGE_INTEGER Zero = RTL_CONSTANT_LARGE_INTEGER(0LL); -if (CcIsFileCached(IoStack->FileObject)) +if (IoStack->FileObject->SectionObjectPointer->DataSectionObject) { CcFlushCache(>SectionObjectPointers, NULL, 0, NULL); CcPurgeCacheSection(>SectionObjectPointers, NULL, 0, FALSE);
[ros-diffs] [reactos] 01/218: [WINESYNC] Fix for older versions of PyYAML
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=79d15a1f371ebebd8d38e0891201ff3b136a8548 commit 79d15a1f371ebebd8d38e0891201ff3b136a8548 Author: Jérôme Gardou AuthorDate: Mon Sep 21 15:27:21 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Feb 4 16:37:00 2021 +0100 [WINESYNC] Fix for older versions of PyYAML --- sdk/tools/winesync/winesync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py index 69f31601490..44fbf1e332f 100644 --- a/sdk/tools/winesync/winesync.py +++ b/sdk/tools/winesync/winesync.py @@ -26,7 +26,7 @@ class wine_sync: def __init__(self, module): if os.path.isfile('winesync.cfg'): with open('winesync.cfg', 'r') as file_input: -config = yaml.load(file_input, Loader=yaml.FullLoader) +config = yaml.safe_load(file_input) self.reactos_src = config['repos']['reactos'] self.wine_src = config['repos']['wine'] self.wine_staging_src = config['repos']['wine-staging'] @@ -52,7 +52,7 @@ class wine_sync: # get the actual state for the asked module self.module = module with open(module + '.cfg', 'r') as file_input: -self.module_cfg = yaml.load(file_input, Loader=yaml.FullLoader) +self.module_cfg = yaml.safe_load(file_input) self.staged_patch_dir = os.path.join('sdk', 'tools', 'winesync', self.module + '_staging')
[ros-diffs] [reactos] 07/218: [SDK/WINE] Add debugstr_a in wine/test.h
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ad65e645dc8177c1a38081ab5d27358076511b6a commit ad65e645dc8177c1a38081ab5d27358076511b6a Author: Jérôme Gardou AuthorDate: Tue Sep 22 09:44:24 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Feb 4 16:37:01 2021 +0100 [SDK/WINE] Add debugstr_a in wine/test.h --- sdk/include/reactos/wine/test.h | 57 + 1 file changed, 57 insertions(+) diff --git a/sdk/include/reactos/wine/test.h b/sdk/include/reactos/wine/test.h index 5eb52d80e36..8b9035adfcf 100644 --- a/sdk/include/reactos/wine/test.h +++ b/sdk/include/reactos/wine/test.h @@ -75,6 +75,7 @@ extern void winetest_add_failures( LONG new_failures ); extern void winetest_wait_child_process( HANDLE process ); extern const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n ); +extern const char *wine_dbgstr_an( const CHAR *str, intptr_t n ); extern const char *wine_dbgstr_guid( const GUID *guid ); extern const char *wine_dbgstr_point( const POINT *guid ); extern const char *wine_dbgstr_size( const SIZE *guid ); @@ -82,6 +83,7 @@ extern const char *wine_dbgstr_rect( const RECT *rect ); #ifdef WINETEST_USE_DBGSTR_LONGLONG extern const char *wine_dbgstr_longlong( ULONGLONG ll ); #endif +static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); } static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); } /* strcmpW is available for tests compiled under Wine, but not in standalone @@ -577,6 +579,61 @@ void winetest_wait_child_process( HANDLE process ) } } +const char *wine_dbgstr_an( const CHAR *str, intptr_t n ) +{ +char *dst, *res; +size_t size; + +if (!((ULONG_PTR)str >> 16)) +{ +if (!str) return "(null)"; +res = get_temp_buffer( 6 ); +sprintf( res, "#%04x", LOWORD(str) ); +return res; +} +if (n == -1) +{ +const CHAR *end = str; +while (*end) end++; +n = end - str; +} +if (n < 0) n = 0; +size = 12 + min( 300, n * 5 ); +dst = res = get_temp_buffer( size ); +*dst++ = '"'; +while (n-- > 0 && dst <= res + size - 10) +{ +CHAR c = *str++; +switch (c) +{ +case '\n': *dst++ = '\\'; *dst++ = 'n'; break; +case '\r': *dst++ = '\\'; *dst++ = 'r'; break; +case '\t': *dst++ = '\\'; *dst++ = 't'; break; +case '"': *dst++ = '\\'; *dst++ = '"'; break; +case '\\': *dst++ = '\\'; *dst++ = '\\'; break; +default: +if (c >= ' ' && c <= 126) +*dst++ = (char)c; +else +{ +*dst++ = '\\'; +sprintf(dst,"%04x",c); +dst+=4; +} +} +} +*dst++ = '"'; +if (n > 0) +{ +*dst++ = '.'; +*dst++ = '.'; +*dst++ = '.'; +} +*dst++ = 0; +release_temp_buffer( res, dst - res ); +return res; +} + const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n ) { char *dst, *res;
[ros-diffs] [reactos] 04/218: [D3DX9_XX] Use a common header for every file
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=edca86dadb24eacc868ad2d8455eb84d83170fa1 commit edca86dadb24eacc868ad2d8455eb84d83170fa1 Author: Jérôme Gardou AuthorDate: Mon Sep 21 16:30:14 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Feb 4 16:37:01 2021 +0100 [D3DX9_XX] Use a common header for every file --- dll/directx/wine/d3dx9_36/animation.c | 4 dll/directx/wine/d3dx9_36/core.c | 4 dll/directx/wine/d3dx9_36/d3dx9.cmake | 1 - dll/directx/wine/d3dx9_36/effect.c| 4 dll/directx/wine/d3dx9_36/font.c | 4 dll/directx/wine/d3dx9_36/guid.c | 5 + dll/directx/wine/d3dx9_36/line.c | 4 dll/directx/wine/d3dx9_36/main.c | 4 dll/directx/wine/d3dx9_36/math.c | 4 dll/directx/wine/d3dx9_36/mesh.c | 5 + dll/directx/wine/d3dx9_36/precomp.h | 16 dll/directx/wine/d3dx9_36/preshader.c | 4 dll/directx/wine/d3dx9_36/render.c| 4 dll/directx/wine/d3dx9_36/shader.c| 4 dll/directx/wine/d3dx9_36/skin.c | 4 dll/directx/wine/d3dx9_36/sprite.c| 4 dll/directx/wine/d3dx9_36/surface.c | 4 dll/directx/wine/d3dx9_36/texture.c | 4 dll/directx/wine/d3dx9_36/util.c | 4 dll/directx/wine/d3dx9_36/volume.c| 4 dll/directx/wine/d3dx9_36/xfile.c | 4 21 files changed, 90 insertions(+), 5 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/animation.c b/dll/directx/wine/d3dx9_36/animation.c index 6be2dd6b5a6..8cdc73cd163 100644 --- a/dll/directx/wine/d3dx9_36/animation.c +++ b/dll/directx/wine/d3dx9_36/animation.c @@ -1,3 +1,6 @@ +#ifdef __REACTOS__ +#include "precomp.h" +#else /* * Animation Controller operations specific to D3DX9. * @@ -22,6 +25,7 @@ #include "wine/port.h" #include "d3dx9_private.h" +#endif /* __REACTOS__ */ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); diff --git a/dll/directx/wine/d3dx9_36/core.c b/dll/directx/wine/d3dx9_36/core.c index 1eb289ece6b..6ef05dfc61f 100644 --- a/dll/directx/wine/d3dx9_36/core.c +++ b/dll/directx/wine/d3dx9_36/core.c @@ -1,3 +1,6 @@ +#ifdef __REACTOS__ +#include "precomp.h" +#else /* * * Copyright 2002 Raphael Junqueira @@ -21,6 +24,7 @@ #include "wine/port.h" #include "d3dx9_private.h" +#endif /* __REACTOS__ */ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); diff --git a/dll/directx/wine/d3dx9_36/d3dx9.cmake b/dll/directx/wine/d3dx9_36/d3dx9.cmake index 95c5ca54d62..4140f00eca1 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9.cmake +++ b/dll/directx/wine/d3dx9_36/d3dx9.cmake @@ -44,5 +44,4 @@ function(add_d3dx9_target __version) add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all) target_compile_definitions(${module} PRIVATE -DD3DX_SDK_VERSION=${__version} -D__WINESRC__ -Dcopysignf=_copysignf) -target_include_directories(${module} PRIVATE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) endfunction() diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c index e8ae7b54c22..9a2e41ae90d 100644 --- a/dll/directx/wine/d3dx9_36/effect.c +++ b/dll/directx/wine/d3dx9_36/effect.c @@ -1,3 +1,6 @@ +#ifdef __REACTOS__ +#include "precomp.h" +#else /* * Copyright 2010 Christian Costa * Copyright 2011 Rico Schüller @@ -25,6 +28,7 @@ #include "d3dx9_private.h" #include "d3dcompiler.h" +#endif /* __REACTOS__ */ /* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 418a3be3328..13c63e11ee1 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -1,3 +1,6 @@ +#ifdef __REACTOS__ +#include "precomp.h" +#else /* * Copyright (C) 2008 Tony Wasserka * @@ -22,6 +25,7 @@ #include "d3dx9_private.h" #include "wine/unicode.h" +#endif /* __REACTOS__ */ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); diff --git a/dll/directx/wine/d3dx9_36/guid.c b/dll/directx/wine/d3dx9_36/guid.c index c43ee3c8b42..526bc124626 100644 --- a/dll/directx/wine/d3dx9_36/guid.c +++ b/dll/directx/wine/d3dx9_36/guid.c @@ -10,6 +10,11 @@ #include #include #include + #include +#include + +/* Wine-specific WIC GUIDs */ +DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22); /* NO CODE HERE, THIS IS JUST REQUIRED FOR THE GUID DEFINITIONS */ diff --git a/dll/directx/wine/d3dx9_36/line.c b/dll/directx/wine/d3dx9_36/line.c index 356d54fbd0c..7f8ae320e81 100644 --- a/dll/directx/wine/d3dx9_36/line.c +++ b/dll/directx/wine/d3dx9_36/line.c @@ -1,3 +1,6 @@ +#ifdef __REACTOS__ +#include "precomp.h" +#else /* * Copyright 2010 Christian Costa * @@ -21,6 +24,7 @@ #include "wine/port.h" #include "d3dx9_private.h" +#endif /* __REACTOS__ */ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
[ros-diffs] [reactos] 05/218: [SDK/CRT] Provide inline implementation of log2
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=86a0852ffb6576bae9dae6ba4dcdb2abcd638f05 commit 86a0852ffb6576bae9dae6ba4dcdb2abcd638f05 Author: Jérôme Gardou AuthorDate: Mon Sep 21 16:54:39 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Feb 4 16:37:01 2021 +0100 [SDK/CRT] Provide inline implementation of log2 --- sdk/include/crt/math.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/include/crt/math.h b/sdk/include/crt/math.h index b6ab12c8313..f565491ad6a 100644 --- a/sdk/include/crt/math.h +++ b/sdk/include/crt/math.h @@ -270,6 +270,7 @@ _Check_return_ __CRT_INLINE long lrintl(_In_ long double x) { return (long)((x < _Check_return_ __CRT_INLINE long long llrint(_In_ double x) { return (long long)((x < 0) ? (x - 0.5f) : (x + 0.5)); } _Check_return_ __CRT_INLINE long long llrintf(_In_ float x) { return (long long)((x < 0) ? (x - 0.5f) : (x + 0.5)); } _Check_return_ __CRT_INLINE long long llrintl(_In_ long double x) { return (long long)((x < 0) ? (x - 0.5f) : (x + 0.5)); } +_Check_return_ __CRT_INLINE double log2(_In_ double x) { return log(x) / log(2); } #ifndef NO_OLDNAMES /* !__STDC__ */
[ros-diffs] [reactos] 03/218: [WINESYNC] Add missing file to d3dx9 configuration
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=17fc441b38eb721d4dcd43812f07008e7bd7e777 commit 17fc441b38eb721d4dcd43812f07008e7bd7e777 Author: Jérôme Gardou AuthorDate: Mon Sep 21 16:12:43 2020 +0200 Commit: Jérôme Gardou CommitDate: Thu Feb 4 16:37:01 2021 +0100 [WINESYNC] Add missing file to d3dx9 configuration --- sdk/tools/winesync/d3dx9.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 689ad51acb8..cefdb2502a3 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -32,5 +32,6 @@ files: include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h + include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h tags: wine: wine-4.2
[ros-diffs] [reactos] 01/01: [RTL] Fix heap usage flags
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6d697561f0ae70875858c808f14c20ab2602f6d5 commit 6d697561f0ae70875858c808f14c20ab2602f6d5 Author: Jérôme Gardou AuthorDate: Thu Jan 28 18:42:59 2021 +0100 Commit: Jérôme Gardou CommitDate: Fri Jan 29 09:42:13 2021 +0100 [RTL] Fix heap usage flags - Use Heap->ForceFlags where needed - Use passed-in flags instead of the heap flags in some places - Do not recursively acquire the heap lock --- sdk/lib/rtl/heap.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/lib/rtl/heap.c b/sdk/lib/rtl/heap.c index a75c18f5d2a..2eba86e046e 100644 --- a/sdk/lib/rtl/heap.c +++ b/sdk/lib/rtl/heap.c @@ -2681,7 +2681,8 @@ RtlReAllocateHeap(HANDLE HeapPtr, { RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; -Flags &= ~HEAP_NO_SERIALIZE; +/* Do not acquire the lock anymore for re-entrant call */ +Flags |= HEAP_NO_SERIALIZE; } /* Get the pointer to the in-use entry */ @@ -3656,7 +3657,7 @@ BOOLEAN NTAPI RtlValidateHeap( } /* Force flags */ -Flags = Heap->ForceFlags; +Flags |= Heap->ForceFlags; /* Acquire the lock if necessary */ if (!(Flags & HEAP_NO_SERIALIZE)) @@ -3744,7 +3745,7 @@ RtlSetUserValueHeap(IN PVOID HeapHandle, BOOLEAN HeapLocked = FALSE, ValueSet = FALSE; /* Force flags */ -Flags |= Heap->Flags; +Flags |= Heap->ForceFlags; /* Call special heap */ if (RtlpHeapIsSpecial(Flags)) @@ -3806,14 +3807,14 @@ RtlSetUserFlagsHeap(IN PVOID HeapHandle, BOOLEAN HeapLocked = FALSE; /* Force flags */ -Flags |= Heap->Flags; +Flags |= Heap->ForceFlags; /* Call special heap */ if (RtlpHeapIsSpecial(Flags)) return RtlDebugSetUserFlagsHeap(Heap, Flags, BaseAddress, UserFlagsReset, UserFlagsSet); /* Lock if it's lockable */ -if (!(Heap->Flags & HEAP_NO_SERIALIZE)) +if (!(Flags & HEAP_NO_SERIALIZE)) { RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; @@ -3862,14 +3863,14 @@ RtlGetUserInfoHeap(IN PVOID HeapHandle, BOOLEAN HeapLocked = FALSE; /* Force flags */ -Flags |= Heap->Flags; +Flags |= Heap->ForceFlags; /* Call special heap */ if (RtlpHeapIsSpecial(Flags)) return RtlDebugGetUserInfoHeap(Heap, Flags, BaseAddress, UserValue, UserFlags); /* Lock if it's lockable */ -if (!(Heap->Flags & HEAP_NO_SERIALIZE)) +if (!(Flags & HEAP_NO_SERIALIZE)) { RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE;
[ros-diffs] [reactos] 04/100: [NTOSKRNL] Rename MM_ROS_SECTION_OBJECT:SectionPageProtection to InitialPageProtection
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7afecee5ebc39c1446be320f057fd47c63bdbf5f commit 7afecee5ebc39c1446be320f057fd47c63bdbf5f Author: Jérôme Gardou AuthorDate: Fri Oct 23 11:46:46 2020 +0200 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Rename MM_ROS_SECTION_OBJECT:SectionPageProtection to InitialPageProtection --- ntoskrnl/include/internal/mm.h | 2 +- ntoskrnl/mm/section.c | 14 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index e803142d651..160c19a8a76 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -200,7 +200,7 @@ typedef struct _ROS_SECTION_OBJECT CSHORT Type; CSHORT Size; LARGE_INTEGER SizeOfSection; -ULONG SectionPageProtection; +ULONG InitialPageProtection; ULONG AllocationAttributes; PFILE_OBJECT FileObject; union diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 13835bb94ac..9704ddba8f6 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2879,7 +2879,7 @@ MmCreatePageFileSection(PROS_SECTION_OBJECT *SectionObject, RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); Section->Type = 'SC'; Section->Size = 'TN'; -Section->SectionPageProtection = SectionPageProtection; +Section->InitialPageProtection = SectionPageProtection; Section->AllocationAttributes = AllocationAttributes; Section->SizeOfSection = MaximumSize; Segment = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_SECTION_SEGMENT), @@ -2949,7 +2949,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); Section->Type = 'SC'; Section->Size = 'TN'; -Section->SectionPageProtection = SectionPageProtection; +Section->InitialPageProtection = SectionPageProtection; Section->AllocationAttributes = AllocationAttributes; /* @@ -3774,7 +3774,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); Section->Type = 'SC'; Section->Size = 'TN'; -Section->SectionPageProtection = SectionPageProtection; +Section->InitialPageProtection = SectionPageProtection; Section->AllocationAttributes = AllocationAttributes; if (FileObject->SectionObjectPointer->ImageSectionObject == NULL) @@ -4641,21 +4641,21 @@ MmMapViewOfSection(IN PVOID SectionObject, { /* check for write access */ if ((Protect & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE)) && -!(Section->SectionPageProtection & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE))) +!(Section->InitialPageProtection & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE))) { MmUnlockAddressSpace(AddressSpace); return STATUS_SECTION_PROTECTION; } /* check for read access */ if ((Protect & (PAGE_READONLY|PAGE_WRITECOPY|PAGE_EXECUTE_READ|PAGE_EXECUTE_WRITECOPY)) && -!(Section->SectionPageProtection & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) +!(Section->InitialPageProtection & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) { MmUnlockAddressSpace(AddressSpace); return STATUS_SECTION_PROTECTION; } /* check for execute access */ if ((Protect & (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY)) && -!(Section->SectionPageProtection & (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) +!(Section->InitialPageProtection & (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) { MmUnlockAddressSpace(AddressSpace); return STATUS_SECTION_PROTECTION; @@ -5133,7 +5133,7 @@ MmCreateSection (OUT PVOID * Section, DesiredAccess, ObjectAttributes, SizeOfSection, - SectionPageProtection, + InitialPageProtection, AllocationAttributes, FileObject); }
[ros-diffs] [reactos] 01/100: [NTOSKRNL] Do not compile unused code
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b74e5ed4ff49d162b8416d5e365857754299538 commit 9b74e5ed4ff49d162b8416d5e365857754299538 Author: Jérôme Gardou AuthorDate: Fri Oct 23 11:30:42 2020 +0200 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Do not compile unused code --- ntoskrnl/cache/section/data.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntoskrnl/cache/section/data.c b/ntoskrnl/cache/section/data.c index 1fb0fc20c56..b7649dd1f62 100644 --- a/ntoskrnl/cache/section/data.c +++ b/ntoskrnl/cache/section/data.c @@ -303,6 +303,7 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment) ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT); } +#ifdef NEWCC NTSTATUS NTAPI MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, @@ -533,6 +534,7 @@ MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, *SectionObject = Section; return STATUS_SUCCESS; } +#endif NTSTATUS NTAPI
[ros-diffs] [reactos] 03/100: [NTOSKRNL] Rename MM_ROS_SECTION_OBJECT:MaximumSize to SizeOfSection
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=54c760574b2ac55006c0e233fd1ee7857a5a9a42 commit 54c760574b2ac55006c0e233fd1ee7857a5a9a42 Author: Jérôme Gardou AuthorDate: Fri Oct 23 11:42:09 2020 +0200 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Rename MM_ROS_SECTION_OBJECT:MaximumSize to SizeOfSection For consistency with the SECTION struct --- ntoskrnl/include/internal/mm.h | 2 +- ntoskrnl/mm/section.c | 18 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index d1754ec4f5c..e803142d651 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -199,7 +199,7 @@ typedef struct _ROS_SECTION_OBJECT { CSHORT Type; CSHORT Size; -LARGE_INTEGER MaximumSize; +LARGE_INTEGER SizeOfSection; ULONG SectionPageProtection; ULONG AllocationAttributes; PFILE_OBJECT FileObject; diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index f586ec37754..13835bb94ac 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2881,7 +2881,7 @@ MmCreatePageFileSection(PROS_SECTION_OBJECT *SectionObject, Section->Size = 'TN'; Section->SectionPageProtection = SectionPageProtection; Section->AllocationAttributes = AllocationAttributes; -Section->MaximumSize = MaximumSize; +Section->SizeOfSection = MaximumSize; Segment = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_SECTION_SEGMENT), TAG_MM_SECTION_SEGMENT); if (Segment == NULL) @@ -3087,7 +3087,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, } MmUnlockSectionSegment(Segment); Section->FileObject = FileObject; -Section->MaximumSize = MaximumSize; +Section->SizeOfSection = MaximumSize; #ifndef NEWCC CcRosReferenceCache(FileObject); #endif @@ -4678,11 +4678,11 @@ MmMapViewOfSection(IN PVOID SectionObject, if ((*ViewSize) == 0) { -(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset; +(*ViewSize) = Section->SizeOfSection.u.LowPart - ViewOffset; } -else if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart) +else if (((*ViewSize)+ViewOffset) > Section->SizeOfSection.u.LowPart) { -(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset; +(*ViewSize) = Section->SizeOfSection.u.LowPart - ViewOffset; } *ViewSize = PAGE_ROUND_UP(*ViewSize); @@ -4869,11 +4869,11 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, if ((*ViewSize) == 0) { -(*ViewSize) = Section->MaximumSize.u.LowPart; +(*ViewSize) = Section->SizeOfSection.u.LowPart; } -else if ((*ViewSize) > Section->MaximumSize.u.LowPart) +else if ((*ViewSize) > Section->SizeOfSection.u.LowPart) { -(*ViewSize) = Section->MaximumSize.u.LowPart; +(*ViewSize) = Section->SizeOfSection.u.LowPart; } MmLockSectionSegment(Section->Segment); @@ -5132,7 +5132,7 @@ MmCreateSection (OUT PVOID * Section, Status = MmCreateCacheSection(SectionObject, DesiredAccess, ObjectAttributes, - MaximumSize, + SizeOfSection, SectionPageProtection, AllocationAttributes, FileObject);
[ros-diffs] [reactos] 02/100: [NTOSKRNL][NDK] Get rid of SECTION_OBJECT typedef
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=073ec9b0d4595b997d1464e59a803e539b348a3a commit 073ec9b0d4595b997d1464e59a803e539b348a3a Author: Jérôme Gardou AuthorDate: Fri Oct 23 11:38:20 2020 +0200 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL][NDK] Get rid of SECTION_OBJECT typedef We will use the more recent SECTION (already used in ARM3) and this will avoid confusions --- ntoskrnl/mm/ARM3/section.c | 4 ++-- ntoskrnl/ps/process.c | 2 +- sdk/include/ndk/mmtypes.h | 13 - 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 02ead9a70a5..fe7e8b46145 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1700,7 +1700,7 @@ PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID SectionObject) { -PSECTION_OBJECT Section; +PSECTION Section; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ASSERT(SectionObject != NULL); @@ -1773,7 +1773,7 @@ VOID NTAPI MmGetImageInformation (OUT PSECTION_IMAGE_INFORMATION ImageInformation) { -PSECTION_OBJECT SectionObject; +PSECTION SectionObject; /* Get the section object of this process*/ SectionObject = PsGetCurrentProcess()->SectionObject; diff --git a/ntoskrnl/ps/process.c b/ntoskrnl/ps/process.c index 179fd1d8fa4..0e6f112a53b 100644 --- a/ntoskrnl/ps/process.c +++ b/ntoskrnl/ps/process.c @@ -358,7 +358,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, PEPROCESS Process, Parent; PVOID ExceptionPortObject; PDEBUG_OBJECT DebugObject; -PSECTION_OBJECT SectionObject; +PSECTION SectionObject; NTSTATUS Status, AccessStatus; ULONG_PTR DirectoryTableBase[2] = {0,0}; KAFFINITY Affinity; diff --git a/sdk/include/ndk/mmtypes.h b/sdk/include/ndk/mmtypes.h index ca62ebdf5ce..3e9fabf1c02 100644 --- a/sdk/include/ndk/mmtypes.h +++ b/sdk/include/ndk/mmtypes.h @@ -623,19 +623,6 @@ typedef struct _SEGMENT_OBJECT PMMSUBSECTION_FLAGS MmSubSectionFlags; } SEGMENT_OBJECT, *PSEGMENT_OBJECT; -// -// Section Object -// -typedef struct _SECTION_OBJECT -{ -PVOID StartingVa; -PVOID EndingVa; -PVOID Parent; -PVOID LeftChild; -PVOID RightChild; -PSEGMENT_OBJECT Segment; -} SECTION_OBJECT, *PSECTION_OBJECT; - // // Generic Address Range Structure //
[ros-diffs] [reactos] 20/100: [NTOS/MM] Introduce MmArePagesResident and MmMakePagesResident
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e4047d1521cd75ffded656aef221d7eb8285a04e commit e4047d1521cd75ffded656aef221d7eb8285a04e Author: Jérôme Gardou AuthorDate: Tue Oct 27 17:37:38 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Introduce MmArePagesResident and MmMakePagesResident --- ntoskrnl/include/internal/mm.h | 14 + ntoskrnl/mm/section.c | 140 + 2 files changed, 154 insertions(+) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 662f49c9bd7..be8b0acc4b0 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -1323,6 +1323,20 @@ MmMapViewInSystemSpaceEx ( _Inout_ PLARGE_INTEGER SectionOffset ); +BOOLEAN +NTAPI +MmArePagesResident( +_In_ PEPROCESS Process, +_In_ PVOID BaseAddress, +_In_ ULONG Length); + +NTSTATUS +NTAPI +MmMakePagesResident( +_In_ PEPROCESS Process, +_In_ PVOID Address, +_In_ ULONG Length); + /* sysldr.c **/ VOID diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index fc2c1a3e904..4d29f5a9ff4 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -5076,4 +5076,144 @@ MmCreateSection (OUT PVOID * Section, return Status; } +BOOLEAN +NTAPI +MmArePagesResident( +_In_ PEPROCESS Process, +_In_ PVOID Address, +_In_ ULONG Length) +{ +PMEMORY_AREA MemoryArea; +BOOLEAN Ret = TRUE; +PMM_SECTION_SEGMENT Segment; +LARGE_INTEGER SegmentOffset, RangeEnd; + +MmLockAddressSpace(>Vm); + +MemoryArea = MmLocateMemoryAreaByAddress(>Vm, Address); +if (MemoryArea == NULL) +{ +MmUnlockAddressSpace(>Vm); +return FALSE; +} + +/* Only supported in old Mm for now */ +ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW); +/* For file mappings */ +ASSERT(MemoryArea->VadNode.u.VadFlags.VadType != VadImageMap); + +Segment = MemoryArea->SectionData.Segment; +MmLockSectionSegment(Segment); + +SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea) ++ MemoryArea->SectionData.ViewOffset.QuadPart; +RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea) ++ MemoryArea->SectionData.ViewOffset.QuadPart; + +while (SegmentOffset.QuadPart < RangeEnd.QuadPart) +{ +ULONG_PTR Entry = MmGetPageEntrySectionSegment(Segment, ); +if ((Entry == 0) || IS_SWAP_FROM_SSE(Entry)) +{ +Ret = FALSE; +break; +} +SegmentOffset.QuadPart += PAGE_SIZE; +} + +MmUnlockSectionSegment(Segment); + +MmUnlockAddressSpace(>Vm); +return Ret; +} + +NTSTATUS +NTAPI +MmMakePagesResident( +_In_ PEPROCESS Process, +_In_ PVOID Address, +_In_ ULONG Length) +{ +PMEMORY_AREA MemoryArea; +PMM_SECTION_SEGMENT Segment; +LARGE_INTEGER SegmentOffset, RangeEnd; + +MmLockAddressSpace(>Vm); + +MemoryArea = MmLocateMemoryAreaByAddress(>Vm, Address); +if (MemoryArea == NULL) +{ +MmUnlockAddressSpace(>Vm); +return FALSE; +} + +/* Only supported in old Mm for now */ +ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW); +/* For file mappings */ +ASSERT(MemoryArea->VadNode.u.VadFlags.VadType != VadImageMap); + +Segment = MemoryArea->SectionData.Segment; +MmLockSectionSegment(Segment); + +SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea) ++ MemoryArea->SectionData.ViewOffset.QuadPart; +RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea) ++ MemoryArea->SectionData.ViewOffset.QuadPart; + +while (SegmentOffset.QuadPart < RangeEnd.QuadPart) +{ +ULONG_PTR Entry = MmGetPageEntrySectionSegment(Segment, ); + +/* Let any pending read proceed */ +while (MM_IS_WAIT_PTE(Entry)) +{ +MmUnlockSectionSegment(Segment); +MmUnlockAddressSpace(>Vm); +MiWaitForPageEvent(NULL, NULL); +MmLockAddressSpace(>Vm); +MmLockSectionSegment(Segment); +Entry = MmGetPageEntrySectionSegment(Segment, ); +} + +/* We are called from Cc, this can't be backed by the page files */ +ASSERT(!IS_SWAP_FROM_SSE(Entry)); + +/* At this point, there may be a valid page there */ +if (Entry == 0) +{ +PFN_NUMBER Page; +NTSTATUS Status; + +/* + * Release all our locks and read in the page from disk + */ +MmSetPageEntrySectionSegment(Segment, , MAKE_SWAP_SSE(MM_WAIT_ENTRY)); +MmUnlockSectionSegment(Segment); +MmUnlockAddressSp
[ros-diffs] [reactos] 24/100: [NTOS/MM] DO not assert when being passed invalid parameters in MmCreateSection
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b46173edaff285e3c414070eb1d1655f2873d998 commit b46173edaff285e3c414070eb1d1655f2873d998 Author: Jérôme Gardou AuthorDate: Wed Nov 18 10:29:17 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] DO not assert when being passed invalid parameters in MmCreateSection --- ntoskrnl/mm/section.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 39ae8bf75f5..6c521522f4f 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4358,7 +4358,6 @@ MmCreateSection (OUT PVOID * Section, else { /* All cases should be handled above */ -ASSERT(FALSE); Status = STATUS_INVALID_PARAMETER; if (FileObject) ObDereferenceObject(FileObject);
[ros-diffs] [reactos] 22/100: [NTOS:MM] Fix locking when paging out
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d932bdb9505e270830e0eb177b523f39d32d1f10 commit d932bdb9505e270830e0eb177b523f39d32d1f10 Author: Jérôme Gardou AuthorDate: Fri Jan 22 09:30:55 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Fix locking when paging out --- ntoskrnl/mm/rmap.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index d1cfb584dce..21b5b246457 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -70,7 +70,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) if (entry == NULL) { MiReleasePfnLock(OldIrql); -return STATUS_UNSUCCESSFUL; +goto WriteSegment; } Process = entry->Process; @@ -176,6 +176,12 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) MmSetDirtyPage(Process, Address); MmUnlockAddressSpace(AddressSpace); +if (Address < MmSystemRangeStart) +{ +ExReleaseRundownProtection(>RundownProtect); +ObDereferenceObject(Process); +} + return STATUS_UNSUCCESSFUL; } } @@ -199,6 +205,11 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) MmSetDirtyPage(Process, Address); MmUnlockAddressSpace(AddressSpace); +if (Address < MmSystemRangeStart) +{ +ExReleaseRundownProtection(>RundownProtect); +ObDereferenceObject(Process); +} return STATUS_UNSUCCESSFUL; } } @@ -256,12 +267,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) KeBugCheck(MEMORY_MANAGEMENT); } -if (Address < MmSystemRangeStart) -{ -ExReleaseRundownProtection(>RundownProtect); -ObDereferenceObject(Process); -} - +WriteSegment: /* Now write this page to file, if needed */ Segment = MmGetSectionAssociation(Page, ); if (Segment)
[ros-diffs] [reactos] 23/100: [NTOS/MM] Assert there are no RMAP left before freeing the page
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba49c390412450157275330268bcaab096aa6149 commit ba49c390412450157275330268bcaab096aa6149 Author: Jérôme Gardou AuthorDate: Tue Nov 17 17:38:53 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Assert there are no RMAP left before freeing the page --- ntoskrnl/mm/rmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index 21b5b246457..80576f4cc59 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -225,9 +225,8 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) /* We can finally let this page go */ MmDeleteRmap(Page, Process, Address); -MmReleasePageMemoryConsumer(MC_USER, Page); - ASSERT(MmGetRmapListHeadPage(Page) == NULL); +MmReleasePageMemoryConsumer(MC_USER, Page); if (Address < MmSystemRangeStart) {
[ros-diffs] [reactos] 36/100: [NTOSKRNL] Address issues raised in PR 3361 review
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d2fa434cb7849442c9813ca3daac83882114cecd commit d2fa434cb7849442c9813ca3daac83882114cecd Author: Jérôme Gardou AuthorDate: Wed Dec 2 15:17:28 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOSKRNL] Address issues raised in PR 3361 review --- ntoskrnl/cache/section/data.c | 4 ntoskrnl/mm/ARM3/section.c| 8 ntoskrnl/mm/section.c | 39 --- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ntoskrnl/cache/section/data.c b/ntoskrnl/cache/section/data.c index 1ec6a3326d9..fa83080eddb 100644 --- a/ntoskrnl/cache/section/data.c +++ b/ntoskrnl/cache/section/data.c @@ -274,8 +274,6 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment) DPRINT("Finalize segment %p\n", Segment); -__debugbreak(); - MmLockSectionSegment(Segment); RemoveEntryList(>ListOfSegments); if (Segment->Flags & MM_DATAFILE_SEGMENT) { @@ -622,8 +620,6 @@ MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment, ULONG_PTR Entry; PFILE_OBJECT FileObject = Segment->FileObject; -__debugbreak(); - Entry = MmGetPageEntrySectionSegment(Segment, FileOffset); DPRINTC("MiFreeSegmentPage(%p:%I64x -> Entry %Ix\n", Segment, diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 9ea36637a22..dde3b2d8cc4 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1094,6 +1094,14 @@ MiMapViewInSystemSpace(IN PVOID Section, *ViewSize = SectionSize - SectionOffset->QuadPart; } +/* Check overflow */ +if ((SectionOffset->QuadPart + *ViewSize) < SectionOffset->QuadPart) +{ +DPRINT1("Integer overflow between size & offset!\n"); +MiDereferenceControlArea(ControlArea); +return STATUS_INVALID_VIEW_SIZE; +} + /* Check if the caller wanted a larger section than the view */ if (SectionOffset->QuadPart + *ViewSize > SectionSize) { diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 6dcf764d7a1..e39f82d0f22 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2050,7 +2050,7 @@ MmCreatePhysicalMemorySection(VOID) /* * Create the section mapping physical memory */ -SectionSize.QuadPart = ~((ULONG_PTR)0); +SectionSize.QuadPart = MmNumberOfPhysicalPages * PAGE_SIZE; InitializeObjectAttributes(, , OBJ_PERMANENT | OBJ_KERNEL_EXCLUSIVE, @@ -2192,7 +2192,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, (PVOID*)); if (!NT_SUCCESS(Status)) { -ObDereferenceObject(FileObject); return(Status); } /* @@ -2240,7 +2239,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (MaximumSize.QuadPart == 0) { ObDereferenceObject(Section); -ObDereferenceObject(FileObject); return STATUS_MAPPED_FILE_SIZE_ZERO; } } @@ -2254,7 +2252,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (!NT_SUCCESS(Status)) { ObDereferenceObject(Section); -ObDereferenceObject(FileObject); return(STATUS_SECTION_NOT_EXTENDED); } } @@ -2263,7 +2260,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (FileObject->SectionObjectPointer == NULL) { ObDereferenceObject(Section); -ObDereferenceObject(FileObject); return STATUS_INVALID_FILE_FOR_SECTION; } @@ -2274,7 +2270,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, if (Status != STATUS_SUCCESS) { ObDereferenceObject(Section); -ObDereferenceObject(FileObject); return(Status); } @@ -2305,7 +2300,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, //KeSetEvent((PVOID)>Lock, IO_NO_INCREMENT, FALSE); MiReleasePfnLock(OldIrql); ObDereferenceObject(Section); -ObDereferenceObject(FileObject); return(STATUS_NO_MEMORY); } @@ -2329,6 +2323,7 @@ MmCreateDataFileSection(PSECTION *SectionObject, ExInitializeFastMutex(>Lock); Segment->FileObject = FileObject; +ObReferenceObject(FileObject); Segment->Image.FileOffset = 0; Segment->Protection = SectionPageProtection; @@ -2370,9 +2365,6 @@ MmCreateDataFileSection(PSECTION *SectionObject, } MmUnlockSectionSegment(Segment); - -/* The segment already has a reference to a file object. Don't bother keeping one.*/ -ObDereferenceObject(FileObject); } Section->SizeOfSection = MaximumSize; @@ -3053,7 +3045,6 @@ MmCreateImageSection(PSECTION *SectionObject,
[ros-diffs] [reactos] 38/100: [NTOS:MM] Acquire file lock when creating section
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d70af61e8fff18b24d9baa3bb63c37c96aa21c6 commit 7d70af61e8fff18b24d9baa3bb63c37c96aa21c6 Author: Jérôme Gardou AuthorDate: Thu Dec 3 17:18:29 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Acquire file lock when creating section --- ntoskrnl/mm/section.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index e39f82d0f22..08e68a20c33 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4290,6 +4290,7 @@ MmCreateSection (OUT PVOID * Section, NTSTATUS Status; ULONG Protection; PSECTION *SectionObject = (PSECTION *)Section; +BOOLEAN FileLock = FALSE; /* Check if an ARM3 section is being created instead */ if (!(AllocationAttributes & (SEC_IMAGE | SEC_PHYSICALMEMORY))) @@ -4343,6 +4344,24 @@ MmCreateSection (OUT PVOID * Section, DPRINT1("Failed to get a handle to the FO: %lx\n", Status); return Status; } + +/* Lock the file */ +Status = FsRtlAcquireToCreateMappedSection(FileObject, SectionPageProtection); +if (!NT_SUCCESS(Status)) +{ +ObDereferenceObject(FileObject); +return Status; +} + +FileLock = TRUE; + +/* Deny access if there are writes on the file */ +if ((AllocationAttributes & SEC_IMAGE) && (Status == STATUS_FILE_LOCKED_WITH_WRITERS)) +{ +DPRINT1("Cannot create image maps with writers open on the file!\n"); +Status = STATUS_ACCESS_DENIED; +goto Quit; +} } else { @@ -4365,7 +4384,6 @@ MmCreateSection (OUT PVOID * Section, SectionPageProtection, AllocationAttributes, FileObject); -ObDereferenceObject(FileObject); } #ifndef NEWCC else if (FileObject != NULL) @@ -4378,7 +4396,6 @@ MmCreateSection (OUT PVOID * Section, AllocationAttributes, FileObject, FileHandle != NULL); -ObDereferenceObject(FileObject); } #else else if (FileHandle != NULL || FileObject != NULL) @@ -4396,10 +4413,14 @@ MmCreateSection (OUT PVOID * Section, { /* All cases should be handled above */ Status = STATUS_INVALID_PARAMETER; -if (FileObject) -ObDereferenceObject(FileObject); } +Quit: +if (FileLock) +FsRtlReleaseFile(FileObject); +if (FileObject) +ObDereferenceObject(FileObject); + return Status; }
[ros-diffs] [reactos] 39/100: [NTOS/MM] Do not zero out the tail of the segment if the mapping is not an image
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f114209782a0f44fa6b80cc3aa1e7d583d5dacea commit f114209782a0f44fa6b80cc3aa1e7d583d5dacea Author: Jérôme Gardou AuthorDate: Fri Dec 4 09:10:13 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Do not zero out the tail of the segment if the mapping is not an image --- ntoskrnl/mm/section.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 08e68a20c33..6b6a6cb94be 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1205,7 +1205,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, Status = STATUS_SUCCESS; } -if ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart) +if ((MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart)) { KIRQL OldIrql; PUCHAR PageMap;
[ros-diffs] [reactos] 40/100: [NTOS/MM] Set FSRTL_MOD_WRITE_TOP_LEVEL_IRP top-level IRP when paging-out
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e39fc52d25a577b3c5abd9a9c9b5d20508c42d88 commit e39fc52d25a577b3c5abd9a9c9b5d20508c42d88 Author: Jérôme Gardou AuthorDate: Fri Dec 4 09:10:59 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Set FSRTL_MOD_WRITE_TOP_LEVEL_IRP top-level IRP when paging-out --- ntoskrnl/mm/section.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 6b6a6cb94be..866b90810e0 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4685,9 +4685,16 @@ MmCheckDirtySegment( MmUnlockSectionSegment(Segment); +/* Tell the FS driver who we are */ +if (PageOut) +IoSetTopLevelIrp((PIRP)FSRTL_MOD_WRITE_TOP_LEVEL_IRP); + /* Go ahead and write the page */ Status = MiWritePage(Segment, Offset->QuadPart, Page); +if (PageOut) +IoSetTopLevelIrp(NULL); + MmLockSectionSegment(Segment); /* Get the entry again */
[ros-diffs] [reactos] 41/100: [NTOS:CC] File size check fix
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cbfc04157d9553fe4e7f2171db64561be2eaf243 commit cbfc04157d9553fe4e7f2171db64561be2eaf243 Author: Jérôme Gardou AuthorDate: Fri Dec 4 09:12:18 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] File size check fix --- ntoskrnl/cc/copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index f92040aa0b2..d228a981ea2 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -809,7 +809,7 @@ CcZeroData ( return TRUE; } -ASSERT(EndOffset->QuadPart <= SharedCacheMap->FileSize.QuadPart); +ASSERT(EndOffset->QuadPart <= SharedCacheMap->SectionSize.QuadPart); while(WriteOffset.QuadPart < EndOffset->QuadPart) {
[ros-diffs] [reactos] 42/100: [NTOS:IO] VFAT sucks less now
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d3454a809238331dae3fd6f25185eb5b92cf73f commit 2d3454a809238331dae3fd6f25185eb5b92cf73f Author: Jérôme Gardou AuthorDate: Fri Dec 4 09:13:01 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:IO] VFAT sucks less now --- ntoskrnl/io/iomgr/iofunc.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 80814a70ba3..7d0a08c5395 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -3014,10 +3014,8 @@ NtReadFile(IN HANDLE FileHandle, /* Now set the deferred read flags */ Irp->Flags |= (IRP_READ_OPERATION | IRP_DEFER_IO_COMPLETION); -#if 0 -/* FIXME: VFAT SUCKS */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE; -#endif /* Perform the call */ return IopPerformSynchronousRequest(DeviceObject, @@ -4082,10 +4080,8 @@ NtWriteFile(IN HANDLE FileHandle, /* Now set the deferred read flags */ Irp->Flags |= (IRP_WRITE_OPERATION | IRP_DEFER_IO_COMPLETION); -#if 0 -/* FIXME: VFAT SUCKS */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE; -#endif /* Perform the call */ return IopPerformSynchronousRequest(DeviceObject,
[ros-diffs] [reactos] 90/100: [NTOS:MM] Unconditionally purge cache on image section creation.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea354c4bc70cb7ee9302cfdd6a2c780b29639af8 commit ea354c4bc70cb7ee9302cfdd6a2c780b29639af8 Author: Jérôme Gardou AuthorDate: Wed Jan 27 17:02:43 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Unconditionally purge cache on image section creation. --- ntoskrnl/mm/section.c | 60 ++- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 8515820e116..ff7d9438baa 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2470,20 +2470,6 @@ ExeFmtpAllocateSegments(IN ULONG NrSegments) return Segments; } - -static NTSTATUS -MmMapViewOfSegment(PMMSUPPORT AddressSpace, - BOOLEAN AsImage, - PMM_SECTION_SEGMENT Segment, - PVOID* BaseAddress, - SIZE_T ViewSize, - ULONG Protect, - LONGLONG ViewOffset, - ULONG AllocationType); -static NTSTATUS -MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, - PVOID BaseAddress); - static NTSTATUS NTAPI @@ -2538,45 +2524,14 @@ ExeFmtpReadFile(IN PVOID File, return STATUS_INSUFFICIENT_RESOURCES; } -if (FileObject->SectionObjectPointer->DataSectionObject) -{ -PVOID SegmentMap = NULL; - -/* Get the data from the file mapping instead */ -MmLockAddressSpace(MmGetKernelAddressSpace()); -Status = MmMapViewOfSegment(MmGetKernelAddressSpace(), -FALSE, - FileObject->SectionObjectPointer->DataSectionObject, -, -BufferSize, -PAGE_READONLY, -FileOffset.QuadPart, -0); -MmUnlockAddressSpace(MmGetKernelAddressSpace()); - -if (!NT_SUCCESS(Status)) -return Status; - -RtlCopyMemory(Buffer, SegmentMap, BufferSize); -UsedSize = BufferSize; - -MmLockAddressSpace(MmGetKernelAddressSpace()); +Status = MiSimpleRead(FileObject, , Buffer, BufferSize, TRUE, ); -MmUnmapViewOfSegment(MmGetKernelAddressSpace(), SegmentMap); +UsedSize = (ULONG)Iosb.Information; -MmUnlockAddressSpace(MmGetKernelAddressSpace()); -} -else +if(NT_SUCCESS(Status) && UsedSize < OffsetAdjustment) { -Status = MiSimpleRead(FileObject, , Buffer, BufferSize, TRUE, ); - -UsedSize = (ULONG)Iosb.Information; - -if(NT_SUCCESS(Status) && UsedSize < OffsetAdjustment) -{ -Status = STATUS_IN_PAGE_ERROR; -ASSERT(!NT_SUCCESS(Status)); -} +Status = STATUS_IN_PAGE_ERROR; +ASSERT(!NT_SUCCESS(Status)); } if(NT_SUCCESS(Status)) @@ -3175,10 +3130,7 @@ MmCreateImageSection(PSECTION *SectionObject, MiReleasePfnLock(OldIrql); /* Purge the cache */ -if (CcIsFileCached(FileObject)) -{ -CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL); -} +CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL); StatusExeFmt = ExeFmtpCreateImageSection(FileObject, ImageSectionObject);
[ros-diffs] [reactos] 89/100: [NTOS:MM] Keep a ref on the segment when mapping a page & keep trace of what is the highest offset mapped.
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c1c51e31e439240fec4542b002dae925ccfb9e3b commit c1c51e31e439240fec4542b002dae925ccfb9e3b Author: Jérôme Gardou AuthorDate: Wed Jan 27 16:59:37 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Keep a ref on the segment when mapping a page & keep trace of what is the highest offset mapped. --- ntoskrnl/cache/section/sptab.c | 23 ++- ntoskrnl/mm/section.c | 3 --- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ntoskrnl/cache/section/sptab.c b/ntoskrnl/cache/section/sptab.c index f0cb3d36c2a..7d960a1ff08 100644 --- a/ntoskrnl/cache/section/sptab.c +++ b/ntoskrnl/cache/section/sptab.c @@ -218,14 +218,35 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, } else { -/* We're switching to a valid entry from an invalid one. Add the Rmap */ +/* + * We're switching to a valid entry from an invalid one. + * Add the Rmap and take a ref on the segment. + */ MmSetSectionAssociation(PFN_FROM_SSE(Entry), Segment, Offset); +InterlockedIncrement64(Segment->ReferenceCount); + +if ((Offset->QuadPart > (Segment->LastPage << PAGE_SHIFT)) || !Segment->LastPage) +Segment->LastPage = (Offset->QuadPart >> PAGE_SHIFT) + 1; } } else if (OldEntry && !IS_SWAP_FROM_SSE(OldEntry)) { /* We're switching to an invalid entry from a valid one */ MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry)); +MmDereferenceSegment(Segment); + +if (Offset->QuadPart == ((Segment->LastPage - 1ULL) << PAGE_SHIFT)) +{ +/* We are unsetting the last page */ +while (--Segment->LastPage) +{ +LARGE_INTEGER CheckOffset; +CheckOffset.QuadPart = (Segment->LastPage - 1) << PAGE_SHIFT; +ULONG_PTR Entry = MmGetPageEntrySectionSegment(Segment, ); +if ((Entry != 0) && !IS_SWAP_FROM_SSE(Entry)) +break; +} +} } PageTable->PageEntries[PageIndex] = Entry; diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 16767458bce..8515820e116 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4113,9 +4113,6 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, return Ret; } - - - /* * @implemented */
[ros-diffs] [reactos] 87/100: [NTOS:MM] Use 64-bit integer to count references on segments
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e43aa1305fa2865c3e61647e5c51857c9a1c9fd commit 3e43aa1305fa2865c3e61647e5c51857c9a1c9fd Author: Jérôme Gardou AuthorDate: Wed Jan 27 16:20:08 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Use 64-bit integer to count references on segments --- ntoskrnl/include/internal/mm.h | 8 +--- ntoskrnl/mm/rmap.c | 2 +- ntoskrnl/mm/section.c | 25 +++-- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index dad1a08bf33..86ed4dfb23a 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -168,7 +168,7 @@ typedef struct _MM_SECTION_SEGMENT FAST_MUTEX Lock; /* lock which protects the page directory */ LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */ LARGE_INTEGER Length; /* absolute length of the segment */ -PULONG ReferenceCount; +PLONG64 ReferenceCount; ULONG SectionCount; ULONG Protection; PULONG Flags; @@ -182,9 +182,11 @@ typedef struct _MM_SECTION_SEGMENT ULONG Characteristics; } Image; - ULONG RefCount; + LONG64 RefCount; ULONG SegFlags; +ULONGLONG LastPage; + RTL_GENERIC_TABLE PageTable; } MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT; @@ -192,7 +194,7 @@ typedef struct _MM_IMAGE_SECTION_OBJECT { PFILE_OBJECT FileObject; -ULONG RefCount; +LONG64 RefCount; ULONG SegFlags; SECTION_IMAGE_INFORMATION ImageInformation; diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index f50e680e401..5b7ffe3a3da 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -525,7 +525,7 @@ MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset) return NULL; } -InterlockedIncrementUL(Result->Segment->ReferenceCount); +InterlockedIncrement64(Result->Segment->ReferenceCount); MiReleasePfnLock(OldIrql); return Result; } diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index a223ba0e302..524b282f606 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -107,7 +107,7 @@ MiGrabDataSection(PSECTION_OBJECT_POINTERS SectionObjectPointer) } ASSERT(Segment->SegFlags & MM_DATAFILE_SEGMENT); -InterlockedIncrementUL(>RefCount); +InterlockedIncrement64(>RefCount); break; } @@ -996,7 +996,7 @@ MmDereferenceSegment(PMM_SECTION_SEGMENT Segment) /* Lock the PFN lock because we mess around with SectionObjectPointers */ OldIrql = MiAcquirePfnLock(); -if (InterlockedDecrementUL(Segment->ReferenceCount) > 0) +if (InterlockedDecrement64(Segment->ReferenceCount) > 0) { /* Nothing to do yet */ MiReleasePfnLock(OldIrql); @@ -2049,25 +2049,6 @@ MmpDeleteSection(PVOID ObjectBody) ASSERT(ImageSectionObject->RefCount > 0); MmDereferenceSegment(ImageSectionObject->Segments); } -#ifdef NEWCC -else if (Section->Segment && Section->Segment->Flags & MM_DATAFILE_SEGMENT) -{ -ULONG RefCount = 0; -PMM_SECTION_SEGMENT Segment = Section->Segment; - -if (Segment && -(RefCount = InterlockedDecrementUL(>ReferenceCount)) == 0) -{ -DPRINT("Freeing section segment\n"); -Section->Segment = NULL; -MmFinalizeSegment(Segment); -} -else -{ -DPRINT("RefCount %d\n", RefCount); -} -} -#endif else { PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment; @@ -3339,7 +3320,7 @@ MmMapViewOfSegment( return(Status); } -InterlockedIncrementUL(Segment->ReferenceCount); +InterlockedIncrement64(Segment->ReferenceCount); MArea->SectionData.Segment = Segment; MArea->SectionData.ViewOffset.QuadPart = ViewOffset;
[ros-diffs] [reactos] 84/100: [NTOS:MM] Introduce MmPurgeSegment & MmFlushSegment
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=90c6a65efe7384269f27fe419e164868c8654fff commit 90c6a65efe7384269f27fe419e164868c8654fff Author: Jérôme Gardou AuthorDate: Wed Jan 27 13:03:06 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Introduce MmPurgeSegment & MmFlushSegment Those will back CcFlushCache and CcPurgeCache. --- ntoskrnl/include/internal/mm.h | 25 - ntoskrnl/mm/section.c | 241 ++--- 2 files changed, 247 insertions(+), 19 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index bd9ea25e0b7..dad1a08bf33 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -1241,10 +1241,14 @@ MmFindRegion( #define DIRTY_SSE(E) ((E) | 2) #define CLEAN_SSE(E) ((E) & ~2) #define IS_DIRTY_SSE(E) ((E) & 2) +#define WRITE_SSE(E) ((E) | 4) +#define IS_WRITE_SSE(E) ((E) & 4) #define PAGE_FROM_SSE(E) ((E) & 0xF000) -#define SHARE_COUNT_FROM_SSE(E) (((E) & 0x0FFC) >> 2) -#define MAX_SHARE_COUNT 0x3FF -#define MAKE_SSE(P, C) ((ULONG_PTR)((P) | ((C) << 2))) +#define SHARE_COUNT_FROM_SSE(E) (((E) & 0x0FFC) >> 3) +#define MAX_SHARE_COUNT 0x1FF +#define MAKE_SSE(P, C) ((ULONG_PTR)((P) | ((C) << 3))) +#define BUMPREF_SSE(E) (PAGE_FROM_SSE(E) | ((SHARE_COUNT_FROM_SSE(E) + 1) << 3) | ((E) & 0x7)) +#define DECREF_SSE(E)(PAGE_FROM_SSE(E) | ((SHARE_COUNT_FROM_SSE(E) - 1) << 3) | ((E) & 0x7)) VOID NTAPI @@ -1375,6 +1379,21 @@ MmRosFlushVirtualMemory( _Inout_ PSIZE_T Length, _Out_ PIO_STATUS_BLOCK Iosb); +NTSTATUS +NTAPI +MmFlushSegment( +_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, +_In_opt_ PLARGE_INTEGER Offset, +_In_ ULONG Length, +_In_opt_ PIO_STATUS_BLOCK Iosb); + +BOOLEAN +NTAPI +MmPurgeSegment( +_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, +_In_opt_ PLARGE_INTEGER Offset, +_In_ ULONG Length); + BOOLEAN NTAPI MmCheckDirtySegment( diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 7ff5485ae81..a223ba0e302 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -60,6 +60,8 @@ extern MMSESSION MmSession; +static LARGE_INTEGER TinyTime = {{-1L, -1L}}; + #ifndef NEWCC KEVENT MmWaitPageEvent; @@ -83,6 +85,37 @@ _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line) } #endif +static +PMM_SECTION_SEGMENT +MiGrabDataSection(PSECTION_OBJECT_POINTERS SectionObjectPointer) +{ +KIRQL OldIrql = MiAcquirePfnLock(); +PMM_SECTION_SEGMENT Segment = NULL; + +while (TRUE) +{ +Segment = SectionObjectPointer->DataSectionObject; +if (!Segment) +break; + +if (Segment->SegFlags & (MM_SEGMENT_INCREATE | MM_SEGMENT_INDELETE)) +{ +MiReleasePfnLock(OldIrql); +KeDelayExecutionThread(KernelMode, FALSE, ); +OldIrql = MiAcquirePfnLock(); +continue; +} + +ASSERT(Segment->SegFlags & MM_DATAFILE_SEGMENT); +InterlockedIncrementUL(>RefCount); +break; +} + +MiReleasePfnLock(OldIrql); + +return Segment; +} + /* Somewhat grotesque, but eh... */ PMM_IMAGE_SECTION_OBJECT ImageSectionObjectFromSegment(PMM_SECTION_SEGMENT Segment) { @@ -1028,7 +1061,6 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset) { ULONG_PTR Entry; -BOOLEAN Dirty; Entry = MmGetPageEntrySectionSegment(Segment, Offset); if (Entry == 0) @@ -1045,11 +1077,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, { KeBugCheck(MEMORY_MANAGEMENT); } -Dirty = IS_DIRTY_SSE(Entry); -Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) + 1); -if (Dirty) -Entry = DIRTY_SSE(Entry); -MmSetPageEntrySectionSegment(Segment, Offset, Entry); +MmSetPageEntrySectionSegment(Segment, Offset, BUMPREF_SSE(Entry)); } BOOLEAN @@ -1080,8 +1108,7 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea, { KeBugCheck(MEMORY_MANAGEMENT); } -Dirty = Dirty || IS_DIRTY_SSE(Entry); -Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) - 1); +Entry = DECREF_SSE(Entry); if (Dirty) Entry = DIRTY_SSE(Entry); if (SHARE_COUNT_FROM_SSE(Entry) > 0) @@ -1094,7 +1121,7 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea, return FALSE; } -if (Dirty && (MemoryArea->VadNode.u.VadFlags.VadType != VadImageMap)) +if (IS_DIRTY_SSE(Entry) && (MemoryArea->VadNode.u.VadFlags.VadType != VadImageMap)) { ASSERT(!Segment->WriteCopy); ASSER
[ros-diffs] [reactos] 86/100: [NTOS:CC] Make sure to purge the Mm side in CcPurgeCacheSection
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc6bc02b916cd2084c9aa8ef5efccfdc7f14d7a4 commit cc6bc02b916cd2084c9aa8ef5efccfdc7f14d7a4 Author: Jérôme Gardou AuthorDate: Wed Jan 27 16:19:07 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Make sure to purge the Mm side in CcPurgeCacheSection --- ntoskrnl/cc/fs.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c index 161833d14e2..bef6502f73f 100644 --- a/ntoskrnl/cc/fs.c +++ b/ntoskrnl/cc/fs.c @@ -180,7 +180,10 @@ CcPurgeCacheSection ( SharedCacheMap = SectionObjectPointer->SharedCacheMap; if (!SharedCacheMap) -return FALSE; +{ +Success = TRUE; +goto purgeMm; +} StartOffset = FileOffset != NULL ? FileOffset->QuadPart : 0; if (Length == 0 || FileOffset == NULL) @@ -257,6 +260,11 @@ CcPurgeCacheSection ( ASSERT(Refs == 0); } +/* Now make sure that Mm doesn't hold some pages here. */ +purgeMm: +if (Success) +Success = MmPurgeSegment(SectionObjectPointer, FileOffset, Length); + return Success; }
[ros-diffs] [reactos] 88/100: [NTOS:MM] Improve MmCanFileBeTruncated
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=91a4e62376d1dbd5d7e155f2a86bb4b468649a24 commit 91a4e62376d1dbd5d7e155f2a86bb4b468649a24 Author: Jérôme Gardou AuthorDate: Wed Jan 27 16:28:45 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Improve MmCanFileBeTruncated --- ntoskrnl/mm/section.c | 42 -- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 524b282f606..16767458bce 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4077,54 +4077,36 @@ BOOLEAN NTAPI MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER NewFileSize) { -KIRQL OldIrql = MiAcquirePfnLock(); BOOLEAN Ret; PMM_SECTION_SEGMENT Segment; -CheckSectionPointer: /* Check whether an ImageSectionObject exists */ if (SectionObjectPointer->ImageSectionObject != NULL) { DPRINT1("ERROR: File can't be truncated because it has an image section\n"); -MiReleasePfnLock(OldIrql); - return FALSE; } -Segment = (PMM_SECTION_SEGMENT)SectionObjectPointer->DataSectionObject; -/* Wait for it to be created/deleted properly */ -while (Segment && (Segment->SegFlags & (MM_SEGMENT_INCREATE | MM_SEGMENT_INDELETE))) +Segment = MiGrabDataSection(SectionObjectPointer); +if (!Segment) { -LARGE_INTEGER ShortTime; - -ShortTime.QuadPart = -10 * 100 * 1000; - -/* Bad luck. Wait a bit for the operation to finish */ -MiReleasePfnLock(OldIrql); -KeDelayExecutionThread(KernelMode, FALSE, ); -OldIrql = MiAcquirePfnLock(); -goto CheckSectionPointer; +/* There is no data section. It's fine to do anything. */ +return TRUE; } -if (Segment) +MmLockSectionSegment(Segment); +if ((Segment->SectionCount == 1) && (SectionObjectPointer->SharedCacheMap != NULL)) { -if ((Segment->SectionCount == 1) && (SectionObjectPointer->SharedCacheMap != NULL)) -{ -/* If the cache is the only one holding a reference to the segment, then it's fine to resize */ -Ret = TRUE; -} -else -{ -/* We can't shrink, but we can extend */ -Ret = NewFileSize->QuadPart >= Segment->RawLength.QuadPart; -} +/* If the cache is the only one holding a reference to the segment, then it's fine to resize */ +Ret = TRUE; } else { -Ret = TRUE; +/* We can't shrink, but we can extend */ +Ret = NewFileSize->QuadPart >= Segment->RawLength.QuadPart; } - -MiReleasePfnLock(OldIrql); +MmUnlockSectionSegment(Segment); +MmDereferenceSegment(Segment); DPRINT("FIXME: didn't check for outstanding write probes\n");
[ros-diffs] [reactos] 85/100: [NTOS:CC] Be sure to flush the whole file in CcFlushCache
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0bf98663b198696a936dc6f8c4921db282f4bee commit d0bf98663b198696a936dc6f8c4921db282f4bee Author: Jérôme Gardou AuthorDate: Wed Jan 27 15:29:57 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Be sure to flush the whole file in CcFlushCache --- ntoskrnl/cc/view.c | 44 +++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 06ec86788a9..591168eeba0 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -906,12 +906,19 @@ CcFlushCache ( CCTRACE(CC_API_DEBUG, "SectionObjectPointers=%p FileOffset=0x%I64X Length=%lu\n", SectionObjectPointers, FileOffset ? FileOffset->QuadPart : 0LL, Length); -if (!SectionObjectPointers || !SectionObjectPointers->SharedCacheMap) +if (!SectionObjectPointers) { Status = STATUS_INVALID_PARAMETER; goto quit; } +if (!SectionObjectPointers->SharedCacheMap) +{ +/* Forward this to Mm */ +MmFlushSegment(SectionObjectPointers, FileOffset, Length, IoStatus); +return; +} + SharedCacheMap = SectionObjectPointers->SharedCacheMap; ASSERT(SharedCacheMap); if (FileOffset) @@ -934,8 +941,14 @@ CcFlushCache ( IoStatus->Information = 0; } +/* + * We flush the VACBs that we find here. + * If there is no (dirty) VACB, it doesn't mean that there is no data to flush, so we call Mm to be sure. + * This is suboptimal, but this is due to the lack of granularity of how we track dirty cache data + */ while (FlushStart < FlushEnd) { +BOOLEAN DirtyVacb = FALSE; PROS_VACB vacb = CcRosLookupVacb(SharedCacheMap, FlushStart); if (vacb != NULL) @@ -947,6 +960,7 @@ CcFlushCache ( { goto quit; } +DirtyVacb = TRUE; } CcRosReleaseVacb(SharedCacheMap, vacb, FALSE, FALSE); @@ -955,11 +969,39 @@ CcFlushCache ( IoStatus->Information += VACB_MAPPING_GRANULARITY; } +if (!DirtyVacb) +{ +IO_STATUS_BLOCK MmIosb; +LARGE_INTEGER MmOffset; + +MmOffset.QuadPart = FlushStart; + +if (FlushEnd - (FlushEnd % VACB_MAPPING_GRANULARITY) <= FlushStart) +{ +/* The whole range fits within a VACB chunk. */ +Status = MmFlushSegment(SectionObjectPointers, , FlushEnd - FlushStart, ); +} +else +{ +ULONG MmLength = VACB_MAPPING_GRANULARITY - (FlushStart % VACB_MAPPING_GRANULARITY); +Status = MmFlushSegment(SectionObjectPointers, , MmLength, ); +} + +if (!NT_SUCCESS(Status)) +goto quit; + +if (IoStatus) +IoStatus->Information += MmIosb.Information; +} + if (!NT_SUCCESS(RtlLongLongAdd(FlushStart, VACB_MAPPING_GRANULARITY, ))) { /* We're at the end of file ! */ break; } + +/* Round down to next VACB start now */ +FlushStart -= FlushStart % VACB_MAPPING_GRANULARITY; } quit:
[ros-diffs] [reactos] 15/100: [NTOSKRNL] Get rid of MM_ROS_SECTION_OBJECT
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b7d988ae5b4948b0ab4be8a094c3b5536fdd187c commit b7d988ae5b4948b0ab4be8a094c3b5536fdd187c Author: Jérôme Gardou AuthorDate: Mon Oct 26 10:31:46 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Get rid of MM_ROS_SECTION_OBJECT --- ntoskrnl/cache/newcc.h | 2 +- ntoskrnl/cache/section/newmm.h | 4 +-- ntoskrnl/include/internal/mm.h | 7 +--- ntoskrnl/mm/ARM3/section.c | 10 ++ ntoskrnl/mm/section.c | 74 -- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/ntoskrnl/cache/newcc.h b/ntoskrnl/cache/newcc.h index adbf1c5d926..8768d7aebd2 100644 --- a/ntoskrnl/cache/newcc.h +++ b/ntoskrnl/cache/newcc.h @@ -6,7 +6,7 @@ typedef struct _NOCC_BCB PUBLIC_BCB Bcb; struct _NOCC_CACHE_MAP *Map; -PROS_SECTION_OBJECT SectionObject; +PSECTION SectionObject; LARGE_INTEGER FileOffset; ULONG Length; PVOID BaseAddress; diff --git a/ntoskrnl/cache/section/newmm.h b/ntoskrnl/cache/section/newmm.h index d5f9998993c..edff99f3d85 100644 --- a/ntoskrnl/cache/section/newmm.h +++ b/ntoskrnl/cache/section/newmm.h @@ -96,7 +96,7 @@ typedef struct _MM_REQUIRED_RESOURCES NTSTATUS NTAPI -MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, +MmCreateCacheSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, @@ -386,7 +386,7 @@ MiSwapInSectionPage(PMMSUPPORT AddressSpace, NTSTATUS NTAPI -MmExtendCacheSection(PROS_SECTION_OBJECT Section, +MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile); diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 74cfcf7f11e..a8536c3d786 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -199,11 +199,6 @@ typedef struct _MM_IMAGE_SECTION_OBJECT PMM_SECTION_SEGMENT Segments; } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT; -typedef struct _ROS_SECTION_OBJECT -{ -SECTION; -} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; - #define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT) #define MA_GetEndingAddress(_MemoryArea) (((_MemoryArea)->VadNode.EndingVpn + 1) << PAGE_SHIFT) @@ -219,7 +214,7 @@ typedef struct _MEMORY_AREA struct { -PROS_SECTION_OBJECT Section; +PSECTION Section; LARGE_INTEGER ViewOffset; PMM_SECTION_SEGMENT Segment; LIST_ENTRY RegionListHead; diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index a91cfe2ed4a..73c0e3050aa 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1655,14 +1655,12 @@ MiGetFileObjectForSectionAddress( if (Vad->u.VadFlags.Spare != 0) { PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad; -PROS_SECTION_OBJECT Section; /* Check if it's a section view (RosMm section) */ if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ -Section = MemoryArea->SectionData.Section; -*FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; +*FileObject = MemoryArea->SectionData.Segment->FileObject; } else { @@ -1732,14 +1730,12 @@ MiGetFileObjectForVad( if (Vad->u.VadFlags.Spare != 0) { PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad; -PROS_SECTION_OBJECT Section; /* Check if it's a section view (RosMm section) */ if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ -Section = MemoryArea->SectionData.Section; -FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; +FileObject = MemoryArea->SectionData.Segment->FileObject; } else { @@ -3840,7 +3836,7 @@ NtExtendSection(IN HANDLE SectionHandle, IN OUT PLARGE_INTEGER NewMaximumSize) { LARGE_INTEGER SafeNewMaximumSize; -PROS_SECTION_OBJECT Section; +PSECTION Section; NTSTATUS Status; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index b975433e271..f43811e9f50 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -138,7 +138,7 @@ C_ASSERT(PEFMT_FIELDS_EQUAL(IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64, Si typedef struct { -PROS_SECTION_OBJECT Section; +PSECTION Section; PMM_SECTION_SEGMENT Segment; LARGE_INTEGER Offset; BOOLEAN WasDirty; @@ -899,7 +899,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT
[ros-diffs] [reactos] 19/100: [NTOS/MM] Introduce MmMapViewInSystemSpaceEx
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f1631b44e120f2c6319fb4d4b113b0a43336b413 commit f1631b44e120f2c6319fb4d4b113b0a43336b413 Author: Jérôme Gardou AuthorDate: Tue Oct 27 17:36:18 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Introduce MmMapViewInSystemSpaceEx --- ntoskrnl/include/internal/mm.h | 10 + ntoskrnl/mm/ARM3/section.c | 38 +++ ntoskrnl/mm/section.c | 51 ++ 3 files changed, 71 insertions(+), 28 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index a8536c3d786..662f49c9bd7 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -1313,6 +1313,16 @@ VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject); +/* Exported from NT 6.2 Onward. We keep it internal. */ +NTSTATUS +NTAPI +MmMapViewInSystemSpaceEx ( +_In_ PVOID Section, +_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase, +_Inout_ PSIZE_T ViewSize, +_Inout_ PLARGE_INTEGER SectionOffset +); + /* sysldr.c **/ VOID diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 511f11a5101..938a08d6037 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -416,12 +416,16 @@ NTSTATUS NTAPI MiAddMappedPtes(IN PMMPTE FirstPte, IN PFN_NUMBER PteCount, -IN PCONTROL_AREA ControlArea) +IN PCONTROL_AREA ControlArea, +IN PLARGE_INTEGER SectionOffset) { MMPTE TempPte; PMMPTE PointerPte, ProtoPte, LastProtoPte, LastPte; PSUBSECTION Subsection; +/* Mapping at offset not supported yet */ +ASSERT(SectionOffset->QuadPart == 0); + /* ARM3 doesn't support this yet */ ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0); ASSERT(ControlArea->u.Flags.Rom == 0); @@ -1052,11 +1056,13 @@ NTAPI MiMapViewInSystemSpace(IN PVOID Section, IN PMMSESSION Session, OUT PVOID *MappedBase, - IN OUT PSIZE_T ViewSize) + IN OUT PSIZE_T ViewSize, + IN PLARGE_INTEGER SectionOffset) { PVOID Base; PCONTROL_AREA ControlArea; -ULONG Buckets, SectionSize; +ULONG Buckets; +LONGLONG SectionSize; NTSTATUS Status; PAGED_CODE(); @@ -1073,13 +1079,23 @@ MiMapViewInSystemSpace(IN PVOID Section, ASSERT(NT_SUCCESS(Status)); /* Get the section size at creation time */ -SectionSize = ((PSECTION)Section)->SizeOfSection.LowPart; +SectionSize = ((PSECTION)Section)->SizeOfSection.QuadPart; -/* If the caller didn't specify a view size, assume the whole section */ -if (!(*ViewSize)) *ViewSize = SectionSize; +/* If the caller didn't specify a view size, assume until the end of the section */ +if (!(*ViewSize)) +{ +/* Check for overflow first */ +if ((SectionSize - SectionOffset->QuadPart) > SIZE_T_MAX) +{ +DPRINT1("Section end is too far away from the specified offset.\n"); +MiDereferenceControlArea(ControlArea); +return STATUS_INVALID_VIEW_SIZE; +} +*ViewSize = SectionSize - SectionOffset->QuadPart; +} /* Check if the caller wanted a larger section than the view */ -if (*ViewSize > SectionSize) +if (SectionOffset->QuadPart + *ViewSize > SectionSize) { /* Fail */ DPRINT1("View is too large\n"); @@ -1129,7 +1145,8 @@ MiMapViewInSystemSpace(IN PVOID Section, /* Create the actual prototype PTEs for this mapping */ Status = MiAddMappedPtes(MiAddressToPte(Base), BYTES_TO_PAGES(*ViewSize), - ControlArea); + ControlArea, + SectionOffset); ASSERT(NT_SUCCESS(Status)); /* Return the base adress of the mapping and success */ @@ -3016,6 +3033,7 @@ MmMapViewInSessionSpace(IN PVOID Section, IN OUT PSIZE_T ViewSize) { PAGED_CODE(); +LARGE_INTEGER SectionOffset; // HACK if (MiIsRosSectionObject(Section)) @@ -3032,10 +3050,12 @@ MmMapViewInSessionSpace(IN PVOID Section, /* Use the system space API, but with the session view instead */ ASSERT(MmIsAddressValid(MmSessionSpace) == TRUE); +SectionOffset.QuadPart = 0; return MiMapViewInSystemSpace(Section, >Session, MappedBase, - ViewSize); + ViewSize, + ); } /* diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 04cba04d612..fc2c1a3e904 100644 --- a/ntoskrnl
[ros-diffs] [reactos] 17/100: [NTOSKRNL/MM] Fix a few wine tests
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c3bd70cfd15772877629fd53df547402cde572f6 commit c3bd70cfd15772877629fd53df547402cde572f6 Author: Jérôme Gardou AuthorDate: Mon Oct 26 12:19:18 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL/MM] Fix a few wine tests --- ntoskrnl/mm/section.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 5dd758f865d..f65c5c1ff64 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4302,13 +4302,22 @@ NtQuerySection( if (Section->u.Flags.Image) { -Sbi.BaseAddress = 0; -Sbi.Size.QuadPart = 0; +if (MiIsRosSectionObject(Section)) +{ +PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); +Sbi.BaseAddress = 0; +Sbi.Size.QuadPart = ImageSectionObject->ImageInformation.ImageFileSize; +} +else +{ +/* Not supported yet */ +ASSERT(FALSE); +} } else if (MiIsRosSectionObject(Section)) { Sbi.BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; -Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; +Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->RawLength.QuadPart; } else {
[ros-diffs] [reactos] 16/100: [NTOSKRNL/MM] Reduce use of MiIsRosSectionObject
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4abda863ce273a58ddcd97ecf48ab142b2b11c63 commit 4abda863ce273a58ddcd97ecf48ab142b2b11c63 Author: Jérôme Gardou AuthorDate: Mon Oct 26 11:23:42 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL/MM] Reduce use of MiIsRosSectionObject --- ntoskrnl/mm/ARM3/section.c | 5 +- ntoskrnl/mm/section.c | 157 ++--- 2 files changed, 64 insertions(+), 98 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 73c0e3050aa..511f11a5101 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -3716,7 +3716,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, return Status; } -if (MiIsRosSectionObject(Section) && Section->u.Flags.PhysicalMemory) +if (Section->u.Flags.PhysicalMemory) { if (PreviousMode == UserMode && SafeSectionOffset.QuadPart + SafeViewSize > MmHighestPhysicalPage << PAGE_SHIFT) @@ -3764,8 +3764,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, if (NT_SUCCESS(Status)) { /* Check if this is an image for the current process */ -if (MiIsRosSectionObject(Section) && -(Section->u.Flags.Image) && +if ((Section->u.Flags.Image) && (Process == PsGetCurrentProcess()) && (Status != STATUS_IMAGE_NOT_AT_BASE)) { diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index f43811e9f50..5dd758f865d 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4279,131 +4279,98 @@ NtQuerySection( return Status; } -if (MiIsRosSectionObject(Section)) +switch(SectionInformationClass) { -switch (SectionInformationClass) +case SectionBasicInformation: { -case SectionBasicInformation: -{ -PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation; +SECTION_BASIC_INFORMATION Sbi; -_SEH2_TRY -{ -Sbi->Attributes = 0; -if (Section->u.Flags.Image) -Sbi->Attributes |= SEC_IMAGE; -if (Section->u.Flags.File) -Sbi->Attributes |= SEC_FILE; -if (Section->u.Flags.NoChange) -Sbi->Attributes |= SEC_NO_CHANGE; - -if (Section->u.Flags.Image) -{ -Sbi->BaseAddress = 0; -Sbi->Size.QuadPart = 0; -} -else -{ -Sbi->BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; -Sbi->Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; -} +Sbi.Size = Section->SizeOfSection; +Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn; -if (ResultLength != NULL) -{ -*ResultLength = sizeof(SECTION_BASIC_INFORMATION); -} -Status = STATUS_SUCCESS; -} -_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) -{ -Status = _SEH2_GetExceptionCode(); -} -_SEH2_END; +Sbi.Attributes = 0; +if (Section->u.Flags.Commit) +Sbi.Attributes |= SEC_COMMIT; +if (Section->u.Flags.Reserve) +Sbi.Attributes |= SEC_RESERVE; +if (Section->u.Flags.File) +Sbi.Attributes |= SEC_FILE; +if (Section->u.Flags.Image) +Sbi.Attributes |= SEC_IMAGE; -break; +/* FIXME : Complete/test the list of flags passed back from NtCreateSection */ + +if (Section->u.Flags.Image) +{ +Sbi.BaseAddress = 0; +Sbi.Size.QuadPart = 0; +} +else if (MiIsRosSectionObject(Section)) +{ +Sbi.BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; +Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; +} +else +{ +DPRINT1("Unimplemented code path!"); } -case SectionImageInformation: +_SEH2_TRY +{ +*((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi; +if (ResultLength) +*ResultLength = sizeof(Sbi); +} +_SEH2_EXCEPT(EXCEPTION_EXECUTE
[ros-diffs] [reactos] 18/100: [NTOS/MM] Infer that the Memory Area is an image mapping from its VAD node
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4f6fd6c42b4fa712dad5cffc9522e801a38279c1 commit 4f6fd6c42b4fa712dad5cffc9522e801a38279c1 Author: Jérôme Gardou AuthorDate: Mon Oct 26 17:49:16 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOS/MM] Infer that the Memory Area is an image mapping from its VAD node --- ntoskrnl/mm/section.c | 57 +++ 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index f65c5c1ff64..04cba04d612 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -138,7 +138,7 @@ C_ASSERT(PEFMT_FIELDS_EQUAL(IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64, Si typedef struct { -PSECTION Section; +PMEMORY_AREA MemoryArea; PMM_SECTION_SEGMENT Segment; LARGE_INTEGER Offset; BOOLEAN WasDirty; @@ -899,7 +899,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, BOOLEAN NTAPI -MmUnsharePageEntrySectionSegment(PSECTION Section, +MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea, PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset, BOOLEAN Dirty, @@ -939,7 +939,7 @@ MmUnsharePageEntrySectionSegment(PSECTION Section, LARGE_INTEGER FileOffset; FileOffset.QuadPart = Offset->QuadPart + Segment->Image.FileOffset; -IsImageSection = Section->u.Flags.Image; +IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap; #endif Page = PFN_FROM_SSE(Entry); @@ -1112,7 +1112,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; RawLength = MemoryArea->SectionData.Segment->RawLength.QuadPart; FileOffset = SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset; -IsImageSection = MemoryArea->SectionData.Section->u.Flags.Image; +IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap; ASSERT(SharedCacheMap); @@ -1631,7 +1631,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, MmCreatePageFileMapping(Process, PAddress, MM_WAIT_ENTRY); MmUnlockAddressSpace(AddressSpace); -if ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart)) && Section->u.Flags.Image) +if ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart)) && (MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap)) { MI_SET_USAGE(MI_USAGE_SECTION); if (Process) MI_SET_PROCESS2(Process->ImageFileName); @@ -1812,7 +1812,6 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, PVOID Address) { PMM_SECTION_SEGMENT Segment; -PSECTION Section; PFN_NUMBER OldPage; PFN_NUMBER NewPage; NTSTATUS Status; @@ -1849,7 +1848,6 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, + MemoryArea->SectionData.ViewOffset.QuadPart; Segment = MemoryArea->SectionData.Segment; -Section = MemoryArea->SectionData.Section; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), >SectionData.RegionListHead, Address, NULL); @@ -1907,7 +1905,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, DPRINT("Swapping page (Old %x New %x)\n", OldPage, NewPage); MmDeleteVirtualMapping(Process, PAddress, NULL, NULL); MmDeleteRmap(OldPage, Process, PAddress); -MmUnsharePageEntrySectionSegment(Section, Segment, , FALSE, FALSE, NULL); +MmUnsharePageEntrySectionSegment(MemoryArea, Segment, , FALSE, FALSE, NULL); MmUnlockSectionSegment(Segment); /* @@ -1955,7 +1953,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address) if (!PageOutContext->Private) { MmLockSectionSegment(PageOutContext->Segment); -MmUnsharePageEntrySectionSegment(PageOutContext->Section, +MmUnsharePageEntrySectionSegment(PageOutContext->MemoryArea, PageOutContext->Segment, >Offset, PageOutContext->WasDirty, @@ -2000,7 +1998,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, * Get the segment and section. */ Context.Segment = MemoryArea->SectionData.Segment; -Context.Section = MemoryArea->SectionData.Section; +Context.MemoryArea = MemoryArea; Context.SectionEntry = Entry; Context.CallingProcess = Process; @@ -2013,7 +2011,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, #ifndef NEWCC FileOffset = Context.Offset.QuadPart + Context.Segment->Image.FileOffset; -IsImageSection = Context.Section->u.Flag
[ros-diffs] [reactos] 76/100: [NTOS:CC][NTOS:MM] Try respecting ValidDataLength
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5949d5095d95d1ab5118f24f00193ded2670b825 commit 5949d5095d95d1ab5118f24f00193ded2670b825 Author: Jérôme Gardou AuthorDate: Tue Jan 5 18:39:55 2021 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC][NTOS:MM] Try respecting ValidDataLength --- ntoskrnl/cc/copy.c | 38 -- ntoskrnl/cc/fs.c | 1 + ntoskrnl/cc/pin.c | 5 + ntoskrnl/cc/view.c | 1 + ntoskrnl/include/internal/cc.h | 1 + ntoskrnl/mm/section.c | 15 --- 6 files changed, 56 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 677ab00dd2f..8ed24f2bd92 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -504,6 +504,24 @@ CcCopyRead ( CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < ReadEnd) { +if (CurrentOffset >= SharedCacheMap->ValidDataLength.QuadPart) +{ +DPRINT1("Zeroing buffer because we are beyond the VDL.\n"); +/* We are beyond what is valid. Just zero this out */ +_SEH2_TRY +{ +RtlZeroMemory(Buffer, Length); +} + _SEH2_EXCEPT(CcpCheckInvalidUserBuffer(_SEH2_GetExceptionInformation(), Buffer, Length)) +{ +ExRaiseStatus(STATUS_INVALID_USER_BUFFER); +} +_SEH2_END; + +ReadLength += Length; +break; +} + Status = CcRosGetVacb(SharedCacheMap, CurrentOffset, ); if (!NT_SUCCESS(Status)) { @@ -598,7 +616,7 @@ CcCopyWrite ( PROS_SHARED_CACHE_MAP SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; NTSTATUS Status; LONGLONG CurrentOffset; -LONGLONG WriteEnd = FileOffset->QuadPart + Length; +LONGLONG WriteEnd; CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d Buffer=%p\n", FileObject, FileOffset->QuadPart, Length, Wait, Buffer); @@ -610,7 +628,11 @@ CcCopyWrite ( if (!SharedCacheMap) return FALSE; -ASSERT((FileOffset->QuadPart + Length) <= SharedCacheMap->SectionSize.QuadPart); +Status = RtlLongLongAdd(FileOffset->QuadPart, Length, ); +if (!NT_SUCCESS(Status)) +ExRaiseStatus(Status); + +ASSERT(WriteEnd <= SharedCacheMap->SectionSize.QuadPart); CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < WriteEnd) @@ -662,6 +684,10 @@ CcCopyWrite ( if (FileObject->Flags & FO_WRITE_THROUGH) CcFlushCache(FileObject->SectionObjectPointer, FileOffset, Length, NULL); +/* Update VDL */ +if (WriteEnd > SharedCacheMap->ValidDataLength.QuadPart) +SharedCacheMap->ValidDataLength.QuadPart = WriteEnd; + return TRUE; } @@ -871,6 +897,14 @@ CcZeroData ( return TRUE; } +/* See if we should simply truncate the valid data length */ +if ((StartOffset->QuadPart < SharedCacheMap->ValidDataLength.QuadPart) && (EndOffset->QuadPart > SharedCacheMap->ValidDataLength.QuadPart)) +{ +DPRINT1("Truncating VDL.\n"); +SharedCacheMap->ValidDataLength = *StartOffset; +return TRUE; +} + ASSERT(EndOffset->QuadPart <= SharedCacheMap->SectionSize.QuadPart); while(WriteOffset.QuadPart < EndOffset->QuadPart) diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c index 7a4c8cf4df2..161833d14e2 100644 --- a/ntoskrnl/cc/fs.c +++ b/ntoskrnl/cc/fs.c @@ -297,6 +297,7 @@ CcSetFileSizes ( OldSectionSize = SharedCacheMap->SectionSize; SharedCacheMap->SectionSize = FileSizes->AllocationSize; SharedCacheMap->FileSize = FileSizes->FileSize; +SharedCacheMap->ValidDataLength = FileSizes->ValidDataLength; KeReleaseSpinLock(>CacheMapLock, OldIrql); if (FileSizes->AllocationSize.QuadPart < OldSectionSize.QuadPart) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index ae62d2da0bc..07bfd63241c 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -543,6 +543,7 @@ CcSetDirtyPinnedData ( IN PLARGE_INTEGER Lsn) { PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); +PROS_SHARED_CACHE_MAP SharedCacheMap = iBcb->Vacb->SharedCacheMap; CCTRACE(CC_API_DEBUG, "Bcb=%p Lsn=%p\n", Bcb, Lsn); @@ -555,6 +556,10 @@ CcSetDirtyPinnedData ( { CcRosMarkDirtyVacb(iBcb->Vacb); } + +/* Update VDL */ +if (SharedCacheMap->ValidDataLength.QuadPart < (iBcb->PFCB.MappedFileOffset.QuadPart + iBcb->PFCB.MappedLength)) +SharedCacheMap->ValidDataLength.QuadPart = iBcb->PFCB.MappedFileOffset.QuadPart + iBcb->PFCB.MappedLength; } diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 21fd37
[ros-diffs] [reactos] 69/100: [NTOS:CC] Simplify CcRosDeleteFileCache
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33cde2831225c26f4b7afed69dc1f56e4a6ab32b commit 33cde2831225c26f4b7afed69dc1f56e4a6ab32b Author: Jérôme Gardou AuthorDate: Wed Dec 30 10:53:31 2020 +0100 Commit: Jérôme Gardou CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Simplify CcRosDeleteFileCache --- ntoskrnl/cc/view.c | 147 + 1 file changed, 68 insertions(+), 79 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 40413a91601..b6b7ec57560 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -974,105 +974,94 @@ CcRosDeleteFileCache ( */ { PLIST_ENTRY current_entry; -PROS_VACB current; -LIST_ENTRY FreeList; ASSERT(SharedCacheMap); +ASSERT(SharedCacheMap == FileObject->SectionObjectPointer->SharedCacheMap); +ASSERT(SharedCacheMap->OpenCount == 0); -SharedCacheMap->OpenCount++; -KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); +/* Remove all VACBs from the global lists */ +KeAcquireSpinLockAtDpcLevel(>CacheMapLock); +current_entry = SharedCacheMap->CacheMapVacbListHead.Flink; +while (current_entry != >CacheMapVacbListHead) +{ +PROS_VACB Vacb = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); -CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL); +RemoveEntryList(>VacbLruListEntry); +InitializeListHead(>VacbLruListEntry); -*OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); -SharedCacheMap->OpenCount--; -if (SharedCacheMap->OpenCount == 0) +if (Vacb->Dirty) +{ +CcRosUnmarkDirtyVacb(Vacb, FALSE); +/* Mark it as dirty again so we know that we have to flush before freeing it */ +Vacb->Dirty = TRUE; +} + +current_entry = current_entry->Flink; +} + +/* Make sure there is no trace anymore of this map */ +FileObject->SectionObjectPointer->SharedCacheMap = NULL; +RemoveEntryList(>SharedCacheMapLinks); + +KeReleaseSpinLockFromDpcLevel(>CacheMapLock); +KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); + +/* Now that we're out of the locks, free everything for real */ +while (!IsListEmpty(>CacheMapVacbListHead)) { -FileObject->SectionObjectPointer->SharedCacheMap = NULL; +PROS_VACB Vacb = CONTAINING_RECORD(RemoveHeadList(>CacheMapVacbListHead), ROS_VACB, CacheMapVacbListEntry); +ULONG RefCount; -/* - * Release all VACBs - */ -InitializeListHead(); -KeAcquireSpinLockAtDpcLevel(>CacheMapLock); -while (!IsListEmpty(>CacheMapVacbListHead)) +InitializeListHead(>CacheMapVacbListEntry); + +/* Flush to disk, if needed */ +if (Vacb->Dirty) { -current_entry = RemoveTailList(>CacheMapVacbListHead); -KeReleaseSpinLockFromDpcLevel(>CacheMapLock); +SIZE_T FlushSize = min(VACB_MAPPING_GRANULARITY, Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart); +IO_STATUS_BLOCK Iosb; +NTSTATUS Status; -current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); -RemoveEntryList(>VacbLruListEntry); -InitializeListHead(>VacbLruListEntry); -if (current->Dirty) -{ -KeAcquireSpinLockAtDpcLevel(>CacheMapLock); -CcRosUnmarkDirtyVacb(current, FALSE); -KeReleaseSpinLockFromDpcLevel(>CacheMapLock); -DPRINT1("Freeing dirty VACB\n"); -} -if (current->MappedCount != 0) +Status = MmFlushVirtualMemory(NULL, >BaseAddress, , ); +if (!NT_SUCCESS(Status)) { -current->MappedCount = 0; -NT_VERIFY(CcRosVacbDecRefCount(current) > 0); -DPRINT1("Freeing mapped VACB\n"); +/* Complain. There's not much we can do */ +DPRINT1("Failed to flush VACB to disk while deleting the cache entry. Status: 0x%08x\n", Status); } -InsertHeadList(, >CacheMapVacbListEntry); - -KeAcquireSpinLockAtDpcLevel(>CacheMapLock); +Vacb->Dirty = FALSE; } -#if DBG -SharedCacheMap->Trace = FALSE; -#endif -KeReleaseSpinLockFromDpcLevel(>CacheMapLock); -KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); -if(SharedCacheMap->Section) -ObDereferenceObject(SharedCacheMap->Section); -ObDereferenceObject(SharedCacheMap->FileObject); - -while (!IsListEmpty()) -{ -ULONG Refs; - -current_entry = RemoveTailList(); -current = CONTAINING_RECOR