Skip to content

Instantly share code, notes, and snippets.

@clod81
Created April 27, 2024 08:38
Show Gist options
  • Save clod81/ec277831a68c5ad242fa801fa74e556c to your computer and use it in GitHub Desktop.
Save clod81/ec277831a68c5ad242fa801fa74e556c to your computer and use it in GitHub Desktop.
Windows C program to find the addresses of kernel drivers
#include <Windows.h>
#include <psapi.h>
#include <stdio.h>
void main() {
LPVOID DriverBases[1024];
CHAR DriverName[100];
DWORD Needed;
ULONG i, DriverCount;
if (!EnumDeviceDrivers(DriverBases, sizeof(DriverBases), &Needed) || (Needed >= sizeof(DriverBases))) {
printf("nope\n");
return;
}
DriverCount = Needed / sizeof(DriverBases[0]);
printf("driver count %i\n", DriverCount);
for (i = 0; i < DriverCount; i++) {
if (!GetDeviceDriverBaseNameA(DriverBases[i], DriverName, sizeof(DriverName))) {
continue;
}
printf("driver name %s - %p\n", DriverName, DriverBases[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment