Skip to content

Commit 1106678

Browse files
committed
[MSVCRT] Add some missing exports
- 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
1 parent 4d20df2 commit 1106678

5 files changed

Lines changed: 110 additions & 20 deletions

File tree

dll/win32/msvcrt/msvcrt.spec

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@
144144
@ cdecl -arch=i386 _CItanh()
145145
@ stub -version=0x600+ _CrtCheckMemory
146146
# stub -version=0x600+ _CrtDbgBreak
147-
# stub -version=0x600+ _CrtDbgReport
148-
# stub -version=0x600+ _CrtDbgReportV
149-
# stub -version=0x600+ _CrtDbgReportW
150-
# stub -version=0x600+ _CrtDbgReportWV
147+
@ cdecl -version=0x600+ _CrtDbgReport(long str long str str)
148+
@ cdecl -version=0x600+ _CrtDbgReportV(long str long str str ptr)
149+
@ cdecl -version=0x600+ _CrtDbgReportW(long wstr long wstr wstr)
150+
@ cdecl -version=0x600+ _CrtDbgReportWV(long wstr long wstr wstr ptr)
151151
# stub -version=0x600+ _CrtDoForAllClientObjects
152152
# stub -version=0x600+ _CrtDumpMemoryLeaks
153153
# stub -version=0x600+ _CrtIsMemoryBlock
@@ -163,10 +163,10 @@
163163
# stub -version=0x600+ _CrtSetDbgBlockType
164164
# stub -version=0x600+ _CrtSetDbgFlag
165165
# stub -version=0x600+ _CrtSetDumpClient
166-
# stub -version=0x600+ _CrtSetReportFile
166+
@ cdecl -version=0x600+ _CrtSetReportFile(long ptr)
167167
# stub -version=0x600+ _CrtSetReportHook
168168
# stub -version=0x600+ _CrtSetReportHook2
169-
@ cdecl -stub -version=0x600+ _CrtSetReportMode(long long)
169+
@ cdecl -version=0x600+ _CrtSetReportMode(long long)
170170
@ stdcall _CxxThrowException(ptr ptr)
171171
@ cdecl -arch=i386 -norelay _EH_prolog()
172172
@ cdecl _Getdays()
@@ -261,10 +261,10 @@
261261
@ cdecl -arch=i386 __p__daylight()
262262
@ cdecl -arch=i386 __p__dstbias()
263263
@ cdecl -arch=i386 __p__environ()
264-
@ stub -arch=i386 __p__fileinfo()
264+
@ cdecl -arch=i386 __p__fileinfo()
265265
@ cdecl -arch=i386 __p__fmode()
266266
@ cdecl -arch=i386 __p__iob() __iob_func
267-
@ stub -arch=i386 __p__mbcasemap()
267+
@ cdecl -arch=i386 __p__mbcasemap()
268268
@ cdecl -arch=i386 __p__mbctype()
269269
@ cdecl -arch=i386 __p__osver()
270270
@ cdecl -arch=i386 __p__pctype()
@@ -397,10 +397,10 @@
397397
@ cdecl _cwait(ptr long long)
398398
@ varargs _cwprintf(wstr)
399399
@ varargs -version=0x600+ _cwprintf_l(wstr ptr)
400-
# stub -version=0x600+ _cwprintf_p(wstr)
401-
# stub -version=0x600+ _cwprintf_p_l(wstr ptr)
402-
# stub -version=0x600+ _cwprintf_s(wstr)
403-
# stub -version=0x600+ _cwprintf_s_l(wstr ptr)
400+
@ stub -version=0x600+ _cwprintf_p
401+
@ stub -version=0x600+ _cwprintf_p_l
402+
@ stub -version=0x600+ _cwprintf_s
403+
@ stub -version=0x600+ _cwprintf_s_l
404404
@ varargs _cwscanf(wstr)
405405
@ varargs -version=0x600+ _cwscanf_l(wstr ptr)
406406
@ varargs -version=0x600+ _cwscanf_s(wstr)
@@ -439,7 +439,7 @@
439439
@ cdecl _fgetchar()
440440
@ cdecl _fgetwchar()
441441
@ cdecl _filbuf(ptr)
442-
# extern _fileinfo
442+
@ extern -arch=i386,x86_64 _fileinfo
443443
@ cdecl _filelength(long)
444444
@ cdecl -ret64 _filelengthi64(long)
445445
@ cdecl _fileno(ptr)
@@ -508,7 +508,7 @@
508508
@ cdecl -version=0x600+ _get_doserrno(ptr)
509509
@ cdecl -version=0x600+ _get_environ(ptr)
510510
@ cdecl -version=0x600+ _get_errno(ptr)
511-
# stub -version=0x600+ _get_fileinfo(ptr)
511+
@ cdecl -version=0x600+ _get_fileinfo(ptr)
512512
@ cdecl -version=0x600+ _get_fmode(ptr)
513513
@ cdecl _get_heap_handle()
514514
@ cdecl _get_osfhandle(long)
@@ -520,7 +520,7 @@
520520
@ cdecl -version=0x600+ _get_wenviron(ptr)
521521
@ cdecl -version=0x600+ _get_winmajor(ptr)
522522
@ cdecl -version=0x600+ _get_winminor(ptr)
523-
# stub -version=0x600+ _get_winver(ptr)
523+
@ cdecl -version=0x600+ _get_winver(ptr)
524524
@ cdecl -version=0x600+ _get_wpgmptr(ptr)
525525
@ cdecl _get_terminate()
526526
@ cdecl _get_tzname(ptr str long long)
@@ -686,12 +686,12 @@
686686
@ cdecl _ltow(long ptr long)
687687
@ cdecl -version=0x600+ _ltow_s(long ptr long long)
688688
@ cdecl _makepath(ptr str str str str)
689-
@ cdecl -version=0x600+ _makepath_s(ptr long str str str str)
690-
# stub -version=0x600+ _malloc_dbg(long long str long)
689+
@ cdecl -version=0x600+ _makepath_s(str long str)
690+
@ stub -version=0x600+ _malloc_dbg
691691
@ cdecl _mbbtombc(long)
692692
@ cdecl -version=0x600+ _mbbtombc_l(long ptr)
693693
@ cdecl _mbbtype(long long)
694-
# extern _mbcasemap
694+
@ extern _mbcasemap
695695
@ cdecl _mbccpy(ptr ptr)
696696
@ cdecl -version=0x600+ _mbccpy_l(ptr ptr ptr)
697697
@ cdecl -version=0x600+ _mbccpy_s(ptr long ptr ptr)
@@ -901,7 +901,7 @@
901901
@ cdecl -version=0x600+ _set_doserrno(long)
902902
@ cdecl -version=0x600+ _set_errno(long)
903903
@ cdecl _set_error_mode(long)
904-
# stub -version=0x600+ _set_fileinfo(long)
904+
@ cdecl -version=0x600+ _set_fileinfo(long)
905905
@ cdecl -version=0x600+ _set_fmode(long)
906906
@ cdecl -version=0x600+ _set_output_format(long)
907907
@ cdecl _set_sbh_threshold(long)
@@ -1008,7 +1008,7 @@
10081008
@ cdecl _tell(long)
10091009
@ cdecl -ret64 _telli64(long)
10101010
@ cdecl _tempnam(str str)
1011-
# stub -version=0x600+ _tempnam_dbg(str str long str long)
1011+
@ stub -version=0x600+ _tempnam_dbg(str str long str long)
10121012
@ cdecl -version=0x600+ _time32(ptr)
10131013
@ cdecl _time64(ptr)
10141014
@ extern _timezone MSVCRT___timezone
@@ -1456,7 +1456,9 @@
14561456
@ cdecl strtok(str str)
14571457
@ cdecl -version=0x600+ strtok_s(ptr str ptr)
14581458
@ cdecl strtol(str ptr long)
1459+
@ cdecl -impsym strtoll(str ptr long) _strtoi64
14591460
@ cdecl strtoul(str ptr long)
1461+
@ cdecl -impsym strtoull(str ptr long) _strtoui64
14601462
@ cdecl strxfrm(ptr str long)
14611463
@ varargs swprintf(ptr wstr) _swprintf
14621464
@ varargs -version=0x600+ swprintf_s(ptr long wstr)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
#include <intrin.h>
3+
4+
void _chkesp_failed(void)
5+
{
6+
__debugbreak();
7+
}

