#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <Psapi.h>
#include <shlwapi.h> //PathFileExists
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "shlwapi.lib")
#define ARRAY_SIZE 1024
int
main(
int
argc,
char
*argv[])
{
DWORD
cbNeeded = 0;
LPVOID
drivers[ARRAY_SIZE] = {0};
int
cDrivers = 0, i = 0;
if
(EnumDeviceDrivers(drivers,
sizeof
(drivers), &cbNeeded) &&
cbNeeded <
sizeof
(drivers))
{
char
szDriver[ARRAY_SIZE] = {0};
char
szPath[ARRAY_SIZE] = {0};
char
szDbgHelp[ARRAY_SIZE] = {0};
char
szSystemPath[ARRAY_SIZE] = {0};
cDrivers = cbNeeded /
sizeof
(
LPVOID
);
bool
bDetect = FALSE;
GetSystemDirectory(szSystemPath,
sizeof
(szSystemPath));
strcat_s(szSystemPath,
"\\dbghelp.dll"
);
for
(i = 0; i < cDrivers; i++)
{
if
(GetDeviceDriverBaseName(drivers[i], szDriver,
sizeof
(szDriver) /
sizeof
(
LPVOID
)))
{
printf
(
"%d:%s\n"
, i+1, szDriver);
GetDeviceDriverFileName(drivers[i], szPath,
sizeof
(szPath));
if
(szPath[1] ==
'?'
)
{
int
len =
strlen
(szPath);
do
{
len--;
}
while
(szPath[len] !=
'\\'
);
do
{
len--;
}
while
(szPath[len] !=
'\\'
);
szPath[len + 1] =
'\0'
;
for
(
int
j = 0; j < len; j++)
{
szPath[j] = szPath[j + 4];
}
sprintf_s(szDbgHelp,
"%sdbghelp.dll"
, szPath);
if
(PathFileExists(szDbgHelp))
{
if
(_strcmpi(szSystemPath, szDbgHelp) != 0)
{
bDetect = TRUE;
break
;
}
else
{
bDetect = FALSE;
}
}
}
}
}
if
(bDetect)
{
printf_s(
"Detect OD\n"
);
printf_s(
"Path: %s\n"
, szPath);
printf_s(
"SOD Name: %s\n"
, szDriver);
}
else
{
printf_s(
"Do not Detect OD\n"
);
}
getchar
();
}
}