Skip to content

Commit da0eedf

Browse files
committed
Swap (Windows): support multiple paging files
1 parent 1133cb6 commit da0eedf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/detection/swap/swap_windows.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77

88
const char* ffDetectSwap(FFSwapResult* swap)
99
{
10-
uint8_t buffer[1024];
10+
uint8_t buffer[4096];
1111
ULONG size = sizeof(buffer);
1212
SYSTEM_PAGEFILE_INFORMATION* pstart = (SYSTEM_PAGEFILE_INFORMATION*) buffer;
1313
if(!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size)))
1414
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
1515

16+
for (SYSTEM_PAGEFILE_INFORMATION* current = pstart; ; current = (SYSTEM_PAGEFILE_INFORMATION*)((uint8_t*) current + current->NextEntryOffset))
17+
{
18+
swap->bytesUsed += current->TotalUsed;
19+
swap->bytesTotal += current->CurrentSize;
20+
if (current->NextEntryOffset == 0)
21+
break;
22+
}
1623
uint32_t pageSize = instance.state.platform.sysinfo.pageSize;
17-
swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize;
18-
swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize;
24+
swap->bytesUsed *= pageSize;
25+
swap->bytesTotal *= pageSize;
1926

2027
return NULL;
2128
}

0 commit comments

Comments
 (0)