GetProcAddress changes in ssh-shellhost to support Nano

This commit is contained in:
Manoj Ampalam 2016-10-22 21:45:49 -07:00
parent 5831b09b84
commit fe82ce1d37

View File

@ -50,6 +50,30 @@
#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
#endif
typedef BOOL (WINAPI *__t_SetCurrentConsoleFontEx)(
_In_ HANDLE hConsoleOutput,
_In_ BOOL bMaximumWindow,
_In_ PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
);
__t_SetCurrentConsoleFontEx __SetCurrentConsoleFontEx;
typedef BOOL (WINAPI *__t_UnhookWinEvent)(
_In_ HWINEVENTHOOK hWinEventHook
);
__t_UnhookWinEvent __UnhookWinEvent;
typedef HWINEVENTHOOK (WINAPI *__t_SetWinEventHook)(
_In_ UINT eventMin,
_In_ UINT eventMax,
_In_ HMODULE hmodWinEventProc,
_In_ WINEVENTPROC lpfnWinEventProc,
_In_ DWORD idProcess,
_In_ DWORD idThread,
_In_ UINT dwflags
);
__t_SetWinEventHook __SetWinEventHook;
typedef struct consoleEvent {
DWORD event;
HWND hwnd;
@ -389,7 +413,7 @@ void SizeWindow(HANDLE hInput) {
matchingFont.FontWeight = FW_NORMAL;
wcscpy(matchingFont.FaceName, L"Consolas");
bSuccess = SetCurrentConsoleFontEx(child_out, FALSE, &matchingFont);
bSuccess = __SetCurrentConsoleFontEx(child_out, FALSE, &matchingFont);
// This information is the live screen
ZeroMemory(&consoleInfo, sizeof(consoleInfo));
@ -1057,6 +1081,14 @@ int start_with_pty(int ac, wchar_t **av) {
DWORD dwMode;
DWORD dwStatus;
HANDLE hEventHook = NULL;
HMODULE hm_kernel32 = NULL, hm_user32 = NULL;
if ((hm_kernel32 = LoadLibraryW(L"kernel32.dll")) == NULL ||
(hm_user32 = LoadLibraryW(L"user32.dll")) == NULL ||
(__SetCurrentConsoleFontEx = GetProcAddress(hm_kernel32, "SetCurrentConsoleFontEx")) == NULL ||
(__UnhookWinEvent = GetProcAddress(hm_user32, "UnhookWinEvent")) == NULL ||
(__SetWinEventHook = GetProcAddress(hm_user32, "SetWinEventHook")) == NULL)
return -1;
pipe_in = GetStdHandle(STD_INPUT_HANDLE);
pipe_out = GetStdHandle(STD_OUTPUT_HANDLE);
@ -1082,7 +1114,7 @@ int start_with_pty(int ac, wchar_t **av) {
InitializeCriticalSection(&criticalSection);
hEventHook = SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_LAYOUT, NULL,
hEventHook = __SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_LAYOUT, NULL,
ConsoleEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
memset(&si, 0, sizeof(STARTUPINFO));
@ -1157,7 +1189,7 @@ cleanup:
if (ux_thread != INVALID_HANDLE_VALUE)
TerminateThread(ux_thread, S_OK);
if (hEventHook)
UnhookWinEvent(hEventHook);
__UnhookWinEvent(hEventHook);
FreeConsole();