#include "pch.h"
#include <Windows.h>
#include "resource.h"
#include <cstdint>
#include <string>
WNDPROC g_pfnOldWndProc = nullptr;
DWORD
getPlaneX()
{
DWORD
* pX = (
DWORD
*)0x00406D6C;
return
*pX;
}
DWORD
getPlaneY()
{
DWORD
* pY = (
DWORD
*)0x00406D70;
return
*pY;
}
void
setPlanePosX(
DWORD
pos)
{
DWORD
* pX = (
DWORD
*)0x00406D6C;
*pX = pos;
}
void
setPlanePosY(
DWORD
pos)
{
DWORD
* pY = (
DWORD
*)0x00406D70;
*pY = pos;
}
DWORD
getBulletNumbers()
{
DWORD
* pNum = (
DWORD
*)0x00406DA8;
return
*pNum;
}
DWORD
translatePos(
DWORD
dwPos)
{
DWORD
_ret = dwPos;
_ret >>= 6;
if
(_ret < 4)
{
return
0;
}
_ret -= 4;
return
_ret;
}
BOOL
autoHide()
{
DWORD
dwBltCount = getBulletNumbers();
for
(unsigned
int
x = 5; x < 200; x++)
{
for
(unsigned
int
y = 5; y < 200; y++)
{
dwBltCount = getBulletNumbers();
BOOL
isCrack = FALSE;
for
(unsigned
int
i = 0; i < dwBltCount; i++)
{
uint8_t blt[15];
memcpy
(blt, (
void
*)((unsigned
int
)0x00406E10 + i * 15), 15);
void
* tmp = (
void
*)blt;
DWORD
dwOrgX;
DWORD
dwOrgY;
memcpy
(&dwOrgX, tmp, 4);
memcpy
(&dwOrgY, (
void
*)((
int
)tmp + 4), 4);
unsigned
int
dwPtX = translatePos(dwOrgX);
unsigned
int
dwPtY = translatePos(dwOrgY);
if
(dwPtX >= x - 4 && dwPtX <= x + 16 && dwPtY >= y - 4 && dwPtY <= y + 16)
{
isCrack = TRUE;
if
(x > 200)
{
x = 0;
}
x + 10;
break
;
}
char
p[100];
sprintf_s(p,
"[DLL] x: %d, y: %d"
, x, y);
OutputDebugString(p);
}
if
(!isCrack)
{
setPlanePosX(x);
setPlanePosY(y);
}
}
}
return
TRUE;
}
DWORD
WINAPI ThreadProc(
LPVOID
lpParameter)
{
while
(
true
)
{
autoHide();
Sleep(1);
return
0;
}
}
LRESULT
CALLBACK NewWindowProc(
HWND
hwnd,
UINT
uMsg,
WPARAM
wParam,
LPARAM
lParam
)
{
uint8_t * pInvi = (uint8_t *)0x00403616;
HANDLE
tid = nullptr;
if
(uMsg == WM_COMMAND)
{
switch
(LOWORD(wParam))
{
case
MN_INVI:
{
*pInvi = 0xeb;
MessageBox(NULL,
"开启无敌"
,
"tips"
, MB_OK);
break
;
}
case
MN_CLS_INVI:
{
*pInvi = 0x74;
MessageBox(NULL,
"关闭无敌"
,
"tips"
, MB_OK);
break
;
}
case
MN_AUTO_HD:
{
if
(tid == nullptr)
{
CreateThread(0, 0, ThreadProc, 0, 0, 0);
MessageBox(NULL,
"自动躲子弹"
,
"tips"
, MB_OK);
}
break
;
}
case
MN_CLS_AUTO_HD:
{
if
(tid != nullptr)
{
TerminateThread(tid, 0);
tid = nullptr;
MessageBox(NULL,
"关闭自动躲子弹"
,
"tips"
, MB_OK);
}
break
;
}
default
:
break
;
}
}
return
CallWindowProc(g_pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
BOOL
install()
{
if
(g_pfnOldWndProc == nullptr)
{
HWND
hWnd = FindWindow(
"wcTKKN"
,
"摿孭"
);
if
(hWnd == nullptr)
{
OutputDebugString(
"FindWindow Failed"
);
return
false
;
}
HMENU
hSubMn = LoadMenu(GetModuleHandle(
"CheatPlane"
), MAKEINTRESOURCE(IDR_MENU1));
SetMenu(hWnd, hSubMn);
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
g_pfnOldWndProc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (
LONG
)NewWindowProc);
}
return
true
;
}
BOOL
APIENTRY DllMain(
HMODULE
hModule,
DWORD
ul_reason_for_call,
LPVOID
lpReserved
)
{
switch
(ul_reason_for_call)
{
case
DLL_PROCESS_ATTACH:
install();
break
;
case
DLL_THREAD_ATTACH:
install();
break
;
case
DLL_THREAD_DETACH:
case
DLL_PROCESS_DETACH:
break
;
}
return
TRUE;
}