-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTLinkReflash.exe.c
11900 lines (10349 loc) · 297 KB
/
STLinkReflash.exe.c
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
typedef unsigned char undefined;
typedef unsigned long long GUID;
typedef pointer32 ImageBaseOffset32;
typedef unsigned char bool;
typedef unsigned char byte;
typedef unsigned int dword;
typedef long long longlong;
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned char undefined1;
typedef unsigned short undefined2;
typedef unsigned int undefined4;
typedef unsigned long long undefined8;
typedef unsigned short ushort;
typedef unsigned short wchar16;
typedef short wchar_t;
typedef unsigned short word;
typedef struct CLIENT_ID CLIENT_ID, *PCLIENT_ID;
struct CLIENT_ID {
void *UniqueProcess;
void *UniqueThread;
};
typedef struct _cpinfo _cpinfo, *P_cpinfo;
typedef uint UINT;
typedef uchar BYTE;
struct _cpinfo {
UINT MaxCharSize;
BYTE DefaultChar[2];
BYTE LeadByte[12];
};
typedef struct _cpinfo *LPCPINFO;
typedef struct _OVERLAPPED _OVERLAPPED, *P_OVERLAPPED;
typedef ulong ULONG_PTR;
typedef union _union_518 _union_518, *P_union_518;
typedef void *HANDLE;
typedef struct _struct_519 _struct_519, *P_struct_519;
typedef void *PVOID;
typedef ulong DWORD;
struct _struct_519 {
DWORD Offset;
DWORD OffsetHigh;
};
union _union_518 {
struct _struct_519 s;
PVOID Pointer;
};
struct _OVERLAPPED {
ULONG_PTR Internal;
ULONG_PTR InternalHigh;
union _union_518 u;
HANDLE hEvent;
};
typedef struct _SECURITY_ATTRIBUTES _SECURITY_ATTRIBUTES, *P_SECURITY_ATTRIBUTES;
typedef void *LPVOID;
typedef int BOOL;
struct _SECURITY_ATTRIBUTES {
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
};
typedef struct _STARTUPINFOW _STARTUPINFOW, *P_STARTUPINFOW;
typedef wchar_t WCHAR;
typedef WCHAR *LPWSTR;
typedef ushort WORD;
typedef BYTE *LPBYTE;
struct _STARTUPINFOW {
DWORD cb;
LPWSTR lpReserved;
LPWSTR lpDesktop;
LPWSTR lpTitle;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
LPBYTE lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
};
typedef struct _STARTUPINFOW *LPSTARTUPINFOW;
typedef struct _OVERLAPPED *LPOVERLAPPED;
typedef struct _SECURITY_ATTRIBUTES *LPSECURITY_ATTRIBUTES;
typedef struct _RTL_CRITICAL_SECTION _RTL_CRITICAL_SECTION, *P_RTL_CRITICAL_SECTION;
typedef struct _RTL_CRITICAL_SECTION *PRTL_CRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
typedef struct _RTL_CRITICAL_SECTION_DEBUG _RTL_CRITICAL_SECTION_DEBUG, *P_RTL_CRITICAL_SECTION_DEBUG;
typedef struct _RTL_CRITICAL_SECTION_DEBUG *PRTL_CRITICAL_SECTION_DEBUG;
typedef long LONG;
typedef struct _LIST_ENTRY _LIST_ENTRY, *P_LIST_ENTRY;
typedef struct _LIST_ENTRY LIST_ENTRY;
struct _RTL_CRITICAL_SECTION {
PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
HANDLE LockSemaphore;
ULONG_PTR SpinCount;
};
struct _LIST_ENTRY {
struct _LIST_ENTRY *Flink;
struct _LIST_ENTRY *Blink;
};
struct _RTL_CRITICAL_SECTION_DEBUG {
WORD Type;
WORD CreatorBackTraceIndex;
struct _RTL_CRITICAL_SECTION *CriticalSection;
LIST_ENTRY ProcessLocksList;
DWORD EntryCount;
DWORD ContentionCount;
DWORD Flags;
WORD CreatorBackTraceIndexHigh;
WORD SpareWORD;
};
typedef struct _EXCEPTION_POINTERS _EXCEPTION_POINTERS, *P_EXCEPTION_POINTERS;
typedef LONG (*PTOP_LEVEL_EXCEPTION_FILTER)(struct _EXCEPTION_POINTERS *);
typedef struct _EXCEPTION_RECORD _EXCEPTION_RECORD, *P_EXCEPTION_RECORD;
typedef struct _EXCEPTION_RECORD EXCEPTION_RECORD;
typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
typedef struct _CONTEXT _CONTEXT, *P_CONTEXT;
typedef struct _CONTEXT CONTEXT;
typedef CONTEXT *PCONTEXT;
typedef struct _FLOATING_SAVE_AREA _FLOATING_SAVE_AREA, *P_FLOATING_SAVE_AREA;
typedef struct _FLOATING_SAVE_AREA FLOATING_SAVE_AREA;
struct _FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
DWORD TagWord;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
BYTE RegisterArea[80];
DWORD Cr0NpxState;
};
struct _CONTEXT {
DWORD ContextFlags;
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
FLOATING_SAVE_AREA FloatSave;
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
DWORD Ebp;
DWORD Eip;
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
BYTE ExtendedRegisters[512];
};
struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
ULONG_PTR ExceptionInformation[15];
};
struct _EXCEPTION_POINTERS {
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
};
typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
typedef struct _iobuf _iobuf, *P_iobuf;
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
typedef char *va_list;
typedef uint uintptr_t;
typedef struct lconv lconv, *Plconv;
struct lconv {
char *decimal_point;
char *thousands_sep;
char *grouping;
char *int_curr_symbol;
char *currency_symbol;
char *mon_decimal_point;
char *mon_thousands_sep;
char *mon_grouping;
char *positive_sign;
char *negative_sign;
char int_frac_digits;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char p_sign_posn;
char n_sign_posn;
wchar_t *_W_decimal_point;
wchar_t *_W_thousands_sep;
wchar_t *_W_int_curr_symbol;
wchar_t *_W_currency_symbol;
wchar_t *_W_mon_decimal_point;
wchar_t *_W_mon_thousands_sep;
wchar_t *_W_positive_sign;
wchar_t *_W_negative_sign;
};
typedef ushort wint_t;
typedef struct threadlocaleinfostruct threadlocaleinfostruct, *Pthreadlocaleinfostruct;
typedef struct threadlocaleinfostruct *pthreadlocinfo;
typedef struct localerefcount localerefcount, *Plocalerefcount;
typedef struct localerefcount locrefcount;
typedef struct __lc_time_data __lc_time_data, *P__lc_time_data;
struct localerefcount {
char *locale;
wchar_t *wlocale;
int *refcount;
int *wrefcount;
};
struct threadlocaleinfostruct {
int refcount;
uint lc_codepage;
uint lc_collate_cp;
uint lc_time_cp;
locrefcount lc_category[6];
int lc_clike;
int mb_cur_max;
int *lconv_intl_refcount;
int *lconv_num_refcount;
int *lconv_mon_refcount;
struct lconv *lconv;
int *ctype1_refcount;
ushort *ctype1;
ushort *pctype;
uchar *pclmap;
uchar *pcumap;
struct __lc_time_data *lc_time_curr;
wchar_t *locale_name[6];
};
struct __lc_time_data {
char *wday_abbr[7];
char *wday[7];
char *month_abbr[12];
char *month[12];
char *ampm[2];
char *ww_sdatefmt;
char *ww_ldatefmt;
char *ww_timefmt;
int ww_caltype;
int refcount;
wchar_t *_W_wday_abbr[7];
wchar_t *_W_wday[7];
wchar_t *_W_month_abbr[12];
wchar_t *_W_month[12];
wchar_t *_W_ampm[2];
wchar_t *_W_ww_sdatefmt;
wchar_t *_W_ww_ldatefmt;
wchar_t *_W_ww_timefmt;
wchar_t *_W_ww_locale_name;
};
typedef uint size_t;
typedef int errno_t;
typedef struct localeinfo_struct localeinfo_struct, *Plocaleinfo_struct;
typedef struct threadmbcinfostruct threadmbcinfostruct, *Pthreadmbcinfostruct;
typedef struct threadmbcinfostruct *pthreadmbcinfo;
struct threadmbcinfostruct {
int refcount;
int mbcodepage;
int ismbcodepage;
ushort mbulinfo[6];
uchar mbctype[257];
uchar mbcasemap[256];
wchar_t *mblocalename;
};
struct localeinfo_struct {
pthreadlocinfo locinfo;
pthreadmbcinfo mbcinfo;
};
typedef int intptr_t;
typedef struct localeinfo_struct *_locale_t;
typedef size_t rsize_t;
typedef PVOID HDEVINFO;
typedef struct _SP_DEVICE_INTERFACE_DATA _SP_DEVICE_INTERFACE_DATA, *P_SP_DEVICE_INTERFACE_DATA;
// WARNING! conflicting data type names: /guiddef.h/GUID - /GUID
struct _SP_DEVICE_INTERFACE_DATA {
DWORD cbSize;
GUID InterfaceClassGuid;
DWORD Flags;
ULONG_PTR Reserved;
};
typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A _SP_DEVICE_INTERFACE_DETAIL_DATA_A, *P_SP_DEVICE_INTERFACE_DETAIL_DATA_A;
typedef char CHAR;
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize;
CHAR DevicePath[1];
};
typedef struct _SP_DEVINFO_DATA _SP_DEVINFO_DATA, *P_SP_DEVINFO_DATA;
struct _SP_DEVINFO_DATA {
DWORD cbSize;
GUID ClassGuid;
DWORD DevInst;
ULONG_PTR Reserved;
};
typedef struct _SP_DEVICE_INTERFACE_DATA *PSP_DEVICE_INTERFACE_DATA;
typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A *PSP_DEVICE_INTERFACE_DETAIL_DATA_A;
typedef struct _SP_DEVINFO_DATA *PSP_DEVINFO_DATA;
typedef struct _GUID _GUID, *P_GUID;
struct _GUID {
ulong Data1;
ushort Data2;
ushort Data3;
uchar Data4[8];
};
typedef struct _IMAGE_SECTION_HEADER _IMAGE_SECTION_HEADER, *P_IMAGE_SECTION_HEADER;
typedef union _union_226 _union_226, *P_union_226;
union _union_226 {
DWORD PhysicalAddress;
DWORD VirtualSize;
};
struct _IMAGE_SECTION_HEADER {
BYTE Name[8];
union _union_226 Misc;
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
};
typedef enum _HEAP_INFORMATION_CLASS {
HeapCompatibilityInformation=0,
HeapEnableTerminationOnCorruption=1
} _HEAP_INFORMATION_CLASS;
typedef CHAR *LPCSTR;
typedef LONG *PLONG;
typedef CHAR *LPSTR;
typedef union _LARGE_INTEGER _LARGE_INTEGER, *P_LARGE_INTEGER;
typedef struct _struct_19 _struct_19, *P_struct_19;
typedef struct _struct_20 _struct_20, *P_struct_20;
typedef double LONGLONG;
struct _struct_20 {
DWORD LowPart;
LONG HighPart;
};
struct _struct_19 {
DWORD LowPart;
LONG HighPart;
};
union _LARGE_INTEGER {
struct _struct_19 s;
struct _struct_20 u;
LONGLONG QuadPart;
};
typedef union _LARGE_INTEGER LARGE_INTEGER;
typedef enum _HEAP_INFORMATION_CLASS HEAP_INFORMATION_CLASS;
typedef struct _IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
typedef WCHAR *LPWCH;
typedef WCHAR *LPCWSTR;
typedef CHAR *PCSTR;
typedef CHAR *PSTR;
typedef DWORD LCID;
typedef struct IMAGE_DOS_HEADER IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
struct IMAGE_DOS_HEADER {
char e_magic[2]; // Magic number
word e_cblp; // Bytes of last page
word e_cp; // Pages in file
word e_crlc; // Relocations
word e_cparhdr; // Size of header in paragraphs
word e_minalloc; // Minimum extra paragraphs needed
word e_maxalloc; // Maximum extra paragraphs needed
word e_ss; // Initial (relative) SS value
word e_sp; // Initial SP value
word e_csum; // Checksum
word e_ip; // Initial IP value
word e_cs; // Initial (relative) CS value
word e_lfarlc; // File address of relocation table
word e_ovno; // Overlay number
word e_res[4][4]; // Reserved words
word e_oemid; // OEM identifier (for e_oeminfo)
word e_oeminfo; // OEM information; e_oemid specific
word e_res2[10][10]; // Reserved words
dword e_lfanew; // File address of new exe header
byte e_program[64]; // Actual DOS program
};
typedef ULONG_PTR DWORD_PTR;
typedef ULONG_PTR SIZE_T;
typedef struct HKEY__ HKEY__, *PHKEY__;
struct HKEY__ {
int unused;
};
typedef DWORD *LPDWORD;
typedef DWORD *PDWORD;
typedef struct HINSTANCE__ HINSTANCE__, *PHINSTANCE__;
typedef struct HINSTANCE__ *HINSTANCE;
struct HINSTANCE__ {
int unused;
};
typedef struct HWND__ HWND__, *PHWND__;
typedef struct HWND__ *HWND;
struct HWND__ {
int unused;
};
typedef HINSTANCE HMODULE;
typedef struct _FILETIME _FILETIME, *P_FILETIME;
typedef struct _FILETIME *LPFILETIME;
struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
};
typedef int (*FARPROC)(void);
typedef WORD *LPWORD;
typedef struct HKEY__ *HKEY;
typedef HKEY *PHKEY;
typedef BOOL *LPBOOL;
typedef BYTE *PBYTE;
typedef void *LPCVOID;
typedef struct IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
typedef struct IMAGE_DATA_DIRECTORY IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
struct IMAGE_DATA_DIRECTORY {
ImageBaseOffset32 VirtualAddress;
dword Size;
};
struct IMAGE_OPTIONAL_HEADER32 {
word Magic;
byte MajorLinkerVersion;
byte MinorLinkerVersion;
dword SizeOfCode;
dword SizeOfInitializedData;
dword SizeOfUninitializedData;
ImageBaseOffset32 AddressOfEntryPoint;
ImageBaseOffset32 BaseOfCode;
ImageBaseOffset32 BaseOfData;
pointer32 ImageBase;
dword SectionAlignment;
dword FileAlignment;
word MajorOperatingSystemVersion;
word MinorOperatingSystemVersion;
word MajorImageVersion;
word MinorImageVersion;
word MajorSubsystemVersion;
word MinorSubsystemVersion;
dword Win32VersionValue;
dword SizeOfImage;
dword SizeOfHeaders;
dword CheckSum;
word Subsystem;
word DllCharacteristics;
dword SizeOfStackReserve;
dword SizeOfStackCommit;
dword SizeOfHeapReserve;
dword SizeOfHeapCommit;
dword LoaderFlags;
dword NumberOfRvaAndSizes;
struct IMAGE_DATA_DIRECTORY DataDirectory[16];
};
typedef struct IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
typedef union Misc Misc, *PMisc;
typedef enum SectionFlags {
IMAGE_SCN_TYPE_NO_PAD=8,
IMAGE_SCN_RESERVED_0001=16,
IMAGE_SCN_CNT_CODE=32,
IMAGE_SCN_CNT_INITIALIZED_DATA=64,
IMAGE_SCN_CNT_UNINITIALIZED_DATA=128,
IMAGE_SCN_LNK_OTHER=256,
IMAGE_SCN_LNK_INFO=512,
IMAGE_SCN_RESERVED_0040=1024,
IMAGE_SCN_LNK_REMOVE=2048,
IMAGE_SCN_LNK_COMDAT=4096,
IMAGE_SCN_GPREL=32768,
IMAGE_SCN_MEM_16BIT=131072,
IMAGE_SCN_MEM_PURGEABLE=131072,
IMAGE_SCN_MEM_LOCKED=262144,
IMAGE_SCN_MEM_PRELOAD=524288,
IMAGE_SCN_ALIGN_1BYTES=1048576,
IMAGE_SCN_ALIGN_2BYTES=2097152,
IMAGE_SCN_ALIGN_4BYTES=3145728,
IMAGE_SCN_ALIGN_8BYTES=4194304,
IMAGE_SCN_ALIGN_16BYTES=5242880,
IMAGE_SCN_ALIGN_32BYTES=6291456,
IMAGE_SCN_ALIGN_64BYTES=7340032,
IMAGE_SCN_ALIGN_128BYTES=8388608,
IMAGE_SCN_ALIGN_256BYTES=9437184,
IMAGE_SCN_ALIGN_512BYTES=10485760,
IMAGE_SCN_ALIGN_1024BYTES=11534336,
IMAGE_SCN_ALIGN_2048BYTES=12582912,
IMAGE_SCN_ALIGN_4096BYTES=13631488,
IMAGE_SCN_ALIGN_8192BYTES=14680064,
IMAGE_SCN_LNK_NRELOC_OVFL=16777216,
IMAGE_SCN_MEM_DISCARDABLE=33554432,
IMAGE_SCN_MEM_NOT_CACHED=67108864,
IMAGE_SCN_MEM_NOT_PAGED=134217728,
IMAGE_SCN_MEM_SHARED=268435456,
IMAGE_SCN_MEM_EXECUTE=536870912,
IMAGE_SCN_MEM_READ=1073741824,
IMAGE_SCN_MEM_WRITE=2147483648
} SectionFlags;
union Misc {
dword PhysicalAddress;
dword VirtualSize;
};
struct IMAGE_SECTION_HEADER {
char Name[8];
union Misc Misc;
ImageBaseOffset32 VirtualAddress;
dword SizeOfRawData;
dword PointerToRawData;
dword PointerToRelocations;
dword PointerToLinenumbers;
word NumberOfRelocations;
word NumberOfLinenumbers;
enum SectionFlags Characteristics;
};
typedef struct IMAGE_FILE_HEADER IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
struct IMAGE_FILE_HEADER {
word Machine; // 332
word NumberOfSections;
dword TimeDateStamp;
dword PointerToSymbolTable;
dword NumberOfSymbols;
word SizeOfOptionalHeader;
word Characteristics;
};
typedef struct IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
struct IMAGE_NT_HEADERS32 {
char Signature[4];
struct IMAGE_FILE_HEADER FileHeader;
struct IMAGE_OPTIONAL_HEADER32 OptionalHeader;
};
typedef struct IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
struct IMAGE_LOAD_CONFIG_DIRECTORY32 {
dword Size;
dword TimeDateStamp;
word MajorVersion;
word MinorVersion;
dword GlobalFlagsClear;
dword GlobalFlagsSet;
dword CriticalSectionDefaultTimeout;
dword DeCommitFreeBlockThreshold;
dword DeCommitTotalFreeThreshold;
pointer32 LockPrefixTable;
dword MaximumAllocationSize;
dword VirtualMemoryThreshold;
dword ProcessHeapFlags;
dword ProcessAffinityMask;
word CsdVersion;
word DependentLoadFlags;
pointer32 EditList;
pointer32 SecurityCookie;
pointer32 SEHandlerTable;
dword SEHandlerCount;
};
typedef LONG LSTATUS;
typedef struct setloc_struct setloc_struct, *Psetloc_struct;
typedef struct _is_ctype_compatible _is_ctype_compatible, *P_is_ctype_compatible;
struct _is_ctype_compatible {
ulong id;
int is_clike;
};
struct setloc_struct {
wchar_t *pchLanguage;
wchar_t *pchCountry;
int iLocState;
int iPrimaryLen;
BOOL bAbbrevLanguage;
BOOL bAbbrevCountry;
UINT _cachecp;
wchar_t _cachein[131];
wchar_t _cacheout[131];
struct _is_ctype_compatible _Loc_c[5];
wchar_t _cacheLocaleName[85];
};
typedef struct _tiddata _tiddata, *P_tiddata;
typedef struct setloc_struct _setloc_struct;
struct _tiddata {
ulong _tid;
uintptr_t _thandle;
int _terrno;
ulong _tdoserrno;
uint _fpds;
ulong _holdrand;
char *_token;
wchar_t *_wtoken;
uchar *_mtoken;
char *_errmsg;
wchar_t *_werrmsg;
char *_namebuf0;
wchar_t *_wnamebuf0;
char *_namebuf1;
wchar_t *_wnamebuf1;
char *_asctimebuf;
wchar_t *_wasctimebuf;
void *_gmtimebuf;
char *_cvtbuf;
uchar _con_ch_buf[5];
ushort _ch_buf_used;
void *_initaddr;
void *_initarg;
void *_pxcptacttab;
void *_tpxcptinfoptrs;
int _tfpecode;
pthreadmbcinfo ptmbcinfo;
pthreadlocinfo ptlocinfo;
int _ownlocale;
ulong _NLG_dwCode;
void *_terminate;
void *_unexpected;
void *_translator;
void *_purecall;
void *_curexception;
void *_curcontext;
int _ProcessingThrow;
void *_curexcspec;
void *_pFrameInfoChain;
_setloc_struct _setloc_data;
void *_reserved1;
void *_reserved2;
void *_reserved3;
void *_reserved4;
void *_reserved5;
int _cxxReThrow;
ulong __initDomain;
int _initapartment;
};
typedef struct _tiddata *_ptiddata;
typedef struct _LocaleUpdate _LocaleUpdate, *P_LocaleUpdate;
struct _LocaleUpdate { // PlaceHolder Structure
};
typedef int (*_onexit_t)(void);
void __cdecl FUN_00401000(uint *param_1,uint *param_2)
{
uint *puVar1;
uint uVar2;
uint *puVar3;
uint uVar4;
uint uVar5;
uint uVar6;
uVar4 = param_1[2];
uVar5 = *param_1;
uVar6 = param_1[1];
uVar2 = param_1[3];
*param_2 = uVar5;
param_2[1] = uVar6;
param_2[2] = uVar4;
param_2[3] = uVar2;
puVar3 = param_2 + 5;
param_2 = &DAT_0042b614;
do {
uVar5 = uVar5 ^ CONCAT31(CONCAT21(CONCAT11((&DAT_0042b410)[uVar2 >> 0x10 & 0xff],
(&DAT_0042b410)[uVar2 >> 8 & 0xff]),
(&DAT_0042b410)[uVar2 & 0xff]),(&DAT_0042b410)[uVar2 >> 0x18])
^ param_2[-1];
uVar6 = uVar6 ^ uVar5;
uVar4 = uVar4 ^ uVar6;
uVar2 = uVar2 ^ uVar4;
puVar3[-1] = uVar5;
*puVar3 = uVar6;
puVar3[1] = uVar4;
puVar3[2] = uVar2;
uVar5 = uVar5 ^ CONCAT31(CONCAT21(CONCAT11((&DAT_0042b410)[uVar2 >> 0x10 & 0xff],
(&DAT_0042b410)[uVar2 >> 8 & 0xff]),
(&DAT_0042b410)[uVar2 & 0xff]),(&DAT_0042b410)[uVar2 >> 0x18])
^ *param_2;
uVar6 = uVar6 ^ uVar5;
uVar4 = uVar4 ^ uVar6;
uVar2 = uVar2 ^ uVar4;
puVar3[3] = uVar5;
puVar3[4] = uVar6;
puVar3[5] = uVar4;
puVar3[6] = uVar2;
uVar5 = uVar5 ^ CONCAT31(CONCAT21(CONCAT11((&DAT_0042b410)[uVar2 >> 0x10 & 0xff],
(&DAT_0042b410)[uVar2 >> 8 & 0xff]),
(&DAT_0042b410)[uVar2 & 0xff]),(&DAT_0042b410)[uVar2 >> 0x18])
^ param_2[1];
uVar6 = uVar6 ^ uVar5;
uVar4 = uVar4 ^ uVar6;
uVar2 = uVar2 ^ uVar4;
puVar3[7] = uVar5;
puVar3[8] = uVar6;
puVar3[9] = uVar4;
puVar3[10] = uVar2;
uVar5 = uVar5 ^ CONCAT31(CONCAT21(CONCAT11((&DAT_0042b410)[uVar2 >> 0x10 & 0xff],
(&DAT_0042b410)[uVar2 >> 8 & 0xff]),
(&DAT_0042b410)[uVar2 & 0xff]),(&DAT_0042b410)[uVar2 >> 0x18])
^ param_2[2];
uVar6 = uVar6 ^ uVar5;
uVar4 = uVar4 ^ uVar6;
uVar2 = uVar2 ^ uVar4;
puVar3[0xb] = uVar5;
puVar3[0xc] = uVar6;
puVar3[0xd] = uVar4;
puVar3[0xe] = uVar2;
puVar1 = param_2 + 3;
param_2 = param_2 + 5;
uVar5 = uVar5 ^ CONCAT31(CONCAT21(CONCAT11((&DAT_0042b410)[uVar2 >> 0x10 & 0xff],
(&DAT_0042b410)[uVar2 >> 8 & 0xff]),
(&DAT_0042b410)[uVar2 & 0xff]),(&DAT_0042b410)[uVar2 >> 0x18])
^ *puVar1;
uVar6 = uVar6 ^ uVar5;
uVar4 = uVar4 ^ uVar6;
uVar2 = uVar2 ^ uVar4;
puVar3[0xf] = uVar5;
puVar3[0x10] = uVar6;
puVar3[0x11] = uVar4;
puVar3[0x12] = uVar2;
puVar3 = puVar3 + 0x14;
} while ((int)param_2 < 0x42b63c);
return;
}
void __cdecl FUN_0040168c(uint *param_1,uint *param_2,uint *param_3)
{
undefined uVar1;
undefined uVar2;
undefined uVar3;
undefined uVar4;
undefined uVar5;
undefined uVar6;
undefined uVar7;
undefined uVar8;
undefined uVar9;
undefined uVar10;
undefined uVar11;
undefined uVar12;
uint3 uVar13;
uint3 uVar14;
uint3 uVar15;
uint3 uVar16;
uint *puVar17;
uint uVar18;
uint uVar19;
uint uVar20;
uint uVar21;
uint uVar22;
uint uVar23;
uint uVar24;
uint uVar25;
uint uVar26;
uint *local_c;
int local_4;
uVar24 = param_1[1] ^ param_3[1];
uVar25 = *param_1 ^ *param_3;
uVar19 = param_1[3] ^ param_3[3];
local_4 = 9;
param_1 = (uint *)(param_1[2] ^ param_3[2]);
puVar17 = param_3 + 4;
do {
local_c = puVar17;
uVar13 = CONCAT21(CONCAT11((&DAT_0042b410)[uVar25 >> 0x18],
(&DAT_0042b410)[uVar24 >> 0x10 & 0xff]),
(&DAT_0042b410)[(uint)param_1 >> 8 & 0xff]);
uVar18 = CONCAT31(uVar13,(&DAT_0042b410)[uVar19 & 0xff]);
uVar14 = CONCAT21(CONCAT11((&DAT_0042b410)[uVar24 >> 0x18],
(&DAT_0042b410)[(uint)param_1 >> 0x10 & 0xff]),
(&DAT_0042b410)[uVar19 >> 8 & 0xff]);
uVar21 = CONCAT31(uVar14,(&DAT_0042b410)[uVar25 & 0xff]);
uVar15 = CONCAT21(CONCAT11((&DAT_0042b410)[(uint)param_1 >> 0x18],
(&DAT_0042b410)[uVar19 >> 0x10 & 0xff]),
(&DAT_0042b410)[uVar25 >> 8 & 0xff]);
uVar20 = uVar25 >> 0x10;
uVar26 = CONCAT31(uVar15,(&DAT_0042b410)[uVar24 & 0xff]);
uVar16 = CONCAT21(CONCAT11((&DAT_0042b410)[uVar19 >> 0x18],(&DAT_0042b410)[uVar20 & 0xff]),
(&DAT_0042b410)[uVar24 >> 8 & 0xff]);
uVar22 = CONCAT31(uVar16,(&DAT_0042b410)[(uint)param_1 & 0xff]);
uVar23 = (uVar18 >> 7 & 0x1010101) * 0x1b;
uVar25 = (uVar18 << 0x10 |
(uint)CONCAT11((&DAT_0042b410)[uVar25 >> 0x18],(&DAT_0042b410)[uVar24 >> 0x10 & 0xff]))
^ ((uint)uVar13 | uVar18 << 0x18) ^
(((uVar18 & 0xffff7f7f) * 2 ^ uVar18) << 8 ^ (uVar18 >> 7 & 0x10101) * 0x1b00 |
((uVar23 ^ uVar18) >> 1 ^ (uVar13 & 0x7f0000) << 8) >> 0x17) ^
(uVar18 & 0xff7f7f7f) * 2 ^ uVar23 ^ *local_c;
uVar18 = (uVar21 >> 7 & 0x1010101) * 0x1b;
uVar24 = (uVar21 << 0x10 |
(uint)CONCAT11((&DAT_0042b410)[uVar24 >> 0x18],
(&DAT_0042b410)[(uint)param_1 >> 0x10 & 0xff])) ^
((uint)uVar14 | uVar21 << 0x18) ^
(((uVar21 & 0xffff7f7f) * 2 ^ uVar21) << 8 ^ (uVar21 >> 7 & 0x10101) * 0x1b00 |
((uVar18 ^ uVar21) >> 1 ^ (uVar14 & 0x7f0000) << 8) >> 0x17) ^
(uVar21 & 0xff7f7f7f) * 2 ^ local_c[1] ^ uVar18;
uVar18 = (uVar26 >> 7 & 0x1010101) * 0x1b;
param_1 = (uint *)((uVar26 << 0x10 |
(uint)CONCAT11((&DAT_0042b410)[(uint)param_1 >> 0x18],
(&DAT_0042b410)[uVar19 >> 0x10 & 0xff])) ^
((uint)uVar15 | uVar26 << 0x18) ^
(((uVar26 & 0xffff7f7f) * 2 ^ uVar26) << 8 ^ (uVar26 >> 7 & 0x10101) * 0x1b00
| ((uVar18 ^ uVar26) >> 1 ^ (uVar15 & 0x7f0000) << 8) >> 0x17) ^
(uVar26 & 0xff7f7f7f) * 2 ^ local_c[2] ^ uVar18);
uVar18 = (uVar22 >> 7 & 0x1010101) * 0x1b;
uVar19 = (uVar22 << 0x10 |
(uint)CONCAT11((&DAT_0042b410)[uVar19 >> 0x18],(&DAT_0042b410)[uVar20 & 0xff])) ^
((uint)uVar16 | uVar22 << 0x18) ^
(((uVar22 & 0xffff7f7f) * 2 ^ uVar22) << 8 ^ (uVar22 >> 7 & 0x10101) * 0x1b00 |
((uVar18 ^ uVar22) >> 1 ^ (uVar16 & 0x7f0000) << 8) >> 0x17) ^
(uVar22 & 0xff7f7f7f) * 2 ^ local_c[3] ^ uVar18;
local_4 = local_4 + -1;
puVar17 = local_c + 4;
} while (local_4 != 0);
uVar4 = (&DAT_0042b410)[uVar19 >> 0x10 & 0xff];
uVar1 = (&DAT_0042b410)[(uint)param_1 >> 0x18];