-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPE_Finish.asm
67 lines (52 loc) · 1.36 KB
/
PE_Finish.asm
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
;==============================================================================
;
; PE Library
;
; Copyright (c) 2019 by fearless
;
; http://github.com/mrfearless
;
;==============================================================================
.686
.MMX
.XMM
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
include PE.inc
EXTERNDEF PE_SetError :PROTO :DWORD,:DWORD
.CODE
PE_ALIGN
;------------------------------------------------------------------------------
; PE_Finish - Frees up hPE if PE was processed from memory directly with a call
; to PE_Analyze. If PE was opened as a file via PE_OpenFile, then PE_CloseFile
; should be used instead of this function.
; Returns: None
;------------------------------------------------------------------------------
PE_Finish PROC USES EBX hPE:DWORD
IFDEF DEBUG32
PrintText 'PE_Finish'
ENDIF
.IF hPE == NULL
xor eax, eax
ret
.ENDIF
mov ebx, hPE
mov ebx, [ebx].PEINFO.PEHandle
.IF ebx != 0
mov eax, 0 ; null out hPE handle if it exists
mov [ebx], eax
.ENDIF
mov eax, hPE
.IF eax != NULL
Invoke GlobalFree, eax
.ENDIF
Invoke PE_SetError, NULL, PE_ERROR_SUCCESS
xor eax, eax
ret
PE_Finish ENDP
PE_LIBEND