mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-29 08:39:44 +08:00
bed7a543c0
This is as a precursor to ProcessReader. Some basic functionality is included for now, with more to be added later as necessary. The PEB code is pretty icky -- walking the doubly-linked list in the target's address space is cumbersome. The alternative is to use EnumProcessModules. That would work but: 1) needs different APIs for XP and Vista 64+ 2) retrieves modules in memory-location order, rather than initialization order. I felt retrieving them in initialization order might be useful when detecting third party DLL injections. In the end, we may want to make both orders available. R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/977003003
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include <stdlib.h>
|
|
#include <wchar.h>
|
|
#include <windows.h>
|
|
|
|
// A simple binary to be loaded and inspected by ProcessInfo.
|
|
int wmain(int argc, wchar_t** argv) {
|
|
if (argc != 3)
|
|
abort();
|
|
|
|
// Get handles to the events we use to communicate with our parent.
|
|
HANDLE started_event = CreateEvent(nullptr, true, false, argv[1]);
|
|
HANDLE done_event = CreateEvent(nullptr, true, false, argv[2]);
|
|
if (!started_event || !done_event)
|
|
abort();
|
|
|
|
// Load an unusual module (that we don't depend upon) so we can do an
|
|
// existence check.
|
|
if (!LoadLibrary(L"lz32.dll"))
|
|
abort();
|
|
|
|
if (!SetEvent(started_event))
|
|
abort();
|
|
|
|
if (WaitForSingleObject(done_event, INFINITE) != WAIT_OBJECT_0)
|
|
abort();
|
|
|
|
CloseHandle(done_event);
|
|
CloseHandle(started_event);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|