-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting PocoMan.exe running #43
Comments
This looks great so far, thanks for breaking it up! Also if you need any help or advice looking into your binary please reach out. I would love to flesh out the docs with anything useful for you. |
By the way, if a function is missing, retrowin32 logs a warning about it but keeps running. So it will only matter if your binary actually calls it (where it will crash after calling a null pointer). Functions like ExitThread might not matter until you get to the end of the program, not sure. |
One idea is you could maybe locally stub out the CreateThread impl such that it never starts the thread in the first place, just to see what happens next. Depends on if it waits for the thread to come back though. I saw in your above list you had CreateEvent/SetEvent which are typically used for thread synchronization... I ran the installer (via wine 😊 ) and I get this:
I guess I need more of your patches? The window size could indicate a problem, but also some apps I've seen create a window with an unknown size, then resize it later in response to some window messages. ghidra says:
and there is some function called by the wndproc that does
|
My above crash is fixed in 6427aed, which now reveals the actual problem was running from the wrong directory
|
If it helps you any, feel free to send a PR that is just like "here are all the stubs I need". You don't need to send separate PRs for them if it's too much effort. (I'm fine with separate PRs, just trying to save you some effort...) |
Sorry, I have had limited with time today and just cherry picked som already done work. Will give some more time to the comments later!
Hehe, yeah I realized that that would probably have been a good strategy 😅 At this point I think that they are all merged though! Well, as far as I have gotten at least, will probably be a bit more when I get more time to dig further! Thanks for all the help, and for looking into the binary yourself! As said, I'll try to read thru all your comments properly and answer in a few days |
I'm running into a really strange problem. For some reason, the application is closing its file handle whilst in the middle of reading from it. It's reading the map data, and since it then errors out goes into an error state. Making diff --git a/win32/src/winapi/kernel32/file.rs b/win32/src/winapi/kernel32/file.rs
index 79e7b8a1..c8a6946f 100644
--- a/win32/src/winapi/kernel32/file.rs
+++ b/win32/src/winapi/kernel32/file.rs
@@ -382,7 +382,7 @@ pub fn SetFilePointer(
lDistanceToMove |= (**high as i64) << 32;
}
let Some(file) = machine.state.kernel32.files.get_mut(hFile) else {
- log::debug!("SetFilePointer({hFile:?}) unknown handle");
+ log::warn!("SetFilePointer({hFile:?}) unknown handle");
set_last_error(machine, ERROR_INVALID_HANDLE);
return u32::MAX;
};
diff --git a/win32/src/winapi/kernel32/misc.rs b/win32/src/winapi/kernel32/misc.rs
index d6d06472..49de0c85 100644
--- a/win32/src/winapi/kernel32/misc.rs
+++ b/win32/src/winapi/kernel32/misc.rs
@@ -279,6 +279,7 @@ pub fn FormatMessageW(
#[win32_derive::dllexport]
pub fn CloseHandle(machine: &mut Machine, hObject: HFILE) -> bool {
+ return true; // FIXME: remove this line
if machine.state.kernel32.files.remove(hObject).is_none() {
log::debug!("CloseHandle({hObject:?}): unknown handle");
set_last_error(machine, ERROR_INVALID_HANDLE);
It's happening right after the call to Reading the disassembled source, there are calls to |
Re time, I just monkeyed with it here, maybe I got something wrong: 0c3e485 Re CloseHandle, I looked at the places where it's called in pocoman and most seemed to be error paths. But the one at address 00410419 might be it(?). I wrote all of the threading-related stubs before retrowin32 supported threads so they are all definitely wrong. I see some use of thread-local storage in pocoman and that also is certainly wrong right now, not sure how serious it is. The function passed to CreateThread immediately calls TlsSetValue, probably to stash some sort of "current state" object. |
Hm wait, the call at 0040c77d seems to be the thread function shutting down and is closing a handle found in the Tls, that seems very likely it. |
(moving TLS discussion to #70 to not clutter this up) |
With 8c1713a it now plays "I am pocoman" audio on startup. Might get annoying, we can put it behind a flag if so! |
That's amazing!! 🤩 Although it seems like the audio then underflows and crashes the entire application 😅
|
Oh no! I pushed another commit to disable it by default until I have it all working, sorry! |
I added a |
The bitmap code is still gross but I made it a lot less gross in af32dd4 , with a special eye to making StretchBlt easy to implement. |
When doing a stretching bit copy, we don't clip the src rectangle to match the dst, we instead transform coordinates to fit within the bounds. Part of #43.
This issue is to track my work in getting PocoMan v4.0 running. See more background in #39
My working branch is here: https://github.com/LinusU/retrowin32/tree/pocoman
kernel32.dll
GetStartupInfoA
Zero out entire struct in GetStartupInfoA #40SizeofResource
Implement SizeofResource #42SetEnvironmentVariableA
add stub SetEnvironmentVariableA #44CreateEventA
/SetEvent
add handles for events #45ResumeThread
add ResumeThread stub #52ExitThread
implement ExitThread #56WideCharToMultiByte
advapi32.dll
RegCreateKeyA
/RegQueryValueExA
RegCreateKeyA and RegQueryValueExA stubs #41RegSetValueExA
add RegSetValueExA stub #48ole32.dll
OleInitialize
add OleInitialize stub #46user32.dll
LoadMenuA
add LoadMenuA stub #47GetWindowRect
implement GetWindowRect #53SetMenuItemInfoA
add SetMenuItemInfoA stub #54GetWindowPlacement
add GetWindowPlacement stub #59 + implement GetWindowPlacement #67CreatePopupMenu
add CreatePopupMenu stub #60GetSubMenu
add GetSubMenu stub #61KillTimer
implement KillTimer #63SetWindowPos
update host window size in SetWindowPos #69gdi32.dll
hdcSrc
withBLACKNESS
support null hdcSrc when using BLACKNESS rop #50CreatePalette
add CreatePalette stub #68SelectPalette
/RealizePalette
gdi32 palette functions #49SetTextAlign
add SetTextAlign stub #66wininet32.dll
InternetOpenA
add InternetOpenA stub #51imul_r16_rm16
implement imul_r16_rm16 #55The text was updated successfully, but these errors were encountered: