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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
| /* Direct Message, asus G1S mini LCD controler
If you want to use this... drop me a line please
Copyright Captnoord (c) 2007
whereangelsdare [at] hotmail [dot] com
*/
/* Todo:
- Create a nice class for this
- Create a dll interface
- Create a few functions to fill the bitmap
- do a lot more...
*/
/* Default windows includes
*/
#include <stdio.h>
#include <tchar.h>
/* Default windows detection
*/
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
# define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
/* Project required includes
*/
#include "windows.h"
#include "setupapi.h"
/* some lazy typedefs
*/
typedef unsigned __int32 uint32;
/* Temp lib include
*/
#pragma comment(lib, "setupapi.lib")
/* Some hacky vc macro...
*/
#define strnicmp _strnicmp
/* Asus frame structure
*/
struct AsusFrame
{
char Header[0x11];
char Frame[0x100];
};
/* Proto's
*/
void InitHeader(char * Header, unsigned char linenumber);
uint32 WriteToLcd(HANDLE _Handle, const char * buffer, const uint32 size);
/* Data header, for picture sending
*/
char header[]=
{
0,
0x55,
0xAA,
0x10, // 0x10 seems to be the first row... 0x11 seems to be the second row
0x80,
0x01,
0x01,
0x00,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
};
/* very hacky way to init the device guid
*/
const char ClassGuid[] =
{
0xB2,
0x55,
0x1E,
0x4D,
0x6F,
0xF1,
0xCF,
0x11,
0x88,
0xCB,
0x0,
0x11,
0x11,
0x0,
0x0,
0x30
};
/* Guess what.. the main function
*/
int main()
{
// Gues what where we start with the init of the device
// we first search for the correct device
// then hook the device and get the filehandle
HDEVINFO DeviceInfoSet = SetupDiGetClassDevs((GUID*)&ClassGuid, 0, 0, 0x12u);
struct _SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
DeviceInterfaceData.cbSize = 28;
HANDLE AsusDIY;
bool Initialised = false;
if (DeviceInfoSet == HDEVINFO(-1))
{
MessageBoxA(NULL,"Direct Message: does not detect compatible devices","Direct Control error", MB_OK);
// handle errors -1 == errors
}
else
{
uint32 MemberIndex = 0;
DWORD RequiredSize = 0, size = 0;
while ( SetupDiEnumDeviceInterfaces(DeviceInfoSet, 0, (GUID*)&ClassGuid, MemberIndex, &DeviceInterfaceData) )
{
++MemberIndex;
SetupDiGetDeviceInterfaceDetailA(DeviceInfoSet, &DeviceInterfaceData, 0, 0, &RequiredSize, 0);
size = RequiredSize;
PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A)malloc(RequiredSize);
DeviceInterfaceDetailData->cbSize = sizeof(*DeviceInterfaceDetailData);
if ( SetupDiGetDeviceInterfaceDetailA(
DeviceInfoSet,
&DeviceInterfaceData,
DeviceInterfaceDetailData,
size,
&RequiredSize,
0)
)
{
printf("Device: %s detected\n", DeviceInterfaceDetailData->DevicePath);
if ( strnicmp(DeviceInterfaceDetailData->DevicePath, "\\\\?\\hid#vid_0B05&pid_1726", 0x19u) )
{
free( DeviceInterfaceDetailData);
}
else
{
printf("Device found, initialising\n");
AsusDIY = CreateFileA((LPCSTR)(DeviceInterfaceDetailData->DevicePath), GENERIC_READ | GENERIC_WRITE, 3u, 0, 3u, 0, 0);
if (AsusDIY == HANDLE(-1) )
{
// handle error
}
else
{
Initialised = true;
printf("Device initialised\n");
}
free (DeviceInterfaceDetailData);
}
}
}
}
//result = SetupDiDestroyDeviceInfoList(DeviceInfoSet);
BOOL xretult = SetupDiDestroyDeviceInfoList(DeviceInfoSet);
// allocate a new frame
char framex[0x100];
// fill it with some random FOR TESTING ONLY
for (uint32 i = 0; i < 0x100; i++)
{
framex[i] = rand() % 255; // get some random value
}
WriteToLcd(AsusDIY,framex,0x100);
CloseHandle(AsusDIY);
return 0;
}
void InitHeader(char * Header, unsigned char linenumber)
{
// base header
static char header[]=
{
0x00, // 0x00
0x55, // 0x55
0xAA, // 0xAA
0x10, // 0x10 seems to be the first row... 0x11 seems to be the second row
0x80, // 0x80
0x01, // 0x01
0x01, // 0x01
0x00, // 0x00
0x01, // 0x01
0x00, // 0x00
0x00, // 0x00
0x00, // 0x00
0x00, // 0x00
0x00, // 0x00
0x00, // 0x00
0x00, // 0x00
0x00 // 0x00
};
memcpy(Header,header,sizeof(header));
// I know this sucks.. I know I am lazy
if (linenumber == 0)
{
// do nothing
}
else
{
Header[3] = 0x11;
}
}
uint32 WriteToLcd(HANDLE _Handle, const char * buffer, const uint32 size)
{
AsusFrame NewFrame;
DWORD BytesWriten;
InitHeader((char *)&NewFrame.Header, 0);
memcpy(NewFrame.Frame, buffer,size);
WriteFile(_Handle, (char*)&NewFrame, size + sizeof(NewFrame.Header),&BytesWriten,0);
return BytesWriten;
} |