Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Unified Diff: handler/win/crashy_test_program.cc

Issue 1379873005: win: Write memory map info as MINIDUMP_MEMORY_INFO[_LIST] (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-peb-more-2
Patch Set: headers Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compat/non_win/winnt.h ('k') | minidump/minidump.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: handler/win/crashy_test_program.cc
diff --git a/handler/win/crashy_test_program.cc b/handler/win/crashy_test_program.cc
index 622a5e5df08d3218dbdd2e5d1a2ab7fca32992e2..638098a68ebeed8b643f34f896980eb1dfa0f918 100644
--- a/handler/win/crashy_test_program.cc
+++ b/handler/win/crashy_test_program.cc
@@ -20,6 +20,7 @@
#define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
#endif
+#include "base/basictypes.h"
#include "base/logging.h"
#include "client/crashpad_client.h"
#include "tools/tool_support.h"
@@ -35,6 +36,45 @@ ULONG RtlNtStatusToDosError(NTSTATUS status) {
return rtl_nt_status_to_dos_error(status);
}
+void AllocateMemoryOfVariousProtections() {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+
+ const size_t kPageSize = system_info.dwPageSize;
+
+ const uint32_t kPageTypes[] = {
+ PAGE_NOACCESS,
+ PAGE_READONLY,
+ PAGE_READWRITE,
+ PAGE_EXECUTE,
+ PAGE_EXECUTE_READ,
+ PAGE_EXECUTE_READWRITE,
+
+ // PAGE_NOACCESS is invalid with PAGE_GUARD.
+ PAGE_READONLY | PAGE_GUARD,
+ PAGE_READWRITE | PAGE_GUARD,
+ PAGE_EXECUTE | PAGE_GUARD,
+ PAGE_EXECUTE_READ | PAGE_GUARD,
+ PAGE_EXECUTE_READWRITE | PAGE_GUARD,
+ };
+
+ // All of these allocations are leaked, we want to view them in windbg via
+ // !vprot.
+ void* reserve = VirtualAlloc(
+ nullptr, arraysize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
+ PCHECK(reserve) << "VirtualAlloc MEM_RESERVE";
+ uintptr_t reserve_as_int = reinterpret_cast<uintptr_t>(reserve);
+
+ for (size_t i = 0; i < arraysize(kPageTypes); ++i) {
+ void* result =
+ VirtualAlloc(reinterpret_cast<void*>(reserve_as_int + (kPageSize * i)),
+ kPageSize,
+ MEM_COMMIT,
+ kPageTypes[i]);
+ PCHECK(result) << "VirtualAlloc MEM_COMMIT " << i;
+ }
+}
+
void SomeCrashyFunction() {
// SetLastError and NTSTATUS so that we have something to view in !gle in
// windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the
@@ -61,6 +101,8 @@ int CrashyMain(int argc, char* argv[]) {
return 1;
}
+ AllocateMemoryOfVariousProtections();
+
SomeCrashyFunction();
return 0;
« no previous file with comments | « compat/non_win/winnt.h ('k') | minidump/minidump.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698