3 msvcrt funcs (#42)

* msvcrt funcs

* fix empty final line

* Promment
This commit is contained in:
Ethan Roseman 2023-09-11 04:22:01 +09:00 committed by GitHub
parent a5499f27de
commit b7e8e5fb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 4 deletions

View File

@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.13)
if (NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Build type options: Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif ()
"Build type options: Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif()
project(wibo LANGUAGES CXX)
@ -25,10 +25,11 @@ add_executable(wibo
dll/user32.cpp
dll/vcruntime.cpp
dll/version.cpp
dll/msvcrt.cpp
files.cpp
handles.cpp
loader.cpp
main.cpp
)
)
target_link_libraries(wibo PRIVATE std::filesystem)
install(TARGETS wibo DESTINATION bin)

36
dll/msvcrt.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "common.h"
namespace msvcrt {
int _commode;
int _fmode;
// Stub because we're only ever a console application
void WIN_FUNC __set_app_type(int at) {
}
int* WIN_FUNC __p__fmode() {
return &_fmode;
}
int* WIN_FUNC __p__commode() {
return &_commode;
}
}
static void *resolveByName(const char *name) {
if (strcmp(name, "__set_app_type") == 0) return (void *) msvcrt::__set_app_type;
if (strcmp(name, "__p__fmode") == 0) return (void *) msvcrt::__p__fmode;
if (strcmp(name, "__p__commode") == 0) return (void *) msvcrt::__p__commode;
return nullptr;
}
wibo::Module lib_msvcrt = {
(const char *[]){
"msvcrt40",
"msvcrt40.dll",
nullptr,
},
resolveByName,
nullptr,
};

View File

@ -77,6 +77,7 @@ extern const wibo::Module lib_bcrypt;
extern const wibo::Module lib_crt;
extern const wibo::Module lib_kernel32;
extern const wibo::Module lib_lmgr;
extern const wibo::Module lib_msvcrt;
extern const wibo::Module lib_ntdll;
extern const wibo::Module lib_ole32;
extern const wibo::Module lib_user32;
@ -88,6 +89,7 @@ const wibo::Module * wibo::modules[] = {
&lib_crt,
&lib_kernel32,
&lib_lmgr,
&lib_msvcrt,
&lib_ntdll,
&lib_ole32,
&lib_user32,