From feb4773c65b02d8f5c736d8cf321879f26be095b Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Sun, 13 Feb 2022 19:54:59 +0800 Subject: [PATCH] 11 --- test/dllmain.cpp | 2 +- test/pch.h | 27 +++++++++++++++++++++------ test/test.vcxproj | 4 ++-- test/函数块.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/test/dllmain.cpp b/test/dllmain.cpp index 6f8d82d..4ef3d52 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -27,7 +27,7 @@ uint32_t NewClosure(uint32_t v, void* f, int freeVarsCnt) return MLnewclosure(v, f, freeVarsCnt); } -static realSqPushString* MLSqPushString = NULL; +static SqPushStringFunc* MLSqPushString = NULL; uint32_t NewPushString(uint32_t v, wchar_t* f, int freeVarsCnt) { diff --git a/test/pch.h b/test/pch.h index c1cfd86..8697b16 100644 --- a/test/pch.h +++ b/test/pch.h @@ -28,12 +28,9 @@ //-------------------------------------------------------------------------------------------Squirrel -// Push 根表 -typedef int(SqPushRootT)(uint32_t v); -static SqPushRootT* SQPushRootTable = (SqPushRootT*)0x1358C50; -// Push 函数名 -typedef int(realSqPushString)(uint32_t v, const wchar_t* funcName, int a); -static realSqPushString* RealSqPushString = (realSqPushString*)0x1358A60; +// PushRoot +typedef int(SqPushRootFunc)(uint32_t v); +static SqPushRootFunc* SQPushRootTable = (SqPushRootFunc*)0x1358C50; // Push 函数绑定闭包 typedef int(realSqNewClosure)(uint32_t v, void* funcAddr, int a); static realSqNewClosure* RealSqNewClosure = (realSqNewClosure*)0x135B850; @@ -61,6 +58,24 @@ static SqGetUserdataFunc* SQGetUserdata = (SqGetUserdataFunc*)0x1358EC0; //GetObjtypetag typedef int(SqGetObjtypetagFunc)(uint32_t v, DWORD* up); static SqGetObjtypetagFunc* SQGetObjtypetag = (SqGetObjtypetagFunc*)0x1358F20; +//GetUserpointer +typedef int(SqGetUserpointerFunc)(uint32_t v, uint32_t idx ,DWORD* up); +static SqGetUserpointerFunc* SQGetUserpointer = (SqGetUserpointerFunc*)0x1358F80; +//GetTop +typedef int(SqGetTopFunc)(uint32_t v); +static SqGetTopFunc* SQGetTop = (SqGetTopFunc*)0x1358FC0; +//PushString +typedef int(SqPushStringFunc)(uint32_t v, const wchar_t* s, int len); +static SqPushStringFunc* SQPushString = (SqPushStringFunc*)0x1358A60; +//PushInt +typedef int(SqPushIntFunc)(uint32_t v, int sint); +static SqPushIntFunc* SQPushInt = (SqPushIntFunc*)0x1358AD0; +//PushBool +typedef int(SqPushBoolFunc)(uint32_t v, bool sbool); +static SqPushBoolFunc* SQPushBool = (SqPushBoolFunc*)0x1358B10; +//PushFloat +typedef int(SqPushFloatFunc)(uint32_t v, float sfloat); +static SqPushFloatFunc* SQPushFloat = (SqPushFloatFunc*)0x1358B60; //获取Squirrel v 基址 inline uint32_t GetSqVm(); diff --git a/test/test.vcxproj b/test/test.vcxproj index 4b0b68c..b537bf2 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -97,7 +97,7 @@ Console - true + false false @@ -117,7 +117,7 @@ Console true true - true + false false squirrel.lib;libMinHook.x86.lib;%(AdditionalDependencies) diff --git a/test/函数块.cpp b/test/函数块.cpp index 114304c..4bf29c3 100644 --- a/test/函数块.cpp +++ b/test/函数块.cpp @@ -251,7 +251,7 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v) if (!v) v = GetSqVm(); SQPushRootTable(v); - RealSqPushString(v, funcName, -1); + SQPushString(v, funcName, -1); RealSqNewClosure(v, funcAddr, 0); SQNewSlot(v, -3, false); SQPopTop(v); @@ -464,6 +464,48 @@ static SQInteger GivePlayerEqu(HSQUIRRELVM v) return 1; } +//ȥ +static int GoDungeon(uint32_t v) +{ + int n1 = 0; + int n2 = 0; + int n3 = 0; + int n4 = 0; + + int num; + num = SQGetTop(v); + + if (num == 2) + { + SQGetInt(v, 2, &n1); + } + else if (num == 5) + { + SQGetInt(v, 2, &n1); + SQGetInt(v, 3, &n2); + SQGetInt(v, 4, &n3); + SQGetInt(v, 5, &n4); + } + else + { + SQPushBool(v, false); + return 1; + } + + _SendpacksType(*_SendClass, 0, 15); + _SendPacks(); + + _SendpacksType(*_SendClass, 0, 16); + _SendPacksWord(*_SendClass, 0, n1); + _SendPacksByte(*_SendClass, 0, n2); + _SendPacksByte(*_SendClass, 0, n3); + _SendPacksByte(*_SendClass, 0, n4); + _SendPacks(); + + SQPushBool(v, true); + return 1; +} + void RegisterNut() { RegisterNutApi(L"L_sq_Test", sq_Test); @@ -480,6 +522,7 @@ void RegisterNut() RegisterNutApi(L"L_sq_SendPack", SendPack); RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem); RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu); + RegisterNutApi(L"L_sq_GoDungeon", GoDungeon); }