mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 17:30:09 +08:00
Add ReadMinidumpUTF16String
Change-Id: If0f33e39bad29ade28eaab8dc064318253e7e70e Reviewed-on: https://chromium-review.googlesource.com/c/1290170 Commit-Queue: Casey Dahlin <sadmac@google.com> Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
fa96a04fc6
commit
456476c3f6
@ -17,14 +17,18 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "minidump/minidump_extensions.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
||||
|
||||
bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
||||
namespace {
|
||||
|
||||
template<typename StringType>
|
||||
bool ReadMinidumpString(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
std::string* string) {
|
||||
StringType* string) {
|
||||
if (rva == 0) {
|
||||
string->clear();
|
||||
return true;
|
||||
@ -39,7 +43,7 @@ bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string local_string(string_size, '\0');
|
||||
StringType local_string(string_size / sizeof((*string)[0]), '\0');
|
||||
if (!file_reader->ReadExactly(&local_string[0], string_size)) {
|
||||
return false;
|
||||
}
|
||||
@ -48,5 +52,33 @@ bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
std::string* string) {
|
||||
return ReadMinidumpString(file_reader, rva, string);
|
||||
}
|
||||
|
||||
bool ReadMinidumpUTF16String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
base::string16* string) {
|
||||
return ReadMinidumpString(file_reader, rva, string);
|
||||
}
|
||||
|
||||
bool ReadMinidumpUTF16String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
std::string* string) {
|
||||
base::string16 string_raw;
|
||||
|
||||
if (!ReadMinidumpString(file_reader, rva, &string_raw)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
base::UTF16ToUTF8(string_raw.data(), string_raw.size(), string);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string16.h"
|
||||
#include "util/file/file_reader.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -34,6 +35,24 @@ bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
std::string* string);
|
||||
|
||||
//! \brief Reads a MinidumpUTF16String from a minidump file at offset \a rva in
|
||||
//! \a file_reader, and returns it in \a string.
|
||||
//!
|
||||
//! \return `true` on success, with \a string set. `false` on failure, with a
|
||||
//! message logged.
|
||||
bool ReadMinidumpUTF16String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
base::string16* string);
|
||||
|
||||
//! \brief Reads a MinidumpUTF16String from a minidump file at offset \a rva in
|
||||
//! \a file_reader, and returns it in \a string.
|
||||
//!
|
||||
//! \return `true` on success, with \a string set. `false` on failure, with a
|
||||
//! message logged.
|
||||
bool ReadMinidumpUTF16String(FileReaderInterface* file_reader,
|
||||
RVA rva,
|
||||
std::string* string);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user