2023-09-10 19:22:01 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2023-10-26 20:28:17 +00:00
|
|
|
typedef void (WIN_ENTRY *_PVFV)(void);
|
|
|
|
|
2023-09-10 19:22:01 +00:00
|
|
|
namespace msvcrt {
|
|
|
|
int _commode;
|
|
|
|
int _fmode;
|
2023-10-26 20:28:17 +00:00
|
|
|
char **___initenv;
|
|
|
|
char **__pgmptr;
|
2023-09-10 19:22:01 +00:00
|
|
|
|
|
|
|
// Stub because we're only ever a console application
|
2023-10-26 20:28:17 +00:00
|
|
|
void WIN_ENTRY __set_app_type(int at) {
|
2023-09-10 19:22:01 +00:00
|
|
|
}
|
|
|
|
|
2023-10-26 20:28:17 +00:00
|
|
|
int* WIN_ENTRY __p__fmode() {
|
2023-09-10 19:22:01 +00:00
|
|
|
return &_fmode;
|
|
|
|
}
|
|
|
|
|
2023-10-26 20:28:17 +00:00
|
|
|
int* WIN_ENTRY __p__commode() {
|
2023-09-10 19:22:01 +00:00
|
|
|
return &_commode;
|
|
|
|
}
|
2023-10-26 20:28:17 +00:00
|
|
|
|
|
|
|
char*** WIN_ENTRY __p___initenv(void) { return &___initenv; }
|
|
|
|
char **WIN_ENTRY __p__pgmptr(void) { return __pgmptr; }
|
|
|
|
void* WIN_ENTRY __p__iob(void) { return nullptr; }
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int WIN_ENTRY _controlfp(unsigned int _new, unsigned int mask) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WIN_ENTRY _initterm(_PVFV *start, _PVFV *end) {
|
|
|
|
_PVFV* it = start;
|
|
|
|
|
|
|
|
while (it < end) {
|
|
|
|
if (*it != nullptr) {
|
|
|
|
(**it)();
|
|
|
|
}
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int WIN_ENTRY __getmainargs(int *argc, char ***argv, char ***envp, int expand_wildcards, int *new_mode) {
|
|
|
|
DEBUG_LOG("msvcrt::__getmainargs(%p, %p, %p, %d, %p)\n", argc, argv, envp, expand_wildcards, new_mode);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
void WIN_ENTRY setbuf(FILE* file, char *buf) {}
|
2023-09-10 19:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2023-10-26 20:28:17 +00:00
|
|
|
if (strcmp(name, "__p___initenv") == 0) return (void *) msvcrt::__p___initenv;
|
|
|
|
if (strcmp(name, "__p__pgmptr") == 0) return (void *) msvcrt::__p__pgmptr;
|
|
|
|
if (strcmp(name, "__p__iob") == 0) return (void *) msvcrt::__p__iob;
|
|
|
|
if (strcmp(name, "_controlfp") == 0) return (void *) msvcrt::_controlfp;
|
|
|
|
if (strcmp(name, "_initterm") == 0) return (void *) msvcrt::_initterm;
|
|
|
|
if (strcmp(name, "__getmainargs") == 0) return (void *) msvcrt::__getmainargs;
|
|
|
|
if (strcmp(name, "setbuf") == 0) return (void *) msvcrt::setbuf;
|
|
|
|
if (strcmp(name, "getenv") == 0) return (void *) getenv;
|
2023-09-10 19:22:01 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
wibo::Module lib_msvcrt = {
|
|
|
|
(const char *[]){
|
2023-09-12 13:44:56 +00:00
|
|
|
"msvcrt",
|
|
|
|
"msvcrt.dll",
|
2023-09-10 19:22:01 +00:00
|
|
|
"msvcrt40",
|
|
|
|
"msvcrt40.dll",
|
2023-09-12 13:44:56 +00:00
|
|
|
"msvcr70",
|
|
|
|
"msvcr70.dll",
|
2023-09-10 19:22:01 +00:00
|
|
|
nullptr,
|
|
|
|
},
|
|
|
|
resolveByName,
|
|
|
|
nullptr,
|
|
|
|
};
|