| Index: util/win/process_info_test_child.cc
|
| diff --git a/util/win/process_info_test_child.cc b/util/win/process_info_test_child.cc
|
| index a0cf5c403a5f2f3963f4a4f2a87d50a54eaeb33e..c587f5b852de80a609f51cbdec10663321ddca79 100644
|
| --- a/util/win/process_info_test_child.cc
|
| +++ b/util/win/process_info_test_child.cc
|
| @@ -12,19 +12,20 @@
|
| // See the License for the specific language governing permissions and
|
| // limitations under the License.
|
|
|
| +#include <intrin.h>
|
| #include <stdlib.h>
|
| +#include <stdint.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)
|
| + if (argc != 2)
|
| 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)
|
| + // Get a handle to the event we use to communicate with our parent.
|
| + HANDLE done_event = CreateEvent(nullptr, true, false, argv[1]);
|
| + if (!done_event)
|
| abort();
|
|
|
| // Load an unusual module (that we don't depend upon) so we can do an
|
| @@ -32,14 +33,22 @@ int wmain(int argc, wchar_t** argv) {
|
| if (!LoadLibrary(L"lz32.dll"))
|
| abort();
|
|
|
| - if (!SetEvent(started_event))
|
| + HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
| + if (out == INVALID_HANDLE_VALUE)
|
| abort();
|
| + // We just want any valid address that's known to be code.
|
| + uint64_t code_address = reinterpret_cast<uint64_t>(_ReturnAddress());
|
| + DWORD bytes_written;
|
| + if (!WriteFile(
|
| + out, &code_address, sizeof(code_address), &bytes_written, nullptr) ||
|
| + bytes_written != sizeof(code_address)) {
|
| + abort();
|
| + }
|
|
|
| if (WaitForSingleObject(done_event, INFINITE) != WAIT_OBJECT_0)
|
| abort();
|
|
|
| CloseHandle(done_event);
|
| - CloseHandle(started_event);
|
|
|
| return EXIT_SUCCESS;
|
| }
|
|
|