Skip to content
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

implement KillTimer #63

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified win32/dll/user32.dll
Binary file not shown.
13 changes: 12 additions & 1 deletion win32/src/winapi/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4906,6 +4906,12 @@ pub mod user32 {
let lprc = <Option<&RECT>>::from_stack(mem, esp + 4u32);
winapi::user32::IsRectEmpty(machine, lprc).to_raw()
}
pub unsafe fn KillTimer(machine: &mut Machine, esp: u32) -> u32 {
let mem = machine.mem().detach();
let hWnd = <HWND>::from_stack(mem, esp + 4u32);
let uIDEvent = <u32>::from_stack(mem, esp + 8u32);
winapi::user32::KillTimer(machine, hWnd, uIDEvent).to_raw()
}
pub unsafe fn LoadAcceleratorsW(machine: &mut Machine, esp: u32) -> u32 {
let mem = machine.mem().detach();
let hInstance = <u32>::from_stack(mem, esp + 4u32);
Expand Down Expand Up @@ -5479,6 +5485,10 @@ pub mod user32 {
name: "IsRectEmpty",
func: crate::shims::Handler::Sync(impls::IsRectEmpty),
};
pub const KillTimer: Shim = Shim {
name: "KillTimer",
func: crate::shims::Handler::Sync(impls::KillTimer),
};
pub const LoadAcceleratorsW: Shim = Shim {
name: "LoadAcceleratorsW",
func: crate::shims::Handler::Sync(impls::LoadAcceleratorsW),
Expand Down Expand Up @@ -5680,7 +5690,7 @@ pub mod user32 {
func: crate::shims::Handler::Sync(impls::wsprintfA),
};
}
const SHIMS: [Shim; 95usize] = [
const SHIMS: [Shim; 96usize] = [
shims::AdjustWindowRect,
shims::AdjustWindowRectEx,
shims::AppendMenuA,
Expand Down Expand Up @@ -5726,6 +5736,7 @@ pub mod user32 {
shims::InvalidateRgn,
shims::IsIconic,
shims::IsRectEmpty,
shims::KillTimer,
shims::LoadAcceleratorsW,
shims::LoadBitmapA,
shims::LoadCursorA,
Expand Down
15 changes: 15 additions & 0 deletions win32/src/winapi/user32/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ impl Timers {
}
}

#[win32_derive::dllexport]
pub fn KillTimer(machine: &mut Machine, hWnd: HWND, uIDEvent: u32) -> bool {
let timers = &mut machine.state.user32.timers.0;
let index = timers
.iter()
.position(|t| t.hwnd == hWnd && t.id == uIDEvent);

if let Some(index) = index {
timers.swap_remove(index);
true
} else {
false
}
}

#[win32_derive::dllexport]
pub fn SetTimer(
machine: &mut Machine,
Expand Down