forked from Velocidex/go-yara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules_pe_utils.c
1929 lines (1851 loc) · 47.2 KB
/
modules_pe_utils.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
/*
Copyright (c) 2014-2015. The YARA Authors. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <yara_endian.h>
#include <yara_utils.h>
#include <yara_strutils.h>
#include <yara_mem.h>
#include <yara_integers.h>
#include <yara_pe_utils.h>
#include <yara_pe.h>
#if HAVE_LIBCRYPTO
#include <openssl/asn1.h>
#endif
PIMAGE_NT_HEADERS32 pe_get_header(
const uint8_t* data,
size_t data_size)
{
PIMAGE_DOS_HEADER mz_header;
PIMAGE_NT_HEADERS32 pe_header;
size_t headers_size = 0;
if (data_size < sizeof(IMAGE_DOS_HEADER))
return NULL;
mz_header = (PIMAGE_DOS_HEADER) data;
if (yr_le16toh(mz_header->e_magic) != IMAGE_DOS_SIGNATURE)
return NULL;
if (yr_le32toh(mz_header->e_lfanew) < 0)
return NULL;
headers_size = yr_le32toh(mz_header->e_lfanew) + \
sizeof(pe_header->Signature) + \
sizeof(IMAGE_FILE_HEADER);
if (data_size < headers_size)
return NULL;
pe_header = (PIMAGE_NT_HEADERS32) (data + yr_le32toh(mz_header->e_lfanew));
if (yr_le32toh(pe_header->Signature) != IMAGE_NT_SIGNATURE)
return NULL;
if (data_size < headers_size + sizeof(IMAGE_OPTIONAL_HEADER32))
return NULL;
if (pe_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
headers_size += sizeof(IMAGE_OPTIONAL_HEADER64);
else
headers_size += sizeof(IMAGE_OPTIONAL_HEADER32);
if (data_size < headers_size)
return NULL;
if (yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_UNKNOWN &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_AM33 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_AMD64 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_ARM &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_ARMNT &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_ARM64 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_EBC &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_I386 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_IA64 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_M32R &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_MIPS16 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_MIPSFPU &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_MIPSFPU16 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_POWERPC &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_POWERPCFP &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_R4000 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_SH3 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_SH3DSP &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_SH4 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_SH5 &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_THUMB &&
yr_le16toh(pe_header->FileHeader.Machine) != IMAGE_FILE_MACHINE_WCEMIPSV2)
{
return NULL;
}
return pe_header;
}
PIMAGE_DATA_DIRECTORY pe_get_directory_entry(
PE* pe,
int entry)
{
PIMAGE_DATA_DIRECTORY directory_start;
uint8_t* optional_header_start;
uint16_t optional_header_size;
// We are specifically NOT checking NumberOfRvaAndSizes here because it can
// lie. 7ff1bf680c80fd73c0b35084904848b3705480ddeb6d0eff62180bd14cd18570 has
// NumberOfRvaAndSizes set to 11 when in fact there is a valid
// IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR entry (which is more than 11). If we
// are overly strict here and only parse entries which are less than
// NumberOfRvaAndSizes we run the risk of missing otherwise perfectly valid
// files. Instead of being strict we check to make sure the entry is within
// the OptionalHeader, since SizeOfOptionalHeader includes the DataDirectory
// array.
// In case someone requests an entry which is, by definition, invalid.
if (entry >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES)
return NULL;
if (IS_64BITS_PE(pe))
{
optional_header_start = (uint8_t*) &pe->header64->OptionalHeader;
optional_header_size = pe->header64->FileHeader.SizeOfOptionalHeader;
directory_start = pe->header64->OptionalHeader.DataDirectory;
}
else
{
optional_header_start = (uint8_t*) &pe->header->OptionalHeader;
optional_header_size = pe->header->FileHeader.SizeOfOptionalHeader;
directory_start = pe->header->OptionalHeader.DataDirectory;
}
// Make sure the entry doesn't point outside of the OptionalHeader.
if ((uint8_t*) (directory_start + entry) <= optional_header_start + optional_header_size)
{
if (IS_64BITS_PE(pe))
return &pe->header64->OptionalHeader.DataDirectory[entry];
else
return &pe->header->OptionalHeader.DataDirectory[entry];
}
return NULL;
}
int64_t pe_rva_to_offset(
PE* pe,
uint64_t rva)
{
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(pe->header);
DWORD lowest_section_rva = 0xffffffff;
DWORD section_rva = 0;
DWORD section_offset = 0;
DWORD section_raw_size = 0;
int64_t result;
int i = 0;
int alignment = 0;
int rest = 0;
while(i < yr_min(yr_le16toh(pe->header->FileHeader.NumberOfSections), MAX_PE_SECTIONS))
{
if (struct_fits_in_pe(pe, section, IMAGE_SECTION_HEADER))
{
if (lowest_section_rva > yr_le32toh(section->VirtualAddress))
{
lowest_section_rva = yr_le32toh(section->VirtualAddress);
}
if (rva >= yr_le32toh(section->VirtualAddress) &&
section_rva <= yr_le32toh(section->VirtualAddress))
{
// Round section_offset
//
// Rounding everything less than 0x200 to 0 as discussed in
// https://code.google.com/archive/p/corkami/wikis/PE.wiki#PointerToRawData
// does not work for PE32_FILE from the test suite and for
// some tinype samples where File Alignment = 4
// (http://www.phreedom.org/research/tinype/).
//
// If FileAlignment is >= 0x200, it is apparently ignored (see
// Ero Carreras's pefile.py, PE.adjust_FileAlignment).
alignment = yr_min(yr_le32toh(OptionalHeader(pe, FileAlignment)), 0x200);
section_rva = yr_le32toh(section->VirtualAddress);
section_offset = yr_le32toh(section->PointerToRawData);
section_raw_size = yr_le32toh(section->SizeOfRawData);
if (alignment)
{
rest = section_offset % alignment;
if (rest)
section_offset -= rest;
}
}
section++;
i++;
}
else
{
return -1;
}
}
// Everything before the first section seems to get mapped straight
// relative to ImageBase.
if (rva < lowest_section_rva)
{
section_rva = 0;
section_offset = 0;
section_raw_size = (DWORD) pe->data_size;
}
// Many sections, have a raw (on disk) size smaller than their in-memory size.
// Check for rva's that map to this sparse space, and therefore have no valid
// associated file offset.
if ((rva - section_rva) >= section_raw_size)
return -1;
result = section_offset + (rva - section_rva);
// Check that the offset fits within the file.
if (result >= pe->data_size)
return -1;
return result;
}
#if !HAVE_TIMEGM
#if HAVE__MKGMTIME
#define timegm _mkgmtime
#else
#include <time.h>
static bool is_leap(
unsigned int year)
{
year += 1900;
return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
}
time_t timegm(
struct tm *tm)
{
static const unsigned ndays[2][12] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
time_t res = 0;
int i;
for (i = 70; i < tm->tm_year; ++i)
res += is_leap(i) ? 366 : 365;
for (i = 0; i < tm->tm_mon; ++i)
res += ndays[is_leap(tm->tm_year)][i];
res += tm->tm_mday - 1;
res *= 24;
res += tm->tm_hour;
res *= 60;
res += tm->tm_min;
res *= 60;
res += tm->tm_sec;
return res;
}
#endif // HAVE__MKGMTIME
#endif // !HAVE_TIMEGM
#if HAVE_LIBCRYPTO
// Taken from http://stackoverflow.com/questions/10975542/asn1-time-conversion
// and cleaned up. Also uses timegm(3) instead of mktime(3).
time_t ASN1_get_time_t(
ASN1_TIME* time)
{
struct tm t;
const char* str = (const char*) time->data;
size_t i = 0;
memset(&t, 0, sizeof(t));
if (time->type == V_ASN1_UTCTIME) /* two digit year */
{
t.tm_year = (str[i++] - '0') * 10;
t.tm_year += (str[i++] - '0');
if (t.tm_year < 70)
t.tm_year += 100;
}
else if (time->type == V_ASN1_GENERALIZEDTIME) /* four digit year */
{
t.tm_year = (str[i++] - '0') * 1000;
t.tm_year += (str[i++] - '0') * 100;
t.tm_year += (str[i++] - '0') * 10;
t.tm_year += (str[i++] - '0');
t.tm_year -= 1900;
}
t.tm_mon = (str[i++] - '0') * 10;
t.tm_mon += (str[i++] - '0') - 1; // -1 since January is 0 not 1.
t.tm_mday = (str[i++] - '0') * 10;
t.tm_mday += (str[i++] - '0');
t.tm_hour = (str[i++] - '0') * 10;
t.tm_hour += (str[i++] - '0');
t.tm_min = (str[i++] - '0') * 10;
t.tm_min += (str[i++] - '0');
t.tm_sec = (str[i++] - '0') * 10;
t.tm_sec += (str[i++] - '0');
/* Note: we did not adjust the time based on time zone information */
return timegm(&t);
}
#endif
// These ordinals are taken from pefile. If a lookup fails attempt to return
// "ordN" and if that fails, return NULL. The caller is responsible for freeing
// the returned string.
char *ord_lookup(
char *dll,
uint16_t ord)
{
char name[64];
name[0] = '\0';
if (strncasecmp(dll, "WS2_32.dll", 10) == 0 ||
strncasecmp(dll, "wsock32.dll", 11) == 0)
{
switch(ord) {
case 1:
sprintf(name, "accept");
break;
case 2:
sprintf(name, "bind");
break;
case 3:
sprintf(name, "closesocket");
break;
case 4:
sprintf(name, "connect");
break;
case 5:
sprintf(name, "getpeername");
break;
case 6:
sprintf(name, "getsockname");
break;
case 7:
sprintf(name, "getsockopt");
break;
case 8:
sprintf(name, "htonl");
break;
case 9:
sprintf(name, "htons");
break;
case 10:
sprintf(name, "ioctlsocket");
break;
case 11:
sprintf(name, "inet_addr");
break;
case 12:
sprintf(name, "inet_ntoa");
break;
case 13:
sprintf(name, "listen");
break;
case 14:
sprintf(name, "ntohl");
break;
case 15:
sprintf(name, "ntohs");
break;
case 16:
sprintf(name, "recv");
break;
case 17:
sprintf(name, "recvfrom");
break;
case 18:
sprintf(name, "select");
break;
case 19:
sprintf(name, "send");
break;
case 20:
sprintf(name, "sendto");
break;
case 21:
sprintf(name, "setsockopt");
break;
case 22:
sprintf(name, "shutdown");
break;
case 23:
sprintf(name, "socket");
break;
case 24:
sprintf(name, "GetAddrInfoW");
break;
case 25:
sprintf(name, "GetNameInfoW");
break;
case 26:
sprintf(name, "WSApSetPostRoutine");
break;
case 27:
sprintf(name, "FreeAddrInfoW");
break;
case 28:
sprintf(name, "WPUCompleteOverlappedRequest");
break;
case 29:
sprintf(name, "WSAAccept");
break;
case 30:
sprintf(name, "WSAAddressToStringA");
break;
case 31:
sprintf(name, "WSAAddressToStringW");
break;
case 32:
sprintf(name, "WSACloseEvent");
break;
case 33:
sprintf(name, "WSAConnect");
break;
case 34:
sprintf(name, "WSACreateEvent");
break;
case 35:
sprintf(name, "WSADuplicateSocketA");
break;
case 36:
sprintf(name, "WSADuplicateSocketW");
break;
case 37:
sprintf(name, "WSAEnumNameSpaceProvidersA");
break;
case 38:
sprintf(name, "WSAEnumNameSpaceProvidersW");
break;
case 39:
sprintf(name, "WSAEnumNetworkEvents");
break;
case 40:
sprintf(name, "WSAEnumProtocolsA");
break;
case 41:
sprintf(name, "WSAEnumProtocolsW");
break;
case 42:
sprintf(name, "WSAEventSelect");
break;
case 43:
sprintf(name, "WSAGetOverlappedResult");
break;
case 44:
sprintf(name, "WSAGetQOSByName");
break;
case 45:
sprintf(name, "WSAGetServiceClassInfoA");
break;
case 46:
sprintf(name, "WSAGetServiceClassInfoW");
break;
case 47:
sprintf(name, "WSAGetServiceClassNameByClassIdA");
break;
case 48:
sprintf(name, "WSAGetServiceClassNameByClassIdW");
break;
case 49:
sprintf(name, "WSAHtonl");
break;
case 50:
sprintf(name, "WSAHtons");
break;
case 51:
sprintf(name, "gethostbyaddr");
break;
case 52:
sprintf(name, "gethostbyname");
break;
case 53:
sprintf(name, "getprotobyname");
break;
case 54:
sprintf(name, "getprotobynumber");
break;
case 55:
sprintf(name, "getservbyname");
break;
case 56:
sprintf(name, "getservbyport");
break;
case 57:
sprintf(name, "gethostname");
break;
case 58:
sprintf(name, "WSAInstallServiceClassA");
break;
case 59:
sprintf(name, "WSAInstallServiceClassW");
break;
case 60:
sprintf(name, "WSAIoctl");
break;
case 61:
sprintf(name, "WSAJoinLeaf");
break;
case 62:
sprintf(name, "WSALookupServiceBeginA");
break;
case 63:
sprintf(name, "WSALookupServiceBeginW");
break;
case 64:
sprintf(name, "WSALookupServiceEnd");
break;
case 65:
sprintf(name, "WSALookupServiceNextA");
break;
case 66:
sprintf(name, "WSALookupServiceNextW");
break;
case 67:
sprintf(name, "WSANSPIoctl");
break;
case 68:
sprintf(name, "WSANtohl");
break;
case 69:
sprintf(name, "WSANtohs");
break;
case 70:
sprintf(name, "WSAProviderConfigChange");
break;
case 71:
sprintf(name, "WSARecv");
break;
case 72:
sprintf(name, "WSARecvDisconnect");
break;
case 73:
sprintf(name, "WSARecvFrom");
break;
case 74:
sprintf(name, "WSARemoveServiceClass");
break;
case 75:
sprintf(name, "WSAResetEvent");
break;
case 76:
sprintf(name, "WSASend");
break;
case 77:
sprintf(name, "WSASendDisconnect");
break;
case 78:
sprintf(name, "WSASendTo");
break;
case 79:
sprintf(name, "WSASetEvent");
break;
case 80:
sprintf(name, "WSASetServiceA");
break;
case 81:
sprintf(name, "WSASetServiceW");
break;
case 82:
sprintf(name, "WSASocketA");
break;
case 83:
sprintf(name, "WSASocketW");
break;
case 84:
sprintf(name, "WSAStringToAddressA");
break;
case 85:
sprintf(name, "WSAStringToAddressW");
break;
case 86:
sprintf(name, "WSAWaitForMultipleEvents");
break;
case 87:
sprintf(name, "WSCDeinstallProvider");
break;
case 88:
sprintf(name, "WSCEnableNSProvider");
break;
case 89:
sprintf(name, "WSCEnumProtocols");
break;
case 90:
sprintf(name, "WSCGetProviderPath");
break;
case 91:
sprintf(name, "WSCInstallNameSpace");
break;
case 92:
sprintf(name, "WSCInstallProvider");
break;
case 93:
sprintf(name, "WSCUnInstallNameSpace");
break;
case 94:
sprintf(name, "WSCUpdateProvider");
break;
case 95:
sprintf(name, "WSCWriteNameSpaceOrder");
break;
case 96:
sprintf(name, "WSCWriteProviderOrder");
break;
case 97:
sprintf(name, "freeaddrinfo");
break;
case 98:
sprintf(name, "getaddrinfo");
break;
case 99:
sprintf(name, "getnameinfo");
break;
case 101:
sprintf(name, "WSAAsyncSelect");
break;
case 102:
sprintf(name, "WSAAsyncGetHostByAddr");
break;
case 103:
sprintf(name, "WSAAsyncGetHostByName");
break;
case 104:
sprintf(name, "WSAAsyncGetProtoByNumber");
break;
case 105:
sprintf(name, "WSAAsyncGetProtoByName");
break;
case 106:
sprintf(name, "WSAAsyncGetServByPort");
break;
case 107:
sprintf(name, "WSAAsyncGetServByName");
break;
case 108:
sprintf(name, "WSACancelAsyncRequest");
break;
case 109:
sprintf(name, "WSASetBlockingHook");
break;
case 110:
sprintf(name, "WSAUnhookBlockingHook");
break;
case 111:
sprintf(name, "WSAGetLastError");
break;
case 112:
sprintf(name, "WSASetLastError");
break;
case 113:
sprintf(name, "WSACancelBlockingCall");
break;
case 114:
sprintf(name, "WSAIsBlocking");
break;
case 115:
sprintf(name, "WSAStartup");
break;
case 116:
sprintf(name, "WSACleanup");
break;
case 151:
sprintf(name, "__WSAFDIsSet");
break;
case 500:
sprintf(name, "WEP");
break;
default:
break;
}
}
else if (strncasecmp(dll, "oleaut32.dll", 12) == 0)
{
switch (ord) {
case 2:
sprintf(name, "SysAllocString");
break;
case 3:
sprintf(name, "SysReAllocString");
break;
case 4:
sprintf(name, "SysAllocStringLen");
break;
case 5:
sprintf(name, "SysReAllocStringLen");
break;
case 6:
sprintf(name, "SysFreeString");
break;
case 7:
sprintf(name, "SysStringLen");
break;
case 8:
sprintf(name, "VariantInit");
break;
case 9:
sprintf(name, "VariantClear");
break;
case 10:
sprintf(name, "VariantCopy");
break;
case 11:
sprintf(name, "VariantCopyInd");
break;
case 12:
sprintf(name, "VariantChangeType");
break;
case 13:
sprintf(name, "VariantTimeToDosDateTime");
break;
case 14:
sprintf(name, "DosDateTimeToVariantTime");
break;
case 15:
sprintf(name, "SafeArrayCreate");
break;
case 16:
sprintf(name, "SafeArrayDestroy");
break;
case 17:
sprintf(name, "SafeArrayGetDim");
break;
case 18:
sprintf(name, "SafeArrayGetElemsize");
break;
case 19:
sprintf(name, "SafeArrayGetUBound");
break;
case 20:
sprintf(name, "SafeArrayGetLBound");
break;
case 21:
sprintf(name, "SafeArrayLock");
break;
case 22:
sprintf(name, "SafeArrayUnlock");
break;
case 23:
sprintf(name, "SafeArrayAccessData");
break;
case 24:
sprintf(name, "SafeArrayUnaccessData");
break;
case 25:
sprintf(name, "SafeArrayGetElement");
break;
case 26:
sprintf(name, "SafeArrayPutElement");
break;
case 27:
sprintf(name, "SafeArrayCopy");
break;
case 28:
sprintf(name, "DispGetParam");
break;
case 29:
sprintf(name, "DispGetIDsOfNames");
break;
case 30:
sprintf(name, "DispInvoke");
break;
case 31:
sprintf(name, "CreateDispTypeInfo");
break;
case 32:
sprintf(name, "CreateStdDispatch");
break;
case 33:
sprintf(name, "RegisterActiveObject");
break;
case 34:
sprintf(name, "RevokeActiveObject");
break;
case 35:
sprintf(name, "GetActiveObject");
break;
case 36:
sprintf(name, "SafeArrayAllocDescriptor");
break;
case 37:
sprintf(name, "SafeArrayAllocData");
break;
case 38:
sprintf(name, "SafeArrayDestroyDescriptor");
break;
case 39:
sprintf(name, "SafeArrayDestroyData");
break;
case 40:
sprintf(name, "SafeArrayRedim");
break;
case 41:
sprintf(name, "SafeArrayAllocDescriptorEx");
break;
case 42:
sprintf(name, "SafeArrayCreateEx");
break;
case 43:
sprintf(name, "SafeArrayCreateVectorEx");
break;
case 44:
sprintf(name, "SafeArraySetRecordInfo");
break;
case 45:
sprintf(name, "SafeArrayGetRecordInfo");
break;
case 46:
sprintf(name, "VarParseNumFromStr");
break;
case 47:
sprintf(name, "VarNumFromParseNum");
break;
case 48:
sprintf(name, "VarI2FromUI1");
break;
case 49:
sprintf(name, "VarI2FromI4");
break;
case 50:
sprintf(name, "VarI2FromR4");
break;
case 51:
sprintf(name, "VarI2FromR8");
break;
case 52:
sprintf(name, "VarI2FromCy");
break;
case 53:
sprintf(name, "VarI2FromDate");
break;
case 54:
sprintf(name, "VarI2FromStr");
break;
case 55:
sprintf(name, "VarI2FromDisp");
break;
case 56:
sprintf(name, "VarI2FromBool");
break;
case 57:
sprintf(name, "SafeArraySetIID");
break;
case 58:
sprintf(name, "VarI4FromUI1");
break;
case 59:
sprintf(name, "VarI4FromI2");
break;
case 60:
sprintf(name, "VarI4FromR4");
break;
case 61:
sprintf(name, "VarI4FromR8");
break;
case 62:
sprintf(name, "VarI4FromCy");
break;
case 63:
sprintf(name, "VarI4FromDate");
break;
case 64:
sprintf(name, "VarI4FromStr");
break;
case 65:
sprintf(name, "VarI4FromDisp");
break;
case 66:
sprintf(name, "VarI4FromBool");
break;
case 67:
sprintf(name, "SafeArrayGetIID");
break;
case 68:
sprintf(name, "VarR4FromUI1");
break;
case 69:
sprintf(name, "VarR4FromI2");
break;
case 70:
sprintf(name, "VarR4FromI4");
break;
case 71:
sprintf(name, "VarR4FromR8");
break;
case 72:
sprintf(name, "VarR4FromCy");
break;
case 73:
sprintf(name, "VarR4FromDate");
break;
case 74:
sprintf(name, "VarR4FromStr");
break;
case 75:
sprintf(name, "VarR4FromDisp");
break;
case 76:
sprintf(name, "VarR4FromBool");
break;
case 77:
sprintf(name, "SafeArrayGetVartype");
break;
case 78:
sprintf(name, "VarR8FromUI1");
break;
case 79:
sprintf(name, "VarR8FromI2");
break;
case 80:
sprintf(name, "VarR8FromI4");
break;
case 81:
sprintf(name, "VarR8FromR4");
break;
case 82:
sprintf(name, "VarR8FromCy");
break;
case 83:
sprintf(name, "VarR8FromDate");
break;
case 84:
sprintf(name, "VarR8FromStr");
break;
case 85:
sprintf(name, "VarR8FromDisp");
break;
case 86:
sprintf(name, "VarR8FromBool");
break;
case 87:
sprintf(name, "VarFormat");
break;
case 88:
sprintf(name, "VarDateFromUI1");
break;
case 89:
sprintf(name, "VarDateFromI2");
break;
case 90:
sprintf(name, "VarDateFromI4");
break;
case 91:
sprintf(name, "VarDateFromR4");
break;
case 92:
sprintf(name, "VarDateFromR8");
break;
case 93:
sprintf(name, "VarDateFromCy");