Function at 0x40314f
Capabilities:
Read file on windows

Disassembly:
mov eax, 0x1044
call fcn.0042b680
push ebx
push ebp
push esi
xor ebp, ebp
push edi
mov esi, ecx
push ebp
mov dword [esp + 0x18], ebp
call dword [sym.imp.KERNEL32.dll_GetCurrentThread]
push eax
call dword [sym.imp.KERNEL32.dll_SetThreadPriority]
mov eax, dword [esi + 0x198]
mov ecx, dword [esi + 0x26c]
mov dword [esp + 0x24], eax
mov dword [esp + 0x18], eax
mov edx, dword [esi + 0x268]
mov dword [esp + 0x30], eax
mov eax, dword [esi + 0x280]
mov dword [esp + 0x28], ecx
mov ecx, dword [esi + 0x2a0]
mov dword [esp + 0x34], eax
mov eax, dword [esi + 0x270]
push 0x14
mov dword [esp + 0x40], eax
lea eax, [esp + 0x44]
push ebp
push eax
mov dword [esp + 0x38], ecx
mov dword [esp + 0x28], ecx
mov dword [esp + 0x2c], edx
mov dword [esp + 0x44], ecx
call fcn.0042b620
mov eax, dword [esi + 0x268]
add esp, 0xc
mov dword [esp + 0x50], eax
cmp word [esi + 0x1b2], bp
jne 0x403a0a
cmp word [esi + 0x30c], bp
je 0x40322d
lea edi, [esi + 0x10]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov ax, word [esi + 0x30a]
mov word [esi + 0x30c], bp
push dword [esi + 0x2a0]
mov word [esi + 0x308], ax
call dword [sym.imp.KERNEL32.dll_ResetEvent]
push dword [esi + 0x2a4]
call dword [sym.imp.KERNEL32.dll_SetEvent]
push edi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
cmp word [esi + 0x308], bp
jne 0x40326a
push str.COMMS:_Reads_suspended
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
lea eax, [esp + 0x1c]
pop ecx
push 0xffffffffffffffff
push ebp
push eax
push 2
call dword [sym.imp.KERNEL32.dll_WaitForMultipleObjects]
test eax, eax
je 0x403a0a
push str.COMMS:_Reads_continuing
jmp 0x403372
lea edi, [esi + 0x10]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [esi + 0x28]
cmp eax, dword [esi + 0x324]
jb 0x40337d
push dword [esi + 0x26c]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
cmp word [esi + 0x308], 4
mov word [esi + 0x260], 1
jne 0x4032e6
cmp word [esi + 0x264], bp
lea edx, [esi + 0x264]
je 0x4032e6
mov ecx, dword [esi + 0x330]
lea eax, [esi + 0x330]
mov ebx, ecx
mov word [edx], bp
shr ebx, 3
sub ecx, ebx
mov dword [eax], ecx
cmp word [0x45349a], bp
je 0x4032e6
push ecx
push str.COMMS:_Rx_buffer_full__LowThreshold_lowered_to__u
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
mov ecx, dword [esi + 0x328]
lea eax, [esi + 0x328]
mov edx, ecx
mov dword [esi + 0x32c], ecx
sub edx, dword [esi + 0x330]
shr edx, 3
sub ecx, edx
mov dword [eax], ecx
cmp word [0x45349a], bp
je 0x40332c
push ecx
push dword [esi + 0x32c]
push str.COMMS:_Rx_buffer_full__ResumeThreshold_lowered_from__u_to__u
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0x10
jmp 0x40333e
push str.COMMS:_Rx_buffer_full
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
push edi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push 0xffffffffffffffff
lea eax, [esp + 0x28]
push ebp
push eax
push 3
call dword [sym.imp.KERNEL32.dll_WaitForMultipleObjects]
cmp eax, ebp
mov word [esi + 0x260], bp
je 0x403a0a
cmp eax, 1
jne 0x4031d9
push str.COMMS:_Rx_buffer_now_has_space_available
push dword [esi + 0x2b0]
jmp 0x4039fe
mov ecx, dword [esi + 0x254]
mov eax, dword [esi + 0x258]
lea ebx, [esi + 0x254]
cmp ecx, eax
jb 0x4033d2
mov edi, dword [esi + 0x25c]
sub edi, ecx
cmp edi, dword [esi + 0x320]
jae 0x4033d7
cmp eax, ecx
jne 0x4033bd
mov ecx, dword [esi + 0x250]
mov dword [esi + 0x258], ecx
mov eax, dword [0x4531a4]
lea edi, [eax - 1]
jmp 0x4033ce
mov dword [esi + 0x25c], ecx
mov ecx, dword [esi + 0x250]
sub eax, ecx
dec eax
mov edi, eax
mov dword [ebx], ecx
jmp 0x4033d7
sub eax, ecx
dec eax
mov edi, eax
lea eax, [esi + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push dword [esi + 0x268]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
mov eax, dword [esi + 0x31c]
mov word [esi + 0x266], bp
cmp eax, ebp
je 0x403400
mov edi, eax
mov ax, word [esi + 6]
test al, 2
je 0x403416
mov eax, dword [esi + 0x318]
cmp edi, eax
jbe 0x40342b
mov edi, eax
jmp 0x40342b
test al, 4
je 0x40342b
push ebp
mov ecx, esi
call fcn.00403049
test ax, ax
jne 0x403a0a
cmp word [0x45349a], bp
je 0x403448
push edi
push str.COMMS:_Call_ReadFile__max_length__u
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
push dword [esi + 0x280]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
lea eax, [esp + 0x40]
push eax
lea eax, [esp + 0x14]
push eax
push edi
push dword [ebx]
push dword [esi + 0x194]
call dword [sym.imp.KERNEL32.dll_ReadFile]
cmp word [0x45349a], bp
mov edi, eax
je 0x4034b2
cmp edi, ebp
je 0x403483
mov eax, 0x438ccc
jmp 0x40349a
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x3e5
mov eax, str.Pending
je 0x40349a
mov eax, str.ERROR
push dword [esp + 0x10]
push eax
push str.COMMS:_ReadFile_returned__s__length__u
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0x10
test byte [esi + 6], 4
je 0x4034bf
mov ecx, esi
call fcn.00403100
cmp edi, ebp
jne 0x4035ea
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov edi, eax
cmp edi, 0x3e5
jne 0x40364f
test byte [esi + 6], 4
je 0x4034f3
push str.COMMS:_Unexpected_overlapped_read_result_for_GF1190
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
test byte [esi + 6], 0x20
je 0x403500
mov eax, dword [0x438158]
jmp 0x403503
or eax, 0xffffffff
push eax
lea eax, [esp + 0x1c]
push ebp
push eax
push 3
call dword [sym.imp.KERNEL32.dll_WaitForMultipleObjects]
cmp eax, 2
je 0x403582
cmp eax, ebp
jne 0x403522
push str.COMMS:_Cancelling_read_because_port_is_closing
jmp 0x403527
push str.COMMS:_Cancelling_read_because_read_mode_has_changed
push dword [esi + 0x2b0]
call fcn.0041e63d
test byte [esi + 6], 0x20
pop ecx
pop ecx
je 0x40355f
lea edi, [esi + 0x2cc]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
cmp dword [esi + 0x224], ebp
je 0x403558
mov word [esi + 0x248], 1
push edi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push dword [esi + 0x194]
call dword [sym.imp.KERNEL32.dll_CancelIo]
push 0xffffffffffffffff
push dword [esi + 0x268]
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
mov word [esi + 0x266], 1
cmp word [0x45349a], bp
je 0x40359d
push str.COMMS:_Call_GetOverlappedResult_for_read
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
lea eax, [esp + 0x10]
push 1
push eax
lea eax, [esp + 0x48]
push eax
push dword [esi + 0x194]
call dword [sym.imp.KERNEL32.dll_GetOverlappedResult]
cmp word [0x45349a], bp
mov edi, eax
je 0x4035e6
cmp edi, ebp
mov eax, 0x438ccc
jne 0x4035ce
mov eax, str.ERROR
push dword [esp + 0x10]
push eax
push str.COMMS:_GetOverlappedResult_returned__s__length__u
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0x10
cmp edi, ebp
je 0x4035f5
mov dword [esi + 0x338], ebp
jmp 0x403745
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp word [esi + 0x266], bp
mov edi, eax
je 0x403612
cmp edi, 0x3e3
je 0x403745
lea eax, [esp + 0x54]
push 0x1000
push eax
push edi
call fcn.004017d5
add esp, 0xc
push eax
push str.COMMS:_Rx_GetOverlappedResult_error____s
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
mov ecx, esi
push edi
call fcn.0040761a
push 4
mov ecx, esi
call fcn.0040596e
jmp 0x403741
lea eax, [esp + 0x54]
push 0x1000
push eax
push edi
call fcn.004017d5
add esp, 0xc
push eax
push str.COMMS:_ReadFile_error____s
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
test byte [esi + 6], 4
je 0x403726
cmp edi, 0x3e3
je 0x403694
cmp edi, 0x45d
jne 0x403726
cmp dword [esi + 0x338], ebp
jne 0x4036af
call dword [sym.imp.WINMM.dll_timeGetTime]
cmp eax, ebp
jne 0x4036a9
push 1
pop eax
mov dword [esi + 0x338], eax
call dword [sym.imp.WINMM.dll_timeGetTime]
cmp eax, ebp
jne 0x4036bc
push 1
pop eax
sub eax, dword [esi + 0x338]
cmp eax, 0x2710
jbe 0x4036ea
push str.COMMS:_GF1190_comms_errors_have_persisted_for_10_seconds
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
push 4
mov ecx, esi
call fcn.0040596e
mov dword [esi + 0x338], ebp
cmp word [esi + 0x308], 4
jne 0x40373b
cmp word [0x4551c6], bp
je 0x40373b
cmp word [0x45349a], bp
je 0x403718
push str.COMMS:_Delay_200ms_after_GF1190_error
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
push 0xc8
mov ecx, esi
call fcn.00407267
jmp 0x40373b
cmp edi, ebp
je 0x40373b
push edi
mov ecx, esi
call fcn.0040761a
push 4
mov ecx, esi
call fcn.0040596e
test byte [esi + 6], 4
jne 0x403745
mov dword [esp + 0x10], ebp
cmp dword [esp + 0x10], ebp
je 0x4038b1
cmp word [0x45349a], bp
je 0x4037a2
mov ecx, dword [esi + 0x2b0]
call fcn.0041eaa4
push dword [esp + 0x10]
push str.COMMS:_Read__u_bytes_...
push dword [esi + 0x2b0]
call fcn.0041e63d
mov eax, dword [0x4534a6]
add esp, 0xc
cmp dword [esp + 0x10], eax
jae 0x403789
mov eax, dword [esp + 0x10]
mov ecx, dword [esi + 0x2b0]
push eax
push dword [ebx]
call fcn.0041e766
mov ecx, dword [esi + 0x2b0]
call fcn.0041eaaf
lea eax, [esi + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
push dword [esp + 0x10]
mov ecx, esi
push ebx
call fcn.00401863
mov eax, dword [esp + 0x10]
add dword [esi + 0x28], eax
add dword [esp + 0x14], eax
cmp word [esi + 8], bp
mov ecx, dword [esi + 0x28]
je 0x4037dd
cmp ecx, ebp
je 0x4037dd
push dword [esi + 0xc]
call dword [sym.imp.KERNEL32.dll_SetEvent]
mov word [esi + 8], bp
cmp word [esi + 0x308], 4
jne 0x403846
mov eax, dword [esi + 0x28]
lea edi, [esi + 0x330]
cmp eax, dword [edi]
ja 0x403828
lea eax, [esi + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
cmp word [0x45349a], bp
je 0x4031d9
push dword [edi]
push dword [esi + 0x28]
push str.COMMS:_Read_delay_skipped__Buffer_level__u__LowThreshold__u_
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0x10
jmp 0x4031d9
cmp word [esi + 0x262], bp
lea edi, [esi + 0x262]
je 0x403846
push dword [esi + 0x270]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
mov word [edi], bp
lea eax, [esi + 0x10]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esi + 0x31c]
cmp eax, ebp
je 0x403883
cmp dword [esp + 0x10], eax
jne 0x4038b1
mov eax, dword [esp + 0x14]
cmp eax, dword [esi + 0x318]
jae 0x4038b1
cmp word [0x45349a], bp
je 0x4031d9
push str.COMMS:_Read_delay_skipped_after_full_block
jmp 0x4039f8
test byte [esi + 6], 0x10
je 0x4038b1
cmp dword [esp + 0x10], 0x40
je 0x40389a
cmp word [esi + 0x308], 4
jne 0x4038b1
cmp word [0x45349a], bp
je 0x4031d9
push str.COMMS:_Read_delay_skipped
jmp 0x4039f8
cmp word [esi + 0x1b2], bp
jne 0x403a0a
mov ecx, dword [esi + 0x310]
mov ebx, dword [esi + 0x314]
cmp ecx, ebx
je 0x40393d
test byte [esi + 6], 6
je 0x4038eb
mov eax, ebx
xor edx, edx
sub eax, ecx
mov ecx, ebx
imul eax, dword [esp + 0x14]
div dword [esi + 0x318]
sub ecx, eax
jmp 0x403929
mov ebp, dword [esi + 0x274]
mov eax, dword [esi + 0x318]
mov ecx, dword [esp + 0x14]
imul eax, ebp
inc ecx
xor edx, edx
div ecx
push 4
pop ecx
push 4
mov edi, eax
sub edi, ebp
add edi, dword [esi + 0x278]
mov eax, edi
cdq
idiv ecx
mov ecx, eax
mov eax, edi
cdq
pop edi
add ecx, ebp
idiv edi
xor ebp, ebp
mov dword [esi + 0x278], edx
mov eax, dword [esi + 0x310]
cmp ecx, eax
jge 0x403937
mov ecx, eax
jmp 0x40393d
cmp ecx, ebx
jbe 0x40393d
mov ecx, ebx
cmp ecx, dword [esi + 0x274]
je 0x403968
mov dword [esi + 0x274], ecx
cmp word [0x45349a], bp
je 0x403968
push ecx
push str.COMMS:_Rx_delay_set_to__ums
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
mov eax, dword [esi + 0x274]
mov dword [esp + 0x14], ebp
cmp eax, ebp
je 0x4031d9
cmp word [0x45349a], bp
je 0x403997
push eax
push str.COMMS:_Delay__ums_before_next_read
push dword [esi + 0x2b0]
call fcn.0041e63d
add esp, 0xc
push dword [esi + 0x274]
lea eax, [esp + 0x34]
push ebp
push eax
xor eax, eax
cmp word [esi + 0x308], 4
sete al
add eax, 3
push eax
call dword [sym.imp.KERNEL32.dll_WaitForMultipleObjects]
cmp word [0x45349a], bp
je 0x4031d9
cmp eax, ebp
jne 0x4039d2
push str.COMMS:_Read_delay_cut_short_because_port_is_closing
jmp 0x4039f8
cmp eax, 1
jne 0x4039de
push str.COMMS:_Read_delay_cut_short_because_event_character_received
jmp 0x4039f8
cmp eax, 2
jne 0x4039ea
push str.COMMS:_Read_delay_cut_short_because_read_mode_has_changed
jmp 0x4039f8
cmp eax, 3
jne 0x4031d9
push str.COMMS:_Read_delay_cut_short_because_buffer_level_low
push dword [esi + 0x2b0]
call fcn.0041e63d
pop ecx
pop ecx
jmp 0x4031d9
push dword [esi + 0x194]
call dword [sym.imp.KERNEL32.dll_CancelIo]
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x1044
ret