Console to Windows Form Application

closed account (LAfSLyTq)
is there any possible way i could get my console application to change stuff on a windows form i have added?
closed account (LAfSLyTq)
basicly what im asking is, how do i make my windows form application do what my console does?
What does your console program do?
closed account (LAfSLyTq)
it changes the value of ammo in HALO

im trying to convert it to a windows from app but i cant seem to get the hack to work...

also, this doesnt work either

Form1::label1::text = sGameStatus;

for some reason
I found this example of getting user input. I wish I could help explain it, but I'm not experienced in windows forms. It looks kind of complicated to me for what it does. So take my advice with a grain of salt. Hopefully this is of some help. Good luck.

http://www.daniweb.com/software-development/cpp/threads/258636/c-win32-input-help

It seams like this is the part of that example where you might convert the input from TCHAR to integer and then launch your change ammo function.

1
2
3
4
5
6
7
8
9
10
11
12
13
long fnWndProc_OnCommand(lpWndEventArgs Wea)
{
 switch(LOWORD(Wea->wParam))
 {
   case IDC_BUTTON:
   {
     TCHAR szBuffer[256];
    
     GetWindowText(GetDlgItem(Wea->hWnd,IDC_EDIT),szBuffer,256);
     //covert szBuffer to integer
     ...
   }
 }


Someone correct me if I'm wrong.
Last edited on
@Invader2010
You should probably set it like this->label1->Text = sGameStatus; somewhere appropriate in Form1.h
Last edited on
That example is in C/C++, which is NOT the programming language you are currently using.
closed account (LAfSLyTq)
@naraku ive already tried that, gives me thiese errors

Error 2 error C2227: left of '->label1' must point to class/struct/union/generic type C:\Users\Jeremy\Documents\Visual Studio 2010\Projects\Windows form1\Windows form1\Windows form1.cpp 92 1 Windows form1

Error 3 error C2227: left of '->Text' must point to class/struct/union/generic type C:\Users\Jeremy\Documents\Visual Studio 2010\Projects\Windows form1\Windows form1\Windows form1.cpp 92 1 Windows form1

Error 1 error C2355: 'this' : can only be referenced inside non-static member functions C:\Users\Jeremy\Documents\Visual Studio 2010\Projects\Windows form1\Windows form1\Windows form1.cpp 92 1 Windows form1
Last edited on
Are you adding your code to Form1.h?
Last edited on
closed account (LAfSLyTq)
yep, gives me too many errors.
Can you post the code?
closed account (LAfSLyTq)
windows form1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Windows form1.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"
#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>
#include "resource.h"

DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress);
void WriteToMemory(HANDLE hProcHandle);

std::string GameName = "assault cube";
LPSTR LGameWindow = "assault cube";
std::string GameStatus;

int MaxAmmo = 8; //The ammo you will change to

bool IsGameAvail;
bool UpdateOnNextRun;

bool AmmoStatus;
LONG AR343 = 0x40100ED8;//ar ammo 343 guilty
LONG AR3431 = 0x4007D888;//ar ammo 343 guilty p1
LONG M343 = 0x4010138C;//M ammo 343 guilty
LONG M3431 = 0x4007DD3C;//M ammo 343 guilty p1
LONG SG343 = 0x400FE614;//sg ammo 343 guilty
LONG SG3431 = 0x4007C324;//SG AMMO 343 P1

bool GrenadeStatus;
LONG G343 = 0x40100ED8;//Grenades 343 p1

using namespace Windowsform1;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
		// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
		HWND hGameWindow = NULL;

	int timeSinceLastUpdate = clock();
	int GameAvailTMR = clock();
	int onePressTMR = clock();
	DWORD dwProcID = NULL;
	HANDLE hProcHandle = NULL;
	UpdateOnNextRun = true;
	std::string sAmmoStatus = "OFF";
	std::string sGrenadeStatus = "OFF";

		while(!GetAsyncKeyState(VK_F3))
	{
		if(clock() - GameAvailTMR > 100)
		{
		GameAvailTMR = clock();
		IsGameAvail = false;

		hGameWindow = FindWindow(NULL, LGameWindow);
		if(hGameWindow)
		{
			GetWindowThreadProcessId(hGameWindow, &dwProcID);
			if(dwProcID != 0)
			{
			hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
			if(hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
			{
				GameStatus = "Failed to open process for valid handle";
			}
			else
			{
				GameStatus = "HALO: Combat Evolved Ready to Hack";
				IsGameAvail = true;
			}
			}
			else
			{
				GameStatus = "Failed to get process ID";
			}
		}
			else
			{
				GameStatus = "HALO NOT OPEN";
			}

			if(UpdateOnNextRun || clock() - timeSinceLastUpdate > 5000)
			{
				this->label1->Text = GameStatus;
				UpdateOnNextRun = false;
				timeSinceLastUpdate = clock();
			}
			if(IsGameAvail)
			{
				WriteToMemory(hProcHandle);
			}
		}
		if(clock() - onePressTMR > 400)
		{
			if(IsGameAvail)
			{
				//ammo
				if(GetAsyncKeyState(VK_F1))
				{
					onePressTMR = clock();
					AmmoStatus = !AmmoStatus;
					UpdateOnNextRun = true;
					if(AmmoStatus)sAmmoStatus = "ON";
					else sAmmoStatus = "OFF";
				}
				else if(GetAsyncKeyState(VK_F2))
				{
					onePressTMR = clock();
					GrenadeStatus = !GrenadeStatus;
					UpdateOnNextRun = true;
					if(GrenadeStatus)sGrenadeStatus = "ON";
					else sGrenadeStatus = "OFF";
				}
			}
	}
}
	return ERROR_SUCCESS;
}

DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress)
{
	DWORD pointer = BaseAddress;
	DWORD pTemp;

	DWORD pointerAddr;
	for(int c = 0; c < PointerLevel; c++)
	{
		if(c == 0)
		{
		ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
		}

		pointerAddr = pTemp + Offsets[c];
		ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, sizeof(pTemp), NULL);
	}
	return pointerAddr;
}

void WriteToMemory(HANDLE hProcHandle)
{
	if(AmmoStatus)
	{

	}
		if(GrenadeStatus)
	{

	}
}
Last edited on
Everything after Application::Run(gcnew Form1()); wont run until after the form is closed. Your also mixing Win32 and CLI, which probably isn't a good idea but I'm honestly not sure. As I said before you should add your code to Form1.h
Edit: Specifically, you probably should add your code to a button click or form load event handler.
Last edited on
naraku9333 wrote:
Your also mixing Win32 and CLI, which probably isn't a good idea
I completely agree with that, unless you really know what you're doing. If not, maybe you might want to research more about these two API?

http://msdn.microsoft.com/en-us/library/ee663266%28v=vs.85%29
http://msdn.microsoft.com/en-us/library/ms229601%28v=vs.90%29

Good luck!!
Last edited on
My honest advice: Ask in the appropriate forums. You may be attached to this one and such, but most of us don't know C++/CLI, which is what you are currently using. Just ask in the MSDN Forums until the day comes when this forum has enough CLI experts. Maybe you can be one of those experts in time! In the meantime, you'll just get half-baked guesses here.
Last edited on
Topic archived. No new replies allowed.