PE-sieve
Scans all running processes. Recognizes and dumps a variety of potentially malicious implants (replaced/implanted PEs, shellcodes, hooks, in-memory patches).
Loading...
Searching...
No Matches
mempage_data.h
Go to the documentation of this file.
1#pragma once
2
3#include <windows.h>
4
5#include <peconv.h>
6
8
9namespace pesieve {
10
12 {
13 public:
14 MemPageData(HANDLE _process, bool _is_process_refl, ULONGLONG _start_va, ULONGLONG _stop_va)
15 : processHandle(_process), start_va(_start_va), stop_va(_stop_va),
16 is_listed_module(false),
17 is_info_filled(false),
18 is_process_refl(_is_process_refl)
19 {
20 fillInfo();
21 }
22
23 virtual ~MemPageData()
24 {
26 }
27
28 bool isRefl() const { return is_process_refl; }
29 bool fillInfo();
30 bool isInfoFilled() { return is_info_filled; }
31 size_t getLoadedSize(bool trimmed = false) { return loadedData.getDataSize(trimmed); }
32 const PBYTE getLoadedData(bool trimmed = false) { return (PBYTE)loadedData.getData(trimmed); }
33 const size_t getStartOffset(bool trimmed = false) { return loadedData.getStartOffset(trimmed); }
34
35 bool validatePtr(const LPVOID field_bgn, size_t field_size)
36 {
37 return loadedData.isValidPtr((BYTE*)field_bgn, field_size);
38 }
39
40 ULONGLONG start_va;
41 ULONGLONG stop_va;
42 DWORD protection;
47
48 ULONGLONG alloc_base;
49 ULONGLONG region_start;
50 ULONGLONG region_end;
51
52 std::string mapped_name;
53 std::string module_name;
54
55 // Checks if `loadedData` is already filled, if not, fills it by reading the remote memory.
56 bool load()
57 {
58 if (loadedData.isFilled()) {
59 return true;
60 }
61 if (!_loadRemote()) {
62 return false;
63 }
64 //check again:
65 if (loadedData.isFilled()) {
66 return true;
67 }
68 return false;
69 }
70
71 bool loadMappedName();
72 bool loadModuleName();
73
74 // checks if the memory area is mapped 1-to-1 from the file on the disk
75 bool isRealMapping();
76
78
79 protected:
80 bool _loadRemote();
81
83 {
85 }
86
88 const bool is_process_refl;
90 };
91
92}; //namespace pesieve
93
size_t getLoadedSize(bool trimmed=false)
DWORD protection
page protection
util::ByteBuffer loadedData
MemPageData(HANDLE _process, bool _is_process_refl, ULONGLONG _start_va, ULONGLONG _stop_va)
const bool is_process_refl
const PBYTE getLoadedData(bool trimmed=false)
ULONGLONG stop_va
the VA at which the read will stop
std::string mapped_name
if the region is mapped from a file, stores its file name
bool isRefl() const
bool validatePtr(const LPVOID field_bgn, size_t field_size)
ULONGLONG start_va
VA that was requested. May not be beginning of the region.
const size_t getStartOffset(bool trimmed=false)
std::string module_name
if the region is on the list of loaded PEs, stores its module name
size_t getDataSize(bool trimmed=false) const
Definition byte_buffer.h:55
const BYTE * getData(bool trimmed=false) const
Definition byte_buffer.h:65
size_t getStartOffset(bool trimmed) const
Definition byte_buffer.h:48
bool isValidPtr(BYTE *field_bgn, size_t field_size)