Apply clang-format code style to all source files
This commit is contained in:
+57
-75
@@ -1,5 +1,5 @@
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
@@ -14,69 +14,62 @@
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static HDEVINFO (WINAPI *next_SetupDiGetClassDevsW)(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags);
|
||||
static HDEVINFO(WINAPI *next_SetupDiGetClassDevsW)(
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiEnumDeviceInfo)(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data);
|
||||
static BOOL(WINAPI *next_SetupDiEnumDeviceInfo)(
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
static BOOL(WINAPI *next_SetupDiGetDeviceRegistryPropertyA)(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
|
||||
static BOOL (WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
||||
static BOOL(WINAPI *next_SetupDiDestroyDeviceInfoList)(HDEVINFO dev_info);
|
||||
|
||||
/* API hooks */
|
||||
|
||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags);
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags);
|
||||
|
||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data);
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data);
|
||||
|
||||
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *need_nbytes);
|
||||
|
||||
static BOOL WINAPI my_SetupDiDestroyDeviceInfoList(HDEVINFO dev_info);
|
||||
|
||||
static const struct hook_symbol monitor_setupapi_syms[] = {
|
||||
{
|
||||
.name = "SetupDiGetClassDevsW",
|
||||
.patch = my_SetupDiGetClassDevsW,
|
||||
.link = (void **) &next_SetupDiGetClassDevsW,
|
||||
}, {
|
||||
.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
||||
}, {
|
||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
||||
}, {
|
||||
.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
||||
.name = "SetupDiGetClassDevsW",
|
||||
.patch = my_SetupDiGetClassDevsW,
|
||||
.link = (void **) &next_SetupDiGetClassDevsW,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiEnumDeviceInfo",
|
||||
.patch = my_SetupDiEnumDeviceInfo,
|
||||
.link = (void **) &next_SetupDiEnumDeviceInfo,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiGetDeviceRegistryPropertyA",
|
||||
.patch = my_SetupDiGetDeviceRegistryPropertyA,
|
||||
.link = (void **) &next_SetupDiGetDeviceRegistryPropertyA,
|
||||
},
|
||||
{
|
||||
.name = "SetupDiDestroyDeviceInfoList",
|
||||
.patch = my_SetupDiDestroyDeviceInfoList,
|
||||
.link = (void **) &next_SetupDiDestroyDeviceInfoList,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -84,17 +77,14 @@ extern bool standard_def;
|
||||
static HDEVINFO monitor_hdevinfo;
|
||||
|
||||
static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
const GUID *class_guid,
|
||||
const wchar_t *enumerator,
|
||||
HWND hwnd,
|
||||
DWORD flags)
|
||||
const GUID *class_guid, const wchar_t *enumerator, HWND hwnd, DWORD flags)
|
||||
{
|
||||
HDEVINFO result;
|
||||
|
||||
result = next_SetupDiGetClassDevsW(class_guid, enumerator, hwnd, flags);
|
||||
|
||||
if ( result != INVALID_HANDLE_VALUE &&
|
||||
IsEqualGUID(class_guid, &monitor_guid)) {
|
||||
if (result != INVALID_HANDLE_VALUE &&
|
||||
IsEqualGUID(class_guid, &monitor_guid)) {
|
||||
monitor_hdevinfo = result;
|
||||
}
|
||||
|
||||
@@ -102,9 +92,7 @@ static HDEVINFO WINAPI my_SetupDiGetClassDevsW(
|
||||
}
|
||||
|
||||
static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
HDEVINFO dev_info,
|
||||
DWORD index,
|
||||
SP_DEVINFO_DATA *info_data)
|
||||
HDEVINFO dev_info, DWORD index, SP_DEVINFO_DATA *info_data)
|
||||
{
|
||||
if (dev_info != monitor_hdevinfo) {
|
||||
return next_SetupDiEnumDeviceInfo(dev_info, index, info_data);
|
||||
@@ -128,26 +116,20 @@ static BOOL WINAPI my_SetupDiEnumDeviceInfo(
|
||||
}
|
||||
|
||||
static BOOL WINAPI my_SetupDiGetDeviceRegistryPropertyA(
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *nbytes_out)
|
||||
HDEVINFO dev_info,
|
||||
SP_DEVINFO_DATA *info_data,
|
||||
DWORD prop,
|
||||
DWORD *reg_type,
|
||||
BYTE *bytes,
|
||||
DWORD nbytes,
|
||||
DWORD *nbytes_out)
|
||||
{
|
||||
const char *txt;
|
||||
size_t txt_nbytes;
|
||||
|
||||
if (dev_info != monitor_hdevinfo) {
|
||||
return next_SetupDiGetDeviceRegistryPropertyA(
|
||||
dev_info,
|
||||
info_data,
|
||||
prop,
|
||||
reg_type,
|
||||
bytes,
|
||||
nbytes,
|
||||
nbytes_out);
|
||||
dev_info, info_data, prop, reg_type, bytes, nbytes, nbytes_out);
|
||||
}
|
||||
|
||||
/* The only implemented property */
|
||||
@@ -199,10 +181,10 @@ static BOOL WINAPI my_SetupDiDestroyDeviceInfoList(HDEVINFO dev_info)
|
||||
void monitor_setupapi_insert_hooks(HMODULE target)
|
||||
{
|
||||
hook_table_apply(
|
||||
target,
|
||||
"setupapi.dll",
|
||||
monitor_setupapi_syms,
|
||||
lengthof(monitor_setupapi_syms));
|
||||
target,
|
||||
"setupapi.dll",
|
||||
monitor_setupapi_syms,
|
||||
lengthof(monitor_setupapi_syms));
|
||||
|
||||
log_info("Inserted monitor setupapi hooks into %p", target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user