[KBSWITCH] Enable Wine debug (#8010)

Debug easy and develop easy.
JIRA issue: CORE-18546
- Include <wine/debug.h>.
- Import ntdll and link to wine.
- Enable Wine debug.
This commit is contained in:
Katayama Hirofumi MZ
2025-05-22 20:08:36 +09:00
committed by GitHub
parent 40721f49ba
commit 99064a58d9
3 changed files with 35 additions and 9 deletions

View File

@@ -2,7 +2,8 @@
add_rc_deps(kbswitch.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/kbswitch.ico)
add_executable(kbswitch kbswitch.c kbswitch.rc)
set_module_type(kbswitch win32gui UNICODE)
add_importlibs(kbswitch advapi32 imm32 user32 shell32 shlwapi gdi32 msvcrt kernel32)
target_link_libraries(kbswitch wine)
add_importlibs(kbswitch advapi32 imm32 user32 shell32 shlwapi gdi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET kbswitch DESTINATION reactos/system32 FOR all)
add_subdirectory(kbsdll)

View File

@@ -1,2 +1,2 @@
@ stdcall KbSwitchSetHooks()
@ stdcall KbSwitchDeleteHooks()
1 stdcall KbSwitchSetHooks()
2 stdcall KbSwitchDeleteHooks()

View File

@@ -13,6 +13,9 @@
#include <imm.h>
#include <imm32_undoc.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(internat);
/*
* This program kbswitch is a mimic of Win2k's internat.exe.
* However, there are some differences.
@@ -561,15 +564,19 @@ SetHooks(VOID)
return FALSE;
}
KbSwitchSetHooks = (PKBSWITCHSETHOOKS) GetProcAddress(g_hHookDLL, "KbSwitchSetHooks");
KbSwitchDeleteHooks = (PKBSWITCHDELETEHOOKS) GetProcAddress(g_hHookDLL, "KbSwitchDeleteHooks");
#define IHOOK_SET 1
#define IHOOK_DELETE 2
KbSwitchSetHooks = (PKBSWITCHSETHOOKS) GetProcAddress(g_hHookDLL, MAKEINTRESOURCEA(IHOOK_SET));
KbSwitchDeleteHooks = (PKBSWITCHDELETEHOOKS) GetProcAddress(g_hHookDLL, MAKEINTRESOURCEA(IHOOK_DELETE));
if (KbSwitchSetHooks == NULL || KbSwitchDeleteHooks == NULL)
if (!KbSwitchSetHooks || !KbSwitchDeleteHooks || !KbSwitchSetHooks())
{
ERR("SetHooks failed\n");
return FALSE;
}
return KbSwitchSetHooks();
TRACE("SetHooks OK\n");
return TRUE;
}
VOID
@@ -580,11 +587,14 @@ DeleteHooks(VOID)
KbSwitchDeleteHooks();
KbSwitchDeleteHooks = NULL;
}
if (g_hHookDLL)
{
FreeLibrary(g_hHookDLL);
g_hHookDLL = NULL;
}
TRACE("DeleteHooks OK\n");
}
static UINT GetLayoutNum(HKL hKL)
@@ -704,6 +714,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_LANG_CHANGED: /* Comes from kbsdll.dll and this module */
{
TRACE("WM_LANG_CHANGED: wParam:%p, lParam:%p\n", wParam, lParam);
UpdateLayoutList((HKL)lParam);
UpdateLanguageDisplay(hwnd, (HKL)lParam);
break;
@@ -711,7 +722,9 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_WINDOW_ACTIVATE: /* Comes from kbsdll.dll and this module */
{
HWND hwndFore = GetForegroundWindow();
HWND hwndFore;
TRACE("WM_WINDOW_ACTIVATE: wParam:%p, lParam:%p\n", wParam, lParam);
hwndFore = GetForegroundWindow();
if (RememberLastActive(hwnd, hwndFore))
return UpdateLanguageDisplayCurrent(hwnd, hwndFore);
break;
@@ -856,6 +869,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
}
else if (Message == ShellHookMessage)
{
TRACE("ShellHookMessage: wParam:%p, lParam:%p\n", wParam, lParam);
if (wParam == HSHELL_LANGUAGE)
PostMessage(hwnd, WM_LANG_CHANGED, wParam, lParam);
else if (wParam == HSHELL_WINDOWACTIVATED)
@@ -881,6 +895,7 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdSh
switch (GetUserDefaultUILanguage())
{
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
TRACE("LAYOUT_RTL\n");
SetProcessDefaultLayout(LAYOUT_RTL);
break;
default:
@@ -889,10 +904,14 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdSh
hMutex = CreateMutex(NULL, FALSE, szKbSwitcherName);
if (!hMutex)
{
ERR("!hMutex\n");
return 1;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
ERR("Another instance is already running\n");
CloseHandle(hMutex);
return 1;
}
@@ -913,7 +932,13 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdSh
hwnd = CreateWindow(szKbSwitcherName, NULL, 0, 0, 0, 1, 1, HWND_DESKTOP, NULL, hInstance, NULL);
ShellHookMessage = RegisterWindowMessage(L"SHELLHOOK");
RegisterShellHookWindow(hwnd);
if (!RegisterShellHookWindow(hwnd))
{
ERR("RegisterShellHookWindow failed\n");
DestroyWindow(hwnd);
CloseHandle(hMutex);
return 1;
}
while (GetMessage(&msg, NULL, 0, 0))
{