| Index: util/win/get_function.cc
|
| diff --git a/snapshot/minidump/minidump_string_reader.cc b/util/win/get_function.cc
|
| similarity index 52%
|
| copy from snapshot/minidump/minidump_string_reader.cc
|
| copy to util/win/get_function.cc
|
| index 6ea36089f60c726e2ec8c7a62e7b00a12ca8b16b..d498d30b77d7ea80a0090904afdd2d9af96c36aa 100644
|
| --- a/snapshot/minidump/minidump_string_reader.cc
|
| +++ b/util/win/get_function.cc
|
| @@ -12,38 +12,32 @@
|
| // See the License for the specific language governing permissions and
|
| // limitations under the License.
|
|
|
| -#include "snapshot/minidump/minidump_string_reader.h"
|
| +#include "util/win/get_function.h"
|
|
|
| #include "base/logging.h"
|
| -#include "minidump/minidump_extensions.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
|
|
| namespace crashpad {
|
| namespace internal {
|
|
|
| -bool ReadMinidumpUTF8String(FileReaderInterface* file_reader,
|
| - RVA rva,
|
| - std::string* string) {
|
| - if (rva == 0) {
|
| - string->clear();
|
| - return true;
|
| +FARPROC GetFunctionInternal(
|
| + const wchar_t* library, const char* function, bool required) {
|
| + HMODULE module = LoadLibrary(library);
|
| + DPCHECK(!required || module) << "LoadLibrary " << base::UTF16ToUTF8(library);
|
| + if (!module) {
|
| + return nullptr;
|
| }
|
|
|
| - if (!file_reader->SeekSet(rva)) {
|
| - return false;
|
| + // Strip off any leading :: that may have come from stringifying the
|
| + // function’s name.
|
| + if (function[0] == ':' && function[1] == ':' &&
|
| + function[2] && function[2] != ':') {
|
| + function += 2;
|
| }
|
|
|
| - uint32_t string_size;
|
| - if (!file_reader->ReadExactly(&string_size, sizeof(string_size))) {
|
| - return false;
|
| - }
|
| -
|
| - std::string local_string(string_size, '\0');
|
| - if (!file_reader->ReadExactly(&local_string[0], string_size)) {
|
| - return false;
|
| - }
|
| -
|
| - string->swap(local_string);
|
| - return true;
|
| + FARPROC proc = GetProcAddress(module, function);
|
| + DPCHECK(!required || proc) << "GetProcAddress " << function;
|
| + return proc;
|
| }
|
|
|
| } // namespace internal
|
|
|