PDA

View Full Version : Making Unbanner for RTCW - help



Szatan
12th July 2003, 11:33
First off, Im a NOOB at C++ (kinda) I want to make a program that the follows a certain process to unban myself from RTCW servers, ive been playign around with it all day long, reading helpfile etc.. looking at examples and I think I got a fair understanding but I need some help on HOW TO: do the following things - I know its a bit much, but im hoping theres a nice dude out there willing to help out -

I need some example code of the following -

How do I make a button run a .exe file?

Make a backup of a certain file?

randomly change the first 16 letters/numbers of a file

delete the modified file and backup the original


I would greatly appreciate any help and will credit it on the release.

Thanks for your time.

:classic:

Das...Oppollum
12th July 2003, 12:41
How do I make a button run a .exe file?

If you mean key, use getasynckeystate and then execute with shellexecute

----------
if (GetAsyncKeyState('X') < 0)
{
bKeypress = true;
ShellExecute(NULL, "open", "File.exe", NULL, NULL, SW_HIDE);

}
else if(!GetAsyncKeyState('X'))
bKeypress = false;
----------




Make a backup of a certain file?

to keep it easy just use system("copy c:\\file.exe c:\\file.bak")



randomly change the first 16 letters/numbers of a file


------------
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>


char* ranomize(char* string)
{

int i, r, len, tmp;
char rstring[16];
char *ret = (char*) malloc(16);

strncpy( rstring, string, 16);

srand( time(NULL) );

len = strlen( rstring );

for ( i = 0; i < len; i++ )
{
int rnd = rand();

r = (int) ( len * ( (float)rand() / (float)RAND_MAX ) );

tmp = rstring[r];
rstring[r] = rstring[i];
rstring[i] = tmp;
}

strncpy( ret, rstring, 16);

return ret;
}
------------



delete the modified file and backup the original

again just use system() and use dos commands (del & copy)

Szatan
13th July 2003, 01:32
hey thanks alot man!!! much appreciate it !!! that really made my day :cool: I will credit you if you wish...

Szatan
13th July 2003, 06:28
hmmm, so am i doing somethign wrong with this?

void CRTCWKEYChangerDlg::OnButton5()
{
if (OnButton5('X') < 0)
{
bKeypress = true;
ShellExecute(NULL, "open", "C:\\Program Files\\Return to Castle Wolfenstein\\WolfMP.exe", NULL, NULL, SW_HIDE);

}
else if(!OnButton5('X'))
bKeypress = false;

:confused:

also, for the random 16 thingy, where do i type in the location of the file?

thanks...

Das...Oppollum
13th July 2003, 09:57
Well i dont know very much about Windows and Resources, only used it with callback functions once, so cant realy help u on this..
but i think this is wrong in any case "if (OnButton5('X') < 0) "
so just try this,



void CRTCWKEYChangerDlg::OnButton5()
{
ShellExecute(NULL, "open", "C:\\Program Files\\Return to Castle Wolfenstein\\WolfMP.exe", NULL, NULL, SW_HIDE);
}



heres a simple read file function, but only works if you know the file size



#include <iostream>
#include <fstream>

using namespace std;

int ReadFile(char *pFilename, char *&buffer)
{
ifstream infile (pFilename);

char buf[256];
int len = 0;

while (infile.good())
{
buf[len] = (char) infile.get();
len++;
}

buf[len] = NULL;
strncpy(buffer,buf,len+1);

infile.close();


return len;
}


int main ()
{

char *buf = (char*)malloc(256);

ReadFile("c:\\test.txt", buf);

cout << buf << endl;


return 0;
}