// ==================================
// filename: EnumDeviceDriver.cpp
// compiler: vs2008
// author  : EdisonX (Edison.Shih.)
//   
//   **** all rights reserve ****
// ==================================

#include <windows.h>
#include <stdio.h>
#include <Psapi.h>
#pragma comment(lib, "psapi.lib")

int main()
{
        DWORD pid = GetCurrentProcessId();

        LPVOID ImageBase[2000];
        DWORD cbNeed, cnt, i;
        char BaseName[MAX_PATH], FileName[MAX_PATH];

        BOOL ret = EnumDeviceDrivers((LPVOID*)(ImageBase), 2000, &cbNeed);
        if(ret==FALSE) printf("fail.\n");

        cnt = cbNeed / sizeof(BYTE);

        for(i=0; i<cnt; i++){
                GetDeviceDriverBaseName(ImageBase[i], BaseName, MAX_PATH);
                GetDeviceDriverFileName(ImageBase[i], FileName, MAX_PATH);

                printf("\n===========================\n");
                printf("BaseName: %s\n", BaseName);
                printf("FileName: %s\n", FileName);
        }

        return 0;
}

 

edisonx 發表在 痞客邦 PIXNET 留言(0) 人氣()