3DCamera error (with sourcs) dont show properly the ClipX

Results 1 to 6 of 6
  1. #1
    Account Upgraded | Title Enabled! thevjfla is offline
    MemberRank
    Apr 2012 Join Date
    203Posts

    3DCamera error (with sourcs) dont show properly the ClipX

    My error it's this:

    i can't make it work correcty with the zoom out...



    I think it's the float <> double convertion of the ClipX, but, i get compiler warning if use double.

    anyone can give me a little help for make it better? =)

    Source Code:

    3DCamera.cpp
    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();
    };

    3DCamera.h
    Code:
    #pragma once 
    #include "StdAfx.h"
    
    #ifndef __LALA_H_
    #define __LALA_H_
    
    static HINSTANCE hInstance;
    
    #pragma data_seg(".SHAREDDATA")
    static HHOOK MouseHook = NULL; 
    static HHOOK KeyboardHook = NULL;
    #pragma data_seg()
    
    #pragma comment(linker, "/SECTION:.SHAREDDATA,RWS")
    
    struct CameraStruct 
    {
    		float Zoom;
    		float RotY;
    		float RotZ;
    		float PosZ;
    		float ClipX;
    		float ClipY;
    		float GlClip;
    } Camera;
    
    
    float *Camera_Zoom    = (float*) 0x00D27BFC;
    float *Camera_RotY    = (float*) 0x00D27B88;
    float *Camera_RotZ    = (float*) 0x087933D8;
    float *Camera_PosZ    = (float*) 0x00D255AC;
    float *Camera_ClipX   = (float*) 0x00D2C848;
    float *Camera_ClipY   = (float*) 0x00D2C894;
    float *Camera_GlClip  = (float*) 0x00D2570C;
    
    int MouseX; 
    int MouseY; 
    
    bool InitCamera = true; 
    bool MoveCamera = false;
    
    BOOL KeyboardSetHook(BOOL set_or_remove);
    BOOL MouseSetHook(BOOL set_or_remove);
    LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
    LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam);
    
    float GetMemBuffer(DWORD *dwpAddress);
    void UnProtect(DWORD *dwpAddress, float Buffer);
    
    void CAMDefault(void *lParam);
    
    #endif // __LALA_H_
    The BOOL of StdAfx.h and the dll entry.
    Code:
    BOOL MouseSetHook(BOOL);
    BOOL KeyboardSetHook(BOOL);


  2. #2
    Account Upgraded | Title Enabled! thevjfla is offline
    MemberRank
    Apr 2012 Join Date
    203Posts

    Re: 3DCamera error (with sourcs) dont show properly the ClipX

    Anybody???
    Last edited by thevjfla; 30-05-15 at 12:44 PM.

  3. #3
    Account Upgraded | Title Enabled! thevjfla is offline
    MemberRank
    Apr 2012 Join Date
    203Posts

    Re: 3DCamera error (with sourcs) dont show properly the ClipX

    Uppppp?

  4. #4
    Apprentice Leandro Taboada is offline
    MemberRank
    Nov 2013 Join Date
    17Posts

    Re: 3DCamera error (with sourcs) dont show properly the ClipX

    Offset:
    CAMERA_GLCLIP

    Ands:
    .0f (f)

  5. #5
    Account Upgraded | Title Enabled! thevjfla is offline
    MemberRank
    Apr 2012 Join Date
    203Posts

    Re: 3DCamera error (with sourcs) dont show properly the ClipX

    Quote Originally Posted by Leandro Taboada View Post
    Offset:
    CAMERA_GLCLIP

    Ands:
    .0f (f)
    ¿?
    I dont understand, whats bad with my code?
    the gl clip offset?

  6. #6
    Account Upgraded | Title Enabled! thevjfla is offline
    MemberRank
    Apr 2012 Join Date
    203Posts

    Re: 3DCamera error (with sourcs) dont show properly the ClipX

    upppppppppp?



Advertisement