MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / Refresh

Method Refresh

WinArk/KernelNotifyTable.cpp:166–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166void CKernelNotifyTable::Refresh() {
167#ifdef _WIN64
168 static ULONG Max = 64;
169#else
170 static ULONG Max = 8;
171#endif
172
173 ULONG count;
174 ProcessNotifyCountData data;
175
176 data.pCount = (PULONG)SymbolHelper::GetKernelSymbolAddressFromName("PspCreateProcessNotifyRoutineCount");
177 data.pExCount = (PULONG)SymbolHelper::GetKernelSymbolAddressFromName("PspCreateProcessNotifyRoutineExCount");
178 count = DriverHelper::GetProcessNotifyCount(&data);
179 NotifyInfo info;
180 info.Count = count;
181 info.pRoutine = (void*)SymbolHelper::GetKernelSymbolAddressFromName("PspCreateProcessNotifyRoutine");
182
183 m_Table.data.n = 0;
184 m_Table.data.info.clear();
185
186 // Enum CreateProcessNotify
187 if (count > 0) {
188 SIZE_T size = Max * sizeof(void*) + sizeof(ULONG);
189 wil::unique_virtualalloc_ptr<> buffer(::VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE));
190
191 KernelCallbackInfo* p = (KernelCallbackInfo*)buffer.get();
192 if (p != nullptr) {
193 p->Count = count + 1;
194 DriverHelper::EnumProcessNotify(&info, p);
195 for (int i = 0; i < count; i++) {
196 CallbackInfo info;
197 info.Routine = p->Address[i];
198 info.Type = CallbackType::CreateProcessNotify;
199 info.Module = Helpers::GetKernelModuleByAddress((ULONG_PTR)info.Routine);
200 std::wstring path = Helpers::StringToWstring(info.Module);
201 info.Company = GetCompanyName(path);
202 m_Table.data.info.push_back(std::move(info));
203 }
204 }
205 }
206
207 ULONG offset = SymbolHelper::GetKernelStructMemberOffset("_OBJECT_TYPE", "CallbackList");
208 KernelNotifyInfo notifyInfo;
209 notifyInfo.Type = NotifyType::ProcessObjectNotify;
210 notifyInfo.Offset = offset;
211 count = DriverHelper::GetObCallbackCount(&notifyInfo);
212 if (count > 0) {
213 SIZE_T size = Max * sizeof(ObCallbackInfo);
214 wil::unique_virtualalloc_ptr<> buffer(::VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE));
215
216 ObCallbackInfo* p = (ObCallbackInfo*)buffer.get();
217 if (p != nullptr) {
218 DriverHelper::EnumObCallbackNotify(&notifyInfo, p, size);
219 for (int i = 0; i < count; i++) {
220 CallbackInfo info;
221 info.Routine = p[i].PostOperation;
222 info.Type = CallbackType::ProcessObPostOperationNotify;
223 info.Module = Helpers::GetKernelModuleByAddress((ULONG_PTR)info.Routine);

Callers

nothing calls this directly

Calls 5

GetObCallbackCountFunction · 0.85
EnumObCallbackNotifyFunction · 0.85
clearMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected