Skip to content

Commit

Permalink
GetProcAddress changes in ssh-shellhost to support Nano
Browse files Browse the repository at this point in the history
  • Loading branch information
manojampalam committed Oct 23, 2016
1 parent 5831b09 commit fe82ce1
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions contrib/win32/win32compat/shell-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -1157,7 +1189,7 @@ int start_with_pty(int ac, wchar_t **av) {
if (ux_thread != INVALID_HANDLE_VALUE)
TerminateThread(ux_thread, S_OK);
if (hEventHook)
UnhookWinEvent(hEventHook);
__UnhookWinEvent(hEventHook);

FreeConsole();

Expand Down

0 comments on commit fe82ce1

Please sign in to comment.