Function at 0x40cf70
Capabilities:
Create thread

Disassembly:
push ebp
mov ebp, esp
add esp, 0xfffffdf0
mov ecx, 0xb
push ebx
push esi
push edi
lea edi, [ebp - 0x2c]
mov esi, 0x4d4058
rep movsd dword es:[edi], dword [esi]
mov dword [ebp - 0x30], 0x2580
mov dword [ebp - 0x34], 8
mov dword [ebp - 0x38], 1
mov byte [ebp - 0x39], 0x4e
lea edi, [ebp - 0x188]
mov ecx, 0x10
mov esi, 0x4d4084
rep movsd dword es:[edi], dword [esi]
xor eax, eax
lea edi, [ebp - 0x1bc]
mov dword [ebp - 0x44], eax
mov ecx, 0xd
mov dword [ebp - 0x48], 0x34
mov esi, 0x4d40c8
rep movsd dword es:[edi], dword [esi]
lea edi, [ebp - 0x1d0]
mov ecx, 5
mov esi, 0x4d40fc
rep movsd dword es:[edi], dword [esi]
lea edi, [ebp - 0x210]
mov ecx, 0x10
mov esi, 0x4d4110
rep movsd dword es:[edi], dword [esi]
mov eax, dword [ebp + 0xc]
push eax
mov edx, dword [ebp + 8]
push edx
push str.openserial:_path_s_mode_d_n
push 3
call fcn.00409f84
add esp, 0x10
push 0x38
call fcn.004b62c0
pop ecx
mov ebx, eax
test eax, eax
jne 0x40d024
xor eax, eax
jmp 0x40d387
push 0x3a
mov edx, dword [ebp + 8]
push edx
call fcn.004b66a4
add esp, 8
mov esi, eax
test eax, eax
je 0x40d080
mov edi, esi
sub edi, dword [ebp + 8]
push edi
mov eax, dword [ebp + 8]
push eax
lea edx, [ebp - 0x148]
push edx
call fcn.004b68b0
add esp, 0xc
lea ecx, [ebp - 0x188]
mov byte [ebp + edi - 0x148], 0
push ecx
lea eax, [ebp - 0x38]
push eax
lea edx, [ebp - 0x39]
push edx
lea ecx, [ebp - 0x34]
push ecx
lea eax, [ebp - 0x30]
push eax
push str.:_d:_d:_c:_d:_s
push esi
call fcn.004ba45c
add esp, 0x1c
jmp 0x40d0a8
mov edx, dword [ebp + 8]
xor eax, eax
mov edi, edx
or ecx, 0xffffffff
repne scasb al, byte es:[edi]
not ecx
sub edi, ecx
lea esi, [ebp - 0x148]
xchg edi, esi
mov edx, ecx
mov eax, edi
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
xor eax, eax
lea edx, [ebp - 0x2c]
mov ecx, dword [edx]
cmp ecx, dword [ebp - 0x30]
je 0x40d0bd
inc eax
add edx, 4
cmp eax, 0xb
jl 0x40d0ad
cmp eax, 0xc
jl 0x40d0fc
mov eax, dword [ebp - 0x30]
push eax
push str.bitrate_error___d_
mov edx, dword [ebp + 0x10]
push edx
call fcn.004ba3e0
add esp, 0xc
mov ecx, dword [ebp + 8]
push ecx
mov eax, dword [ebp + 0x10]
push eax
push 0x4d77bc
push 1
call fcn.00409f84
add esp, 0x10
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
movsx esi, byte [ebp - 0x39]
push esi
call fcn.004bd4b4
pop ecx
mov byte [ebp - 0x39], al
lea eax, [ebp - 0x148]
lea edx, [ebp - 0xc8]
push eax
push str.._s
push edx
call fcn.004ba3e0
add esp, 0xc
test byte [ebp + 0xc], 1
je 0x40d132
or dword [ebp - 0x44], 0x80000000
test byte [ebp + 0xc], 2
je 0x40d13f
or dword [ebp - 0x44], 0x40000000
push 0
push 0
push 3
push 0
push 0
mov ecx, dword [ebp - 0x44]
push ecx
lea eax, [ebp - 0xc8]
push eax
call sub.KERNEL32.DLL_CreateFileA
mov esi, eax
mov dword [ebx], esi
cmp esi, 0xffffffff
jne 0x40d19e
call sub.KERNEL32.DLL_GetLastError
push eax
push str.device_open_error___d_
mov eax, dword [ebp + 0x10]
push eax
call fcn.004ba3e0
add esp, 0xc
mov edx, dword [ebp + 8]
push edx
mov ecx, dword [ebp + 0x10]
push ecx
push str.openserial:__s_path_s_n
push 1
call fcn.00409f84
add esp, 0x10
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
lea edx, [ebp - 0x48]
push edx
lea ecx, [ebp - 0x1bc]
push ecx
lea eax, [ebp - 0x148]
push eax
call sub.KERNEL32.DLL_GetDefaultCommConfigA
test eax, eax
jne 0x40d1f9
call sub.KERNEL32.DLL_GetLastError
push eax
push str.getconfig_error___d_
mov edx, dword [ebp + 0x10]
push edx
call fcn.004ba3e0
add esp, 0xc
mov ecx, dword [ebp + 0x10]
push ecx
push 0x4d781f
push 1
call fcn.00409f84
add esp, 0xc
mov eax, dword [ebx]
push eax
call sub.KERNEL32.DLL_CloseHandle
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
mov edx, dword [ebp - 0x38]
push edx
mov ecx, dword [ebp - 0x34]
push ecx
lea ecx, [ebp - 0x210]
movsx eax, byte [ebp - 0x39]
push eax
mov edx, dword [ebp - 0x30]
push edx
push str.baud_d_parity_c_data_d_stop_d
push ecx
call fcn.004ba3e0
add esp, 0x18
lea eax, [ebp - 0x1b4]
push eax
lea edx, [ebp - 0x210]
push edx
call sub.KERNEL32.DLL_BuildCommDCBA
test eax, eax
jne 0x40d275
call sub.KERNEL32.DLL_GetLastError
push eax
push str.buiddcb_error___d_
mov ecx, dword [ebp + 0x10]
push ecx
call fcn.004ba3e0
add esp, 0xc
mov eax, dword [ebp + 0x10]
push eax
push 0x4d7864
push 1
call fcn.00409f84
add esp, 0xc
mov edx, dword [ebx]
push edx
call sub.KERNEL32.DLL_CloseHandle
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
lea eax, [ebp - 0x188]
mov edx, 0x4d7874
mov cl, byte [eax]
cmp cl, byte [edx]
jne 0x40d2ae
test cl, cl
je 0x40d29c
mov cl, byte [eax + 1]
cmp cl, byte [edx + 1]
jne 0x40d2ae
add eax, 2
add edx, 2
test cl, cl
jne 0x40d280
jne 0x40d2ae
mov al, byte [ebp - 0x1ab]
and al, 0xcf
or al, 0x20
mov byte [ebp - 0x1ab], al
mov edx, dword [ebp - 0x48]
lea ecx, [ebp - 0x1bc]
push edx
push ecx
mov eax, dword [ebx]
push eax
call sub.KERNEL32.DLL_SetCommConfig
lea edx, [ebp - 0x1d0]
push edx
mov ecx, dword [ebx]
push ecx
call sub.KERNEL32.DLL_SetCommTimeouts
push 0
lea eax, [ebp - 0x40]
push eax
mov edx, dword [ebx]
push edx
call sub.KERNEL32.DLL_ClearCommError
push 0xf
mov ecx, dword [ebx]
push ecx
call sub.KERNEL32.DLL_PurgeComm
lea eax, [ebx + 0x1c]
push eax
call sub.KERNEL32.DLL_InitializeCriticalSection
xor edx, edx
mov dword [ebx + 4], edx
mov dword [ebx + 0x10], edx
mov dword [ebx + 0xc], edx
mov dword [ebx + 8], edx
mov eax, dword [0x4d3b48]
mov dword [ebx + 0x14], eax
mov ecx, dword [0x4d3b48]
push ecx
call fcn.004b62c0
pop ecx
mov dword [ebx + 0x34], eax
test eax, eax
jne 0x40d32e
mov edx, dword [ebx]
push edx
call sub.KERNEL32.DLL_CloseHandle
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
push 0
push 0
push ebx
push 0x40ced4
push 0
push 0
call sub.KERNEL32.DLL_CreateThread
mov dword [ebx + 0x18], eax
test eax, eax
jne 0x40d385
call sub.KERNEL32.DLL_GetLastError
push eax
push str.serial_thread_error___d_
mov edx, dword [ebp + 0x10]
push edx
call fcn.004ba3e0
add esp, 0xc
mov ecx, dword [ebp + 0x10]
push ecx
push str.openserial:__s_n
push 1
call fcn.00409f84
add esp, 0xc
mov eax, dword [ebx]
push eax
call sub.KERNEL32.DLL_CloseHandle
push ebx
call fcn.004b62d0
pop ecx
xor eax, eax
jmp 0x40d387
mov eax, ebx
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret