-
Notifications
You must be signed in to change notification settings - Fork 1
/
rva_map_clamav.lmod
48 lines (37 loc) · 1.32 KB
/
rva_map_clamav.lmod
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
############################################
## libclamav/pe.c:cli_rawaddr
############################################
LOADREL clamav
DEFINE FILESIZE 500
INPUT HEADER FILESIZE
INPUT RVA 4
OUTPUT OFF 4
OUTPUT VAL 1
OUTPUT ERROR 1
P: sectOff <- SECT HEADER
P: nSect <- NSECT HEADER
P: optHdr <- OPTHDR HEADER as pe_image_optional_hdr32
P: hdrSize <- optHdr.SizeOfHeaders
V1: ULE RVA hdrSize
V2(V1): UGE RVA FILESIZE
V3(V2): EQ ERROR 1 term
V4(V1, !V2): AND (EQ RVA OFF) (EQ ERROR 0) term
P: notFound <- INT 0 (sizeof pe_image_section_hdr)
P: found <- notFound as pe_image_section_hdr
L1: sect <- LOOP(HEADER, sectOff, sizeof pe_image_section_hdr, nSect, 5) AS pe_image_section_hdr
P: SRVA <- sect.VirtualAddress
P: cl_rva <- ALIGNDOWN SRVA optHdr.SectionAlignment
P: SRSZ <- sect.SizeOfRawData
P: cl_rsz <- ALIGNUP SRSZ optHdr.FileAlignment
V5(!V1): AND (EQ found notFound) (AND AND (NEQ cl_rsz 0) (UGE RVA cl_rva) (UGT cl_rsz (SUB RVA cl_rva)))
P(V5): found <- sect
END L1
V6(!V1): EQ found notFound
V7(V6): EQ ERROR 1 term
P: SRVA <- found.VirtualAddress
P: cl_rva <- ALIGNUP SRVA optHdr.SectionAlignment
P: PRD <- found.PointerToRawData
P: cl_raw <- ALIGNDOWN PRD optHdr.FileAlignment
V8(!V1, !V6): EQ OFF (ADD (SUB RVA cl_rva) cl_raw) term
V9(!V1, !V6): EQ VAL HEADER[OFF, 1] term
V10(!V1, !V6): EQ ERROR 0 term