PDA

View Full Version : Whats up With This Timer For Scope?



jamo27
01-11-2008, 03:10 PM
Hey.. Im working on a scope hack. Im pretty new to c++ .. and iv done everything ok. and now im trying to put in hotkeys.. and for the hotkeys, i need timers.. so i have tried to put in timers at the minute. and i get errors? i will put in hotkeys after


// Ball2Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Ball2.h"
#include "Ball2Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
DWORD proc_id;
HANDLE hProcess;

void memory()
{
HWND hWnd = FindWindow(0, "WarRock");
GetWindowThreadProcessId(hWnd, &proc_id);
hProcess = OpenProcess(PROCESS_ALL_ACCESS|PROCESS_VM_OPERATIO N|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_I NFORMATION, FALSE, proc_id);
}

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBall2Dlg dialog

CBall2Dlg::CBall2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CBall2Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBall2Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CBall2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBall2Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBall2Dlg, CDialog)
//{{AFX_MSG_MAP(CBall2Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnScopeON)
ON_BN_CLICKED(IDC_BUTTON2, OnScopeOFF)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON3, OnTimerOn)
ON_BN_CLICKED(IDC_BUTTON4, OnTimerOff)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBall2Dlg message handlers

BOOL CBall2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CBall2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CBall2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CBall2Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void Writelong(long addy, long value)
{
memory();
WriteProcessMemory(hProcess, (LPVOID*)(DWORD) addy, &value, sizeof(value), NULL);

}
void WritePointerFloat(long addy, short offset, float value)
{
long maddy;
long saddy;
memory();
ReadProcessMemory(hProcess, (LPVOID*)(DWORD) addy, &maddy, sizeof(maddy), NULL);
saddy = maddy + offset;
WriteProcessMemory(hProcess, (LPVOID*)(DWORD) saddy, &value, sizeof(value), NULL);
}



void CBall2Dlg::OnScopeON()
{
Writelong(0xAC4A66, 1);

}

void CBall2Dlg::OnScopeOFF()
{
Writelong(0xAC4A66, 0);
}


void CBall2Dlg::OnTimer(UINT nIDEvent)
{

CDialog::OnTimer(nIDEvent);
}

void CBall2Dlg::OnTimerOn()
{
SetTimer(FIRSTTIMER, 1, NULL);
}

void CBall2Dlg::OnTimerOff()
{
KillTimer(FIRSTTIMER);
}


And the Errors Are:


Deleting intermediate files and output files for project 'Ball2 - Win32 Debug'.
--------------------Configuration: Ball2 - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
Ball2.cpp
Ball2Dlg.cpp
C:\Documents and Settings\Jamie\Desktop\Ball2\Ball2Dlg.cpp(224) : error C2065: 'FIRSTTIMER' : undeclared identifier
Generating Code...
Error executing cl.exe.

Ball2.exe - 1 error(s), 0 warning(s)

wr194t
01-11-2008, 03:14 PM
Scope doesn't use a timer so delete it.
Wrong address. New Scope address: AEFEE6

DutchHelFire
01-11-2008, 04:06 PM
out of my mind and it has some things u need to correct so u can learn from it dont just copy and paste


void CBall2Dlg::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case FIRSTTIMER:
if (GetKeyState(VK_RBUTTON)&1<< 0xF)
{
writelong(0xAEFEE6,1)
}
else
{
writelong(0xAEFEE6,0);
}
break;
}
CDialog::OnTimer(nIDEvent);
}


to set the hotkey on(in a button):
SetTimer(FIRSTTIMER,1,NULL);

off
KillTimer(FIRSTTIMER)

This in resource.h:
#define FIRSTIMER 1280

jamo27
01-11-2008, 06:46 PM
Oh Right. Thanx For The Address, And I Didnt Quite Get The Post Above Me.. But I Am Tryin To Learn As I Go Along ;]

Also.. I was told that you need a timer for hotkeys? .. And Now Im Just Confused? :eek:

DutchHelFire
01-12-2008, 04:56 AM
lol if u dont want to learn here are the things that i did wrong so u learn:

void CBall2Dlg::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case yourtimerhere:
if (GetKeyState(VK_RBUTTON)&1<< 0xF)
{
writelong(0xAEFEE6,1);
}
else
{
writelong(0xAEFEE6,0);
}
break;
}
CDialog::OnTimer(nIDEvent);
}

~----------------------------~

SetTimer(yourtimerhere,1,NULL); //put this in Onintdialog to call the timer on when the trainer is open.



This in resource.h:
#define yourtimerhere 1280