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

Disassembly:
push ecx
push ebp
mov ebp, ecx
mov eax, dword [ebp + 4]
cmp eax, dword [ebp + 8]
jae 0x40d7b0
mov eax, dword [ebp + 0x2d4]
test eax, eax
je 0x40d7b0
lea ecx, [ebp + 0xc]
push 0x4190b0
push ecx
call dword [sym.imp.MSVCR71.dll_fopen]
add esp, 8
test eax, eax
mov dword [esp + 4], eax
jne 0x40d7b7
xor eax, eax
pop ebp
pop ecx
ret 0xc
mov edx, dword [ebp + 0x2cc]
push ebx
mov ebx, dword [ebp + 0x2d4]
add ebx, edx
mov dword [ebp + 0x2d0], edx
cmp dword [ebx], 0x2014b50
push esi
push edi
jne 0x40d865
mov esi, dword [esp + 0x1c]
mov edi, dword [sym.imp.MSVCR71.dll_strncpy]
movzx eax, word [ebx + 0x1c]
push eax
lea ecx, [ebx + 0x2e]
push ecx
push esi
call edi
movzx edx, word [ebx + 0x1c]
mov byte [edx + esi], 0
movzx eax, word [ebx + 0x1c]
mov cl, byte [eax + esi - 1]
add esp, 0xc
cmp cl, 0x2f
je 0x40d813
movzx ecx, word [ebx + 0x1c]
cmp byte [ecx + esi - 1], 0x5c
jne 0x40d879
mov eax, dword [ebp + 0x2cc]
add eax, 0x2e
mov dword [ebp + 0x2cc], eax
movzx edx, word [ebx + 0x1e]
add eax, edx
mov dword [ebp + 0x2cc], eax
movzx ecx, word [ebx + 0x1c]
add eax, ecx
mov dword [ebp + 0x2cc], eax
movzx edx, word [ebx + 0x20]
add edx, eax
mov dword [ebp + 0x2cc], edx
inc dword [ebp + 4]
mov ebx, dword [ebp + 0x2d4]
mov ecx, dword [ebp + 0x2cc]
mov eax, dword [ebx + ecx]
add ebx, ecx
cmp eax, 0x2014b50
je 0x40d7e4
mov eax, dword [esp + 0x10]
push eax
call dword [sym.imp.MSVCR71.dll_fclose]
add esp, 4
pop edi
pop esi
pop ebx
xor eax, eax
pop ebp
pop ecx
ret 0xc
mov eax, dword [ebx + 0x2a]
mov ecx, dword [esp + 0x10]
push 0
push eax
push ecx
call dword [sym.imp.MSVCR71.dll_fseek]
mov edx, dword [esp + 0x1c]
push edx
push 1
lea edi, [ebp + 0x264]
push 0x1e
push edi
call dword [sym.imp.MSVCR71.dll_fread]
mov eax, dword [edi]
add esp, 0x1c
cmp eax, 0x4034b50
jne 0x40d861
movzx ecx, word [ebp + 0x280]
movzx edx, word [ebp + 0x27e]
mov eax, dword [ebx + 0x2a]
add ecx, edx
lea ecx, [ecx + eax + 0x1e]
mov eax, dword [esp + 0x20]
test eax, eax
mov dword [esp + 0x1c], ecx
je 0x40d914
push 0x2f
push esi
call dword [sym.imp.MSVCR71.dll__mbsrchr]
add esp, 8
test eax, eax
je 0x40d8f4
mov edi, dword [sym.imp.MSVCR71.dll_strrchr]
push 0x2f
push esi
mov byte [eax], 0x5c
call edi
add esp, 8
test eax, eax
jne 0x40d8e5
push esi
mov esi, dword [esp + 0x1c]
push esi
mov ecx, ebp
call fcn.0040d0f0
lea edx, [ebp + 0x138]
push edx
push esi
call dword [sym.imp.MSVCR71.dll_sprintf]
add esp, 8
jmp 0x40d97c
push esi
lea eax, [ebp + 0x138]
push 0x4189e0
push eax
call dword [sym.imp.MSVCR71.dll_sprintf]
mov edi, dword [sym.imp.MSVCR71.dll__mbsrchr]
push 0x2f
push esi
call edi
add esp, 0x14
test eax, eax
jne 0x40d93b
mov eax, esi
push 0x2e
push eax
call edi
add esp, 8
test eax, eax
je 0x40d978
mov edx, eax
lea esp, [esp]
mov cl, byte [eax]
inc eax
test cl, cl
jne 0x40d950
mov edi, dword [esp + 0x18]
sub eax, edx
dec edi
mov edi, edi
mov cl, byte [edi + 1]
inc edi
test cl, cl
jne 0x40d960
mov ecx, eax
shr ecx, 2
mov esi, edx
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov esi, dword [esp + 0x18]
cmp word [ebp + 0x26c], 0
jne 0x40da49
mov ecx, dword [esp + 0x1c]
mov edi, dword [esp + 0x10]
push 0
push ecx
push edi
call dword [sym.imp.MSVCR71.dll_fseek]
push 0x4190c8
push esi
call dword [sym.imp.MSVCR71.dll_fopen]
add esp, 0x14
test eax, eax
mov dword [esp + 0x18], eax
jne 0x40d9c7
push edi
call dword [sym.imp.MSVCR71.dll_fclose]
add esp, 4
pop edi
pop esi
pop ebx
xor eax, eax
pop ebp
pop ecx
ret 0xc
push 0xa000
xor edi, edi
call sub.MFC71.DLL_operator_new
mov esi, eax
mov eax, dword [ebp + 0x276]
add esp, 4
test eax, eax
jbe 0x40da2a
mov eax, dword [ebp + 0x276]
sub eax, edi
cmp eax, 0xa000
jbe 0x40d9f6
mov eax, 0xa000
mov edx, dword [esp + 0x10]
push edx
push eax
push 1
push esi
call dword [sym.imp.MSVCR71.dll_fread]
add esp, 0x10
test eax, eax
je 0x40da2a
mov ecx, dword [esp + 0x18]
push ecx
push 1
push eax
push esi
add edi, eax
call dword [sym.imp.MSVCR71.dll_fwrite]
mov eax, dword [ebp + 0x276]
add esp, 0x10
cmp edi, eax
jb 0x40d9e2
mov edx, dword [esp + 0x18]
mov edi, dword [sym.imp.MSVCR71.dll_fclose]
push edx
call edi
mov eax, dword [esp + 0x14]
push eax
call edi
push esi
call sub.MSVCR71.dll_free
add esp, 0xc
jmp 0x40da74
mov edx, dword [ebp + 0x276]
mov eax, dword [esp + 0x1c]
push esi
mov esi, dword [esp + 0x14]
push edx
push eax
push esi
mov ecx, ebp
call fcn.0040d400
test al, al
push esi
je 0x40d866
call dword [sym.imp.MSVCR71.dll_fclose]
add esp, 4
mov esi, dword [ebp + 0x2cc]
add esi, 0x2e
mov dword [ebp + 0x2cc], esi
movzx ecx, word [ebx + 0x1e]
mov eax, esi
add eax, ecx
mov dword [ebp + 0x2cc], eax
movzx edx, word [ebx + 0x1c]
add eax, edx
mov dword [ebp + 0x2cc], eax
movzx ecx, word [ebx + 0x20]
add ecx, eax
mov eax, dword [ebp + 4]
pop edi
pop esi
inc eax
mov dword [ebp + 4], eax
pop ebx
mov dword [ebp + 0x2cc], ecx
mov eax, 1
pop ebp
pop ecx
ret 0xc