-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbzh_dell_smm_io_drv_fun.cpp
84 lines (71 loc) · 1.82 KB
/
bzh_dell_smm_io_drv_fun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SOURCE: /~https://github.com/424778940z/dell-fan-utility
#ifdef __cplusplus
extern "C"
{
#endif
#include "bzh_dell_smm_io_drv_fun.h"
SMBIOS_PKG smm_pkg;
#include <stdio.h>
#include <stdlib.h>
void display_error(ULONG errorcode)
{
printf("Error code:%lu \n",errorcode);
switch (errorcode)
{
case 0x7a:
printf("ERROR_INSUFFICIENT_BUFFER \n");
break;
case 0x57:
printf("ERROR_INVALID_PARAMETER \n");
break;
case 0x1f:
printf("ERROR_GEN_FAILURE \n");
break;
default:
printf("UNKNOWN ERROR \n");
break;
}
}
ULONG _stdcall dell_smm_io(ULONG cmd, ULONG data)
{
if (!IsInitialized)
{
printf("Initialization is not complete.\n");
return -1;
}
smm_pkg.cmd = cmd;
smm_pkg.data = data;
smm_pkg.stat1 = 0;
smm_pkg.stat2 = 0;
ULONG result_size = 0;
bool status_dic = DeviceIoControl(hDriver,
IOCTL_BZH_DELL_SMM_RWREG,
&smm_pkg,
sizeof(SMBIOS_PKG),
&smm_pkg,
sizeof(SMBIOS_PKG),
&result_size,
NULL);
if(status_dic == false)
{
//ULONG lsterr = GetLastError();
//display_error(lsterr);
return -1;
}
else
{
return smm_pkg.cmd;
}
}
ULONG dell_smm_io_set_fan_lv(ULONG fan_no, ULONG lv)
{
ULONG arg = (lv << 8) | fan_no;
return dell_smm_io(DELL_SMM_IO_SET_FAN_LV, arg);
}
ULONG dell_smm_io_get_fan_rpm(ULONG fan_no)
{
return dell_smm_io(DELL_SMM_IO_GET_FAN_RPM, fan_no);
}
#ifdef __cplusplus
}
#endif