Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not rely on a hidden symbol from libuv #567

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions library/posture.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@

#pragma comment(lib, "netapi32.lib")
#pragma comment(lib, "bcrypt.lib")
#include <VersionHelpers.h>
#include <windows.h>

// provided by libuv
typedef NTSTATUS (NTAPI *sRtlGetVersion)
(PRTL_OSVERSIONINFOW lpVersionInformation);
extern sRtlGetVersion pRtlGetVersion;

#elif __APPLE__ && __MACH__
#include <TargetConditionals.h>
Expand Down Expand Up @@ -668,19 +666,36 @@ static void ziti_pr_handle_process(ziti_context ztx, const char *id, const char
ziti_collect_pr(ztx, path, obj, obj_len);
}

static void default_pq_os(ziti_context ztx, const char *id, ziti_pr_os_cb response_cb) {
#if _WIN32
typedef NTSTATUS (NTAPI *sRtlGetVersion)
(PRTL_OSVERSIONINFOW lpVersionInformation);

static sRtlGetVersion get_win32_version_f() {
static sRtlGetVersion s_func;
if (s_func == NULL) {
HMODULE ntdll = GetModuleHandleA("ntdll.dll");
s_func = (sRtlGetVersion) GetProcAddress(ntdll, "RtlGetVersion");
}
return s_func;
}
static

#endif // _WIN32

void default_pq_os(ziti_context ztx, const char *id, ziti_pr_os_cb response_cb) {
const char *os;
const char *ver;
const char *build;
#if _WIN32
OSVERSIONINFOEXW os_info = {0};
os_info.dwOSVersionInfoSize = sizeof(os_info);
if (pRtlGetVersion) {
pRtlGetVersion((PRTL_OSVERSIONINFOW) &os_info);
sRtlGetVersion version_f = get_win32_version_f();
if (version_f) {
version_f((PRTL_OSVERSIONINFOW) &os_info);
} else {
/* Silence GetVersionEx() deprecation warning. */
#pragma warning(suppress : 4996)
GetVersionExW(&os_info);
GetVersionExW((LPOSVERSIONINFOW) &os_info);
}

switch (os_info.wProductType) {
Expand Down
Loading