Code:
#include "Stdafx.h"
#include "3DCamera.h"
//1.04D OFFSETS
#define CAMERA_ZOOM 0x00D27BFC
#define CAMERA_ROTY 0x00D27B88
#define CAMERA_ROTZ 0x087933D8
#define CAMERA_POSZ 0x00D255AC
#define CAMERA_CLIPX 0x00D2C848
#define CAMERA_CLIPY 0x00D2C894
#define CAMERA_GLCLIP 0x00D2570C
#define Main_PrintGlobal 00597630H;
int *MAIN_STATE_ADDR = (int*)0x00E609E8;
int *MAP_CHECKER_ADDR = (int*)0x00E61E18;
#define CAM_DEFAULT (*Camera_PosZ != 150.0f || *Camera_RotZ != -45.0f || *Camera_RotY != -48.5f || *Camera_Zoom != 35.0f)
enum MAINSTATE {
SELECT_SERVER = 2,
SELECT_CHARACTER = 4,
SELECT_GAME = 5,
};
bool CAM_Init = true;
bool CAM_Move = false;
bool VK_IsPressed = false;
void Message(int ColorId, char* Message)
{
_asm
{
Mov Edi,Main_PrintGlobal
Push ColorId
Push Message
Call Edi
Add Esp,0x8
}
}
//int Is3D = 1; //GetPrivateProfileIntA("3D", "IsEnabled", true, "./Custom/Settings.ini");
int CAM_IsActive = 1;
//int CAM_IsActive = GetPrivateProfileIntA("3D", "IsActive", 1, ".\\Custom\\Settings.ini");
int Sensivity = GetPrivateProfileIntA("3D", "Sensivity", 8, ".\\Custom\\Settings.ini");
BOOL KeyboardSetHook(BOOL set_or_remove) {
if(set_or_remove == TRUE) {
if(KeyboardHook == NULL) {
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, hInstance, GetCurrentThreadId());
if(!KeyboardHook) { return FALSE; }
}
}
else {
KeyboardHook = NULL;
return UnhookWindowsHookEx(KeyboardHook);
}
return TRUE;
}
BOOL MouseSetHook(BOOL set_or_remove) {
if(set_or_remove == TRUE) {
if(MouseHook == NULL) {
MouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, hInstance, GetCurrentThreadId());
if(!MouseHook) { return FALSE; }
}
}
else {
MouseHook = NULL;
return UnhookWindowsHookEx(MouseHook);
}
return TRUE;
}
float GetMemBuffer(DWORD *dwpAddress) {
float pBuffer;
if (ReadProcessMemory(GetCurrentProcess(), dwpAddress, (float*)&pBuffer, 4, 0) == TRUE)
return pBuffer;
else return 0;
}
void UnProtect(DWORD *dwpAddress, float pBuffer) {
DWORD dwOldProtect = 0;
HANDLE hWnd = GetCurrentProcess();
VirtualProtectEx(hWnd, dwpAddress, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect);
WriteProcessMemory(hWnd, dwpAddress, (void*)&pBuffer, 4, 0);
VirtualProtectEx(hWnd, dwpAddress, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect);
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (((lParam >> 31) & 1) && (nCode == HC_ACTION)) {
if (wParam == VK_F10) {
if (VK_IsPressed == false && CAM_IsActive == true) {
VK_IsPressed = true; CAM_IsActive = false;
Message(1,"Camera OFF");
}
else {
VK_IsPressed = false; CAM_IsActive = true;
Message(1,"Camera ON");
}
}
if (wParam == VK_F9) {
_beginthread(CAMDefault, 0, NULL);
Message(1,"Camera Reseted");
}
}
return CallNextHookEx(KeyboardHook, nCode, wParam, lParam);
}
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam){
MOUSEHOOKSTRUCTEX* mhs = (MOUSEHOOKSTRUCTEX*)lParam;
HWND MuWnd = FindWindow("MU", NULL);
if (*MAIN_STATE_ADDR == SELECT_CHARACTER || *MAP_CHECKER_ADDR == 0x1E || *MAP_CHECKER_ADDR == 0x3E) {
InitCamera = false;
UnProtect((DWORD*)Camera_ClipX, Camera.ClipX);
UnProtect((DWORD*)Camera_ClipY, Camera.ClipY);
UnProtect((DWORD*)Camera_GlClip, Camera.GlClip);
UnProtect((DWORD*)Camera_PosZ, 150.0f);
UnProtect((DWORD*)Camera_RotY, -48.5f);
UnProtect((DWORD*)Camera_RotZ, -45.0f);
UnProtect((DWORD*)Camera_Zoom, 35.0f);
}
if (CAM_IsActive) {
if (GetForegroundWindow() == MuWnd) {
if (InitCamera) {
Camera.ClipX = *Camera_ClipX; Camera.ClipY = *Camera_ClipY; Camera.GlClip = *Camera_GlClip;
Camera.PosZ = *Camera_PosZ; Camera.RotY = *Camera_RotY; Camera.RotZ = *Camera_RotZ; Camera.Zoom = *Camera_Zoom;
InitCamera = false;
}
else if (wParam == WM_MOUSEWHEEL) {
int direction = mhs->mouseData;
if (direction > 0) {
if(*Camera_Zoom < 60) {
UnProtect((DWORD*)Camera_Zoom, (GetMemBuffer((DWORD*)CAMERA_ZOOM))+2);
}
}
else if (direction < 0) {
if (*Camera_Zoom > 12) {
UnProtect((DWORD*)Camera_Zoom, (GetMemBuffer((DWORD*)CAMERA_ZOOM))-2);
}
}
float Aux = abs(GetMemBuffer((DWORD*)CAMERA_POSZ) - 100) * 3;
UnProtect((DWORD*)Camera_ClipX, 1190.0f + Aux + 3000.0f);
UnProtect((DWORD*)Camera_ClipY, 2400.0f + Aux + 3000.0f);
UnProtect((DWORD*)Camera_GlClip, 3000.0f + Aux + 1500.0f);
}
else if (wParam == WM_MBUTTONDOWN) {
MouseX = mhs->pt.x;
MouseY = mhs->pt.y;
MoveCamera = true;
}
else if (wParam == WM_MBUTTONUP) {
MoveCamera = false;
}
else if (wParam == WM_MOUSEMOVE) {
if (MoveCamera) {
if (MouseX < mhs->pt.x) {
UnProtect((DWORD*)Camera_RotZ, (GetMemBuffer((DWORD*)CAMERA_ROTZ))+Sensivity);
if (*Camera_RotZ > 315) {
UnProtect((DWORD*)Camera_RotZ, -45.0f);
}
}
else if (MouseX > mhs->pt.x) {
UnProtect((DWORD*)Camera_RotZ, (GetMemBuffer((DWORD*)CAMERA_ROTZ))-Sensivity);
if (*Camera_RotZ < -405) {
UnProtect((DWORD*)Camera_RotZ, -45.0f);
}
}
if (MouseY < mhs->pt.y) {
if (*Camera_RotY < -45) {
UnProtect((DWORD*)Camera_PosZ, (GetMemBuffer((DWORD*)CAMERA_POSZ))-44);;
UnProtect((DWORD*)Camera_RotY, (GetMemBuffer((DWORD*)CAMERA_ROTY))+2.42f);
}
}
else if (MouseY > mhs->pt.y) {
if (*Camera_RotY > -90) {
UnProtect((DWORD*)Camera_PosZ, (GetMemBuffer((DWORD*)CAMERA_POSZ))+44);
UnProtect((DWORD*)Camera_RotY, (GetMemBuffer((DWORD*)CAMERA_ROTY))-2.42f);
}
}
MouseX = mhs->pt.x;
MouseY = mhs->pt.y;
float Aux = abs(GetMemBuffer((DWORD*)CAMERA_POSZ) - 150) * 3;
UnProtect((DWORD*)Camera_ClipX, 1190.0f + Aux + 3000.0f);
UnProtect((DWORD*)Camera_ClipY, 2400.0f + Aux + 3000.0f);
UnProtect((DWORD*)Camera_GlClip, 3000.0f + Aux + 1500.0f);
}
}
}
}
return CallNextHookEx(MouseHook, code, wParam, lParam);
}
void CAMDefault(void *lParam)
{
while (CAM_DEFAULT)
{
(*Camera_PosZ > 150.0f) ? UnProtect((DWORD*)Camera_PosZ, (GetMemBuffer((DWORD*)CAMERA_POSZ))-5.0f) : UnProtect((DWORD*)Camera_PosZ, (GetMemBuffer((DWORD*)CAMERA_POSZ))+5.0f);
if (*Camera_PosZ > 146.0f && *Camera_PosZ < 152.0f)
UnProtect((DWORD*)Camera_PosZ, 150.0f);
(*Camera_RotZ > -45.0f) ? UnProtect((DWORD*)Camera_RotZ, (GetMemBuffer((DWORD*)CAMERA_ROTZ))-1.0f) : UnProtect((DWORD*)Camera_RotZ, (GetMemBuffer((DWORD*)CAMERA_ROTZ))+1.0f);
if (*Camera_RotZ > -47.0f && *Camera_RotZ < -43.0f)
UnProtect((DWORD*)Camera_RotZ, -45.0f);
(*Camera_RotY > -48.5f) ? UnProtect((DWORD*)Camera_RotY, (GetMemBuffer((DWORD*)CAMERA_ROTY))-0.5f) : UnProtect((DWORD*)Camera_RotY, (GetMemBuffer((DWORD*)CAMERA_ROTY))+0.5f);
if (*Camera_RotY > -50.5f && *Camera_RotY < -46.5f)
UnProtect((DWORD*)Camera_RotY, -48.5f);
(*Camera_Zoom > 35.0f) ? UnProtect((DWORD*)Camera_Zoom, (GetMemBuffer((DWORD*)CAMERA_ZOOM))-1.0f) : UnProtect((DWORD*)Camera_Zoom, (GetMemBuffer((DWORD*)CAMERA_ZOOM))+1.0f);
if (*Camera_Zoom > 33.0f && *Camera_Zoom < 37.0f)
UnProtect((DWORD*)Camera_Zoom, 35.0f);
Sleep(2);
}
_endthread();
};