; Listing generated by Microsoft (R) Optimizing Compiler Version 19.26.28806.0 

	TITLE	C:\Users\IEUser\Source\Repos\Project1\Project1\shellcode_task_step1.cpp
	.686P
	.XMM
	;include listing.inc
	.model	flat

assume fs:nothing

CONST	SEGMENT
;$SG89718 DB	'k', 00H, 'e', 00H, 'r', 00H, 'n', 00H, 'e', 00H, 'l', 00H
;	DB	'3', 00H, '2', 00H, '.', 00H, 'd', 00H, 'l', 00H, 'l', 00H, 00H
;	DB	00H
;	ORG $+2
;$SG89720 DB	'LoadLibraryA', 00H
;	ORG $+3
;$SG89722 DB	'GetProcAddress', 00H
;	ORG $+1
;$SG89724 DB	'user32.dll', 00H
;	ORG $+1
;$SG89725 DB	'MessageBoxW', 00H
;$SG89727 DB	'O', 00H, 'K', 00H, 00H, 00H
;	ORG $+2
;$SG89728 DB	'L', 00H, 'o', 00H, 'a', 00H, 'd', 00H, 'e', 00H, 'd', 00H
;	DB	'!', 00H, 00H, 00H
CONST	ENDS
PUBLIC	?get_module_by_name@@YAPAXPA_W@Z		; get_module_by_name
PUBLIC	?get_func_by_name@@YAPAXPAXPAD@Z		; get_func_by_name
PUBLIC	_main
; Function compile flags: /Odtp
_TEXT	SEGMENT
__GetProcAddress$ = -28					; size = 4
_u32_dll$ = -24						; size = 4
__LoadLibraryA$ = -20					; size = 4
__MessageBoxW$ = -16					; size = 4
_get_proc$ = -12					; size = 4
_load_lib$ = -8						; size = 4
_base$ = -4						; size = 4
_main	PROC
; File C:\Users\IEUser\Source\Repos\Project1\Project1\shellcode_task_step1.cpp
; Line 149
	push	ebp
	mov	ebp, esp
	sub	esp, 28					; 0000001cH
; Line 150
	call after_kernel32_str
DB	'k', 00H, 'e', 00H, 'r', 00H, 'n', 00H, 'e', 00H, 'l', 00H
	DB	'3', 00H, '2', 00H, '.', 00H, 'd', 00H, 'l', 00H, 'l', 00H, 00H
	DB	00H
	ORG $+2
after_kernel32_str:
	;push	OFFSET $SG89718
	call	?get_module_by_name@@YAPAXPA_W@Z	; get_module_by_name
	add	esp, 4
	mov	DWORD PTR _base$[ebp], eax
; Line 151
	cmp	DWORD PTR _base$[ebp], 0
	jne	SHORT $LN2@main
; Line 152
	mov	eax, 1
	jmp	$LN1@main
$LN2@main:
; Line 155
	call after_load_lib_str
    DB	'LoadLibraryA', 00H
	ORG $+3
after_load_lib_str:
	;push	OFFSET $SG89720
	mov	eax, DWORD PTR _base$[ebp]
	push	eax
	call	?get_func_by_name@@YAPAXPAXPAD@Z	; get_func_by_name
	add	esp, 8
	mov	DWORD PTR _load_lib$[ebp], eax
; Line 156
	cmp	DWORD PTR _load_lib$[ebp], 0
	jne	SHORT $LN3@main
; Line 157
	mov	eax, 2
	;jmp	SHORT $LN1@main
	; Line 183
	mov	esp, ebp
	pop	ebp
	ret	0
$LN3@main:
; Line 159
	call after_get_proc_addr_str
	 DB	'GetProcAddress', 00H
	 ORG $+1
after_get_proc_addr_str:	
	;push	OFFSET $SG89722
	mov	ecx, DWORD PTR _base$[ebp]
	push	ecx
	call	?get_func_by_name@@YAPAXPAXPAD@Z	; get_func_by_name
	add	esp, 8
	mov	DWORD PTR _get_proc$[ebp], eax
; Line 160
	cmp	DWORD PTR _get_proc$[ebp], 0
	jne	SHORT $LN4@main
; Line 161
	mov	eax, 3
	;jmp	SHORT $LN1@main
	; Line 183
	mov	esp, ebp
	pop	ebp
	ret	0
