Function at 0x40d597
Capabilities:
Write file on windows

Disassembly:
push ebp
lea ebp, [esp - 0x514]
sub esp, 0x590
mov eax, dword [0x422010]
xor eax, ebp
mov dword [ebp + 0x510], eax
mov eax, dword [ebp + 0x520]
push esi
xor esi, esi
cmp dword [ebp + 0x524], esi
mov dword [ebp - 0x64], eax
mov dword [ebp - 0x60], esi
mov dword [ebp - 0x68], esi
jne 0x40d5d3
xor eax, eax
jmp 0x40dba3
cmp eax, esi
jne 0x40d5fe
call fcn.00406b7d
mov dword [eax], esi
call fcn.00406b6a
push esi
push esi
push esi
push esi
push esi
mov dword [eax], 0x16
call fcn.004091ca
add esp, 0x14
or eax, 0xffffffff
jmp 0x40dba3
push ebx
push edi
mov edi, dword [ebp + 0x51c]
mov eax, edi
sar eax, 5
lea esi, [eax*4 + 0x429280]
mov eax, dword [esi]
and edi, 0x1f
shl edi, 6
add eax, edi
mov bl, byte [eax + 0x24]
add bl, bl
sar bl, 1
cmp bl, 2
mov dword [ebp - 0x70], esi
mov byte [ebp - 0x71], bl
je 0x40d633
cmp bl, 1
jne 0x40d666
mov ecx, dword [ebp + 0x524]
not ecx
test cl, 1
jne 0x40d666
call fcn.00406b7d
xor esi, esi
mov dword [eax], esi
call fcn.00406b6a
push esi
push esi
push esi
push esi
push esi
mov dword [eax], 0x16
call fcn.004091ca
add esp, 0x14
jmp 0x40db96
test byte [eax + 4], 0x20
je 0x40d680
push 2
push 0
push 0
push dword [ebp + 0x51c]
call fcn.0040d3fb
add esp, 0x10
push dword [ebp + 0x51c]
call fcn.0040d1f6
test eax, eax
pop ecx
je 0x40d8cd
mov eax, dword [esi]
test byte [edi + eax + 4], 0x80
je 0x40d8cd
call fcn.00406472
mov eax, dword [eax + 0x6c]
xor ecx, ecx
cmp dword [eax + 0x14], ecx
lea eax, [ebp - 0x7c]
sete cl
push eax
mov eax, dword [esi]
push dword [edi + eax]
mov dword [ebp - 0x78], ecx
call dword [sym.imp.KERNEL32.dll_GetConsoleMode]
test eax, eax
je 0x40d8cd
xor ecx, ecx
cmp dword [ebp - 0x78], ecx
je 0x40d6da
test bl, bl
je 0x40d8cf
call dword [sym.imp.KERNEL32.dll_GetConsoleCP]
mov ebx, dword [ebp - 0x64]
mov dword [ebp - 0x7c], eax
xor eax, eax
cmp dword [ebp + 0x524], eax
mov dword [ebp - 0x5c], eax
jbe 0x40db3e
mov dword [ebp - 0x54], eax
mov al, byte [ebp - 0x71]
test al, al
jne 0x40d842
mov cl, byte [ebx]
mov esi, dword [ebp - 0x70]
xor eax, eax
cmp cl, 0xa
sete al
mov dword [ebp - 0x78], eax
mov eax, dword [esi]
add eax, edi
cmp dword [eax + 0x38], 0
je 0x40d73d
mov dl, byte [eax + 0x34]
mov byte [ebp + 0x508], dl
mov byte [ebp + 0x509], cl
and dword [eax + 0x38], 0
push 2
lea eax, [ebp + 0x508]
push eax
jmp 0x40d782
movsx eax, cl
push eax
call fcn.00406be4
test eax, eax
pop ecx
je 0x40d77f
mov ecx, dword [ebp - 0x64]
sub ecx, ebx
add ecx, dword [ebp + 0x524]
xor eax, eax
inc eax
cmp ecx, eax
jbe 0x40d8b7
push 2
lea eax, [ebp - 0x58]
push ebx
push eax
call fcn.0040dfca
add esp, 0xc
cmp eax, 0xffffffff
je 0x40db38
inc ebx
inc dword [ebp - 0x54]
jmp 0x40d797
push 1
push ebx
lea eax, [ebp - 0x58]
push eax
call fcn.0040dfca
add esp, 0xc
cmp eax, 0xffffffff
je 0x40db38
xor eax, eax
push eax
push eax
push 5
lea ecx, [ebp + 0x508]
push ecx
push 1
lea ecx, [ebp - 0x58]
push ecx
push eax
push dword [ebp - 0x7c]
inc ebx
inc dword [ebp - 0x54]
call dword [sym.imp.KERNEL32.dll_WideCharToMultiByte]
mov esi, eax
test esi, esi
je 0x40db38
push 0
lea eax, [ebp - 0x5c]
push eax
push esi
lea eax, [ebp + 0x508]
push eax
mov eax, dword [ebp - 0x70]
mov eax, dword [eax]
push dword [edi + eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40db2f
mov eax, dword [ebp - 0x54]
mov ecx, dword [ebp - 0x68]
add eax, ecx
cmp dword [ebp - 0x5c], esi
mov dword [ebp - 0x60], eax
jl 0x40db38
cmp dword [ebp - 0x78], 0
je 0x40d8a3
push 0
lea eax, [ebp - 0x5c]
push eax
push 1
lea eax, [ebp + 0x508]
push eax
mov eax, dword [ebp - 0x70]
mov eax, dword [eax]
mov byte [ebp + 0x508], 0xd
push dword [edi + eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40db2f
cmp dword [ebp - 0x5c], 1
jl 0x40db38
inc dword [ebp - 0x68]
inc dword [ebp - 0x60]
jmp 0x40d8a3
cmp al, 1
je 0x40d84a
cmp al, 2
jne 0x40d862
movzx esi, word [ebx]
xor ecx, ecx
cmp si, 0xa
sete cl
inc ebx
inc ebx
add dword [ebp - 0x54], 2
mov dword [ebp - 0x58], esi
mov dword [ebp - 0x78], ecx
cmp al, 1
je 0x40d86a
cmp al, 2
jne 0x40d8a3
push dword [ebp - 0x58]
call fcn.0040e364
cmp ax, word [ebp - 0x58]
pop ecx
jne 0x40db2f
inc dword [ebp - 0x60]
cmp dword [ebp - 0x78], 0
je 0x40d8a3
push 0xd
pop eax
push eax
mov dword [ebp - 0x58], eax
call fcn.0040e364
cmp ax, word [ebp - 0x58]
pop ecx
jne 0x40db2f
inc dword [ebp - 0x60]
inc dword [ebp - 0x68]
mov eax, dword [ebp + 0x524]
cmp dword [ebp - 0x54], eax
jb 0x40d6fa
jmp 0x40db38
mov ecx, dword [esi]
mov dl, byte [ebx]
inc dword [ebp - 0x60]
mov byte [edi + ecx + 0x34], dl
mov ecx, dword [esi]
mov dword [edi + ecx + 0x38], eax
jmp 0x40db38
xor ecx, ecx
mov eax, dword [esi]
add eax, edi
test byte [eax + 4], 0x80
je 0x40db08
test bl, bl
mov eax, dword [ebp - 0x64]
mov dword [ebp - 0x58], ecx
jne 0x40d981
cmp dword [ebp + 0x524], ecx
mov dword [ebp - 0x5c], eax
jbe 0x40db6e
jmp 0x40d8ff
mov esi, dword [ebp - 0x70]
mov ecx, dword [ebp - 0x5c]
and dword [ebp - 0x54], 0
sub ecx, dword [ebp - 0x64]
lea eax, [ebp - 0x50]
cmp ecx, dword [ebp + 0x524]
jae 0x40d93b
mov edx, dword [ebp - 0x5c]
inc dword [ebp - 0x5c]
mov dl, byte [edx]
inc ecx
cmp dl, 0xa
jne 0x40d92c
inc dword [ebp - 0x68]
mov byte [eax], 0xd
inc eax
inc dword [ebp - 0x54]
mov byte [eax], dl
inc eax
inc dword [ebp - 0x54]
cmp dword [ebp - 0x54], 0x400
jb 0x40d90c
mov ebx, eax
lea eax, [ebp - 0x50]
sub ebx, eax
push 0
lea eax, [ebp - 0x6c]
push eax
push ebx
lea eax, [ebp - 0x50]
push eax
mov eax, dword [esi]
push dword [edi + eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40db2f
mov eax, dword [ebp - 0x6c]
add dword [ebp - 0x60], eax
cmp eax, ebx
jl 0x40db38
mov eax, dword [ebp - 0x5c]
sub eax, dword [ebp - 0x64]
cmp eax, dword [ebp + 0x524]
jb 0x40d8fc
jmp 0x40db38
cmp bl, 2
mov dword [ebp - 0x54], eax
jne 0x40da30
cmp dword [ebp + 0x524], ecx
jbe 0x40db6e
jmp 0x40d99e
mov esi, dword [ebp - 0x70]
mov ecx, dword [ebp - 0x54]
and dword [ebp - 0x5c], 0
sub ecx, dword [ebp - 0x64]
lea eax, [ebp - 0x50]
cmp ecx, dword [ebp + 0x524]
jae 0x40d9e6
mov edx, dword [ebp - 0x54]
add dword [ebp - 0x54], 2
movzx edx, word [edx]
inc ecx
inc ecx
cmp dx, 0xa
jne 0x40d9d4
add dword [ebp - 0x68], 2
mov word [eax], 0xd
inc eax
inc eax
add dword [ebp - 0x5c], 2
add dword [ebp - 0x5c], 2
mov word [eax], dx
inc eax
inc eax
cmp dword [ebp - 0x5c], 0x3ff
jb 0x40d9ab
mov ebx, eax
lea eax, [ebp - 0x50]
sub ebx, eax
push 0
lea eax, [ebp - 0x6c]
push eax
push ebx
lea eax, [ebp - 0x50]
push eax
mov eax, dword [esi]
push dword [edi + eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40db2f
mov eax, dword [ebp - 0x6c]
add dword [ebp - 0x60], eax
cmp eax, ebx
jl 0x40db38
mov eax, dword [ebp - 0x54]
sub eax, dword [ebp - 0x64]
cmp eax, dword [ebp + 0x524]
jb 0x40d99b
jmp 0x40db38
cmp dword [ebp + 0x524], ecx
jbe 0x40db6e
mov ecx, dword [ebp - 0x54]
and dword [ebp - 0x5c], 0
sub ecx, dword [ebp - 0x64]
push 2
lea eax, [ebp + 0x3b4]
pop esi
cmp ecx, dword [ebp + 0x524]
jae 0x40da83
mov edx, dword [ebp - 0x54]
movzx edx, word [edx]
add dword [ebp - 0x54], esi
add ecx, esi
cmp dx, 0xa
jne 0x40da72
mov word [eax], 0xd
add eax, esi
add dword [ebp - 0x5c], esi
add dword [ebp - 0x5c], esi
mov word [eax], dx
add eax, esi
cmp dword [ebp - 0x5c], 0x152
jb 0x40da4f
xor esi, esi
push esi
push esi
push 0x2ab
lea ecx, [ebp + 0x104]
push ecx
lea ecx, [ebp + 0x3b4]
sub eax, ecx
cdq
sub eax, edx
sar eax, 1
push eax
mov eax, ecx
push eax
push esi
push 0xfde9
call dword [sym.imp.KERNEL32.dll_WideCharToMultiByte]
mov ebx, eax
cmp ebx, esi
je 0x40db2f
push 0
lea eax, [ebp - 0x6c]
push eax
mov eax, ebx
sub eax, esi
push eax
lea eax, [ebp + esi + 0x104]
push eax
mov eax, dword [ebp - 0x70]
mov eax, dword [eax]
push dword [edi + eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40dae4
add esi, dword [ebp - 0x6c]
cmp ebx, esi
jg 0x40dab6
jmp 0x40daed
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [ebp - 0x58], eax
cmp ebx, esi
jg 0x40db38
mov eax, dword [ebp - 0x54]
sub eax, dword [ebp - 0x64]
cmp eax, dword [ebp + 0x524]
mov dword [ebp - 0x60], eax
jb 0x40da3c
jmp 0x40db38
push 0
lea ecx, [ebp - 0x6c]
push ecx
push dword [ebp + 0x524]
push dword [ebp - 0x64]
push dword [eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x40db2f
mov eax, dword [ebp - 0x6c]
and dword [ebp - 0x58], 0
mov dword [ebp - 0x60], eax
jmp 0x40db38
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [ebp - 0x58], eax
cmp dword [ebp - 0x60], 0
jne 0x40db9b
cmp dword [ebp - 0x58], 0
je 0x40db6b
push 5
pop esi
cmp dword [ebp - 0x58], esi
jne 0x40db60
call fcn.00406b6a
mov dword [eax], 9
call fcn.00406b7d
mov dword [eax], esi
jmp 0x40db96
push dword [ebp - 0x58]
call fcn.00406b90
pop ecx
jmp 0x40db96
mov esi, dword [ebp - 0x70]
mov eax, dword [esi]
test byte [edi + eax + 4], 0x40
je 0x40db83
mov eax, dword [ebp - 0x64]
cmp byte [eax], 0x1a
jne 0x40db83
xor eax, eax
jmp 0x40dba1
call fcn.00406b6a
mov dword [eax], 0x1c
call fcn.00406b7d
and dword [eax], 0
or eax, 0xffffffff
jmp 0x40dba1
mov eax, dword [ebp - 0x60]
sub eax, dword [ebp - 0x68]
pop edi
pop ebx
mov ecx, dword [ebp + 0x510]
xor ecx, ebp
pop esi
call fcn.00404197
add ebp, 0x514
leave
ret