Skip to content

Commit

Permalink
修复CreateWindowExA hook当lpClassName为atom时崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnux committed Nov 19, 2022
1 parent 50287af commit 267277a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,21 @@ unsafe extern "system" fn CreateWindowExA_detour(
lpParam,
);
if !ret.is_null() {
// lpClassName可能是atom
if std::mem::size_of::<LPCSTR>() == 8 {
// 64位,判断高位DWORD是否是0,是的话再判断低DWORD的HIWORD是否是0,是0那就是atom
if (lpClassName as u64 >> 32) & 0xffffffff == 0 {
if winapi::shared::minwindef::HIWORD(lpClassName as DWORD) == 0 {
return ret;
}
}
} else {
// 32位判断HIWORD是否是0,是0那就是atom
if winapi::shared::minwindef::HIWORD(lpClassName as DWORD) == 0 {
return ret;
}
}

if 0 == lstrcmpiA(lpClassName, b"emacs\0".as_ptr() as _)
|| 0 == lstrcmpiA(lpClassName, b"ScrollBar\0".as_ptr() as _)
{
Expand Down

0 comments on commit 267277a

Please sign in to comment.