当前位置:网站首页>Access to display the data
Access to display the data
2022-07-30 09:21:00 【ThatAllOver】
#define _CRT_NON_CONFORMING_SWPRINTFS
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <tchar.h>
#include <initguid.h>
#include <wmistr.h>
DEFINE_GUID(wmi_monitor_id_guid, 0x671a8285, 0x4edb, 0x4cae, 0x99, 0xfe, 0x69, 0xa1, 0x5c, 0x48, 0xc0, 0xbc);
typedef struct _wmi_monitor_id
{
unsigned short product_code_id[16];
unsigned short serial_number_id[16];
unsigned short manufacturer_name[16];
unsigned char week_of_manufacture;
unsigned short year_of_manufacture;
unsigned short user_friendly_name_length;
unsigned short user_friendly_name[1];
} wmi_monitor_id;
#define OFFSET_TO_PTR(base_address, offset_length) ((PBYTE)((PBYTE)base_address + offset_length))
typedef HRESULT(WINAPI* FWmiOpenBlock) (IN LPGUID , IN DWORD , OUT PLONG);
typedef HRESULT(WINAPI* FWmiQueryAllDataW) (IN LONG , PULONG , OUT PUCHAR);
typedef HRESULT(WINAPI* FWmiCloseBlock) (IN LONG);
int main(int argc, char* argv[])
{
HMODULE advapi32 = LoadLibraryW(L"Advapi32.dll");
if (!advapi32) return 0;
wprintf(L"current process id = %d \r\n", GetCurrentProcessId());
FWmiOpenBlock WmiOpenBlock = (FWmiOpenBlock)GetProcAddress(advapi32, "WmiOpenBlock");
FWmiQueryAllDataW WmiQueryAllData = (FWmiQueryAllDataW)GetProcAddress(advapi32, "WmiQueryAllDataW");
FWmiCloseBlock WmiCloseBlock = (FWmiCloseBlock)GetProcAddress(advapi32, "WmiCloseBlock");
if (WmiOpenBlock && WmiQueryAllData && WmiCloseBlock)
{
LONG handle = 0;
HRESULT hr = WmiOpenBlock((LPGUID)&wmi_monitor_id_guid, GENERIC_READ, &handle);
if (hr == S_OK)
{
ULONG buffer_size = 1024 * 4;
UCHAR* data_buffer = new UCHAR[buffer_size];
if (data_buffer)
{
memset(data_buffer, 0, buffer_size);
hr = WmiQueryAllData(handle, &buffer_size, data_buffer);
if (hr == S_OK)
{
while (true)
{
wmi_monitor_id* monitor_id = nullptr;
PWNODE_ALL_DATA all_data = (PWNODE_ALL_DATA)data_buffer;
if (all_data->WnodeHeader.Flags & WNODE_FLAG_FIXED_INSTANCE_SIZE)
monitor_id = (wmi_monitor_id*)&data_buffer[all_data->DataBlockOffset];
else
monitor_id = (wmi_monitor_id*)&data_buffer[all_data->OffsetInstanceDataAndLength[0].OffsetInstanceData];
ULONG offset = (ULONG)data_buffer[all_data->OffsetInstanceNameOffsets];
WCHAR* instance_name = (WCHAR*)OFFSET_TO_PTR(all_data, offset + sizeof(USHORT));
wprintf(L"instance name = %s \r\n", instance_name);
WCHAR* user_friendly_name = (WCHAR*)monitor_id->user_friendly_name;
wprintf(L"user friendly name = %s \r\n", user_friendly_name);
WCHAR* manufacturer_name = (WCHAR*)monitor_id->manufacturer_name;
wprintf(L"manufacturer name = %s \r\n", manufacturer_name);
WCHAR* product_code_id = (WCHAR*)monitor_id->product_code_id;
wprintf(L"product code id = %s \r\n", product_code_id);
WCHAR* serial_number_id = (WCHAR*)monitor_id->serial_number_id;
wprintf(L"serial number id = %s \r\n", serial_number_id);
if (!all_data->WnodeHeader.Linkage) break;
data_buffer += all_data->WnodeHeader.Linkage;
}
}
delete[] data_buffer;
}
WmiCloseBlock(handle);
}
}
system("pause");
return 0;
}

边栏推荐
- OA Project Pending Meeting & History Meeting & All Meetings
- Apache DolphinScheduler's new generation of distributed workflow task scheduling platform in practice - Part 1
- 智能存储柜——解决您的存储需求
- JS中如何阻止事件冒泡和默认行为
- 深入浅出零钱兑换问题——背包问题的套壳
- Judging from the Internet:
- cmd命令
- 都说FPGA高端,它到底能干啥?
- 经典毕业设计:基于SSM实现高校后勤报修系统
- Flutter 环境变量配置和flutter doctor中的错误解决
猜你喜欢

hcip实验

Taosi TDengine 2.6+ optimization parameters

基于SSM实现个性化健康饮食推荐系统

信号完整性测试

How to run dist file on local computer

ACL 2022 | Introduce angular margin to construct comparative learning objectives and enhance text semantic discrimination ability

英语语法-名词性从句

【三子棋】——玩家VS电脑(C语言实现)

积分简明笔记-第二类曲线积分的类型

Apache DolphinScheduler's new generation of distributed workflow task scheduling platform in practice - Part 1
随机推荐
看完这100个客户需求,我终于知道企业文档管理的秘密
【Kotlin 中的类和继承】
【零基础玩转BLDC系列】以GD32F30x为例定时器相关功能详解
香港服务器iis配置web服务器如何操作?
2022杭电多校第二场
七大排序之直接选择排序
[Fun BLDC series with zero basics] Taking GD32F30x as an example, the timer related functions are explained in detail
ACL 2022 | 引入角度margin构建对比学习目标,增强文本语义判别能力
Webview中的超链接点击到外部浏览器打开
sql注入数据库原理详解
嘉为鲸翼·多云管理平台荣获信通院可信云技术服务最佳实践
开关电源波纹的产生、测量及抑制,一篇全搞定!
Flutter 环境变量配置和flutter doctor中的错误解决
Detailed description of iperf3 parameter options
Circuit analysis: constant current source circuit composed of op amp and triode
It is said that FPGA is high-end, what can it do?
电源完整性基础知识
Splunk tag 的利用场景
智能存储柜——解决您的存储需求
function (1)