Function at 0x406970
Capabilities:
Read file on windows
Read pipe
Write file on windows

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
mov eax, 0x10014
call fcn.0045ba30
mov eax, dword [0x46c00c]
xor eax, esp
mov dword [esp + 0x10010], eax
mov eax, dword [ebp + 8]
push ebx
push esi
push edi
mov edi, ecx
mov dword [esp + 0xc], eax
mov eax, dword [edi + 4]
cmp eax, 3
je case.0x406acd.4
cmp eax, 1
jne 0x406db6
mov ebx, dword [sym.imp.KERNEL32.dll_CloseHandle]
mov esi, dword [edi]
test esi, esi
je 0x406d46
mov eax, dword [esi + 4]
cmp eax, 0xffffffff
je 0x406d46
push 0
lea ecx, [esp + 0x10018]
mov dword [esp + 0x10018], 0
push ecx
push 0
push 0
push 0
push eax
call dword [sym.imp.KERNEL32.dll_PeekNamedPipe]
test eax, eax
je 0x406d37
cmp dword [esp + 0x10014], 8
jb 0x406d46
push 0
lea eax, [esp + 0x1001c]
mov dword [esp + 0x1001c], 0
push eax
push 8
lea eax, [esp + 0x1c]
push eax
push dword [esi + 4]
call dword [sym.imp.KERNEL32.dll_ReadFile]
cmp eax, 1
jne 0x406d37
mov ebx, dword [esp + 0x14]
test ebx, ebx
je 0x406ac0
mov esi, dword [edi]
test esi, esi
je 0x406b84
mov eax, dword [esi + 4]
cmp eax, 0xffffffff
je 0x406b84
push 0
lea ecx, [esp + 0x10018]
mov dword [esp + 0x10018], 0
push ecx
push 0
push 0
push 0
push eax
call dword [sym.imp.KERNEL32.dll_PeekNamedPipe]
test eax, eax
je 0x406b70
cmp dword [esp + 0x10014], ebx
jb 0x406b84
push 0
lea eax, [esp + 0x1001c]
mov dword [esp + 0x1001c], 0
push eax
push ebx
lea eax, [esp + 0x24]
push eax
push dword [esi + 4]
call dword [sym.imp.KERNEL32.dll_ReadFile]
cmp eax, 1
jne 0x406b70
mov eax, dword [esp + 0x14]
mov byte [esp + eax + 0x18], 0
mov ebx, dword [esp + 0x14]
mov eax, dword [esp + 0x10]
cmp eax, 4
ja case.0x406acd.0
jmp dword [eax*4 + 0x406dd0]
mov dword [esp + 0x10], 4
add ebx, 8
je case.0x406acd.4
mov eax, dword [edi]
test eax, eax
je 0x406b2d
mov eax, dword [eax + 4]
cmp eax, 0xffffffff
je 0x406b2d
push 0
lea ecx, [esp + 0x10018]
mov dword [esp + 0x10018], 0
push ecx
push ebx
lea ecx, [esp + 0x1c]
push ecx
push eax
call dword [sym.imp.KERNEL32.dll_WriteFile]
cmp eax, 1
jne 0x406b2d
cmp dword [esp + 0x10014], ebx
mov ebx, dword [sym.imp.KERNEL32.dll_CloseHandle]
je 0x4069b1
mov ecx, dword [edi + 0xc]
test ecx, ecx
je 0x406b4d
mov eax, dword [edi + 4]
cmp eax, 3
je 0x406b41
cmp eax, 1
jne 0x406b4d
lea eax, [edi + 0x54]
push eax
push dword [edi + 0x50]
call ecx
add esp, 8
mov esi, dword [edi]
mov ebx, dword [sym.imp.KERNEL32.dll_CloseHandle]
push dword [esi + 4]
call ebx
mov dword [esi + 4], 0xffffffff
mov byte [esi], 0
mov dword [edi + 4], 0
jmp 0x4069b1
push dword [esi + 4]
mov eax, dword [sym.imp.KERNEL32.dll_CloseHandle]
call eax
mov byte [esi], 0
mov dword [esi + 4], 0xffffffff
mov ecx, str.Partial_data_in_frame
mov dword [edi + 0x50], 2
lea ebx, [edi + 0x54]
mov esi, 1
mov edx, ebx
sub esi, ecx
nop dword [eax]
lea eax, [esi + ecx]
cmp eax, 0x100
jae 0x406d7a
mov al, byte [ecx]
inc ecx
mov byte [edx], al
inc edx
cmp byte [ecx], 0
jne 0x406ba0
jmp 0x406d7a
mov ebx, dword [esp + 0xc]
lea eax, [esp + 0x18]
push eax
mov ecx, ebx
call fcn.00406df0
test ebx, ebx
je 0x406c19
push str.code
lea eax, [esp + 0x10018]
mov dword [esp + 0x10018], 0
push eax
mov ecx, ebx
call fcn.00405ed0
mov ecx, dword [ebx]
lea esi, [ebx + 8]
mov eax, dword [esp + 0x10014]
shl ecx, 5
add ecx, dword [esi]
cmp eax, ecx
je 0x406c19
mov cl, byte [eax + 0x1e]
shr cl, 5
test cl, 1
je 0x406c19
mov eax, dword [eax + 0x10]
mov dword [edi + 0x50], eax
jmp 0x406c27
mov dword [edi + 0x50], 0
lea esi, [ebx + 8]
test ebx, ebx
je 0x406c81
push str.message
lea eax, [esp + 0x10018]
mov dword [esp + 0x10018], 0
push eax
mov ecx, ebx
call fcn.00405ed0
mov ecx, dword [ebx]
mov eax, dword [esp + 0x10014]
shl ecx, 5
add ecx, dword [esi]
cmp eax, ecx
je 0x406c81
mov cx, word [eax + 0x1e]
shr cx, 0xa
test cl, 1
je 0x406c81
lea ecx, [eax + 0x10]
mov eax, 0x1000
test word [ecx + 0xe], ax
jne 0x406c76
mov ecx, dword [ecx + 8]
lea ebx, [edi + 0x54]
mov eax, ecx
test ecx, ecx
je 0x406cb8
jmp 0x406c8b
mov eax, 0x45d85f
lea ebx, [edi + 0x54]
mov ecx, eax
cmp byte [eax], 0
mov edx, ebx
je 0x406cb5
mov esi, 1
sub esi, eax
nop dword [eax]
lea eax, [esi + ecx]
cmp eax, 0x100
jae 0x406cb5
mov al, byte [ecx]
inc ecx
mov byte [edx], al
inc edx
cmp byte [ecx], 0
jne 0x406ca0
mov byte [edx], 0
mov eax, dword [edi + 0xc]
test eax, eax
je 0x406d9a
mov ecx, dword [edi + 4]
cmp ecx, 3
je 0x406cd4
cmp ecx, 1
jne 0x406d9a
push ebx
push dword [edi + 0x50]
call eax
jmp 0x406d97
mov ecx, dword [esp + 0xc]
lea eax, [esp + 0x18]
push eax
call fcn.00406df0
mov al, 1
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x10010]
xor ecx, esp
call fcn.0045a66e
mov esp, ebp
pop ebp
ret 4
mov ecx, str.Bad_ipc_frame
mov dword [edi + 0x50], 2
lea ebx, [edi + 0x54]
mov esi, 1
mov edx, ebx
sub esi, ecx
nop
lea eax, [esi + ecx]
cmp eax, 0x100
jae 0x406d7a
mov al, byte [ecx]
inc ecx
mov byte [edx], al
inc edx
cmp byte [ecx], 0
jne 0x406d20
jmp 0x406d7a
push dword [esi + 4]
call ebx
mov byte [esi], 0
mov dword [esi + 4], 0xffffffff
mov eax, dword [edi]
cmp byte [eax], 0
jne 0x406db6
lea ebx, [edi + 0x54]
mov dword [edi + 0x50], 1
mov ecx, str.Pipe_closed
mov esi, 1
mov edx, ebx
sub esi, ecx
lea eax, [esi + ecx]
cmp eax, 0x100
jae 0x406d7a
mov al, byte [ecx]
inc ecx
mov byte [edx], al
inc edx
cmp byte [ecx], 0
jne 0x406d65
mov byte [edx], 0
mov ecx, dword [edi + 0xc]
test ecx, ecx
je 0x406d9a
mov eax, dword [edi + 4]
cmp eax, 3
je 0x406d91
cmp eax, 1
jne 0x406d9a
push ebx
push dword [edi + 0x50]
call ecx
add esp, 8
mov esi, dword [edi]
push dword [esi + 4]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov dword [esi + 4], 0xffffffff
mov byte [esi], 0
mov dword [edi + 4], 0
mov ecx, dword [esp + 0x1001c]
xor al, al
pop edi
pop esi
pop ebx
xor ecx, esp
call fcn.0045a66e
mov esp, ebp
pop ebp
ret 4