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

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x11c
mov eax, dword [section..data]
xor eax, ebp
mov dword [ebp - 4], eax
cmp dword [ebp + 8], 3
push ebx
push esi
mov esi, dword [ebp + 0xc]
push edi
mov dword [ebp - 0x11c], esi
jl 0x40176f
mov edx, dword [esi + 4]
mov ecx, edx
lea edi, [ecx + 1]
mov al, byte [ecx]
inc ecx
test al, al
jne 0x4010bb
sub ecx, edi
cmp ecx, 0xfa
jae 0x40176f
lea ecx, [ebp - 0x108]
sub ecx, edx
mov al, byte [edx]
mov byte [edx + ecx], al
inc edx
test al, al
jne 0x4010d8
lea ecx, [ebp - 0x108]
dec ecx
mov al, byte [ecx + 1]
inc ecx
test al, al
jne 0x4010e9
mov eax, dword [str..bak]
mov dword [ecx], eax
mov al, byte [0x4031a4]
mov byte [ecx + 4], al
lea eax, [ebp - 0x10c]
push eax
push 0x4031a8
push dword [esi + 8]
call fcn.0040105f
xor edi, edi
add esp, 0xc
inc edi
cmp eax, edi
je 0x401126
push 2
pop esi
jmp 0x401772
push 0x4031ac
push dword [esi + 4]
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fopen]
mov ebx, eax
pop ecx
pop ecx
test ebx, ebx
jne 0x40115e
push dword [esi + 4]
push str.unable_to_open_file__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 3
pop eax
jmp 0x40177f
push 2
push 0
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
add esp, 0xc
test eax, eax
jne 0x401746
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_ftell]
mov dword [ebp - 0x114], eax
pop ecx
test eax, eax
jle 0x401746
lea ecx, [eax - 0x100]
cmp ecx, 0x3fff00
ja 0x40171d
push edi
xor ecx, ecx
push 0x20
pop edx
add eax, edx
setb cl
neg ecx
or ecx, eax
push ecx
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_calloc]
mov edi, eax
pop ecx
pop ecx
test edi, edi
jne 0x4011e0
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
mov dword [esp], str.Error_allocating_memory_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 8
jmp 0x401158
push 0
push 0
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
add esp, 0xc
test eax, eax
jne 0x4016ec
push ebx
push dword [ebp - 0x114]
inc eax
push eax
push edi
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov edx, dword [ebp - 0x114]
add esp, 0x10
cmp eax, edx
jne 0x4016ec
mov eax, dword [edi]
cmp eax, dword [0x403498]
je 0x40124e
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Wrong_file_header_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x14
jmp 0x401158
cmp byte [edi + 4], 1
jne 0x4016bf
cmp byte [edi + 5], 1
jne 0x4016bf
cmp byte [edi + 6], 1
jne 0x4016bf
xor ecx, ecx
inc ecx
cmp dword [edi + 0x14], ecx
jne 0x4016bf
push 0x34
pop eax
cmp word [edi + 0x28], ax
jne 0x4016bf
movzx eax, word [edi + 0x2a]
push 0x20
pop esi
cmp ax, si
jne 0x4016bf
cmp word [edi + 0x2e], 0x28
jne 0x4016bf
cmp word [edi + 0x2c], cx
jne 0x4016bf
mov esi, dword [edi + 0x1c]
mov ecx, edx
sub ecx, eax
mov dword [ebp - 0x110], esi
cmp esi, ecx
jbe 0x4012e8
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Invalid_program_header_offset_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x32
jmp 0x401158
mov eax, dword [esi + edi + 0x10]
test al, 0xf
je 0x40131d
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Binary_data_length_not_multiple_of_16_bytes_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x33
jmp 0x401158
cmp eax, 0x100
jae 0x401351
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Binary_data_length_less_than_minimum_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x3a
jmp 0x401158
cmp eax, 0x400000
jbe 0x401385
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Binary_data_length_more_than_maximum_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x3b
jmp 0x401158
cmp eax, edx
jae 0x401692
mov esi, dword [esi + edi + 4]
cmp esi, edx
jae 0x401692
lea ecx, [esi + eax]
mov dword [ebp - 0x118], ecx
cmp ecx, edx
ja 0x401692
mov ecx, dword [ebp - 0x110]
mov edx, dword [ecx + edi + 8]
cmp dword [ebp - 0x10c], edx
jb 0x401665
lea ecx, [edx + eax]
mov eax, dword [ebp - 0x10c]
add eax, 4
cmp eax, ecx
jae 0x401665
sub esi, edx
add esi, dword [ebp - 0x10c]
cmp dword [esi + edi], 0xaa550ff0
je 0x401412
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.ImgLen_marker_not_found_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x36
jmp 0x401158
mov eax, dword [ebp - 0x118]
cmp dword [eax + edi - 4], 0xdeadbeef
je 0x40144f
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.CRC_marker_not_found_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x37
jmp 0x401158
lea eax, [ebp - 0x108]
push 0x403404
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fopen]
mov dword [ebp - 0x118], eax
pop ecx
pop ecx
test eax, eax
jne 0x4014a2
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
lea eax, [ebp - 0x108]
push eax
push str.unable_to_open_backup_file__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 0x64
jmp 0x401158
push eax
push dword [ebp - 0x114]
xor eax, eax
inc eax
push eax
push edi
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
push dword [ebp - 0x118]
mov esi, eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
add esp, 0x14
cmp esi, dword [ebp - 0x114]
je 0x401502
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
lea eax, [ebp - 0x108]
push eax
push str.unable_to_write_backup_file__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 0x65
jmp 0x401158
mov esi, dword [ebp - 0x110]
mov edx, dword [ebp - 0x10c]
mov eax, dword [esi + edi + 4]
sub eax, dword [esi + edi + 8]
add edx, eax
mov dword [ebp - 0x10c], edx
mov ecx, dword [esi + edi + 0x10]
mov eax, dword [esi + edi + 4]
add eax, 0xfffffffe
add eax, ecx
mov dword [ebp - 0x110], eax
lea eax, [ecx - 2]
mov dword [edx + edi], eax
mov ecx, 0xffff
mov edx, dword [esi + edi + 4]
mov esi, dword [esi + edi + 0x10]
add edx, edi
dec esi
jmp 0x401561
movzx eax, byte [edx]
xor eax, ecx
shr cx, 8
movzx eax, al
xor cx, word [eax*2 + 0x4034a0]
inc edx
movzx ecx, cx
sub esi, 1
jne 0x401549
mov esi, dword [ebp - 0x110]
add esi, edi
push 0
mov word [esi], cx
push dword [ebp - 0x10c]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
add esp, 0xc
test eax, eax
jne 0x40162e
push ebx
inc eax
push 4
push eax
mov eax, dword [ebp - 0x10c]
add eax, edi
push eax
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
add esp, 0x10
cmp eax, 4
jne 0x40162e
push 0
push dword [ebp - 0x110]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
add esp, 0xc
test eax, eax
jne 0x4015f7
push ebx
push 2
inc eax
push eax
push esi
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
add esp, 0x10
cmp eax, 2
jne 0x4015f7
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push str.Done._n
call fcn.00401031
add esp, 0xc
xor eax, eax
jmp 0x40177f
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
mov eax, dword [ebp - 0x11c]
pop ecx
pop ecx
push dword [eax + 4]
push str.unable_to_patch_file__s_for_CRC_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 0x6f
jmp 0x401158
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
mov eax, dword [ebp - 0x11c]
pop ecx
pop ecx
push dword [eax + 4]
push str.unable_to_patch_file__s_for_length_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 0x6e
jmp 0x401158
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.ImgLenAddressHex_not_in_address_range_of_program_data_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x35
jmp 0x401158
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Invalid_program_data_offset_or_length_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x34
jmp 0x401158
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push str.Only_ELF_v1_supported_for_little_endian_32bit_machines_nand_FH_size_52byte__PH_size_32byte__SH_size_40byte_nand_1_program_header_only_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
pop ecx
pop ecx
push 0x15
jmp 0x401158
push edi
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
pop ecx
push dword [esi + 4]
push str.unable_to_read_file__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 9
jmp 0x401158
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
push dword [esi + 4]
push str.wrong_input_file_size__s_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 5
jmp 0x401158
push ebx
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
pop ecx
push dword [esi + 4]
push str.unable_to_get_file__s_size_n
push 2
call dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func]
pop ecx
push eax
call fcn.0040100c
add esp, 0xc
push 4
jmp 0x401158
xor esi, esi
inc esi
push str.usage:_ELFer__inoutfile___ImgLenAddressHex__n_tThis_program_will_load__calc_CRC_and_write_ELF_files_n_tSections_needed:__n
call fcn.00401031
pop ecx
mov eax, esi
mov ecx, dword [ebp - 4]
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.0040178e
leave
ret