conan-recipes/recipes/breakpad/all/patches/0025-Ensure-wide-strings-use-the-wide-versions-of-Windows.patch
2020-10-19 07:52:36 +10:00

209 lines
8.9 KiB
Diff

From dee30faf8a5386b18b6c4368f83cddb3e82b8246 Mon Sep 17 00:00:00 2001
From: Danny Robson <danny@nerdcruft.net>
Date: Thu, 31 Oct 2019 10:41:51 +1100
Subject: [PATCH 2/7] Ensure wide strings use the wide versions of Windows
syscalls
This aids cross compilation under MinGW. Otherwise we encounter wide
type conversion errors when it defaults to the ANSI variants of each
syscall.
There is probably a build flag that dynamically switches these calls,
but usage of wide strings is hard coded in a few places already so
these fixes are necessary regardless.
---
.../crash_generation_client.cc | 24 ++++++-------
.../crash_generation_server.cc | 16 ++++-----
.../crash_generation/minidump_generator.cc | 34 +++++++++----------
.../windows/handler/exception_handler.cc | 18 +++++-----
4 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/src/client/windows/crash_generation/crash_generation_client.cc b/src/client/windows/crash_generation/crash_generation_client.cc
index 3ba5d4e4..b33ecb24 100644
--- a/src/client/windows/crash_generation/crash_generation_client.cc
+++ b/src/client/windows/crash_generation/crash_generation_client.cc
@@ -280,13 +280,13 @@ HANDLE CrashGenerationClient::ConnectToPipe(const wchar_t* pipe_name,
}
for (int i = 0; i < kPipeConnectMaxAttempts; ++i) {
- HANDLE pipe = CreateFile(pipe_name,
- pipe_access,
- 0,
- NULL,
- OPEN_EXISTING,
- flags_attrs,
- NULL);
+ HANDLE pipe = CreateFileW(pipe_name,
+ pipe_access,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ flags_attrs,
+ NULL);
if (pipe != INVALID_HANDLE_VALUE) {
return pipe;
}
@@ -298,7 +298,7 @@ HANDLE CrashGenerationClient::ConnectToPipe(const wchar_t* pipe_name,
}
// Cannot continue retrying if wait on pipe fails.
- if (!WaitNamedPipe(pipe_name, kPipeBusyWaitTimeoutMs)) {
+ if (!WaitNamedPipeW(pipe_name, kPipeBusyWaitTimeoutMs)) {
break;
}
}
@@ -376,9 +376,9 @@ bool CrashGenerationClient::SignalCrashEventAndWait() {
HANDLE CrashGenerationClient::DuplicatePipeToClientProcess(const wchar_t* pipe_name,
HANDLE hProcess) {
for (int i = 0; i < kPipeConnectMaxAttempts; ++i) {
- HANDLE local_pipe = CreateFile(pipe_name, kPipeDesiredAccess,
- 0, NULL, OPEN_EXISTING,
- kPipeFlagsAndAttributes, NULL);
+ HANDLE local_pipe = CreateFileW(pipe_name, kPipeDesiredAccess,
+ 0, NULL, OPEN_EXISTING,
+ kPipeFlagsAndAttributes, NULL);
if (local_pipe != INVALID_HANDLE_VALUE) {
HANDLE remotePipe = INVALID_HANDLE_VALUE;
if (DuplicateHandle(GetCurrentProcess(), local_pipe,
@@ -395,7 +395,7 @@ HANDLE CrashGenerationClient::DuplicatePipeToClientProcess(const wchar_t* pipe_n
return INVALID_HANDLE_VALUE;
}
- if (!WaitNamedPipe(pipe_name, kPipeBusyWaitTimeoutMs)) {
+ if (!WaitNamedPipeW(pipe_name, kPipeBusyWaitTimeoutMs)) {
return INVALID_HANDLE_VALUE;
}
}
diff --git a/src/client/windows/crash_generation/crash_generation_server.cc b/src/client/windows/crash_generation/crash_generation_server.cc
index 0af213ba..619ced43 100644
--- a/src/client/windows/crash_generation/crash_generation_server.cc
+++ b/src/client/windows/crash_generation/crash_generation_server.cc
@@ -239,14 +239,14 @@ bool CrashGenerationServer::Start() {
return false;
}
- pipe_ = CreateNamedPipe(pipe_name_.c_str(),
- kPipeAttr,
- kPipeMode,
- 1,
- kOutBufferSize,
- kInBufferSize,
- 0,
- pipe_sec_attrs_);
+ pipe_ = CreateNamedPipeW(pipe_name_.c_str(),
+ kPipeAttr,
+ kPipeMode,
+ 1,
+ kOutBufferSize,
+ kInBufferSize,
+ 0,
+ pipe_sec_attrs_);
if (pipe_ == INVALID_HANDLE_VALUE) {
return false;
}
diff --git a/src/client/windows/crash_generation/minidump_generator.cc b/src/client/windows/crash_generation/minidump_generator.cc
index 573c2786..f274e502 100644
--- a/src/client/windows/crash_generation/minidump_generator.cc
+++ b/src/client/windows/crash_generation/minidump_generator.cc
@@ -468,13 +468,13 @@ bool MinidumpGenerator::GenerateDumpFile(wstring* dump_path) {
return false;
}
- dump_file_ = CreateFile(dump_file_path.c_str(),
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ dump_file_ = CreateFileW(dump_file_path.c_str(),
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
if (dump_file_ == INVALID_HANDLE_VALUE) {
return false;
}
@@ -501,15 +501,15 @@ bool MinidumpGenerator::GenerateFullDumpFile(wstring* full_dump_path) {
return false;
}
full_dump_file_path.resize(full_dump_file_path.size() - 4); // strip .dmp
- full_dump_file_path.append(TEXT("-full.dmp"));
-
- full_dump_file_ = CreateFile(full_dump_file_path.c_str(),
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ full_dump_file_path.append(TEXT(L"-full.dmp"));
+
+ full_dump_file_ = CreateFileW(full_dump_file_path.c_str(),
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
if (full_dump_file_ == INVALID_HANDLE_VALUE) {
return false;
}
@@ -576,7 +576,7 @@ bool MinidumpGenerator::GenerateDumpFilePath(wstring* file_path) {
wstring id_str = GUIDString::GUIDToWString(&uuid_);
- *file_path = dump_path_ + TEXT("\\") + id_str + TEXT(".dmp");
+ *file_path = dump_path_ + TEXT(L"\\") + id_str + TEXT(L".dmp");
return true;
}
diff --git a/src/client/windows/handler/exception_handler.cc b/src/client/windows/handler/exception_handler.cc
index ad45b200..99783ad0 100644
--- a/src/client/windows/handler/exception_handler.cc
+++ b/src/client/windows/handler/exception_handler.cc
@@ -226,7 +226,7 @@ void ExceptionHandler::Initialize(
assert(handler_thread_ != NULL);
}
- dbghelp_module_ = LoadLibrary(L"dbghelp.dll");
+ dbghelp_module_ = LoadLibraryW(L"dbghelp.dll");
if (dbghelp_module_) {
minidump_write_dump_ = reinterpret_cast<MiniDumpWriteDump_type>(
GetProcAddress(dbghelp_module_, "MiniDumpWriteDump"));
@@ -235,7 +235,7 @@ void ExceptionHandler::Initialize(
// Load this library dynamically to not affect existing projects. Most
// projects don't link against this directly, it's usually dynamically
// loaded by dependent code.
- rpcrt4_module_ = LoadLibrary(L"rpcrt4.dll");
+ rpcrt4_module_ = LoadLibraryW(L"rpcrt4.dll");
if (rpcrt4_module_) {
uuid_create_ = reinterpret_cast<UuidCreate_type>(
GetProcAddress(rpcrt4_module_, "UuidCreate"));
@@ -917,13 +917,13 @@ bool ExceptionHandler::WriteMinidumpWithExceptionForProcess(
bool write_requester_stream) {
bool success = false;
if (minidump_write_dump_) {
- HANDLE dump_file = CreateFile(next_minidump_path_c_,
- GENERIC_WRITE,
- 0, // no sharing
- NULL,
- CREATE_NEW, // fail if exists
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ HANDLE dump_file = CreateFileW(next_minidump_path_c_,
+ GENERIC_WRITE,
+ 0, // no sharing
+ NULL,
+ CREATE_NEW, // fail if exists
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
if (dump_file != INVALID_HANDLE_VALUE) {
MINIDUMP_EXCEPTION_INFORMATION except_info;
except_info.ThreadId = requesting_thread_id;
--
2.28.0