DNF_DLL/test/pch.h

280 lines
8.9 KiB
C++

// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// 添加要在此处预编译的标头
#include "framework.h"
#include "RSAC.h"
//-------------------------------------------------------------------------------------------Squirrel
// 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;
// New槽
typedef int(SqNewSlot)(uint32_t v, int a, bool b);
static SqNewSlot* SQNewSlot = (SqNewSlot*)0x135AA80;
// 平栈
typedef int(SqPopTop)(uint32_t v);
static SqPopTop* SQPopTop = (SqPopTop*)0x1358FF0;
// 平栈
typedef int(SqPop)(uint32_t v, int n);
static SqPop* SQPop = (SqPop*)0x1358FD0;
//SQ_Get
typedef int(Sq_Get)(uint32_t v, int n);
static Sq_Get* SQ_Get = (Sq_Get*)0x135AE30;
//SQ_Rawget
typedef int(Sq_Rawget)(uint32_t v, int n);
static Sq_Rawget* SQ_Rawget = (Sq_Rawget*)0x135AEA0;
//SQ*Getlocal
typedef wchar_t* (SqGetlocal)(uint32_t v, int n, int idx);
static SqGetlocal* SQGetlocal = (SqGetlocal*)0x135AFD0;
//SQ_Wakeupvm
typedef int (Sq_Wakeupvm)(uint32_t v, int n, int retval, int raiseerror);
static Sq_Wakeupvm* SQ_Wakeupvm = (Sq_Wakeupvm*)0x135B0D0;
//SQ_Call
typedef int (Sq_CallFunc)(uint32_t v, int params, int retval, int raiseerror);
static Sq_CallFunc* SQ_Call = (Sq_CallFunc*)0x1359280;
//SQ_Remove
typedef int (SQ_RemoveFunc)(uint32_t v, int idx);
static SQ_RemoveFunc* SQ_Remove = (SQ_RemoveFunc*)0x1359000;
//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;
//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;
//Push
typedef int(SqPushFunc)(uint32_t v, int idx);
static SqPushFunc* SQPush = (SqPushFunc*)0x1358C90;
//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;
//SQLOADFILE
typedef void* (SQLOADFILEFunc)(uint32_t v, const wchar_t* filename, bool printerror);
static SQLOADFILEFunc* SQLOADFILEF = (SQLOADFILEFunc*)0x13560E0;
//SQDOFILE
typedef void* (SQDOFILEFunc)(uint32_t v, const wchar_t* filename, bool retval, bool printerror);
static SQDOFILEFunc* SQDOFILE = (SQDOFILEFunc*)0x1356240;
typedef void*(*SQFILE)();
//SQ_io_file_lexfeed_编码
//typedef int(LSQLEXREADFUNC)(int n);
typedef int(*LSQLEXREADFUNC)(int n);
static LSQLEXREADFUNC SQ_io_file_lexfeed_ASCII = (LSQLEXREADFUNC)0x1355F60;
static LSQLEXREADFUNC SQ_io_file_lexfeed_UCS2_BE = (LSQLEXREADFUNC)0x1356050;
static LSQLEXREADFUNC SQ_io_file_lexfeed_UCS2_LE = (LSQLEXREADFUNC)0x1356020;
static LSQLEXREADFUNC SQ_io_file_lexfeed_UTF8 = (LSQLEXREADFUNC)0x1355F90;
//SQfopen
typedef SQFILE* (SQfopenFunc)(const wchar_t* filename, const wchar_t* type);
static SQfopenFunc* SQfopen = (SQfopenFunc*)0x1355DC0;
//SQfread
typedef int(SQfreadFunc)(void* buffer, int a, int b, void* file);
static SQfreadFunc* SQfread = (SQfreadFunc*)0x1355DD0;
//SQwrite
typedef int(SQwriteFunc)(void* buffer, int a, int b, void* file);
static SQwriteFunc* SQwrite = (SQwriteFunc*)0x1355DE0;
//SQfseek
typedef int(SQfseekFunc)(void* buffer, int a, int b);
static SQfseekFunc* SQfseek = (SQfseekFunc*)0x1355DF0;
//SQftell
typedef int(SQftellFunc)(void* file);
static SQftellFunc* SQftell = (SQftellFunc*)0x1355E50;
//SQ_File_read
typedef int(SQ_File_readFunc)(void* file, void* afile, int a);
static SQ_File_readFunc* SQ_File_read = (SQ_File_readFunc*)0x1356090;
//SQ_Readclosure
typedef int(SQ_ReadclosureFunc)(uint32_t v, SQ_File_readFunc a, void* file);
static SQ_ReadclosureFunc* SQ_Readclosure = (SQ_ReadclosureFunc*)0x1359460;
//SQ_Fclose
typedef int(SQ__FcloseFunc)(void* file);
static SQ__FcloseFunc* SQ__Fclose = (SQ__FcloseFunc*)0x1355E70;
//SQ_Compile
typedef int(SQ_CompileFunc)(uint32_t v, LSQLEXREADFUNC FUNC, void* file, const wchar_t* filename, bool printerror);
static SQ_CompileFunc* SQ_Compile = (SQ_CompileFunc*)0x135A390;
//SQ_Throwerror
typedef int(SQ_ThrowerrorFunc)(uint32_t v, const wchar_t* error);
static SQ_ThrowerrorFunc* SQ_Throwerror = (SQ_ThrowerrorFunc*)0x13591A0;
//获取Squirrel v 基址
inline uint32_t GetSqVm();
//新增nut接口funcName绑定C语言函数funcAddr
void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v = NULL);
//注册Nut函数
void RegisterNut();
//新增Nut接口绑定C函数
// 示例如下
/*
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 表示该函数有返回值传给nut脚本 0则无
return 1;
}
*/
//新增C++调用 nut
// 示例如下
/*
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"dofile", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, L"1.cpp", -1);
SQ_Call(v, 2, 1, 0);
SQPop(v, 2);
*/
//-------------------------------------------------------------------------------------------Squirrel
//获取EXE使用头 号位数据
int GetExeNutWrtNum(int Pos);
//写EXE使用头 号位数据
void SetExeNutWrtNum(int Pos, int num);
//获取Nut头 号位数据
int GetNutArrNum(int Nut头地址, int Pos);
//写Nut头 号位数据
void SetNutArrNum(int Nut头地址, int Pos, int num);
//读内存偏移地址
int GetHook(int Addr, std::string );
//发包函数 地址
typedef DWORD SendPacks();
static SendPacks* _SendPacks = (SendPacks*)0x1127EC0;
//发包Class this地址
typedef DWORD SendClass;
static SendClass* _SendClass = (SendClass*)0x1AEB6E4;
//发包类型 地址
typedef int(__fastcall* SendPacksType)(DWORD thisc, int Seat, int Parm);
static SendPacksType _SendpacksType = (SendPacksType)0x1127D60;
//发包参数 BYTE
typedef int(__fastcall* SendPacksByte)(DWORD thisc, int Seat, int Parm);
static SendPacksByte _SendPacksByte = (SendPacksByte)0x1128550;
//发包参数 WORD
typedef int(__fastcall* SendPacksWORD)(DWORD thisc, int Seat, int Parm);
static SendPacksWORD _SendPacksWord = (SendPacksWORD)0x1128580;
//发包参数 DWORD
typedef int(__fastcall* SendPacksDWORD)(DWORD thisc, int Seat, int Parm);
static SendPacksDWORD _SendPacksDWord = (SendPacksDWORD)0x11285B0;
//公告Class this地址
typedef DWORD NoticeClass;
static NoticeClass* _NoticeClass = (NoticeClass*)0x1A5FB20;
//公告CALL
typedef void(__fastcall* NoticeCall)(DWORD thisc, int Seat , char* a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7);
static NoticeCall _Noticecall = (NoticeCall)0x9536C0;
//公告CALL
typedef void(__fastcall* NoticeTCall)(DWORD thisc, DWORD Seat, DWORD a1, char* a2, DWORD a3);
static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070;
#endif //PCH_H