diff --git a/test/dllmain.cpp b/test/dllmain.cpp index 9881caa..6f8d82d 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -1,6 +1,5 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -//#include "函数块.h" @@ -9,15 +8,6 @@ - - - - -typedef int(SqGetStringFunc)(uint32_t v, uint32_t stackIndex, wchar_t** ppString); -static SqGetStringFunc* SQGetString = (SqGetStringFunc*)0x1358E70; - - - static realSqNewClosure* MLnewclosure = NULL; uint32_t NewClosure(uint32_t v, void* f, int freeVarsCnt) @@ -54,10 +44,6 @@ int HOOK() { std::cout << u8"开始hook" << std::endl; - if (MH_Initialize() != MH_OK) - { - return 1; - } /* if (MH_CreateHook((void*)0x135B850, &NewClosure, @@ -92,14 +78,11 @@ int HOOK() } - -typedef int(isgm)(int C); -static isgm* gm = (isgm*)0x176F380; - - void testcall() { + + //SQDofile(GetSqVm(),L"1.cpp",0,0); //std::cout << gm(0x186FB828) << std::endl; diff --git a/test/pch.h b/test/pch.h index 9a3fc2a..c1cfd86 100644 --- a/test/pch.h +++ b/test/pch.h @@ -43,7 +43,24 @@ static SqNewSlot* SQNewSlot = (SqNewSlot*)0x135AA80; // 平栈 typedef int(SqPopTop)(uint32_t v); static SqPopTop* SQPopTop = (SqPopTop*)0x1358FF0; - +//GetInt +typedef int(SqGetIntFunc)(uint32_t v, uint32_t stackIndex, int* sint); +static SqGetIntFunc* SQGetInt = (SqGetIntFunc*)0x1358D70; +//GetFloat +typedef int(SqGetFloatFunc)(uint32_t v, uint32_t stackIndex, float* sfloat); +static SqGetFloatFunc* SQGetFloat = (SqGetFloatFunc*)0x1358DD0; +//GetBool +typedef int(SqGetBoolFunc)(uint32_t v, uint32_t stackIndex, bool* sbool); +static SqGetBoolFunc* SQGetBool = (SqGetBoolFunc*)0x1358E30; +//GetString +typedef int(SqGetStringFunc)(uint32_t v, uint32_t stackIndex, wchar_t** sstring); +static SqGetStringFunc* SQGetString = (SqGetStringFunc*)0x1358E70; +//GetUserdata +typedef int(SqGetUserdataFunc)(uint32_t v, uint32_t stackIndex, DWORD* up, DWORD* up1); +static SqGetUserdataFunc* SQGetUserdata = (SqGetUserdataFunc*)0x1358EC0; +//GetObjtypetag +typedef int(SqGetObjtypetagFunc)(uint32_t v, DWORD* up); +static SqGetObjtypetagFunc* SQGetObjtypetag = (SqGetObjtypetagFunc*)0x1358F20; //获取Squirrel v 基址 inline uint32_t GetSqVm(); diff --git a/test/函数块.cpp b/test/函数块.cpp index 652a46b..114304c 100644 --- a/test/函数块.cpp +++ b/test/函数块.cpp @@ -257,6 +257,13 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v) SQPopTop(v); } +//Test +static SQInteger sq_Test(uint32_t v) +{ + + //sq_pushinteger(v, n1); + return 0; +} // װ static SQInteger GetCharacterAttribute(HSQUIRRELVM v) { @@ -401,8 +408,65 @@ static SQInteger SendPack(HSQUIRRELVM v) return 1; } +//Ʒ +static SQInteger GivePlayerItem(HSQUIRRELVM v) +{ + SQInteger n1,n2; + + + sq_getinteger(v, 2, &n1); + sq_getinteger(v, 3, &n2); + + if (n1>0 && n2>0) + { + _SendpacksType(*_SendClass, 0, 65); + _SendPacksDWord(*_SendClass, 0, 1); + _SendPacksDWord(*_SendClass, 0, n1); + _SendPacksDWord(*_SendClass, 0, n2); + _SendPacks(); + + sq_pushinteger(v, 1); + } + + if (!n1 || !n2) + { + sq_pushinteger(v, 0); + } + + return 1; +} + +//װ +static SQInteger GivePlayerEqu(HSQUIRRELVM v) +{ + SQInteger n1, n2; + + + sq_getinteger(v, 2, &n1); + sq_getinteger(v, 3, &n2); + + if (n1 > 0 && n2 > 0) + { + _SendpacksType(*_SendClass, 0, 65); + _SendPacksDWord(*_SendClass, 0, 2); + _SendPacksDWord(*_SendClass, 0, n1); + _SendPacksDWord(*_SendClass, 0, n2); + _SendPacks(); + + sq_pushinteger(v, 1); + } + + if (!n1 || !n2) + { + sq_pushinteger(v, 0); + } + + return 1; +} + void RegisterNut() { + RegisterNutApi(L"L_sq_Test", sq_Test); RegisterNutApi(L"L_sq_GetCharacterAttribute", GetCharacterAttribute); RegisterNutApi(L"L_sq_SetCharacterAttribute", SetCharacterAttribute); RegisterNutApi(L"L_sq_GetTownIndex", GetTownIndex); @@ -414,6 +478,8 @@ void RegisterNut() RegisterNutApi(L"L_sq_SendPackWord", SendPackWord); RegisterNutApi(L"L_sq_SendPackDWord", SendPackDWord); RegisterNutApi(L"L_sq_SendPack", SendPack); + RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem); + RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu); }