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