Function at 0x401680
Capabilities:
Check if file exists
Delete file
Extract resource via kernel32 functions
Get file size
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
sub esp, 0x27c
mov eax, dword [0x420004]
xor eax, esp
mov dword [esp + 0x278], eax
mov eax, dword [ebp + 8]
push ebx
push esi
xor esi, esi
mov byte [0x421620], 0
xor ebx, ebx
mov dword [esp + 0xc], 0
push edi
mov edi, dword [ebp + 0xc]
cmp eax, 1
jne 0x40177a
push ebx
push 0x65
push 0x41de5c
push ebx
call dword [sym.imp.KERNEL32.dll_FindResourceExW]
mov esi, eax
test esi, esi
je 0x40173d
push esi
push ebx
call dword [sym.imp.KERNEL32.dll_LoadResource]
push eax
call dword [sym.imp.KERNEL32.dll_LockResource]
mov edi, eax
test edi, edi
je 0x40173d
push esi
push ebx
call dword [sym.imp.KERNEL32.dll_SizeofResource]
lea ecx, [esp + 0x14]
mov dword [esp + 0x2c], str.Md7a5_K
push ecx
lea ecx, [esp + 0x2c]
mov dword [esp + 0x34], 0x10
push ecx
push eax
push edi
lea ecx, [esp + 0x3c]
mov dword [esp + 0x38], ebx
mov dword [esp + 0x24], ebx
call fcn.00401250
test eax, eax
jne 0x40173d
mov edi, dword [esp + 0x28]
cmp dword [edi], 0x15f961c
je 0x401746
push edi
push eax
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
xor esi, esi
xor edi, edi
jmp 0x401870
push ecx
mov ecx, edi
call fcn.00402050
add esp, 4
mov esi, eax
push edi
push 0
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
mov eax, esi
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x278]
xor ecx, esp
call fcn.0040296b
mov esp, ebp
pop ebp
ret
cmp eax, 5
jl 0x40173f
push dword [edi + 4]
push str._path
call fcn.00406644
add esp, 8
test eax, eax
jne 0x4017ab
push dword [edi + 8]
call dword [sym.imp.SHLWAPI.dll_PathFileExistsW]
test eax, eax
je 0x401857
mov eax, dword [edi + 8]
mov dword [esp + 0x10], eax
push dword [edi + 0xc]
push str._run
call fcn.00406644
add esp, 8
test eax, eax
jne 0x40185e
mov esi, dword [edi + 0x10]
lea ecx, [esi + 2]
nop dword [eax]
mov ax, word [esi]
add esi, 2
test ax, ax
jne 0x4017d0
mov ebx, dword [sym.imp.KERNEL32.dll_GetProcessHeap]
sub esi, ecx
sar esi, 1
lea eax, [esi*2 + 2]
push eax
push 8
call ebx
push eax
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
push dword [edi + 0x10]
lea ecx, [esi + 1]
mov dword [esp + 0x18], eax
push ecx
mov esi, eax
push esi
call fcn.004084bd
add esp, 0xc
push esi
call dword [sym.imp.SHLWAPI.dll_PathStripPathW]
push 0xfffe
push 8
call ebx
push eax
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
push esi
push dword [esp + 0x14]
mov ebx, eax
push str._ws_ws
push 0x7fff
push ebx
call fcn.00401600
add esp, 0x14
push ebx
call dword [sym.imp.SHLWAPI.dll_PathFileExistsW]
test eax, eax
mov edi, str.The_Run_file_was_not_found.
mov eax, 0
cmovne edi, eax
jmp 0x401860
mov edi, str.The_system_cannot_find_the_path_specified.
jmp 0x401870
xor edi, edi
cmp dword [esp + 0x10], 0
je 0x401870
mov byte [esp + 0xf], 0
test esi, esi
jne 0x401875
mov byte [esp + 0xf], 1
push str._r_nsdf_v2.0___Create_and_run_a_Single_Deployment_File_r_n
call fcn.00401480
add esp, 4
push str.Copyright__C__2020_ForensiT_Limited_r_n
call fcn.00401480
add esp, 4
push str.ForensiT___www.ForensiT.com_r_n_r_n
call fcn.00401480
add esp, 4
test edi, edi
je 0x4018cd
push edi
call fcn.00401480
add esp, 4
push str._r_n_r_n
call fcn.00401480
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x278]
xor ecx, esp
call fcn.0040296b
mov esp, ebp
pop ebp
ret
cmp byte [esp + 0xf], 0
je 0x40191f
push str.Usage:_sdf__path_folderpath___run_scriptname_r_n_r_n
call fcn.00401480
add esp, 4
push str._path_tThe_path_to_the_folder_with_the_files_you_want_to_include_in_your_.exe_file_r_n
call fcn.00401480
add esp, 4
push str._run_tThe_name_of_the_script_to_run_r_n
call fcn.00401480
add esp, 4
push 0x41de34
call fcn.00401480
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x278]
xor ecx, esp
call fcn.0040296b
mov esp, ebp
pop ebp
ret
push str..exe
push ebx
xor edi, edi
call dword [sym.imp.SHLWAPI.dll_PathRenameExtensionW]
push ebx
call dword [sym.imp.KERNEL32.dll_DeleteFileW]
mov ecx, dword [esp + 0x10]
lea eax, [esp + 0x18]
push eax
lea eax, [esp + 0x2c]
mov dword [esp + 0x2c], edi
push eax
mov edx, esi
mov dword [esp + 0x20], edi
call fcn.00401be0
mov eax, dword [esp + 0x30]
add esp, 8
test eax, eax
je 0x401ba3
lea ecx, [esp + 0x20]
mov dword [esp + 0x14], edi
push ecx
lea ecx, [esp + 0x18]
mov dword [esp + 0x24], edi
push ecx
push dword [esp + 0x20]
lea ecx, [esp + 0x38]
mov dword [esp + 0x38], str.Md7a5_K
push eax
mov dword [esp + 0x40], 0x10
call section..text
push 0x104
lea eax, [esp + 0x7c]
push eax
push edi
call dword [sym.imp.KERNEL32.dll_GetModuleFileNameW]
push edi
push edi
push 3
push edi
push 1
push 0x80000000
lea eax, [esp + 0x90]
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov dword [esp + 0x10], eax
cmp eax, 0xffffffff
je 0x401a7c
push edi
push eax
call dword [sym.imp.KERNEL32.dll_GetFileSize]
push eax
push 8
mov dword [esp + 0x20], eax
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
mov esi, eax
mov dword [esp + 0x34], edi
push edi
lea eax, [esp + 0x38]
mov dword [esp + 0x20], esi
push eax
push dword [esp + 0x20]
push esi
push dword [esp + 0x20]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x401a4e
push edi
push edi
push 2
push edi
push edi
push 0x10000000
push ebx
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov dword [esp + 0x24], eax
cmp eax, 0xffffffff
je 0x401a4e
push edi
lea ecx, [esp + 0x30]
push ecx
push dword [esp + 0x20]
push esi
push eax
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov esi, dword [sym.imp.KERNEL32.dll_GetLastError]
test eax, eax
jne 0x401a42
call esi
mov edi, eax
push dword [esp + 0x24]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
jmp 0x401a58
mov esi, dword [sym.imp.KERNEL32.dll_GetLastError]
call esi
mov edi, eax
mov eax, dword [esp + 0x1c]
test eax, eax
je 0x401a70
push eax
push 0
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
push dword [esp + 0x10]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
jmp 0x401a86
mov esi, dword [sym.imp.KERNEL32.dll_GetLastError]
call esi
mov edi, eax
test edi, edi
jne 0x401acd
push edi
push ebx
call dword [sym.imp.KERNEL32.dll_BeginUpdateResourceW]
mov dword [esp + 0x1c], eax
test eax, eax
je 0x401ac9
push dword [esp + 0x20]
push dword [esp + 0x18]
push edi
push 0x65
push 0x41de5c
push eax
call dword [sym.imp.KERNEL32.dll_UpdateResourceW]
test eax, eax
jne 0x401ab9
call esi
mov edi, eax
push 0
push dword [esp + 0x20]
call dword [sym.imp.KERNEL32.dll_EndUpdateResourceW]
test eax, eax
jne 0x401acd
call esi
mov edi, eax
push dword [esp + 0x28]
push 0
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
test edi, edi
je 0x401ba3
push 0
push 0
lea eax, [esp + 0x30]
mov dword [esp + 0x30], 0
push eax
push 0x400
push edi
push 0
push 0x1300
call dword [sym.imp.KERNEL32.dll_FormatMessageW]
mov edx, dword [esp + 0x28]
test edx, edx
je 0x401b3c
mov ecx, edx
lea esi, [ecx + 2]
nop dword [eax]
mov ax, word [ecx]
add ecx, 2
test ax, ax
jne 0x401b20
sub ecx, esi
sar ecx, 1
xor eax, eax
mov word [edx + ecx*2 - 4], ax
mov esi, dword [esp + 0x28]
jmp 0x401b8c
push 0xa
push 0x20
lea eax, [esp + 0x40]
push eax
push edi
call fcn.0040686a
lea esi, [esp + 0x48]
add esp, 0x10
lea ecx, [esi + 2]
mov ax, word [esi]
add esi, 2
test ax, ax
jne 0x401b55
sub esi, ecx
sar esi, 1
lea esi, [esi*2 + 0x10]
push esi
push 0x40
call dword [sym.imp.KERNEL32.dll_LocalAlloc]
push edi
push str.Error__u.
push esi
push eax
mov dword [esp + 0x2c], eax
call fcn.00401600
mov esi, dword [esp + 0x2c]
add esp, 0x10
push esi
push str._ws_r_n
call fcn.00401480
add esp, 8
push esi
call dword [sym.imp.KERNEL32.dll_LocalFree]
jmp 0x401bb8
push ebx
call dword [sym.imp.SHLWAPI.dll_PathStripPathW]
push ebx
push str.Created__ws_r_n_r_n
call fcn.00401480
add esp, 8
push ebx
push 0
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
mov ecx, dword [esp + 0x284]
mov eax, edi
pop edi
pop esi
pop ebx
xor ecx, esp
call fcn.0040296b
mov esp, ebp
pop ebp
ret