Function at 0x406c10
Capabilities:
Write file on windows

Disassembly:
sub esp, 0x48
push ebx
push ebp
mov ebp, ecx
push esi
mov dword [esp + 0xc], 0
mov eax, dword [ebp + 0x14]
cmp eax, 0xffffffff
jne 0x406c36
pop esi
pop ebp
mov eax, 0x80
pop ebx
add esp, 0x48
ret 0x18
mov ebx, dword [esp + 0x64]
mov esi, ebx
and esi, 0xffff
lea eax, [esi + esi + 9]
cmp eax, 0x40
mov dword [esp + 0x64], eax
jg 0x406eac
mov eax, dword [esp + 0x60]
test eax, eax
je 0x406eac
mov eax, dword [ebp + 4]
push edi
push eax
call dword [sym.imp.KERNEL32.dll_ResetEvent]
lea eax, [ebp + 0x2dc]
push eax
mov dword [esp + 0x18], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov edi, dword [sym.imp.KERNEL32.dll_InterlockedExchange]
lea eax, [ebp + 0x2d0]
push 0
push eax
call edi
mov ecx, dword [esp + 0x5c]
lea edx, [ebp + 0x2cc]
and ecx, 0xff
push ecx
push edx
call edi
mov al, byte [esp + 0x5c]
xor ecx, ecx
mov byte [esp + 0x18], al
mov ax, word [esp + 0x60]
xor edx, edx
mov byte [esp + 0x1d], bl
mov cl, ah
mov dl, bh
shl bl, 1
test esi, esi
mov byte [esp + 0x19], 0x10
mov byte [esp + 0x1a], cl
mov byte [esp + 0x1b], al
mov byte [esp + 0x1c], dl
mov byte [esp + 0x1e], bl
jbe 0x406cf4
mov eax, dword [esp + 0x64]
lea edi, [esp + 0x1f]
sub edi, eax
mov edx, esi
mov cx, word [eax]
xor ebx, ebx
mov bl, ch
add eax, 2
mov bh, cl
dec edx
mov word [edi + eax - 2], bx
jne 0x406ce0
push 0
lea eax, [esi + esi + 7]
push 0
lea ecx, [esp + 0x20]
push eax
push ecx
mov ecx, ebp
call fcn.00406780
mov ecx, dword [esp + 0x68]
xor edx, edx
mov dl, ah
mov dword [ebp + 0x2d4], ecx
mov byte [esp + esi*2 + 0x1f], dl
mov byte [esp + esi*2 + 0x20], al
mov eax, ecx
lea esi, [esp + 0x18]
lea edi, [ebp + 0x1cc]
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov edi, dword [ebp + 0x2d4]
mov eax, dword [ebp + 0x14]
mov ebx, dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
cmp eax, 0xffffffff
je 0x406dc3
lea ecx, [esp + 0x64]
push 0
push ecx
mov edx, dword [ebp + 0x14]
push edx
call dword [sym.imp.KERNEL32.dll_ClearCommError]
test eax, eax
je 0x406d74
mov eax, dword [esp + 0x64]
test eax, eax
jbe 0x406d74
push 5
mov eax, dword [ebp + 0x14]
push eax
call dword [sym.imp.KERNEL32.dll_PurgeComm]
lea esi, [ebp + 0x74]
lea ecx, [esp + 0x60]
push esi
push ecx
lea edx, [esp + 0x20]
push edi
mov dword [esp + 0x6c], 0
push edx
mov eax, dword [ebp + 0x14]
push eax
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
jne 0x406dc3
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x3e5
je 0x406dc3
mov ecx, dword [ebp + 0x84]
push 0x14
push ecx
call ebx
lea edx, [esp + 0x60]
push 0
push edx
push esi
mov eax, dword [ebp + 0x14]
push eax
call dword [sym.imp.KERNEL32.dll_GetOverlappedResult]
mov ecx, dword [ebp + 0xc8]
mov edx, dword [ebp + 4]
push ecx
push edx
call ebx
test eax, eax
pop edi
jne 0x406e8c
mov ax, word [ebp + 0x2d0]
mov ebx, dword [esp + 0x58]
lea esi, [ebp + 0xcc]
push eax
push esi
push ebx
mov ecx, ebp
call fcn.00406ec0
test eax, eax
je 0x406e6c
cmp byte [esi], bl
jne 0x406e6c
mov al, byte [esi + 1]
mov cl, al
and cl, 0x7f
cmp cl, 0x10
jne 0x406e6c
test al, 0x80
je 0x406e2e
mov eax, dword [esp + 0x10]
xor edx, edx
mov dl, byte [esi + 2]
push eax
mov dword [esp + 0x10], edx
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0xc]
pop esi
pop ebp
pop ebx
add esp, 0x48
ret 0x18
mov eax, dword [esp + 0x68]
test eax, eax
je 0x406e41
xor ecx, ecx
mov ch, byte [esi + 2]
mov cl, byte [esi + 3]
mov word [eax], cx
mov eax, dword [esp + 0x6c]
test eax, eax
je 0x406e94
xor edx, edx
mov dh, byte [esi + 4]
mov dl, byte [esi + 5]
mov word [eax], dx
mov eax, dword [esp + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0xc]
pop esi
pop ebp
pop ebx
add esp, 0x48
ret 0x18
mov eax, dword [esp + 0x10]
mov dword [esp + 0xc], 0x81
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0xc]
pop esi
pop ebp
pop ebx
add esp, 0x48
ret 0x18
mov dword [esp + 0xc], 0x82
mov eax, dword [esp + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0xc]
pop esi
pop ebp
pop ebx
add esp, 0x48
ret 0x18
pop esi
pop ebp
mov eax, 0x83
pop ebx
add esp, 0x48
ret 0x18