9 MEMORY_BASIC_INFORMATION page_info = { 0 };
11 if (out !=
sizeof(page_info)) {
12 if (GetLastError() == ERROR_INVALID_PARAMETER) {
16 std::cout <<
"Could not query page: " << std::hex <<
start_va <<
". Error: " << GetLastError() << std::endl;
23 alloc_base = (ULONGLONG) page_info.AllocationBase;
32 const HMODULE mod_base = (HMODULE)this->alloc_base;
34 if (module_name.length() == 0) {
36 std::cerr <<
"Could not retrieve the module name. Base: " << std::hex << mod_base << std::endl;
40 this->module_name = module_name;
46 if (!isInfoFilled() && !fillInfo()) {
50 if (mapped_filename.length() == 0) {
52 std::cerr <<
"Could not retrieve the mapped name. Base: " << std::hex << this->alloc_base << std::endl;
56 this->mapped_name = mapped_filename;
62 if (!loadMappedName()) {
64 std::cerr <<
"Could not retrieve name" << std::endl;
68 PVOID old_val =
nullptr;
70 HANDLE file = CreateFileA(this->mapped_name.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
72 if(file == INVALID_HANDLE_VALUE) {
74 std::cerr <<
"Could not open file!" << std::endl;
78 HANDLE mapping = CreateFileMapping(file, 0, PAGE_READONLY, 0, 0, 0);
81 std::cerr <<
"Could not create mapping!" << std::endl;
86 BYTE *rawData = (BYTE*) MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
87 if (rawData ==
nullptr) {
89 std::cerr <<
"Could not map view of file: " << this->mapped_name << std::endl;
98 size_t r_size = GetFileSize(file, 0);
99 is_same = this->loadedData.isDataContained(rawData, r_size);
103 std::cerr <<
"[" << std::hex << start_va <<
"] Page not loaded!" << std::endl;
106 UnmapViewOfFile(rawData);
107 CloseHandle(mapping);
115 size_t region_size = size_t(this->region_end - this->start_va);
116 if (stop_va && ( stop_va >= start_va && stop_va < this->region_end)) {
117 region_size = size_t(this->stop_va - this->start_va);
120 if (region_size == 0) {
123 if (!loadedData.allocBuffer(region_size)) {
126 const bool can_force_access = is_process_refl ? true :
false;
127 const size_t size_read = peconv::read_remote_region(this->processHandle, (BYTE*)this->start_va, loadedData.data, loadedData.getDataSize(), can_force_access);
128 if (size_read == 0) {
131 std::cerr <<
"Cannot read remote memory!" << std::endl;
ULONGLONG start_va
VA that was requested. May not be beginning of the region.