mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 22:56:13 +00:00
Fix TlsGetValue & more (#48)
`TlsGetValue` disambiguates 0 and an error by relying on `GetLastError`. Depending on the program state, `GetLastError` could be non-0, even though `TlsGetValue` succeeded. Resolve this by always setting `wibo::lastError`. This matches the behavior described by the documentation. Additionally, when reading resources, later versions of mwcc and mwld call `GetModuleHandleA` with the program path, and then call `LoadStringA` on that handle. Support this behavior by _actually_ loading the PE at the path passed in to `GetModuleHandleA`, instead of assuming it's the current program. (This is especially useful because sjiswrap relies on overriding `GetModuleFileNameA`, so the wrapped program reads its own resources, rather than sjiswrap's.) Other small changes: - Add ms-win-crt `exit` & run atexit funcs - Implements vcruntime `memmove` - Implements kernel32 `GetModuleFileNameA`
This commit is contained in:
@@ -8,6 +8,8 @@ void *WIN_ENTRY memset(void *dest, int ch, size_t count) { return ::memset(dest,
|
||||
|
||||
int WIN_ENTRY memcmp(const void *buf1, const void *buf2, size_t count) { return ::memcmp(buf1, buf2, count); }
|
||||
|
||||
void *WIN_ENTRY memmove(void *dest, const void *src, size_t count) { return ::memmove(dest, src, count); }
|
||||
|
||||
} // namespace vcruntime
|
||||
|
||||
static void *resolveByName(const char *name) {
|
||||
@@ -17,6 +19,8 @@ static void *resolveByName(const char *name) {
|
||||
return (void *)vcruntime::memset;
|
||||
if (strcmp(name, "memcmp") == 0)
|
||||
return (void *)vcruntime::memcmp;
|
||||
if (strcmp(name, "memmove") == 0)
|
||||
return (void *)vcruntime::memmove;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user