-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpe_gen.go
2289 lines (1890 loc) · 66.5 KB
/
pe_gen.go
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
package pe
// Autogenerated code from pe_profile.json. Do not edit.
import (
"encoding/binary"
"fmt"
"bytes"
"io"
"sort"
"strings"
"unicode/utf16"
"unicode/utf8"
)
var (
// Depending on autogenerated code we may use this. Add a reference
// to shut the compiler up.
_ = bytes.MinRead
_ = fmt.Sprintf
_ = utf16.Decode
_ = binary.LittleEndian
_ = utf8.RuneError
_ = sort.Strings
_ = strings.Join
_ = io.Copy
)
func indent(text string) string {
result := []string{}
lines := strings.Split(text,"\n")
for _, line := range lines {
result = append(result, " " + line)
}
return strings.Join(result, "\n")
}
type PeProfile struct {
Off_CV_RSDS_HEADER_Signature int64
Off_CV_RSDS_HEADER_GUID int64
Off_CV_RSDS_HEADER_Age int64
Off_CV_RSDS_HEADER_Filename int64
Off_MESSAGE_RESOURCE_BLOCK_LowId int64
Off_MESSAGE_RESOURCE_BLOCK_HighId int64
Off_MESSAGE_RESOURCE_BLOCK_OffsetToEntries int64
Off_MESSAGE_RESOURCE_DATA_NumberOfBlocks int64
Off_MESSAGE_RESOURCE_DATA__Blocks int64
Off_MESSAGE_RESOURCE_ENTRY_Length int64
Off_MESSAGE_RESOURCE_ENTRY_Flags int64
Off_MESSAGE_RESOURCE_ENTRY_Text int64
Off_PrefixedString_Length int64
Off_PrefixedString__Buffer int64
Off_ResourceString_Length int64
Off_ResourceString_ValueLength int64
Off_ResourceString_Type int64
Off_ResourceString_Key int64
Off_StringFileInfo_Length int64
Off_StringFileInfo_ValueLength int64
Off_StringFileInfo_Type int64
Off_StringFileInfo_Key int64
Off_StringTable_Length int64
Off_StringTable_ValueLength int64
Off_StringTable_Type int64
Off_StringTable_Key int64
Off_VS_VERSIONINFO_Length int64
Off_VS_VERSIONINFO_ValueLength int64
Off_VS_VERSIONINFO_Type int64
Off_VS_VERSIONINFO_szKey int64
Off_WIN_CERTIFICATE_Length int64
Off_WIN_CERTIFICATE_Revision int64
Off_WIN_CERTIFICATE_CertificateType int64
Off_GENERIC_DIRECTORY_TimeDateStamp int64
Off_GUID_Data1 int64
Off_GUID_Data2 int64
Off_GUID_Data3 int64
Off_GUID_Data4 int64
Off_IMAGE_DATA_DIRECTORY_DirSize int64
Off_IMAGE_DATA_DIRECTORY_VirtualAddress int64
Off_IMAGE_DEBUG_DIRECTORY_AddressOfRawData int64
Off_IMAGE_DEBUG_DIRECTORY_TimeDateStamp int64
Off_IMAGE_DEBUG_DIRECTORY_Type int64
Off_IMAGE_DOS_HEADER_E_lfanew int64
Off_IMAGE_DOS_HEADER_E_magic int64
Off_IMAGE_EXPORT_DIRECTORY_AddressOfFunctions int64
Off_IMAGE_EXPORT_DIRECTORY_AddressOfNameOrdinals int64
Off_IMAGE_EXPORT_DIRECTORY_AddressOfNames int64
Off_IMAGE_EXPORT_DIRECTORY_Base int64
Off_IMAGE_EXPORT_DIRECTORY_Name int64
Off_IMAGE_EXPORT_DIRECTORY_NumberOfFunctions int64
Off_IMAGE_EXPORT_DIRECTORY_NumberOfNames int64
Off_IMAGE_EXPORT_DIRECTORY_TimeDateStamp int64
Off_IMAGE_EXPORT_DIRECTORY_ordinals int64
Off_IMAGE_EXPORT_DIRECTORY_names int64
Off_IMAGE_EXPORT_DIRECTORY_funcs64 int64
Off_IMAGE_FILE_HEADER_Characteristics int64
Off_IMAGE_FILE_HEADER_Machine int64
Off_IMAGE_FILE_HEADER_NumberOfSections int64
Off_IMAGE_FILE_HEADER_SizeOfOptionalHeader int64
Off_IMAGE_FILE_HEADER_TimeDateStamp int64
Off_IMAGE_FILE_HEADER_TimeDateStampRaw int64
Off_IMAGE_IMPORT_BY_NAME_Name int64
Off_IMAGE_IMPORT_DESCRIPTOR_Characteristics int64
Off_IMAGE_IMPORT_DESCRIPTOR_Name int64
Off_IMAGE_IMPORT_DESCRIPTOR_OriginalFirstThunk int64
Off_IMAGE_NT_HEADERS_FileHeader int64
Off_IMAGE_NT_HEADERS_OptionalHeader int64
Off_IMAGE_NT_HEADERS_Signature int64
Off_IMAGE_OPTIONAL_HEADER_CheckSum int64
Off_IMAGE_OPTIONAL_HEADER_DataDirectory int64
Off_IMAGE_OPTIONAL_HEADER_ImageBase int64
Off_IMAGE_OPTIONAL_HEADER_Magic int64
Off_IMAGE_OPTIONAL_HEADER_SizeOfHeaders int64
Off_IMAGE_OPTIONAL_HEADER64_DataDirectory int64
Off_IMAGE_OPTIONAL_HEADER64_ImageBase int64
Off_IMAGE_OPTIONAL_HEADER64_Magic int64
Off_IMAGE_OPTIONAL_HEADER64_SizeOfHeaders int64
Off_IMAGE_RESOURCE_DATA_ENTRY_OffsetToData int64
Off_IMAGE_RESOURCE_DATA_ENTRY_DataSize int64
Off_IMAGE_RESOURCE_DATA_ENTRY_CodePage int64
Off_IMAGE_RESOURCE_DIRECTORY_NumberOfIdEntries int64
Off_IMAGE_RESOURCE_DIRECTORY_NumberOfNamedEntries int64
Off_IMAGE_RESOURCE_DIRECTORY_TimeDateStamp int64
Off_IMAGE_RESOURCE_DIRECTORY__Entries int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_Type int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_DataIsDirectory int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_NameIsString int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_NameOffset int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_OffsetToData int64
Off_IMAGE_RESOURCE_DIRECTORY_ENTRY_OffsetToDirectory int64
Off_IMAGE_SECTION_HEADER_Characteristics int64
Off_IMAGE_SECTION_HEADER_Name int64
Off_IMAGE_SECTION_HEADER_PointerToRawData int64
Off_IMAGE_SECTION_HEADER_SizeOfRawData int64
Off_IMAGE_SECTION_HEADER_VirtualAddress int64
Off_IMAGE_THUNK_DATA32_AddressOfData int64
Off_IMAGE_THUNK_DATA32_ForwarderString int64
Off_IMAGE_THUNK_DATA32_Function int64
Off_IMAGE_THUNK_DATA32_Ordinal int64
Off_IMAGE_THUNK_DATA64_AddressOfData int64
Off_IMAGE_THUNK_DATA64_ForwarderString int64
Off_IMAGE_THUNK_DATA64_Function int64
Off_IMAGE_THUNK_DATA64_Ordinal int64
}
func NewPeProfile() *PeProfile {
// Specific offsets can be tweaked to cater for slight version mismatches.
self := &PeProfile{0,4,20,24,0,4,8,0,4,0,2,4,0,2,0,2,4,6,0,2,4,6,0,2,4,6,0,2,4,6,0,4,6,4,0,4,6,8,4,0,20,4,12,60,0,28,36,32,16,12,20,24,4,0,0,0,18,0,2,16,4,4,2,0,12,0,4,24,0,64,96,28,0,60,112,24,0,60,0,4,8,14,12,4,16,0,4,0,0,4,4,36,0,20,16,12,0,0,0,0,0,0,0,0}
return self
}
func (self *PeProfile) CV_RSDS_HEADER(reader io.ReaderAt, offset int64) *CV_RSDS_HEADER {
return &CV_RSDS_HEADER{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) MESSAGE_RESOURCE_BLOCK(reader io.ReaderAt, offset int64) *MESSAGE_RESOURCE_BLOCK {
return &MESSAGE_RESOURCE_BLOCK{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) MESSAGE_RESOURCE_DATA(reader io.ReaderAt, offset int64) *MESSAGE_RESOURCE_DATA {
return &MESSAGE_RESOURCE_DATA{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) MESSAGE_RESOURCE_ENTRY(reader io.ReaderAt, offset int64) *MESSAGE_RESOURCE_ENTRY {
return &MESSAGE_RESOURCE_ENTRY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) PrefixedString(reader io.ReaderAt, offset int64) *PrefixedString {
return &PrefixedString{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) ResourceString(reader io.ReaderAt, offset int64) *ResourceString {
return &ResourceString{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) StringFileInfo(reader io.ReaderAt, offset int64) *StringFileInfo {
return &StringFileInfo{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) StringTable(reader io.ReaderAt, offset int64) *StringTable {
return &StringTable{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) VS_VERSIONINFO(reader io.ReaderAt, offset int64) *VS_VERSIONINFO {
return &VS_VERSIONINFO{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) WIN_CERTIFICATE(reader io.ReaderAt, offset int64) *WIN_CERTIFICATE {
return &WIN_CERTIFICATE{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) GENERIC_DIRECTORY(reader io.ReaderAt, offset int64) *GENERIC_DIRECTORY {
return &GENERIC_DIRECTORY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) GUID(reader io.ReaderAt, offset int64) *GUID {
return &GUID{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_DATA_DIRECTORY(reader io.ReaderAt, offset int64) *IMAGE_DATA_DIRECTORY {
return &IMAGE_DATA_DIRECTORY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_DEBUG_DIRECTORY(reader io.ReaderAt, offset int64) *IMAGE_DEBUG_DIRECTORY {
return &IMAGE_DEBUG_DIRECTORY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_DOS_HEADER(reader io.ReaderAt, offset int64) *IMAGE_DOS_HEADER {
return &IMAGE_DOS_HEADER{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_EXPORT_DIRECTORY(reader io.ReaderAt, offset int64) *IMAGE_EXPORT_DIRECTORY {
return &IMAGE_EXPORT_DIRECTORY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_FILE_HEADER(reader io.ReaderAt, offset int64) *IMAGE_FILE_HEADER {
return &IMAGE_FILE_HEADER{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_IMPORT_BY_NAME(reader io.ReaderAt, offset int64) *IMAGE_IMPORT_BY_NAME {
return &IMAGE_IMPORT_BY_NAME{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_IMPORT_DESCRIPTOR(reader io.ReaderAt, offset int64) *IMAGE_IMPORT_DESCRIPTOR {
return &IMAGE_IMPORT_DESCRIPTOR{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_NT_HEADERS(reader io.ReaderAt, offset int64) *IMAGE_NT_HEADERS {
return &IMAGE_NT_HEADERS{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_OPTIONAL_HEADER(reader io.ReaderAt, offset int64) *IMAGE_OPTIONAL_HEADER {
return &IMAGE_OPTIONAL_HEADER{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_OPTIONAL_HEADER64(reader io.ReaderAt, offset int64) *IMAGE_OPTIONAL_HEADER64 {
return &IMAGE_OPTIONAL_HEADER64{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_RESOURCE_DATA_ENTRY(reader io.ReaderAt, offset int64) *IMAGE_RESOURCE_DATA_ENTRY {
return &IMAGE_RESOURCE_DATA_ENTRY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_RESOURCE_DIRECTORY(reader io.ReaderAt, offset int64) *IMAGE_RESOURCE_DIRECTORY {
return &IMAGE_RESOURCE_DIRECTORY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_RESOURCE_DIRECTORY_ENTRY(reader io.ReaderAt, offset int64) *IMAGE_RESOURCE_DIRECTORY_ENTRY {
return &IMAGE_RESOURCE_DIRECTORY_ENTRY{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_SECTION_HEADER(reader io.ReaderAt, offset int64) *IMAGE_SECTION_HEADER {
return &IMAGE_SECTION_HEADER{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_THUNK_DATA32(reader io.ReaderAt, offset int64) *IMAGE_THUNK_DATA32 {
return &IMAGE_THUNK_DATA32{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) IMAGE_THUNK_DATA64(reader io.ReaderAt, offset int64) *IMAGE_THUNK_DATA64 {
return &IMAGE_THUNK_DATA64{Reader: reader, Offset: offset, Profile: self}
}
func (self *PeProfile) TagVS_FIXEDFILEINFO(reader io.ReaderAt, offset int64) *TagVS_FIXEDFILEINFO {
return &TagVS_FIXEDFILEINFO{Reader: reader, Offset: offset, Profile: self}
}
type CV_RSDS_HEADER struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_GUID *GUID
_Age uint32
_Age_cached bool
}
func (self *CV_RSDS_HEADER) Size() int {
return 28
}
func (self *CV_RSDS_HEADER) Signature() string {
return ParseString(self.Reader, self.Profile.Off_CV_RSDS_HEADER_Signature + self.Offset, 4)
}
func (self *CV_RSDS_HEADER) GUID() *GUID {
if self._GUID != nil {
return self._GUID
}
result := self.Profile.GUID(self.Reader, self.Profile.Off_CV_RSDS_HEADER_GUID + self.Offset)
self._GUID = result
return result
}
func (self *CV_RSDS_HEADER) Age() uint32 {
if self._Age_cached {
return self._Age
}
result := ParseUint32(self.Reader, self.Profile.Off_CV_RSDS_HEADER_Age + self.Offset)
self._Age = result
self._Age_cached = true
return result
}
func (self *CV_RSDS_HEADER) Filename() string {
return ParseTerminatedString(self.Reader, self.Profile.Off_CV_RSDS_HEADER_Filename + self.Offset)
}
func (self *CV_RSDS_HEADER) DebugString() string {
result := fmt.Sprintf("struct CV_RSDS_HEADER @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Signature: %v\n", string(self.Signature()))
result += fmt.Sprintf(" GUID: {\n%v}\n", indent(self.GUID().DebugString()))
result += fmt.Sprintf(" Age: %#0x\n", self.Age())
result += fmt.Sprintf(" Filename: %v\n", string(self.Filename()))
return result
}
type MESSAGE_RESOURCE_BLOCK struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_LowId uint32
_LowId_cached bool
_HighId uint32
_HighId_cached bool
_OffsetToEntries uint32
_OffsetToEntries_cached bool
}
func (self *MESSAGE_RESOURCE_BLOCK) Size() int {
return 12
}
func (self *MESSAGE_RESOURCE_BLOCK) LowId() uint32 {
if self._LowId_cached {
return self._LowId
}
result := ParseUint32(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_BLOCK_LowId + self.Offset)
self._LowId = result
self._LowId_cached = true
return result
}
func (self *MESSAGE_RESOURCE_BLOCK) HighId() uint32 {
if self._HighId_cached {
return self._HighId
}
result := ParseUint32(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_BLOCK_HighId + self.Offset)
self._HighId = result
self._HighId_cached = true
return result
}
func (self *MESSAGE_RESOURCE_BLOCK) OffsetToEntries() uint32 {
if self._OffsetToEntries_cached {
return self._OffsetToEntries
}
result := ParseUint32(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_BLOCK_OffsetToEntries + self.Offset)
self._OffsetToEntries = result
self._OffsetToEntries_cached = true
return result
}
func (self *MESSAGE_RESOURCE_BLOCK) DebugString() string {
result := fmt.Sprintf("struct MESSAGE_RESOURCE_BLOCK @ %#x:\n", self.Offset)
result += fmt.Sprintf(" LowId: %#0x\n", self.LowId())
result += fmt.Sprintf(" HighId: %#0x\n", self.HighId())
result += fmt.Sprintf(" OffsetToEntries: %#0x\n", self.OffsetToEntries())
return result
}
type MESSAGE_RESOURCE_DATA struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_NumberOfBlocks uint32
_NumberOfBlocks_cached bool
__Blocks []*MESSAGE_RESOURCE_BLOCK
__Blocks_cached bool
}
func (self *MESSAGE_RESOURCE_DATA) Size() int {
return 0
}
func (self *MESSAGE_RESOURCE_DATA) NumberOfBlocks() uint32 {
if self._NumberOfBlocks_cached {
return self._NumberOfBlocks
}
result := ParseUint32(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_DATA_NumberOfBlocks + self.Offset)
self._NumberOfBlocks = result
self._NumberOfBlocks_cached = true
return result
}
func (self *MESSAGE_RESOURCE_DATA) _Blocks() []*MESSAGE_RESOURCE_BLOCK {
return ParseArray_MESSAGE_RESOURCE_BLOCK(self.Profile, self.Reader, self.Profile.Off_MESSAGE_RESOURCE_DATA__Blocks + self.Offset, 0)
}
func (self *MESSAGE_RESOURCE_DATA) DebugString() string {
result := fmt.Sprintf("struct MESSAGE_RESOURCE_DATA @ %#x:\n", self.Offset)
result += fmt.Sprintf(" NumberOfBlocks: %#0x\n", self.NumberOfBlocks())
return result
}
type MESSAGE_RESOURCE_ENTRY struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
_Flags uint16
_Flags_cached bool
}
func (self *MESSAGE_RESOURCE_ENTRY) Size() int {
return 0
}
func (self *MESSAGE_RESOURCE_ENTRY) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_ENTRY_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *MESSAGE_RESOURCE_ENTRY) Flags() uint16 {
if self._Flags_cached {
return self._Flags
}
result := ParseUint16(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_ENTRY_Flags + self.Offset)
self._Flags = result
self._Flags_cached = true
return result
}
func (self *MESSAGE_RESOURCE_ENTRY) Text() string {
return ParseTerminatedUTF16String(self.Reader, self.Profile.Off_MESSAGE_RESOURCE_ENTRY_Text + self.Offset)
}
func (self *MESSAGE_RESOURCE_ENTRY) DebugString() string {
result := fmt.Sprintf("struct MESSAGE_RESOURCE_ENTRY @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" Flags: %#0x\n", self.Flags())
result += fmt.Sprintf(" Text: %v\n", string(self.Text()))
return result
}
type PrefixedString struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
__Buffer uint8
__Buffer_cached bool
}
func (self *PrefixedString) Size() int {
return 2
}
func (self *PrefixedString) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_PrefixedString_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *PrefixedString) _Buffer() byte {
if self.__Buffer_cached {
return self.__Buffer
}
result := ParseUint8(self.Reader, self.Profile.Off_PrefixedString__Buffer + self.Offset)
self.__Buffer = result
self.__Buffer_cached = true
return result
}
func (self *PrefixedString) DebugString() string {
result := fmt.Sprintf("struct PrefixedString @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" _Buffer: %#0x\n", self._Buffer())
return result
}
type ResourceString struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
_ValueLength uint16
_ValueLength_cached bool
_Type uint16
_Type_cached bool
}
func (self *ResourceString) Size() int {
return 0
}
func (self *ResourceString) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_ResourceString_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *ResourceString) ValueLength() uint16 {
if self._ValueLength_cached {
return self._ValueLength
}
result := ParseUint16(self.Reader, self.Profile.Off_ResourceString_ValueLength + self.Offset)
self._ValueLength = result
self._ValueLength_cached = true
return result
}
func (self *ResourceString) Type() uint16 {
if self._Type_cached {
return self._Type
}
result := ParseUint16(self.Reader, self.Profile.Off_ResourceString_Type + self.Offset)
self._Type = result
self._Type_cached = true
return result
}
func (self *ResourceString) Key() string {
return ParseTerminatedUTF16String(self.Reader, self.Profile.Off_ResourceString_Key + self.Offset)
}
func (self *ResourceString) DebugString() string {
result := fmt.Sprintf("struct ResourceString @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" ValueLength: %#0x\n", self.ValueLength())
result += fmt.Sprintf(" Type: %#0x\n", self.Type())
result += fmt.Sprintf(" Key: %v\n", string(self.Key()))
return result
}
type StringFileInfo struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
_ValueLength uint16
_ValueLength_cached bool
_Type uint16
_Type_cached bool
}
func (self *StringFileInfo) Size() int {
return 0
}
func (self *StringFileInfo) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_StringFileInfo_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *StringFileInfo) ValueLength() uint16 {
if self._ValueLength_cached {
return self._ValueLength
}
result := ParseUint16(self.Reader, self.Profile.Off_StringFileInfo_ValueLength + self.Offset)
self._ValueLength = result
self._ValueLength_cached = true
return result
}
func (self *StringFileInfo) Type() uint16 {
if self._Type_cached {
return self._Type
}
result := ParseUint16(self.Reader, self.Profile.Off_StringFileInfo_Type + self.Offset)
self._Type = result
self._Type_cached = true
return result
}
func (self *StringFileInfo) Key() string {
return ParseTerminatedUTF16String(self.Reader, self.Profile.Off_StringFileInfo_Key + self.Offset)
}
func (self *StringFileInfo) DebugString() string {
result := fmt.Sprintf("struct StringFileInfo @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" ValueLength: %#0x\n", self.ValueLength())
result += fmt.Sprintf(" Type: %#0x\n", self.Type())
result += fmt.Sprintf(" Key: %v\n", string(self.Key()))
return result
}
type StringTable struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
_ValueLength uint16
_ValueLength_cached bool
_Type uint16
_Type_cached bool
}
func (self *StringTable) Size() int {
return 0
}
func (self *StringTable) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_StringTable_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *StringTable) ValueLength() uint16 {
if self._ValueLength_cached {
return self._ValueLength
}
result := ParseUint16(self.Reader, self.Profile.Off_StringTable_ValueLength + self.Offset)
self._ValueLength = result
self._ValueLength_cached = true
return result
}
func (self *StringTable) Type() uint16 {
if self._Type_cached {
return self._Type
}
result := ParseUint16(self.Reader, self.Profile.Off_StringTable_Type + self.Offset)
self._Type = result
self._Type_cached = true
return result
}
func (self *StringTable) Key() string {
return ParseUTF16String(self.Reader, self.Profile.Off_StringTable_Key + self.Offset, 16)
}
func (self *StringTable) DebugString() string {
result := fmt.Sprintf("struct StringTable @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" ValueLength: %#0x\n", self.ValueLength())
result += fmt.Sprintf(" Type: %#0x\n", self.Type())
result += fmt.Sprintf(" Key: %v\n", string(self.Key()))
return result
}
type VS_VERSIONINFO struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint16
_Length_cached bool
_ValueLength uint16
_ValueLength_cached bool
}
func (self *VS_VERSIONINFO) Size() int {
return 6
}
func (self *VS_VERSIONINFO) Length() uint16 {
if self._Length_cached {
return self._Length
}
result := ParseUint16(self.Reader, self.Profile.Off_VS_VERSIONINFO_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *VS_VERSIONINFO) ValueLength() uint16 {
if self._ValueLength_cached {
return self._ValueLength
}
result := ParseUint16(self.Reader, self.Profile.Off_VS_VERSIONINFO_ValueLength + self.Offset)
self._ValueLength = result
self._ValueLength_cached = true
return result
}
func (self *VS_VERSIONINFO) Type() *Enumeration {
value := ParseUint16(self.Reader, self.Profile.Off_VS_VERSIONINFO_Type + self.Offset)
name := "Unknown"
switch value {
case 0:
name = "Binary"
case 1:
name = "Text"
}
return &Enumeration{Value: uint64(value), Name: name}
}
func (self *VS_VERSIONINFO) szKey() string {
return ParseUTF16String(self.Reader, self.Profile.Off_VS_VERSIONINFO_szKey + self.Offset, 32)
}
func (self *VS_VERSIONINFO) DebugString() string {
result := fmt.Sprintf("struct VS_VERSIONINFO @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" ValueLength: %#0x\n", self.ValueLength())
result += fmt.Sprintf(" Type: %v\n", self.Type().DebugString())
result += fmt.Sprintf(" szKey: %v\n", string(self.szKey()))
return result
}
type WIN_CERTIFICATE struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Length uint32
_Length_cached bool
_Revision uint16
_Revision_cached bool
_CertificateType uint16
_CertificateType_cached bool
}
func (self *WIN_CERTIFICATE) Size() int {
return 8
}
func (self *WIN_CERTIFICATE) Length() uint32 {
if self._Length_cached {
return self._Length
}
result := ParseUint32(self.Reader, self.Profile.Off_WIN_CERTIFICATE_Length + self.Offset)
self._Length = result
self._Length_cached = true
return result
}
func (self *WIN_CERTIFICATE) Revision() uint16 {
if self._Revision_cached {
return self._Revision
}
result := ParseUint16(self.Reader, self.Profile.Off_WIN_CERTIFICATE_Revision + self.Offset)
self._Revision = result
self._Revision_cached = true
return result
}
func (self *WIN_CERTIFICATE) CertificateType() uint16 {
if self._CertificateType_cached {
return self._CertificateType
}
result := ParseUint16(self.Reader, self.Profile.Off_WIN_CERTIFICATE_CertificateType + self.Offset)
self._CertificateType = result
self._CertificateType_cached = true
return result
}
func (self *WIN_CERTIFICATE) DebugString() string {
result := fmt.Sprintf("struct WIN_CERTIFICATE @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Length: %#0x\n", self.Length())
result += fmt.Sprintf(" Revision: %#0x\n", self.Revision())
result += fmt.Sprintf(" CertificateType: %#0x\n", self.CertificateType())
return result
}
type GENERIC_DIRECTORY struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_TimeDateStamp *UnixTimeStamp32
}
func (self *GENERIC_DIRECTORY) Size() int {
return 16
}
func (self *GENERIC_DIRECTORY) TimeDateStamp() *UnixTimeStamp32 {
if self._TimeDateStamp != nil {
return self._TimeDateStamp
}
result := self.Profile.UnixTimeStamp32(self.Reader, self.Profile.Off_GENERIC_DIRECTORY_TimeDateStamp + self.Offset)
self._TimeDateStamp = result
return result
}
func (self *GENERIC_DIRECTORY) DebugString() string {
result := fmt.Sprintf("struct GENERIC_DIRECTORY @ %#x:\n", self.Offset)
result += fmt.Sprintf(" TimeDateStamp: {\n%v}\n", indent(self.TimeDateStamp().DebugString()))
return result
}
type GUID struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_Data1 uint32
_Data1_cached bool
_Data2 uint16
_Data2_cached bool
_Data3 uint16
_Data3_cached bool
_Data4 []byte
_Data4_cached bool
}
func (self *GUID) Size() int {
return 16
}
func (self *GUID) Data1() uint32 {
if self._Data1_cached {
return self._Data1
}
result := ParseUint32(self.Reader, self.Profile.Off_GUID_Data1 + self.Offset)
self._Data1 = result
self._Data1_cached = true
return result
}
func (self *GUID) Data2() uint16 {
if self._Data2_cached {
return self._Data2
}
result := ParseUint16(self.Reader, self.Profile.Off_GUID_Data2 + self.Offset)
self._Data2 = result
self._Data2_cached = true
return result
}
func (self *GUID) Data3() uint16 {
if self._Data3_cached {
return self._Data3
}
result := ParseUint16(self.Reader, self.Profile.Off_GUID_Data3 + self.Offset)
self._Data3 = result
self._Data3_cached = true
return result
}
func (self *GUID) Data4() []byte {
return ParseArray_byte(self.Profile, self.Reader, self.Profile.Off_GUID_Data4 + self.Offset, 8)
}
func (self *GUID) DebugString() string {
result := fmt.Sprintf("struct GUID @ %#x:\n", self.Offset)
result += fmt.Sprintf(" Data1: %#0x\n", self.Data1())
result += fmt.Sprintf(" Data2: %#0x\n", self.Data2())
result += fmt.Sprintf(" Data3: %#0x\n", self.Data3())
return result
}
type IMAGE_DATA_DIRECTORY struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_DirSize uint32
_DirSize_cached bool
_VirtualAddress uint32
_VirtualAddress_cached bool
}
func (self *IMAGE_DATA_DIRECTORY) Size() int {
return 8
}
func (self *IMAGE_DATA_DIRECTORY) DirSize() uint32 {
if self._DirSize_cached {
return self._DirSize
}
result := ParseUint32(self.Reader, self.Profile.Off_IMAGE_DATA_DIRECTORY_DirSize + self.Offset)
self._DirSize = result
self._DirSize_cached = true
return result
}
func (self *IMAGE_DATA_DIRECTORY) VirtualAddress() uint32 {
if self._VirtualAddress_cached {
return self._VirtualAddress
}
result := ParseUint32(self.Reader, self.Profile.Off_IMAGE_DATA_DIRECTORY_VirtualAddress + self.Offset)
self._VirtualAddress = result
self._VirtualAddress_cached = true
return result
}
func (self *IMAGE_DATA_DIRECTORY) DebugString() string {
result := fmt.Sprintf("struct IMAGE_DATA_DIRECTORY @ %#x:\n", self.Offset)
result += fmt.Sprintf(" DirSize: %#0x\n", self.DirSize())
result += fmt.Sprintf(" VirtualAddress: %#0x\n", self.VirtualAddress())
return result
}
type IMAGE_DEBUG_DIRECTORY struct {
Reader io.ReaderAt
Offset int64
Profile *PeProfile
_AddressOfRawData uint32
_AddressOfRawData_cached bool
_TimeDateStamp *UnixTimeStamp32
}
func (self *IMAGE_DEBUG_DIRECTORY) Size() int {
return 24
}
func (self *IMAGE_DEBUG_DIRECTORY) AddressOfRawData() uint32 {
if self._AddressOfRawData_cached {
return self._AddressOfRawData
}
result := ParseUint32(self.Reader, self.Profile.Off_IMAGE_DEBUG_DIRECTORY_AddressOfRawData + self.Offset)
self._AddressOfRawData = result
self._AddressOfRawData_cached = true
return result
}
func (self *IMAGE_DEBUG_DIRECTORY) TimeDateStamp() *UnixTimeStamp32 {
if self._TimeDateStamp != nil {
return self._TimeDateStamp
}
result := self.Profile.UnixTimeStamp32(self.Reader, self.Profile.Off_IMAGE_DEBUG_DIRECTORY_TimeDateStamp + self.Offset)
self._TimeDateStamp = result
return result
}
func (self *IMAGE_DEBUG_DIRECTORY) Type() *Enumeration {
value := ParseUint32(self.Reader, self.Profile.Off_IMAGE_DEBUG_DIRECTORY_Type + self.Offset)
name := "Unknown"
switch value {
case 0:
name = "IMAGE_DEBUG_TYPE_UNKNOWN"
case 1:
name = "IMAGE_DEBUG_TYPE_COFF"
case 2:
name = "IMAGE_DEBUG_TYPE_CODEVIEW"