mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 12:39:35 +00:00
[KERNEL32][SDK] RegisterConsoleIME and UnregisterConsoleIME (#5270)
The conime.exe program exists in WinXP/Win2k3 and it realizes Console IME. conime.exe calls kernel32!RegisterConsoleIME and kernel32!UnregisterConsoleIME. To realize Console IME, these two functions are required. CORE-11700
This commit is contained in:
parent
c50b94579e
commit
8b948ff062
2 changed files with 121 additions and 5 deletions
|
@ -3030,13 +3030,109 @@ SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknow
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
IntRegisterConsoleIME(
|
||||||
|
_In_ HWND hWnd,
|
||||||
|
_In_ DWORD dwThreadId,
|
||||||
|
_In_opt_ SIZE_T cbDesktop,
|
||||||
|
_In_opt_ PWSTR pDesktop,
|
||||||
|
_Out_opt_ PDWORD pdwAttachToThreadId)
|
||||||
|
{
|
||||||
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
|
PCONSOLE_REGISTERCONSOLEIME RegisterConsoleIME = &ApiMessage.Data.RegisterConsoleIME;
|
||||||
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
|
if (!cbDesktop || !pDesktop)
|
||||||
|
{
|
||||||
|
pDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Buffer;
|
||||||
|
cbDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
cbDesktop = min(cbDesktop, (MAX_PATH + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
|
RegisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
|
RegisterConsoleIME->hWnd = hWnd;
|
||||||
|
RegisterConsoleIME->dwThreadId = dwThreadId;
|
||||||
|
RegisterConsoleIME->cbDesktop = cbDesktop;
|
||||||
|
|
||||||
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, cbDesktop);
|
||||||
|
if (!CaptureBuffer)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
|
pDesktop,
|
||||||
|
cbDesktop,
|
||||||
|
(PVOID*)&RegisterConsoleIME->pDesktop);
|
||||||
|
|
||||||
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
|
CaptureBuffer,
|
||||||
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepRegisterConsoleIME),
|
||||||
|
sizeof(*RegisterConsoleIME));
|
||||||
|
|
||||||
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdwAttachToThreadId)
|
||||||
|
{
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
*pdwAttachToThreadId = RegisterConsoleIME->dwAttachToThreadId;
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(STATUS_ACCESS_VIOLATION);
|
||||||
|
_SEH2_YIELD(return FALSE);
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
IntUnregisterConsoleIME(
|
||||||
|
_In_ DWORD dwThreadId)
|
||||||
|
{
|
||||||
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
|
PCONSOLE_UNREGISTERCONSOLEIME UnregisterConsoleIME = &ApiMessage.Data.UnregisterConsoleIME;
|
||||||
|
|
||||||
|
UnregisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
|
UnregisterConsoleIME->dwThreadId = dwThreadId;
|
||||||
|
|
||||||
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
|
NULL,
|
||||||
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepUnregisterConsoleIME),
|
||||||
|
sizeof(*UnregisterConsoleIME));
|
||||||
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is called by CONIME.EXE */
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
DECLSPEC_HOTPATCH
|
DECLSPEC_HOTPATCH
|
||||||
RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId)
|
RegisterConsoleIME(
|
||||||
|
_In_ HWND hWnd,
|
||||||
|
_Out_opt_ LPDWORD pdwAttachToThreadId)
|
||||||
{
|
{
|
||||||
STUB;
|
return IntRegisterConsoleIME(hWnd,
|
||||||
return FALSE;
|
GetCurrentThreadId(),
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
pdwAttachToThreadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
@ -3057,13 +3153,13 @@ SetConsoleOS2OemFormat(BOOL bUnknown)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function is called by CONIME.EXE */
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
DECLSPEC_HOTPATCH
|
DECLSPEC_HOTPATCH
|
||||||
UnregisterConsoleIME(VOID)
|
UnregisterConsoleIME(VOID)
|
||||||
{
|
{
|
||||||
STUB;
|
return IntUnregisterConsoleIME(GetCurrentThreadId());
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -894,6 +894,22 @@ typedef struct _CONSOLE_REGISTERVDM
|
||||||
PVOID VDMBuffer;
|
PVOID VDMBuffer;
|
||||||
} CONSOLE_REGISTERVDM, *PCONSOLE_REGISTERVDM;
|
} CONSOLE_REGISTERVDM, *PCONSOLE_REGISTERVDM;
|
||||||
|
|
||||||
|
typedef struct _CONSOLE_REGISTERCONSOLEIME
|
||||||
|
{
|
||||||
|
HANDLE ConsoleHandle;
|
||||||
|
HWND hWnd;
|
||||||
|
DWORD dwThreadId;
|
||||||
|
DWORD cbDesktop;
|
||||||
|
LPWSTR pDesktop;
|
||||||
|
DWORD dwAttachToThreadId;
|
||||||
|
} CONSOLE_REGISTERCONSOLEIME, *PCONSOLE_REGISTERCONSOLEIME;
|
||||||
|
|
||||||
|
typedef struct _CONSOLE_UNREGISTERCONSOLEIME
|
||||||
|
{
|
||||||
|
HANDLE ConsoleHandle;
|
||||||
|
DWORD dwThreadId;
|
||||||
|
} CONSOLE_UNREGISTERCONSOLEIME, *PCONSOLE_UNREGISTERCONSOLEIME;
|
||||||
|
|
||||||
typedef struct _CONSOLE_API_MESSAGE
|
typedef struct _CONSOLE_API_MESSAGE
|
||||||
{
|
{
|
||||||
PORT_MESSAGE Header;
|
PORT_MESSAGE Header;
|
||||||
|
@ -1002,6 +1018,10 @@ typedef struct _CONSOLE_API_MESSAGE
|
||||||
|
|
||||||
/* Virtual DOS Machine */
|
/* Virtual DOS Machine */
|
||||||
CONSOLE_REGISTERVDM RegisterVDMRequest;
|
CONSOLE_REGISTERVDM RegisterVDMRequest;
|
||||||
|
|
||||||
|
/* Console IME */
|
||||||
|
CONSOLE_REGISTERCONSOLEIME RegisterConsoleIME;
|
||||||
|
CONSOLE_UNREGISTERCONSOLEIME UnregisterConsoleIME;
|
||||||
} Data;
|
} Data;
|
||||||
} CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
|
} CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue