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:
@@ -57,8 +57,7 @@ namespace user32 {
|
||||
return (unsigned int*)(rsrcBase + langEntry);
|
||||
}
|
||||
|
||||
static const char *getStringFromTable(unsigned int uID) {
|
||||
wibo::Executable *mod = wibo::mainModule;
|
||||
static const char *getStringFromTable(wibo::Executable *mod, unsigned int uID) {
|
||||
unsigned int tableID = (uID >> 4) + 1;
|
||||
unsigned int entryID = uID & 15;
|
||||
unsigned int* stringTable = getResourceByID(mod, 6, tableID, 1033);
|
||||
@@ -82,7 +81,11 @@ namespace user32 {
|
||||
|
||||
int WIN_FUNC LoadStringA(void* hInstance, unsigned int uID, char* lpBuffer, int cchBufferMax) {
|
||||
DEBUG_LOG("LoadStringA %p %d %d\n", hInstance, uID, cchBufferMax);
|
||||
const char* s = getStringFromTable(uID);
|
||||
wibo::Executable *mod = wibo::executableFromModule(hInstance);
|
||||
if (!mod) {
|
||||
return 0;
|
||||
}
|
||||
const char* s = getStringFromTable(mod, uID);
|
||||
if (!s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user