-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cpp
More file actions
30 lines (28 loc) · 1002 Bytes
/
driver.cpp
File metadata and controls
30 lines (28 loc) · 1002 Bytes
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
#include <Windows.h>
#include <errhandlingapi.h>
#include <fileapi.h>
#include <ioapiset.h>
#include <iostream>
#include <usbiodef.h>
#include "driver.h"
static HANDLE CreateFile(LPCSTR lpFileName){
return CreateFile(lpFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
BOOL tppwrif(PTPPWRIF out, TPI index, BYTE flag){
DWORD dwOut = 0;
TPPWRIFIN in = { 0 };
in.index = (BYTE)index;
in.flag = flag;
HANDLE h = CreateFile("\\\\.\\TPPWRIF");
return DeviceIoControl(h, USB_CTL(0x810), &in, sizeof(in), out, sizeof(TPPWRIF), &dwOut, NULL);
}
IBMDW ibmpmdrv(IBM id, BYTE value, IBMRW flag){
DWORD dwOut = 0;
IBMDW out = { 0 }, in = { 0 };
in.value = value;
in.flag = (BYTE)flag;
HANDLE h = CreateFile("\\\\.\\IBMPmDrv");
if (!DeviceIoControl(h, USB_CTL((UINT)id), &in, sizeof(in), &out, sizeof(out), &dwOut, NULL))
std::cout << "mecker: " << GetLastError() << "\n";
return out;
}