Skip to content

Commit

Permalink
Get path of conpty.node for conpty.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Aug 6, 2024
1 parent 485379c commit cf62104
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/win/conpty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,24 @@ HANDLE LoadConptyDll(const Napi::CallbackInfo& info,
return LoadLibraryExW(L"kernel32.dll", 0, 0);
}
wchar_t currentDir[MAX_PATH];
DWORD result = GetCurrentDirectoryW(MAX_PATH, currentDir);
HMODULE hModule = GetModuleHandleA("conpty.node");
if (hModule == NULL) {
throw errorWithCode(info, "Failed to get conpty.node module handle");
}
DWORD result = GetModuleFileNameW(hModule, currentDir, MAX_PATH);
if (result == 0) {
throw errorWithCode(info, "Failed to get current directory");
throw errorWithCode(info, "Failed to get conpty.node module file name");
}
std::wstring currentDirStr(currentDir);

std::wstring conptyDllPath = currentDirStr + L"\\build\\Release\\conpty\\conpty.dll";
PathRemoveFileSpecW(currentDir);
wchar_t conptyDllPath[MAX_PATH];
PathCombineW(conptyDllPath, currentDir, L"conpty\\conpty.dll");
if (!path_util::file_exists(conptyDllPath)) {
std::wstring errorMessage = L"Cannot find conpty.dll at " + conptyDllPath;
std::string errorMessageStr(errorMessage.begin(), errorMessage.end());
std::wstring errorMessage = L"Cannot find conpty.dll at " + std::wstring(conptyDllPath);
std::string errorMessageStr = path_util::wstring_to_string(errorMessage);
throw errorWithCode(info, errorMessageStr.c_str());
}

return LoadLibraryW(conptyDllPath.c_str());
return LoadLibraryW(conptyDllPath);
}

HRESULT CreateNamedPipesAndPseudoConsole(const Napi::CallbackInfo& info,
Expand Down

0 comments on commit cf62104

Please sign in to comment.