Function at 0x401e70
Capabilities:
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0xb0
mov eax, dword [0x406008]
xor eax, ebp
mov dword [ebp - 4], eax
mov eax, dword [ebp + 8]
push ebx
push esi
mov esi, dword [ebp + 0x10]
push edi
mov edi, dword [ebp + 0x14]
mov dword [ebp - 0xac], eax
mov eax, dword [ebp + 0x18]
push 0x4046c8
push edi
mov dword [ebp - 0xb0], eax
call fcn.00402290
push 3
xor ecx, ecx
push 0x4046cc
mov word [eax], cx
push eax
mov byte [eax + 2], cl
call dword [sym.imp.api_ms_win_crt_string_l1_1_0.dll_strncat]
mov ebx, dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__fsopen]
push 0x10
push 0x404660
push esi
call ebx
add esp, 0x20
mov dword [ebp - 0xa8], eax
test eax, eax
jne 0x401f1c
call dword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll__errno]
push dword [eax]
call dword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll_strerror]
add esp, 4
push eax
push esi
push str.Open__s:__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
add esp, 4
push eax
call fcn.00401180
add esp, 0x10
or eax, 0xffffffff
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004026f8
mov esp, ebp
pop ebp
ret
mov esi, dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
push 2
push 0
push eax
call esi
push dword [ebp - 0xa8]
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_ftell]
push 0
push 0
push dword [ebp - 0xa8]
mov dword [ebp - 0x9c], eax
call esi
push 0x10
push 0x404660
push edi
call ebx
add esp, 0x28
mov dword [ebp - 0xa4], eax
test eax, eax
jne 0x401f76
call dword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll__errno]
push dword [eax]
call dword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll_strerror]
add esp, 4
push eax
push edi
jmp 0x401eef
mov esi, dword [ebp - 0xb0]
push 0x20
push 0x4046e0
push esi
call ebx
mov ebx, eax
add esp, 0xc
mov dword [ebp - 0xa0], ebx
test ebx, ebx
je 0x401edc
lea eax, [ebp - 0x18]
push eax
mov eax, dword [ebp - 0xac]
push 9
push 0
push dword [eax]
call dword [sym.imp.modbus.dll_modbus_read_input_registers]
mov edi, eax
add esp, 0x10
test edi, edi
jns 0x401fe8
call dword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll__errno]
push dword [eax]
call dword [sym.imp.modbus.dll_modbus_strerror]
add esp, 4
push eax
push str.Read_bootloader_config_error:__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
add esp, 4
push eax
call fcn.00401180
add esp, 0xc
jmp 0x402216
movzx ecx, word [ebp - 8]
xor esi, esi
movzx eax, word [ebp - 0xa]
shl ecx, 0x10
or ecx, eax
movzx eax, word [ebp - 0x12]
mov dword [ebp - 0xb0], ecx
movzx ecx, word [ebp - 0xe]
sub ecx, eax
mov dword [ebp - 0xac], ecx
cmp dword [ebp - 0x9c], esi
jle 0x402075
nop word [eax + eax]
push dword [ebp - 0xa8]
lea eax, [ebp - 0x98]
push 0x80
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
add esp, 0x10
test eax, eax
js 0x402216
jle 0x402065
push ebx
push eax
lea eax, [ebp - 0x98]
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
mov edi, eax
add esp, 0x10
test edi, edi
js 0x402216
add esi, edi
cmp dword [ebp - 0x9c], esi
jg 0x402020
mov ecx, dword [ebp - 0xac]
mov byte [ebp - 0x98], 0xff
cmp esi, ecx
jae 0x4020a9
push ebx
push 1
lea eax, [ebp - 0x98]
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
mov edi, eax
add esp, 0x10
test edi, edi
js 0x402216
add esi, edi
cmp esi, dword [ebp - 0xac]
jb 0x402080
push dword [ebp - 0xa4]
mov dword [ebp - 0x9c], 0
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_feof]
add esp, 4
test eax, eax
jne 0x402160
nop word [eax + eax]
push dword [ebp - 0xa4]
lea eax, [ebp - 0x98]
push 0x80
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov ebx, eax
add esp, 0x10
test ebx, ebx
js 0x402210
mov ecx, ebx
and ecx, 0x80000001
jns 0x402106
dec ecx
or ecx, 0xfffffffe
inc ecx
cmp ecx, 1
jne 0x402114
mov byte [ebp + ebx - 0x98], 0xff
inc ebx
test ebx, ebx
jle 0x40213b
push dword [ebp - 0xa0]
lea eax, [ebp - 0x98]
push ebx
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
mov edi, eax
add esp, 0x10
test edi, edi
js 0x402210
push dword [ebp - 0xa4]
add dword [ebp - 0x9c], ebx
add esi, edi
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_feof]
add esp, 4
test eax, eax
je 0x4020d0
mov ebx, dword [ebp - 0xa0]
mov eax, dword [ebp - 0xb0]
add eax, 0xf8000000
mov byte [ebp - 0x98], 0xff
cmp esi, eax
jae 0x4021a6
push ebx
push 1
lea eax, [ebp - 0x98]
push 1
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
mov edi, eax
add esp, 0x10
test edi, edi
js 0x402216
mov eax, dword [ebp - 0xb0]
add esi, edi
add eax, 0xf8000000
cmp esi, eax
jb 0x402176
mov ecx, dword [ebp + 0x1c]
push ebx
push 8
push 1
movzx eax, byte [ecx]
mov byte [ebp - 0x96], al
movzx eax, byte [ecx + 1]
mov ecx, dword [ebp - 0x9c]
mov byte [ebp - 0x95], al
mov eax, ecx
sar eax, 8
mov byte [ebp - 0x93], al
mov eax, ecx
sar eax, 0x10
mov byte [ebp - 0x92], al
lea eax, [ebp - 0x98]
mov byte [ebp - 0x94], cl
sar ecx, 0x18
push eax
mov word [ebp - 0x98], 0xb007
mov byte [ebp - 0x91], cl
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
mov edi, eax
add esp, 0x10
xor eax, eax
test edi, edi
cmovns edi, eax
jmp 0x402216
mov ebx, dword [ebp - 0xa0]
mov esi, dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
push ebx
call esi
push dword [ebp - 0xa4]
call esi
push dword [ebp - 0xa8]
call esi
mov ecx, dword [ebp - 4]
add esp, 0xc
mov eax, edi
xor ecx, ebp
pop edi
pop esi
pop ebx
call fcn.004026f8
mov esp, ebp
pop ebp
ret