Skip to content

Commit fe82ce1

Browse files
committed
GetProcAddress changes in ssh-shellhost to support Nano
1 parent 5831b09 commit fe82ce1

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

contrib/win32/win32compat/shell-host.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@
5050
#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
5151
#endif
5252

53+
typedef BOOL (WINAPI *__t_SetCurrentConsoleFontEx)(
54+
_In_ HANDLE hConsoleOutput,
55+
_In_ BOOL bMaximumWindow,
56+
_In_ PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
57+
);
58+
__t_SetCurrentConsoleFontEx __SetCurrentConsoleFontEx;
59+
60+
typedef BOOL (WINAPI *__t_UnhookWinEvent)(
61+
_In_ HWINEVENTHOOK hWinEventHook
62+
);
63+
__t_UnhookWinEvent __UnhookWinEvent;
64+
65+
typedef HWINEVENTHOOK (WINAPI *__t_SetWinEventHook)(
66+
_In_ UINT eventMin,
67+
_In_ UINT eventMax,
68+
_In_ HMODULE hmodWinEventProc,
69+
_In_ WINEVENTPROC lpfnWinEventProc,
70+
_In_ DWORD idProcess,
71+
_In_ DWORD idThread,
72+
_In_ UINT dwflags
73+
);
74+
__t_SetWinEventHook __SetWinEventHook;
75+
76+
5377
typedef struct consoleEvent {
5478
DWORD event;
5579
HWND hwnd;
@@ -389,7 +413,7 @@ void SizeWindow(HANDLE hInput) {
389413
matchingFont.FontWeight = FW_NORMAL;
390414
wcscpy(matchingFont.FaceName, L"Consolas");
391415

392-
bSuccess = SetCurrentConsoleFontEx(child_out, FALSE, &matchingFont);
416+
bSuccess = __SetCurrentConsoleFontEx(child_out, FALSE, &matchingFont);
393417

394418
// This information is the live screen
395419
ZeroMemory(&consoleInfo, sizeof(consoleInfo));
@@ -1057,6 +1081,14 @@ int start_with_pty(int ac, wchar_t **av) {
10571081
DWORD dwMode;
10581082
DWORD dwStatus;
10591083
HANDLE hEventHook = NULL;
1084+
HMODULE hm_kernel32 = NULL, hm_user32 = NULL;
1085+
1086+
if ((hm_kernel32 = LoadLibraryW(L"kernel32.dll")) == NULL ||
1087+
(hm_user32 = LoadLibraryW(L"user32.dll")) == NULL ||
1088+
(__SetCurrentConsoleFontEx = GetProcAddress(hm_kernel32, "SetCurrentConsoleFontEx")) == NULL ||
1089+
(__UnhookWinEvent = GetProcAddress(hm_user32, "UnhookWinEvent")) == NULL ||
1090+
(__SetWinEventHook = GetProcAddress(hm_user32, "SetWinEventHook")) == NULL)
1091+
return -1;
10601092

10611093
pipe_in = GetStdHandle(STD_INPUT_HANDLE);
10621094
pipe_out = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -1082,7 +1114,7 @@ int start_with_pty(int ac, wchar_t **av) {
10821114

10831115
InitializeCriticalSection(&criticalSection);
10841116

1085-
hEventHook = SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_LAYOUT, NULL,
1117+
hEventHook = __SetWinEventHook(EVENT_CONSOLE_CARET, EVENT_CONSOLE_LAYOUT, NULL,
10861118
ConsoleEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
10871119

10881120
memset(&si, 0, sizeof(STARTUPINFO));
@@ -1157,7 +1189,7 @@ int start_with_pty(int ac, wchar_t **av) {
11571189
if (ux_thread != INVALID_HANDLE_VALUE)
11581190
TerminateThread(ux_thread, S_OK);
11591191
if (hEventHook)
1160-
UnhookWinEvent(hEventHook);
1192+
__UnhookWinEvent(hEventHook);
11611193

11621194
FreeConsole();
11631195

0 commit comments

Comments
 (0)