-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNativeStructs.cs
1446 lines (1269 loc) · 46.8 KB
/
NativeStructs.cs
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/////////////////////////////////////////////////////////////////////////////////
// paint.net //
// Copyright (C) dotPDN LLC, Rick Brewster, and contributors. //
// All Rights Reserved. //
/////////////////////////////////////////////////////////////////////////////////
using PaintDotNet.Rendering;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace PaintDotNet.SystemLayer
{
internal static class NativeStructs
{
[StructLayout(LayoutKind.Explicit)]
public struct LARGE_INTEGER
{
[FieldOffset(0)]
public uint LowPart;
[FieldOffset(4)]
public int HighPart;
[FieldOffset(0)]
public long QuadPart;
}
[StructLayout(LayoutKind.Explicit)]
public struct ULARGE_INTEGER
{
[FieldOffset(0)]
public uint LowPart;
[FieldOffset(4)]
public uint HighPart;
[FieldOffset(0)]
public ulong QuadPart;
}
[StructLayout(LayoutKind.Sequential)]
public struct LUID
{
public uint LowPart;
public uint HighPart;
}
[StructLayout(LayoutKind.Sequential)]
public struct LUID_AND_ATTRIBUTES
{
public LUID Luid;
public uint Attributes;
}
[StructLayout(LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES
{
public uint PrivilegeCount;
public LUID_AND_ATTRIBUTES Privilege; // this is actually a LUID_AND_ATTRIBUTES[0] in the header files. we only ever need to take one privilege though so this is fine
}
[StructLayout(LayoutKind.Sequential)]
public struct PROCESS_INFORMATION
{
public IntPtr hProcess;
public IntPtr hThread;
public uint dwProcessId;
public uint dwThreadId;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STATSTG
{
public IntPtr pwcsName;
public NativeConstants.STGTY type;
public ulong cbSize;
public System.Runtime.InteropServices.ComTypes.FILETIME mtime;
public System.Runtime.InteropServices.ComTypes.FILETIME ctime;
public System.Runtime.InteropServices.ComTypes.FILETIME atime;
public uint grfMode;
public uint grfLocksSupported;
public Guid clsid;
public uint grfStateBits;
public uint reserved;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)]
public struct KNOWNFOLDER_DEFINITION
{
public NativeConstants.KF_CATEGORY category;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszName;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszCreator;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszDescription;
public Guid fidParent;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszRelativePath;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszParsingName;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszToolTip;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszLocalizedName;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszIcon;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszSecurity;
public uint dwAttributes;
public NativeConstants.KF_DEFINITION_FLAGS kfdFlags;
public Guid ftidType;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct PROPERTYKEY
{
public Guid fmtid;
public uint pid;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)]
public struct COMDLG_FILTERSPEC
{
[MarshalAs(UnmanagedType.LPWStr)]
public string pszName;
[MarshalAs(UnmanagedType.LPWStr)]
public string pszSpec;
}
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_INFO
{
public ushort wProcessorArchitecture;
public ushort wReserved;
public uint dwPageSize;
public IntPtr lpMinimumApplicationAddress;
public IntPtr lpMaximumApplicationAddress;
public UIntPtr dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OSVERSIONINFOEX
{
public static int SizeOf
{
get
{
return Marshal.SizeOf(typeof(OSVERSIONINFOEX));
}
}
public uint dwOSVersionInfoSize;
public uint dwMajorVersion;
public uint dwMinorVersion;
public uint dwBuildNumber;
public uint dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szCSDVersion;
public ushort wServicePackMajor;
public ushort wServicePackMinor;
public ushort wSuiteMask;
public byte wProductType;
public byte wReserved;
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public UIntPtr dwData;
public uint cbData;
public IntPtr lpData;
}
[StructLayout(LayoutKind.Sequential)]
public struct SHELLEXECUTEINFO
{
public uint cbSize;
public uint fMask;
public IntPtr hwnd;
[MarshalAs(UnmanagedType.LPTStr)] public string lpVerb;
[MarshalAs(UnmanagedType.LPTStr)] public string lpFile;
[MarshalAs(UnmanagedType.LPTStr)] public string lpParameters;
[MarshalAs(UnmanagedType.LPTStr)] public string lpDirectory;
public int nShow;
public IntPtr hInstApp;
public IntPtr lpIDList;
[MarshalAs(UnmanagedType.LPTStr)] public string lpClass;
public IntPtr hkeyClass;
public uint dwHotKey;
public IntPtr hIcon_or_hMonitor;
public IntPtr hProcess;
}
[StructLayout(LayoutKind.Sequential)]
public struct MEMORYSTATUSEX
{
public uint dwLength;
public uint dwMemoryLoad;
public ulong ullTotalPhys;
public ulong ullAvailPhys;
public ulong ullTotalPageFile;
public ulong ullAvailPageFile;
public ulong ullTotalVirtual;
public ulong ullAvailVirtual;
public ulong ullAvailExtendedVirtual;
}
[StructLayout(LayoutKind.Sequential)]
public struct RGBQUAD
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved;
}
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
}
public struct ICONINFO
: IDisposable
{
[MarshalAs(UnmanagedType.Bool)]
public bool fIcon;
public uint xHotspot;
public uint yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
public void Dispose()
{
if (this.hbmMask != IntPtr.Zero)
{
NativeMethods.DeleteObject(this.hbmMask);
this.hbmMask = IntPtr.Zero;
}
if (this.hbmColor != IntPtr.Zero)
{
NativeMethods.DeleteObject(this.hbmColor);
this.hbmColor = IntPtr.Zero;
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CIEXYZ
{
public int ciexyzX;
public int ciexyzY;
public int ciexyzZ;
}
[StructLayout(LayoutKind.Sequential)]
public struct CIEXYZTRIPLE
{
public CIEXYZ ciexyzRed;
public CIEXYZ ciexyzGreen;
public CIEXYZ ciexyzBlue;
}
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPV5HEADER
{
public uint bV5Size;
public int bV5Width;
public int bV5Height;
public ushort bV5Planes;
public ushort bV5BitCount;
public uint bV5Compression;
public uint bV5SizeImage;
public int bV5XPelsPerMeter;
public int bV5YPelsPerMeter;
public uint bV5ClrUsed;
public uint bV5ClrImportant;
public uint bV5RedMask;
public uint bV5GreenMask;
public uint bV5BlueMask;
public uint bV5AlphaMask;
public uint bV5CSType;
public CIEXYZTRIPLE bV5Endpoints;
public uint bV5GammaRed;
public uint bV5GammaGreen;
public uint bV5GammaBlue;
public uint bV5Intent;
public uint bV5ProfileData;
public uint bV5ProfileSize;
public uint bV5Reserved;
}
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFO
{
public BITMAPINFOHEADER bmiHeader;
public RGBQUAD bmiColors;
}
[StructLayout(LayoutKind.Sequential)]
public struct MEMORY_BASIC_INFORMATION
{
public IntPtr BaseAddress;
public IntPtr AllocationBase;
public uint AllocationProtect;
public IntPtr RegionSize;
public uint State;
public uint Protect;
public uint Type;
}
[StructLayout(LayoutKind.Sequential)]
public struct COMBOBOXINFO
{
public uint cbSize;
public RECT rcItem;
public RECT rcButton;
public uint stateButton;
public IntPtr hwndCombo;
public IntPtr hwndItem;
public IntPtr hwndList;
}
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
[MarshalAs(UnmanagedType.Bool)] public bool fErase;
public NativeStructs.RECT rcPaint;
[MarshalAs(UnmanagedType.Bool)] public bool fRestore;
[MarshalAs(UnmanagedType.Bool)] public bool fIncUpdate;
public uint rgbReserved0;
public uint rgbReserved1;
public uint rgbReserved2;
public uint rgbReserved3;
public uint rgbReserved4;
public uint rgbReserved5;
public uint rgbReserved6;
public uint rgbReserved7;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LOGFONTW
: IEquatable<LOGFONTW>
{
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
// Split the lfFaceName string across several fields. This way we can
// have a blittable type and take the address of it from managed code.
// LF_FACESIZE is 32, multiplied by 2 bytes per char is 64.
private uint lfFaceName1;
private uint lfFaceName2;
private uint lfFaceName3;
private uint lfFaceName4;
private uint lfFaceName5;
private uint lfFaceName6;
private uint lfFaceName7;
private uint lfFaceName8;
private uint lfFaceName9;
private uint lfFaceName10;
private uint lfFaceName11;
private uint lfFaceName12;
private uint lfFaceName13;
private uint lfFaceName14;
private uint lfFaceName15;
private uint lfFaceName16;
private const int lfFaceNameSize = 2 * NativeConstants.LF_FACESIZE;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
public unsafe string lfFaceName
{
get
{
fixed (uint* plfFaceName = &this.lfFaceName1)
{
using (var bytes = ArrayUtil.Rent<byte>(lfFaceNameSize))
{
Marshal.Copy((IntPtr)plfFaceName, bytes.Array, 0, lfFaceNameSize);
string faceName1 = Encoding.Unicode.GetString(bytes.Array);
int indexOf0 = faceName1.IndexOf('\0');
string faceName2 = faceName1.Substring(0, indexOf0);
return faceName2;
}
}
}
set
{
if (value.Length >= NativeConstants.LF_FACESIZE)
{
throw new ArgumentException("Max length for this is " + NativeConstants.LF_FACESIZE);
}
if (value.Length == 0 || value[value.Length - 1] != '\0')
{
value += '\0';
}
byte[] bytes = Encoding.Unicode.GetBytes(value);
if (bytes.Length > lfFaceNameSize)
{
throw new ArgumentException("The encoded string was too big");
}
fixed (uint* plfFaceName = &this.lfFaceName1)
{
BufferUtil.Clear(plfFaceName, lfFaceNameSize);
Marshal.Copy(bytes, 0, (IntPtr)plfFaceName, Math.Min(bytes.Length, lfFaceNameSize));
}
}
}
public override bool Equals(object obj)
{
return EquatableUtil.Equals(this, obj);
}
public bool Equals(LOGFONTW other)
{
return this.lfHeight == other.lfHeight &&
this.lfWidth == other.lfWidth &&
this.lfEscapement == other.lfEscapement &&
this.lfOrientation == other.lfOrientation &&
this.lfWeight == other.lfWeight &&
this.lfItalic == other.lfItalic &&
this.lfUnderline == other.lfUnderline &&
this.lfStrikeOut == other.lfStrikeOut &&
this.lfCharSet == other.lfCharSet &&
this.lfOutPrecision == other.lfOutPrecision &&
this.lfClipPrecision == other.lfClipPrecision &&
this.lfQuality == other.lfQuality &&
this.lfPitchAndFamily == other.lfPitchAndFamily &&
(0 == string.Compare(this.lfFaceName, other.lfFaceName, StringComparison.InvariantCulture));
}
public override int GetHashCode()
{
return HashCodeUtil.CombineHashCodes(
this.lfFaceName.GetHashCode(),
this.lfHeight,
this.lfQuality);
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENUMLOGFONTEXW
{
public LOGFONTW elfLogFont;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeConstants.LF_FULLFACESIZE)]
public string elfFullName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeConstants.LF_FACESIZE)]
public string elfStyle;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeConstants.LF_FACESIZE)]
public string elfScript;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TEXTMETRICW
{
public int tmHeight;
public int tmAscent;
public int tmDescent;
public int tmInternalLeading;
public int tmExternalLeading;
public int tmAveCharWidth;
public int tmMaxCharWidth;
public int tmWeight;
public int tmOverhang;
public int tmDigitizedAspectX;
public int tmDigitizedAspectY;
public char tmFirstChar;
public char tmLastChar;
public char tmDefaultChar;
public char tmBreakChar;
public byte tmItalic;
public byte tmUnderlined;
public byte tmStruckOut;
public byte tmPitchAndFamily;
public byte tmCharSet;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct OUTLINETEXTMETRICW_Base
{
public uint otmSize;
public TEXTMETRICW otmTextMetrics;
public byte otmFiller;
public PANOSE otmPanoseNumber;
public uint otmfsSelection;
public uint otmfsType;
public int otmsCharSlopeRise;
public int otmsCharSlopeRun;
public int otmItalicAngle;
public uint otmEMSquare;
public int otmAscent;
public int otmDescent;
public uint otmLineGap;
public uint otmsCapEmHeight;
public uint otmsXHeight;
public RECT otmrcFontBox;
public int otmMacAscent;
public int otmMacDescent;
public uint otmMacLineGap;
public uint otmusMinimumPPEM;
public POINT otmptSubscriptSize;
public POINT otmptSubscriptOffset;
public POINT otmptSuperscriptSize;
public POINT otmptSuperscriptOffset;
public uint otmsStrikeoutSize;
public int otmsStrikeoutPosition;
public int otmsUnderscoreSize;
public int otmsUnderscorePosition;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct OUTLINETEXTMETRICW_Unsafe
{
public OUTLINETEXTMETRICW_Base baseStruct;
private IntPtr otmpFamilyName;
private IntPtr otmpFaceName;
private IntPtr otmpStyleName;
private IntPtr otmpFullName;
public unsafe OUTLINETEXTMETRICW_Safe GetSafeCopy()
{
fixed (OUTLINETEXTMETRICW_Unsafe* pThis = &this)
{
IntPtr pThisPtr = (IntPtr)pThis;
OUTLINETEXTMETRICW_Safe safeCopy = new OUTLINETEXTMETRICW_Safe();
safeCopy.baseStruct = this.baseStruct;
safeCopy.otmpFamilyName = Marshal.PtrToStringUni(new IntPtr(pThisPtr.ToInt64() + this.otmpFamilyName.ToInt64()));
safeCopy.otmpFaceName = Marshal.PtrToStringUni(new IntPtr(pThisPtr.ToInt64() + this.otmpFaceName.ToInt64()));
safeCopy.otmpStyleName = Marshal.PtrToStringUni(new IntPtr(pThisPtr.ToInt64() + this.otmpStyleName.ToInt64()));
safeCopy.otmpFullName = Marshal.PtrToStringUni(new IntPtr(pThisPtr.ToInt64() + this.otmpFullName.ToInt64()));
return safeCopy;
}
}
}
public class OUTLINETEXTMETRICW_Safe
{
public OUTLINETEXTMETRICW_Base baseStruct;
public string otmpFamilyName;
public string otmpFaceName;
public string otmpStyleName;
public string otmpFullName;
}
[StructLayout(LayoutKind.Sequential)]
public struct PANOSE
{
public byte bFamilyType;
public byte bSerifStyle;
public byte bWeight;
public byte bProportion;
public byte bContrast;
public byte bStrokeVariation;
public byte bArmStyle;
public byte bLetterform;
public byte bMidline;
public byte bXHeight;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NEWTEXTMETRICW
{
public int tmHeight;
public int tmAscent;
public int tmDescent;
public int tmInternalLeading;
public int tmExternalLeading;
public int tmAveCharWidth;
public int tmMaxCharWidth;
public int tmWeight;
public int tmOverhang;
public int tmDigitizedAspectX;
public int tmDigitizedAspectY;
public char tmFirstChar;
public char tmLastChar;
public char tmDefaultChar;
public char tmBreakChar;
public byte tmItalic;
public byte tmUnderlined;
public byte tmStruckOut;
public byte tmPitchAndFamily;
public byte tmCharSet;
public uint ntmFlags;
public uint ntmSizeEM;
public uint ntmCellHeight;
public uint ntmAvgWidth;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NEWTEXTMETRICEXW
{
public NEWTEXTMETRICW ntmTm;
public FONTSIGNATURE ntmFontSig;
}
[StructLayout(LayoutKind.Sequential)]
public struct FONTSIGNATURE
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] fsUsb;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint[] fcCsb;
}
[StructLayout(LayoutKind.Sequential)]
public struct LOGBRUSH
{
public uint lbStyle;
public uint lbColor;
public int lbHatch;
}
[StructLayout(LayoutKind.Sequential)]
public struct RGNDATAHEADER
{
public uint dwSize;
public uint iType;
public uint nCount;
public uint nRgnSize;
public RECT rcBound;
}
[StructLayout(LayoutKind.Sequential)]
public struct RGNDATA
{
public RGNDATAHEADER rdh;
public unsafe static RECT *GetRectsPointer(RGNDATA *me)
{
return (RECT *)((byte *)me + sizeof(RGNDATAHEADER));
}
}
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int x;
public int y;
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
public static POINT FromGdipPoint(System.Drawing.Point pt)
{
return new POINT(pt.X, pt.Y);
}
public static implicit operator Point2Int32(POINT pt)
{
return new Point2Int32(pt.x, pt.y);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
public RECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public System.Drawing.Rectangle ToGdipRectangle()
{
return new System.Drawing.Rectangle(this.left, this.top, this.right - this.left, this.bottom - this.top);
}
public RectInt32 ToRectInt32()
{
return PaintDotNet.Rendering.RectInt32.FromEdges(this.left, this.top, this.right, this.bottom);
}
public static RECT FromRectInt32(PaintDotNet.Rendering.RectInt32 rect)
{
RECT rc = new RECT();
rc.left = rect.X;
rc.top = rect.Y;
rc.right = rect.X + rect.Width;
rc.bottom = rect.Y + rect.Height;
return rc;
}
public static RECT FromGdipRectangle(System.Drawing.Rectangle rect)
{
RECT rc = new RECT();
rc.left = rect.Left;
rc.top = rect.Top;
rc.right = rect.Right;
rc.bottom = rect.Bottom;
return rc;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct ABC
{
public int abcA;
public uint abcB;
public int abcC;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct GCP_RESULTS
{
public uint lStructSize;
public short* lpOutString;
public uint* lpOrder;
public int* lpDx;
public int* lpCaretPos;
public byte* lpClass;
public short* lpGlyphs;
public uint nGlyphs;
public int nMaxFit;
}
[StructLayout(LayoutKind.Sequential)]
public struct SIZE
{
public int cx;
public int cy;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct PropertyItem
{
public int id;
public uint length;
public short type;
public void *value;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct WINTRUST_DATA
{
public uint cbStruct;
public IntPtr pPolicyCallbackData;
public IntPtr pSIPClientData;
public uint dwUIChoice;
public uint fdwRevocationChecks;
public uint dwUnionChoice;
public void *pInfo; // pFile, pCatalog, pBlob, pSgnr, or pCert
public uint dwStateAction;
public IntPtr hWVTStateData;
public IntPtr pwszURLReference;
public uint dwProvFlags;
public uint dwUIContext;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct WINTRUST_FILE_INFO
{
public uint cbStruct;
public char *pcwszFilePath;
public IntPtr hFile;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
{
public bool fAutoDetect;
public IntPtr lpszAutoConfigUrl;
public IntPtr lpszProxy;
public IntPtr lpszProxyBypass;
}
[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVINFO_DATA
{
public uint cbSize;
public Guid ClassGuid;
public uint DevInst;
public UIntPtr Reserved;
}
[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
public IntPtr hwnd;
public uint message;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public NativeStructs.POINT pt;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NONCLIENTMETRICSW
{
public uint cbSize;
public int iBorderWidth;
public int iScrollWidth;
public int iScrollHeight;
public int iCaptionWidth;
public int iCaptionHeight;
public NativeStructs.LOGFONTW lfCaptionFont;
public int iSmCaptionWidth;
public int iSmCaptionHeight;
public NativeStructs.LOGFONTW lfSmCaptionFont;
public int iMenuWidth;
public int iMenuHeight;
public NativeStructs.LOGFONTW lfMenuFont;
public NativeStructs.LOGFONTW lfStatusFont;
public NativeStructs.LOGFONTW lfMessageFont;
public int iPaddedBorderWidth;
}
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
}
[StructLayout(LayoutKind.Sequential)]
public struct DTTOPTS
{
public uint dwSize;
public uint dwFlags;
public int crText;
public int crBorder;
public int crShadow;
public int iTextShadowType;
public NativeStructs.POINT ptShadowOffset;
public int iBorderSize;
public int iFontPropId;
public int iColorPropId;
public int iStateId;
[MarshalAs(UnmanagedType.Bool)] public bool fApplyOverlay;
public int iGlowSize;
public IntPtr pfnDrawTextCallback; // ???
public IntPtr lParam;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct NCCALCSIZE_PARAMS
{
public RECT rgrc0;
public RECT rgrc1;
public RECT rgrc2;
public WINDOWPOS* lppos;
}
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public int x;
public int y;
public int cx;
public int cy;
public uint flags;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct THUMBBUTTON
{
[MarshalAs(UnmanagedType.U4)]
public NativeEnums.THBMASK dwMask;
public uint iId;
public uint iBitmap;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szTip;
[MarshalAs(UnmanagedType.U4)]
public NativeEnums.THBFLAGS dwFlags;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct BP_PAINTPARAMS
{
public uint cbSize;
public uint dwFlags;
public NativeStructs.RECT* prcExclude;
public NativeStructs.BLENDFUNCTION* pBlendFunction;
}
[StructLayout(LayoutKind.Sequential)]
public struct BP_ANIMATIONPARAMS
{
public uint cbSize;
public uint dwFlags;
public NativeEnums.BP_ANIMATIONSTYLE style;
public uint dwDuration;
}
[StructLayout(LayoutKind.Sequential)]
public struct BLENDFUNCTION
{
public byte BlendOp;
public byte BlendFlags;
public byte SourceConstantAlpha;
public byte AlphaFormat;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHSTOCKICONINFO
{
public uint cbSize;
public IntPtr hIcon;
public int iSysImageIndex;
public int iIcon;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NativeConstants.MAX_PATH)]
public ushort[] szPath;
}
[StructLayout(LayoutKind.Sequential)]
public struct WTA_OPTIONS
{
public uint dwFlags;
public uint dwMask;
}
[StructLayout(LayoutKind.Sequential)]
public struct TITLEBARINFOEX
{
public uint cbSize;
public RECT rcTitleBar;
public uint rgstate0;
public uint rgstate1;
public uint rgstate2;
public uint rgstate3;
public uint rgstate4;
public uint rgstate5;
public RECT rgrect0;
public RECT rgrect1;
public RECT rgrect2;
public RECT rgrect3;
public RECT rgrect4;
public RECT rgrect5;
}
[StructLayout(LayoutKind.Sequential)]