11
This commit is contained in:
30
Base/_Tool/Hacker_Class.nut
Normal file
30
Base/_Tool/Hacker_Class.nut
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
文件名:Hacker_Class.nut
|
||||
路径:Base/_Tool/Hacker_Class.nut
|
||||
创建日期:2024-09-24 06:25
|
||||
文件用途:
|
||||
*/
|
||||
class _Rindro_Hacker {
|
||||
HookTable = null;
|
||||
|
||||
constructor() {
|
||||
HookTable = {};
|
||||
}
|
||||
|
||||
function UnLoadHook(AddressStr) {
|
||||
Sq_DeHookFunc(HookTable[AddressStr]);
|
||||
}
|
||||
|
||||
function LoadHook(AddressStr, ArgumentArr, EnterFunc, LeaveFunc) {
|
||||
//如果已经HOOK过 需要先卸载原来的HOOK
|
||||
if (HookTable.rawin(AddressStr)) {
|
||||
UnLoadHook(AddressStr);
|
||||
print("地址: " + AddressStr + " 已经装载了Hook,本次操作将会卸载之前的Hook在执行。")
|
||||
}
|
||||
|
||||
local Controler = Sq_HookFunc(AddressStr, ArgumentArr, EnterFunc, LeaveFunc);
|
||||
HookTable.rawset(AddressStr, Controler);
|
||||
}
|
||||
}
|
||||
//初始化Hacker
|
||||
Rindro_Haker <- _Rindro_Hacker();
|
||||
42
Base/_Tool/Hacker_RegApi.nut
Normal file
42
Base/_Tool/Hacker_RegApi.nut
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
文件名:Hacker_RegApi.nut
|
||||
路径:Base/_Tool/Hacker_RegApi.nut
|
||||
创建日期:2024-09-25 18:31
|
||||
文件用途:注册API
|
||||
*/
|
||||
//工具类
|
||||
class R_Utils {
|
||||
|
||||
//播放音效
|
||||
function PlaySound(SoundName) {
|
||||
L_Sq_CallFunc(0x75BD70, "void", FFI_MS_CDECL, ["pointer", "int", "int", "int"], Memory.allocUtf8String(SoundName).C_Object, -1, 0, 0);
|
||||
}
|
||||
|
||||
//读取文件内容
|
||||
function ReadScript(Path, Size, CodePage) {
|
||||
local ReadPath = L_sq_P2I(Memory.allocUtf8String(Path).C_Object);
|
||||
local Reader = Memory.alloc(Size);
|
||||
local ReadBuffer = L_sq_P2I(Reader.C_Object);
|
||||
L_Sq_CallFunc(0x11A2030, "int", FFI_FASTCALL, ["int", "int", "int", "int", "int", "int"], 0x1D17638, 0, ReadPath, ReadBuffer, 0x100000, 0x19DAF4);
|
||||
|
||||
|
||||
if (CodePage == "utf8")
|
||||
return Reader.readUtf8String();
|
||||
if (CodePage == "unicode")
|
||||
return Reader.readUnicodeString();
|
||||
if (CodePage == "big5")
|
||||
return Reader.readBig5String();
|
||||
}
|
||||
|
||||
//读取配置表
|
||||
function ReadScriptConfig(Path, Size, ...) {
|
||||
local CodePage = "utf8";
|
||||
if (vargc > 0) CodePage = vargv[0];
|
||||
local Script = R_Utils.ReadScript(Path, Size, CodePage);
|
||||
local Func = compilestring("return " + Script);
|
||||
local Ret = Func();
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
201
Base/_Tool/MemoryClass.nut
Normal file
201
Base/_Tool/MemoryClass.nut
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
文件名:MemoryClass.nut
|
||||
路径:Base/_Tool/MemoryClass.nut
|
||||
创建日期:2024-09-24 08:22
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Memory {
|
||||
|
||||
function alloc(Size) {
|
||||
return NativePointer(Size);
|
||||
}
|
||||
|
||||
function allocUtf8String(Str) {
|
||||
return NativePointer(Str_Ptr(Str));
|
||||
}
|
||||
}
|
||||
|
||||
class NativePointer {
|
||||
|
||||
C_Object = null;
|
||||
|
||||
constructor(T) {
|
||||
if (type(T) == "integer") {
|
||||
C_Object = Sq_New_Point(T);
|
||||
//注册销毁伪析构
|
||||
Register_Destruction(C_Object, this);
|
||||
} else if (type(T) == "userdata") {
|
||||
C_Object = T;
|
||||
}
|
||||
}
|
||||
|
||||
function add(intoffset) {
|
||||
this.C_Object = L_sq_I2P(L_sq_P2I(this.C_Object) + intoffset);
|
||||
return this;
|
||||
}
|
||||
|
||||
function sub(intoffset) {
|
||||
this.C_Object = L_sq_I2P(L_sq_P2I(this.C_Object) - intoffset);
|
||||
return this;
|
||||
}
|
||||
|
||||
function writeByteArray(arr) {
|
||||
Sq_Memory_WriteByteArr(this.C_Object, arr);
|
||||
}
|
||||
|
||||
function readByteArray(size) {
|
||||
local PointB = Sq_Point2Blob(this.C_Object, size);
|
||||
local arr = [];
|
||||
foreach(value in PointB) {
|
||||
arr.append(value);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
function write(value, type) {
|
||||
local Buf = blob(0);
|
||||
Buf.writen(value, type);
|
||||
local arr = [];
|
||||
foreach(value in Buf) {
|
||||
arr.append(value);
|
||||
}
|
||||
writeByteArray(arr);
|
||||
}
|
||||
|
||||
function writeS8(value) {
|
||||
write(value, 'c');
|
||||
}
|
||||
|
||||
function writeU8(value) {
|
||||
write(value, 'b');
|
||||
}
|
||||
|
||||
function writeS16(value) {
|
||||
write(value, 's');
|
||||
}
|
||||
|
||||
function writeU16(value) {
|
||||
write(value, 'w');
|
||||
}
|
||||
|
||||
function writeS32(value) {
|
||||
write(value, 'i');
|
||||
}
|
||||
|
||||
function writeU32(value) {
|
||||
write(value, 'i');
|
||||
}
|
||||
|
||||
function writeShort(value) {
|
||||
write(value, 's');
|
||||
}
|
||||
|
||||
function writeUShort(value) {
|
||||
write(value, 'w');
|
||||
}
|
||||
|
||||
function writeInt(value) {
|
||||
write(value, 'i');
|
||||
}
|
||||
|
||||
function writeUInt(value) {
|
||||
write(value, 'i');
|
||||
}
|
||||
|
||||
function writeFloat(value) {
|
||||
write(value, 'f');
|
||||
}
|
||||
|
||||
function writeDouble(value) {
|
||||
write(value, 'd');
|
||||
}
|
||||
|
||||
|
||||
function read(type) {
|
||||
local Buf = Sq_Point2Blob(this.C_Object, 4);
|
||||
return Buf.readn(type);
|
||||
}
|
||||
|
||||
function readS8() {
|
||||
return read('c');
|
||||
}
|
||||
|
||||
function readU8() {
|
||||
return read('b');
|
||||
}
|
||||
|
||||
function readS16() {
|
||||
return read('s');
|
||||
}
|
||||
|
||||
function readU16() {
|
||||
return read('w');
|
||||
}
|
||||
|
||||
function readS32() {
|
||||
return read('i');
|
||||
}
|
||||
|
||||
function readU32() {
|
||||
return read('i');
|
||||
}
|
||||
|
||||
function readShort() {
|
||||
return read('s');
|
||||
}
|
||||
|
||||
function readUShort() {
|
||||
return read('w');
|
||||
}
|
||||
|
||||
function readInt() {
|
||||
return read('i');
|
||||
}
|
||||
|
||||
function readUInt() {
|
||||
return read('i');
|
||||
}
|
||||
|
||||
function readFloat() {
|
||||
return read('f');
|
||||
}
|
||||
|
||||
function readDouble() {
|
||||
return read('d');
|
||||
}
|
||||
|
||||
|
||||
function readUnicodeString(...) {
|
||||
if (vargc > 0) {
|
||||
return Sq_Memory_ReadString(this.C_Object, vargv[0]);
|
||||
} else {
|
||||
return Sq_Memory_ReadString(this.C_Object);
|
||||
}
|
||||
}
|
||||
|
||||
function readUtf8String(...) {
|
||||
if (vargc > 0) {
|
||||
return Sq_Memory_ReadStringByUtf8(this.C_Object, vargv[0]);
|
||||
} else {
|
||||
return Sq_Memory_ReadStringByUtf8(this.C_Object);
|
||||
}
|
||||
}
|
||||
|
||||
function readBig5String(...) {
|
||||
if (vargc > 0) {
|
||||
return Sq_Memory_ReadStringByBig5(this.C_Object, vargv[0]);
|
||||
} else {
|
||||
return Sq_Memory_ReadStringByBig5(this.C_Object);
|
||||
}
|
||||
}
|
||||
|
||||
function readPointer() {
|
||||
return Sq_ReadPoint(this.C_Object);
|
||||
}
|
||||
|
||||
function tostring() {
|
||||
return this.C_Object.tostring();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user