iw9: disassembler & decompiler

This commit is contained in:
xensik 2022-11-16 13:52:26 +01:00
parent 17a0b789c4
commit ad29da7bf3
9 changed files with 4039 additions and 445 deletions

View File

@ -9,9 +9,8 @@
namespace xsk::gsc::iw9 namespace xsk::gsc::iw9
{ {
void context::init(build mode, read_cb_type callback) void context::init(build, read_cb_type callback)
{ {
compiler_.mode(mode);
resolver::init(callback); resolver::init(callback);
} }

View File

@ -11,6 +11,7 @@ namespace xsk::gsc::iw9
class context : public gsc::context class context : public gsc::context
{ {
iw9::disassembler disassembler_; iw9::disassembler disassembler_;
iw9::decompiler decompiler_;
public: public:
void init(build mode, read_cb_type callback); void init(build mode, read_cb_type callback);
@ -19,7 +20,7 @@ public:
auto assembler() -> gsc::assembler& { throw std::runtime_error("not impl"); } auto assembler() -> gsc::assembler& { throw std::runtime_error("not impl"); }
auto disassembler() -> gsc::disassembler& { return disassembler_; } auto disassembler() -> gsc::disassembler& { return disassembler_; }
auto compiler() -> gsc::compiler& { throw std::runtime_error("not impl"); } auto compiler() -> gsc::compiler& { throw std::runtime_error("not impl"); }
auto decompiler() -> gsc::decompiler& { throw std::runtime_error("not impl"); } auto decompiler() -> gsc::decompiler& { return decompiler_; }
}; };
} // namespace xsk::gsc::iw9 } // namespace xsk::gsc::iw9

3120
src/iw9/xsk/decompiler.cpp Normal file

File diff suppressed because it is too large Load Diff

101
src/iw9/xsk/decompiler.hpp Normal file
View File

@ -0,0 +1,101 @@
// Copyright 2022 xensik. All rights reserved.
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
namespace xsk::gsc::iw9
{
class decompiler : public gsc::decompiler
{
std::string filename_;
ast::program::ptr program_;
ast::decl_thread::ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<ast::node::ptr> stack_;
std::vector<block> blocks_;
bool in_waittill_;
public:
auto output() -> std::vector<std::uint8_t>;
void decompile(const std::string& file, std::vector<function::ptr>& funcs);
private:
void decompile_function(const function::ptr& func);
void decompile_instruction(const instruction::ptr& inst);
void decompile_expressions(const instruction::ptr& inst);
void decompile_statements(const ast::stmt_list::ptr& stmt);
void decompile_loops(const ast::stmt_list::ptr& stmt);
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_tuples(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse_end(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_inf(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_endon(const ast::stmt_endon::ptr& stmt, const block::ptr& blk);
void process_stmt_notify(const ast::stmt_notify::ptr& stmt, const block::ptr& blk);
void process_stmt_wait(const ast::stmt_wait::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);
void process_stmt_waittillmatch(const ast::stmt_waittillmatch::ptr& stmt, const block::ptr& blk);
void process_stmt_if(const ast::stmt_if::ptr& stmt, const block::ptr& blk);
void process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const block::ptr& blk);
void process_stmt_while(const ast::stmt_while::ptr& stmt, const block::ptr& blk);
void process_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block::ptr& blk);
void process_stmt_for(const ast::stmt_for::ptr& stmt, const block::ptr& blk);
void process_stmt_foreach(const ast::stmt_foreach::ptr& stmt, const block::ptr& blk);
void process_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::ptr& blk);
void process_stmt_cases(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_break(const ast::stmt_break::ptr& stmt, const block::ptr& blk);
void process_stmt_continue(const ast::stmt_continue::ptr& stmt, const block::ptr& blk);
void process_stmt_return(const ast::stmt_return::ptr& stmt, const block::ptr& blk);
void process_expr(ast::expr& expr, const block::ptr& blk);
void process_expr_assign(ast::expr_assign::ptr& expr, const block::ptr& blk);
void process_expr_increment(const ast::expr_increment::ptr& expr, const block::ptr& blk);
void process_expr_decrement(const ast::expr_decrement::ptr& expr, const block::ptr& blk);
void process_expr_ternary(const ast::expr_ternary::ptr& expr, const block::ptr& blk);
void process_expr_binary(const ast::expr_binary::ptr& expr, const block::ptr& blk);
void process_expr_and(const ast::expr_and::ptr& expr, const block::ptr& blk);
void process_expr_or(const ast::expr_or::ptr& expr, const block::ptr& blk);
void process_expr_complement(const ast::expr_complement::ptr& expr, const block::ptr& blk);
void process_expr_not(const ast::expr_not::ptr& expr, const block::ptr& blk);
void process_expr_call(const ast::expr_call::ptr& expr, const block::ptr& blk);
void process_expr_method(const ast::expr_method::ptr& expr, const block::ptr& blk);
void process_expr_call_pointer(const ast::expr_pointer::ptr& expr, const block::ptr& blk);
void process_expr_call_function(const ast::expr_function::ptr& expr, const block::ptr& blk);
void process_expr_method_pointer(const ast::expr_pointer::ptr& expr, ast::expr& obj, const block::ptr& blk);
void process_expr_method_function(const ast::expr_function::ptr& expr, ast::expr& obj, const block::ptr& blk);
void process_expr_arguments(const ast::expr_arguments::ptr& expr, const block::ptr& blk);
void process_expr_add_array(const ast::expr_add_array::ptr& expr, const block::ptr& blk);
void process_expr_size(const ast::expr_size::ptr& expr, const block::ptr& blk);
void process_expr_tuple(const ast::expr_tuple::ptr& expr, const block::ptr& blk);
void process_expr_array(const ast::expr_array::ptr& expr, const block::ptr& blk);
void process_expr_field(const ast::expr_field::ptr& expr, const block::ptr& blk);
void process_expr_vector(const ast::expr_vector::ptr& vec, const block::ptr& blk);
void process_var_create(ast::expr& expr, const block::ptr& blk, bool fromstmt = false);
void process_var_access(ast::expr& expr, const block::ptr& blk);
void process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk);
};
} // namespace xsk::gsc::iw9

View File

@ -50,8 +50,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos()); func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>(); func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint32_t>(); func->name = utils::string::va("id_%016llX", stack_->read<std::uint64_t>());
func->name = func->id == 0 ? decrypt_string(stack_->read_c_string()) : resolver::token_name(func->id);
dissasemble_function(func); dissasemble_function(func);
@ -64,7 +63,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
void disassembler::dissasemble_function(const function::ptr& func) void disassembler::dissasemble_function(const function::ptr& func)
{ {
auto size = func->size; auto size = static_cast<int32_t>(func->size);
while (size > 0) while (size > 0)
{ {
@ -78,17 +77,243 @@ void disassembler::dissasemble_function(const function::ptr& func)
dissasemble_instruction(inst); dissasemble_instruction(inst);
size -= inst->size; size -= inst->size;
if (inst->index + inst->size != script_->pos())
{
throw error("wrong inst size");
}
if (size < 0)
{
throw error("wrong func size");
}
} }
} }
void disassembler::dissasemble_instruction(const instruction::ptr& inst) void disassembler::dissasemble_instruction(const instruction::ptr& inst)
{ {
/*switch (static_cast<opcode>(inst->opcode)) switch (static_cast<opcode>(inst->opcode))
{ {
case opcode::OP_CastFieldObject:
case opcode::OP_plus:
case opcode::OP_GetGameRef:
case opcode::OP_GetThisthread:
case opcode::OP_greater:
case opcode::OP_shift_right:
case opcode::OP_dec:
case opcode::OP_bit_or:
case opcode::OP_equality:
case opcode::OP_ClearLocalVariableFieldCached0:
case opcode::OP_notify:
case opcode::OP_PreScriptCall:
case opcode::OP_GetUndefined:
case opcode::OP_SetLocalVariableFieldCached0:
case opcode::OP_GetLevel:
case opcode::OP_size:
case opcode::OP_AddArray:
case opcode::OP_endon:
case opcode::OP_shift_left:
case opcode::OP_EvalLocalArrayRefCached0:
case opcode::OP_Return:
case opcode::OP_SafeSetVariableFieldCached0:
case opcode::OP_GetSelfObject:
case opcode::OP_GetGame:
case opcode::OP_EvalArray:
case opcode::OP_GetSelf:
case opcode::OP_End:
case opcode::OP_less_equal:
case opcode::OP_EvalLocalVariableCached0:
case opcode::OP_EvalLocalVariableCached1:
case opcode::OP_EvalLocalVariableCached2:
case opcode::OP_EvalLocalVariableCached3:
case opcode::OP_EvalLocalVariableCached4:
case opcode::OP_EvalLocalVariableCached5:
case opcode::OP_ScriptMethodCallPointer:
case opcode::OP_checkclearparams:
case opcode::OP_minus:
case opcode::OP_greater_equal:
case opcode::OP_vector:
case opcode::OP_ClearArray:
case opcode::OP_DecTop:
case opcode::OP_CastBool:
case opcode::OP_EvalArrayRef:
case opcode::OP_GetZero:
case opcode::OP_wait:
case opcode::OP_waittill:
case opcode::OP_GetAnimObject:
case opcode::OP_mod:
case opcode::OP_clearparams:
case opcode::OP_ScriptFunctionCallPointer:
case opcode::OP_EmptyArray:
case opcode::OP_BoolComplement:
case opcode::OP_less:
case opcode::OP_BoolNot:
case opcode::OP_waittillFrameEnd:
case opcode::OP_waitframe:
case opcode::OP_GetLevelObject:
case opcode::OP_inc:
case opcode::OP_GetAnim:
case opcode::OP_SetVariableField:
case opcode::OP_divide:
case opcode::OP_multiply:
case opcode::OP_EvalLocalVariableRefCached0:
case opcode::OP_bit_and:
case opcode::OP_voidCodepos:
case opcode::OP_inequality:
case opcode::OP_bit_ex_or:
case opcode::OP_unk_139:
case opcode::OP_BoolNotAfterAnd:
case opcode::OP_IsDefined:
case opcode::OP_IsTrue:
break;
case opcode::OP_GetByte:
case opcode::OP_GetNegByte:
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
break;
case opcode::OP_GetUnsignedShort:
case opcode::OP_GetNegUnsignedShort:
inst->data.push_back(utils::string::va("%i", script_->read<std::uint16_t>()));
break;
case opcode::OP_GetInteger:
inst->data.push_back(utils::string::va("%i", script_->read<std::int32_t>()));
break;
case opcode::OP_GetFloat:
inst->data.push_back(utils::string::float_string(script_->read<float>()));
break;
case opcode::OP_GetVector:
inst->data.push_back(utils::string::float_string(script_->read<float>()));
inst->data.push_back(utils::string::float_string(script_->read<float>()));
inst->data.push_back(utils::string::float_string(script_->read<float>()));
break;
case opcode::OP_GetString:
case opcode::OP_GetIString:
script_->seek(4);
inst->data.push_back(utils::string::quote(stack_->read_c_string(), false));
break;
case opcode::OP_GetAnimTree:
script_->seek(1);
inst->data.push_back(utils::string::quote(stack_->read_c_string(), false));
break;
case opcode::OP_GetAnimation:
script_->seek(8);
inst->data.push_back(utils::string::quote(stack_->read_c_string(), false));
inst->data.push_back(utils::string::quote(stack_->read_c_string(), false));
break;
case opcode::OP_waittillmatch:
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
break;
case opcode::OP_EvalSelfFieldVariableRef:
case opcode::OP_EvalAnimFieldVariable:
case opcode::OP_EvalLevelFieldVariableRef:
case opcode::OP_SetSelfFieldVariableField:
case opcode::OP_ClearFieldVariable:
case opcode::OP_EvalFieldVariable:
case opcode::OP_SetLevelFieldVariableField:
case opcode::OP_EvalSelfFieldVariable:
case opcode::OP_SetAnimFieldVariableField:
case opcode::OP_EvalFieldVariableRef:
case opcode::OP_EvalLevelFieldVariable:
case opcode::OP_EvalAnimFieldVariableRef:
inst->data.push_back(utils::string::va("id_%016llX", script_->read<std::uint64_t>()));
break;
case opcode::OP_CreateLocalVariable:
case opcode::OP_EvalNewLocalArrayRefCached0:
case opcode::OP_SafeCreateVariableFieldCached:
case opcode::OP_SetNewLocalVariableFieldCached0:
inst->data.push_back(utils::string::va("%016llX", script_->read<std::uint64_t>()));
break;
case opcode::OP_SetLocalVariableFieldCached:
case opcode::OP_RemoveLocalVariables:
case opcode::OP_SafeSetWaittillVariableFieldCached:
case opcode::OP_EvalLocalVariableCached:
case opcode::OP_EvalLocalVariableObjectCached:
case opcode::OP_EvalLocalArrayCached:
case opcode::OP_SafeSetVariableFieldCached:
case opcode::OP_EvalLocalVariableRefCached:
case opcode::OP_ClearLocalVariableFieldCached:
case opcode::OP_EvalLocalArrayRefCached:
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
break;
case opcode::OP_ScriptMethodChildThreadCallPointer:
case opcode::OP_CallBuiltinMethodPointer:
case opcode::OP_ScriptChildThreadCallPointer:
case opcode::OP_ScriptMethodThreadCallPointer:
case opcode::OP_ScriptThreadCallPointer:
case opcode::OP_CallBuiltinPointer:
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
break;
case opcode::OP_GetFarFunction:
case opcode::OP_ScriptFarFunctionCall:
case opcode::OP_ScriptFarMethodCall:
disassemble_far_call(inst, false);
break;
case opcode::OP_ScriptFarThreadCall:
case opcode::OP_ScriptFarChildThreadCall:
case opcode::OP_ScriptFarMethodThreadCall:
case opcode::OP_ScriptFarMethodChildThreadCall:
disassemble_far_call(inst, true);
break;
case opcode::OP_CallBuiltin:
disassemble_builtin_call(inst, false, true);
break;
case opcode::OP_CallBuiltinMethod:
disassemble_builtin_call(inst, true, true);
break;
case opcode::OP_GetBuiltinFunction:
disassemble_builtin_call(inst, false, false);
break;
case opcode::OP_GetBuiltinMethod:
disassemble_builtin_call(inst, true, false);
break;
case opcode::OP_JumpOnFalse:
case opcode::OP_JumpOnTrue:
case opcode::OP_JumpOnFalseExpr:
case opcode::OP_JumpOnTrueExpr:
disassemble_jump(inst, true, false);
break;
case opcode::OP_jumpback:
disassemble_jump(inst, false, true);
break;
case opcode::OP_jump:
disassemble_jump(inst, false, false);
break;
case opcode::OP_switch:
disassemble_switch(inst);
break;
case opcode::OP_endswitch:
disassemble_end_switch(inst);
break;
/* case opcode::OP_prof_begin:
script_->seek(5); // TODO: skipped data
break;
case opcode::OP_prof_end:
script_->seek(1); // TODO: skipped data
break;
case opcode::OP_EvalNewLocalArrayRefCached0_Precompiled:
case opcode::OP_SetNewLocalVariableFieldCached0_Precompiled:
case opcode::OP_CreateLocalVariable_Precompiled:
case opcode::OP_SafeCreateVariableFieldCached_Precompiled:
script_->seek(8); // TODO: skipped data
break;*/
case opcode::OP_NativeGetFarFunction:
case opcode::OP_NativeFarFunctionCall:
case opcode::OP_NativeFarMethodCall:
disassemble_native_call(inst, false);
break;
case opcode::OP_NativeFarFunctionThreadCall:
case opcode::OP_NativeFarMethodThreadCall:
case opcode::OP_NativeFarFunctionChildThreadCall:
case opcode::OP_NativeFarMethodChildThreadCall:
disassemble_native_call(inst, true);
break;
case opcode::OP_FormalParams:
case opcode::OP_FormalParams_Precompiled:
disassemble_formal_params(inst);
break;
default: default:
throw disasm_error(utils::string::va("unhandled opcode 0x%X at index '%04X'!", inst->opcode, inst->index)); throw disasm_error(utils::string::va("unhandled opcode 0x%X at index '%04X'!", inst->opcode, inst->index));
}*/ }
} }
void disassembler::disassemble_builtin_call(const instruction::ptr& inst, bool method, bool args) void disassembler::disassemble_builtin_call(const instruction::ptr& inst, bool method, bool args)
@ -98,39 +323,55 @@ void disassembler::disassemble_builtin_call(const instruction::ptr& inst, bool m
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>())); inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
} }
const auto id = script_->read<std::uint16_t>(); if (method) // TODO
const auto name = method ? resolver::method_name(id) : resolver::function_name(id); {
inst->data.emplace(inst->data.begin(), name); auto str = stack_->read_c_string();
script_->seek(2);
inst->data.emplace(inst->data.begin(), str);
}
else
{
auto str = stack_->read_c_string();
script_->seek(2);
inst->data.emplace(inst->data.begin(), str);
}
} }
void disassembler::disassemble_local_call(const instruction::ptr& inst, bool thread) void disassembler::disassemble_native_call(const instruction::ptr& inst, bool thread)
{ {
const auto offset = disassemble_offset(); script_->seek(4);
inst->data.push_back(utils::string::va("%X", offset + inst->index + 1));
if (thread) if (thread)
{ {
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>())); inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
} }
inst->data.emplace(inst->data.begin(), utils::string::va("%08X", stack_->read<std::uint32_t>()));
} }
void disassembler::disassemble_far_call(const instruction::ptr& inst, bool thread) void disassembler::disassemble_far_call(const instruction::ptr& inst, bool thread)
{ {
script_->seek(3); auto offs = script_->read<std::uint32_t>();
if (thread) if (thread)
{ {
inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>())); inst->data.push_back(utils::string::va("%i", script_->read<std::uint8_t>()));
} }
const auto file_id = stack_->read<std::uint32_t>(); auto file = stack_->read<std::uint64_t>();
const auto file_name = file_id == 0 ? decrypt_string(stack_->read_c_string()) : resolver::token_name(file_id); auto name = stack_->read<std::uint64_t>();
const auto func_id = stack_->read<std::uint32_t>();
const auto func_name = func_id == 0 ? decrypt_string(stack_->read_c_string()) : resolver::token_name(func_id);
inst->data.emplace(inst->data.begin(), func_name); if (file == 0)
inst->data.emplace(inst->data.begin(), file_name); {
inst->data.emplace(inst->data.begin(), "");
inst->data.push_back(utils::string::va("%X", offs + inst->index + 1));
}
else
{
inst->data.emplace(inst->data.begin(), utils::string::va("id_%016llX", file));
inst->data.emplace(inst->data.begin(), utils::string::va("id_%016llX", name));
}
} }
void disassembler::disassemble_switch(const instruction::ptr& inst) void disassembler::disassemble_switch(const instruction::ptr& inst)
@ -154,65 +395,57 @@ void disassembler::disassemble_end_switch(const instruction::ptr& inst)
for (auto i = count; i > 0; i--) for (auto i = count; i > 0; i--)
{ {
const auto value = script_->read<std::uint32_t>(); const auto value = script_->read<std::uint32_t>();
const auto offs = script_->read<std::int16_t>();
script_->seek(1);
const auto byte = script_->read<std::uint8_t>();
if (byte == 2)
{
auto str = stack_->read_c_string();
if (value < 0x100000 && value > 0) if (str[0] == 1)
{ {
inst->data.push_back("case"); inst->data.push_back("default");
inst->data.push_back(utils::string::quote(decrypt_string(stack_->read_c_string()), false)); }
} else
else if (value == 0) {
{ inst->data.push_back("case");
inst->data.push_back("default"); inst->data.push_back(utils::string::quote(str, false));
stack_->read_c_string(); // this should be always [0x01 0x00] unencrypted }
} }
else else
{ {
inst->data.push_back("case"); inst->data.push_back("case");
inst->data.push_back(utils::string::va("%i", (value - 0x800000) & 0xFFFFFF)); inst->data.push_back(utils::string::va("%i", value));
} }
index += 4; const auto addr = index + 4 + offs;
const auto addr = disassemble_offset() + index;
const auto label = utils::string::va("loc_%X", addr); const auto label = utils::string::va("loc_%X", addr);
inst->data.push_back(label); inst->data.push_back(label);
labels_.insert({ addr, label }); labels_.insert({ addr, label });
index += 3; index += 8;
inst->size += 7; inst->size += 8;
} }
} }
} }
void disassembler::disassemble_field_variable(const instruction::ptr& inst) void disassembler::disassemble_field_variable(const instruction::ptr& inst)
{ {
const auto id = script_->read<std::uint32_t>(); inst->data.push_back(utils::string::va("id_%016llX", script_->read<std::uint64_t>()));
std::string name;
if (id > max_string_id)
{
auto temp = stack_->read<std::uint32_t>();
name = temp == 0 ? decrypt_string(stack_->read_c_string()) : std::to_string(temp);
}
else
{
name = resolver::token_name(id);
}
inst->data.push_back(name);
} }
void disassembler::disassemble_formal_params(const instruction::ptr& inst) void disassembler::disassemble_formal_params(const instruction::ptr& inst)
{ {
const auto count = script_->read<std::uint8_t>(); const auto count = script_->read<std::uint8_t>();
inst->size += count; inst->size += count * 8;
inst->data.push_back(utils::string::va("%i", count)); inst->data.push_back(utils::string::va("%i", count));
for (auto i = 0u; i < count; i++) for (auto i = 0u; i < count; i++)
{ {
inst->data.push_back(utils::string::va("%d", script_->read<std::uint8_t>())); inst->data.push_back(utils::string::va("%016llX", script_->read<std::uint64_t>()));
} }
} }
@ -222,7 +455,7 @@ void disassembler::disassemble_jump(const instruction::ptr& inst, bool expr, boo
if (expr) if (expr)
{ {
addr = inst->index + 3 + script_->read<std::int16_t>(); addr = inst->index + 3 + script_->read<std::uint16_t>();
} }
else if (back) else if (back)
{ {
@ -239,43 +472,27 @@ void disassembler::disassemble_jump(const instruction::ptr& inst, bool expr, boo
labels_.insert({ addr, label }); labels_.insert({ addr, label });
} }
auto disassembler::disassemble_offset() -> std::int32_t
{
std::array<std::uint8_t, 4> bytes = {};
for (auto i = 0; i < 3; i++)
{
bytes[i] = script_->read<std::uint8_t>();
}
auto offset = *reinterpret_cast<std::int32_t*>(bytes.data());
offset = (offset << 8) >> 8;
return offset;
}
void disassembler::resolve_local_functions() void disassembler::resolve_local_functions()
{ {
for (const auto& func : functions_) for (const auto& func : functions_)
{ {
for (const auto& inst : func->instructions) for (const auto& inst : func->instructions)
{ {
/*switch (static_cast<opcode>(inst->opcode)) switch (static_cast<opcode>(inst->opcode))
{ {
case opcode::OP_GetLocalFunction: case opcode::OP_GetFarFunction:
case opcode::OP_ScriptLocalFunctionCall: case opcode::OP_ScriptFarFunctionCall:
case opcode::OP_ScriptLocalFunctionCall2: case opcode::OP_ScriptFarMethodCall:
case opcode::OP_ScriptLocalMethodCall: case opcode::OP_ScriptFarThreadCall:
case opcode::OP_ScriptLocalThreadCall: case opcode::OP_ScriptFarChildThreadCall:
case opcode::OP_ScriptLocalChildThreadCall: case opcode::OP_ScriptFarMethodThreadCall:
case opcode::OP_ScriptLocalMethodThreadCall: case opcode::OP_ScriptFarMethodChildThreadCall:
case opcode::OP_ScriptLocalMethodChildThreadCall: if (inst->data[0].empty())
inst->data[0] = resolve_function(inst->data[0]); inst->data[1] = resolve_function(inst->data[1]);
break; break;
default: default:
break; break;
}*/ }
} }
} }
} }
@ -300,27 +517,10 @@ auto disassembler::resolve_function(const std::string& index) -> std::string
throw disasm_error(utils::string::va("\"%s\" is not valid function address!", index.data())); throw disasm_error(utils::string::va("\"%s\" is not valid function address!", index.data()));
} }
auto disassembler::decrypt_string(const std::string& str) -> std::string
{
if (str.size() > 0 && ((static_cast<std::uint8_t>(str[0]) & 0xC0) == 0x80))
{
std::string data = "_encstr_";
for (auto i = 0u; i < str.size(); i++)
{
data = utils::string::va("%s%02X", data.data(), static_cast<std::uint8_t>(str[i]));
}
return data;
}
return str;
}
void disassembler::print_function(const function::ptr& func) void disassembler::print_function(const function::ptr& func)
{ {
output_->write_string("\n"); output_->write_string("\n");
output_->write_string(utils::string::va("sub_%s\n", func->name.data())); output_->write_string(utils::string::va("sub_%s %i\n", func->name.data(), func->size));
for (const auto& inst : func->instructions) for (const auto& inst : func->instructions)
{ {
@ -339,7 +539,7 @@ void disassembler::print_function(const function::ptr& func)
void disassembler::print_instruction(const instruction::ptr& inst) void disassembler::print_instruction(const instruction::ptr& inst)
{ {
output_->write_string(utils::string::va("\t\t%s", resolver::opcode_name(inst->opcode).data())); output_->write_string(utils::string::va("%i\t%i\t%s", inst->index, inst->size, resolver::opcode_name(inst->opcode).data()));
/*switch (static_cast<opcode>(inst->opcode)) /*switch (static_cast<opcode>(inst->opcode))
{ {

View File

@ -26,17 +26,15 @@ private:
void dissasemble_function(const function::ptr& func); void dissasemble_function(const function::ptr& func);
void dissasemble_instruction(const instruction::ptr& inst); void dissasemble_instruction(const instruction::ptr& inst);
void disassemble_builtin_call(const instruction::ptr& inst, bool method, bool args); void disassemble_builtin_call(const instruction::ptr& inst, bool method, bool args);
void disassemble_local_call(const instruction::ptr& inst, bool thread); void disassemble_native_call(const instruction::ptr& inst, bool thread);
void disassemble_far_call(const instruction::ptr& inst, bool thread); void disassemble_far_call(const instruction::ptr& inst, bool thread);
void disassemble_switch(const instruction::ptr& inst); void disassemble_switch(const instruction::ptr& inst);
void disassemble_end_switch(const instruction::ptr& inst); void disassemble_end_switch(const instruction::ptr& inst);
void disassemble_field_variable(const instruction::ptr& inst); void disassemble_field_variable(const instruction::ptr& inst);
void disassemble_formal_params(const instruction::ptr& inst); void disassemble_formal_params(const instruction::ptr& inst);
void disassemble_jump(const instruction::ptr& inst, bool expr, bool back); void disassemble_jump(const instruction::ptr& inst, bool expr, bool back);
auto disassemble_offset() -> std::int32_t;
void resolve_local_functions(); void resolve_local_functions();
auto resolve_function(const std::string& index) -> std::string; auto resolve_function(const std::string& index) -> std::string;
auto decrypt_string(const std::string& str) -> std::string;
void print_function(const function::ptr& func); void print_function(const function::ptr& func);
void print_instruction(const instruction::ptr& inst); void print_instruction(const instruction::ptr& inst);
}; };

View File

@ -11,12 +11,186 @@ namespace xsk::gsc::iw9
auto opcode_size(std::uint8_t id) -> std::uint32_t auto opcode_size(std::uint8_t id) -> std::uint32_t
{ {
/*switch (static_cast<opcode>(id)) switch (static_cast<opcode>(id))
{ {
case opcode::OP_CastFieldObject:
default:*/ case opcode::OP_plus:
case opcode::OP_GetGameRef:
case opcode::OP_GetThisthread:
case opcode::OP_greater:
case opcode::OP_shift_right:
case opcode::OP_dec:
case opcode::OP_bit_or:
case opcode::OP_equality:
case opcode::OP_ClearLocalVariableFieldCached0:
case opcode::OP_notify:
case opcode::OP_PreScriptCall:
case opcode::OP_GetUndefined:
case opcode::OP_SetLocalVariableFieldCached0:
case opcode::OP_GetLevel:
case opcode::OP_size:
case opcode::OP_AddArray:
case opcode::OP_endon:
case opcode::OP_shift_left:
case opcode::OP_EvalLocalArrayRefCached0:
case opcode::OP_Return:
case opcode::OP_SafeSetVariableFieldCached0:
case opcode::OP_GetSelfObject:
case opcode::OP_GetGame:
case opcode::OP_EvalArray:
case opcode::OP_GetSelf:
case opcode::OP_End:
case opcode::OP_less_equal:
case opcode::OP_EvalLocalVariableCached0:
case opcode::OP_EvalLocalVariableCached1:
case opcode::OP_EvalLocalVariableCached2:
case opcode::OP_EvalLocalVariableCached3:
case opcode::OP_EvalLocalVariableCached4:
case opcode::OP_EvalLocalVariableCached5:
case opcode::OP_ScriptMethodCallPointer:
case opcode::OP_checkclearparams:
case opcode::OP_minus:
case opcode::OP_greater_equal:
case opcode::OP_vector:
case opcode::OP_ClearArray:
case opcode::OP_DecTop:
case opcode::OP_CastBool:
case opcode::OP_EvalArrayRef:
case opcode::OP_GetZero:
case opcode::OP_wait:
case opcode::OP_waittill:
case opcode::OP_GetAnimObject:
case opcode::OP_mod:
case opcode::OP_clearparams:
case opcode::OP_ScriptFunctionCallPointer:
case opcode::OP_EmptyArray:
case opcode::OP_BoolComplement:
case opcode::OP_less:
case opcode::OP_BoolNot:
case opcode::OP_waittillFrameEnd:
case opcode::OP_waitframe:
case opcode::OP_GetLevelObject:
case opcode::OP_inc:
case opcode::OP_GetAnim:
case opcode::OP_SetVariableField:
case opcode::OP_divide:
case opcode::OP_multiply:
case opcode::OP_EvalLocalVariableRefCached0:
case opcode::OP_bit_and:
case opcode::OP_voidCodepos:
case opcode::OP_inequality:
case opcode::OP_bit_ex_or:
case opcode::OP_unk_139:
case opcode::OP_BoolNotAfterAnd:
case opcode::OP_IsDefined:
case opcode::OP_IsTrue:
return 1;
case opcode::OP_SetLocalVariableFieldCached:
case opcode::OP_RemoveLocalVariables:
case opcode::OP_ScriptMethodChildThreadCallPointer:
case opcode::OP_GetByte:
case opcode::OP_SafeSetWaittillVariableFieldCached:
case opcode::OP_CallBuiltinMethodPointer:
case opcode::OP_EvalLocalVariableCached:
case opcode::OP_ScriptChildThreadCallPointer:
case opcode::OP_EvalLocalVariableObjectCached:
case opcode::OP_GetNegByte:
case opcode::OP_GetAnimTree:
case opcode::OP_EvalLocalArrayCached:
case opcode::OP_ScriptMethodThreadCallPointer:
case opcode::OP_SafeSetVariableFieldCached:
case opcode::OP_EvalLocalVariableRefCached:
case opcode::OP_ScriptThreadCallPointer:
case opcode::OP_ClearLocalVariableFieldCached:
case opcode::OP_EvalLocalArrayRefCached:
case opcode::OP_CallBuiltinPointer:
case opcode::OP_prof_end:
case opcode::OP_FormalParams:
case opcode::OP_FormalParams_Precompiled:
return 2;
case opcode::OP_waittillmatch:
case opcode::OP_JumpOnTrue:
case opcode::OP_JumpOnFalseExpr:
case opcode::OP_jumpback:
case opcode::OP_JumpOnTrueExpr:
case opcode::OP_GetBuiltinFunction:
case opcode::OP_GetNegUnsignedShort:
case opcode::OP_GetBuiltinMethod:
case opcode::OP_endswitch:
case opcode::OP_GetUnsignedShort:
case opcode::OP_JumpOnFalse:
return 3;
case opcode::OP_CallBuiltin:
case opcode::OP_CallBuiltinMethod:
return 4;
case opcode::OP_GetInteger:
case opcode::OP_GetIString:
case opcode::OP_ScriptFarFunctionCall:
case opcode::OP_GetFloat:
case opcode::OP_GetString:
case opcode::OP_switch:
case opcode::OP_GetFarFunction:
case opcode::OP_jump:
case opcode::OP_ScriptFarMethodCall:
case opcode::OP_unk_134:
case opcode::OP_unk_137:
case opcode::OP_NativeGetFarFunction:
case opcode::OP_NativeFarFunctionCall:
case opcode::OP_NativeFarMethodCall:
return 5;
case opcode::OP_ScriptFarMethodChildThreadCall:
case opcode::OP_ScriptFarThreadCall:
case opcode::OP_ScriptFarMethodThreadCall:
case opcode::OP_ScriptFarChildThreadCall:
case opcode::OP_prof_begin:
case opcode::OP_NativeFarFunctionThreadCall:
case opcode::OP_NativeFarMethodThreadCall:
case opcode::OP_NativeFarFunctionChildThreadCall:
case opcode::OP_NativeFarMethodChildThreadCall:
return 6;
case opcode::OP_EvalSelfFieldVariableRef:
case opcode::OP_EvalAnimFieldVariable:
case opcode::OP_EvalLevelFieldVariableRef:
case opcode::OP_SetSelfFieldVariableField:
case opcode::OP_ClearFieldVariable:
case opcode::OP_EvalFieldVariable:
case opcode::OP_CreateLocalVariable:
case opcode::OP_SetLevelFieldVariableField:
case opcode::OP_EvalSelfFieldVariable:
case opcode::OP_EvalNewLocalArrayRefCached0:
case opcode::OP_SetAnimFieldVariableField:
case opcode::OP_SafeCreateVariableFieldCached:
case opcode::OP_SetNewLocalVariableFieldCached0:
case opcode::OP_EvalFieldVariableRef:
case opcode::OP_EvalLevelFieldVariable:
case opcode::OP_EvalAnimFieldVariableRef:
case opcode::OP_GetAnimation:
case opcode::OP_unk_133:
case opcode::OP_unk_135:
case opcode::OP_unk_136:
case opcode::OP_unk_138:
case opcode::OP_EvalNewLocalArrayRefCached0_Precompiled:
case opcode::OP_SetNewLocalVariableFieldCached0_Precompiled:
case opcode::OP_CreateLocalVariable_Precompiled:
case opcode::OP_SafeCreateVariableFieldCached_Precompiled:
case opcode::OP_unk_166:
return 9;
case opcode::OP_GetVector:
return 13;
case opcode::OP_waittillmatch2:
case opcode::OP_ClearVariableField:
case opcode::OP_EvalNewLocalVariableRefCached0:
case opcode::OP_unk_140:
case opcode::OP_unk_141:
case opcode::OP_unk_142:
case opcode::OP_unk_143:
case opcode::OP_unk_144:
case opcode::OP_breakpoint:
case opcode::OP_assignmentBreakpoint:
case opcode::OP_manualAndAssignmentBreakpoint:
default:
throw error("couldn't resolve instruction size for " + std::to_string(id)); throw error("couldn't resolve instruction size for " + std::to_string(id));
// } }
} }
} // namespace xsk::gsc::iw9 } // namespace xsk::gsc::iw9

View File

@ -8,6 +8,7 @@
#include "utils/xsk/utils.hpp" #include "utils/xsk/utils.hpp"
#include "disassembler.hpp" #include "disassembler.hpp"
#include "decompiler.hpp"
#include "resolver.hpp" #include "resolver.hpp"
#include "context.hpp" #include "context.hpp"
@ -18,173 +19,173 @@ constexpr std::uint32_t max_string_id = 0;
enum class opcode : std::uint8_t enum class opcode : std::uint8_t
{ {
unk_000 = 0x00, // size 1 OP_CastFieldObject OP_CastFieldObject = 0x00,
unk_001 = 0x01, // size 2 OP_SetLocalVariableFieldCached OP_SetLocalVariableFieldCached = 0x01,
unk_002 = 0x02, // size 1 OP_plus OP_plus = 0x02,
unk_003 = 0x03, // size 2 OP_RemoveLocalVariables OP_RemoveLocalVariables = 0x03,
unk_004 = 0x04, // size 9, script 8 (hash?) OP_EvalSelfFieldVariableRef OP_EvalSelfFieldVariableRef = 0x04,
unk_005 = 0x05, // size 6, stack 8 + 8 OP_ScriptFarMethodChildThreadCall OP_ScriptFarMethodChildThreadCall = 0x05,
unk_006 = 0x06, // size 1 OP_GetGameRef OP_GetGameRef = 0x06,
unk_007 = 0x07, // size 9, script 8 (hash?) OP_EvalAnimFieldVariable OP_EvalAnimFieldVariable = 0x07,
unk_008 = 0x08, // size 9, script 8 (hash?) OP_EvalLevelFieldVariableRef OP_EvalLevelFieldVariableRef = 0x08,
unk_009 = 0x09, // size 1 OP_GetThisthread OP_GetThisthread = 0x09,
unk_010 = 0x0A, // size 1 OP_greater OP_greater = 0x0A,
unk_011 = 0x0B, // size 3 OP_waittillmatch OP_waittillmatch = 0x0B,
unk_012 = 0x0C, // size 1 OP_shift_right OP_shift_right = 0x0C,
unk_013 = 0x0D, // size 1 OP_dec OP_dec = 0x0D,
unk_014 = 0x0E, // size 3 OP_JumpOnTrue OP_JumpOnTrue = 0x0E,
unk_015 = 0x0F, // size 1 OP_bit_or OP_bit_or = 0x0F,
unk_016 = 0x10, // size 1 OP_equality OP_equality = 0x10,
unk_017 = 0x11, // size 1 OP_ClearLocalVariableFieldCached0 OP_ClearLocalVariableFieldCached0 = 0x11,
unk_018 = 0x12, // size 1 OP_notify OP_notify = 0x12,
unk_019 = 0x13, // size 13 OP_GetVector OP_GetVector = 0x13,
unk_020 = 0x14, // size 2 OP_ScriptMethodChildThreadCallPointer OP_ScriptMethodChildThreadCallPointer = 0x14,
unk_021 = 0x15, // size 1 OP_PreScriptCall OP_PreScriptCall = 0x15,
unk_022 = 0x16, // size 2 OP_GetByte OP_GetByte = 0x16,
unk_023 = 0x17, // size 6, stack 8 + 8 OP_ScriptFarThreadCall OP_ScriptFarThreadCall = 0x17,
unk_024 = 0x18, // size 9, script 8 (hash?) OP_SetSelfFieldVariableField OP_SetSelfFieldVariableField = 0x18,
unk_025 = 0x19, // size 3 OP_JumpOnFalseExpr OP_JumpOnFalseExpr = 0x19,
unk_026 = 0x1A, // size 1 OP_GetUndefined OP_GetUndefined = 0x1A,
unk_027 = 0x1B, // size 3 OP_jumpback OP_jumpback = 0x1B,
unk_028 = 0x1C, // size 3 OP_JumpOnTrueExpr OP_JumpOnTrueExpr = 0x1C,
unk_029 = 0x1D, // size 4, stack string OP_CallBuiltin OP_CallBuiltin = 0x1D,
unk_030 = 0x1E, // size 1 OP_SetLocalVariableFieldCached0 OP_SetLocalVariableFieldCached0 = 0x1E,
unk_031 = 0x1F, // size 9, script 8 (hash?) OP_ClearFieldVariable OP_ClearFieldVariable = 0x1F,
unk_032 = 0x20, // size 1 OP_GetLevel OP_GetLevel = 0x20,
unk_033 = 0x21, // size 1 OP_size OP_size = 0x21,
unk_034 = 0x22, // size 2 OP_SafeSetWaittillVariableFieldCached OP_SafeSetWaittillVariableFieldCached = 0x22,
unk_035 = 0x23, // size 1 OP_AddArray OP_AddArray = 0x23,
unk_036 = 0x24, // size 1 OP_endon OP_endon = 0x24,
unk_037 = 0x25, // size 9, script 8 (hash?) OP_EvalFieldVariable OP_EvalFieldVariable = 0x25,
unk_038 = 0x26, // size 1 OP_shift_left OP_shift_left = 0x26,
unk_039 = 0x27, // size 1 OP_EvalLocalArrayRefCached0 OP_EvalLocalArrayRefCached0 = 0x27,
unk_040 = 0x28, // size 1 OP_Return OP_Return = 0x28,
unk_041 = 0x29, // size 9 OP_CreateLocalVariable OP_CreateLocalVariable = 0x29,
unk_042 = 0x2A, // size 1 OP_SafeSetVariableFieldCached0 OP_SafeSetVariableFieldCached0 = 0x2A,
unk_043 = 0x2B, // size 3, stack string OP_GetBuiltinFunction OP_GetBuiltinFunction = 0x2B,
unk_044 = 0x2C, // size 2 OP_CallBuiltinMethodPointer OP_CallBuiltinMethodPointer = 0x2C,
unk_045 = 0x2D, // size 1 OP_GetSelfObject OP_GetSelfObject = 0x2D,
unk_046 = 0x2E, // size 1 OP_GetGame OP_GetGame = 0x2E,
unk_047 = 0x2F, // size 9, script 8 (hash?) OP_SetLevelFieldVariableField OP_SetLevelFieldVariableField = 0x2F,
unk_048 = 0x30, // size 1 OP_EvalArray OP_EvalArray = 0x30,
unk_049 = 0x31, // size 1 OP_GetSelf OP_GetSelf = 0x31,
unk_050 = 0x32, // size 1 OP_End OP_End = 0x32,
unk_051 = 0x33, // size 9, script 8 (hash?) OP_EvalSelfFieldVariable OP_EvalSelfFieldVariable = 0x33,
unk_052 = 0x34, // size 1 OP_less_equal OP_less_equal = 0x34,
unk_053 = 0x35, // size 1 OP_EvalLocalVariableCached0 OP_EvalLocalVariableCached0 = 0x35,
unk_054 = 0x36, // size 1 OP_EvalLocalVariableCached1 OP_EvalLocalVariableCached1 = 0x36,
unk_055 = 0x37, // size 1 OP_EvalLocalVariableCached2 OP_EvalLocalVariableCached2 = 0x37,
unk_056 = 0x38, // size 1 OP_EvalLocalVariableCached3 OP_EvalLocalVariableCached3 = 0x38,
unk_057 = 0x39, // size 1 OP_EvalLocalVariableCached4 OP_EvalLocalVariableCached4 = 0x39,
unk_058 = 0x3A, // size 1 OP_EvalLocalVariableCached5 OP_EvalLocalVariableCached5 = 0x3A,
unk_059 = 0x3B, // size 2 OP_EvalLocalVariableCached OP_EvalLocalVariableCached = 0x3B,
unk_060 = 0x3C, // size 9 OP_EvalNewLocalArrayRefCached0 OP_EvalNewLocalArrayRefCached0 = 0x3C,
unk_061 = 0x3D, // size 2 OP_ScriptChildThreadCallPointer OP_ScriptChildThreadCallPointer = 0x3D,
unk_062 = 0x3E, // size 2 OP_EvalLocalVariableObjectCached OP_EvalLocalVariableObjectCached = 0x3E,
unk_063 = 0x3F, // size 5 OP_GetInteger OP_GetInteger = 0x3F,
unk_064 = 0x40, // size 1 OP_ScriptMethodCallPointer OP_ScriptMethodCallPointer = 0x40,
unk_065 = 0x41, // size 1 OP_checkclearparams OP_checkclearparams = 0x41,
unk_066 = 0x42, // size 9, script 8 (hash?) OP_SetAnimFieldVariableField OP_SetAnimFieldVariableField = 0x42,
unk_067 = 0x43, // missing OP_waittillmatch2 OP_waittillmatch2 = 0x43,
unk_068 = 0x44, // size 1 OP_minus OP_minus = 0x44,
unk_069 = 0x45, // size 3 OP_GetNegUnsignedShort OP_GetNegUnsignedShort = 0x45,
unk_070 = 0x46, // size 2 OP_GetNegByte OP_GetNegByte = 0x46,
unk_071 = 0x47, // size 9 OP_SafeCreateVariableFieldCached OP_SafeCreateVariableFieldCached = 0x47,
unk_072 = 0x48, // size 1 OP_greater_equal OP_greater_equal = 0x48,
unk_073 = 0x49, // size 1 OP_vector OP_vector = 0x49,
unk_074 = 0x4A, // size 3, stack string OP_GetBuiltinMethod OP_GetBuiltinMethod = 0x4A,
unk_075 = 0x4B, // size 3 + 8 * count, stack strings OP_endswitch OP_endswitch = 0x4B,
unk_076 = 0x4C, // size 1 OP_ClearArray OP_ClearArray = 0x4C,
unk_077 = 0x4D, // size 1 OP_DecTop OP_DecTop = 0x4D,
unk_078 = 0x4E, // size 1 OP_CastBool OP_CastBool = 0x4E,
unk_079 = 0x4F, // size 1 OP_EvalArrayRef OP_EvalArrayRef = 0x4F,
unk_080 = 0x50, // size 9 OP_SetNewLocalVariableFieldCached0 OP_SetNewLocalVariableFieldCached0 = 0x50,
unk_081 = 0x51, // size 1 OP_GetZero OP_GetZero = 0x51,
unk_082 = 0x52, // size 1 OP_wait OP_wait = 0x52,
unk_083 = 0x53, // size 1 OP_waittill OP_waittill = 0x53,
unk_084 = 0x54, // size 5, stack string OP_GetIString OP_GetIString = 0x54,
unk_085 = 0x55, // size 5, stack 8 + 8 OP_ScriptFarFunctionCall OP_ScriptFarFunctionCall = 0x55,
unk_086 = 0x56, // size 1 OP_GetAnimObject OP_GetAnimObject = 0x56,
unk_087 = 0x57, // size 2, stack string OP_GetAnimTree OP_GetAnimTree = 0x57,
unk_088 = 0x58, // size 2 OP_EvalLocalArrayCached OP_EvalLocalArrayCached = 0x58,
unk_089 = 0x59, // size 1 OP_mod OP_mod = 0x59,
unk_090 = 0x5A, // size 6, stack 8 + 8 OP_ScriptFarMethodThreadCall OP_ScriptFarMethodThreadCall = 0x5A,
unk_091 = 0x5B, // size 3 OP_GetUnsignedShort OP_GetUnsignedShort = 0x5B,
unk_092 = 0x5C, // size 1 OP_clearparams OP_clearparams = 0x5C,
unk_093 = 0x5D, // size 2 OP_ScriptMethodThreadCallPointer OP_ScriptMethodThreadCallPointer = 0x5D,
unk_094 = 0x5E, // size 1 OP_ScriptFunctionCallPointer OP_ScriptFunctionCallPointer = 0x5E,
unk_095 = 0x5F, // size 1 OP_EmptyArray OP_EmptyArray = 0x5F,
unk_096 = 0x60, // size 2 OP_SafeSetVariableFieldCached OP_SafeSetVariableFieldCached = 0x60,
unk_097 = 0x61, // missing OP_ClearVariableField OP_ClearVariableField = 0x61,
unk_098 = 0x62, // size 9, script 8 (hash?) OP_EvalFieldVariableRef OP_EvalFieldVariableRef = 0x62,
unk_099 = 0x63, // missing OP_EvalNewLocalVariableRefCached0 OP_EvalNewLocalVariableRefCached0 = 0x63,
unk_100 = 0x64, // size 5 OP_GetFloat OP_GetFloat = 0x64,
unk_101 = 0x65, // size 2 OP_EvalLocalVariableRefCached OP_EvalLocalVariableRefCached = 0x65,
unk_102 = 0x66, // size 3 OP_JumpOnFalse OP_JumpOnFalse = 0x66,
unk_103 = 0x67, // size 1 OP_BoolComplement OP_BoolComplement = 0x67,
unk_104 = 0x68, // size 2 OP_ScriptThreadCallPointer OP_ScriptThreadCallPointer = 0x68,
unk_105 = 0x69, // size 1 OP_less OP_less = 0x69,
unk_106 = 0x6A, // size 1 OP_BoolNot OP_BoolNot = 0x6A,
unk_107 = 0x6B, // size 1 OP_waittillFrameEnd OP_waittillFrameEnd = 0x6B,
unk_108 = 0x6C, // size 1 OP_waitframe OP_waitframe = 0x6C,
unk_109 = 0x6D, // size 5, stack string OP_GetString OP_GetString = 0x6D,
unk_110 = 0x6E, // size 9, script 8 (hash?) OP_EvalLevelFieldVariable OP_EvalLevelFieldVariable = 0x6E,
unk_111 = 0x6F, // size 1 OP_GetLevelObject OP_GetLevelObject = 0x6F,
unk_112 = 0x70, // size 1 OP_inc OP_inc = 0x70,
unk_113 = 0x71, // size 4, stack string (hash) OP_CallBuiltinMethod OP_CallBuiltinMethod = 0x71,
unk_114 = 0x72, // size 1 OP_GetAnim OP_GetAnim = 0x72,
unk_115 = 0x73, // size 5 OP_switch OP_switch = 0x73,
unk_116 = 0x74, // size 1 OP_SetVariableField OP_SetVariableField = 0x74,
unk_117 = 0x75, // size 1 OP_divide OP_divide = 0x75,
unk_118 = 0x76, // size 6, stack 8 + 8 OP_ScriptFarChildThreadCall OP_ScriptFarChildThreadCall = 0x76,
unk_119 = 0x77, // size 1 OP_multiply OP_multiply = 0x77,
unk_120 = 0x78, // size 2 OP_ClearLocalVariableFieldCached OP_ClearLocalVariableFieldCached = 0x78,
unk_121 = 0x79, // size 9, script 8 (hash?) OP_EvalAnimFieldVariableRef OP_EvalAnimFieldVariableRef = 0x79,
unk_122 = 0x7A, // size 2 OP_EvalLocalArrayRefCached OP_EvalLocalArrayRefCached = 0x7A,
unk_123 = 0x7B, // size 1 OP_EvalLocalVariableRefCached0 OP_EvalLocalVariableRefCached0 = 0x7B,
unk_124 = 0x7C, // size 1 OP_bit_and OP_bit_and = 0x7C,
unk_125 = 0x7D, // size ?, stack string * 2 OP_GetAnimation OP_GetAnimation = 0x7D,
unk_126 = 0x7E, // size 5, stack 8 + 8 OP_GetFarFunction OP_GetFarFunction = 0x7E,
unk_127 = 0x7F, // size 2 OP_CallBuiltinPointer OP_CallBuiltinPointer = 0x7F,
unk_128 = 0x80, // size 5 OP_jump OP_jump = 0x80,
unk_129 = 0x81, // size 1 OP_voidCodepos OP_voidCodepos = 0x81,
unk_130 = 0x82, // size 5, stack 8 + 8 OP_ScriptFarMethodCall OP_ScriptFarMethodCall = 0x82,
unk_131 = 0x83, // size 1 OP_inequality OP_inequality = 0x83,
unk_132 = 0x84, // size 1 OP_bit_ex_or OP_bit_ex_or = 0x84,
unk_133 = 0x85, // size 9 OP_unk_133 = 0x85, // size 9
unk_134 = 0x86, // size 5 OP_unk_134 = 0x86, // size 5
unk_135 = 0x87, // size 9 OP_unk_135 = 0x87, // size 9
unk_136 = 0x88, // size 9 OP_unk_136 = 0x88, // size 9
unk_137 = 0x89, // size 5 OP_unk_137 = 0x89, // size 5
unk_138 = 0x8A, // size 9 OP_unk_138 = 0x8A, // size 9
unk_139 = 0x8B, OP_unk_139 = 0x8B,
unk_140 = 0x8C, OP_unk_140 = 0x8C,
unk_141 = 0x8D, OP_unk_141 = 0x8D,
unk_142 = 0x8E, OP_unk_142 = 0x8E,
unk_143 = 0x8F, OP_unk_143 = 0x8F,
unk_144 = 0x90, OP_unk_144 = 0x90,
unk_145 = 0x91, // size 6 OP_prof_begin OP_prof_begin = 0x91,
unk_146 = 0x92, // size 2 OP_prof_end OP_prof_end = 0x92,
unk_147 = 0x93, // OP_breakpoint OP_breakpoint = 0x93,
unk_148 = 0x94, // OP_assignmentBreakpoint OP_assignmentBreakpoint = 0x94,
unk_149 = 0x95, // OP_manualAndAssignmentBreakpoint OP_manualAndAssignmentBreakpoint = 0x95,
unk_150 = 0x96, // size 1 OP_BoolNotAfterAnd OP_BoolNotAfterAnd = 0x96,
unk_151 = 0x97, // size 2 + 8 * count (params?) OP_FormalParams OP_FormalParams = 0x97,
unk_152 = 0x98, // size 1 OP_IsDefined OP_IsDefined = 0x98,
unk_153 = 0x99, // size 1 OP_IsTrue OP_IsTrue = 0x99,
unk_154 = 0x9A, // size 5, stack 4 OP_NativeGetFarFunction OP_NativeGetFarFunction = 0x9A,
unk_155 = 0x9B, // size 5, stack 4 OP_NativeFarFunctionCall OP_NativeFarFunctionCall = 0x9B,
unk_156 = 0x9C, // size 5, stack 4 OP_NativeFarMethodCall OP_NativeFarMethodCall = 0x9C,
unk_157 = 0x9D, // size 6, stack 4 OP_NativeFarFunctionThreadCall OP_NativeFarFunctionThreadCall = 0x9D,
unk_158 = 0x9E, // size 6, stack 4 OP_NativeFarMethodThreadCall OP_NativeFarMethodThreadCall = 0x9E,
unk_159 = 0x9F, // size 6, stack 4 OP_NativeFarFunctionChildThreadCall OP_NativeFarFunctionChildThreadCall = 0x9F,
unk_160 = 0xA0, // size 6, stack 4 OP_NativeFarMethodChildThreadCall OP_NativeFarMethodChildThreadCall = 0xA0,
unk_161 = 0xA1, // size 9 OP_EvalNewLocalArrayRefCached0_Precompiled OP_EvalNewLocalArrayRefCached0_Precompiled = 0xA1,
unk_162 = 0xA2, // size 9 OP_SetNewLocalVariableFieldCached0_Precompiled OP_SetNewLocalVariableFieldCached0_Precompiled = 0xA2,
unk_163 = 0xA3, // size 9 OP_CreateLocalVariable_Precompiled OP_CreateLocalVariable_Precompiled = 0xA3,
unk_164 = 0xA4, // size 9 OP_SafeCreateVariableFieldCached_Precompiled OP_SafeCreateVariableFieldCached_Precompiled = 0xA4,
unk_165 = 0xA5, // size 2 + 8 * count (params?) OP_FormalParams_Precompiled OP_FormalParams_Precompiled = 0xA5,
unk_166 = 0xA6, // size 9, stack 8 OP_unk_166 = 0xA6, // size 9, stack 8
OP_count = 0xA7, OP_count = 0xA7,
}; };

View File

@ -297,173 +297,173 @@ auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesy
const std::array<std::pair<std::uint8_t, const char*>, 167> opcode_list const std::array<std::pair<std::uint8_t, const char*>, 167> opcode_list
{{ {{
{ 0x00, "unk_000" }, { 0x00, "OP_CastFieldObject" },
{ 0x01, "unk_001" }, { 0x01, "OP_SetLocalVariableFieldCached" },
{ 0x02, "unk_002" }, { 0x02, "OP_plus" },
{ 0x03, "unk_003" }, { 0x03, "OP_RemoveLocalVariables" },
{ 0x04, "unk_004" }, { 0x04, "OP_EvalSelfFieldVariableRef" },
{ 0x05, "unk_005" }, { 0x05, "OP_ScriptFarMethodChildThreadCall" },
{ 0x06, "unk_006" }, { 0x06, "OP_GetGameRef" },
{ 0x07, "unk_007" }, { 0x07, "OP_EvalAnimFieldVariable" },
{ 0x08, "unk_008" }, { 0x08, "OP_EvalLevelFieldVariableRef" },
{ 0x09, "unk_009" }, { 0x09, "OP_GetThisthread" },
{ 0x0A, "unk_010" }, { 0x0A, "OP_greater" },
{ 0x0B, "unk_011" }, { 0x0B, "OP_waittillmatch" },
{ 0x0C, "unk_012" }, { 0x0C, "OP_shift_right" },
{ 0x0D, "unk_013" }, { 0x0D, "OP_dec" },
{ 0x0E, "unk_014" }, { 0x0E, "OP_JumpOnTrue" },
{ 0x0F, "unk_015" }, { 0x0F, "OP_bit_or" },
{ 0x10, "unk_016" }, { 0x10, "OP_equality" },
{ 0x11, "unk_017" }, { 0x11, "OP_ClearLocalVariableFieldCached0" },
{ 0x12, "unk_018" }, { 0x12, "OP_notify" },
{ 0x13, "unk_019" }, { 0x13, "OP_GetVector" },
{ 0x14, "unk_020" }, { 0x14, "OP_ScriptMethodChildThreadCallPointer" },
{ 0x15, "unk_021" }, { 0x15, "OP_PreScriptCall" },
{ 0x16, "unk_022" }, { 0x16, "OP_GetByte" },
{ 0x17, "unk_023" }, { 0x17, "OP_ScriptFarThreadCall" },
{ 0x18, "unk_024" }, { 0x18, "OP_SetSelfFieldVariableField" },
{ 0x19, "unk_025" }, { 0x19, "OP_JumpOnFalseExpr" },
{ 0x1A, "unk_026" }, { 0x1A, "OP_GetUndefined" },
{ 0x1B, "unk_027" }, { 0x1B, "OP_jumpback" },
{ 0x1C, "unk_028" }, { 0x1C, "OP_JumpOnTrueExpr" },
{ 0x1D, "unk_029" }, { 0x1D, "OP_CallBuiltin" },
{ 0x1E, "unk_030" }, { 0x1E, "OP_SetLocalVariableFieldCached0" },
{ 0x1F, "unk_031" }, { 0x1F, "OP_ClearFieldVariable" },
{ 0x20, "unk_032" }, { 0x20, "OP_GetLevel" },
{ 0x21, "unk_033" }, { 0x21, "OP_size" },
{ 0x22, "unk_034" }, { 0x22, "OP_SafeSetWaittillVariableFieldCached" },
{ 0x23, "unk_035" }, { 0x23, "OP_AddArray" },
{ 0x24, "unk_036" }, { 0x24, "OP_endon" },
{ 0x25, "unk_037" }, { 0x25, "OP_EvalFieldVariable" },
{ 0x26, "unk_038" }, { 0x26, "OP_shift_left" },
{ 0x27, "unk_039" }, { 0x27, "OP_EvalLocalArrayRefCached0" },
{ 0x28, "unk_040" }, { 0x28, "OP_Return" },
{ 0x29, "unk_041" }, { 0x29, "OP_CreateLocalVariable" },
{ 0x2A, "unk_042" }, { 0x2A, "OP_SafeSetVariableFieldCached0" },
{ 0x2B, "unk_043" }, { 0x2B, "OP_GetBuiltinFunction" },
{ 0x2C, "unk_044" }, { 0x2C, "OP_CallBuiltinMethodPointer" },
{ 0x2D, "unk_045" }, { 0x2D, "OP_GetSelfObject" },
{ 0x2E, "unk_046" }, { 0x2E, "OP_GetGame" },
{ 0x2F, "unk_047" }, { 0x2F, "OP_SetLevelFieldVariableField" },
{ 0x30, "unk_048" }, { 0x30, "OP_EvalArray" },
{ 0x31, "unk_049" }, { 0x31, "OP_GetSelf" },
{ 0x32, "unk_050" }, { 0x32, "OP_End" },
{ 0x33, "unk_051" }, { 0x33, "OP_EvalSelfFieldVariable" },
{ 0x34, "unk_052" }, { 0x34, "OP_less_equal" },
{ 0x35, "unk_053" }, { 0x35, "OP_EvalLocalVariableCached0" },
{ 0x36, "unk_054" }, { 0x36, "OP_EvalLocalVariableCached1" },
{ 0x37, "unk_055" }, { 0x37, "OP_EvalLocalVariableCached2" },
{ 0x38, "unk_056" }, { 0x38, "OP_EvalLocalVariableCached3" },
{ 0x39, "unk_057" }, { 0x39, "OP_EvalLocalVariableCached4" },
{ 0x3A, "unk_058" }, { 0x3A, "OP_EvalLocalVariableCached5" },
{ 0x3B, "unk_059" }, { 0x3B, "OP_EvalLocalVariableCached" },
{ 0x3C, "unk_060" }, { 0x3C, "OP_EvalNewLocalArrayRefCached0" },
{ 0x3D, "unk_061" }, { 0x3D, "OP_ScriptChildThreadCallPointer" },
{ 0x3E, "unk_062" }, { 0x3E, "OP_EvalLocalVariableObjectCached" },
{ 0x3F, "unk_063" }, { 0x3F, "OP_GetInteger" },
{ 0x40, "unk_064" }, { 0x40, "OP_ScriptMethodCallPointer" },
{ 0x41, "unk_065" }, { 0x41, "OP_checkclearparams" },
{ 0x42, "unk_066" }, { 0x42, "OP_SetAnimFieldVariableField" },
{ 0x43, "unk_067" }, { 0x43, "OP_waittillmatch2" },
{ 0x44, "unk_068" }, { 0x44, "OP_minus" },
{ 0x45, "unk_069" }, { 0x45, "OP_GetNegUnsignedShort" },
{ 0x46, "unk_070" }, { 0x46, "OP_GetNegByte" },
{ 0x47, "unk_071" }, { 0x47, "OP_SafeCreateVariableFieldCached" },
{ 0x48, "unk_072" }, { 0x48, "OP_greater_equal" },
{ 0x49, "unk_073" }, { 0x49, "OP_vector" },
{ 0x4A, "unk_074" }, { 0x4A, "OP_GetBuiltinMethod" },
{ 0x4B, "unk_075" }, { 0x4B, "OP_endswitch" },
{ 0x4C, "unk_076" }, { 0x4C, "OP_ClearArray" },
{ 0x4D, "unk_077" }, { 0x4D, "OP_DecTop" },
{ 0x4E, "unk_078" }, { 0x4E, "OP_CastBool" },
{ 0x4F, "unk_079" }, { 0x4F, "OP_EvalArrayRef" },
{ 0x50, "unk_080" }, { 0x50, "OP_SetNewLocalVariableFieldCached0" },
{ 0x51, "unk_081" }, { 0x51, "OP_GetZero" },
{ 0x52, "unk_082" }, { 0x52, "OP_wait" },
{ 0x53, "unk_083" }, { 0x53, "OP_waittill" },
{ 0x54, "unk_084" }, { 0x54, "OP_GetIString" },
{ 0x55, "unk_085" }, { 0x55, "OP_ScriptFarFunctionCall" },
{ 0x56, "unk_086" }, { 0x56, "OP_GetAnimObject" },
{ 0x57, "unk_087" }, { 0x57, "OP_GetAnimTree" },
{ 0x58, "unk_088" }, { 0x58, "OP_EvalLocalArrayCached" },
{ 0x59, "unk_089" }, { 0x59, "OP_mod" },
{ 0x5A, "unk_090" }, { 0x5A, "OP_ScriptFarMethodThreadCall" },
{ 0x5B, "unk_091" }, { 0x5B, "OP_GetUnsignedShort" },
{ 0x5C, "unk_092" }, { 0x5C, "OP_clearparams" },
{ 0x5D, "unk_093" }, { 0x5D, "OP_ScriptMethodThreadCallPointer" },
{ 0x5E, "unk_094" }, { 0x5E, "OP_ScriptFunctionCallPointer" },
{ 0x5F, "unk_095" }, { 0x5F, "OP_EmptyArray" },
{ 0x60, "unk_096" }, { 0x60, "OP_SafeSetVariableFieldCached" },
{ 0x61, "unk_097" }, { 0x61, "OP_ClearVariableField" },
{ 0x62, "unk_098" }, { 0x62, "OP_EvalFieldVariableRef" },
{ 0x63, "unk_099" }, { 0x63, "OP_EvalNewLocalVariableRefCached0" },
{ 0x64, "unk_100" }, { 0x64, "OP_GetFloat" },
{ 0x65, "unk_101" }, { 0x65, "OP_EvalLocalVariableRefCached" },
{ 0x66, "unk_102" }, { 0x66, "OP_JumpOnFalse" },
{ 0x67, "unk_103" }, { 0x67, "OP_BoolComplement" },
{ 0x68, "unk_104" }, { 0x68, "OP_ScriptThreadCallPointer" },
{ 0x69, "unk_105" }, { 0x69, "OP_less" },
{ 0x6A, "unk_106" }, { 0x6A, "OP_BoolNot" },
{ 0x6B, "unk_107" }, { 0x6B, "OP_waittillFrameEnd" },
{ 0x6C, "unk_108" }, { 0x6C, "OP_waitframe" },
{ 0x6D, "unk_109" }, { 0x6D, "OP_GetString" },
{ 0x6E, "unk_110" }, { 0x6E, "OP_EvalLevelFieldVariable" },
{ 0x6F, "unk_111" }, { 0x6F, "OP_GetLevelObject" },
{ 0x70, "unk_112" }, { 0x70, "OP_inc" },
{ 0x71, "unk_113" }, { 0x71, "OP_CallBuiltinMethod" },
{ 0x72, "unk_114" }, { 0x72, "OP_GetAnim" },
{ 0x73, "unk_115" }, { 0x73, "OP_switch" },
{ 0x74, "unk_116" }, { 0x74, "OP_SetVariableField" },
{ 0x75, "unk_117" }, { 0x75, "OP_divide" },
{ 0x76, "unk_118" }, { 0x76, "OP_ScriptFarChildThreadCall" },
{ 0x77, "unk_119" }, { 0x77, "OP_multiply" },
{ 0x78, "unk_120" }, { 0x78, "OP_ClearLocalVariableFieldCached" },
{ 0x79, "unk_121" }, { 0x79, "OP_EvalAnimFieldVariableRef" },
{ 0x7A, "unk_122" }, { 0x7A, "OP_EvalLocalArrayRefCached" },
{ 0x7B, "unk_123" }, { 0x7B, "OP_EvalLocalVariableRefCached0" },
{ 0x7C, "unk_124" }, { 0x7C, "OP_bit_and" },
{ 0x7D, "unk_125" }, { 0x7D, "OP_GetAnimation" },
{ 0x7E, "unk_126" }, { 0x7E, "OP_GetFarFunction" },
{ 0x7F, "unk_127" }, { 0x7F, "OP_CallBuiltinPointer" },
{ 0x80, "unk_128" }, { 0x80, "OP_jump" },
{ 0x81, "unk_129" }, { 0x81, "OP_voidCodepos" },
{ 0x82, "unk_130" }, { 0x82, "OP_ScriptFarMethodCall" },
{ 0x83, "unk_131" }, { 0x83, "OP_inequality" },
{ 0x84, "unk_132" }, { 0x84, "OP_bit_ex_or" },
{ 0x85, "unk_133" }, { 0x85, "OP_unk_133" },
{ 0x86, "unk_134" }, { 0x86, "OP_unk_134" },
{ 0x87, "unk_135" }, { 0x87, "OP_unk_135" },
{ 0x88, "unk_136" }, { 0x88, "OP_unk_136" },
{ 0x89, "unk_137" }, { 0x89, "OP_unk_137" },
{ 0x8A, "unk_138" }, { 0x8A, "OP_unk_138" },
{ 0x8B, "unk_139" }, { 0x8B, "OP_unk_139" },
{ 0x8C, "unk_140" }, { 0x8C, "OP_unk_140" },
{ 0x8D, "unk_141" }, { 0x8D, "OP_unk_141" },
{ 0x8E, "unk_142" }, { 0x8E, "OP_unk_142" },
{ 0x8F, "unk_143" }, { 0x8F, "OP_unk_143" },
{ 0x90, "unk_144" }, { 0x90, "OP_unk_144" },
{ 0x91, "unk_145" }, { 0x91, "OP_prof_begin" },
{ 0x92, "unk_146" }, { 0x92, "OP_prof_end" },
{ 0x93, "unk_147" }, { 0x93, "OP_breakpoint" },
{ 0x94, "unk_148" }, { 0x94, "OP_assignmentBreakpoint" },
{ 0x95, "unk_149" }, { 0x95, "OP_manualAndAssignmentBreakpoint" },
{ 0x96, "unk_150" }, { 0x96, "OP_BoolNotAfterAnd" },
{ 0x97, "unk_151" }, { 0x97, "OP_FormalParams" },
{ 0x98, "unk_152" }, { 0x98, "OP_IsDefined" },
{ 0x99, "unk_153" }, { 0x99, "OP_IsTrue" },
{ 0x9A, "unk_154" }, { 0x9A, "OP_NativeGetFarFunction" },
{ 0x9B, "unk_155" }, { 0x9B, "OP_NativeFarFunctionCall" },
{ 0x9C, "unk_156" }, { 0x9C, "OP_NativeFarMethodCall" },
{ 0x9D, "unk_157" }, { 0x9D, "OP_NativeFarFunctionThreadCall" },
{ 0x9E, "unk_158" }, { 0x9E, "OP_NativeFarMethodThreadCall" },
{ 0x9F, "unk_159" }, { 0x9F, "OP_NativeFarFunctionChildThreadCall" },
{ 0xA0, "unk_160" }, { 0xA0, "OP_NativeFarMethodChildThreadCall" },
{ 0xA1, "unk_161" }, { 0xA1, "OP_EvalNewLocalArrayRefCached0_Precompiled" },
{ 0xA2, "unk_162" }, { 0xA2, "OP_SetNewLocalVariableFieldCached0_Precompiled" },
{ 0xA3, "unk_163" }, { 0xA3, "OP_CreateLocalVariable_Precompiled" },
{ 0xA4, "unk_164" }, { 0xA4, "OP_SafeCreateVariableFieldCached_Precompiled" },
{ 0xA5, "unk_165" }, { 0xA5, "OP_FormalParams_Precompiled" },
{ 0xA6, "unk_166" }, { 0xA6, "OP_unk_166" },
}}; }};
const std::array<std::pair<std::uint16_t, const char*>, 0> function_list const std::array<std::pair<std::uint16_t, const char*>, 0> function_list