MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / BuildPageHandler

Function BuildPageHandler

Kernel-Bridge/API/Hypervisor.cpp:1113–1183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111 }
1112
1113 void BuildPageHandler(MTRR_MEMORY_TYPE CacheType, UINT64 ReadPa, UINT64 WritePa, UINT64 ExecutePa, UINT64 ExecuteReadPa, UINT64 ExecuteWritePa, __out PAGE_HANDLER& Handler)
1114 {
1115 Handler.OnRead.Value = 0;
1116 Handler.OnWrite.Value = 0;
1117 Handler.OnExecute.Value = 0;
1118 Handler.OnExecuteRead.Value = 0;
1119 Handler.OnExecuteWrite.Value = 0;
1120
1121 if (ReadPa)
1122 {
1123 Handler.OnRead.Page4Kb.ReadAccess = TRUE;
1124 Handler.OnRead.Page4Kb.Type = static_cast<unsigned long long>(CacheType);
1125 Handler.OnRead.Page4Kb.PagePhysicalPfn = PAGE_TO_PFN(ReadPa);
1126 }
1127
1128 if (WritePa)
1129 {
1130 // We're unable to make a write-only page:
1131 Handler.OnWrite.Page4Kb.ReadAccess = TRUE; // Without it we will get the EPT_MISCONFIGURATION error
1132 Handler.OnWrite.Page4Kb.WriteAccess = TRUE;
1133 Handler.OnWrite.Page4Kb.Type = static_cast<unsigned long long>(CacheType);
1134 Handler.OnWrite.Page4Kb.PagePhysicalPfn = PAGE_TO_PFN(WritePa);
1135 }
1136
1137 if (ExecutePa)
1138 {
1139 Handler.OnExecute.Page4Kb.ExecuteAccess = TRUE;
1140 Handler.OnExecute.Page4Kb.Type = static_cast<unsigned long long>(CacheType);
1141 Handler.OnExecute.Page4Kb.PagePhysicalPfn = PAGE_TO_PFN(ExecutePa);
1142 }
1143
1144 if (ExecuteReadPa)
1145 {
1146 Handler.OnExecuteRead.Page4Kb.ReadAccess = TRUE;
1147 Handler.OnExecuteRead.Page4Kb.ExecuteAccess = TRUE;
1148 Handler.OnExecuteRead.Page4Kb.Type = static_cast<unsigned long long>(CacheType);
1149 Handler.OnExecuteRead.Page4Kb.PagePhysicalPfn = PAGE_TO_PFN(ExecuteReadPa);
1150 }
1151
1152 if (ExecuteWritePa)
1153 {
1154 Handler.OnExecuteWrite.Page4Kb.ReadAccess = TRUE;
1155 Handler.OnExecuteWrite.Page4Kb.WriteAccess = TRUE;
1156 Handler.OnExecuteWrite.Page4Kb.ExecuteAccess = TRUE;
1157 Handler.OnExecuteWrite.Page4Kb.Type = static_cast<unsigned long long>(CacheType);
1158 Handler.OnExecuteWrite.Page4Kb.PagePhysicalPfn = PAGE_TO_PFN(ExecuteWritePa);
1159 }
1160
1161 if (ReadPa && (ReadPa == WritePa))
1162 {
1163 Handler.OnRead.Page4Kb.WriteAccess = TRUE;
1164 Handler.OnWrite.Page4Kb.ReadAccess = TRUE;
1165 }
1166
1167 if (WritePa && (WritePa == ExecutePa))
1168 {
1169 Handler.OnWrite.Page4Kb.ExecuteAccess = TRUE;
1170 Handler.OnExecute.Page4Kb.WriteAccess = TRUE;

Callers 1

InterceptPageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected