| 
									
										
										
										
											2024-09-27 14:04:23 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 文件名:Hacker_RegApi.nut | 
					
						
							|  |  |  | 路径:Base/_Tool/Hacker_RegApi.nut | 
					
						
							|  |  |  | 创建日期:2024-09-25	18:31 | 
					
						
							|  |  |  | 文件用途:注册API | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | //工具类 | 
					
						
							|  |  |  | class R_Utils { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  |     String = { | 
					
						
							|  |  |  |         FindLastSubstring = function(str, substring) { | 
					
						
							|  |  |  |             local strLen = str.len(); | 
					
						
							|  |  |  |             local subLen = substring.len(); | 
					
						
							|  |  |  |             local lastIndex = -1; | 
					
						
							|  |  |  |             for (local i = 0; i <= strLen - subLen; i++) { | 
					
						
							|  |  |  |                 local found = true; | 
					
						
							|  |  |  |                 for (local j = 0; j< subLen; j++) { | 
					
						
							|  |  |  |                     if (str[i + j] != substring[j]) { | 
					
						
							|  |  |  |                         found = false; | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (found) { | 
					
						
							|  |  |  |                     lastIndex = i; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return lastIndex; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-09-27 14:04:23 +08:00
										 |  |  |     //播放音效 | 
					
						
							|  |  |  |     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(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  |     //读取文件 | 
					
						
							|  |  |  |     function GetScriptFileReader(Path, ...) { | 
					
						
							|  |  |  |         local AllocSize = 102400; | 
					
						
							|  |  |  |         if (vargc > 0) AllocSize = vargv[0]; | 
					
						
							|  |  |  |         //读取路径 | 
					
						
							|  |  |  |         local ReadPath = L_sq_P2I(Memory.allocUtf8String(Path).C_Object); | 
					
						
							|  |  |  |         //读取缓存 | 
					
						
							|  |  |  |         local Reader = Memory.alloc(AllocSize); | 
					
						
							|  |  |  |         local ReadBuffer = L_sq_P2I(Reader.C_Object); | 
					
						
							|  |  |  |         //实际读取大小 | 
					
						
							|  |  |  |         local ReadSizeer = Memory.alloc(4); | 
					
						
							|  |  |  |         local ReadSizeBuffer = L_sq_P2I(ReadSizeer.C_Object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local Flag = L_Sq_CallFunc(0x59E3D0, "bool", FFI_MS_CDECL, ["int", "int", "int", "int"], ReadPath, ReadBuffer, AllocSize, ReadSizeBuffer); | 
					
						
							|  |  |  |         if (Flag) { | 
					
						
							|  |  |  |             return { | 
					
						
							|  |  |  |                 Buffer = Reader, | 
					
						
							|  |  |  |                 Size = ReadSizeer.readInt() | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |         } else return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-27 14:04:23 +08:00
										 |  |  |     //读取配置表 | 
					
						
							|  |  |  |     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; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  |     //获取一个指定装备的角色对象 | 
					
						
							| 
									
										
										
										
											2024-10-05 11:46:39 +08:00
										 |  |  |     function GetCharacByEqu(Job, GrowType, Equ) { | 
					
						
							|  |  |  |         local Obj = sq_CreateCharacter(Job, GrowType); | 
					
						
							|  |  |  |         local ObjAddress = L_Sq_GetObjectAddress(Obj); | 
					
						
							|  |  |  |         foreach(value in Equ) { | 
					
						
							|  |  |  |             local ItemObject = L_sq_GetItem(value); | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  |             // L_Sq_CallFunc(0x825570, "void", FFI_THISCALL, ["int", "int"], ObjAddress, ItemObject); | 
					
						
							|  |  |  |             L_Sq_CallFunc(0x8265A0, "void", FFI_THISCALL, ["int", "int", "int"], ObjAddress, ItemObject, -1); | 
					
						
							| 
									
										
										
										
											2024-10-05 11:46:39 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  |         return sq_GetCNRDObjectToSQRCharacter(Obj); | 
					
						
							| 
									
										
										
										
											2024-10-05 11:46:39 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //获取装备编号的得文件路径 | 
					
						
							|  |  |  |     function GetEquPath(Equ) { | 
					
						
							|  |  |  |         local EquPathAddress = L_Sq_CallFunc(0x1219E80, "int", FFI_THISCALL, ["int", "int"], 0x1d7993c, Equ); | 
					
						
							|  |  |  |         if (EquPathAddress) { | 
					
						
							|  |  |  |             return NativePointer(EquPathAddress).readUnicodeString(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //获取Lst文件的返回Array | 
					
						
							|  |  |  |     function GetLstArr(Path, Header) { | 
					
						
							|  |  |  |         local Arr = []; | 
					
						
							|  |  |  |         local LstBuf = R_Utils.GetScriptFileReader(Path); | 
					
						
							|  |  |  |         if (LstBuf) { | 
					
						
							|  |  |  |             local IO = Sq_Point2Blob(L_sq_P2I(LstBuf.Buffer.C_Object), LstBuf.Size); | 
					
						
							|  |  |  |             local i = 2; | 
					
						
							|  |  |  |             while (i< LstBuf.Size) { | 
					
						
							|  |  |  |                 if ((LstBuf.Size - i) >= 10) { | 
					
						
							|  |  |  |                     IO.seek(i + 6); //内容指示位 | 
					
						
							|  |  |  |                     local FindKey = IO.readn('i'); | 
					
						
							|  |  |  |                     local Key = Rindro_Script.GetBinString(FindKey); | 
					
						
							|  |  |  |                     if (Key) { | 
					
						
							|  |  |  |                         local StrFilePath = Header + Key.tolower(); | 
					
						
							|  |  |  |                         Arr.append(StrFilePath); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } else break; | 
					
						
							|  |  |  |                 i += 10; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return Arr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //通过处理函数获取文件Table | 
					
						
							|  |  |  |     function GetFileTableByHandle(Path, Func) { | 
					
						
							|  |  |  |         local Data = {}; | 
					
						
							|  |  |  |         local FileData = R_Utils.GetScriptFileReader(Path); | 
					
						
							|  |  |  |         if (FileData) { | 
					
						
							|  |  |  |             if (FileData.Size >= 7) { | 
					
						
							|  |  |  |                 //创建Blob对象 | 
					
						
							|  |  |  |                 local IO = Sq_Point2Blob(L_sq_P2I(FileData.Buffer.C_Object), FileData.Size); | 
					
						
							|  |  |  |                 //以5为单步从第二位开始遍历字节 | 
					
						
							|  |  |  |                 local i = 2; | 
					
						
							|  |  |  |                 while (true) { | 
					
						
							|  |  |  |                     if (i< FileData.Size && FileData.Size - i >= 5) { | 
					
						
							|  |  |  |                         i = Func(Data, IO, i); | 
					
						
							|  |  |  |                     } else break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return Data; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //根据List读取文件地址 | 
					
						
							|  |  |  | // Rindro_Haker.LoadHook(0x1219E80, ["int", "int", "int"], | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(format("%02x", args[0])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //         // print(args[2]); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }, | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(666); | 
					
						
							|  |  |  | //         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  | //         // TTTAni <- args.pop(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //         // local Path = NativePointer(L_sq_I2P(args.pop())).readUnicodeString(); | 
					
						
							|  |  |  | //         // if (Path != "character/swordman/weapon/katana/kat_lowkogaras.equ" && Path != "new_elvengard.twn") { | 
					
						
							|  |  |  | //         //     print(args[0]); | 
					
						
							|  |  |  | //         //     print(args[1]); | 
					
						
							|  |  |  | //         //     // print(format("%02x", args[1])); | 
					
						
							|  |  |  | //         //     print(Path); | 
					
						
							|  |  |  | //         // } | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //可能是构造装备以及构造其他东西 | 
					
						
							|  |  |  | // Rindro_Haker.LoadHook(0x972220, ["int", "int", "int", "int"], | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(format("%02x", args[0])); | 
					
						
							|  |  |  | //         // local AniPath = NativePointer(L_sq_I2P(args[0])).readUnicodeString(); | 
					
						
							|  |  |  | //         if (args[0] == 10402) { | 
					
						
							|  |  |  | //             print(args[0]); | 
					
						
							|  |  |  | //             print(args[1]); | 
					
						
							|  |  |  | //             print(args[2]); | 
					
						
							|  |  |  | //         } | 
					
						
							|  |  |  | //         // print(args[2]); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }, | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(666); | 
					
						
							|  |  |  | //         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  | //         // TTTAni <- args.pop(); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //绘制字符 | 
					
						
							|  |  |  | getroottable().DrawCodeCallBackFunc <- {}; | 
					
						
							|  |  |  | // Rindro_Haker.LoadHook(0x1206BD0, ["int", "int", "int", "pointer", "int", "void"], | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print("nut:" + format("%02x", args[3])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //         if (args[3]) { | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | //             // for (local i = 0; i< 10000; i++) { | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | //             local DrawCode = NativePointer((args[3])).readUnicodeString(); | 
					
						
							|  |  |  | //             if (DrawCode in DrawCodeCallBackFunc) | 
					
						
							|  |  |  | //                 DrawCodeCallBackFunc[DrawCode](args); | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | //             // } | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | //         } | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }, | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(666); | 
					
						
							|  |  |  | //         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  | //         // TTTAni <- args.pop(); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | //绘制城镇回调 | 
					
						
							|  |  |  | getroottable().DrawTownCallBackFunc <- {}; | 
					
						
							|  |  |  | Rindro_Haker.LoadHook(0x1108700, ["int", "void"], | 
					
						
							|  |  |  |     function(args) { | 
					
						
							|  |  |  |         // print("nut:" + format("%02x", args[3])); | 
					
						
							|  |  |  |         // print(format("%02x", args[0])); | 
					
						
							|  |  |  |         foreach(Func in DrawTownCallBackFunc) { | 
					
						
							|  |  |  |             Func(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     function(args) { | 
					
						
							|  |  |  |         // print(666); | 
					
						
							|  |  |  |         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  |         // TTTAni <- args.pop(); | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //顺图 | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | function Rindro_Gm_MoveMap(obj) { | 
					
						
							|  |  |  |     if (sq_IsKeyDown(OPTION_HOTKEY_PAUSE_IN_TOWER, ENUM_SUBKEY_TYPE_ALL) && RINDROLOCAL) { | 
					
						
							|  |  |  |         if (KeyPress.isKeyPress(0)) L_sq_MoveMap(2); | 
					
						
							|  |  |  |         if (KeyPress.isKeyPress(1)) L_sq_MoveMap(0); | 
					
						
							|  |  |  |         if (KeyPress.isKeyPress(2)) L_sq_MoveMap(3); | 
					
						
							|  |  |  |         if (KeyPress.isKeyPress(3)) L_sq_MoveMap(1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | getroottable()["LenheartFuncTab"].rawset("Rindro_Gm_MoveMapFuncN", Rindro_Gm_MoveMap); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //丢弃物品回调 | 
					
						
							|  |  |  | getroottable().DiscardItemCallBackFunc <- {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function Sq_DiscardItem(Item) { | 
					
						
							|  |  |  |     local Flag = true; | 
					
						
							|  |  |  |     foreach(Func in DiscardItemCallBackFunc) { | 
					
						
							|  |  |  |         local Ret = Func(Item); | 
					
						
							|  |  |  |         if (!Ret) Flag = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Flag; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //从exe获取字符串 | 
					
						
							|  |  |  | getroottable()["Sq_GetExeStr_Map"] <- {}; | 
					
						
							|  |  |  | function Sq_GetExeStr_Event(Index) | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  |     if(Index in getroottable()["Sq_GetExeStr_Map"]){ | 
					
						
							|  |  |  |         return getroottable()["Sq_GetExeStr_Map"][Index](Index); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Index; | 
					
						
							| 
									
										
										
										
											2024-11-15 10:32:19 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2025-05-27 21:24:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // //hook打开窗口 | 
					
						
							|  |  |  | // Rindro_Haker.LoadHook(0xE6E070, ["int","int","int","int","void"], | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }, | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(666); | 
					
						
							|  |  |  | //         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  | //         // TTTAni <- args.pop(); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Rindro_Haker.LoadHook(0xE6E070, ["int", "int", "int", "int", "int"], | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         print("nut:" + format("%02x", args[0])); | 
					
						
							|  |  |  | //         print("nut:" + format("%02x", args[1])); | 
					
						
							|  |  |  | //         print("nut:" + format("%02x", args[2])); | 
					
						
							|  |  |  | //         print("nut:" + format("%02x", args[3])); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }, | 
					
						
							|  |  |  | //     function(args) { | 
					
						
							|  |  |  | //         // print(666); | 
					
						
							|  |  |  | //         // print(format("%02x", args.pop())); | 
					
						
							|  |  |  | //         // TTTAni <- args.pop(); | 
					
						
							|  |  |  | //         return null; | 
					
						
							|  |  |  | //     }); |