|
|
|
@ -34,12 +34,11 @@ |
|
|
|
|
namespace grpc_core { |
|
|
|
|
namespace internal { |
|
|
|
|
|
|
|
|
|
bool check_bios_data(const char*) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
bool check_bios_data(const char*) { return false; } |
|
|
|
|
|
|
|
|
|
bool check_windows_registry_product_name( |
|
|
|
|
HKEY root_key, const char* reg_key_path, const char* reg_key_name) { |
|
|
|
|
bool check_windows_registry_product_name(HKEY root_key, |
|
|
|
|
const char* reg_key_path, |
|
|
|
|
const char* reg_key_name) { |
|
|
|
|
const size_t kProductNameBufferSize = 256; |
|
|
|
|
char const expected_substr[] = "Google"; |
|
|
|
|
|
|
|
|
@ -47,8 +46,7 @@ bool check_windows_registry_product_name( |
|
|
|
|
// enough space for the trailing NUL character that will be included.
|
|
|
|
|
DWORD buffer_size{}; |
|
|
|
|
auto rc = ::RegGetValueA( |
|
|
|
|
root_key, reg_key_path, reg_key_name, |
|
|
|
|
RRF_RT_REG_SZ, |
|
|
|
|
root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ, |
|
|
|
|
nullptr, // We know the type will be REG_SZ.
|
|
|
|
|
nullptr, // We're only fetching the size; no buffer given yet.
|
|
|
|
|
&buffer_size); // Fetch the size in bytes of the value, if it exists.
|
|
|
|
@ -64,10 +62,9 @@ bool check_windows_registry_product_name( |
|
|
|
|
char buffer[kProductNameBufferSize]; |
|
|
|
|
buffer_size = kProductNameBufferSize; |
|
|
|
|
rc = ::RegGetValueA( |
|
|
|
|
root_key, reg_key_path, reg_key_name, |
|
|
|
|
RRF_RT_REG_SZ, |
|
|
|
|
nullptr, // We know the type will be REG_SZ.
|
|
|
|
|
static_cast<void*>(buffer), // Fetch the string value this time.
|
|
|
|
|
root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ, |
|
|
|
|
nullptr, // We know the type will be REG_SZ.
|
|
|
|
|
static_cast<void*>(buffer), // Fetch the string value this time.
|
|
|
|
|
&buffer_size); // The string size in bytes, not including trailing NUL.
|
|
|
|
|
if (rc != 0) { |
|
|
|
|
return false; |
|
|
|
@ -93,8 +90,9 @@ bool grpc_alts_is_running_on_gcp() { |
|
|
|
|
gpr_once_init(&g_once, init_mu); |
|
|
|
|
gpr_mu_lock(&g_mu); |
|
|
|
|
if (!g_compute_engine_detection_done) { |
|
|
|
|
g_is_on_compute_engine = grpc_core::internal::check_windows_registry_product_name( |
|
|
|
|
HKEY_LOCAL_MACHINE, reg_key_path, reg_key_name); |
|
|
|
|
g_is_on_compute_engine = |
|
|
|
|
grpc_core::internal::check_windows_registry_product_name( |
|
|
|
|
HKEY_LOCAL_MACHINE, reg_key_path, reg_key_name); |
|
|
|
|
g_compute_engine_detection_done = true; |
|
|
|
|
} |
|
|
|
|
gpr_mu_unlock(&g_mu); |
|
|
|
|