$LN4@main:
; Line 163
	mov	edx, DWORD PTR _load_lib$[ebp]
	mov	DWORD PTR __LoadLibraryA$[ebp], edx
; Line 164
	mov	eax, DWORD PTR _get_proc$[ebp]
	mov	DWORD PTR __GetProcAddress$[ebp], eax
; Line 166
	call after_user32_str
	DB	'user32.dll', 00H
	ORG $+1
after_user32_str:
	;push	OFFSET $SG89724
	call	DWORD PTR __LoadLibraryA$[ebp]
	mov	DWORD PTR _u32_dll$[ebp], eax
; Line 172
	call after_MessageBoxW_str
	$SG89725 DB	'MessageBoxW', 00H
after_MessageBoxW_str:
	;push	OFFSET $SG89725
	mov	ecx, DWORD PTR _u32_dll$[ebp]
	push	ecx
	call	DWORD PTR __GetProcAddress$[ebp]
	mov	DWORD PTR __MessageBoxW$[ebp], eax
; Line 178
	cmp	DWORD PTR __MessageBoxW$[ebp], 0
	jne	SHORT $LN5@main
	mov	eax, 4
	jmp	SHORT $LN1@main
$LN5@main:
; Line 180
	push	0
	;push	OFFSET $SG89727
	;push	OFFSET $SG89728
call after_ok_str
	$SG89727 DB	'O', 00H, 'K', 00H, 00H, 00H
	ORG $+2
after_ok_str:
	call after_msg_str
$SG89728 DB	'L', 00H, 'o', 00H, 'a', 00H, 'd', 00H, 'e', 00H, 'd', 00H
	DB	'!', 00H, 00H, 00H
after_msg_str:
	push	0
	call	DWORD PTR __MessageBoxW$[ebp]
; Line 182
	xor eax, eax
$LN1@main:
; Line 183
	mov	esp, ebp
	pop	ebp
	ret	0
_main	ENDP
_TEXT	ENDS
; Function compile flags: /Odtp
;	COMDAT ?get_func_by_name@@YAPAXPAXPAD@Z
_TEXT	SEGMENT
_funcRVA$1 = -60					; size = 4
_nameRVA$2 = -56					; size = 4
_nameIndex$3 = -52					; size = 4
_funcsListRVA$ = -48					; size = 4
_namesOrdsListRVA$ = -44				; size = 4
_funcNamesListRVA$ = -40				; size = 4
_namesCount$ = -36					; size = 4
_expAddr$ = -32						; size = 4
_nt_headers$ = -28					; size = 4
_exportsDir$ = -24					; size = 4
_idh$ = -20						; size = 4
_curr_name$4 = -16					; size = 4
_exp$ = -12						; size = 4
_i$5 = -8						; size = 4
_k$6 = -4						; size = 4
_module$ = 8						; size = 4
_func_name$ = 12					; size = 4
?get_func_by_name@@YAPAXPAXPAD@Z PROC			; get_func_by_name, COMDAT
; File C:\Users\IEUser\Source\Repos\Project1\Project1\shellcode_task_step1.cpp
; Line 110
	push	ebp
	mov	ebp, esp
	sub	esp, 60					; 0000003cH
; Line 111
	mov	eax, DWORD PTR _module$[ebp]
	mov	DWORD PTR _idh$[ebp], eax
; Line 112
	mov	ecx, DWORD PTR _idh$[ebp]
	movzx	edx, WORD PTR [ecx]
	cmp	edx, 23117				; 00005a4dH
	je	SHORT $LN8@get_func_b
; Line 113
	xor	eax, eax
	jmp	$LN1@get_func_b
$LN8@get_func_b:
; Line 115
	mov	eax, DWORD PTR _idh$[ebp]
	mov	ecx, DWORD PTR _module$[ebp]
	add	ecx, DWORD PTR [eax+60]
	mov	DWORD PTR _nt_headers$[ebp], ecx
; Line 116
	mov	edx, 8
	imul	eax, edx, 0
	mov	ecx, DWORD PTR _nt_headers$[ebp]
	lea	edx, DWORD PTR [ecx+eax+120]
	mov	DWORD PTR _exportsDir$[ebp], edx
; Line 117
	mov	eax, DWORD PTR _exportsDir$[ebp]
	cmp	DWORD PTR [eax], 0
	jne	SHORT $LN9@get_func_b
