mEOF.bas
VB declares PE image header structureVB declares PE e_lfanew header field
SHA-2560401a1ea3de46ae76d56792f79e2a2f5f94e25b4f27aaeaaa75d72c22e8c7df0
MaleculeH₂(Db₂F)
Evidence
1Attribute VB_Name = "mEOF"
2
3Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, Src As Any, ByVal L As Long)
4
5Public Type IMAGE_DOS_HEADER
6 e_magic As Integer ' Magic number
7 e_cblp As Integer ' Bytes on last page of file
8 e_cp As Integer …
21 e_oemid As Integer ' OEM identifier (for e_oeminfo)
22 e_oeminfo As Integer ' OEM information; e_oemid specific
23 e_res2(0 To 9) As Integer ' Reserved words
24 e_lfanew As Long ' File address of new exe header
25End Type
26Public Type IMAGE_FILE_HEADER
27 Machine As Integer
28 NumberOfSections As Integer
29 TimeDateStamp As Long
30 PointerToSymbolTable As Long
31 Numb …
87 Characteristics As Long
88End Type
89
90Public Sub PatchEOF(strFile As String)
91
92 Dim idh As IMAGE_DOS_HEADER
93 Dim inh As IMAGE_NT_HEADERS
94 Dim ish As IMAGE_SECTION_HEADER
95 Dim FileData As String
96 Dim ExeData() As Byte
97 Dim ExeLen As Long
98
99 'Get binary data to file and convert to byte array
100 FileData = GetFileData(strFile)
101 ExeData = StrConv(FileData, vbFromUnicode)
102
103 'Copy ExeData into IMAGE_DOS_HEADER and check if it's valid
104 CopyMemory idh, ExeData(0), 64
105 If idh.e_magic < …
106:4… Debug.Print "Not Valid EXE!"
107 Exit Sub
108 End If
109
110 'Copy ExeData into IMAGE_NT_HEADER and check if it's valid
111 CopyMemory inh, ExeData( …
130:41… ode)
131 SaveFileData strFile, FileData
132
133End Sub
134
135Public Function GetFileData(strFile As String) As String
136
137Dim strData As String
138Open strFile For Binary Access Read Lock Write As #1
139 strData = String$(LOF(1), Chr$(0))
140 Get #1, , strData
141Close #1
142GetFileData = strData
143
144End Function
145
146Public Sub SaveFileData(strFile As String, strData As String)
147
148Open strFile For Output As #1
149 Print #1, strData
150Close #1
⋯5 lines