终于的我回来了,之前因为某某DOTA比赛缠身啊~所以长时间没更新
看<Undocumented Windows 2000 Secrets>写出来的,貌似用NtQuerySystemInformation之类的函数也可以实现.
#include <windows.h>
#include <psapi.h>
#pragma comment(lib, "psapi")
#define SIZE_MINIMUM 0x00000100 // minimum list size
typedef PVOID *PPVOID;
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwSize = SIZE_MINIMUM * sizeof(PVOID);
DWORD dwCount = 0;
PPVOID ppList = NULL;
while ((ppList = (PPVOID)LocalAlloc(LMEM_FIXED, dwSize))!=NULL)
{
if ((EnumDeviceDrivers(ppList, dwSize, &dwCount)) &&
(dwCount < dwSize))
{
dwCount /= sizeof(PVOID);
break;
}
dwCount = 0;
LocalFree(ppList);
ppList = NULL;
if ((dwSize <<= 1) > (SIZE_MINIMUM * sizeof(PVOID)))
{
break;
}
}
CHAR szFileName[MAX_PATH] = {0};
for (DWORD dw = 0;dw < dwCount;dw++)
{
ZeroMemory(szFileName,MAX_PATH);
GetDeviceDriverFileNameA(ppList[dw],szFileName,MAX_PATH);
puts(szFileName);
}
return 0;
}
看<Undocumented Windows 2000 Secrets>写出来的,貌似用NtQuerySystemInformation之类的函数也可以实现.
#include <windows.h>
#include <psapi.h>
#pragma comment(lib, "psapi")
#define SIZE_MINIMUM 0x00000100 // minimum list size
typedef PVOID *PPVOID;
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwSize = SIZE_MINIMUM * sizeof(PVOID);
DWORD dwCount = 0;
PPVOID ppList = NULL;
while ((ppList = (PPVOID)LocalAlloc(LMEM_FIXED, dwSize))!=NULL)
{
if ((EnumDeviceDrivers(ppList, dwSize, &dwCount)) &&
(dwCount < dwSize))
{
dwCount /= sizeof(PVOID);
break;
}
dwCount = 0;
LocalFree(ppList);
ppList = NULL;
if ((dwSize <<= 1) > (SIZE_MINIMUM * sizeof(PVOID)))
{
break;
}
}
CHAR szFileName[MAX_PATH] = {0};
for (DWORD dw = 0;dw < dwCount;dw++)
{
ZeroMemory(szFileName,MAX_PATH);
GetDeviceDriverFileNameA(ppList[dw],szFileName,MAX_PATH);
puts(szFileName);
}
return 0;
}