Skip to content

Commit 752fc86

Browse files
fix(shell): fix crash
1 parent 8315e50 commit 752fc86

File tree

2 files changed

+2
-60
lines changed

2 files changed

+2
-60
lines changed

src/inject/inject.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ struct inject_all_switch : public button_widget {
419419
CloseHandle(event);
420420
}
421421

422+
restart_explorer();
423+
422424
std::thread([this]() {
423425
Sleep(200);
424426
check_is_injecting_all();

src/shell/fix_win11_menu.cc

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -109,64 +109,4 @@ void mb_shell::fix_win11_menu::install() {
109109
return RegGetValueHook->call_trampoline<long>(
110110
hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
111111
});
112-
113-
// approch 2: patch the shell32.dll to predent the shift key is pressed
114-
std::thread([=]() {
115-
if (auto shell32 = proc->module("shell32.dll")) {
116-
// mov ecx, 10
117-
// call GetKeyState/GetAsyncKeyState
118-
auto disasm = shell32.value()->section(".text")->disassembly();
119-
120-
auto patch_area = [&](auto mem) {
121-
for (auto it = mem.begin(); it != mem.end(); ++it) {
122-
auto &insn = *it;
123-
if (insn->getMnemonic() == zasm::x86::Mnemonic::Mov) {
124-
if (insn->getOperand(0) == zasm::x86::ecx &&
125-
insn->getOperand(1).template holds<zasm::Imm>() &&
126-
insn->getOperand(1)
127-
.template get<zasm::Imm>()
128-
.template value<int>() == 0x10) {
129-
auto &next = *std::next(it);
130-
if (next->getMnemonic() == zasm::x86::Mnemonic::Call &&
131-
next->getOperand(0).template holds<zasm::Mem>()) {
132-
insn.ptr()
133-
.reassembly([](auto a) {
134-
a.mov(zasm::x86::eax, 0x0);
135-
a.bts(zasm::x86::edi, 0x8);
136-
a.nop();
137-
a.nop();
138-
a.nop();
139-
})
140-
.patch();
141-
142-
return true;
143-
}
144-
}
145-
}
146-
}
147-
148-
return false;
149-
};
150-
151-
// the function to determine if show win10 menu or win11 menu calls
152-
// SetMessageExtraInfo, so we use it as a hint
153-
auto extraInfo =
154-
GetProcAddress(LoadLibraryA("user32.dll"), "SetMessageExtraInfo");
155-
for (auto &ins : disasm) {
156-
if (ins->getMnemonic() == zasm::x86::Mnemonic::Call) {
157-
auto xrefs = ins.xrefs();
158-
if (xrefs.empty())
159-
continue;
160-
if (auto ptr = xrefs[0].try_read<void *>();
161-
ptr.has_value() && ptr.value() == extraInfo) {
162-
if (patch_area(ins.ptr()
163-
.find_upwards({0x40, 0x55})
164-
->range_size(0x150)
165-
.disassembly()))
166-
break;
167-
}
168-
}
169-
}
170-
}
171-
}).detach();
172112
}

0 commit comments

Comments
 (0)