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

Disassembly:
push ebp
mov ebp, esp
sub esp, 0xc4c
push 0x423e40
mov eax, dword [ebp + 8]
mov cl, byte [eax]
push ecx
call fcn.0040b87f
add esp, 8
mov dword [ebp - 0xc2c], eax
cmp dword [ebp - 0xc2c], 0
jne 0x406998
or eax, 0xffffffff
jmp 0x406e8f
lea edx, [ebp - 0x824]
push edx
mov ax, word [0x41fa92]
push eax
call fcn.00410a87
add esp, 8
movsx ecx, word [0x424c70]
test ecx, ecx
je 0x4069be
jmp 0x406e8a
mov edx, dword [ebp + 8]
movsx eax, word [edx + 0x22]
test eax, eax
je 0x406c7d
mov ecx, dword [ebp - 0xc2c]
mov edx, dword [ecx + 0x24]
push edx
call fcn.00401c10
add esp, 4
movsx eax, ax
test eax, eax
je 0x406c7d
mov ecx, dword [ebp + 8]
mov edx, dword [ecx + 0x124]
push edx
push 1
movsx eax, word [0x41fa90]
push eax
lea ecx, [ebp - 0xc28]
push ecx
call dword [sym.imp.MSVCRT.dll_fread]
add esp, 0x10
mov word [ebp - 0x828], ax
movsx edx, word [ebp - 0x828]
test edx, edx
je 0x406a88
mov eax, dword [ebp - 0xc2c]
mov ecx, dword [eax + 0x24]
push ecx
lea edx, [ebp - 0xc28]
push edx
call fcn.004010c2
add esp, 8
movsx eax, ax
test eax, eax
je 0x406a56
push 0
push 0
push str.Error_writing_circular_buffer
call sub.MFC42.DLL_AfxMessageBox
or eax, 0xffffffff
jmp 0x406e8f
mov ecx, dword [ebp + 8]
mov dx, word [ecx + 0x128]
add dx, 1
mov eax, dword [ebp + 8]
mov word [eax + 0x128], dx
movsx ecx, word [0x41fa90]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x18]
sub eax, ecx
mov ecx, dword [ebp + 8]
mov dword [ecx + 0x18], eax
jmp 0x406c7d
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x124]
mov ecx, dword [eax + 0xc]
and ecx, 0x20
test ecx, ecx
je 0x406afa
lea edx, [ebp - 0x824]
push edx
call dword [sym.imp.MSVCRT.dll__errno]
mov eax, dword [eax]
push eax
call fcn.00406410
add esp, 4
push eax
call fcn.0041097c
add esp, 8
lea ecx, [ebp - 0x824]
push ecx
push str.error_4
call fcn.0041097c
add esp, 8
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x124]
push eax
call dword [sym.imp.MSVCRT.dll_fclose]
add esp, 4
mov ecx, dword [ebp + 8]
mov word [ecx + 0x22], 0
push 0
push 0
push str.File_reading_failure
call sub.MFC42.DLL_AfxMessageBox
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x124]
mov ecx, dword [eax + 0xc]
and ecx, 0x10
test ecx, ecx
je 0x406c7d
mov edx, dword [ebp - 0xc2c]
mov eax, dword [edx + 0x24]
push eax
lea ecx, [ebp - 0xc28]
push ecx
mov edx, dword [ebp + 8]
mov ax, word [edx + 0x18]
push eax
call fcn.004013be
add esp, 0xc
movsx ecx, ax
test ecx, ecx
je 0x406b5b
lea edx, [ebp - 0x824]
push edx
push str.error_2
call fcn.0041097c
add esp, 8
push 0
push 0
push 0x41fb60
call sub.MFC42.DLL_AfxMessageBox
mov eax, dword [ebp + 8]
mov cx, word [eax + 0x128]
add cx, 1
mov edx, dword [ebp + 8]
mov word [edx + 0x128], cx
mov eax, dword [ebp - 0xc2c]
mov ecx, dword [eax + 0x24]
push ecx
call fcn.00401506
add esp, 4
mov edx, dword [ebp - 0xc2c]
mov eax, dword [edx + 0x24]
push eax
call fcn.00401ca7
add esp, 4
mov ecx, dword [ebp + 8]
mov edx, dword [ecx + 0x124]
push edx
call dword [sym.imp.MSVCRT.dll_fclose]
add esp, 4
test eax, eax
je 0x406bf1
lea eax, [ebp - 0x824]
push eax
call dword [sym.imp.MSVCRT.dll__errno]
mov ecx, dword [eax]
push ecx
call fcn.00406410
add esp, 4
push eax
call fcn.0041097c
add esp, 8
lea edx, [ebp - 0x824]
push edx
push str.error_3
call fcn.0041097c
add esp, 8
push 0
push 0
push str.Closing_failure
call sub.MFC42.DLL_AfxMessageBox
mov word [0x424c70], 1
or eax, 0xffffffff
jmp 0x406e8f
mov eax, dword [ebp - 0xc2c]
cmp dword [eax + 8], 0x12
jne 0x406c19
mov word [0x424c70], 0
jmp 0x406c23
mov eax, 0xfffffffe
jmp 0x406e8f
mov ecx, dword [ebp + 8]
mov word [ecx + 0x22], 0
mov byte [ebp - 0xc3c], 0
mov byte [ebp - 0xc3b], 0x1a
mov edx, dword [ebp + 8]
mov al, byte [edx]
mov byte [ebp - 0xc3a], al
mov byte [ebp - 0xc39], 4
push 4
lea ecx, [ebp - 0xc3c]
push ecx
call fcn.00402610
mov ecx, eax
call fcn.00409b80
push 0
push 0x424c78
push 0x424c7c
mov edx, dword [ebp + 8]
mov al, byte [edx]
push eax
push 0x64
call fcn.00406f77
add esp, 0x14
mov ecx, dword [ebp + 8]
movsx edx, word [ecx + 0x20]
test edx, edx
je 0x406e4f
mov eax, dword [ebp - 0xc2c]
mov ecx, dword [eax + 0x24]
push ecx
call fcn.00401c1c
add esp, 4
mov word [ebp - 0xc30], ax
movsx edx, word [ebp - 0xc30]
test edx, edx
jle 0x406dd6
mov eax, dword [ebp - 0xc2c]
mov ecx, dword [eax + 0x24]
push ecx
lea edx, [ebp - 0xc28]
push edx
call fcn.00401572
add esp, 8
mov ecx, dword [ebp + 8]
xor edx, edx
mov dl, byte [ecx]
imul edx, edx, 0x318
cmp dword [edx + 0x42463c], 0
je 0x406d10
mov eax, dword [ebp + 8]
mov ecx, dword [eax + 0x124]
push ecx
push 1
movsx edx, word [0x41fa90]
push edx
lea eax, [ebp - 0xc28]
push eax
call dword [sym.imp.MSVCRT.dll_fwrite]
add esp, 0x10
mov word [ebp - 0x828], ax
jmp 0x406d6b
lea ecx, [ebp - 0xc28]
push ecx
call sub.MSVCRT.dll_strlen
add esp, 4
mov dword [ebp - 0xc40], eax
movsx edx, word [0x41fa90]
cmp dword [ebp - 0xc40], edx
jbe 0x406d41
movsx eax, word [0x41fa90]
mov dword [ebp - 0xc40], eax
mov ecx, dword [ebp + 8]
mov edx, dword [ecx + 0x124]
push edx
push 1
mov eax, dword [ebp - 0xc40]
push eax
lea ecx, [ebp - 0xc28]
push ecx
call dword [sym.imp.MSVCRT.dll_fwrite]
add esp, 0x10
mov word [ebp - 0x828], ax
movsx edx, word [ebp - 0x828]
cmp edx, 1
je 0x406dbc
lea eax, [ebp - 0x824]
push eax
call dword [sym.imp.MSVCRT.dll__errno]
mov ecx, dword [eax]
push ecx
call fcn.00406410
add esp, 4
push eax
call fcn.0041097c
add esp, 8
lea edx, [ebp - 0x824]
push edx
push str.error_10
call fcn.0041097c
add esp, 8
push 0
push 0
push str.Writing_failure
call sub.MFC42.DLL_AfxMessageBox
jmp 0x406dd4
mov eax, dword [ebp + 8]
mov cx, word [eax + 0x12a]
add cx, 1
mov edx, dword [ebp + 8]
mov word [edx + 0x12a], cx
jmp 0x406e4f
movsx eax, word [ebp - 0xc30]
cmp eax, 0xfffffffd
jne 0x406e4f
mov ecx, dword [ebp + 8]
mov edx, dword [ecx + 0x124]
push edx
call dword [sym.imp.MSVCRT.dll_fclose]
add esp, 4
mov eax, dword [ebp + 8]
mov word [eax + 0x20], 0
mov byte [ebp - 0xc4c], 0
mov byte [ebp - 0xc4b], 0x1a
mov ecx, dword [ebp + 8]
mov dl, byte [ecx]
mov byte [ebp - 0xc4a], dl
mov byte [ebp - 0xc49], 4
push 4
lea eax, [ebp - 0xc4c]
push eax
call fcn.00402610
mov ecx, eax
call fcn.00409b80
push 0
push 0x424c80
push 0x424c84
mov ecx, dword [ebp + 8]
mov dl, byte [ecx]
push edx
push 0x64
call fcn.00406f77
add esp, 0x14
mov eax, dword [ebp + 8]
movsx ecx, word [eax + 0x20]
test ecx, ecx
jne 0x406e86
mov edx, dword [ebp + 8]
movsx eax, word [edx + 0x22]
test eax, eax
jne 0x406e86
mov byte [ebp - 4], 0x64
mov ecx, dword [ebp + 8]
mov dl, byte [ecx]
mov byte [ebp - 3], dl
mov byte [ebp - 2], 0
lea eax, [ebp - 4]
push eax
push 0x423288
call fcn.004067d6
add esp, 8
xor eax, eax
jmp 0x406e8f
jmp 0x406c02
mov esp, ebp
pop ebp
ret