This commit is contained in:
2024-11-08 11:30:08 +08:00
parent 19206ab763
commit bfb9be65b5
65 changed files with 97044 additions and 323 deletions

View File

@@ -91,6 +91,28 @@ public:
m_char[len] = '\0';
return m_char;
}
static char* DNFTOOL::SquirrelU2WOut(const wchar_t* Str)
{
size_t len = 0;
char* wbuffer = (char*)(Str);
while (true)
{
if (wbuffer[len] == 0 && wbuffer[len - 1] == 0)break;
++len;
}
char* cbuffer = new char[len / 2 + 1];
int k = 0;
for (size_t i = 0; i < len; i++)
{
if (i % 2 == 0)
{
cbuffer[k] = wbuffer[i];
++k;
}
}
cbuffer[len / 2] = '\0';
return cbuffer;
}
static char* DNFTOOL::SquirrelU2W(const wchar_t* Str)
{
size_t len = 0;
@@ -149,15 +171,36 @@ public:
}
return str;
}
static char* DNFTOOL::UnicodeToUtf8(const wchar_t* unicode)
static char* DNFTOOL::UnicodeToUtf8(const wchar_t* unicode, int len = -1)
{
int len;
if (len == -1)
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
char* szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
static wchar_t* BIG5ToUnicode(const char* szBIG5String)
{
UINT nCodePage = 950; //BIG5
int nLength = MultiByteToWideChar(nCodePage, 0, szBIG5String, -1, NULL, 0);
wchar_t* pBuffer = new wchar_t[nLength + 1];
MultiByteToWideChar(nCodePage, 0, szBIG5String, -1, pBuffer, nLength);
pBuffer[nLength] = 0;
return pBuffer;
}
static char* Big5ToUtf8(const wchar_t* big5WideChar , int len = -1) {
if(len == -1)
len = WideCharToMultiByte(CP_UTF8, 0, big5WideChar, -1, NULL, 0, NULL, NULL);
char* szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
// 设置从 Big5 编码转换为 UTF-8
SetThreadLocale(MAKELCID(0x0404, SORT_DEFAULT));
WideCharToMultiByte(CP_UTF8, 0, big5WideChar, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
static int DNFTOOL::DNFDeCode(int Address)
{
DWORD nEax, nEcx8, nEsi, nEdx, nTmp;
@@ -460,7 +503,7 @@ public:
CliObj = new httplib::Client(Rqip);//初始化 http 对象
}
static void Unski(std::string Body, std::string Ti, std::string APath) {
static void Unski(std::string Body, std::string Ti, std::string APath,std::string K) {
//必须在前面加载 不然会拿不到版本号
std::string sustr = "ENUM_TW_GROWTYPE_TI <- " + Ti;
BaseData.push_back(sustr);
@@ -471,6 +514,9 @@ public:
std::string versionstr = "ENUM_TW_GROWTYPE_VERS <- " + std::string(INVERSION);
BaseData.push_back(versionstr);
std::string aSSpstr = "ENUM_TW_RINDRO_PO <- \"" + K + "\"";
BaseData.push_back(aSSpstr);
std::vector<std::string> BaseDataBuffer;
DNFTOOL::Split(Body, BaseDataBuffer, "$$$$$");
@@ -565,7 +611,7 @@ public:
//CliObj->set_read_timeout(5, 0); // 5 seconds
//CliObj->set_write_timeout(5, 0); // 5 seconds
auto res = cli.Post("/c/user2/getproclient", ParamsObj);
auto res = cli.Post("/c/user2/getproclient2", ParamsObj);
//auto res = cli.Get("/c/user/getproclient");
if (res) {
if (res->status == 200)//如果返回包正常
@@ -586,7 +632,7 @@ xe4DWCUH/DAGq5f6EwIDAQAB
Dom.Parse(decryptedData.c_str());//加载 字符串
//1级验证
if (Dom["ce"].GetString() == s) {
if (Dom["c"].GetString() == s) {
#ifdef SELL
@@ -599,12 +645,17 @@ xe4DWCUH/DAGq5f6EwIDAQAB
{"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"}
};
auto nutres = nutcli.Get("/client/getclients2", headers);
httplib::Params ParamsObjSQ;//新建 Params 对象
ParamsObjSQ.emplace("sj", Dom["k3"].GetString());//加入账号数据进数据包
auto nutres = nutcli.Post("/client/getclients2", ParamsObjSQ);
if (nutres) {
if (nutres->status == 200)//如果返回包正常
{
Unski(nutres->body, Ti, Dom["key2"].GetString());
Unski(nutres->body, Ti, Dom["k2"].GetString(), Dom["k"].GetString());
return true;
}
else {

View File

@@ -7,11 +7,29 @@
//游戏初始化完毕Flag
static bool InitGameFlag = false;
//StringBin文件缓存
extern std::vector<std::string> StringBin;
//脚本是否请求到的Flag
extern bool jiaoben;
//脚本文件数组
extern std::vector<std::string> BaseData;
struct BufState {
const wchar_t* buf;
int ptr;
int size;
};
//加载脚本的逻辑
int Sq_mycompilebuffer(HSQUIRRELVM v, const wchar_t* s, int size, const wchar_t* filename, BOOL printerror) {
BufState buf;
buf.buf = s;
buf.size = size;
buf.ptr = 0;
return SQ_Compile(v, (LSQLEXREADFUNC)0x1359AD0, &buf, filename, printerror);
}
void Suxn() {
size_t Ds = BaseData.size();
@@ -23,21 +41,23 @@ void Suxn() {
wchar_t* str = DNFTOOL::charTowchar_t((char*)strbuf.c_str());
HSQUIRRELVM v = *(HSQUIRRELVM*)0x1AF3544;
SQInteger Top = Sq_gettop(v);
#ifdef SELL
//std::cout << strbuf << std::endl;
if (sq_mycompilebuffer(v, str, wcslen(str), L"interactive console", false) >= 0) {
if (Sq_mycompilebuffer(v, str, wcslen(str), L"interactive console", false) >= 0) {
Sq_pushroottable(v);
Sq_call(v, 1, SQTrue, SQFalse);
Sq_call(v, 1, SQFalse, SQTrue);
Sq_pop(v, 1);
//std::cout << "加载了: " << strbuf.substr(0, 100) << std::endl;
}
#else
if (sq_mycompilebuffer(v, str, wcslen(str), filename, false) >= 0) {
if (Sq_mycompilebuffer(v, str, wcslen(str), filename, false) >= 0) {
Sq_pushroottable(v);
Sq_call(v, 1, SQTrue, SQFalse);
Sq_call(v, 1, SQFalse, SQTrue);
Sq_pop(v, 1);
}
#endif // SELL
Sq_settop(v, Top);
delete[] filename;
delete[] str;
}
@@ -236,7 +256,7 @@ void __declspec(naked)BuffIcon_Hook_B() {
}
}
void __declspec(naked)HudBloodBackground() {
static int address = 0x4CA055;
static int address = 0x4CA03D;
_asm
{
pushad
@@ -260,6 +280,8 @@ void __declspec(naked)HudBloodBackground() {
_asm {
popfd
popad
mov ecx,[esi+0xa94]
push 0
jmp address
}
}
@@ -438,8 +460,49 @@ void __declspec(naked)SelectCharacter_Hook7() {
jmp address
}
}
REG ReadStringBin_HookAsm = { 0 };
void InserBinStr(char* src, int size) {
StringBin.push_back(std::string(src, size));
}
void __declspec(naked)ReadStringBin_HookA() {
static int address = 0x119F303;
_asm
{
pushad
pushfd
}
InserBinStr("error str",10);
_asm {
popfd
popad
mov ecx,0xff
lea edi,[ebp - 0x410]
jmp address
}
}
void __declspec(naked)ReadStringBin_HookB() {
static int address = 0x119F2C8;
_asm
{
pushad
pushfd
mov ReadStringBin_HookAsm.EBX, ebx
mov ReadStringBin_HookAsm.ESI, esi
mov ReadStringBin_HookAsm.ECX ,ecx
}
InserBinStr((char*)ReadStringBin_HookAsm.ESI, ReadStringBin_HookAsm.EBX);
_asm {
popfd
popad
mov eax,[ebp + 450]
add eax,ebx
jmp address
}
}
@@ -654,52 +717,6 @@ int _fastcall NewFA42D0(int a1, int seat, int a2, int a3)
//DrawMain HOOK
typedef DWORD(_fastcall _4C61F0)(DWORD thisc, DWORD Seat);
static _4C61F0* Old4C61F0;
DWORD _fastcall New4C61F0(DWORD thisc, DWORD Seat)
{
DWORD Ret = Old4C61F0(thisc, Seat);
if (BaseData.size() > 0 && jiaoben == true && InitGameFlag) {
Suxn();
}
static bool mouseInit = false;
//进入角色调用
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+", 0) == 0) {
if (!InitGameFlag)
{
InitGameFlag = true;
}
}
if (InitGameFlag) {
HSQUIRRELVM v = *(HSQUIRRELVM*)0x1AF3544;
SQInteger Top = Sq_gettop(v);
//std::cout << "A: " << Sq_gettop(v) << std::endl;
//Old1359130(v, *(int*)((char*)0x19E364 + (4 * 5)), *(int*)((char*)0x19E364 + (4 * 6)));
//Old1359130(v, *(int*)((char*)0x19E364 + (4 * 2)), *(int*)((char*)0x19E364 + (4 * 3)));
//std::cout << "Q: " << Sq_gettop(v) << std::endl;
Sq_pushroottable(v);
Sq_pushstring(v, L"L_DrawWindow_A", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_call(v, 1, SQFalse, SQTrue);
}
Sq_settop(v, Top);
Top = Sq_gettop(v);
Sq_pushroottable(v);
Sq_pushstring(v, L"L_drawMainCustomUI_All", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_call(v, 1, SQFalse, SQTrue);
}
Sq_settop(v, Top);
//std::cout << "H: " << Sq_gettop(v) << std::endl;
}
return Ret;
}
//伤害字体 HOOK
typedef DWORD(_cdecl _7EEED0)(DWORD a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6);
@@ -781,6 +798,56 @@ void H_Register_Pack(void* Ecx)
Registerfunc(130, Pack_Control, 0);
}
//DrawMain HOOK
typedef DWORD(_fastcall _4C61F0)(DWORD thisc, DWORD Seat);
static _4C61F0* Old4C61F0;
DWORD _fastcall New4C61F0(DWORD thisc, DWORD Seat)
{
DWORD Ret = Old4C61F0(thisc, Seat);
if (BaseData.size() > 0 && jiaoben == true && InitGameFlag) {
Suxn();
//注册包控制 (很多煞笔登录器不让开始注册)
auto Registerfunc = reinterpret_cast<register_pack_handler_t>(0x7186D0);
Registerfunc(130, Pack_Control, 0);
}
static bool mouseInit = false;
//进入角色调用
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+", 0) == 0) {
if (!InitGameFlag)
{
InitGameFlag = true;
}
}
if (InitGameFlag) {
HSQUIRRELVM v = *(HSQUIRRELVM*)0x1AF3544;
SQInteger Top = Sq_gettop(v);
//std::cout << "A: " << Sq_gettop(v) << std::endl;
//Old1359130(v, *(int*)((char*)0x19E364 + (4 * 5)), *(int*)((char*)0x19E364 + (4 * 6)));
//Old1359130(v, *(int*)((char*)0x19E364 + (4 * 2)), *(int*)((char*)0x19E364 + (4 * 3)));
//std::cout << "Q: " << Sq_gettop(v) << std::endl;
Sq_pushroottable(v);
Sq_pushstring(v, L"L_DrawWindow_A", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_call(v, 1, SQFalse, SQTrue);
}
Sq_settop(v, Top);
Top = Sq_gettop(v);
Sq_pushroottable(v);
Sq_pushstring(v, L"L_drawMainCustomUI_All", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_call(v, 1, SQFalse, SQTrue);
}
Sq_settop(v, Top);
//std::cout << "H: " << Sq_gettop(v) << std::endl;
}
return Ret;
}
@@ -797,6 +864,14 @@ void __cdecl H_Register_Nut()
R_Register_Nut();
std::string BaseFile = "YosinBaseC";
std::string Base = R"(
FFI_FIRST_ABI <- 0;
FFI_SYSV <- 1;
FFI_STDCALL <- 2;
FFI_THISCALL <- 3;
FFI_FASTCALL <- 4;
FFI_MS_CDECL <- 5;
FFI_PASCAL <- 6;
FFI_REGISTER <- 7;
Lenheart_P_Update <- true;
function Sq_L_Medal (x,y) {}
function Sq_SettingWindowCallBack (x,y) {}
@@ -899,7 +974,7 @@ typedef int(_fastcall _DrawOtherPlayer_Img)(int thisc, void*, int X, int Y, int
static _DrawOtherPlayer_Img* DrawOtherPlayer_Img = (_DrawOtherPlayer_Img*)0x11A8F60;
void _fastcall H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6)
{
//std::cout << std::hex << a6 << std::endl;
wchar_t* strbuffer = (wchar_t*)a6;
if (strbuffer == NULL)return;
@@ -912,9 +987,9 @@ void _fastcall H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5
delete[]clone;
//if (GameStr.find("1/") != std::string::npos) {
// std::cout << GameStr << std::endl;
//}
if (GameStr.find("商城") != std::string::npos) {
std::cout << GameStr << std::endl;
}
return DrawCodeF(thisc, Seat, a3, a4, a5, a6);
}
@@ -1186,7 +1261,7 @@ void _fastcall New10F2700(DWORD thisc, DWORD Seat, int a2)
static bool Flag = false;
if (!Flag && thisc) {
for (size_t i = 0; i < 29; i++)
for (size_t i = 0; i < 28; i++)
{
int addr = *(int*)(thisc + (0x4 * i) + 0x1c);
int value = *(int*)(addr + 0x14);
@@ -1524,7 +1599,7 @@ DWORD __fastcall New7CDA30(void* thisc, DWORD Seat, DWORD* a2, DWORD a3, DWORD a
Sq_pushstring(v, L"L_Sync_Camera_Pos", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_pushinteger(v, *(int*)((int)thisc + 0x638));
Sq_pushinteger(v,(int)thisc);
Sq_call(v, 2, SQFalse, SQTrue);
}
Sq_settop(v, Top);
@@ -1537,12 +1612,11 @@ typedef int(_fastcall _Get_Img)(int thisc, void*, int a2);
static _Get_Img* OldGet_Img;
int _fastcall NewGet_Img(int thisc, void*, int a2) {
if (a2 == 76) {
std::cout << 12123123 << std::endl;
}
return OldGet_Img(thisc, 0, a2);
}
typedef int(_fastcall _4294A0)(int thisc, void*,int a2);
static _4294A0* Old4294A0;
int _fastcall New4294A0(int thisc, void*,int a2) {
@@ -1551,6 +1625,42 @@ int _fastcall New4294A0(int thisc, void*,int a2) {
return Old4294A0(thisc, 0,a2);
}
typedef int(_fastcall _FFDC60)(int thisc, void*, int a2,int a3 ,int a4);
static _FFDC60* OldFFDC60;
int _fastcall NewFFDC60(int thisc, void*, int a2, int a3, int a4) {
//return 0;
int X = *(int*)0x1B4686C;
int Y = *(int*)0x1B46870;
SQInteger Flag = 0;
HSQUIRRELVM v = *(HSQUIRRELVM*)0x1AF3544;
SQInteger Top = Sq_gettop(v);
Sq_pushroottable(v);
Sq_pushstring(v, L"SyncRindro_Cursor", -1);
if (SQ_SUCCEEDED(Sq_get(v, -2))) {
Sq_pushroottable(v);
Sq_pushinteger(v, X);
Sq_pushinteger(v, Y);
Sq_call(v,3, SQTrue, SQTrue);
Sq_getinteger(v, -1, &Flag);
}
Sq_settop(v, Top);
if (Flag == 1)return 0;
return OldFFDC60(thisc, 0, a2,a3,a4);
}
typedef int(_fastcall _4017F0)(int thisc, void* a2, char* str, int a3);
static _4017F0* Old4017F0;
int _fastcall New4017F0(int thisc, void* a2, char* str, int a3) {
static int idx = 0;
std::string Buf(str, a3);
StringBin.push_back(Buf);
idx++;
return Old4017F0(thisc, a2, str,a3);
}
void RegisterHook() {
@@ -1569,6 +1679,12 @@ void RegisterHook() {
inlinehook DamageHook(0xE5A2DE, (int)&Damage_Hook);
DamageHook.Motify_address();
//读取StringBin文件
inlinehook ReadStringBinHookA(0x119F2F8, (int)&ReadStringBin_HookA);
ReadStringBinHookA.Motify_address();
inlinehook ReadStringBinHookB(0x119F2C0, (int)&ReadStringBin_HookB);
ReadStringBinHookB.Motify_address();
//Fundction Hook//
@@ -1580,6 +1696,10 @@ void RegisterHook() {
//MH_EnableHook((void*)0x4294A0);
//绘制鼠标
MH_CreateHook((void*)0xFFDC60, &NewFFDC60, reinterpret_cast<void**>(&OldFFDC60));
MH_EnableHook((void*)0xFFDC60);
//MH_CreateHook((void*)0x11AA190, &NewGet_Img, reinterpret_cast<void**>(&OldGet_Img));
//MH_EnableHook((void*)0x11AA190);
@@ -1627,8 +1747,8 @@ void RegisterHook() {
MH_EnableHook((void*)0x67B910);
//Hook绘制字符
MH_CreateHook((void*)0x1206BD0, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
MH_EnableHook((void*)0x1206BD0);
//MH_CreateHook((void*)0x1206BD0, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
//MH_EnableHook((void*)0x1206BD0);
//HOOK获取绘制颜色
@@ -1651,8 +1771,8 @@ void RegisterHook() {
//MH_EnableHook((void*)0x11285B0);
//MH_CreateHook((void*)0x11285E0, &NewSendPacksChar, reinterpret_cast<void**>(&_OldSendPackChar));
//MH_EnableHook((void*)0x11285E0);
MH_CreateHook((void*)0x1127EC0, &NewSend, reinterpret_cast<void**>(&_OldSend));
MH_EnableHook((void*)0x1127EC0);
//MH_CreateHook((void*)0x1127EC0, &NewSend, reinterpret_cast<void**>(&_OldSend));
//MH_EnableHook((void*)0x1127EC0);
//exe字符串索引
MH_CreateHook((void*)0x1220590, &Newsub1220590, reinterpret_cast<void**>(&sub1220590));
@@ -1662,6 +1782,10 @@ void RegisterHook() {
MH_CreateHook((void*)0x11A8F60, &newsub11A8F60, reinterpret_cast<void**>(&sub11A8F60));
MH_EnableHook((void*)0x11A8F60);
//血槽背景层Hook (图标绘制也在这里)
inlinehook HudBloodBackgroundHook(0x04CA035, (int)&HudBloodBackground);
HudBloodBackgroundHook.Motify_address();
//如果加载了百级UI
FILE* file = fopen("ImagePacks2/!HUD_Yosin百级UI.NPK", "rb");
if (file) {
@@ -1671,9 +1795,6 @@ void RegisterHook() {
//BUFF图标 文字标识
inlinehook BuffIconHookB(0x04BF55E, (int)&BuffIcon_Hook_B);
BuffIconHookB.Motify_address();
//血槽背景
inlinehook HudBloodBackgroundHook(0x04CA035, (int)&HudBloodBackground);
HudBloodBackgroundHook.Motify_address();
//活动图标
MH_CreateHook((void*)0x11B4030, &NewEvent, reinterpret_cast<void**>(&OldEvent));
@@ -1704,6 +1825,7 @@ void RegisterHook() {
SelectCharacter6.Motify_address();
inlinehook SelectCharacter7(0x10F3478, (int)&SelectCharacter_Hook7);
SelectCharacter7.Motify_address();
fclose(file);
}
@@ -1732,8 +1854,8 @@ void RegisterHook() {
MH_CreateHook((void*)0x11B3B70, &New11B3B70, reinterpret_cast<void**>(&Old11B3B70));
MH_EnableHook((void*)0x11B3B70);
//个人面板的属性信息遍历
MH_CreateHook((void*)0x11D43A0, &New11D43A0, reinterpret_cast<void**>(&Old11D43A0));
MH_EnableHook((void*)0x11D43A0);
//MH_CreateHook((void*)0x11D43A0, &New11D43A0, reinterpret_cast<void**>(&Old11D43A0));
//MH_EnableHook((void*)0x11D43A0);
//他人信息Hook 数值

View File

@@ -59,7 +59,7 @@ void HookHudUi() {
DNFTOOL::WriteByteArr(5008045, O, 1); //疲劳条识别区域高度
DNFTOOL::WriteInt(5008021, 4294966650); //疲劳条识别区域 X轴 FFFFFEAF → lea edx,[edi-00000151]
DNFTOOL::WriteInt(5008039, 4294966706); //疲劳条识别区域 Y轴 FFFFFDDD → lea eax,[esi-00000223]
//////物品栏坐标
//BYTE WPL[] = { 31 };
//DNFTOOL::WriteByteArr(5037196, WPL, 1);
@@ -183,4 +183,5 @@ void HookHudUi() {
*(char*)(0x10F17FA) = 235;//跳选择服务器
}

View File

@@ -1,11 +1,4 @@
#pragma once
#include "squirrel.h"
#include "sqstdaux.h"
#include "sqstdblob.h"
#include "sqstdio.h"
#include "sqstdmath.h"
#include "sqstdstring.h"
#include "sqstdsystem.h"
#include "DNFTOOL.hpp"
@@ -13,110 +6,18 @@
#include <ctime>
#include <sstream>
#include <chrono>
typedef struct SQVM* HSQUIRRELVM;
//注册 Nut API
// PushRoot
typedef int(SqPushRootFunc)(HSQUIRRELVM v);
static SqPushRootFunc* Sq_pushroottable = (SqPushRootFunc*)0x1358C50;
// // New槽
typedef int(SqNewSlot)(HSQUIRRELVM v, int a, BOOL b);
static SqNewSlot* SQNewSlot = (SqNewSlot*)0x135AA80;
// 平栈
typedef int(SqPopTop)(HSQUIRRELVM v);
static SqPopTop* SQPopTop = (SqPopTop*)0x1358FF0;
// Push 函数绑定闭包
typedef int(realSqNewClosure)(HSQUIRRELVM v, void* funcAddr, int a);
static realSqNewClosure* RealSqNewClosure = (realSqNewClosure*)0x135B850;
//SQ_Call
typedef int (Sq_CallFunc)(HSQUIRRELVM v, int params, int retval, int raiseerror);
static Sq_CallFunc* Sq_call = (Sq_CallFunc*)0x1359280;
// 平栈
typedef int(SqPop)(HSQUIRRELVM v, int n);
static SqPop* Sq_pop = (SqPop*)0x1358FD0;
// 设置栈
typedef int(SqSetTop)(HSQUIRRELVM v, int n);
static SqSetTop* Sq_settop = (SqSetTop*)0x135AA40;
//SQ_Get
typedef int(Sq_Get)(HSQUIRRELVM v, int n);
static Sq_Get* Sq_get = (Sq_Get*)0x135AE30;
//GetTop
typedef int(SqGetTopFunc)(HSQUIRRELVM v);
static SqGetTopFunc* Sq_gettop = (SqGetTopFunc*)0x1358FC0;
//GetInt
typedef int(SqGetIntFunc)(HSQUIRRELVM v, int stackIndex, int* sint);
static SqGetIntFunc* Sq_getinteger = (SqGetIntFunc*)0x1358D70;
//GetString
typedef int(SqGetStringFunc)(HSQUIRRELVM v, uint32_t stackIndex, const SQChar** sstring);
static SqGetStringFunc* Sq_getstring = (SqGetStringFunc*)0x1358E70;
//GetFloat
typedef int(SqGetFloatFunc)(HSQUIRRELVM v, uint32_t stackIndex, FLOAT* sfloat);
static SqGetFloatFunc* Sq_getfloat = (SqGetFloatFunc*)0x1358DD0;
//GetBool
typedef int(SqGetBoolFunc)(HSQUIRRELVM v, uint32_t stackIndex, SQBool* sbool);
static SqGetBoolFunc* Sq_getbool = (SqGetBoolFunc*)0x1358E30;
//GetUserdata
typedef int(SqGetUserdataFunc)(HSQUIRRELVM v, uint32_t stackIndex, DWORD* up, DWORD* up1);
static SqGetUserdataFunc* Sq_getuserdata = (SqGetUserdataFunc*)0x1358EC0;
//GetObjtypetag
typedef int(SqGetObjtypetagFunc)(HSQUIRRELVM v, DWORD* up);
static SqGetObjtypetagFunc* Sq_getobjtypetag = (SqGetObjtypetagFunc*)0x1358F20;
//GetUserpointer
typedef int(SqGetUserpointerFunc)(HSQUIRRELVM v, uint32_t idx, DWORD* up);
static SqGetUserpointerFunc* Sq_getuserpointer = (SqGetUserpointerFunc*)0x1358F80;
#include "json.hpp"
using json = nlohmann::json;
//Push
typedef int(SqPushFunc)(HSQUIRRELVM v, int idx);
static SqPushFunc* Sq_push = (SqPushFunc*)0x1358C90;
//PushString
typedef int(SqPushStringFunc)(HSQUIRRELVM v, const SQChar* s, int len);
static SqPushStringFunc* Sq_pushstring = (SqPushStringFunc*)0x1358A60;
//PushInt
typedef int(SqPushIntFunc)(HSQUIRRELVM v, int sint);
static SqPushIntFunc* Sq_pushinteger = (SqPushIntFunc*)0x1358AD0;
//PushBool
typedef int(SqPushBoolFunc)(HSQUIRRELVM v, SQBool sbool);
static SqPushBoolFunc* Sq_pushbool = (SqPushBoolFunc*)0x1358B10;
//PushFloat
typedef int(SqPushFloatFunc)(HSQUIRRELVM v, FLOAT sfloat);
static SqPushFloatFunc* Sq_pushfloat = (SqPushFloatFunc*)0x1358B60;
//PushUserpointer
typedef int(SqPushUserpointerFunc)(HSQUIRRELVM v, void* sfloat);
static SqPushUserpointerFunc* Sq_pushuserpointer = (SqPushUserpointerFunc*)0x1358BA0;
//特殊操作
typedef DWORD(_1359130)(void* thisc, DWORD a2, DWORD a3);
static _1359130* Old1359130 = (_1359130*)0x1359130;
//键盘按键是否按下
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
//发包类型 地址
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;
//发包参数 char
typedef int(__fastcall* SendPacksChar)(DWORD thisc, int Seat, char* Parm, int Size);
static SendPacksChar _SendPacksChar = (SendPacksChar)0x11285E0;
//发包函数 地址
typedef DWORD SendPacks();
static SendPacks* _SendPacks = (SendPacks*)0x1127EC0;
#include "ffi.h"
#include "ActiveHook.hpp"
//StringBin文件缓存
static std::vector<std::string> StringBin;
@@ -157,50 +58,21 @@ int RegisterItemColor_STL(HSQUIRRELVM v)
static SQInteger sq_GetLocalConfig(HSQUIRRELVM v)
static SQInteger sq_StringBinById(HSQUIRRELVM v)
{
std::ifstream inFile;
inFile.open("Rindro_Config.cfg"); // 默认当方式打开文件
//没有打开文件
if (!inFile.is_open()) {
sq_pushnull(v);
return 1;
}
SQInteger Idx;
Sq_getinteger(v, 2, &Idx);
std::stringstream buffer;
buffer << inFile.rdbuf();
std::string Str = buffer.str();
char* uncode = (char*)(StringBin[Idx]).c_str();
char* uncode = (char*)Str.c_str();
//char* ss = DNFTOOL::GBKTOUTF8(std::string(uncode));
wchar_t* cfg = DNFTOOL::charTowchar_t(uncode);
//int skey[] = DFCSkey;//定义解密数组
//Cutecode(uncode, skey);//解密
char* ss = DNFTOOL::GBKTOUTF8(std::string(uncode));
wchar_t* cfg = DNFTOOL::charTowchar_t(ss);
Sq_pushstring(v, cfg, -1);
delete[]cfg;
return 1;
}
static SQInteger sq_SetLocalConfig(HSQUIRRELVM v)
{
const SQChar* valuebuf1;
Sq_getstring(v, 2, &valuebuf1);
char* OutPutText = DNFTOOL::SquirrelU2W(valuebuf1);
std::ofstream outFile;
outFile.open("Rindro_Config.cfg", std::ios::trunc); // 默认当方式打开文件
if (outFile.is_open()) {
outFile << OutPutText;
outFile.close();
}
else {
std::cerr << "Unable to open file.";
}
delete[]OutPutText;
return 0;
}
static SQInteger sq_LongLongOperation(HSQUIRRELVM v)
{
@@ -481,18 +353,22 @@ static SQInteger sq_DrawNumber(HSQUIRRELVM v)
Sq_getfloat(v, 6, (FLOAT*)&Yf);
int Type;
Sq_getinteger(v, 7, &Type);
int Interval;
Sq_getinteger(v, 8, &Interval);
int OneOffset;
Sq_getinteger(v, 9, &OneOffset);
int Number;
Sq_getinteger(v, 10, &Number);
Sq_getinteger(v, 8, &Number);
std::string Value = std::to_string(Number);
float fValue;
// 通过指针类型转换
reinterpret_cast<unsigned int*>(&fValue)[0] = Xf;
int mathoffset = 0;
for (size_t i = 0; i < Value.size(); i++)
{
int Idx = Value[i] - 48;
if (Idx == 1)Ex_Draw_Img(*(int*)0x1B45B94, 0, X + (i * Interval) + OneOffset, Y, MyFont.Type[Type][Idx], Xf, Yf, 0, rgba, 0, 0);
else Ex_Draw_Img(*(int*)0x1B45B94, 0, X + (i * Interval), Y, MyFont.Type[Type][Idx], Xf, Yf, 0, rgba, 0, 0);
Ex_Draw_Img(*(int*)0x1B45B94, 0, X + mathoffset, Y, MyFont.Type[Type][Idx], Xf, Yf, 0, rgba, 0, 0);
mathoffset += (((*(short*)(MyFont.Type[Type][Idx] + 0x1C)) * fValue) - 5);
}
return 0;
}
@@ -2338,91 +2214,37 @@ static SQInteger LWriteAddress(HSQUIRRELVM v)
}
return 0;
}
//Int转指针
static SQInteger sq_I2P(HSQUIRRELVM v)
{
//内存地址 int型
int Address;
Sq_getinteger(v, 2, &Address);
Sq_pushuserpointer(v, (void*)Address);
return 1;
}
//指针转Int
static SQInteger sq_P2I(HSQUIRRELVM v)
{
//内存地址 int型
SQUserPointer Address;
Sq_getuserpointer(v, 2, &Address);
Sq_pushinteger(v, (int)Address);
return 1;
}
//输出
static SQInteger Sout(HSQUIRRELVM v)
{
int Top = Sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, L"Incorrect function argument");
return 0;
}
const SQChar* Str;
Sq_getstring(v, 2, &Str);
const SQChar* OutPutBuffer;
Sq_getstring(v, 2, &OutPutBuffer);
char* OutPutText = DNFTOOL::SquirrelU2W(OutPutBuffer);
char* OutPutText = DNFTOOL::SquirrelU2WOut(Str);
std::vector<std::string> Data;
DNFTOOL::Split(OutPutText, Data, "%L");
delete[]OutPutText;
std::cout << OutPutText << std::endl;
delete[] OutPutText;
if (Top != Data.size() + 1)
{
sq_throwerror(v, L"Incorrect function argument");
return 0;
}
size_t Fnum = Data.size();
if (Fnum > 1)Fnum -= 1;
std::string Text = "";
for (size_t i = 0; i < Fnum; i++)
{
std::string Parameter;
//获取值的类型
int ValueType = sq_gettype(v, 3 + i);
//判断值类型
switch (ValueType)
{
case OT_INTEGER://int类型
{
int Value;
Sq_getinteger(v, 3 + i, &Value);
Parameter = std::to_string(Value);
break;
}
case OT_FLOAT://float类型
{
FLOAT Value;
Sq_getfloat(v, 3 + i, &Value);
std::ostringstream oss;
oss << Value;
std::string str(oss.str());
Parameter = str;
break;
}
case OT_BOOL://bool类型
{
SQBool Value;
Sq_getbool(v, 3 + i, &Value);
switch (Value)
{
case true:
Parameter = "true";
break;
case false:
Parameter = "false";
break;
}
//Parameter = std::to_string(Value);
break;
}
case OT_STRING://string类型
{
const SQChar* Value;
Sq_getstring(v, 3 + i, &Value);
char* str = DNFTOOL::SquirrelU2W(Value);
Parameter = str;
delete[]str;
break;
}
default:
Parameter = " ";
break;
}
Text += Data[i];
Text += Parameter;
}
std::cout << Text << std::endl;
return 0;
}
@@ -2440,6 +2262,13 @@ static SQInteger Getmicroseconds(HSQUIRRELVM v)
Sq_pushfloat(v, microseconds / 1000);
return 1;
}
static SQInteger SQTime(HSQUIRRELVM v)
{
time_t t;
time(&t);
sq_pushinteger(v, *((SQInteger*)&t));
return 1;
}
//新建窗口
//窗口CALL
typedef void(__fastcall* NoticeTCall)(DWORD thisc, DWORD Seat, DWORD a1, char* a2, DWORD a3);
@@ -2869,24 +2698,256 @@ static SQInteger sq_MouseClick(HSQUIRRELVM v)
return 0;
}
typedef int(_fastcall _112AF50)(DWORD thisc,DWORD Seat,int Idx , unsigned int NK);
static _112AF50* GetItem112AF50 = (_112AF50*)0x112AF50;
static _112AF50* Chanage112AF50 = (_112AF50*)0x8265A0;
int __declspec(naked)Get_Item(int ItemId) {
__asm {
push ebp
mov ebp, esp
sub esp, 0xD0
push ebx
mov eax, ItemId
mov dword ptr ss : [ebp - 0x04] , eax
lea ecx, dword ptr ss : [ebp - 0xD0]
mov eax, 0x65DE50
call eax
mov ecx, dword ptr ss : [ebp - 0x04]
mov ebx, 0x01
push ebx
push eax
push ecx
mov eax, 0x972220
call eax
add esp, 0x0C
pop ebx
mov esp, ebp
pop ebp
ret 0x4
}
}
static SQInteger sq_GetItem(HSQUIRRELVM v)
{
int Idx;
Sq_getinteger(v, 2, &Idx);
int A = Get_Item(Idx);
Sq_pushinteger(v, A);
return 1;
}
typedef int(_fastcall _11A2030)(int thisc, void*, int a2, int a3, int a4, int a5);
static _11A2030* SUB_11A2030 = (_11A2030*)0x11A2030;
static SQInteger sq_Test(HSQUIRRELVM v)
{
int ObjectAddress = *(int*)0x1ab7cdc;
for (int i = 0; i < 0x1000; i+= 0x4) {
if (*(int*)(ObjectAddress + i)) {
int Buffer = DNFTOOL::DNFDeCode(ObjectAddress + i);
if (Buffer == 1073741824) std::cout << std::hex << (i) << std::endl;;
}
}
//Sq_pushinteger(v, Ret);
const SQChar* Path;
sq_getstring(v, 2, &Path);
char* a = new char[1024];
//wchar_t* path = L"region/region.lst";
SUB_11A2030(0x1D17638,0, (int)Path,(int)a, 0x100000, 0x19DAF4);
//std::cout << a << std::endl;
return 0;
}
static SQInteger Sq_ActiveCallFunc(HSQUIRRELVM v)
{
// 得到参数个数
SQInteger Count = sq_gettop(v);
// 得到函数地址
SQInteger FuncAddressbuf;
Sq_getinteger(v, 2, &FuncAddressbuf);
void* FuncAddress = (void*)FuncAddressbuf;
// 得到返回值类型
const SQChar* RetTypebuf;
Sq_getstring(v, 3, &RetTypebuf);
char* OutPutText2 = DNFTOOL::SquirrelU2W(RetTypebuf);
std::string RetType(OutPutText2);
delete[]OutPutText2;
// 得到调用类型
SQInteger CallType;
Sq_getinteger(v, 4, &CallType);
std::vector<std::string> ParameterType;
// 遍历参数类型数组
sq_pushnull(v); // null iterator
while (SQ_SUCCEEDED(sq_next(v, 5)))
{
const SQChar* path;
Sq_getstring(v, -1, &path);
char* OutPutText = DNFTOOL::SquirrelU2W(path);
ParameterType.push_back(OutPutText);
delete[]OutPutText;
Sq_pop(v, 2);
}
Sq_pop(v, 1);
// 头部信息个数
int HeaderCount = 5;
// 计算valist内存
int AdrSize = 0;
for (std::string Type : ParameterType)
{
if (CONTAINS_STRING(Type, "int"))
AdrSize += sizeof(int);
else if (CONTAINS_STRING(Type, "bool"))
AdrSize += sizeof(bool);
else if (CONTAINS_STRING(Type, "string"))
AdrSize += sizeof(char*);
else if (CONTAINS_STRING(Type, "float"))
AdrSize += sizeof(float);
else if (CONTAINS_STRING(Type, "pointer"))
AdrSize += sizeof(void*);
else if (CONTAINS_STRING(Type, "short"))
AdrSize += sizeof(short);
else if (CONTAINS_STRING(Type, "char"))
AdrSize += sizeof(char);
}
char* m = (char*)malloc(AdrSize);
void* bm = m;
// 定义函数签名
ffi_cif cif;
ffi_type** args = (ffi_type**)malloc(ParameterType.size() * sizeof(ffi_type*)); // 动态分配参数类型数组
void** values = (void**)malloc(ParameterType.size() * sizeof(void*)); // 动态分配参数值数组
ffi_arg result;
int CFlag = 0;
for (int i = (HeaderCount + 1); i < (Count + 1); i++)
{
if (CONTAINS_STRING(ParameterType[0], "int"))
{
Sq_getinteger(v, i, (SQInteger*)m);
args[CFlag] = &ffi_type_sint;
values[CFlag] = m;
m += sizeof(int);
}
else if (CONTAINS_STRING(ParameterType[0], "float"))
{
Sq_getfloat(v, i, (SQFloat*)m);
args[CFlag] = &ffi_type_float;
values[CFlag] = m;
m += sizeof(float);
}
else if (CONTAINS_STRING(ParameterType[0], "bool"))
{
Sq_getbool(v, i, (SQBool*)m);
args[CFlag] = &ffi_type_sint8;
values[CFlag] = m;
m += sizeof(bool);
}
else if (CONTAINS_STRING(ParameterType[0], "string"))
{
Sq_getstring(v, i, (const SQChar**)m);
args[CFlag] = &ffi_type_pointer;
values[CFlag] = m;
m += sizeof(void*);
}
else if (CONTAINS_STRING(ParameterType[0], "pointer"))
{
Sq_getuserpointer(v, i, (SQUserPointer*)m);
args[CFlag] = &ffi_type_sint;
values[CFlag] = m;
m += sizeof(int);
}
else if (CONTAINS_STRING(ParameterType[0], "short"))
{
Sq_getinteger(v, i, (SQInteger*)m);
args[CFlag] = &ffi_type_sint16;
values[CFlag] = m;
m += sizeof(short);
}
else if (CONTAINS_STRING(ParameterType[0], "char"))
{
Sq_getinteger(v, i, (SQInteger*)m);
args[CFlag] = &ffi_type_schar;
values[CFlag] = m;
m += sizeof(char);
}
ParameterType.erase(ParameterType.begin());
CFlag++;
}
ffi_type* RetTypeFlag = &ffi_type_void;
std::string RetTypeString = RetType;
if (CONTAINS_STRING(RetTypeString, "int"))
RetTypeFlag = &ffi_type_sint;
else if (CONTAINS_STRING(RetTypeString, "float"))
RetTypeFlag = &ffi_type_float;
else if (CONTAINS_STRING(RetTypeString, "bool"))
RetTypeFlag = &ffi_type_sint8;
else if (CONTAINS_STRING(RetTypeString, "string"))
RetTypeFlag = &ffi_type_pointer;
else if (CONTAINS_STRING(RetTypeString, "pointer"))
RetTypeFlag = &ffi_type_pointer;
else if (CONTAINS_STRING(RetTypeString, "short"))
RetTypeFlag = &ffi_type_sint16;
else if (CONTAINS_STRING(RetTypeString, "char"))
RetTypeFlag = &ffi_type_schar;
int RetCore = 999;
if (RetCore = ffi_prep_cif(&cif, (ffi_abi)CallType, CFlag, RetTypeFlag, args) == FFI_OK)
{
// 动态调用函数
ffi_call(&cif, FFI_FN(FuncAddress), &result, values);
}
free(args);
free(values);
free(bm);
if (CONTAINS_STRING(RetTypeString, "int"))
Sq_pushinteger(v, (int)result);
else if (CONTAINS_STRING(RetTypeString, "float"))
Sq_pushfloat(v, (float)result);
else if (CONTAINS_STRING(RetTypeString, "bool"))
Sq_pushbool(v, (bool)result);
else if (CONTAINS_STRING(RetTypeString, "string")) {
wchar_t* ss = DNFTOOL::charTowchar_t((char*)result);
Sq_pushstring(v, ss, -1);
delete[]ss;
}
else if (CONTAINS_STRING(RetTypeString, "pointer"))
Sq_pushuserpointer(v, (void*)result);
else if (CONTAINS_STRING(RetTypeString, "short"))
Sq_pushinteger(v, (int)result);
else if (CONTAINS_STRING(RetTypeString, "char"))
Sq_pushinteger(v, (int)result);
else
return 0;
return 1;
}
static SQInteger Sq_GetExportByName(HSQUIRRELVM v)
{
//获取函数符号名
const SQChar* FuncNamebuf;
Sq_getstring(v, 2, &FuncNamebuf);
char* OutPutText2 = DNFTOOL::SquirrelU2W(FuncNamebuf);
std::string FuncName(OutPutText2);
delete[]OutPutText2;
HMODULE hModule = GetModuleHandle(NULL);
if (!hModule)
return 0;
FARPROC funcPtr = GetProcAddress(hModule, FuncName.c_str());
if (!funcPtr)
return 0;
Sq_pushinteger(v, (int)funcPtr);
return 1;
}
void RegisterMyNutApi(wchar_t* funcName, SQFUNCTION funcAddr)
{
@@ -2899,12 +2960,234 @@ void RegisterMyNutApi(wchar_t* funcName, SQFUNCTION funcAddr)
}
static SQInteger L_Str_Ptr(HSQUIRRELVM v)
{
const SQChar* str;
Sq_getstring(v, 2, &str);
Sq_pushuserpointer(v, (void*)str);
return 1;
}
static SQInteger New_Point(HSQUIRRELVM v)
{
SQInteger Len;
Sq_getinteger(v, 2, &Len);
void* P = malloc(Len);
Sq_pushuserpointer(v, P);
return 1;
}
static SQInteger _file_releasehook(SQUserPointer p, SQInteger a)
{
free((void*)p);
return 0;
}
// 注册析构函数
static SQInteger Register_Destruction(HSQUIRRELVM v)
{
// 析构函数测试
SQUserPointer P;
sq_getuserpointer(v, 2, &P);
sq_setinstanceup(v, 3, P);
sq_setreleasehook(v, 3, _file_releasehook);
return 0;
}
// 写字节数组
static SQInteger Memory_WriteByteArr(HSQUIRRELVM v)
{
SQUserPointer P;
Sq_getuserpointer(v, 2, &P);
char* Address = (char*)P;
size_t Idx = 0;
sq_pushnull(v); // null iterator
while (SQ_SUCCEEDED(sq_next(v, 3)))
{
SQInteger Buf;
Sq_getinteger(v, -1, &Buf);
*(BYTE*)(Address + Idx) = (BYTE)Buf;
// 这里-1是值-2是键
Sq_pop(v, 2); // 在下一次迭代之前弹出键和值
Idx++;
}
Sq_pop(v, 1);
return 0;
}
// 读内存字符串
static SQInteger Memory_ReadString(HSQUIRRELVM v)
{
// 内存地址
SQUserPointer Address;
// 获取地址
Sq_getuserpointer(v, 2, &Address);
if (Sq_gettop(v) == 3)
{
SQInteger Length;
Sq_getinteger(v, 3, &Length);
char* str = DNFTOOL::UnicodeToUtf8((wchar_t*)Address);
wchar_t* name = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, name, Length);
delete[]name;
}
else
{
char* str = DNFTOOL::UnicodeToUtf8((wchar_t*)Address);
wchar_t* name = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, name, -1);
delete[]name;
}
return 1;
}
// 读内存字符串
static SQInteger Memory_ReadStringByUtf8(HSQUIRRELVM v)
{
// 内存地址
SQUserPointer Address;
// 获取地址
Sq_getuserpointer(v, 2, &Address);
if (Sq_gettop(v) == 3)
{
SQInteger Length;
Sq_getinteger(v, 3, &Length);
wchar_t* name = DNFTOOL::charTowchar_t((char*)Address);
Sq_pushstring(v, name, Length);
delete[]name;
}
else
{
wchar_t* name = DNFTOOL::charTowchar_t((char*)Address);
Sq_pushstring(v, name, -1);
delete[]name;
}
return 1;
}
// 读内存字符串
static SQInteger Memory_ReadStringByBig5(HSQUIRRELVM v)
{
// 内存地址
SQUserPointer Address;
// 获取地址
Sq_getuserpointer(v, 2, &Address);
if (Sq_gettop(v) == 3)
{
SQInteger Length;
Sq_getinteger(v, 3, &Length);
wchar_t* newadd = DNFTOOL::charTowchar_t((char*)Address);
char* str = DNFTOOL::Big5ToUtf8(newadd);
wchar_t* name = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, name, Length);
delete[]name;
}
else
{
wchar_t* newadd = DNFTOOL::charTowchar_t((char*)Address);
char* str = DNFTOOL::Big5ToUtf8(newadd);
wchar_t* name = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, name, -1);
delete[]name;
}
return 1;
}
// 转换字符串
static SQInteger ConvertWideChar(HSQUIRRELVM v)
{
const SQChar* Str;
Sq_getstring(v, 2, &Str);
const SQChar* olgcodepage;
Sq_getstring(v, 3, &olgcodepage);
char* OutPutText1 = DNFTOOL::SquirrelU2W(olgcodepage);
std::string fromEncoding = OutPutText1;
delete[]OutPutText1;
if (CONTAINS_STRING(fromEncoding, "big5")) {
char* csa = DNFTOOL::wchar_tTochar((wchar_t*) Str);
wchar_t* name = DNFTOOL::BIG5ToUnicode(csa);
char* str = DNFTOOL::UnicodeToUtf8(name);
wchar_t* realname = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, realname, -1);
delete[]csa;
delete[]name;
delete[]realname;
}
else if (CONTAINS_STRING(fromEncoding, "unicode")) {
char* str = DNFTOOL::UnicodeToUtf8((wchar_t*)Str);
wchar_t* name = DNFTOOL::charTowchar_t(str);
free(str);
Sq_pushstring(v, name, -1);
delete[]name;
}
return 1;
}
// 指针转Blob
static SQInteger L_Point2Blob(HSQUIRRELVM v)
{
SQInteger P;
sq_getinteger(v, 2, &P);
SQInteger Count;
sq_getinteger(v, 3, &Count);
char* Address = (char*)P;
SQUserPointer Blobobj = sqstd_createblob(v, Count);
memcpy(Blobobj, Address, Count);
return 1;
}
static SQInteger OutPutTable(HSQUIRRELVM v)
{
const SQChar* Str;
sq_getstring(v, 2, &Str);
char* OutPutText = DNFTOOL::wchar_tTochar((wchar_t*)Str);
std::string str = OutPutText;
delete[]OutPutText;
nlohmann::json ex1 = nlohmann::json::parse(str);
std::cout << std::setw(4) << ex1 << std::endl;
return 0;
}
void R_Register_Nut() {
RegisterMyNutApi(L"L_sq_Test", sq_Test);//zlib解压
RegisterMyNutApi(L"L_sq_GetLocalConfig", sq_GetLocalConfig);//获取本地配置
RegisterMyNutApi(L"L_sq_SetLocalConfig", sq_SetLocalConfig);//设置本地配置
RegisterMyNutApi(L"Sq_OutPutTable", OutPutTable);
RegisterMyNutApi(L"Sq_HookFunc", L_HookFunc);
RegisterMyNutApi(L"Sq_DeHookFunc", L_DeHookFunc);
RegisterMyNutApi(L"Str_Ptr", L_Str_Ptr);
RegisterMyNutApi(L"Sq_New_Point", New_Point);
RegisterMyNutApi(L"Register_Destruction", Register_Destruction);
RegisterMyNutApi(L"Sq_Memory_WriteByteArr", Memory_WriteByteArr);
RegisterMyNutApi(L"Sq_Memory_ReadString", Memory_ReadString);
RegisterMyNutApi(L"Sq_Memory_ReadStringByUtf8", Memory_ReadStringByUtf8);
RegisterMyNutApi(L"Sq_Memory_ReadStringByBig5", Memory_ReadStringByBig5);
RegisterMyNutApi(L"Sq_ConvertWideChar", ConvertWideChar);
RegisterMyNutApi(L"Sq_Point2Blob", L_Point2Blob);
RegisterMyNutApi(L"L_Sq_CallFunc", Sq_ActiveCallFunc);//动态Call
RegisterMyNutApi(L"L_Sq_GetExportByName", Sq_GetExportByName);//动态Call
RegisterMyNutApi(L"L_sq_GetItem", sq_GetItem);//获取Item
RegisterMyNutApi(L"L_sq_StringBinById", sq_StringBinById);//获取字符串在StringBin中
RegisterMyNutApi(L"L_sq_LongLongOperation", sq_LongLongOperation);//longlong类型运算
RegisterMyNutApi(L"L_sq_Dezlib", sq_Dezlib);//zlib解压
RegisterMyNutApi(L"L_sq_DrawImg", sq_DrawImg);//绘制Img
@@ -2987,9 +3270,14 @@ void R_Register_Nut() {
RegisterMyNutApi(L"L_sq_RAB", LReadAddressB);//读内存
RegisterMyNutApi(L"L_sq_WAB", LWriteAddressB);//写内存
RegisterMyNutApi(L"Sout", Sout);//输出
RegisterMyNutApi(L"L_sq_I2P", sq_I2P);//int转指针
RegisterMyNutApi(L"L_sq_P2I", sq_P2I);//指针转int
RegisterMyNutApi(L"printf", Sout);//输出
//RegisterMyNutApi(L"L_ReplaceInString", ReplaceInString);//输出
RegisterMyNutApi(L"Clock", Clock);//输出
RegisterMyNutApi(L"L_Getmicroseconds", Getmicroseconds);//获取微秒级
RegisterMyNutApi(L"Sq_Time", SQTime);
RegisterMyNutApi(L"L_NewWindows", NewWindows);//创建窗口
RegisterMyNutApi(L"L_Cmd", sq_Cmd);//执行Cmd命令

531
Include/ffi.h Normal file
View File

@@ -0,0 +1,531 @@
/* -----------------------------------------------------------------*-C-*-
libffi 3.4.4
- Copyright (c) 2011, 2014, 2019, 2021, 2022 Anthony Green
- Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the ``Software''), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* -------------------------------------------------------------------
Most of the API is documented in doc/libffi.texi.
The raw API is designed to bypass some of the argument packing and
unpacking on architectures for which it can be avoided. Routines
are provided to emulate the raw API if the underlying platform
doesn't allow faster implementation.
More details on the raw API can be found in:
http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
and
http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
-------------------------------------------------------------------- */
#ifndef LIBFFI_H
#define LIBFFI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Specify which architecture libffi is configured for. */
#ifndef X86_WIN32
#define X86_WIN32
#endif
/* ---- System configuration information --------------------------------- */
/* If these change, update src/mips/ffitarget.h. */
#define FFI_TYPE_VOID 0
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
#if 0
#define FFI_TYPE_LONGDOUBLE 4
#else
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
#endif
#define FFI_TYPE_UINT8 5
#define FFI_TYPE_SINT8 6
#define FFI_TYPE_UINT16 7
#define FFI_TYPE_SINT16 8
#define FFI_TYPE_UINT32 9
#define FFI_TYPE_SINT32 10
#define FFI_TYPE_UINT64 11
#define FFI_TYPE_SINT64 12
#define FFI_TYPE_STRUCT 13
#define FFI_TYPE_POINTER 14
#define FFI_TYPE_COMPLEX 15
/* This should always refer to the last type code (for sanity checks). */
#define FFI_TYPE_LAST FFI_TYPE_COMPLEX
#include <ffitarget.h>
#ifndef LIBFFI_ASM
#if defined(_MSC_VER) && !defined(__clang__)
#define __attribute__(X)
#endif
#include <stddef.h>
#include <limits.h>
/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
But we can find it either under the correct ANSI name, or under GNU
C's internal name. */
#define FFI_64_BIT_MAX 9223372036854775807
#ifdef LONG_LONG_MAX
# define FFI_LONG_LONG_MAX LONG_LONG_MAX
#else
# ifdef LLONG_MAX
# define FFI_LONG_LONG_MAX LLONG_MAX
# ifdef _AIX52 /* or newer has C99 LLONG_MAX */
# undef FFI_64_BIT_MAX
# define FFI_64_BIT_MAX 9223372036854775807LL
# endif /* _AIX52 or newer */
# else
# ifdef __GNUC__
# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
# endif
# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */
# ifndef __PPC64__
# if defined (__IBMC__) || defined (__IBMCPP__)
# define FFI_LONG_LONG_MAX LONGLONG_MAX
# endif
# endif /* __PPC64__ */
# undef FFI_64_BIT_MAX
# define FFI_64_BIT_MAX 9223372036854775807LL
# endif
# endif
#endif
/* The closure code assumes that this works on pointers, i.e. a size_t
can hold a pointer. */
typedef struct _ffi_type
{
size_t size;
unsigned short alignment;
unsigned short type;
struct _ffi_type **elements;
} ffi_type;
/* Need minimal decorations for DLLs to work on Windows. GCC has
autoimport and autoexport. Always mark externally visible symbols
as dllimport for MSVC clients, even if it means an extra indirection
when using the static version of the library.
Besides, as a workaround, they can define FFI_BUILDING if they
*know* they are going to link with the static library. */
#if defined _MSC_VER
# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */
# define FFI_API __declspec(dllexport)
# elif !defined FFI_BUILDING /* Importing libffi.DLL */
# define FFI_API __declspec(dllimport)
# else /* Building/linking static library */
# define FFI_API
# endif
#else
# define FFI_API
#endif
/* The externally visible type declarations also need the MSVC DLL
decorations, or they will not be exported from the object file. */
#if defined LIBFFI_HIDE_BASIC_TYPES
# define FFI_EXTERN FFI_API
#else
# define FFI_EXTERN extern FFI_API
#endif
#ifndef LIBFFI_HIDE_BASIC_TYPES
#if SCHAR_MAX == 127
# define ffi_type_uchar ffi_type_uint8
# define ffi_type_schar ffi_type_sint8
#else
#error "char size not supported"
#endif
#if SHRT_MAX == 32767
# define ffi_type_ushort ffi_type_uint16
# define ffi_type_sshort ffi_type_sint16
#elif SHRT_MAX == 2147483647
# define ffi_type_ushort ffi_type_uint32
# define ffi_type_sshort ffi_type_sint32
#else
#error "short size not supported"
#endif
#if INT_MAX == 32767
# define ffi_type_uint ffi_type_uint16
# define ffi_type_sint ffi_type_sint16
#elif INT_MAX == 2147483647
# define ffi_type_uint ffi_type_uint32
# define ffi_type_sint ffi_type_sint32
#elif INT_MAX == 9223372036854775807
# define ffi_type_uint ffi_type_uint64
# define ffi_type_sint ffi_type_sint64
#else
#error "int size not supported"
#endif
#if LONG_MAX == 2147483647
# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX
#error "no 64-bit data type supported"
# endif
#elif LONG_MAX != FFI_64_BIT_MAX
#error "long size not supported"
#endif
#if LONG_MAX == 2147483647
# define ffi_type_ulong ffi_type_uint32
# define ffi_type_slong ffi_type_sint32
#elif LONG_MAX == FFI_64_BIT_MAX
# define ffi_type_ulong ffi_type_uint64
# define ffi_type_slong ffi_type_sint64
#else
#error "long size not supported"
#endif
/* These are defined in types.c. */
FFI_EXTERN ffi_type ffi_type_void;
FFI_EXTERN ffi_type ffi_type_uint8;
FFI_EXTERN ffi_type ffi_type_sint8;
FFI_EXTERN ffi_type ffi_type_uint16;
FFI_EXTERN ffi_type ffi_type_sint16;
FFI_EXTERN ffi_type ffi_type_uint32;
FFI_EXTERN ffi_type ffi_type_sint32;
FFI_EXTERN ffi_type ffi_type_uint64;
FFI_EXTERN ffi_type ffi_type_sint64;
FFI_EXTERN ffi_type ffi_type_float;
FFI_EXTERN ffi_type ffi_type_double;
FFI_EXTERN ffi_type ffi_type_pointer;
#if 0
FFI_EXTERN ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
#endif
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
FFI_EXTERN ffi_type ffi_type_complex_float;
FFI_EXTERN ffi_type ffi_type_complex_double;
#if 0
FFI_EXTERN ffi_type ffi_type_complex_longdouble;
#else
#define ffi_type_complex_longdouble ffi_type_complex_double
#endif
#endif
#endif /* LIBFFI_HIDE_BASIC_TYPES */
typedef enum {
FFI_OK = 0,
FFI_BAD_TYPEDEF,
FFI_BAD_ABI,
FFI_BAD_ARGTYPE
} ffi_status;
typedef struct {
ffi_abi abi;
unsigned nargs;
ffi_type **arg_types;
ffi_type *rtype;
unsigned bytes;
unsigned flags;
#ifdef FFI_EXTRA_CIF_FIELDS
FFI_EXTRA_CIF_FIELDS;
#endif
} ffi_cif;
/* ---- Definitions for the raw API -------------------------------------- */
#ifndef FFI_SIZEOF_ARG
# if LONG_MAX == 2147483647
# define FFI_SIZEOF_ARG 4
# elif LONG_MAX == FFI_64_BIT_MAX
# define FFI_SIZEOF_ARG 8
# endif
#endif
#ifndef FFI_SIZEOF_JAVA_RAW
# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
#endif
typedef union {
ffi_sarg sint;
ffi_arg uint;
float flt;
char data[FFI_SIZEOF_ARG];
void* ptr;
} ffi_raw;
#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8
/* This is a special case for mips64/n32 ABI (and perhaps others) where
sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */
typedef union {
signed int sint;
unsigned int uint;
float flt;
char data[FFI_SIZEOF_JAVA_RAW];
void* ptr;
} ffi_java_raw;
#else
typedef ffi_raw ffi_java_raw;
#endif
FFI_API
void ffi_raw_call (ffi_cif *cif,
void (*fn)(void),
void *rvalue,
ffi_raw *avalue);
FFI_API void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
FFI_API void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
FFI_API size_t ffi_raw_size (ffi_cif *cif);
/* This is analogous to the raw API, except it uses Java parameter
packing, even on 64-bit machines. I.e. on 64-bit machines longs
and doubles are followed by an empty 64-bit word. */
#if !FFI_NATIVE_RAW_API
FFI_API
void ffi_java_raw_call (ffi_cif *cif,
void (*fn)(void),
void *rvalue,
ffi_java_raw *avalue) __attribute__((deprecated));
#endif
FFI_API
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated));
FFI_API
void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __attribute__((deprecated));
FFI_API
size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
/* ---- Definitions for closures ----------------------------------------- */
#if FFI_CLOSURES
#ifdef _MSC_VER
__declspec(align(8))
#endif
typedef struct {
#if 0
void *trampoline_table;
void *trampoline_table_entry;
#else
union {
char tramp[FFI_TRAMPOLINE_SIZE];
void *ftramp;
};
#endif
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data;
#if defined(_MSC_VER) && defined(_M_IX86)
void *padding;
#endif
} ffi_closure
#ifdef __GNUC__
__attribute__((aligned (8)))
#endif
;
#ifndef __GNUC__
# ifdef __sgi
# pragma pack 0
# endif
#endif
FFI_API void *ffi_closure_alloc (size_t size, void **code);
FFI_API void ffi_closure_free (void *);
#if defined(PA_LINUX) || defined(PA_HPUX)
#define FFI_CLOSURE_PTR(X) ((void *)((unsigned int)(X) | 2))
#define FFI_RESTORE_PTR(X) ((void *)((unsigned int)(X) & ~3))
#else
#define FFI_CLOSURE_PTR(X) (X)
#define FFI_RESTORE_PTR(X) (X)
#endif
FFI_API ffi_status
ffi_prep_closure (ffi_closure*,
ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data)
#if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 405)
__attribute__((deprecated ("use ffi_prep_closure_loc instead")))
#elif defined(__GNUC__) && __GNUC__ >= 3
__attribute__((deprecated))
#endif
;
FFI_API ffi_status
ffi_prep_closure_loc (ffi_closure*,
ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void *codeloc);
#ifdef __sgi
# pragma pack 8
#endif
typedef struct {
#if 0
void *trampoline_table;
void *trampoline_table_entry;
#else
char tramp[FFI_TRAMPOLINE_SIZE];
#endif
ffi_cif *cif;
#if !FFI_NATIVE_RAW_API
/* If this is enabled, then a raw closure has the same layout
as a regular closure. We use this to install an intermediate
handler to do the translation, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void *this_closure;
#endif
void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
void *user_data;
} ffi_raw_closure;
typedef struct {
#if 0
void *trampoline_table;
void *trampoline_table_entry;
#else
char tramp[FFI_TRAMPOLINE_SIZE];
#endif
ffi_cif *cif;
#if !FFI_NATIVE_RAW_API
/* If this is enabled, then a raw closure has the same layout
as a regular closure. We use this to install an intermediate
handler to do the translation, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void *this_closure;
#endif
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);
void *user_data;
} ffi_java_raw_closure;
FFI_API ffi_status
ffi_prep_raw_closure (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data);
FFI_API ffi_status
ffi_prep_raw_closure_loc (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data,
void *codeloc);
#if !FFI_NATIVE_RAW_API
FFI_API ffi_status
ffi_prep_java_raw_closure (ffi_java_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data) __attribute__((deprecated));
FFI_API ffi_status
ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data,
void *codeloc) __attribute__((deprecated));
#endif
#endif /* FFI_CLOSURES */
#if FFI_GO_CLOSURES
typedef struct {
void *tramp;
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
} ffi_go_closure;
FFI_API ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*));
FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
void **avalue, void *closure);
#endif /* FFI_GO_CLOSURES */
/* ---- Public interface definition -------------------------------------- */
FFI_API
ffi_status ffi_prep_cif(ffi_cif *cif,
ffi_abi abi,
unsigned int nargs,
ffi_type *rtype,
ffi_type **atypes);
FFI_API
ffi_status ffi_prep_cif_var(ffi_cif *cif,
ffi_abi abi,
unsigned int nfixedargs,
unsigned int ntotalargs,
ffi_type *rtype,
ffi_type **atypes);
FFI_API
void ffi_call(ffi_cif *cif,
void (*fn)(void),
void *rvalue,
void **avalue);
FFI_API
ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type,
size_t *offsets);
/* Useful for eliminating compiler warnings. */
#define FFI_FN(f) ((void (*)(void))f)
/* ---- Definitions shared with assembly code ---------------------------- */
#endif
#ifdef __cplusplus
}
#endif
#endif

164
Include/ffitarget.h Normal file
View File

@@ -0,0 +1,164 @@
/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2012, 2014, 2018 Anthony Green
Copyright (c) 1996-2003, 2010 Red Hat, Inc.
Copyright (C) 2008 Free Software Foundation, Inc.
Target configuration macros for x86 and x86-64.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
/* ---- System specific configurations ----------------------------------- */
/* For code common to all platforms on x86 and x86_64. */
#define X86_ANY
#if defined (X86_64) && defined (__i386__)
#undef X86_64
#warning ******************************************************
#warning ********** X86 IS DEFINED ****************************
#warning ******************************************************
#define X86
#endif
#ifdef X86_WIN64
#define FFI_SIZEOF_ARG 8
#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
#endif
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
#ifndef _MSC_VER
#define FFI_TARGET_HAS_COMPLEX_TYPE
#endif
/* ---- Generic type definitions ----------------------------------------- */
#ifndef LIBFFI_ASM
#ifdef X86_WIN64
#ifdef _MSC_VER
typedef unsigned __int64 ffi_arg;
typedef __int64 ffi_sarg;
#else
typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#endif
#else
#if defined __x86_64__ && defined __ILP32__
#define FFI_SIZEOF_ARG 8
#define FFI_SIZEOF_JAVA_RAW 4
typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#else
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
#endif
#endif
typedef enum ffi_abi {
#if defined(X86_WIN64)
FFI_FIRST_ABI = 0,
FFI_WIN64, /* sizeof(long double) == 8 - microsoft compilers */
FFI_GNUW64, /* sizeof(long double) == 16 - GNU compilers */
FFI_LAST_ABI,
#ifdef __GNUC__
FFI_DEFAULT_ABI = FFI_GNUW64
#else
FFI_DEFAULT_ABI = FFI_WIN64
#endif
#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
FFI_FIRST_ABI = 1,
FFI_UNIX64,
FFI_WIN64,
FFI_EFI64 = FFI_WIN64,
FFI_GNUW64,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_UNIX64
#elif defined(X86_WIN32)
FFI_FIRST_ABI = 0,
FFI_SYSV = 1,
FFI_STDCALL = 2,
FFI_THISCALL = 3,
FFI_FASTCALL = 4,
FFI_MS_CDECL = 5,
FFI_PASCAL = 6,
FFI_REGISTER = 7,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_MS_CDECL
#else
FFI_FIRST_ABI = 0,
FFI_SYSV = 1,
FFI_THISCALL = 3,
FFI_FASTCALL = 4,
FFI_STDCALL = 5,
FFI_PASCAL = 6,
FFI_REGISTER = 7,
FFI_MS_CDECL = 8,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_SYSV
#endif
} ffi_abi;
#endif
/* ---- Definitions for closures ----------------------------------------- */
#define FFI_CLOSURES 1
#define FFI_GO_CLOSURES 1
#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
#if defined (X86_64) || defined(X86_WIN64) \
|| (defined (__x86_64__) && defined (X86_DARWIN))
/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP
+ 8 bytes of pointer. */
# define FFI_TRAMPOLINE_SIZE 32
# define FFI_NATIVE_RAW_API 0
#else
/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused
bytes. */
# define FFI_TRAMPOLINE_SIZE 16
# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
#endif
#if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__)
# include <cet.h>
# if (__CET__ & 1) != 0
# define ENDBR_PRESENT
# endif
# define _CET_NOTRACK notrack
#else
# define _CET_ENDBR
# define _CET_NOTRACK
#endif
#endif

70004
Include/frida-gum.h Normal file

File diff suppressed because it is too large Load Diff

241
Include/iconv.h Normal file
View File

@@ -0,0 +1,241 @@
/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version 2.1
of the License, or (at your option) any later version.
The GNU LIBICONV Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
If not, see <https://www.gnu.org/licenses/>. */
/* When installed, this file is called "iconv.h". */
#ifndef _LIBICONV_H
#define _LIBICONV_H
#define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */
extern int _libiconv_version; /* Likewise */
/* We would like to #include any system header file which could define
iconv_t, 1. in order to eliminate the risk that the user gets compilation
errors because some other system header file includes /usr/include/iconv.h
which defines iconv_t or declares iconv after this file, 2. when compiling
for LIBICONV_PLUG, we need the proper iconv_t type in order to produce
binary compatible code.
But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
has been installed in /usr/local/include, there is no way any more to
include the original /usr/include/iconv.h. We simply have to get away
without it.
Ad 1. The risk that a system header file does
#include "iconv.h" or #include_next "iconv.h"
is small. They all do #include <iconv.h>.
Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It
has to be a scalar type because (iconv_t)(-1) is a possible return value
from iconv_open().) */
/* Define iconv_t ourselves. */
#undef iconv_t
#define iconv_t libiconv_t
typedef void* iconv_t;
/* Get size_t declaration.
Get wchar_t declaration if it exists. */
#include <stddef.h>
/* Get errno declaration and values. */
#include <errno.h>
/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
have EILSEQ in a different header. On these systems, define EILSEQ
ourselves. */
#ifndef EILSEQ
#define EILSEQ
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Allocates descriptor for code conversion from encoding fromcode to
encoding tocode. */
#ifndef LIBICONV_PLUG
#define iconv_open libiconv_open
#endif
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
/* Converts, using conversion descriptor cd, at most *inbytesleft bytes
starting at *inbuf, writing at most *outbytesleft bytes starting at
*outbuf.
Decrements *inbytesleft and increments *inbuf by the same amount.
Decrements *outbytesleft and increments *outbuf by the same amount. */
#ifndef LIBICONV_PLUG
#define iconv libiconv
#endif
extern size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
/* Frees resources allocated for conversion descriptor cd. */
#ifndef LIBICONV_PLUG
#define iconv_close libiconv_close
#endif
extern int iconv_close (iconv_t cd);
#ifdef __cplusplus
}
#endif
#ifndef LIBICONV_PLUG
/* Nonstandard extensions. */
#if 1
#if 0
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
included before <wchar.h>. */
#include <stddef.h>
#include <stdio.h>
#include <time.h>
#endif
#include <wchar.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* A type that holds all memory needed by a conversion descriptor.
A pointer to such an object can be used as an iconv_t. */
typedef struct {
void* dummy1[28];
#if 1
mbstate_t dummy2;
#endif
} iconv_allocation_t;
/* Allocates descriptor for code conversion from encoding fromcode to
encoding tocode into preallocated memory. Returns an error indicator
(0 or -1 with errno set). */
#define iconv_open_into libiconv_open_into
extern int iconv_open_into (const char* tocode, const char* fromcode,
iconv_allocation_t* resultp);
/* Control of attributes. */
#define iconvctl libiconvctl
extern int iconvctl (iconv_t cd, int request, void* argument);
/* Hook performed after every successful conversion of a Unicode character. */
typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
/* Hook performed after every successful conversion of a wide character. */
typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
/* Set of hooks. */
struct iconv_hooks {
iconv_unicode_char_hook uc_hook;
iconv_wide_char_hook wc_hook;
void* data;
};
/* Fallback function. Invoked when a small number of bytes could not be
converted to a Unicode character. This function should process all
bytes from inbuf and may produce replacement Unicode characters by calling
the write_replacement callback repeatedly. */
typedef void (*iconv_unicode_mb_to_uc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const unsigned int *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a Unicode character could not be converted
to the target encoding. This function should process the character and
may produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_unicode_uc_to_mb_fallback)
(unsigned int code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#if 1
/* Fallback function. Invoked when a number of bytes could not be converted to
a wide character. This function should process all bytes from inbuf and may
produce replacement wide characters by calling the write_replacement
callback repeatedly. */
typedef void (*iconv_wchar_mb_to_wc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const wchar_t *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a wide character could not be converted to
the target encoding. This function should process the character and may
produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_wchar_wc_to_mb_fallback)
(wchar_t code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#else
/* If the wchar_t type does not exist, these two fallback functions are never
invoked. Their argument list therefore does not matter. */
typedef void (*iconv_wchar_mb_to_wc_fallback) ();
typedef void (*iconv_wchar_wc_to_mb_fallback) ();
#endif
/* Set of fallbacks. */
struct iconv_fallbacks {
iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
void* data;
};
/* Requests for iconvctl. */
#define ICONV_TRIVIALP 0 /* int *argument */
#define ICONV_GET_TRANSLITERATE 1 /* int *argument */
#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */
#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */
#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */
#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */
#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */
/* Listing of locale independent encodings. */
#define iconvlist libiconvlist
extern void iconvlist (int (*do_one) (unsigned int namescount,
const char * const * names,
void* data),
void* data);
/* Canonicalize an encoding name.
The result is either a canonical encoding name, or name itself. */
extern const char * iconv_canonicalize (const char * name);
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern void libiconv_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif
#endif /* _LIBICONV_H */

45
Include/libcharset.h Normal file
View File

@@ -0,0 +1,45 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
The GNU CHARSET Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU CHARSET Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
see <https://www.gnu.org/licenses/>. */
#ifndef _LIBCHARSET_H
#define _LIBCHARSET_H
#include <localcharset.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern void LIBCHARSET_DLL_EXPORTED libcharset_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif /* _LIBCHARSET_H */

137
Include/localcharset.h Normal file
View File

@@ -0,0 +1,137 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H
#ifdef __cplusplus
extern "C" {
#endif
/* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed below.
The result must not be freed; it is statically allocated. The result
becomes invalid when setlocale() is used to change the global locale, or
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
is changed; threads in multithreaded programs should not do this.
If the canonical name cannot be determined, the result is a non-canonical
name. */
extern const char * locale_charset (void);
/* About GNU canonical names for character encodings:
Every canonical name must be supported by GNU libiconv. Support by GNU libc
is also desirable.
The name is case insensitive. Usually an upper case MIME charset name is
preferred.
The current list of these GNU canonical names is:
name MIME? used by which systems
(darwin = Mac OS X, windows = native Windows)
ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-3 Y glibc solaris cygwin
ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-6 Y glibc aix hpux solaris cygwin
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
ISO-8859-14 glibc cygwin
ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
KOI8-T glibc
CP437 dos
CP775 dos
CP850 aix osf dos
CP852 dos
CP855 dos
CP856 aix
CP857 dos
CP861 dos
CP862 dos
CP864 dos
CP865 dos
CP866 freebsd netbsd openbsd darwin dos
CP869 dos
CP874 windows dos
CP922 aix
CP932 aix cygwin windows dos
CP943 aix zos
CP949 osf darwin windows dos
CP950 windows dos
CP1046 aix
CP1124 aix
CP1125 dos
CP1129 aix
CP1131 freebsd darwin
CP1250 windows
CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
CP1252 aix windows
CP1253 windows
CP1254 windows
CP1255 glibc windows
CP1256 windows
CP1257 windows
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
EUC-TW glibc aix hpux irix osf solaris netbsd
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
BIG5-HKSCS glibc hpux solaris netbsd darwin
GBK glibc aix osf solaris freebsd darwin cygwin windows dos
GB18030 glibc hpux solaris freebsd netbsd darwin
SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
JOHAB glibc solaris windows
TIS-620 glibc aix hpux osf solaris cygwin zos
VISCII Y glibc
TCVN5712-1 glibc
ARMSCII-8 glibc freebsd netbsd darwin
GEORGIAN-PS glibc cygwin
PT154 glibc netbsd cygwin
HP-ROMAN8 hpux
HP-ARABIC8 hpux
HP-GREEK8 hpux
HP-HEBREW8 hpux
HP-TURKISH8 hpux
HP-KANA8 hpux
DEC-KANJI osf
DEC-HANYU osf
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
Note: Names which are not marked as being a MIME name should not be used in
Internet protocols for information interchange (mail, news, etc.).
Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
must understand both names and treat them as equivalent.
*/
#ifdef __cplusplus
}
#endif
#endif /* _LOCALCHARSET_H */