From 23a2e761c4336994b3757cbef015a7584df43551 Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 1 Apr 2024 15:31:46 -0300 Subject: [PATCH 1/5] idk --- dll/kernel32.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index b899b3d..4b32818 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -119,6 +119,7 @@ namespace kernel32 { } uint32_t WIN_FUNC GetLastError() { + DEBUG_LOG("GetLastError() -> %u\n", wibo::lastError); return wibo::lastError; } @@ -276,6 +277,7 @@ namespace kernel32 { } int WIN_FUNC GetSystemDefaultLangID() { + DEBUG_LOG("STUB GetSystemDefaultLangID\n"); return 0; } @@ -774,6 +776,7 @@ namespace kernel32 { } int WIN_FUNC FindNextFileA(void *hFindFile, WIN32_FIND_DATA *lpFindFileData) { + DEBUG_LOG("FindNextFileA(%p, %p)\n", hFindFile, lpFindFileData); // Special value from FindFirstFileA if (hFindFile == (void *) 1) { wibo::lastError = ERROR_NO_MORE_FILES; @@ -1279,7 +1282,7 @@ namespace kernel32 { } unsigned int WIN_FUNC SetConsoleCtrlHandler(void *HandlerRoutine, unsigned int Add) { - DEBUG_LOG("SetConsoleCtrlHandler\n"); + DEBUG_LOG("STUB SetConsoleCtrlHandler\n"); // This is a function that gets called when doing ^C // We might want to call this later (being mindful that it'll be stdcall I think) @@ -1302,6 +1305,7 @@ namespace kernel32 { }; unsigned int WIN_FUNC GetConsoleScreenBufferInfo(void *hConsoleOutput, CONSOLE_SCREEN_BUFFER_INFO *lpConsoleScreenBufferInfo) { + DEBUG_LOG("GetConsoleScreenBufferInfo(%p, %p)\n", hConsoleOutput, lpConsoleScreenBufferInfo); // Tell a lie // mwcc doesn't care about anything else lpConsoleScreenBufferInfo->dwSize_x = 80; @@ -1786,6 +1790,7 @@ namespace kernel32 { return 1; // sure.. we have that feature... + DEBUG_LOG(" IsProcessorFeaturePresent: we don't know about feature %u, lying...\n", processorFeature); return 1; } From bb74ba64a4ec04a0a51d57649674f0f6cbb20a8f Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 2 Apr 2024 15:08:18 -0300 Subject: [PATCH 2/5] meh --- dll/kernel32.cpp | 4 +++- files.cpp | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index 4b32818..ae8ca67 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -1372,7 +1372,7 @@ namespace kernel32 { } unsigned int WIN_FUNC GetCurrentDirectoryA(unsigned int uSize, char *lpBuffer) { - DEBUG_LOG("GetCurrentDirectoryA(%u, %p)\n", uSize, lpBuffer); + DEBUG_LOG("GetCurrentDirectoryA(%u, %p)", uSize, lpBuffer); std::filesystem::path cwd = std::filesystem::current_path(); std::string path = files::pathToWindows(cwd); @@ -1380,9 +1380,11 @@ namespace kernel32 { // If the buffer is too small, return the required buffer size. // (Add 1 to include the NUL terminator) if (path.size() + 1 > uSize) { + DEBUG_LOG(" !! Buffer too small: %i, %i\n", path.size() + 1, uSize); return path.size() + 1; } + DEBUG_LOG(" -> %s\n", path.c_str()); strcpy(lpBuffer, path.c_str()); return path.size(); } diff --git a/files.cpp b/files.cpp index a684ae3..2701d30 100644 --- a/files.cpp +++ b/files.cpp @@ -32,7 +32,6 @@ namespace files { return path; } - path = path.lexically_normal(); std::filesystem::path newPath = "."; bool followingExisting = true; for (const auto& component : path) { From bfa0c441c4eb9f0ed224ec247968239cc9ac45f5 Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 2 Apr 2024 16:00:59 -0300 Subject: [PATCH 3/5] Implement trailing periods on FindFirstFileA --- dll/kernel32.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index ae8ca67..c0467f2 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -682,6 +682,13 @@ namespace kernel32 { }; bool findNextFile(FindFirstFileHandle *handle) { + if ((handle->it != std::filesystem::directory_iterator()) && (handle->pattern == "")) { + // The caller (ie `FindFirstFileA`) was passed a path with a + // trailing period (like `include/.`). This behavior doesn't seem + // to be documented, so we treat it as an "find any file on this + // directory". + return true; + } while (handle->it != std::filesystem::directory_iterator()) { std::filesystem::path path = *handle->it; if (fnmatch(handle->pattern.c_str(), path.filename().c_str(), 0) == 0) { @@ -716,6 +723,8 @@ namespace kernel32 { auto path = files::pathFromWindows(lpFileName); DEBUG_LOG("FindFirstFileA %s (%s)\n", lpFileName, path.c_str()); + assert(strchr(path.c_str(), '*') == NULL && "wildcards are not supported yet :c"); + lpFindFileData->ftCreationTime = defaultFiletime; lpFindFileData->ftLastAccessTime = defaultFiletime; lpFindFileData->ftLastWriteTime = defaultFiletime; From 9c1b3c569dfbff651f2f6879b92fd5da65663dbf Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 2 Apr 2024 16:15:30 -0300 Subject: [PATCH 4/5] ah? --- dll/kernel32.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index c0467f2..c8808dc 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -723,7 +723,10 @@ namespace kernel32 { auto path = files::pathFromWindows(lpFileName); DEBUG_LOG("FindFirstFileA %s (%s)\n", lpFileName, path.c_str()); - assert(strchr(path.c_str(), '*') == NULL && "wildcards are not supported yet :c"); + if (strchr(path.c_str(), '*') != NULL) { + printf("path: %s\n", path.c_str()); + assert(!"wildcards are not supported yet :c"); + } lpFindFileData->ftCreationTime = defaultFiletime; lpFindFileData->ftLastAccessTime = defaultFiletime; From 996dbb9c692e9944e6c00110a37dde000bc500dc Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 2 Apr 2024 16:18:15 -0300 Subject: [PATCH 5/5] Remove assert --- dll/kernel32.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index c8808dc..f5195d8 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -723,11 +723,6 @@ namespace kernel32 { auto path = files::pathFromWindows(lpFileName); DEBUG_LOG("FindFirstFileA %s (%s)\n", lpFileName, path.c_str()); - if (strchr(path.c_str(), '*') != NULL) { - printf("path: %s\n", path.c_str()); - assert(!"wildcards are not supported yet :c"); - } - lpFindFileData->ftCreationTime = defaultFiletime; lpFindFileData->ftLastAccessTime = defaultFiletime; lpFindFileData->ftLastWriteTime = defaultFiletime;