Function at 0x406800
Capabilities:
Write file on windows

Disassembly:
sub esp, 0x48
push esi
mov esi, ecx
mov dword [esp + 4], 0
mov eax, dword [esi + 0x14]
cmp eax, 0xffffffff
jne 0x406822
mov eax, 0x80
pop esi
add esp, 0x48
ret 0x14
push ebx
push ebp
lea eax, [esi + 0x2dc]
push edi
push eax
mov dword [esp + 0x18], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [esi + 4]
push eax
call dword [sym.imp.KERNEL32.dll_ResetEvent]
mov edi, dword [sym.imp.KERNEL32.dll_InterlockedExchange]
lea ebp, [esi + 0x2d0]
push 0
push ebp
call edi
mov ebx, dword [esp + 0x5c]
lea edx, [esi + 0x2cc]
mov ecx, ebx
and ecx, 0xff
push ecx
push edx
call edi
mov ax, word [esp + 0x60]
xor ecx, ecx
mov cl, ah
mov byte [esp + 0x1b], al
mov ax, word [esp + 0x64]
xor edx, edx
mov dl, ah
mov byte [esp + 0x1d], al
push 0
push 0
lea eax, [esp + 0x20]
mov byte [esp + 0x22], cl
push 6
push eax
mov ecx, esi
mov byte [esp + 0x28], bl
mov byte [esp + 0x29], 3
mov byte [esp + 0x2c], dl
call fcn.00406780
xor ecx, ecx
mov byte [esp + 0x1f], al
mov cl, ah
mov eax, dword [esp + 0x18]
lea edx, [esi + 0x1cc]
mov dword [esi + 0x2d4], 8
mov byte [esp + 0x1e], cl
mov ecx, dword [esp + 0x1c]
mov dword [edx], eax
mov dword [edx + 4], ecx
mov edi, dword [esi + 0x2d4]
mov eax, dword [esi + 0x14]
cmp eax, 0xffffffff
je 0x40695a
lea edx, [esp + 0x64]
push 0
push edx
mov eax, dword [esi + 0x14]
push eax
call dword [sym.imp.KERNEL32.dll_ClearCommError]
test eax, eax
je 0x406904
mov eax, dword [esp + 0x64]
test eax, eax
jbe 0x406904
push 5
mov ecx, dword [esi + 0x14]
push ecx
call dword [sym.imp.KERNEL32.dll_PurgeComm]
lea eax, [esi + 0x74]
lea edx, [esp + 0x60]
push eax
push edx
lea eax, [esp + 0x20]
push edi
mov dword [esp + 0x6c], 0
push eax
mov ecx, dword [esi + 0x14]
push ecx
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
jne 0x40695a
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x3e5
je 0x40695a
mov edx, dword [esi + 0x84]
push 0x14
push edx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
lea eax, [esp + 0x60]
push 0
push eax
lea eax, [esi + 0x74]
push eax
mov ecx, dword [esi + 0x14]
push ecx
call dword [sym.imp.KERNEL32.dll_GetOverlappedResult]
mov edx, dword [esi + 0xc8]
mov eax, dword [esi + 4]
push edx
push eax
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
test eax, eax
jne 0x4069eb
mov cx, word [ebp]
lea edi, [esi + 0xcc]
push ecx
push edi
push ebx
mov ecx, esi
call fcn.00406ec0
test eax, eax
je 0x4069e1
cmp byte [edi], bl
jne 0x4069e1
mov al, byte [edi + 1]
mov dl, al
and dl, 0x7f
cmp dl, 3
jne 0x4069e1
test al, 0x80
je 0x4069a7
xor eax, eax
mov al, byte [edi + 2]
mov dword [esp + 0x10], eax
jmp 0x4069f3
mov ebp, dword [esp + 0x68]
test ebp, ebp
je 0x4069f3
mov edx, dword [esp + 0x6c]
test edx, edx
je 0x4069f3
xor eax, eax
xor ecx, ecx
mov ax, word [edx]
mov cl, byte [edi + 2]
cmp eax, ecx
jle 0x4069c7
mov eax, ecx
mov ecx, eax
lea esi, [edi + 3]
mov ebx, ecx
mov edi, ebp
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, ebx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov word [edx], ax
jmp 0x4069f3
mov dword [esp + 0x10], 0x81
jmp 0x4069f3
mov dword [esp + 0x10], 0x82
mov ecx, dword [esp + 0x14]
push ecx
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0x10]
pop edi
pop ebp
pop ebx
pop esi
add esp, 0x48
ret 0x14