dll/win32/msvcrt/reactos/misc.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* PROJECT: ReactOS msvcrt.dll
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4+
* PURPOSE: Miscellaneous functions and data
5+
* COPYRIGHT: Copyright Timo Kreuzer <timo.kreuzer@reactos.org>
6+
*/
7+
8+
#include <stdlib.h>
9+
#include <errno.h>
10+
#include <msvcrt.h>
11+
12+
extern unsigned int MSVCRT__winver;
13+
14+
unsigned char _mbcasemap[257] =
15+
{
16+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
17+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
18+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
19+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
20+
0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
21+
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x0, 0x0, 0x0, 0x0, 0x0,
22+
0x0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
23+
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x0, 0x0, 0x0, 0x0, 0x0,
24+
};
25+
26+
int _fileinfo = -1;
27+
28+
unsigned char* __p__mbcasemap(void)
29+
{
30+
return _mbcasemap;
31+
}
32+
33+
int* __p__fileinfo(void)
34+
{
35+
return &_fileinfo;
36+
}
37+
38+
int _get_fileinfo(_Out_ int *_Value)
39+
{
40+
if (!MSVCRT_CHECK_PMT(_Value != NULL))
41+
{
42+
return EINVAL;
43+
}
44+
45+
*_Value = _fileinfo;
46+
return 0;
47+
}
48+
49+
int _set_fileinfo(_In_ int _Value)
50+
{
51+
_fileinfo = _Value;
52+
return 0;
53+
}
54+
55+
errno_t
56+
__cdecl
57+
_get_winver(_Out_ unsigned int *_Value)
58+
{
59+
if (!MSVCRT_CHECK_PMT(_Value != NULL))
60+
{
61+
return EINVAL;
62+
}
63+
64+
*_Value = MSVCRT__winver;
65+
return 0;
66+
}