; Line 118
	xor	eax, eax
	jmp	$LN1@get_func_b
$LN9@get_func_b:
; Line 121
	mov	ecx, DWORD PTR _exportsDir$[ebp]
	mov	edx, DWORD PTR [ecx]
	mov	DWORD PTR _expAddr$[ebp], edx
; Line 122
	mov	eax, DWORD PTR _expAddr$[ebp]
	add	eax, DWORD PTR _module$[ebp]
	mov	DWORD PTR _exp$[ebp], eax
; Line 123
	mov	ecx, DWORD PTR _exp$[ebp]
	mov	edx, DWORD PTR [ecx+24]
	mov	DWORD PTR _namesCount$[ebp], edx
; Line 125
	mov	eax, DWORD PTR _exp$[ebp]
	mov	ecx, DWORD PTR [eax+28]
	mov	DWORD PTR _funcsListRVA$[ebp], ecx
; Line 126
	mov	edx, DWORD PTR _exp$[ebp]
	mov	eax, DWORD PTR [edx+32]
	mov	DWORD PTR _funcNamesListRVA$[ebp], eax
; Line 127
	mov	ecx, DWORD PTR _exp$[ebp]
	mov	edx, DWORD PTR [ecx+36]
	mov	DWORD PTR _namesOrdsListRVA$[ebp], edx
; Line 130
	mov	DWORD PTR _i$5[ebp], 0
	jmp	SHORT $LN4@get_func_b
$LN2@get_func_b:
	mov	eax, DWORD PTR _i$5[ebp]
	add	eax, 1
	mov	DWORD PTR _i$5[ebp], eax
$LN4@get_func_b:
	mov	ecx, DWORD PTR _i$5[ebp]
	cmp	ecx, DWORD PTR _namesCount$[ebp]
	jae	$LN3@get_func_b
; Line 131
	mov	edx, DWORD PTR _module$[ebp]
	add	edx, DWORD PTR _funcNamesListRVA$[ebp]
	mov	eax, DWORD PTR _i$5[ebp]
	lea	ecx, DWORD PTR [edx+eax*4]
	mov	DWORD PTR _nameRVA$2[ebp], ecx
; Line 132
	mov	edx, DWORD PTR _module$[ebp]
	add	edx, DWORD PTR _namesOrdsListRVA$[ebp]
	mov	eax, DWORD PTR _i$5[ebp]
	lea	ecx, DWORD PTR [edx+eax*2]
	mov	DWORD PTR _nameIndex$3[ebp], ecx
; Line 133
	mov	edx, DWORD PTR _module$[ebp]
	add	edx, DWORD PTR _funcsListRVA$[ebp]
	mov	eax, DWORD PTR _nameIndex$3[ebp]
	movzx	ecx, WORD PTR [eax]
	lea	edx, DWORD PTR [edx+ecx*4]
	mov	DWORD PTR _funcRVA$1[ebp], edx
; Line 135
	mov	eax, DWORD PTR _nameRVA$2[ebp]
	mov	ecx, DWORD PTR _module$[ebp]
	add	ecx, DWORD PTR [eax]
	mov	DWORD PTR _curr_name$4[ebp], ecx
; Line 136
	mov	DWORD PTR _k$6[ebp], 0
; Line 137
	mov	DWORD PTR _k$6[ebp], 0
	jmp	SHORT $LN7@get_func_b
$LN5@get_func_b:
	mov	edx, DWORD PTR _k$6[ebp]
	add	edx, 1
	mov	DWORD PTR _k$6[ebp], edx
$LN7@get_func_b:
	mov	eax, DWORD PTR _func_name$[ebp]
	add	eax, DWORD PTR _k$6[ebp]
	movsx	ecx, BYTE PTR [eax]
	test	ecx, ecx
	je	SHORT $LN6@get_func_b
	mov	edx, DWORD PTR _curr_name$4[ebp]
	add	edx, DWORD PTR _k$6[ebp]
	movsx	eax, BYTE PTR [edx]
	test	eax, eax
	je	SHORT $LN6@get_func_b
; Line 138
	mov	ecx, DWORD PTR _func_name$[ebp]
	add	ecx, DWORD PTR _k$6[ebp]
	movsx	edx, BYTE PTR [ecx]
	mov	eax, DWORD PTR _curr_name$4[ebp]
	add	eax, DWORD PTR _k$6[ebp]
	movsx	ecx, BYTE PTR [eax]
	cmp	edx, ecx
	je	SHORT $LN10@get_func_b
	jmp	SHORT $LN6@get_func_b
