ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2023
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
79 discussions
Start a n
N
ew thread
[reactos] 02/02: [KMTESTS:KE] Correctly handle MP builds in KeSpinLock test.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f1fff696bbc49163eaa7…
commit 5f1fff696bbc49163eaa709c8e53ae507cc2c196 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sat Jan 28 21:54:05 2023 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sat Jan 28 23:26:30 2023 -0500 [KMTESTS:KE] Correctly handle MP builds in KeSpinLock test. --- modules/rostests/kmtests/ntos_ke/KeSpinLock.c | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/rostests/kmtests/ntos_ke/KeSpinLock.c b/modules/rostests/kmtests/ntos_ke/KeSpinLock.c index 9b16648573f..32f5b8ce351 100644 --- a/modules/rostests/kmtests/ntos_ke/KeSpinLock.c +++ b/modules/rostests/kmtests/ntos_ke/KeSpinLock.c @@ -1,8 +1,9 @@ /* - * PROJECT: ReactOS kernel-mode tests - * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Kernel-Mode Test Suite Spin lock test - * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + * PROJECT: ReactOS kernel-mode tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Kernel-Mode Test Suite Spin lock test + * COPYRIGHT: Copyright 2011-2023 Thomas Faber (thomas.faber(a)reactos.org) + * COPYRIGHT: Copyright 2021 Jérôme Gardou (jerome.gardou(a)reactos.org) */ #ifndef _WIN64 @@ -265,13 +266,21 @@ TestSpinLock( CheckSpinLock(SpinLock, CheckData, 0); ok_bool_true(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned"); CheckSpinLock(SpinLock, CheckData, 1); + /* A second TryToAcquire results in SPINLOCK_ALREADY_OWNED on checked builds */ if (!KmtIsCheckedBuild) { - /* SPINLOCK_ALREADY_OWNED on checked build */ - ok_bool_true(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned"); - /* even a failing acquire sets irql */ - ok_eq_uint(CheckData->Irql, CheckData->IrqlWhenAcquired); - CheckData->Irql = CheckData->OriginalIrql; + if (KmtIsMultiProcessorBuild) + { + /* In MP, this fails as you would expect */ + ok_bool_false(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned"); + } + else + { + /* In UP, this always succeeds: recursive acquires are illegal and parallel processors don't exist */ + ok_bool_true(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned"); + ok_eq_uint(CheckData->Irql, CheckData->IrqlWhenAcquired); + CheckData->Irql = CheckData->OriginalIrql; + } CheckSpinLock(SpinLock, CheckData, 1); } CheckData->Release(SpinLock, CheckData); @@ -312,7 +321,16 @@ TestSpinLock( CheckSpinLock(SpinLock, CheckData, 1); if (!KmtIsCheckedBuild) { - ok_bool_true(CheckData->TryAcquireNoRaise(SpinLock, CheckData), "TryAcquireNoRaise returned"); + if (KmtIsMultiProcessorBuild) + { + /* In MP, this fails as you would expect */ + ok_bool_false(CheckData->TryAcquireNoRaise(SpinLock, CheckData), "TryAcquireNoRaise returned"); + } + else + { + /* In UP, this always succeeds: recursive acquires are illegal and parallel processors don't exist */ + ok_bool_true(CheckData->TryAcquireNoRaise(SpinLock, CheckData), "TryAcquireNoRaise returned"); + } CheckSpinLock(SpinLock, CheckData, 1); } CheckData->ReleaseNoLower(SpinLock, CheckData);
2 years, 2 months
1
0
0
0
[reactos] 01/02: [KMTESTS:MM] Fix failures in MmMdl test on machines with 2GB of free RAM.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2f63da62e305b6609045b…
commit 2f63da62e305b6609045bf09ac0d853d610bc2fb Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sat Jan 28 19:55:19 2023 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sat Jan 28 23:17:52 2023 -0500 [KMTESTS:MM] Fix failures in MmMdl test on machines with 2GB of free RAM. --- modules/rostests/kmtests/ntos_mm/MmMdl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/rostests/kmtests/ntos_mm/MmMdl.c b/modules/rostests/kmtests/ntos_mm/MmMdl.c index 3ee201f5e0d..e84e3b2ecab 100644 --- a/modules/rostests/kmtests/ntos_mm/MmMdl.c +++ b/modules/rostests/kmtests/ntos_mm/MmMdl.c @@ -1,8 +1,9 @@ /* - * PROJECT: ReactOS kernel-mode tests - * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory - * PURPOSE: Kernel-Mode Test Suite MDL test - * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: Kernel-Mode Test Suite MDL test + * COPYRIGHT: Copyright 2015,2023 Thomas Faber (thomas.faber(a)reactos.org) + * COPYRIGHT: Copyright 2017 Pierre Schweitzer (pierre(a)reactos.org) */ #include <kmt_test.h> @@ -104,7 +105,7 @@ TestMmAllocatePagesForMdl(VOID) MmFreePagesFromMdl(Mdl); ExFreePoolWithTag(Mdl, 0); - /* try to allocate 2 GB -- should succeed but not map */ + /* try to allocate 2 GB -- should succeed (possibly with fewer pages) but not map */ Mdl = MmAllocatePagesForMdl(LowAddress, HighAddress, SkipBytes, @@ -112,12 +113,12 @@ TestMmAllocatePagesForMdl(VOID) ok(Mdl != NULL, "MmAllocatePagesForMdl failed for 2 GB\n"); if (Mdl != NULL) { - ok(MmGetMdlByteCount(Mdl) != 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl)); + ok(MmGetMdlByteCount(Mdl) <= 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl)); ok(MmGetMdlVirtualAddress(Mdl) == NULL, "Virtual address: %p\n", MmGetMdlVirtualAddress(Mdl)); ok(!(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA), "MdlFlags: %lx\n", Mdl->MdlFlags); MdlPages = MmGetMdlPfnArray(Mdl); MdlPageCount = ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(Mdl), MmGetMdlByteCount(Mdl)); - ok(MdlPageCount < 2UL * 1024 * 1024 * 1024 / PAGE_SIZE, "MdlPageCount = %lu\n", MdlPageCount); + ok(MdlPageCount <= 2UL * 1024 * 1024 * 1024 / PAGE_SIZE, "MdlPageCount = %lu\n", MdlPageCount); for (i = 0; i < MdlPageCount; i++) { if (MdlPages[i] == 0 || @@ -135,7 +136,7 @@ TestMmAllocatePagesForMdl(VOID) ok(SystemVa == NULL, "MmMapLockedPagesSpecifyCache succeeded for 2 GB\n"); if (SystemVa != NULL) MmUnmapLockedPages(SystemVa, Mdl); - ok(MmGetMdlByteCount(Mdl) != 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl)); + ok(MmGetMdlByteCount(Mdl) <= 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl)); ok(MmGetMdlVirtualAddress(Mdl) == NULL, "Virtual address: %p\n", MmGetMdlVirtualAddress(Mdl)); ok(!(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA), "MdlFlags: %lx\n", Mdl->MdlFlags); MmFreePagesFromMdl(Mdl);
2 years, 2 months
1
0
0
0
[reactos] 02/02: [BUTTERFLIES] Do not release the DC passed to OpenGL. CORE-18498
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=afb953ae4dd1ca89c66dd…
commit afb953ae4dd1ca89c66ddd602f22146803b0709d Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Jan 16 19:45:03 2023 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Fri Jan 27 22:31:37 2023 -0500 [BUTTERFLIES] Do not release the DC passed to OpenGL. CORE-18498 --- modules/rosapps/applications/screensavers/butterflies/butterflies.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/rosapps/applications/screensavers/butterflies/butterflies.c b/modules/rosapps/applications/screensavers/butterflies/butterflies.c index 4c675a757a8..6d33fd35e66 100644 --- a/modules/rosapps/applications/screensavers/butterflies/butterflies.c +++ b/modules/rosapps/applications/screensavers/butterflies/butterflies.c @@ -12,6 +12,7 @@ HINSTANCE hInstance; // Holds The Instance Of The Application GLuint texture[3]; //stores texture objects and display list +HDC hdcOpenGL; LPCTSTR registryPath = _T("Software\\Microsoft\\ScreenSavers\\Butterflies"); BOOL dRotate; @@ -136,7 +137,7 @@ HGLRC InitOGLWindow(HWND hWnd) hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); - ReleaseDC(hWnd, hDC); + hdcOpenGL = hDC; return hRC; } @@ -287,6 +288,7 @@ LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, case WM_DESTROY: wglMakeCurrent(NULL, NULL); wglDeleteContext(hRC); + ReleaseDC(hWnd, hdcOpenGL); break; }
2 years, 2 months
1
0
0
0
[reactos] 01/02: [GDI32] Fix memory leak in case of public DC. CORE-18498
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8b19b6ec5abcaf3603e14…
commit 8b19b6ec5abcaf3603e147252fa87fce998ec79e Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Jan 16 14:24:07 2023 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Fri Jan 27 22:30:35 2023 -0500 [GDI32] Fix memory leak in case of public DC. CORE-18498 --- win32ss/gdi/gdi32/objects/bitmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/gdi32/objects/bitmap.c b/win32ss/gdi/gdi32/objects/bitmap.c index 438521f69e9..b029d4ad2df 100644 --- a/win32ss/gdi/gdi32/objects/bitmap.c +++ b/win32ss/gdi/gdi32/objects/bitmap.c @@ -756,8 +756,10 @@ SetDIBitsToDevice( if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr)) { + DPRINT1("SetDIBitsToDevice called on invalid DC %p (not owned?)\n", hdc); SetLastError(ERROR_INVALID_PARAMETER); - return 0; + LinesCopied = 0; + goto Exit; } /* if ( !pDc_Attr || // DC is Public @@ -867,8 +869,10 @@ StretchDIBits( if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr)) { + DPRINT1("StretchDIBits called on invalid DC %p (not owned?)\n", hdc); SetLastError(ERROR_INVALID_PARAMETER); - return 0; + LinesCopied = 0; + goto Exit; } /* if ( !pDc_Attr || @@ -894,6 +898,7 @@ StretchDIBits( cjBmpScanSize, NULL ); } +Exit: if (pvSafeBits) RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); if (lpBitsInfo != pConvertedInfo)
2 years, 2 months
1
0
0
0
[reactos] 07/07: [WINESYNC] msvcrt: Don't fail when _aligned_offset_malloc is used with size=0.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f34e425e1a2be61db3983…
commit f34e425e1a2be61db3983a452a39bb0a69f24485 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 11:50:18 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [WINESYNC] msvcrt: Don't fail when _aligned_offset_malloc is used with size=0. wine commit id 7771552f247660acc472b4862f32c4f8426be180 by Piotr Caban <piotr(a)codeweavers.com> --- sdk/lib/crt/wine/heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 6a49988c63b..8fc3f6c37f1 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -545,7 +545,7 @@ void * CDECL _aligned_offset_malloc(MSVCRT_size_t size, MSVCRT_size_t alignment, } /* offset must be less than size */ - if (offset >= size) + if (offset && offset >= size) { *MSVCRT__errno() = MSVCRT_EINVAL; return NULL;
2 years, 2 months
1
0
0
0
[reactos] 06/07: [WINESYNC] msvcrt: Fixed strncpy_s behavior when count equals 0.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=739c9a1e77d5218bdc76a…
commit 739c9a1e77d5218bdc76a5ee942cbef24b497463 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 11:36:51 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [WINESYNC] msvcrt: Fixed strncpy_s behavior when count equals 0. wine commit id bdf9a9f9bd56354f70a7431a9682183b84353211 by Piotr Caban <piotr(a)codeweavers.com> --- sdk/lib/crt/wine/heap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index ad809de181c..6a49988c63b 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -819,8 +819,11 @@ int CDECL MSVCRT_strncpy_s(char *dest, MSVCRT_size_t numberOfElements, TRACE("(%s %lu %s %lu)\n", dest, numberOfElements, src, count); - if(!count) + if(!count) { + if(dest && numberOfElements) + *dest = 0; return 0; + } if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
2 years, 2 months
1
0
0
0
[reactos] 05/07: [CRT] Add a number of functions from wine
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c36ea58f32deabb044b33…
commit c36ea58f32deabb044b333253b60c2ab0149835c Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 11:21:03 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [CRT] Add a number of functions from wine This adds _aligned_msize, _recalloc, wmemmove_s, memcpy_s, wmemcpy_s --- sdk/lib/crt/wine/heap.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 39e2e0c44b9..ad809de181c 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -26,6 +26,7 @@ #define MSVCRT_size_t size_t #define MSVCRT_intptr_t intptr_t +#define MSVCRT_wchar_t wchar_t #define MSVCRT__HEAPBADNODE _HEAPBADNODE #define MSVCRT__HEAPOK _HEAPOK #define MSVCRT__HEAPEND _HEAPEND @@ -35,6 +36,7 @@ #define MSVCRT_EINVAL EINVAL #define MSVCRT_ENOSYS ENOSYS #define MSVCRT_ENOMEM ENOMEM +#define MSVCRT_ERANGE ERANGE #define MSVCRT__TRUNCATE _TRUNCATE #define MSVCRT__heapinfo _heapinfo #define MSVCRT__errno _errno @@ -42,6 +44,7 @@ #define MSVCRT_malloc malloc #define MSVCRT_realloc realloc #define MSVCRT_free free +#define MSVCRT_memcpy_s memcpy_s #define MSVCRT_memmove_s memmove_s #define MSVCRT_strncpy_s strncpy_s #define msvcrt_set_errno _dosmaperr @@ -394,6 +397,22 @@ MSVCRT_size_t CDECL _msize(void* mem) return size; } +/********************************************************************* + * _aligned_msize (MSVCR100.@) + */ +size_t CDECL _aligned_msize(void *p, MSVCRT_size_t alignment, MSVCRT_size_t offset) +{ + void **alloc_ptr; + + if(!MSVCRT_CHECK_PMT(p)) return -1; + + if(alignment < sizeof(void*)) + alignment = sizeof(void*); + + alloc_ptr = SAVED_PTR(p); + return _msize(*alloc_ptr)-alignment-sizeof(void*); +} + /********************************************************************* * calloc (MSVCRT.@) */ @@ -432,6 +451,31 @@ void* CDECL MSVCRT_realloc(void* ptr, MSVCRT_size_t size) return NULL; } +/********************************************************************* + * _recalloc (MSVCR100.@) + */ +void* CDECL _recalloc(void *mem, MSVCRT_size_t num, MSVCRT_size_t size) +{ + MSVCRT_size_t old_size; + void *ret; + + if(!mem) + return MSVCRT_calloc(num, size); + + size = num*size; + old_size = _msize(mem); + + ret = MSVCRT_realloc(mem, size); + if(!ret) { + *MSVCRT__errno() = MSVCRT_ENOMEM; + return NULL; + } + + if(size>old_size) + memset((BYTE*)ret+old_size, 0, size-old_size); + return ret; +} + /********************************************************************* * __p__amblksiz (MSVCRT.@) */ @@ -690,6 +734,81 @@ int CDECL MSVCRT_memmove_s(void *dest, MSVCRT_size_t numberOfElements, const voi return 0; } +/********************************************************************* + * wmemmove_s (MSVCR100.@) + */ +int CDECL wmemmove_s(MSVCRT_wchar_t *dest, MSVCRT_size_t numberOfElements, + const MSVCRT_wchar_t *src, MSVCRT_size_t count) +{ + TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count); + + if (!count) + return 0; + + /* Native does not seem to conform to 6.7.1.2.3 in + *
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1225.pdf
+ * in that it does not zero the output buffer on constraint violation. + */ + if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, MSVCRT_ERANGE)) return MSVCRT_ERANGE; + + memmove(dest, src, sizeof(MSVCRT_wchar_t)*count); + return 0; +} + +/********************************************************************* + * memcpy_s (MSVCRT.@) + */ +int CDECL MSVCRT_memcpy_s(void *dest, MSVCRT_size_t numberOfElements, const void *src, MSVCRT_size_t count) +{ + TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count); + + if(!count) + return 0; + + if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT(src != NULL)) + { + memset(dest, 0, numberOfElements); + return MSVCRT_EINVAL; + } + if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, MSVCRT_ERANGE )) + { + memset(dest, 0, numberOfElements); + return MSVCRT_ERANGE; + } + + memcpy(dest, src, count); + return 0; +} + +/********************************************************************* + * wmemcpy_s (MSVCR100.@) + */ +int CDECL wmemcpy_s(MSVCRT_wchar_t *dest, MSVCRT_size_t numberOfElements, + const MSVCRT_wchar_t *src, MSVCRT_size_t count) +{ + TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count); + + if (!count) + return 0; + + if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; + + if (!MSVCRT_CHECK_PMT(src != NULL)) { + memset(dest, 0, numberOfElements*sizeof(MSVCRT_wchar_t)); + return MSVCRT_EINVAL; + } + if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, MSVCRT_ERANGE)) { + memset(dest, 0, numberOfElements*sizeof(MSVCRT_wchar_t)); + return MSVCRT_ERANGE; + } + + memcpy(dest, src, sizeof(MSVCRT_wchar_t)*count); + return 0; +} + /********************************************************************* * strncpy_s (MSVCRT.@) */
2 years, 2 months
1
0
0
0
[reactos] 04/07: [CRT] Reduce diff
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0a52a6d714cf195eb828…
commit d0a52a6d714cf195eb828821fa537f135565d041 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 11:20:11 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [CRT] Reduce diff - use msvcrt_set_errno - MSVCRT_CHECK_PMT already sets the error. - NULL check is already in HeapFree --- sdk/lib/crt/wine/heap.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 2c3f5ffe260..39e2e0c44b9 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -44,6 +44,7 @@ #define MSVCRT_free free #define MSVCRT_memmove_s memmove_s #define MSVCRT_strncpy_s strncpy_s +#define msvcrt_set_errno _dosmaperr /* MT */ #define LOCK_HEAP _mlock( _HEAP_LOCK ) @@ -277,7 +278,7 @@ int CDECL _heapchk(void) if (!HeapValidate(heap, 0, NULL) || (sb_heap && !HeapValidate(sb_heap, 0, NULL))) { - _dosmaperr(GetLastError()); + msvcrt_set_errno(GetLastError()); return MSVCRT__HEAPBADNODE; } return MSVCRT__HEAPOK; @@ -292,7 +293,7 @@ int CDECL _heapmin(void) (sb_heap && !HeapCompact( sb_heap, 0 ))) { if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) - _dosmaperr(GetLastError()); + msvcrt_set_errno(GetLastError()); return -1; } return 0; @@ -317,7 +318,7 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) !HeapValidate( heap, 0, phe.lpData )) { UNLOCK_HEAP; - _dosmaperr(GetLastError()); + msvcrt_set_errno(GetLastError()); return MSVCRT__HEAPBADNODE; } @@ -328,7 +329,7 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) UNLOCK_HEAP; if (GetLastError() == ERROR_NO_MORE_ITEMS) return MSVCRT__HEAPEND; - _dosmaperr(GetLastError()); + msvcrt_set_errno(GetLastError()); if (!phe.lpData) return MSVCRT__HEAPBADBEGIN; return MSVCRT__HEAPBADNODE; @@ -406,7 +407,6 @@ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size) */ void CDECL MSVCRT_free(void* ptr) { - if(ptr == NULL) return; msvcrt_heap_free(ptr); } @@ -703,11 +703,9 @@ int CDECL MSVCRT_strncpy_s(char *dest, MSVCRT_size_t numberOfElements, if(!count) return 0; - if (!MSVCRT_CHECK_PMT(dest != NULL) || !MSVCRT_CHECK_PMT(src != NULL) || - !MSVCRT_CHECK_PMT(numberOfElements != 0)) { - *_errno() = EINVAL; - return EINVAL; - } + if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return MSVCRT_EINVAL; if(count!=MSVCRT__TRUNCATE && count<numberOfElements) end = count;
2 years, 2 months
1
0
0
0
[reactos] 03/07: [CRT] Use the original wine heap functions
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c47506a5f4675b4c2248e…
commit c47506a5f4675b4c2248e9874ed32072d787a8bb Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 10:30:51 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [CRT] Use the original wine heap functions --- sdk/lib/crt/misc/crt_init.c | 4 ++ sdk/lib/crt/wine/heap.c | 138 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 127 insertions(+), 15 deletions(-) diff --git a/sdk/lib/crt/misc/crt_init.c b/sdk/lib/crt/misc/crt_init.c index 6818144a8ac..dc0ae5cd94d 100644 --- a/sdk/lib/crt/misc/crt_init.c +++ b/sdk/lib/crt/misc/crt_init.c @@ -5,6 +5,7 @@ extern int BlockEnvToEnvironA(void); extern int BlockEnvToEnvironW(void); extern void FreeEnvironment(char **environment); +extern BOOL msvcrt_init_heap(void); extern void msvcrt_init_mt_locks(void); extern void msvcrt_init_io(void); @@ -34,6 +35,9 @@ crt_process_init(void) if (!msvcrt_init_tls()) return FALSE; + if (!msvcrt_init_heap()) + return FALSE; + if (BlockEnvToEnvironA() < 0) return FALSE; diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 8f31f3e30cf..2c3f5ffe260 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -56,6 +56,9 @@ ((((DWORD_PTR)((char *)ptr + alignment + sizeof(void *) + offset)) & \ ~(alignment - 1)) - offset)) +#define SB_HEAP_ALIGN 16 + +static HANDLE heap, sb_heap; typedef int (CDECL *MSVCRT_new_handler_func)(MSVCRT_size_t size); @@ -67,6 +70,78 @@ static unsigned int MSVCRT_amblksiz = 16; /* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */ static MSVCRT_size_t MSVCRT_sbh_threshold = 0; +static void* msvcrt_heap_alloc(DWORD flags, MSVCRT_size_t size) +{ + if(size < MSVCRT_sbh_threshold) + { + void *memblock, *temp, **saved; + + temp = HeapAlloc(sb_heap, flags, size+sizeof(void*)+SB_HEAP_ALIGN); + if(!temp) return NULL; + + memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0); + saved = SAVED_PTR(memblock); + *saved = temp; + return memblock; + } + + return HeapAlloc(heap, flags, size); +} + +static void* msvcrt_heap_realloc(DWORD flags, void *ptr, MSVCRT_size_t size) +{ + if(sb_heap && ptr && !HeapValidate(heap, 0, ptr)) + { + /* TODO: move data to normal heap if it exceeds sbh_threshold limit */ + void *memblock, *temp, **saved; + MSVCRT_size_t old_padding, new_padding, old_size; + + saved = SAVED_PTR(ptr); + old_padding = (char*)ptr - (char*)*saved; + old_size = HeapSize(sb_heap, 0, *saved); + if(old_size == -1) + return NULL; + old_size -= old_padding; + + temp = HeapReAlloc(sb_heap, flags, *saved, size+sizeof(void*)+SB_HEAP_ALIGN); + if(!temp) return NULL; + + memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0); + saved = SAVED_PTR(memblock); + new_padding = (char*)memblock - (char*)temp; + + if(new_padding != old_padding) + memmove(memblock, (char*)temp+old_padding, old_size>size ? size : old_size); + + *saved = temp; + return memblock; + } + + return HeapReAlloc(heap, flags, ptr, size); +} + +static BOOL msvcrt_heap_free(void *ptr) +{ + if(sb_heap && ptr && !HeapValidate(heap, 0, ptr)) + { + void **saved = SAVED_PTR(ptr); + return HeapFree(sb_heap, 0, *saved); + } + + return HeapFree(heap, 0, ptr); +} + +static MSVCRT_size_t msvcrt_heap_size(void *ptr) +{ + if(sb_heap && ptr && !HeapValidate(heap, 0, ptr)) + { + void **saved = SAVED_PTR(ptr); + return HeapSize(sb_heap, 0, *saved); + } + + return HeapSize(heap, 0, ptr); +} + /********************************************************************* * ??2@YAPAXI@Z (MSVCRT.@) */ @@ -78,7 +153,7 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size) do { - retval = HeapAlloc(GetProcessHeap(), 0, size); + retval = msvcrt_heap_alloc(0, size); if(retval) { TRACE("(%ld) returning %p\n", size, retval); @@ -117,7 +192,7 @@ void* CDECL MSVCRT_operator_new_dbg(MSVCRT_size_t size, int type, const char *fi void CDECL MSVCRT_operator_delete(void *mem) { TRACE("(%p)\n", mem); - HeapFree(GetProcessHeap(), 0, mem); + msvcrt_heap_free(mem); } @@ -191,7 +266,7 @@ int CDECL _callnewh(MSVCRT_size_t size) */ void* CDECL _expand(void* mem, MSVCRT_size_t size) { - return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size); + return msvcrt_heap_realloc(HEAP_REALLOC_IN_PLACE_ONLY, mem, size); } /********************************************************************* @@ -199,7 +274,8 @@ void* CDECL _expand(void* mem, MSVCRT_size_t size) */ int CDECL _heapchk(void) { - if (!HeapValidate( GetProcessHeap(), 0, NULL)) + if (!HeapValidate(heap, 0, NULL) || + (sb_heap && !HeapValidate(sb_heap, 0, NULL))) { _dosmaperr(GetLastError()); return MSVCRT__HEAPBADNODE; @@ -212,7 +288,8 @@ int CDECL _heapchk(void) */ int CDECL _heapmin(void) { - if (!HeapCompact( GetProcessHeap(), 0 )) + if (!HeapCompact( heap, 0 ) || + (sb_heap && !HeapCompact( sb_heap, 0 ))) { if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) _dosmaperr(GetLastError()); @@ -228,13 +305,16 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) { PROCESS_HEAP_ENTRY phe; + if (sb_heap) + FIXME("small blocks heap not supported\n"); + LOCK_HEAP; phe.lpData = next->_pentry; phe.cbData = (DWORD)next->_size; phe.wFlags = next->_useflag == MSVCRT__USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0; if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && - !HeapValidate( GetProcessHeap(), 0, phe.lpData )) + !HeapValidate( heap, 0, phe.lpData )) { UNLOCK_HEAP; _dosmaperr(GetLastError()); @@ -243,7 +323,7 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) do { - if (!HeapWalk( GetProcessHeap(), &phe )) + if (!HeapWalk( heap, &phe )) { UNLOCK_HEAP; if (GetLastError() == ERROR_NO_MORE_ITEMS) @@ -296,7 +376,7 @@ int CDECL _heapadd(void* mem, MSVCRT_size_t size) */ MSVCRT_intptr_t CDECL _get_heap_handle(void) { - return (MSVCRT_intptr_t)GetProcessHeap(); + return (MSVCRT_intptr_t)heap; } /********************************************************************* @@ -304,7 +384,7 @@ MSVCRT_intptr_t CDECL _get_heap_handle(void) */ MSVCRT_size_t CDECL _msize(void* mem) { - MSVCRT_size_t size = HeapSize(GetProcessHeap(),0,mem); + MSVCRT_size_t size = msvcrt_heap_size(mem); if (size == ~(MSVCRT_size_t)0) { WARN(":Probably called with non wine-allocated memory, ret = -1\n"); @@ -318,7 +398,7 @@ MSVCRT_size_t CDECL _msize(void* mem) */ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size) { - return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, count * size ); + return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, count*size); } /********************************************************************* @@ -327,7 +407,7 @@ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size) void CDECL MSVCRT_free(void* ptr) { if(ptr == NULL) return; - HeapFree(GetProcessHeap(),0,ptr); + msvcrt_heap_free(ptr); } /********************************************************************* @@ -335,7 +415,7 @@ void CDECL MSVCRT_free(void* ptr) */ void* CDECL MSVCRT_malloc(MSVCRT_size_t size) { - void *ret = HeapAlloc(GetProcessHeap(),0,size); + void *ret = msvcrt_heap_alloc(0, size); if (!ret) *MSVCRT__errno() = MSVCRT_ENOMEM; return ret; @@ -347,7 +427,7 @@ void* CDECL MSVCRT_malloc(MSVCRT_size_t size) void* CDECL MSVCRT_realloc(void* ptr, MSVCRT_size_t size) { if (!ptr) return MSVCRT_malloc(size); - if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, size); + if (size) return msvcrt_heap_realloc(0, ptr, size); MSVCRT_free(ptr); return NULL; } @@ -373,11 +453,22 @@ MSVCRT_size_t CDECL _get_sbh_threshold(void) */ int CDECL _set_sbh_threshold(MSVCRT_size_t threshold) { +#ifdef _WIN64 + return 0; +#else if(threshold > 1016) return 0; - else - MSVCRT_sbh_threshold = threshold; + + if(!sb_heap) + { + sb_heap = HeapCreate(0, 0, 0); + if(!sb_heap) + return 0; + } + + MSVCRT_sbh_threshold = (threshold+0xf) & ~0xf; return 1; +#endif } /********************************************************************* @@ -635,3 +726,20 @@ int CDECL MSVCRT_strncpy_s(char *dest, MSVCRT_size_t numberOfElements, dest[0] = '\0'; return MSVCRT_EINVAL; } + +BOOL msvcrt_init_heap(void) +{ +#ifdef __REACTOS__ + heap = GetProcessHeap(); +#else + heap = HeapCreate(0, 0, 0); +#endif + return heap != NULL; +} + +void msvcrt_destroy_heap(void) +{ + HeapDestroy(heap); + if(sb_heap) + HeapDestroy(sb_heap); +}
2 years, 2 months
1
0
0
0
[reactos] 02/07: [CRT] reduce diff to wine of heap code
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf40758d76c5f5130678a…
commit cf40758d76c5f5130678a3c1b2d86c3266bb58d8 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Tue Jan 10 10:33:07 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jan 24 18:53:13 2023 +0100 [CRT] reduce diff to wine of heap code No functional changes intended. --- sdk/lib/crt/wine/heap.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 43c321fb9c9..8f31f3e30cf 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -62,7 +62,7 @@ typedef int (CDECL *MSVCRT_new_handler_func)(MSVCRT_size_t size); static MSVCRT_new_handler_func MSVCRT_new_handler; static int MSVCRT_new_mode; -/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ +/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ static unsigned int MSVCRT_amblksiz = 16; /* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */ static MSVCRT_size_t MSVCRT_sbh_threshold = 0; @@ -74,6 +74,7 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size) { void *retval; int freed; + MSVCRT_new_handler_func handler; do { @@ -85,14 +86,18 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size) } LOCK_HEAP; - if(MSVCRT_new_handler) - freed = (*MSVCRT_new_handler)(size); + handler = MSVCRT_new_handler; + if(handler) + freed = (*handler)(size); else freed = 0; UNLOCK_HEAP; } while(freed); TRACE("(%ld) out of memory\n", size); +#if _MSVCR_VER >= 80 + throw_bad_alloc("bad allocation"); +#endif return NULL; } @@ -174,9 +179,11 @@ int CDECL MSVCRT__set_new_mode(int mode) */ int CDECL _callnewh(MSVCRT_size_t size) { - if(MSVCRT_new_handler) - (*MSVCRT_new_handler)(size); - return 0; + int ret = 0; + MSVCRT_new_handler_func handler = MSVCRT_new_handler; + if(handler) + ret = (*handler)(size) ? 1 : 0; + return ret; } /********************************************************************* @@ -285,7 +292,7 @@ int CDECL _heapadd(void* mem, MSVCRT_size_t size) } /********************************************************************* - * _heapadd (MSVCRT.@) + * _get_heap_handle (MSVCRT.@) */ MSVCRT_intptr_t CDECL _get_heap_handle(void) {
2 years, 2 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
Older →
Jump to page:
1
2
3
4
5
6
7
8
Results per page:
10
25
50
100
200