diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index ef0e663..8e18008 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -1635,7 +1635,7 @@ namespace kernel32 { } const size_t copyLen = std::min(len, nSize - 1); - memcpy(lpFilename, stringToWideString(path.c_str()).data(), copyLen); + memcpy(lpFilename, stringToWideString(path.c_str()).data(), copyLen * 2); if (copyLen < nSize) { lpFilename[copyLen] = 0; } diff --git a/dll/msvcrt.cpp b/dll/msvcrt.cpp index 6c3a10e..bdf5074 100644 --- a/dll/msvcrt.cpp +++ b/dll/msvcrt.cpp @@ -324,7 +324,21 @@ namespace msvcrt { } int WIN_ENTRY wcscpy_s(uint16_t *dest, size_t dest_size, const uint16_t *src){ - DEBUG_LOG("STUB: wcscpy_s\n"); + std::string src_str = wideStringToString(src); + DEBUG_LOG("wcscpy_s %s\n", src_str.c_str()); + if (!dest || !src || dest_size == 0) { + return -1; + } + + size_t src_len = 0; + while (src[src_len] != 0) src_len++; + + if (src_len + 1 > dest_size) { + dest[0] = 0; + return -1; + } + + wstrcpy(dest, src); return 0; }