Hey all, I'm new to the forum here. Nice to see all the wonderful people helping others with programming! Anyways.. :p
About:
I am writing a program for a game, Halo Trial, which I play quite frequently. I host servers everyday for my 'clan' to play on. However, we get lots of 'noobs' who ruin the server by betraying other members and such. We hate these kinds of people. Recently, I got into editing hex values inside the game. I found values of players that I could change so they would freeze and couldn't move. I did this to these 'noob' players who annoyed me. This was just a temporary fix. Every time I would have to freeze a player, I would have to go inside of memory, search for that player, and edit his values...by that time, he was causing mass chaos.
My Program:
I can make simple programs to 'Poke' an address to freeze the player. But, I have to figure out which player I have to freeze, by going in memory and figuring out which player goes with which offset. This is a hassle. My new program, which I am working on, needs to read the player names into a listbox, so I can choose which player to edit. This will save time and hassle for kicking a player off my server.
The problem:
I can't get the strings of player names to read into my listbox. Here is the code and I will explain more at bottom:
Why is it not reading strings into my listbox? Anyone know?Code:#include <windows.h>
#include "resource.h"
#pragma comment(linker,"/FILEALIGN:512 /MERGE:.rdata=.text /MERGE:.data=.text /SECTION:.text,EWR /IGNORE:4078")
char *gameWindow = "Halo"; // Edit the game caption here
DWORD pid; HWND hwndWindow; DWORD bytes; HANDLE hand = NULL;
/** Start of Declarations here **/
DWORD Player1 = 0x4BD7AFD0, NextPlayer = 0x4BD7B1D0; // Player 1's name address at first byte then player2's name at first byte
BYTE HoldName[22]; // Max player name legth is 22 bytes
// Get it by subing Player 1's name address from player 2's.
int OffsetBetweenPlayerNames = 0x200; // 200 bytes between players or should it be C8h?
char Out[26];
int MaxNumberOfPlayers = 16;
int i = 0;
void CreatePlayerList(HWND hwnd) // notice the new param
{
// Clear the list.
SendDlgItemMessage(hwnd, IDC_PLAYERLIST, LB_RESETCONTENT, 0, 0);
for(i = 0; i < MaxNumberOfPlayers; i++)
{
ReadProcessMemory(hand, (VOID*)NextPlayer, HoldName, 22, NULL);
wsprintf(Out, "%s", HoldName); // Ex text: 1. Silentkarma
// Set Listbox Text with name and offset
SendDlgItemMessage(hwnd, IDC_PLAYERLIST, LB_ADDSTRING, (WPARAM) i, (LPARAM) (LPCTSTR) Out);
NextPlayer = Player1 + (i * OffsetBetweenPlayerNames);
}
}
// Below is the about text that is shown when "About" button is clicked
char *about =
"HTMP Trainer v2\n\n"
"Limbo :: Nor Heaven, Nor Hell.\n"
"You live eternally in nowhere.\n\n"
"SilentK/Scoopa";
/** End of Declarations here **/
void aboutButton(HWND hwnd)
{
MessageBox(hwnd,about,"About",MB_ICONINFORMATION);
}
void Initialize(HWND hwnd,WPARAM wParam, LPARAM lParam) {
hwndWindow = FindWindow(NULL,gameWindow);
if(hwndWindow) {
GetWindowThreadProcessId(hwndWindow, &pid);
hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
SetTimer(hwnd, 1, 100, NULL); //Timer speed is 100ms, you can change it here
} else {
MessageBox(NULL, "Cannot find Halo Trial! It MUST be open for this trainer to work!", "Error", MB_OK + MB_ICONWARNING);
}
}
void timerCall(HWND hwnd) // Added Param for function
{
/** All your Pokes should go in here **/
if(GetAsyncKeyState(VK_F6))
CreatePlayerList(hwnd);
/** End **/
}
BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
Initialize(hwnd,wParam,lParam);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_ABOUT:
aboutButton(hwnd);
return TRUE;
case IDC_EXIT:
EndDialog (hwnd, 0);
return TRUE;
}
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
case WM_CLOSE:
PostQuitMessage(0);
return TRUE;
case WM_TIMER:
timerCall(hwnd); /* Changed to match new func */
return TRUE;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAINDLG), NULL,DialogProc);
return 0;
}
[Using VC++ - IDC_PLAYERLIST is the listbox ID]