Update logic to identify console conpty support (#411)

conpty identity logic.
This commit is contained in:
bagajjal 2019-12-02 10:57:03 -08:00 committed by GitHub
parent a4ea7dcced
commit 9e42eb0c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 16 deletions

View File

@ -1707,6 +1707,6 @@
#define _PATH_SFTP_SERVER "sftp-server.exe" #define _PATH_SFTP_SERVER "sftp-server.exe"
#define _PATH_SSH_PROGRAM "ssh.exe" #define _PATH_SSH_PROGRAM "ssh.exe"
#define _PATH_LS "dir" #define _PATH_LS "dir"
#define FORK_NOT_SUPPORTED 1 #define FORK_NOT_SUPPORTED
#define HAVE_FREEZERO #define HAVE_FREEZERO
#define FILESYSTEM_NO_BACKSLASH #define FILESYSTEM_NO_BACKSLASH

View File

@ -38,30 +38,21 @@
int int
is_conpty_supported() is_conpty_supported()
{ {
wchar_t system32_path[PATH_MAX] = { 0, }; wchar_t *kernel32_dll_path = L"kernel32.dll";
wchar_t kernel32_dll_path[PATH_MAX] = { 0, }; HMODULE hm_kernel32 = NULL;
HMODULE hm_kernelbase = NULL;
static int isConpty = -1; static int isConpty = -1;
if (isConpty != -1) if (isConpty != -1)
return isConpty; return isConpty;
isConpty = 0; isConpty = 0;
if (!GetSystemDirectoryW(system32_path, PATH_MAX)) { if ((hm_kernel32 = LoadLibraryExW(kernel32_dll_path, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32)) == NULL) {
error("failed to get system directory"); error("failed to load %S dll", kernel32_dll_path);
goto done; goto done;
} }
wcscat_s(kernel32_dll_path, PATH_MAX, system32_path); if (GetProcAddress(hm_kernel32, "CreatePseudoConsole") == NULL) {
wcscat_s(kernel32_dll_path, PATH_MAX, L"\\Kernel32.dll"); debug3("couldn't find CreatePseudoConsole() in %S dll", kernel32_dll_path);
if ((hm_kernelbase = LoadLibraryW(kernel32_dll_path)) == NULL) {
error("failed to load kernerlbase dll:%s", kernel32_dll_path);
goto done;
}
if (GetProcAddress(hm_kernelbase, "CreatePseudoConsole") == NULL) {
debug3("couldn't find CreatePseudoConsole() in kernerlbase dll");
goto done; goto done;
} }