Skip to content

Commit 4f842dd

Browse files
committed
Added CopyOnWrite section protection.
1 parent 5f34625 commit 4f842dd

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

Memory/Section.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ public enum SectionProtection
1717

1818
Read = 1,
1919
Write = 2,
20-
Execute = 4,
20+
CopyOnWrite = 4,
21+
Execute = 8,
2122

22-
Guard = 8
23+
Guard = 16
2324
}
2425

2526
public enum SectionType

NativeCore/ReClassNET_Plugin.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ enum class SectionProtection
3232

3333
Read = 1,
3434
Write = 2,
35-
Execute = 4,
35+
CopyOnWrite = 4,
36+
Execute = 8,
3637

37-
Guard = 8
38+
Guard = 16
3839
};
3940

4041
inline SectionProtection operator|(SectionProtection lhs, SectionProtection rhs)

NativeCore/Windows/EnumerateRemoteSectionsAndModules.cpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,15 @@ void __stdcall EnumerateRemoteSectionsAndModules(RC_Pointer process, EnumerateRe
2525
section.BaseAddress = memInfo.BaseAddress;
2626
section.Size = memInfo.RegionSize;
2727

28-
switch (memInfo.Protect & 0xFF)
29-
{
30-
case PAGE_EXECUTE:
31-
section.Protection = SectionProtection::Execute;
32-
break;
33-
case PAGE_EXECUTE_READ:
34-
section.Protection = SectionProtection::Execute | SectionProtection::Read;
35-
break;
36-
case PAGE_EXECUTE_READWRITE:
37-
case PAGE_EXECUTE_WRITECOPY:
38-
section.Protection = SectionProtection::Execute | SectionProtection::Read | SectionProtection::Write;
39-
break;
40-
case PAGE_NOACCESS:
41-
section.Protection = SectionProtection::NoAccess;
42-
break;
43-
case PAGE_READONLY:
44-
section.Protection = SectionProtection::Read;
45-
break;
46-
case PAGE_READWRITE:
47-
case PAGE_WRITECOPY:
48-
section.Protection = SectionProtection::Read | SectionProtection::Write;
49-
break;
50-
}
51-
if ((memInfo.Protect & PAGE_GUARD) == PAGE_GUARD)
52-
{
53-
section.Protection |= SectionProtection::Guard;
54-
}
28+
section.Protection = SectionProtection::NoAccess;
29+
if ((memInfo.Protect & PAGE_EXECUTE) == PAGE_EXECUTE) section.Protection |= SectionProtection::Execute;
30+
if ((memInfo.Protect & PAGE_EXECUTE_READ) == PAGE_EXECUTE_READ) section.Protection |= SectionProtection::Execute | SectionProtection::Read;
31+
if ((memInfo.Protect & PAGE_EXECUTE_READWRITE) == PAGE_EXECUTE_READWRITE) section.Protection |= SectionProtection::Execute | SectionProtection::Read | SectionProtection::Write;
32+
if ((memInfo.Protect & PAGE_EXECUTE_WRITECOPY) == PAGE_EXECUTE_READWRITE) section.Protection |= SectionProtection::Execute | SectionProtection::Read | SectionProtection::CopyOnWrite;
33+
if ((memInfo.Protect & PAGE_READONLY) == PAGE_READONLY) section.Protection |= SectionProtection::Read;
34+
if ((memInfo.Protect & PAGE_READWRITE) == PAGE_READWRITE) section.Protection |= SectionProtection::Read | SectionProtection::Write;
35+
if ((memInfo.Protect & PAGE_WRITECOPY) == PAGE_WRITECOPY) section.Protection |= SectionProtection::Read | SectionProtection::CopyOnWrite;
36+
if ((memInfo.Protect & PAGE_GUARD) == PAGE_GUARD) section.Protection |= SectionProtection::Guard;
5537

5638
switch (memInfo.Type)
5739
{

0 commit comments

Comments
 (0)