use crate::emu;
use crate::winapi::helper;
pub fn LeaveCriticalSection(emu: &mut emu::Emu) {
let cs_ptr = emu.regs().rcx;
let tid = emu.current_thread().id;
log_red!(
emu,
"kernel32!LeaveCriticalSection thread: 0x{:x} cs: 0x{:x}",
tid,
cs_ptr
);
if let Some(wake_tid) = emu.global_locks.leave(cs_ptr, tid) {
for thread in &mut emu.threads {
if thread.id == wake_tid {
thread.blocked_on_cs = None;
thread.wake_tick = 0; log::trace!(" Waking thread 0x{:x}", wake_tid);
break;
}
}
}
helper::advance_tick(emu, 1);
}