@@ -116,47 +116,45 @@ void mb_shell::context_menu_hooks::install_SHCreateDefaultContextMenu_hook() {
116116 std::cerr << " Failed to find CreateWindowExW in user32.dll" << std::endl;
117117 }
118118 static auto CreateWindowExWHook = CreateWindowExWFunc->inline_hook ();
119- CreateWindowExWHook->install (+[](DWORD dwExStyle, LPCWSTR lpClassName,
120- LPCWSTR lpWindowName, DWORD dwStyle, int X,
121- int Y, int nWidth, int nHeight,
122- HWND hWndParent, HMENU hMenu,
123- HINSTANCE hInstance,
124- LPVOID lpParam) -> HWND {
125- std::wstring class_name = [&]{
126- if (!lpClassName) {
119+ CreateWindowExWHook->install (
120+ +[](DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName,
121+ DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent,
122+ HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) -> HWND {
123+ std::wstring class_name = [&] {
124+ if (!lpClassName) {
127125 return std::wstring (L" " );
128- }
129- if (blook::Pointer ((void *)lpClassName).try_read <int >()) {
126+ }
127+ if (blook::Pointer ((void *)lpClassName).try_read <int >()) {
130128 return std::wstring (lpClassName);
131- } else {
129+ } else {
132130 // read as registered class
133131 wchar_t class_name_buffer[256 ];
134132 if (GetClassNameW ((HWND)lpClassName, class_name_buffer, 256 ) > 0 ) {
135- return std::wstring (class_name_buffer);
133+ return std::wstring (class_name_buffer);
136134 } else {
137- return std::wstring (L" " );
135+ return std::wstring (L" " );
138136 }
139- }
140- }();
137+ }
138+ }();
141139
142- bool should_close =
143- close_next_create_window_exw_window &&
144- class_name.starts_with (L" HwndWrapper[OneCommander.exe" );
140+ bool should_close =
141+ close_next_create_window_exw_window &&
142+ class_name.starts_with (L" HwndWrapper[OneCommander.exe" );
145143
146- if (should_close) {
147- dwStyle &= ~WS_VISIBLE;
148- }
144+ if (should_close) {
145+ dwStyle &= ~WS_VISIBLE;
146+ }
149147
150- auto res = CreateWindowExWHook->call_trampoline <HWND>(
151- dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight ,
152- hWndParent, hMenu, hInstance, lpParam);
153- if (res && should_close) {
154- close_next_create_window_exw_window = false ;
155- PostMessageW (res, WM_CLOSE, 0 , 0 );
156- CloseWindow (res);
157- }
158- return res;
159- });
148+ auto res = CreateWindowExWHook->call_trampoline <HWND>(
149+ dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth,
150+ nHeight, hWndParent, hMenu, hInstance, lpParam);
151+ if (res && should_close) {
152+ close_next_create_window_exw_window = false ;
153+ PostMessageW (res, WM_CLOSE, 0 , 0 );
154+ CloseWindow (res);
155+ }
156+ return res;
157+ });
160158
161159 /* *
162160 prototype: SHSTDAPI SHCreateDefaultContextMenu(
0 commit comments