summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/InjectCrashReporter.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-05 20:01:10 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-05 20:01:10 +0200
commitc3b63b831cd2c64700e875b28540212c7c881ac6 (patch)
treeedd98fcbd2004d3b562904f822bf6c3322fc7f52 /toolkit/crashreporter/InjectCrashReporter.cpp
parentd432e068a21c815d5d5e7bcbc1cc8c6e77a7d1e0 (diff)
parentcc07da9cb4d6e7a53f8d953427ffc2bca2e0c2df (diff)
downloadUXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar
UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.gz
UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.lz
UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.xz
UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.zip
Merge branch 'master' into 816
Diffstat (limited to 'toolkit/crashreporter/InjectCrashReporter.cpp')
-rw-r--r--toolkit/crashreporter/InjectCrashReporter.cpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/toolkit/crashreporter/InjectCrashReporter.cpp b/toolkit/crashreporter/InjectCrashReporter.cpp
deleted file mode 100644
index 1b79f2cd1..000000000
--- a/toolkit/crashreporter/InjectCrashReporter.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "InjectCrashReporter.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsDirectoryServiceDefs.h"
-#include "client/windows/crash_generation/crash_generation_client.h"
-#include "nsExceptionHandler.h"
-#include "LoadLibraryRemote.h"
-#include "nsWindowsHelpers.h"
-
-using google_breakpad::CrashGenerationClient;
-using CrashReporter::GetChildNotificationPipe;
-
-namespace mozilla {
-
-InjectCrashRunnable::InjectCrashRunnable(DWORD pid)
- : mPID(pid)
-{
- nsCOMPtr<nsIFile> dll;
- nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(dll));
- if (NS_SUCCEEDED(rv)) {
- dll->Append(NS_LITERAL_STRING("breakpadinjector.dll"));
- dll->GetPath(mInjectorPath);
- }
-}
-
-NS_IMETHODIMP
-InjectCrashRunnable::Run()
-{
- if (mInjectorPath.IsEmpty())
- return NS_OK;
-
- nsAutoHandle hProcess(
- OpenProcess(PROCESS_CREATE_THREAD |
- PROCESS_QUERY_INFORMATION |
- PROCESS_DUP_HANDLE |
- PROCESS_VM_OPERATION |
- PROCESS_VM_WRITE |
- PROCESS_VM_READ, FALSE, mPID));
- if (!hProcess) {
- NS_WARNING("Unable to open remote process handle for crashreporter injection.");
- return NS_OK;
- }
-
- void* proc = LoadRemoteLibraryAndGetAddress(hProcess, mInjectorPath.get(),
- "Start");
- if (!proc) {
- NS_WARNING("Unable to inject crashreporter DLL.");
- return NS_OK;
- }
-
- HANDLE hRemotePipe =
- CrashGenerationClient::DuplicatePipeToClientProcess(
- NS_ConvertASCIItoUTF16(GetChildNotificationPipe()).get(),
- hProcess);
- if (INVALID_HANDLE_VALUE == hRemotePipe) {
- NS_WARNING("Unable to duplicate crash reporter pipe to process.");
- return NS_OK;
- }
-
- nsAutoHandle hThread(CreateRemoteThread(hProcess, nullptr, 0,
- (LPTHREAD_START_ROUTINE) proc,
- (void*) hRemotePipe, 0, nullptr));
- if (!hThread) {
- NS_WARNING("Unable to CreateRemoteThread");
-
- // We have to close the remote pipe or else our crash generation client
- // will be stuck unable to accept other remote requests.
- HANDLE toClose = INVALID_HANDLE_VALUE;
- if (DuplicateHandle(hProcess, hRemotePipe, ::GetCurrentProcess(),
- &toClose, 0, FALSE,
- DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
- CloseHandle(toClose);
- return NS_OK;
- }
- }
-
- return NS_OK;
-}
-
-} // namespace mozilla