Skip to content

Commit

Permalink
implement KillTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU authored and evmar committed Sep 21, 2024
1 parent c52bb28 commit f702308
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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

0 comments on commit f702308

Please sign in to comment.