-
Notifications
You must be signed in to change notification settings - Fork 5
/
WTypes.lua
814 lines (646 loc) · 15.2 KB
/
WTypes.lua
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
local ffi = require"ffi"
local bit = require"bit"
local bnot = bit.bnot
local band = bit.band
local bor = bit.bor
local lshift = bit.lshift
local rshift = bit.rshift
ffi.cdef[[
typedef char * PCHAR;
typedef char * PSTR;
typedef const char * PCSTR;
typedef const short * PCWSTR;
typedef uint32_t * PDWORD;
typedef long * PLONG;
typedef uint64_t ULONGLONG;
typedef uint64_t ULONG64;
typedef uint64_t * PULONG64;
typedef uint64_t DWORD64;
typedef uint64_t * PDWORD64;
]]
ffi.cdef[[
// Basic Data types
typedef unsigned char BYTE;
typedef long BOOL;
typedef BYTE BOOLEAN;
typedef char CHAR;
typedef wchar_t WCHAR;
typedef uint16_t WORD;
typedef unsigned long DWORD;
typedef uint32_t DWORD32;
typedef int INT;
typedef int32_t INT32;
typedef int64_t INT64;
typedef float FLOAT;
typedef long LONG;
typedef signed int LONG32;
typedef int64_t LONGLONG;
typedef size_t SIZE_T;
typedef uint8_t BCHAR;
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned int UINT32;
typedef unsigned long ULONG;
typedef unsigned int ULONG32;
typedef unsigned short USHORT;
typedef uint64_t ULONGLONG;
// Some pointer types
typedef uint8_t * PBYTE;
typedef unsigned char *PUCHAR;
typedef const unsigned char *PCUCHAR;
typedef unsigned int *PUINT;
typedef unsigned int *PUINT32;
typedef unsigned long *PULONG;
typedef unsigned int *PULONG32;
typedef unsigned short *PUSHORT;
typedef LONGLONG *PLONGLONG;
typedef ULONGLONG *PULONGLONG;
typedef void * PVOID;
typedef DWORD * DWORD_PTR;
typedef intptr_t LONG_PTR;
typedef uintptr_t UINT_PTR;
typedef uintptr_t ULONG_PTR;
typedef ULONG_PTR * PULONG_PTR;
typedef DWORD * LPCOLORREF;
typedef BOOL * LPBOOL;
typedef char * LPSTR;
typedef short * LPWSTR;
typedef short * PWSTR;
typedef const short * LPCWSTR;
typedef LPSTR LPTSTR;
typedef DWORD * LPDWORD;
typedef void * LPVOID;
typedef WORD * LPWORD;
typedef const char * LPCSTR;
typedef LPCSTR LPCTSTR;
typedef const void * LPCVOID;
typedef LONG_PTR LRESULT;
typedef LONG_PTR LPARAM;
typedef UINT_PTR WPARAM;
typedef unsigned char TBYTE;
typedef char TCHAR;
typedef USHORT COLOR16;
typedef DWORD COLORREF;
// Special types
typedef WORD ATOM;
typedef DWORD LCID;
typedef USHORT LANGID;
// Various Handles
typedef void * HANDLE;
typedef HANDLE *PHANDLE;
typedef HANDLE LPHANDLE;
typedef void * HBITMAP;
typedef void * HBRUSH;
typedef void * HICON;
typedef HICON HCURSOR;
typedef HANDLE HDC;
typedef void * HDESK;
typedef HANDLE HDROP;
typedef HANDLE HDWP;
typedef HANDLE HENHMETAFILE;
typedef INT HFILE;
typedef HANDLE HFONT;
typedef void * HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HGLRC;
typedef HANDLE HHOOK;
typedef void * HINSTANCE;
typedef void * HKEY;
typedef void * HKL;
typedef HANDLE HLOCAL;
typedef void * HMEMF;
typedef HANDLE HMENU;
typedef HANDLE HMETAFILE;
typedef void HMF;
typedef HINSTANCE HMODULE;
typedef HANDLE HMONITOR;
typedef HANDLE HPALETTE;
typedef void * HPEN;
typedef LONG HRESULT;
typedef HANDLE HRGN;
typedef void * HRSRC;
typedef void * HSTR;
typedef HANDLE HSZ;
typedef void * HTASK;
typedef void * HWINSTA;
typedef HANDLE HWND;
// Ole Automation
typedef WCHAR OLECHAR;
typedef OLECHAR *LPOLESTR;
typedef const OLECHAR *LPCOLESTR;
//typedef char OLECHAR;
//typedef LPSTR LPOLESTR;
//typedef LPCSTR LPCOLESTR;
typedef OLECHAR *BSTR;
typedef BSTR *LPBSTR;
typedef DWORD ACCESS_MASK;
typedef ACCESS_MASK* PACCESS_MASK;
typedef LONG FXPT16DOT16, *LPFXPT16DOT16;
typedef LONG FXPT2DOT30, *LPFXPT2DOT30;
typedef int NTSTATUS;
]]
--[[
From guiddef
--]]
ffi.cdef[[
typedef struct {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID, UUID, *LPGUID;
]]
ffi.cdef[[
typedef const GUID * LPCGUID;
typedef const GUID * REFGUID;
typedef GUID IID;
typedef IID * LPIID;
typedef const IID * REFIID;
typedef GUID CLSID;
typedef CLSID * LPCLSID;
typedef const GUID * REFCLSID;
]]
local function bytecompare(a, b, n)
local res = true
for i=0,n-1 do
if a[i] ~= b[i] then
return false
end
end
return res
end
GUID = nil
GUID_mt = {
__tostring = function(self)
local res = string.format("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
self.Data1, self.Data2, self.Data3,
self.Data4[0], self.Data4[1],
self.Data4[2], self.Data4[3], self.Data4[4],
self.Data4[5], self.Data4[6], self.Data4[7])
return res
end,
__eq = function(a, b)
return (a.Data1 == b.Data1) and
(a.Data2 == b.Data2) and
(a.Data3 == b.Data3) and
bytecompare(a.Data4, b.Data4, 4)
end,
__index = {
Define = function(self, name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8 )
return GUID({ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }), name
end,
DefineOle = function(self, name, l, w1, w2)
return GUID({ l, w1, w2, { 0xC0,0,0,0,0,0,0,0x46 } }), name
end,
},
}
GUID = ffi.metatype("GUID", GUID_mt)
--require "CGuid"
GUID_NULL = GUID()
IID_NULL = GUID_NULL
CLSID_NULL = GUID_NULL
FMTID_NULL = GUID_NULL
function DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
return GUID():Define(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
end
DEFINE_UUID = DEFINE_GUID
function DEFINE_OLEGUID(name, l, w1, w2)
return GUID():DefineOle(name, l, w1, w2)
end
--[[
Useful routines
--]]
function IsEqualIID(riid1, riid2)
return riid1 == riid2
end
function IsEqualCLSID(rclsid1, rclsid2)
return rclsid1 == rclsid2
end
function IsEqualFMTID(rfmtid1, rfmtid2)
return rfmtid1 == rfmtid2
end
-- From Rpcrt4.h
Rpcrt4 = ffi.load("Rpcrt4")
ffi.cdef[[
int UuidCreate(UUID * Uuid);
int UuidFromStringA(const char * StringUuid, UUID * Uuid);
int UuidToStringA(UUID * Uuid , char ** StringUuid);
]]
-- Helpful function for constructing a UUID/GUID
-- from a string
function UUIDFromString(stringid)
local id = ffi.new("UUID[1]")
Rpcrt4.UuidFromStringA(stringid, id)
id = id[0]
return id
end
ffi.cdef[[
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
};
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
typedef struct _ULARGE_INTEGER
{
ULONGLONG QuadPart;
} ULARGE_INTEGER;
typedef struct _FILETIME
{
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
typedef struct _FILETIME *PFILETIME;
typedef struct _FILETIME *LPFILETIME;
typedef struct _SYSTEMTIME
{
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
typedef struct _SECURITY_ATTRIBUTES {
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
typedef USHORT SECURITY_DESCRIPTOR_CONTROL;
typedef USHORT *PSECURITY_DESCRIPTOR_CONTROL;
typedef PVOID PSID;
typedef struct _ACL
{
UCHAR AclRevision;
UCHAR Sbz1;
USHORT AclSize;
USHORT AceCount;
USHORT Sbz2;
} ACL, *PACL;
typedef struct _SECURITY_DESCRIPTOR
{
UCHAR Revision;
UCHAR Sbz1;
SECURITY_DESCRIPTOR_CONTROL Control;
PSID Owner;
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
typedef struct _COAUTHIDENTITY
{
USHORT *User;
ULONG UserLength;
USHORT *Domain;
ULONG DomainLength;
USHORT *Password;
ULONG PasswordLength;
ULONG Flags;
} COAUTHIDENTITY;
typedef struct _COAUTHINFO
{
DWORD dwAuthnSvc;
DWORD dwAuthzSvc;
LPWSTR pwszServerPrincName;
DWORD dwAuthnLevel;
DWORD dwImpersonationLevel;
COAUTHIDENTITY *pAuthIdentityData;
DWORD dwCapabilities;
} COAUTHINFO;
typedef LONG SCODE;
typedef SCODE *PSCODE;
typedef
enum tagMEMCTX {
MEMCTX_TASK = 1,
MEMCTX_SHARED = 2,
MEMCTX_MACSYSTEM = 3,
MEMCTX_UNKNOWN = -1,
MEMCTX_SAME = -2
} MEMCTX;
typedef
enum tagMSHLFLAGS
{ MSHLFLAGS_NORMAL = 0,
MSHLFLAGS_TABLESTRONG = 1,
MSHLFLAGS_TABLEWEAK = 2,
MSHLFLAGS_NOPING = 4,
MSHLFLAGS_RESERVED1 = 8,
MSHLFLAGS_RESERVED2 = 16,
MSHLFLAGS_RESERVED3 = 32,
MSHLFLAGS_RESERVED4 = 64
} MSHLFLAGS;
typedef
enum tagMSHCTX
{ MSHCTX_LOCAL = 0,
MSHCTX_NOSHAREDMEM = 1,
MSHCTX_DIFFERENTMACHINE = 2,
MSHCTX_INPROC = 3,
MSHCTX_CROSSCTX = 4
} MSHCTX;
typedef
enum tagDVASPECT
{ DVASPECT_CONTENT = 1,
DVASPECT_THUMBNAIL = 2,
DVASPECT_ICON = 4,
DVASPECT_DOCPRINT = 8
} DVASPECT;
typedef
enum tagSTGC
{ STGC_DEFAULT = 0,
STGC_OVERWRITE = 1,
STGC_ONLYIFCURRENT = 2,
STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4,
STGC_CONSOLIDATE = 8
} STGC;
typedef
enum tagSTGMOVE
{ STGMOVE_MOVE = 0,
STGMOVE_COPY = 1,
STGMOVE_SHALLOWCOPY = 2
} STGMOVE;
typedef
enum tagSTATFLAG
{ STATFLAG_DEFAULT = 0,
STATFLAG_NONAME = 1,
STATFLAG_NOOPEN = 2
} STATFLAG;
typedef void *HCONTEXT;
typedef struct _BYTE_BLOB
{
unsigned long clSize;
uint8_t abData[ 1 ];
} BYTE_BLOB;
typedef struct _WORD_BLOB
{
unsigned long clSize;
unsigned short asData[ 1 ];
} WORD_BLOB;
typedef struct _DWORD_BLOB
{
unsigned long clSize;
unsigned long alData[ 1 ];
} DWORD_BLOB;
typedef struct _FLAGGED_BYTE_BLOB
{
unsigned long fFlags;
unsigned long clSize;
uint8_t abData[ 1 ];
} FLAGGED_BYTE_BLOB;
typedef struct _FLAGGED_WORD_BLOB
{
unsigned long fFlags;
unsigned long clSize;
unsigned short asData[ 1 ];
} FLAGGED_WORD_BLOB;
typedef struct _BYTE_SIZEDARR
{
unsigned long clSize;
uint8_t *pData;
} BYTE_SIZEDARR;
typedef struct _SHORT_SIZEDARR
{
unsigned long clSize;
unsigned short *pData;
} WORD_SIZEDARR;
typedef struct _LONG_SIZEDARR
{
unsigned long clSize;
unsigned long *pData;
} DWORD_SIZEDARR;
]]
--typedef enum tagCLSCTX {
CLSCTX_INPROC_SERVER = 0x1
CLSCTX_INPROC_HANDLER = 0x2
CLSCTX_LOCAL_SERVER = 0x4
CLSCTX_INPROC_SERVER16 = 0x8
CLSCTX_REMOTE_SERVER = 0x10
CLSCTX_INPROC_HANDLER16 = 0x20
CLSCTX_RESERVED1 = 0x40
CLSCTX_RESERVED2 = 0x80
CLSCTX_RESERVED3 = 0x100
CLSCTX_RESERVED4 = 0x200
CLSCTX_NO_CODE_DOWNLOAD = 0x400
CLSCTX_RESERVED5 = 0x800
CLSCTX_NO_CUSTOM_MARSHAL = 0x1000
CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000
CLSCTX_NO_FAILURE_LOG = 0x4000
CLSCTX_DISABLE_AAA = 0x8000
CLSCTX_ENABLE_AAA = 0x10000
CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
CLSCTX_ENABLE_CLOAKING = 0x100000
CLSCTX_PS_DLL = 0x80000000
--} CLSCTX;
CLSCTX_VALID_MASK = bor(
CLSCTX_INPROC_SERVER ,
CLSCTX_INPROC_HANDLER ,
CLSCTX_LOCAL_SERVER ,
CLSCTX_INPROC_SERVER16 ,
CLSCTX_REMOTE_SERVER ,
CLSCTX_NO_CODE_DOWNLOAD ,
CLSCTX_NO_CUSTOM_MARSHAL ,
CLSCTX_ENABLE_CODE_DOWNLOAD ,
CLSCTX_NO_FAILURE_LOG ,
CLSCTX_DISABLE_AAA ,
CLSCTX_ENABLE_AAA ,
CLSCTX_FROM_DEFAULT_CONTEXT ,
CLSCTX_ACTIVATE_32_BIT_SERVER ,
CLSCTX_ACTIVATE_64_BIT_SERVER ,
CLSCTX_ENABLE_CLOAKING ,
CLSCTX_PS_DLL)
WDT_INPROC_CALL =( 0x48746457 )
WDT_REMOTE_CALL =( 0x52746457 )
WDT_INPROC64_CALL = ( 0x50746457 )
--[[
ffi.cdef[[
enum {
MAXSHORT = 32767,
MINSHORT = -32768,
MAXINT = 2147483647,
MININT = -2147483648,
MAXLONGLONG = 9223372036854775807LL,
MINLONGLONG = -9223372036854775807LL,
};
]]
--]]
ffi.cdef[[
typedef struct tagSIZE {
LONG cx;
LONG cy;
} SIZE, *PSIZE;
typedef struct tagPOINT {
int32_t x;
int32_t y;
} POINT, *PPOINT;
typedef struct _POINTL {
LONG x;
LONG y;
} POINTL, *PPOINTL;
typedef struct tagRECT {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
} RECT, *PRECT;
]]
RECT = nil
RECT_mt = {
__tostring = function(self)
local str = string.format("%d %d %d %d", self.left, self.top, self.right, self.bottom)
return str
end,
__index = {
}
}
RECT = ffi.metatype("RECT", RECT_mt)
ffi.cdef[[
typedef struct _TRIVERTEX {
LONG x;
LONG y;
COLOR16 Red;
COLOR16 Green;
COLOR16 Blue;
COLOR16 Alpha;
}TRIVERTEX, *PTRIVERTEX;
typedef struct _GRADIENT_TRIANGLE {
ULONG Vertex1;
ULONG Vertex2;
ULONG Vertex3;
}GRADIENT_TRIANGLE, *PGRADIENT_TRIANGLE;
typedef struct _GRADIENT_RECT {
ULONG UpperLeft;
ULONG LowerRight;
}GRADIENT_RECT, *PGRADIENT_RECT;
typedef struct tagRGBQUAD {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
typedef struct tagRGBTRIPLE {
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} RGBTRIPLE;
typedef struct tagBITMAP {
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
} BITMAP, *PBITMAP;
typedef struct tagBITMAPCOREHEADER {
DWORD bcSize;
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes;
WORD bcBitCount;
} BITMAPCOREHEADER, *PBITMAPCOREHEADER;
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;
typedef struct tagCIEXYZ {
FXPT2DOT30 ciexyzX;
FXPT2DOT30 ciexyzY;
FXPT2DOT30 ciexyzZ;
} CIEXYZ, * PCIEXYZ;
typedef struct tagCIEXYZTRIPLE {
CIEXYZ ciexyzRed;
CIEXYZ ciexyzGreen;
CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE, *PCIEXYZTRIPLE;
typedef struct {
DWORD bV4Size;
LONG bV4Width;
LONG bV4Height;
WORD bV4Planes;
WORD bV4BitCount;
DWORD bV4V4Compression;
DWORD bV4SizeImage;
LONG bV4XPelsPerMeter;
LONG bV4YPelsPerMeter;
DWORD bV4ClrUsed;
DWORD bV4ClrImportant;
DWORD bV4RedMask;
DWORD bV4GreenMask;
DWORD bV4BlueMask;
DWORD bV4AlphaMask;
DWORD bV4CSType;
CIEXYZTRIPLE bV4Endpoints;
DWORD bV4GammaRed;
DWORD bV4GammaGreen;
DWORD bV4GammaBlue;
} BITMAPV4HEADER, *PBITMAPV4HEADER;
typedef struct {
DWORD bV5Size;
LONG bV5Width;
LONG bV5Height;
WORD bV5Planes;
WORD bV5BitCount;
DWORD bV5Compression;
DWORD bV5SizeImage;
LONG bV5XPelsPerMeter;
LONG bV5YPelsPerMeter;
DWORD bV5ClrUsed;
DWORD bV5ClrImportant;
DWORD bV5RedMask;
DWORD bV5GreenMask;
DWORD bV5BlueMask;
DWORD bV5AlphaMask;
DWORD bV5CSType;
CIEXYZTRIPLE bV5Endpoints;
DWORD bV5GammaRed;
DWORD bV5GammaGreen;
DWORD bV5GammaBlue;
DWORD bV5Intent;
DWORD bV5ProfileData;
DWORD bV5ProfileSize;
DWORD bV5Reserved;
} BITMAPV5HEADER, *PBITMAPV5HEADER;
]]
BITMAPINFOHEADER = nil
BITMAPINFOHEADER_mt = {
__new = function(ct)
print("BITMAPINFOHEADER: new()");
return ffi.new(ct, ffi.sizeof(ct))
end,
__index = {
Init = function(self)
print("BITMAPINFOHEADER:Init()");
self.biSize = ffi.sizeof("BITMAPINFOHEADER")
end,
}
}
BITMAPINFOHEADER = ffi.metatype("BITMAPINFOHEADER", BITMAPINFOHEADER_mt)
BITMAPINFO = nil
BITMAPINFO_mt = {
__new = function(ct)
local obj = ffi.new(ct)
obj.bmiHeader:Init();
return obj;
end,
}
BITMAPINFO = ffi.metatype("BITMAPINFO", BITMAPINFO_mt)