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

Disassembly:
push ebp
mov ebp, esp
push edi
push esi
push ebx
and esp, 0xfffffff0
sub esp, 0x20
mov edi, dword [ebp + 0xc]
call dbg.__main
cmp dword [ebp + 8], 4
jne 0x4029f3
mov dword [esp + 4], 1
mov dword [esp], 0x10000000
call sym._calloc
mov ebx, eax
test eax, eax
je 0x402aa7
mov dword [esp + 4], 0x404038
mov eax, dword [edi + 4]
mov dword [esp], eax
call sym._fopen
mov esi, eax
test eax, eax
je 0x402a53
mov dword [esp + 8], 2
mov dword [esp + 4], 0
mov dword [esp], eax
call sym._fseek
mov dword [esp], esi
call sym._ftell
mov dword [esp + 8], 0
mov dword [esp + 4], 0
mov dword [esp], esi
mov dword [esp + 0x1c], eax
call sym._fseek
mov eax, dword [esp + 0x1c]
mov dword [esp + 0xc], esi
mov dword [esp + 4], 1
mov dword [esp + 8], eax
lea eax, [ebx + 0x800]
mov dword [esp], eax
call sym._fread
cmp dword [esp + 0x1c], eax
jne 0x402a04
mov dword [esp], esi
call sym._fclose
mov eax, dword [esp + 0x1c]
mov dword [esp + 4], 0x404038
lea edx, [eax + 0x3fe]
add eax, 0x1ff
cmovs eax, edx
sar eax, 9
add eax, 3
and eax, 0xfffffffc
mov dword [esp + 0x18], eax
mov eax, dword [edi + 8]
mov dword [esp], eax
call sym._fopen
mov esi, eax
test eax, eax
je 0x402a6f
mov dword [esp + 8], 2
mov dword [esp + 4], 0
mov dword [esp], eax
call sym._fseek
mov dword [esp], esi
call sym._ftell
mov dword [esp + 8], 0
mov dword [esp + 4], 0
mov dword [esp], esi
mov dword [esp + 0x1c], eax
call sym._fseek
mov edx, dword [esp + 0x18]
mov eax, dword [esp + 0x1c]
mov dword [esp + 0xc], esi
mov dword [esp + 4], 1
lea ecx, [edx + 4]
mov dword [esp + 8], eax
mov eax, ecx
mov dword [esp + 0x14], ecx
shl eax, 9
add eax, ebx
mov dword [esp], eax
call sym._fread
cmp dword [esp + 0x1c], eax
jne 0x402a25
mov dword [esp], esi
call sym._fclose
mov eax, dword [esp + 0x1c]
mov edx, 0x200
mov dword [ebx], 0xff0aa55
mov dword [ebx + 8], 1
lea esi, [eax + 0x3fe]
add eax, 0x1ff
mov dword [ebx + 0xc], 0x40004
cmovns esi, eax
mov eax, dword [esp + 0x18]
sar esi, 9
mov word [ebx + 0x1fa], ax
add esi, 3
and esi, 0xfffffffc
add eax, esi
mov word [ebx + 0x1fc], ax
mov eax, ebx
call dbg.rc4
lea eax, [ebx + 0x200]
mov edx, 0x204
call dbg.rc4
lea eax, [ebx + 0x400]
mov edx, 0x200
call dbg.rc4
lea eax, [ebx + 0x600]
mov edx, 0x1fe
call dbg.rc4
mov dword [esp + 4], 0x40408f
mov eax, dword [edi + 0xc]
mov dword [esp], eax
call sym._fopen
test eax, eax
je 0x402a8b
add esi, dword [esp + 0x14]
mov dword [esp + 0xc], eax
shl esi, 9
mov dword [esp + 4], 1
mov dword [esp + 8], esi
mov dword [esp], ebx
mov dword [esp + 0x1c], eax
call sym._fwrite
mov edx, dword [esp + 0x1c]
cmp esi, eax
jne 0x402a2e
mov dword [esp], edx
call sym._fclose
mov dword [esp], ebx
call sym._free
mov eax, dword [edi + 0xc]
mov dword [esp], str.Binary_pack_file_____s_n
mov dword [esp + 4], eax
call sym._printf
xor eax, eax
lea esp, [ebp - 0xc]
pop ebx
pop esi
pop edi
pop ebp
ret
mov dword [esp], str.Usage:_mkidb__ddr___boot___bootpak_
call sym._puts
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Read_file_boot_error
call sym._puts
mov dword [esp], ebx
call sym._free
mov dword [esp], esi
call sym._fclose
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Read_boot_file_error
jmp 0x402a0b
mov dword [esp], str.Write_bootpak_file_error
call sym._puts
mov dword [esp], ebx
call sym._free
mov edx, dword [esp + 0x1c]
mov dword [esp], edx
call sym._fclose
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Open_ddr_file_error
call sym._puts
mov dword [esp], ebx
call sym._free
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Open_boot_file_error
call sym._puts
mov dword [esp], ebx
call sym._free
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Open_bootpak_file_error
call sym._puts
mov dword [esp], ebx
call sym._free
or eax, 0xffffffff
jmp 0x4029eb
mov dword [esp], str.Malloc_buffer_error
call sym._puts
or eax, 0xffffffff
jmp 0x4029eb