a few more funcs

This commit is contained in:
rjkiv 2025-08-06 11:21:33 -07:00
parent 6a161b0155
commit a045fd0b9e
2 changed files with 35 additions and 0 deletions

View File

@ -898,6 +898,23 @@ namespace kernel32 {
}
}
unsigned int WIN_FUNC GetFileAttributesW(const wchar_t* lpFileName) {
DEBUG_LOG("GetFileAttributesW\n");
size_t len = std::wcstombs(nullptr, lpFileName, 0);
if(len != (size_t)-1){
char* converted = new char[len + 1];
std::wcstombs(converted, lpFileName, len + 1);
unsigned int ret = GetFileAttributesA(converted);
delete [] converted;
return ret;
}
else {
DEBUG_LOG("Could not convert filename for GetFileAttributesW!\n");
wibo::lastError = 2;
return 0xFFFFFFFF;
}
}
unsigned int WIN_FUNC WriteFile(void *hFile, const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten, void *lpOverlapped) {
DEBUG_LOG("WriteFile(%p, %d)\n", hFile, nNumberOfBytesToWrite);
assert(!lpOverlapped);
@ -2431,6 +2448,7 @@ static void *resolveByName(const char *name) {
if (strcmp(name, "FindNextFileA") == 0) return (void *) kernel32::FindNextFileA;
if (strcmp(name, "FindClose") == 0) return (void *) kernel32::FindClose;
if (strcmp(name, "GetFileAttributesA") == 0) return (void *) kernel32::GetFileAttributesA;
if (strcmp(name, "GetFileAttributesW") == 0) return (void *) kernel32::GetFileAttributesW;
if (strcmp(name, "WriteFile") == 0) return (void *) kernel32::WriteFile;
if (strcmp(name, "ReadFile") == 0) return (void *) kernel32::ReadFile;
if (strcmp(name, "CreateFileA") == 0) return (void *) kernel32::CreateFileA;

View File

@ -292,6 +292,20 @@ namespace msvcrt {
return dup;
}
void* WIN_ENTRY memset(void *s, int c, size_t n){
return std::memset(s, c, n);
}
int WIN_ENTRY wcsncpy_s(wchar_t *strDest, size_t numberOfElements, const wchar_t *strSource, size_t count){
DEBUG_LOG("STUB: wcsncpy_s\n");
return 0;
}
int WIN_ENTRY wcsncat_s(wchar_t *strDest, size_t numberOfElements, const wchar_t *strSource, size_t count){
DEBUG_LOG("STUB: wscncat_s\n");
return 0;
}
}
@ -314,6 +328,9 @@ static void *resolveByName(const char *name) {
if (strcmp(name, "_wsplitpath_s") == 0) return (void*)msvcrt::_wsplitpath_s;
if (strcmp(name, "wcscat_s") == 0) return (void*)msvcrt::wcscat_s;
if (strcmp(name, "_wcsdup") == 0) return (void*)msvcrt::_wcsdup;
if (strcmp(name, "memset") == 0) return (void*)msvcrt::memset;
if (strcmp(name, "wcsncpy_s") == 0) return (void*)msvcrt::wcsncpy_s;
if (strcmp(name, "wcsncat_s") == 0) return (void*)msvcrt::wcsncat_s;
return nullptr;
}