Skip to content

[MSVCRT] Import msvcrt from wine-10.0#8204

Merged
tkreuzer merged 33 commits intoreactos:masterfrom
tkreuzer:wine/msvcrt
Dec 30, 2025
Merged

[MSVCRT] Import msvcrt from wine-10.0#8204
tkreuzer merged 33 commits intoreactos:masterfrom
tkreuzer:wine/msvcrt

Conversation

@tkreuzer
Copy link
Copy Markdown
Contributor

@tkreuzer tkreuzer commented Jun 30, 2025

Purpose

Import msvcrt from wine-10.0.
This fixes (roughly) 7574 out of 25517 test failures, i.e. 29.6% of all failures.

Proposed changes

  • Import msvcrt from wine-10.0
  • Make it compile with MSVC
  • Fix/improve exports a bit
  • Replace a few functions with our own ones, which are better (e.g. vcruntime and math)
  • Fix a few bugs (like the totally broken _LDOUBLE stuff)
  • Rewrite system/_wsystem (because the wine ones are quite broken)

Testbot runs (Filled in by Devs)

Crashes fixed (x64)

  • gdiplus:image
  • msvcrt:_finite
  • msvcrt:_isnan
  • oleaut32:vartest

Fixed tests

Test KVM x86 KVM x64
advapi32:lsa -1 -
atl:CString -8
gdi32:metafile -6 -6
kernel32:locale -10
msvcrt:cpp -38 -38
msvcrt:crtdata -4 (todos removed) -4 (todos removed)
msvcrt:data -1 -1
msvcrt:dir -11 -11
msvcrt:environ -6 -4
msvcrt:file -35 -35
msvcrt:ieee -6
msvcrt:locale -5 -5
msvcrt:misc -14 -51
msvcrt:printf -64 -64
msvcrt:scanf -15 -15
msvcrt:signal -1 -1
msvcrt:sprintf +1 -3
msvcrt:string -7301 -7305
msvcrt:strlen -1
msvcrt:time -57 -54
msvcrt:wctomb -2 -2
msvcrt:_mbsncmp -4
msvcrt:_mbsstr -5 -5
msvcrt:_stricmp -5 -2
msvcrt:_strlwr -1 -1
msvcrt:_strnicmp -2 -2
msvcrt:_strupr -1 -1
msvcrt:_wcsicmp -2 -2
msvcrt:_wcslwr -1 -1
msvcrt:_wcsnicmp -2 -2
msvcrt:_wcsupr -1 -1
msxml3:domdoc -3 -3
ntdll:strlen -1

Aditional test failures

Test KVM x86 KVM x64 Comment
kernel32:codepage +1 +1 Happens with Win msvcrt-dll, too
kernel32:MultiByteToWideChar +1 +1 Happens with Win msvcrt-dll, too
kernel32:sync - +2
msvcrt:sprintf +1 Test does not cause exception as on Windows
msvcrt:_mbsnbcat +3 +3 Test does not cause exception as on Windows + 1 actual regression
msvcrt:_mbsncat +2 +2
msvcrt:_vsnprintf +2 +2 Test does not cause exception as on Windows
msvcrt:_vsnwprintf +2 +2 Test does not cause exception as on Windows
msvcrt:_wpgmptr +1 +1 Test marked as todo
oleaut32:vartype +1 +1 Test succeeded inside todo block
win32u:NtUserSystemParametersInfo +1 Probably a test problem

Probably random

Test KVM x86 KVM x64
user32:cursoricon -1
user32:sysparams -1

New test failures

  • kernel32:codepage - New failure is codepage.c:442: Test failed: GetLastError() is 0 - this failure also happens, when replacing msvcrt.dll with the one from Windows 2003
  • kernel32:MultiByteToWideChar - New failure is MultiByteToWideChar.c:280: Test failed: Line 148: Wrong last error. Expected 48815, got 0 - this failure also happens, when replacing msvcrt.dll with the one from Windows 2003
  • oleaut32:vartype - New failure is vartype.c:4602: Test succeeded inside todo block: string different

@tkreuzer tkreuzer self-assigned this Jun 30, 2025
@binarymaster binarymaster added the 3rd party sync Updating 3rd party components, such as Wine and others label Jun 30, 2025
@tkreuzer tkreuzer force-pushed the wine/msvcrt branch 7 times, most recently from a43c2bd to 4c73cfc Compare July 1, 2025 15:27
@github-actions github-actions bot added ROSTESTS Label for ROS testcases PRs. kernel&hal Code changes to the ntoskrnl and HAL Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs. labels Aug 5, 2025
@github-actions github-actions bot removed kernel&hal Code changes to the ntoskrnl and HAL Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs. labels Aug 22, 2025
@tkreuzer tkreuzer force-pushed the wine/msvcrt branch 3 times, most recently from feec79a to 4856cc5 Compare September 1, 2025 19:43
@github-actions github-actions bot added the kernel&hal Code changes to the ntoskrnl and HAL label Nov 2, 2025
@tkreuzer tkreuzer force-pushed the wine/msvcrt branch 2 times, most recently from 989105c to e79d0aa Compare November 8, 2025 13:00
@github-actions github-actions bot removed the kernel&hal Code changes to the ntoskrnl and HAL label Nov 8, 2025
@tkreuzer tkreuzer force-pushed the wine/msvcrt branch 3 times, most recently from bec6cf7 to c124a02 Compare November 21, 2025 10:46
@github-actions github-actions bot added the Win32SS For Win32 subsystem (Win32k, GDI/USER DLLs, etc.) related components PRs. label Nov 21, 2025
Bypass the wine wrappers, and comment out _fpclass and ldexp in math.c, because our own functions work better.
- Add _mbcasemap, __p__mbcasemap, _fileinfo, __p__fileinfo, _get_fileinfo, _set_fileinfo, _get_winver
- Add strtoll and strtoull import symbols
- Add CrtDbgReport*
- Enable a few stubs
Fixes crash in msvcrt_apitest:wctomb
This fixes a number of failures of cmd_winetest batch.
- Fix a quote character parsing bug in cmdline_to_argv- Implement ansi version of cmdline_to_argv
- Use cmdline_to_argv(A) in __(w)getmainargs to reparse the command line from _(w)cmdln
Fixes 30 failures in msvcrt_apitest:__getmainargs
Wine msvcrt behaves like Vista+ here.
Also disable related static_crt tests, because it isn't even well defined how they should behave and what to compare it to.
This is a hack, which was used before and is still needed, because wine code uses CRT allocation functions, even when the process heap should be used.
The new implementation is closely based on UCRT code and passes all tests for Vista+.
@tkreuzer tkreuzer merged commit 19450a9 into reactos:master Dec 30, 2025
34 checks passed
@tkreuzer tkreuzer deleted the wine/msvcrt branch December 30, 2025 10:57

.code

PUBLIC __inp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why these functions would be needed in msvcrt. It's not as if IO ports accesses were allowed to user mode win32 apps on NT systems...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3rd party sync Updating 3rd party components, such as Wine and others ROSTESTS Label for ROS testcases PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants