summaryrefslogtreecommitdiffstats
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp50
1 files changed, 39 insertions, 11 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index adc72a79e9..0d151668ba 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -40,10 +40,10 @@
#include "core/debugger/script_debugger.h"
#include "core/io/marshalls.h"
#include "core/version_generated.gen.h"
-#include "drivers/unix/net_socket_posix.h"
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/file_access_windows_pipe.h"
+#include "drivers/windows/net_socket_winsock.h"
#include "main/main.h"
#include "servers/audio_server.h"
#include "servers/rendering/rendering_server_default.h"
@@ -139,13 +139,13 @@ void RedirectIOToConsole() {
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
// Restore redirection (Note: if not redirected it's NULL handles not INVALID_HANDLE_VALUE).
- if (h_stdin != 0) {
+ if (h_stdin != nullptr) {
SetStdHandle(STD_INPUT_HANDLE, h_stdin);
}
- if (h_stdout != 0) {
+ if (h_stdout != nullptr) {
SetStdHandle(STD_OUTPUT_HANDLE, h_stdout);
}
- if (h_stderr != 0) {
+ if (h_stderr != nullptr) {
SetStdHandle(STD_ERROR_HANDLE, h_stderr);
}
@@ -209,7 +209,7 @@ void OS_Windows::initialize() {
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM);
- NetSocketPosix::make_default();
+ NetSocketWinSock::make_default();
// We need to know how often the clock is updated
QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second);
@@ -303,7 +303,7 @@ void OS_Windows::finalize_core() {
timeEndPeriod(1);
memdelete(process_map);
- NetSocketPosix::cleanup();
+ NetSocketWinSock::cleanup();
#ifdef WINDOWS_DEBUG_OUTPUT_ENABLED
remove_error_handler(&error_handlers);
@@ -908,9 +908,9 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String
}
// Create pipes.
- HANDLE pipe_in[2] = { 0, 0 };
- HANDLE pipe_out[2] = { 0, 0 };
- HANDLE pipe_err[2] = { 0, 0 };
+ HANDLE pipe_in[2] = { nullptr, nullptr };
+ HANDLE pipe_out[2] = { nullptr, nullptr };
+ HANDLE pipe_err[2] = { nullptr, nullptr };
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -981,7 +981,7 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List<String
Ref<FileAccessWindowsPipe> err_pipe;
err_pipe.instantiate();
- err_pipe->open_existing(pipe_err[0], 0, p_blocking);
+ err_pipe->open_existing(pipe_err[0], nullptr, p_blocking);
ret["stdio"] = main_pipe;
ret["stderr"] = err_pipe;
@@ -1363,7 +1363,7 @@ public:
locale = p_locale;
n_sub = p_nsub;
rtl = p_rtl;
- };
+ }
virtual ~FallbackTextAnalysisSource() {}
};
@@ -1740,6 +1740,34 @@ String OS_Windows::get_locale() const {
return "en";
}
+String OS_Windows::get_model_name() const {
+ HKEY hkey;
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) {
+ return OS::get_model_name();
+ }
+
+ String sys_name;
+ String board_name;
+ WCHAR buffer[256];
+ DWORD buffer_len = 256;
+ DWORD vtype = REG_SZ;
+ if (RegQueryValueExW(hkey, L"SystemProductName", nullptr, &vtype, (LPBYTE)buffer, &buffer_len) == ERROR_SUCCESS && buffer_len != 0) {
+ sys_name = String::utf16((const char16_t *)buffer, buffer_len).strip_edges();
+ }
+ buffer_len = 256;
+ if (RegQueryValueExW(hkey, L"BaseBoardProduct", nullptr, &vtype, (LPBYTE)buffer, &buffer_len) == ERROR_SUCCESS && buffer_len != 0) {
+ board_name = String::utf16((const char16_t *)buffer, buffer_len).strip_edges();
+ }
+ RegCloseKey(hkey);
+ if (!sys_name.is_empty() && sys_name.to_lower() != "system product name") {
+ return sys_name;
+ }
+ if (!board_name.is_empty() && board_name.to_lower() != "base board product") {
+ return board_name;
+ }
+ return OS::get_model_name();
+}
+
String OS_Windows::get_processor_name() const {
const String id = "Hardware\\Description\\System\\CentralProcessor\\0";