Function at 0x40864d
Capabilities:
Execute command
Query environment variable
Read file on windows
Write and execute a file
Write file on windows

Disassembly:
push r14
push r13
push r12
push rbp
push rdi
push rsi
push rbx
sub rsp, 0x40
cmp edx, 2
mov rsi, rcx
mov rbx, r8
mov qword [rsp + 0x30], 0
jne 0x40867a
mov rcx, qword [r8 + 8]
call sym.sqlite3_value_text
jmp 0x408686
lea rcx, str.VISUAL
call sym.getenv
lea rdx, str.no_editor_for_edit__
or r8d, 0xffffffff
test rax, rax
mov r14, rax
je 0x4086b1
mov rcx, qword [rbx]
call sym.sqlite3_value_type
cmp eax, 5
jne 0x4086be
lea rdx, str.NULL_input_to_edit__
or r8d, 0xffffffff
mov rcx, rsi
call sym.sqlite3_result_error
jmp 0x40898b
mov rcx, rsi
call sym.sqlite3_context_db_handle
xor edx, edx
mov r8d, 0x10
mov qword [rsp + 0x30], 0
lea r9, [rsp + 0x30]
mov rcx, rax
call sym.sqlite3_file_control
cmp qword [rsp + 0x30], 0
jne 0x40872c
lea rdx, [rsp + 0x38]
mov ecx, 8
mov qword [rsp + 0x38], 0
call sym.sqlite3_randomness
mov rdx, qword [rsp + 0x38]
lea rcx, str.temp_llx
call sym.sqlite3_mprintf
test rax, rax
mov qword [rsp + 0x30], rax
jne 0x40872c
mov rcx, rsi
call sym.sqlite3_result_error_nomem
jmp 0x40898b
mov rcx, qword [rbx]
call sym.sqlite3_value_type
mov rcx, qword [rsp + 0x30]
lea rdx, [0x004d4486]
cmp eax, 4
mov r13d, eax
lea rax, [0x004d483f]
cmovne rdx, rax
call sym.fopen
lea rdx, str.edit___cannot_open_temp_file
or r8d, 0xffffffff
test rax, rax
mov rbp, rax
je 0x40886b
mov rcx, qword [rbx]
call sym.sqlite3_value_bytes
cmp r13d, 4
mov rcx, qword [rbx]
movsxd rdi, eax
jne 0x4087a1
call sym.sqlite3_value_blob
mov r9, rbp
mov r8, rdi
mov edx, 1
mov rcx, rax
xor r12d, r12d
call sym.fwrite
mov rbx, rax
jmp 0x4087e5
call sym.sqlite3_value_text
xor r12d, r12d
test rax, rax
je 0x4087c7
lea rdx, [0x004d4898]
mov rcx, rax
xor r12d, r12d
call sym.strstr
test rax, rax
setne r12b
mov rcx, qword [rbx]
call sym.sqlite3_value_text
mov r9, rbp
mov r8, rdi
mov edx, 1
mov rcx, rax
call sym.fwrite
mov rbx, rax
mov rcx, rbp
call sym.fclose
lea rdx, str.edit___could_not_write_the_whole_file
or r8d, 0xffffffff
cmp rbx, rdi
jne 0x40886b
mov r8, qword [rsp + 0x30]
lea rcx, str._s___s_
mov rdx, r14
call sym.sqlite3_mprintf
test rax, rax
mov rbx, rax
jne 0x408826
mov rcx, rsi
call sym.sqlite3_result_error_nomem
jmp 0x40896d
mov rcx, rax
call sym.system
mov rcx, rbx
mov edi, eax
call sym.sqlite3_free
lea rdx, str.EDITOR_returned_non_zero
or r8d, 0xffffffff
test edi, edi
jne 0x40886b
mov rcx, qword [rsp + 0x30]
lea rdx, [0x004d4489]
call sym.fopen
test rax, rax
mov rbp, rax
jne 0x408878
lea rdx, str.edit___cannot_reopen_temp_file_after_edit
or r8d, 0xffffffff
mov rcx, rsi
call sym.sqlite3_result_error
jmp 0x40896b
xor edx, edx
mov r8d, 2
mov rcx, rax
call sym.fseek
mov rcx, rbp
call sym.ftell
mov rcx, rbp
movsxd rdi, eax
call sym.rewind
lea rcx, [rdi + 1]
call sym.sqlite3_malloc64
test rax, rax
mov rbx, rax
jne 0x4088c1
mov rcx, rsi
call sym.sqlite3_result_error_nomem
mov rcx, rbp
call sym.fclose
jmp 0x40896d
mov r9, rbp
mov r8, rdi
mov edx, 1
mov rcx, rax
call sym.fread
mov rcx, rbp
mov r14, rax
call sym.fclose
cmp rdi, r14
je 0x4088f9
lea rdx, str.could_not_read_back_the_whole_file
or r8d, 0xffffffff
mov rcx, rsi
call sym.sqlite3_result_error
jmp 0x40896d
cmp r13d, 4
jne 0x408916
lea r9, [sym.sqlite3_free]
mov r8, rdi
mov rdx, rbx
mov rcx, rsi
call sym.sqlite3_result_blob64
jmp 0x40896b
test r12d, r12d
jne 0x40894e
mov byte [rbx + rdi], 0
xor edx, edx
xor eax, eax
cmp rax, rdi
jge 0x408947
cmp byte [rbx + rax], 0xd
jne 0x408938
cmp byte [rbx + rax + 1], 0xa
jne 0x408938
inc rax
mov cl, byte [rbx + rax]
inc rdx
inc rax
mov byte [rbx + rdx - 1], cl
jmp 0x408923
mov byte [rbx + rdx], 0
mov rdi, rdx
mov dword [rsp + 0x20], 1
lea r9, [sym.sqlite3_free]
mov r8, rdi
mov rdx, rbx
mov rcx, rsi
call sym.sqlite3_result_text64
xor ebx, ebx
mov rcx, qword [rsp + 0x30]
call qword [sym.imp.msvcrt.dll__unlink]
mov rcx, qword [rsp + 0x30]
call sym.sqlite3_free
mov rcx, rbx
call sym.sqlite3_free
nop
add rsp, 0x40
pop rbx
pop rsi
pop rdi
pop rbp
pop r12
pop r13
pop r14
ret