sdk/lib/crt/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ if(MSVC AND ARCH STREQUAL "i386")
5656
set_target_properties(ftol2 PROPERTIES LINKER_LANGUAGE "C")
5757
add_dependencies(ftol2 asm)
5858
endif()
59+
60+
add_library(dbgrpt misc/dbgrpt.cpp)
61+
target_link_libraries(dbgrpt chkstk ${PSEH_LIB})
62+
target_compile_definitions(dbgrpt PRIVATE
63+
_MT
64+
_DEBUG)
65+
add_dependencies(dbgrpt psdk asm)

sdk/lib/crt/except/except.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ add_asm_files(chkstk_lib_asm ${CHKSTK_ASM_SOURCE})
7979
add_library(chkstk ${CHKSTK_SOURCE} ${chkstk_lib_asm})
8080
set_target_properties(chkstk PROPERTIES LINKER_LANGUAGE "C")
8181
add_dependencies(chkstk asm)
82+
83+
# Temporary lib, until crt and vcruntime are cleaned up
84+
if(ARCH STREQUAL "i386")
85+
add_asm_files(chkesp_lib_asm except/i386/chkesp.s)
86+
add_library(chkesp ${chkesp_lib_asm})
87+
set_target_properties(chkesp PROPERTIES LINKER_LANGUAGE "C")
88+
add_dependencies(chkesp asm)
89+
endif()

0 commit comments

Comments
 (0)