$LN10@get_func_b:
; Line 139
	jmp	SHORT $LN5@get_func_b
$LN6@get_func_b:
; Line 140
	mov	edx, DWORD PTR _func_name$[ebp]
	add	edx, DWORD PTR _k$6[ebp]
	movsx	eax, BYTE PTR [edx]
	test	eax, eax
	jne	SHORT $LN11@get_func_b
	mov	ecx, DWORD PTR _curr_name$4[ebp]
	add	ecx, DWORD PTR _k$6[ebp]
	movsx	edx, BYTE PTR [ecx]
	test	edx, edx
	jne	SHORT $LN11@get_func_b
; Line 142
	mov	eax, DWORD PTR _funcRVA$1[ebp]
	mov	ecx, DWORD PTR _module$[ebp]
	add	ecx, DWORD PTR [eax]
	mov	eax, ecx
	jmp	SHORT $LN1@get_func_b
$LN11@get_func_b:
; Line 144
	jmp	$LN2@get_func_b
$LN3@get_func_b:
; Line 145
	xor	eax, eax
$LN1@get_func_b:
; Line 146
	mov	esp, ebp
	pop	ebp
	ret	0
?get_func_by_name@@YAPAXPAXPAD@Z ENDP			; get_func_by_name
_TEXT	ENDS
; Function compile flags: /Odtp
;	COMDAT ?get_module_by_name@@YAPAXPA_W@Z
_TEXT	SEGMENT
_list$ = -52						; size = 8
_Flink$ = -44						; size = 4
_ldr$ = -40						; size = 4
tv151 = -36						; size = 4
tv132 = -32						; size = 4
_peb$ = -28						; size = 4
_curr_module$ = -24					; size = 4
_curr_name$1 = -20					; size = 4
_i$2 = -16						; size = 4
_c2$3 = -12						; size = 2
_c1$4 = -8						; size = 2
tv155 = -4						; size = 2
tv136 = -2						; size = 2
_module_name$ = 8					; size = 4
?get_module_by_name@@YAPAXPA_W@Z PROC			; get_module_by_name, COMDAT
; File C:\Users\IEUser\Source\Repos\Project1\Project1\shellcode_task_step1.cpp
; Line 75
	push	ebp
	mov	ebp, esp
	sub	esp, 52					; 00000034H
; Line 76
	mov	DWORD PTR _peb$[ebp], 0
; Line 80
	mov	eax, DWORD PTR fs:48
	mov	DWORD PTR _peb$[ebp], eax
; Line 82
	mov	ecx, DWORD PTR _peb$[ebp]
	mov	edx, DWORD PTR [ecx+12]
	mov	DWORD PTR _ldr$[ebp], edx
; Line 83
	mov	eax, DWORD PTR _ldr$[ebp]
	mov	ecx, DWORD PTR [eax+12]
	mov	edx, DWORD PTR [eax+16]
	mov	DWORD PTR _list$[ebp], ecx
	mov	DWORD PTR _list$[ebp+4], edx
; Line 85
	mov	eax, DWORD PTR _list$[ebp]
	mov	DWORD PTR _Flink$[ebp], eax
; Line 86
	mov	ecx, DWORD PTR _Flink$[ebp]
	mov	DWORD PTR _curr_module$[ebp], ecx
$LN2@get_module:
; Line 88
	cmp	DWORD PTR _curr_module$[ebp], 0
	je	$LN3@get_module
	mov	edx, DWORD PTR _curr_module$[ebp]
	cmp	DWORD PTR [edx+24], 0
	je	$LN3@get_module
; Line 89
	mov	eax, DWORD PTR _curr_module$[ebp]
	cmp	DWORD PTR [eax+48], 0
	jne	SHORT $LN7@get_module
	jmp	SHORT $LN2@get_module
$LN7@get_module:
; Line 90
	mov	ecx, DWORD PTR _curr_module$[ebp]
	mov	edx, DWORD PTR [ecx+48]
	mov	DWORD PTR _curr_name$1[ebp], edx
; Line 92
	mov	DWORD PTR _i$2[ebp], 0
; Line 93
	mov	DWORD PTR _i$2[ebp], 0
	jmp	SHORT $LN6@get_module
