Function at 0x14003840c
Capabilities:
Read file on windows

Disassembly:
mov qword [rsp + 0x20], rbx
push rbp
push rsi
push rdi
push r12
push r13
push r14
push r15
lea rbp, [rsp - 0x2390]
mov eax, 0x2490
call fcn.140056270
sub rsp, rax
mov rax, qword [0x14006d678]
xor rax, rsp
mov qword [rbp + 0x2380], rax
mov rdi, rdx
mov dword [rsp + 0x38], r9d
mov rsi, rcx
mov qword [rsp + 0x48], r8
xor ecx, ecx
lea rdx, [0x140000000]
mov r13d, r9d
mov r15, r8
cmp dword [rdi + 0x24], ecx
je 0x14003846b
lea ebx, [rcx + 2]
jmp 0x140038476
movsxd rax, dword [rdi + 0x28]
mov ebx, dword [rdx + rax*4 + 0x5f9e0]
mov dword [rsp + 0x3c], ecx
mov r12d, ecx
movsxd rcx, dword [rdi + 0x70]
lea eax, [rcx - 1]
cmp eax, 1
ja 0x1400384a0
mov r8, qword [rdx + rcx*8 + 0x6c2a8]
lea rdx, str.cannot_read_on_a_File_opened_in__s_mode
mov rcx, rsi
call sym.wluart_static.exe_luaL_error
lea rdx, [rsp + 0x60]
mov rcx, rsi
call sym.wluart_static.exe_luaL_buffinit
xor eax, eax
cmp dword [rdi + 0x24], eax
je 0x140038716
mov ecx, 0xfffffff6
call qword [sym.imp.KERNEL32.dll_GetStdHandle]
mov rcx, rsi
mov qword [rsp + 0x50], rax
call fcn.1400258e4
mov r8d, dword [sym.wluart_static.exe_TFile]
or edx, 0xffffffff
mov rcx, rsi
call sym.wluart_static.exe_lua_toself
mov edx, 0xfffffffe
mov rcx, rsi
mov r14, qword [rax + 8]
call sym.wluart_static.exe_lua_settop
cmp word [0x14006d988], r12w
jne 0x140038599
test r13d, r13d
je 0x140038599
mov rcx, qword [rdi + 8]
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__fileno]
mov ecx, eax
mov edx, 0x20000
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__setmode]
mov r8, qword [rdi + 8]
lea rcx, [rbp + 0x380]
mov edx, 0x1000
mov ebx, eax
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fgetws]
test rax, rax
je 0x14003857d
lea rax, [rbp + 0x380]
or r8, 0xffffffffffffffff
inc r8
cmp word [rax + r8*2], r12w
jne 0x140038549
lea r8, [r8*2 - 2]
lea rdx, [rbp + 0x380]
lea rcx, [rsp + 0x60]
call sym.wluart_static.exe_luaL_addlstring
mov rcx, qword [rdi + 8]
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__fileno]
mov edx, ebx
jmp 0x140038709
lea rdx, [0x140059530]
mov rcx, rsi
call sym.wluart_static.exe_lua_pushstring
mov rcx, rsi
call sym.wluart_static.exe_lua_error
jmp 0x14003883c
mov rcx, r14
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__fileno]
mov ecx, eax
mov edx, 0x20000
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__setmode]
mov rcx, qword [rdi + 0x18]
lea rdx, [rsp + 0x40]
mov dword [rsp + 0x44], eax
call qword [sym.imp.KERNEL32.dll_GetConsoleMode]
mov edx, dword [rsp + 0x40]
mov ebx, eax
mov rcx, qword [rdi + 0x18]
and edx, 0xfffffff8
call qword [sym.imp.KERNEL32.dll_SetConsoleMode]
xor edx, edx
test ebx, ebx
sete r12b
lea ebx, [rdx + 0xd]
mov rcx, qword [rdi + 0x18]
test r12, r12
je 0x140038606
mov qword [rsp + 0x20], rdx
lea r9, [rsp + 0x3c]
lea rdx, [rsp + 0x30]
mov r8d, 2
call qword [sym.imp.KERNEL32.dll_ReadFile]
jmp 0x140038621
mov qword [rsp + 0x20], rdx
lea r9, [rsp + 0x3c]
lea rdx, [rsp + 0x30]
mov r8d, 1
call qword [sym.imp.KERNEL32.dll_ReadConsoleW]
movzx ecx, word [rsp + 0x30]
xor edx, edx
test r13d, r13d
je 0x140038636
cmp cx, bx
je 0x1400386ed
mov eax, 3
cmp cx, ax
jne 0x14003865e
lea rdx, [0x14005fe4c]
mov rcx, rsi
call sym.wluart_static.exe_lua_pushstring
mov rcx, rsi
call sym.wluart_static.exe_lua_error
movzx ecx, word [rsp + 0x30]
xor edx, edx
test r12, r12
jne 0x1400386c3
cmp cx, 8
jne 0x1400386a3
mov rax, qword [rsp + 0x70]
test rax, rax
je 0x1400386a3
sub rax, 2
inc r15
cmp word [0x14006d988], dx
mov qword [rsp + 0x70], rax
je 0x14003869a
mov rdx, r14
lea rcx, [0x14005fe50]
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fputws]
xor edx, edx
mov rcx, qword [rdi + 0x18]
jmp 0x140038606
movzx eax, word [0x14006d988]
test ax, ax
je 0x1400386b4
movzx ecx, ax
jmp 0x1400386ba
cmp cx, 0x1f
jbe 0x1400386c3
mov rdx, r14
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fputwc]
mov r8d, 2
lea rdx, [rsp + 0x30]
lea rcx, [rsp + 0x60]
call sym.wluart_static.exe_luaL_addlstring
xor edx, edx
test r13d, r13d
jne 0x1400385e0
sub r15, 1
jne 0x1400385e0
mov edx, dword [rsp + 0x40]
mov rcx, qword [rsp + 0x50]
call qword [sym.imp.KERNEL32.dll_SetConsoleMode]
mov rcx, r14
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__fileno]
mov edx, dword [rsp + 0x44]
mov ecx, eax
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll__setmode]
jmp 0x14003883c
mov r9, qword [rdi + 8]
test r9, r9
je 0x14003882d
movsxd r14, ebx
lea rcx, [rsp + 0x34]
mov rdx, r14
mov r8d, 1
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
xor edx, edx
test rax, rax
je 0x14003883c
lea ecx, [rdx + 0xd]
lea r8d, [rdx + 3]
mov eax, dword [rsp + 0x34]
mov r10d, 1
cmp dword [rdi + 0x28], r10d
jne 0x1400387af
movzx ecx, al
mov edx, 0xe5000000
shr ecx, 3
and ecx, 0x1e
shr edx, cl
and edx, r8d
add edx, r10d
mov r13d, edx
cmp r13, r10
jbe 0x1400387a3
mov r9, qword [rdi + 8]
lea rcx, [rsp + 0x35]
dec rdx
mov r8d, r10d
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov r8d, r13d
lea rdx, [rsp + 0x34]
lea rcx, [rsp + 0x60]
call sym.wluart_static.exe_luaL_addlstring
jmp 0x1400387fc
mov r13d, dword [rsp + 0x38]
mov ecx, reloc.WS2_32.dll_listen
xor edx, edx
cmp ebx, 2
jne 0x1400387ba
cmp ax, 0xa
je 0x1400387c3
cmp ebx, r10d
jne 0x1400387d7
cmp al, 0xa
jne 0x1400387e0
cmp dword [rdi + 0x28], edx
je 0x1400387d2
cmp r12d, ecx
jne 0x1400387d2
sub qword [rsp + 0x70], r14
test r13d, r13d
jne 0x14003883c
movzx r12d, ax
cmp ebx, 2
je 0x1400387e4
movsx r12d, al
mov r8, r14
lea rdx, [rsp + 0x34]
lea rcx, [rsp + 0x60]
call sym.wluart_static.exe_luaL_addlstring
sub r15, 1
je 0x14003883c
mov r9, qword [rdi + 8]
lea rcx, [rsp + 0x34]
mov r8d, 1
mov rdx, r14
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov r13d, dword [rsp + 0x38]
xor edx, edx
lea ecx, [rdx + 0xd]
lea r8d, [rdx + 3]
test rax, rax
jne 0x14003874c
jmp 0x14003883c
lea rdx, str.could_not_read__File_is_not_open
mov rcx, rsi
call sym.wluart_static.exe_luaL_error
lea rcx, [rsp + 0x60]
call sym.wluart_static.exe_luaL_pushresult
xor eax, eax
cmp qword [rsp + 0x70], rax
jne 0x140038855
cmp dword [rsp + 0x38], eax
je 0x140038888
cmp dword [rdi + 0x28], 2
je 0x140038860
cmp dword [rdi + 0x24], eax
je 0x140038883
lea r8, [rsp + 0x48]
or edx, 0xffffffff
mov rcx, rsi
call sym.wluart_static.exe_lua_tolstring
mov r8, qword [rsp + 0x48]
mov rdx, rax
shr r8, 1
mov rcx, rsi
call sym.wluart_static.exe_lua_pushlwstring
mov eax, 1
mov rcx, qword [rbp + 0x2380]
xor rcx, rsp
call fcn.140056240
mov rbx, qword [rsp + 0x24e8]
add rsp, 0x2490
pop r15
pop r14
pop r13
pop r12
pop rdi
pop rsi
pop rbp
ret