================ @@ -0,0 +1,113 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/windows/PseudoConsole.h" + +#include <mutex> + +#include "lldb/Host/windows/windows.h" + +#include "llvm/Support/Errc.h" +#include "llvm/Support/Errno.h" + +using namespace lldb_private; + +typedef HRESULT(WINAPI *CreatePseudoConsole_t)(COORD size, HANDLE hInput, + HANDLE hOutput, DWORD dwFlags, + HPCON *phPC); + +typedef VOID(WINAPI *ClosePseudoConsole_t)(HPCON hPC); + +struct Kernel32 { + Kernel32() { + hModule = LoadLibraryW(L"kernel32.dll"); + CreatePseudoConsole_ = + (CreatePseudoConsole_t)GetProcAddress(hModule, "CreatePseudoConsole"); + ClosePseudoConsole_ = + (ClosePseudoConsole_t)GetProcAddress(hModule, "ClosePseudoConsole"); + isAvailable = (CreatePseudoConsole_ && ClosePseudoConsole_); + } + + HRESULT CreatePseudoConsole(COORD size, HANDLE hInput, HANDLE hOutput, + DWORD dwFlags, HPCON *phPC) { + return CreatePseudoConsole_(size, hInput, hOutput, dwFlags, phPC); ---------------- ashgti wrote:
Should this `assert` that `CreatePseudoConsole_` is not null? Or should we return -1 if it is null? I see we're checking `IsAvailable` below, but if that is every changed in the future, should we also have the check / assert here as well? https://github.com/llvm/llvm-project/pull/168729 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