$LN4@get_module:
	mov	eax, DWORD PTR _i$2[ebp]
	add	eax, 1
	mov	DWORD PTR _i$2[ebp], eax
$LN6@get_module:
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	test	eax, eax
	je	$LN5@get_module
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _curr_name$1[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	test	eax, eax
	je	$LN5@get_module
; Line 95
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	cmp	eax, 90					; 0000005aH
	jg	SHORT $LN11@get_module
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	cmp	eax, 65					; 00000041H
	jl	SHORT $LN11@get_module
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	add	eax, 32					; 00000020H
	mov	DWORD PTR tv132[ebp], eax
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	mov	ax, WORD PTR tv132[ebp]
	mov	WORD PTR [edx+ecx*2], ax
	mov	cx, WORD PTR tv132[ebp]
	mov	WORD PTR tv136[ebp], cx
	jmp	SHORT $LN12@get_module
$LN11@get_module:
	mov	edx, DWORD PTR _i$2[ebp]
	mov	eax, DWORD PTR _module_name$[ebp]
	mov	cx, WORD PTR [eax+edx*2]
	mov	WORD PTR tv136[ebp], cx
$LN12@get_module:
	mov	dx, WORD PTR tv136[ebp]
	mov	WORD PTR _c1$4[ebp], dx
; Line 96
	mov	eax, DWORD PTR _i$2[ebp]
	mov	ecx, DWORD PTR _curr_name$1[ebp]
	movzx	edx, WORD PTR [ecx+eax*2]
	cmp	edx, 90					; 0000005aH
	jg	SHORT $LN13@get_module
	mov	eax, DWORD PTR _i$2[ebp]
	mov	ecx, DWORD PTR _curr_name$1[ebp]
	movzx	edx, WORD PTR [ecx+eax*2]
	cmp	edx, 65					; 00000041H
	jl	SHORT $LN13@get_module
	mov	eax, DWORD PTR _i$2[ebp]
	mov	ecx, DWORD PTR _curr_name$1[ebp]
	movzx	edx, WORD PTR [ecx+eax*2]
	add	edx, 32					; 00000020H
	mov	DWORD PTR tv151[ebp], edx
	mov	eax, DWORD PTR _i$2[ebp]
	mov	ecx, DWORD PTR _curr_name$1[ebp]
	mov	dx, WORD PTR tv151[ebp]
	mov	WORD PTR [ecx+eax*2], dx
	mov	ax, WORD PTR tv151[ebp]
	mov	WORD PTR tv155[ebp], ax
	jmp	SHORT $LN14@get_module
$LN13@get_module:
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _curr_name$1[ebp]
	mov	ax, WORD PTR [edx+ecx*2]
	mov	WORD PTR tv155[ebp], ax
$LN14@get_module:
	mov	cx, WORD PTR tv155[ebp]
	mov	WORD PTR _c2$3[ebp], cx
; Line 97
	movzx	edx, WORD PTR _c1$4[ebp]
	movzx	eax, WORD PTR _c2$3[ebp]
	cmp	edx, eax
	je	SHORT $LN8@get_module
	jmp	SHORT $LN5@get_module
$LN8@get_module:
; Line 98
	jmp	$LN4@get_module
$LN5@get_module:
; Line 99
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _module_name$[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	test	eax, eax
	jne	SHORT $LN9@get_module
	mov	ecx, DWORD PTR _i$2[ebp]
	mov	edx, DWORD PTR _curr_name$1[ebp]
	movzx	eax, WORD PTR [edx+ecx*2]
	test	eax, eax
	jne	SHORT $LN9@get_module
; Line 101
	mov	ecx, DWORD PTR _curr_module$[ebp]
	mov	eax, DWORD PTR [ecx+24]
	jmp	SHORT $LN1@get_module
$LN9@get_module:
; Line 104
	mov	edx, DWORD PTR _curr_module$[ebp]
	mov	eax, DWORD PTR [edx]
	mov	DWORD PTR _curr_module$[ebp], eax
; Line 105
	jmp	$LN2@get_module
$LN3@get_module:
; Line 106
	xor	eax, eax
$LN1@get_module:
; Line 107
	mov	esp, ebp
	pop	ebp
	ret	0
?get_module_by_name@@YAPAXPA_W@Z ENDP			; get_module_by_name
_TEXT	ENDS
END
