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

Disassembly:
push 0xffffffffffffffff
push 0x537328
mov eax, dword fs:[0]
push eax
sub esp, 0x30
push ebx
push ebp
push esi
push edi
mov eax, dword [0x58a710]
xor eax, esp
push eax
lea eax, [esp + 0x44]
mov dword fs:[0], eax
mov edi, ecx
lea ebx, [edi + 0x18]
mov ecx, ebx
mov dword [esp + 0x24], ebx
call fcn.00404210
mov eax, dword [edi + 4]
mov ecx, 0x568d00
test al, 0x40
je 0x40d88a
mov ecx, 0x568d08
jmp 0x40d893
test al, 0x20
je 0x40d893
mov ecx, 0x568d10
mov eax, dword [esp + 0x54]
push ecx
xor ebp, ebp
push eax
mov dword [edi], ebp
call fcn.0050f44b
add esp, 8
mov dword [edi], eax
cmp eax, ebp
jne 0x40d8fe
lea edi, [esp + 0x20]
call fcn.0040b340
push eax
mov ecx, ebx
mov dword [esp + 0x50], ebp
call fcn.00405700
mov dword [esp + 0x4c], 0xffffffff
mov eax, dword [esp + 0x20]
add eax, 0xfffffff0
lea ecx, [eax + 0xc]
or edx, 0xffffffff
lock xadd dword [ecx], edx
dec edx
test edx, edx
jg 0x40d8e8
mov ecx, dword [eax]
mov edx, dword [ecx]
push eax
mov eax, dword [edx + 4]
call eax
xor al, al
mov ecx, dword [esp + 0x44]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x3c
ret
mov ecx, dword [edi + 4]
mov byte [esp + 0x1b], 1
test cl, 0x10
je 0x40daf2
push 2
push ebp
push eax
call fcn.0050f4ec
mov ecx, dword [edi]
push ecx
call fcn.0050f70e
mov edx, dword [edi]
push ebp
push ebp
push edx
mov dword [edi + 8], eax
call fcn.0050f4ec
mov eax, dword [edi + 8]
mov esi, 0x400
add esp, 0x1c
cmp eax, esi
jge 0x40d946
mov esi, eax
test esi, esi
je 0x40db39
push esi
call fcn.004107fa
mov ebx, eax
mov eax, dword [edi]
push eax
push 1
push esi
push ebx
mov dword [esp + 0x30], ebx
call fcn.0050fa1c
add esp, 0x14
cmp eax, 1
sete al
mov byte [esp + 0x1b], al
test al, al
je 0x40dae0
and dword [edi + 4], 0xfffffffa
xor ecx, ecx
mov dword [edi + 0x10], 1
cmp dword [0x58c688], ecx
je 0x40d9fe
xor eax, eax
lea ebx, [ebx]
mov edx, dword [eax + 0x58c68c]
test edx, edx
jle 0x40d9bb
cmp ebp, esi
jge 0x40d9bb
mov ebx, dword [esp + 0x1c]
mov edx, dword [eax + 0x58c688]
mov bl, byte [ebx + ebp]
cmp bl, byte [edx + ebp]
mov edx, dword [eax + 0x58c68c]
jne 0x40d9bb
inc ebp
cmp ebp, edx
jl 0x40d99a
cmp ebp, edx
je 0x40d9d1
inc ecx
mov eax, ecx
xor ebp, ebp
shl eax, 4
cmp dword [eax + 0x58c688], ebp
jne 0x40d990
jmp 0x40d9fa
shl ecx, 4
mov eax, dword [ecx + 0x58c694]
or eax, dword [edi + 4]
sub dword [edi + 8], ebp
mov dword [edi + 4], eax
cmp ebp, 2
jne 0x40d9eb
mov dword [edi + 0x10], ebp
mov ecx, dword [ecx + 0x58c690]
push ecx
lea ecx, [edi + 0x1c]
call fcn.00404370
mov ebx, dword [esp + 0x1c]
cmp esi, ebp
jle 0x40da10
mov edx, dword [edi]
push 0
push ebp
push edx
call fcn.0050f4ec
add esp, 0xc
test ebp, ebp
jne 0x40dac5
lea ecx, [esp + 0x1c]
call fcn.00404b60
push esi
push ebx
push ecx
mov dword [esp + 0x58], 1
mov eax, esp
mov dword [esp + 0x2c], esp
push ecx
mov dword [eax], str.UTF_8
mov eax, esp
mov dword [eax], str.UTF_16
lea eax, [esp + 0x38]
mov dword [esp + 0x30], esp
push eax
call fcn.0040e2b0
push esi
lea ecx, [esp + 0x20]
mov byte [esp + 0x50], 2
call fcn.00404810
push eax
lea ecx, [esp + 0x2c]
push ecx
mov dword [esp + 0x40], esi
call fcn.0040d560
add esp, 8
push eax
lea ecx, [esp + 0x20]
call fcn.0040a630
mov edx, dword [esp + 0x1c]
push ecx
mov eax, esp
mov dword [esp + 0x24], esp
mov dword [eax], edx
lea eax, [esp + 0x24]
push eax
call fcn.0040aff0
add esp, 8
lea ecx, [edi + 0x1c]
push eax
mov byte [esp + 0x50], 3
call fcn.00405700
lea ecx, [esp + 0x20]
call fcn.00404b40
lea esi, [esp + 0x28]
call fcn.0040dc00
lea ecx, [esp + 0x1c]
mov dword [esp + 0x4c], 0xffffffff
call fcn.00404b40
mov edx, dword [edi + 0x1c]
cmp dword [edx - 0xc], 0
lea ecx, [edi + 0x1c]
jne 0x40dae0
cmp byte [ebx], 0x3c
jne 0x40dae0
push str.UTF_8
call fcn.00404370
push ebx
call fcn.004107ef
mov ebx, dword [esp + 0x28]
add esp, 4
jmp 0x40dbc0
test cl, 0x20
je 0x40db39
mov dword [edi + 0x10], 1
test cl, 0x40
je 0x40db0f
push eax
call fcn.0050f70e
add esp, 4
mov dword [edi + 8], eax
cmp dword [edi + 8], ebp
jne 0x40db39
xor ecx, ecx
cmp dword [0x58c688], ebp
je 0x40db39
mov edx, dword [edi + 4]
xor eax, eax
test dword [eax + 0x58c694], edx
jne 0x40db81
inc ecx
mov eax, ecx
shl eax, 4
cmp dword [eax + 0x58c688], ebp
jne 0x40db23
mov ecx, dword [edi + 0x1c]
add edi, 0x1c
cmp dword [ecx - 0xc], 0
je 0x40db69
push edi
mov ecx, ebx
call fcn.00405700
test ebp, ebp
je 0x40db5d
push str._BOM_
mov ecx, ebx
call fcn.0040a5f0
push 0x564d58
mov ecx, ebx
call fcn.0040a5f0
mov al, byte [esp + 0x1b]
mov ecx, dword [esp + 0x44]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x3c
ret
shl ecx, 4
mov esi, ecx
mov ebp, dword [esi + 0x58c68c]
cmp ebp, 2
jne 0x40dba3
mov dword [edi + 0x10], ebp
mov eax, dword [esi + 0x58c690]
push eax
lea ecx, [edi + 0x1c]
call fcn.00404370
mov ecx, dword [edi]
mov edx, dword [esi + 0x58c688]
push ecx
push 1
push ebp
push edx
call fcn.0050fb9b
add esp, 0x10
cmp eax, 1
sete byte [esp + 0x1b]
cmp byte [esp + 0x1b], 0
jne 0x40db39
lea edi, [esp + 0x24]
call fcn.0040b340
push eax
mov ecx, ebx
mov dword [esp + 0x50], 4
call fcn.00405700
mov dword [esp + 0x4c], 0xffffffff
mov eax, dword [esp + 0x24]
jmp 0x40d8cc