This commit is contained in:
2024-03-31 13:23:55 +08:00
parent a1b9f7a32d
commit a08eb9c220
11 changed files with 804 additions and 233 deletions

View File

@@ -344,6 +344,7 @@ static NNoticeTCall _ANoticeTcall = (NNoticeTCall)0xE6E070;
//打开特殊窗口
typedef void(_fastcall _Open_ExWindow)(int thisc, void*, int a2, char a3, char a4);
static _Open_ExWindow* Open_ExWindow = (_Open_ExWindow*)0xE718A0;
static _Open_ExWindow* Open_ExWindow2 = (_Open_ExWindow*)0xE6E070;
int sq_Open_ExWindow(uint32_t v) {
int a1, a2, a3, a4;
@@ -355,7 +356,17 @@ int sq_Open_ExWindow(uint32_t v) {
Open_ExWindow(a1,0,a2,a3,a4);
return 0;
}
int sq_Open_ExWindow2(uint32_t v) {
int a1, a2, a3, a4;
SQGetInt(v, 2, &a1);
SQGetInt(v, 3, &a2);
SQGetInt(v, 4, &a3);
SQGetInt(v, 5, &a4);
Open_ExWindow2(a1, 0, a2, a3, a4);
return 0;
}
typedef int(_cdecl _sub7AAB60)(int a1);
@@ -494,81 +505,231 @@ int sq_Select_MiniMap_Index(uint32_t v) {
return 0;
}
struct InputWindowInfoS {
int x;
int y;
int width;
int height;
std::string str;
};
LRESULT CALLBACK LenheartCode(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
static int mX, mY;
static HWND hwndButton;
static HWND hwndEditbox;
std::string strXy;
const int IDcmdButton = 1;
const int IDeditBox = 2;
static InputWindowInfoS* WInfo;
switch (message) {
case WM_CREATE:
{
RECT rect;
GetWindowRect(hwnd, &rect); // 获取窗口的矩形区域
// 获取传递的参数
CREATESTRUCT* pCreate = (CREATESTRUCT*)lParam;
WInfo = (InputWindowInfoS*)pCreate->lpCreateParams;
hwndEditbox = CreateWindowA("edit", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE,
0, 0,
WInfo->width, WInfo->height,
hwnd, (HMENU)IDeditBox, NULL, NULL);
ShowWindow(hwndEditbox, SW_SHOW);
UpdateWindow(hwndEditbox);
HFONT hFont = CreateFont(13.5, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, TEXT("Fonts\\msjh.ttf"));
SendMessage(hwndEditbox, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SetForegroundWindow(hwndEditbox);
//如果有字先写进去
if (WInfo->str.length() > 0)SetWindowTextA(hwndEditbox, WInfo->str.c_str());
// 获取当前文本长度
int length = GetWindowTextLengthA(hwndEditbox);
// 将光标移动到文本末尾
SendMessage(hwndEditbox, EM_SETSEL, length, length);
return 0;
}
case WM_CTLCOLOREDIT:
{
HDC ahdc = (HDC)wParam;
SetTextColor(ahdc, RGB(0, 0, 0));
//SetTextColor(ahdc, RGB(255, 255, 255));
SetBkMode(ahdc, TRANSPARENT); // 设置背景透明
return (INT_PTR)GetStockObject(NULL_BRUSH); // 返回空画刷
//return 0; //返回句柄画刷时,背景颜色变为对应的背景颜色
}
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
}
case WM_SIZE:
{
return 0;
}
case WM_COMMAND:
switch (LOWORD(wParam)) {
case 0:
PostQuitMessage(0);
break;
case IDeditBox:
if (HIWORD(wParam) == EN_CHANGE) {
char strbuf[256];
// 编辑框内容发生变化
GetWindowTextA(hwndEditbox, strbuf, 256);
//std::cout << strbuf << std::endl;
WInfo->str = strbuf;
}
if (HIWORD(wParam) == EN_SETFOCUS) {
}
else if (HIWORD(wParam) == EN_KILLFOCUS) {
DestroyWindow(hwnd); //销毁窗口
WInfo->str = "LenheartNULL";
//CREATESTRUCT* pCreate = (CREATESTRUCT*)lParam;
//delete[](InputWindowInfoS*)pCreate->lpCreateParams;
//pCreate->lpCreateParams = NULL;
//exit(0);
}
break;
}
return 0;
case WM_MOUSEACTIVATE:
break;
case WM_CLOSE:
DestroyWindow(hwnd); //销毁窗口
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
void LenheartWindows(LPVOID lpParam) {
HWND DNFW = FindWindow(L"DNF Taiwan", L"DNF Taiwan"); // 替换"Window Title"为你要查找的窗口标题
RECT rect;
GetWindowRect(DNFW, &rect); // 获取窗口的矩形区域
InputWindowInfoS* WInfo = (InputWindowInfoS*)lpParam;
const wchar_t* className = L"myInputBoxClass";
HINSTANCE hInstance = GetModuleHandle(NULL);
WNDCLASS wc = {};
wc.lpfnWndProc = LenheartCode;
wc.hInstance = hInstance;
wc.lpszClassName = className;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
//wc.hbrBackground = NULL;
RegisterClass(&wc);
// 创建输入框
HWND hwnd = CreateWindowEx(
0, className, L"Input Box",
WS_POPUP | WS_EX_TOOLWINDOW,
rect.left + WInfo->x, rect.top + WInfo->y, WInfo->width, WInfo->height,
NULL, NULL, hInstance, lpParam);
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TOOLWINDOW);
SetLayeredWindowAttributes(hwnd, 0, 0, LWA_ALPHA);
ShowWindow(hwnd, SW_SHOW);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
int sq_NewInputBox(uint32_t v)
{
InputWindowInfoS* WInfo = new InputWindowInfoS();
SQGetInt(v, 2, &WInfo->x);
SQGetInt(v, 3, &WInfo->y);
SQGetInt(v, 4, &WInfo->width);
SQGetInt(v, 5, &WInfo->height);
wchar_t* Str;
SQGetString(v, 6, &Str);
char* OutPutText = DNFTOOL::SquirrelU2W(Str);
std::string RealStr = OutPutText;
delete[]OutPutText;
WInfo->str = RealStr;
DWORD threadID3;
HANDLE Thand3 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LenheartWindows, WInfo, 0, &threadID3);
SQPushInt(v, (int)WInfo);
return 1;
}
int sq_GetInputBoxStr(uint32_t v)
{
int Addr;
SQGetInt(v, 2, &Addr);
InputWindowInfoS* WInfo = (InputWindowInfoS*)Addr;
std::string str = WInfo->str;
char* ss = GBKTOUTF8(str);
//wchar_t* name = DNFTOOL::charTowchar_t((char*)Buf.c_str());
wchar_t* aa = DNFTOOL::charTowchar_t(ss);
SQPushString(v, aa, -1);
return 1;
}
int sq_SetInputBoxStr(uint32_t v)
{
int Addr;
SQGetInt(v, 2, &Addr);
wchar_t* Str;
SQGetString(v, 3, &Str);
char* OutPutText = DNFTOOL::SquirrelU2W(Str);
std::string RealStr = OutPutText;
delete[]OutPutText;
InputWindowInfoS* WInfo = (InputWindowInfoS*)Addr;
WInfo->str = RealStr;
return 0;
}
int squirrel::sq_Test(uint32_t v)
{
//int ReIndex;
//SQGetInt(v, 2, &ReIndex);
//static int dnf_103E030 = 0x103E030;
//static int dnf_287FA88 = 0x287FA88;
//static int dnf_103DCD0 = 0x103DCD0;
//static int dnf_103B240 = 0x103B240;
//static int dnf_2878D95 = 0x2878D95;
//static int dnf_1194FC0 = 0x1194FC0;
//static int dnf_410230 = 0x410230;
//static int dnf_102F4D0 = 0x102F4D0;
//_asm
//{
//
// mov ecx, dword ptr ds :[0x1A5FB20]
// mov esi, dword ptr ds :[ecx+0x42DC]
// push ReIndex
// call dnf_103E030
// mov ecx,eax
// call dnf_287FA88
// push ReIndex
// call dnf_103E030
// mov ecx,eax
// call dnf_103DCD0
// mov ecx,eax
// mov dword ptr ds:[esi+0x24],eax
// call dnf_103B240
// mov ecx,dword ptr ds:[esi+0x24]
// call dnf_2878D95
// push 0x1556138
// call dnf_1194FC0
// mov ecx,eax
// add esp,4
// lea edi,dword ptr ds:[ecx+2]
// dnf_1031651:
// mov dx,word ptr ds:[ecx]
// add ecx,2
// test dx,dx
// jne dnf_1031651
// sub ecx,edi
// sar ecx,1
// push ecx
// push eax
// lea ecx,dword ptr ds:[esi+0x144]
// call dnf_410230
// mov ecx,esi
// mov dword ptr ds:[esi+0x28],14
// call dnf_102F4D0
//}
//int ObjectAddress;
//int SkillId;
//SQGetInt(v, 2, &ObjectAddress);
//SQGetInt(v, 3, &SkillId);
//Test(ObjectAddress, 0, SkillId);
//TestB(ObjectAddress, 0, SkillId);
//std::cout << ret << std::endl;
int objaddress;
int Key_Value;
SQGetInt(v, 2, &objaddress);
SQGetInt(v, 3, &Key_Value);
Test(objaddress,0, Key_Value);
return 0;
}
@@ -870,23 +1031,6 @@ int sq_GetStringDrawLength(uint32_t v) {
}
char* GBKTOUTF8(std::string& strGBK)//转码 GBK编码转成UTF8编码
{
int len = MultiByteToWideChar(CP_ACP, 0, strGBK.c_str(), -1, NULL, 0);
wchar_t* wszUtf8 = new wchar_t[len];
memset(wszUtf8, 0, len);
MultiByteToWideChar(CP_ACP, 0, strGBK.c_str(), -1, wszUtf8, len);
len = WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL);
char* szUtf8 = new char[len + 1];
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, szUtf8, len, NULL, NULL);
strGBK = szUtf8;
delete[] szUtf8;
delete[] wszUtf8;
return (char*)strGBK.c_str();
}
#include "include/squirrel.h"
int sq_GetStringDrawArray(uint32_t v) {
wchar_t* Str;
@@ -1175,6 +1319,12 @@ int sq_DrawButton(uint32_t v)
SQGetString(v, 5, &File);
int StartIdx;
SQGetInt(v, 6, &StartIdx);
//填充宽度
int FillWidth;
SQGetInt(v, 7, &FillWidth);
//首节宽度
int FirstWidth;
SQGetInt(v, 8, &FirstWidth);
int widthCount = round(WindowWidth / 2);
@@ -1184,15 +1334,13 @@ int sq_DrawButton(uint32_t v)
int rightFrame = Get_Img(npkbuf, 0, 2 + StartIdx);
Draw_Img(*(int*)0x1B45B94, 0, X, Y, leftFrame);
for (int i = 0; i < widthCount; i++) {
Draw_Img(*(int*)0x1B45B94, 0, X + 28 + 2 * i, Y, CenterFrame);
Draw_Img(*(int*)0x1B45B94, 0, X + FirstWidth + FillWidth * i, Y, CenterFrame);
}
Draw_Img(*(int*)0x1B45B94, 0, X + 28 + 2 * widthCount, Y, rightFrame);
Draw_Img(*(int*)0x1B45B94, 0, X + FirstWidth + FillWidth * widthCount, Y, rightFrame);
return 0;
}
@@ -1362,6 +1510,7 @@ std::string EncodeTABLE(HSQUIRRELVM v,std::string Jso) {
std::string str = OutPutText;
delete[]OutPutText;
Jso += "\"";
Jso += str;
Jso += "\"";
@@ -1452,6 +1601,20 @@ int EncondeJson(uint32_t v) {
return 1;
}
int sq_IsKeyDown(uint32_t v) {
int KeyCode;
SQGetInt(v, 2, &KeyCode);
if (KEY_DOWN(KeyCode)) {
SQPushBool(v, true);
}
else {
SQPushBool(v, false);
}
return 1;
}
//加载IMG帧
//preloadnpk(*(int*)0x1b4684c,img,0)
@@ -2140,14 +2303,54 @@ int squirrel::LReadAddress(uint32_t v)
}
return 0;
}
//读内存
int LReadAddressB(uint32_t v)
{
//内存地址 int型
int Address;
//获取参数个数
int ParameterNum = SQGetTop(v);
//1个参数时
if (ParameterNum == 2)
{
//获取地址
SQGetInt(v, 2, &Address);
int Value = *(BYTE*)Address;
SQPushInt(v, Value);
return 1;
}
if (ParameterNum == 3)
{
////地址
//int Address;
////偏移
//wchar_t* offset;
//SQGetInt(v, 2, &Address);
//SQGetString(v, 3, &offset);
//int Value = DNFTOOL::GetHook(Address, DNFTOOL::wchar_tTochar(offset));
//SQPushInt(v, Value);
std::cout << "未完成" << std::endl;
return 0;
}
else
{
SQPushBool(v, false);
return 1;
}
return 0;
}
//写内存
int LWriteAddressB(uint32_t v)
{
//内存地址 int型
int Address;
//获取参数个数
int ParameterNum = SQGetTop(v);
//1个参数时
if (ParameterNum == 3)
{
//获取地址
@@ -2155,8 +2358,29 @@ int LWriteAddressB(uint32_t v)
//获取修改的值
int WriteValue;
SQGetInt(v, 3, &WriteValue);
*(BYTE*)Address = (BYTE)WriteValue;
SQPushBool(v, true);
return 1;
}
if (ParameterNum == 4)
{
//地址
int Address;
//偏移
wchar_t* offset;
//修改值
int WriteValue;
SQGetInt(v, 2, &Address);
SQGetString(v, 3, &offset);
SQGetInt(v, 4, &WriteValue);
int SelectAddress = DNFTOOL::GetHook(Address, DNFTOOL::wchar_tTochar(offset), 1);
*(BYTE*)Address = (BYTE)WriteValue;
}
else
{
SQPushBool(v, false);
return 1;
}
return 0;
}
@@ -2171,32 +2395,15 @@ int squirrel::LWriteAddress(uint32_t v)
//1个参数时
if (ParameterNum == 3)
{
//获取值的类型
int ParameterType = SQ_GetType(v, 2);
switch (ParameterType)
{
case OT_INTEGER://int类型
{
//获取地址
SQGetInt(v, 2, &Address);
//获取修改的值
int WriteValue;
SQGetInt(v, 3, &WriteValue);
*(int*)Address = WriteValue;
SQPushBool(v, true);
return 1;
}
break;
case OT_STRING://String类型
{
}
break;
}
//获取地址
SQGetInt(v, 2, &Address);
//获取修改的值
int WriteValue;
SQGetInt(v, 3, &WriteValue);
*(int*)Address = WriteValue;
SQPushBool(v, true);
return 1;
}
if (ParameterNum == 4)
{
@@ -3370,9 +3577,11 @@ void squirrel::R_Register_Nut()
RegisterNutApi(L"L_sq_GetStringDrawArray", sq_GetStringDrawArray);
RegisterNutApi(L"L_sq_DecondeJson", DecondeJson);
RegisterNutApi(L"L_sq_EncondeJson", EncondeJson);
RegisterNutApi(L"L_sq_IsKeyDown", sq_IsKeyDown);
RegisterNutApi(L"L_sq_Open_ExWindow", sq_Open_ExWindow);//创建特殊窗口
RegisterNutApi(L"L_sq_Open_ExWindow2", sq_Open_ExWindow2);//创建特殊窗口
RegisterNutApi(L"L_sq_Select_MiniMap_Index", sq_Select_MiniMap_Index);//选择大地图区域
RegisterNutApi(L"L_Sq_DrawSkill", sq_DrawSkill);//绘制技能
RegisterNutApi(L"L_sq_UseSkill", sq_UseSkill);//绘制技能
@@ -3448,6 +3657,8 @@ void squirrel::R_Register_Nut()
#if defined ADDRESS_API_SWITCH
RegisterNutApi(L"L_sq_RA", squirrel::LReadAddress);//读内存
RegisterNutApi(L"L_sq_WA", squirrel::LWriteAddress);//写内存
RegisterNutApi(L"L_sq_RAB", LReadAddressB);//读内存
RegisterNutApi(L"L_sq_WAB", LWriteAddressB);//写内存
#endif
@@ -3498,6 +3709,12 @@ void squirrel::R_Register_Nut()
RegisterNutApi(L"L_RegisterCodeDraw_STL", squirrel::RegisterCodeDraw_STL);//注册文字绘制HOOK
#endif
//输入框
RegisterNutApi(L"L_sq_GetInputBoxStr",sq_GetInputBoxStr);
RegisterNutApi(L"L_sq_SetInputBoxStr", sq_SetInputBoxStr);
RegisterNutApi(L"L_sq_NewInputBox", sq_NewInputBox);
//龙盒
#if defined DRAGONBOX_SWITCH
//RegisterNutApi(L"L_Get_DragonModel", squirrel::Get_DragonModel);//获取龙盒模式
@@ -3612,6 +3829,11 @@ void printfunc(HSQUIRRELVM v, const SQChar* s, ...)
va_end(vl);
}
void squirrel::InitGameScript()
{
uint32_t v = GetSqVm();
@@ -3621,23 +3843,30 @@ void squirrel::InitGameScript()
#endif // COPY_MESSAGE
FILE* file = fopen("DNF.exe", "rb");
if (file)
{
int size = filelength(fileno(file));
if (size < 30770624) {
#ifdef SELL
//FILE* file = fopen("DNF.exe", "rb");
//if (file)
//{
// int size = filelength(fileno(file));
// if (size < 30770624) {
auto Registerfunc = reinterpret_cast<register_pack_handler_t>(0x7186D0);
Registerfunc(130, sock::Pack_Control, 0);
sq_setprintfunc((HSQUIRRELVM) v, (SQPRINTFUNCTION) printfunc);
}
fclose(file);
}
FILE* file2 = fopen("Xuefeng2_bConsole", "rb");
if (file2)
{
sq_setprintfunc((HSQUIRRELVM)v, (SQPRINTFUNCTION)printfunc);
}
hook::RegisterHook();
// }
// fclose(file);
//}
#endif
HHOOK hHook = SetWindowsHookEx(WH_GETMESSAGE, HookProc, NULL, GetCurrentThreadId());
// 设置钩子
//HHOOK g_hHook = SetWindowsHookEx(WH_CALLWNDPROC, ImeEndCompositionProc, NULL, GetCurrentThreadId());
#ifdef SELL