Yo, aside from this looking good, you're into game design sir?
Anyways, when I was building my game engine I needed some way to open and read configuration files, and later when I was trying to develop the scripting system this proved quite useful. I'm also building a method hooker to hook multiple methods. I will be posting the source code for the method hooker a little later. Anyways, here's an example of I'm using them for(given you divide each line into a buffer) :
With a couple lines of C++ code using the methods you can load all that into an array of structs or however you want to organize them.//START//
[GENEREL_CONFIG]
MS_EXECUTION_DELAY:10;
MS_BYTE_WRITE_LOOP_SLEEP:10;
RESTORE_PAGE_ACCESS:NO;
LOOP_BYTE_WRITE:YES;
CHECK_REHOOKS:NO;
CONSOLE_OUTPUT:NO;
METHOD_HOOKS:3; //careful with this, if I'm too lazy or I forget about this, changing this to a bad number can == buffer overflow :X
HOOK_LOGS_DIR:*logs; //Will create seperate text files for each method
SEG_END;
[HOOK_DEFINITIONS]
HOOKID:Nigz;
ADR_TYPE:-1;
REDIRECT:NO;
LOG:YES;
TGT_ADDRESS:115548;
PARAMS:2;
PARAM0:%d;
PARAM1:%s;
END_DEF;
HOOKID:Nigz2;
ADR_TYPE:1;
REDIRECT:NO;
LOG:YES;
EXPORT_MODULE:KERNEL32.DLL;
SYMBOL_NAME:OutputDebugStringA;
PARAMS:1;
PARAM1:%d;
END_DEF;
HOOKID:REDIR;
ADR_TYPE:1;
REDIRECT_ADR_TYPE:1;
REDIRECT:YES;
LOG:YES;
EXPORT_MODULE:KERNEL32.DLL;
SYMBOL_NAME:OutputDebugStringA;
REDIRECT_ADRSPACE:HookCode.exe;
REDIRECT_MODULE:someniggahz.dll;
REDIRECT_SYMBOL:SomeSymbolName;
PARAMS:1;
PARAM1:%s;
END_DEF;
SEG_END;
[BYTE_WRITE]
//END//
Here's the headers :
[php]
#pragma once
#include <windows.h>
char* splitString (char* secondHalfBuffer, char* stringToSplit, char devideChar = ':');
bool startsWith (char* prefix , char* msg);
int extractInt (char* msg , char split = ':');
char* extractString(char* msg , char split = ':');
bool extractBool(char* msg, char split = ':', char* trueVal = "YES");
DWORD extractHexDword(char* msg, char split = ':');
[/php]
The source files
[php]
#include "stdafx.h"
#include "stdlib.h"
#include "stringTools.h"
#include <windows.h>
char* splitString(char* secondHalfBuffer, char* stringToSplit,char devideChar) {
char* buffer = new char[strlen(stringToSplit)];
memset(buffer, 0, strlen(stringToSplit));
for(unsigned int i = 0; i < strlen(stringToSplit); i++) {
if(stringToSplit[i] == devideChar) {
for(unsigned int x = i + 1; x < strlen(stringToSplit) + i; x++)
buffer[x - i - 1] = stringToSplit[x];
break;
}else
if(secondHalfBuffer != NULL)
secondHalfBuffer[i] = stringToSplit[i];
}
return buffer;
}
bool startsWith(char* prefix, char* msg) {
for(unsigned int i = 0; i < strlen(prefix); i++)
if(prefix[i] != msg[i])
return false;
return true;
}
int extractInt(char* msg, char split) {
char* buffer = new char[sizeof(msg)];
char* returnBuffer = new char[sizeof(msg)];
memset(buffer, 0, sizeof(buffer));
memset(returnBuffer, 0, sizeof(returnBuffer));
if(split != NULL)
buffer = splitString(NULL, msg, split);
else
buffer = msg;
for(unsigned int i = 0;i < strlen(buffer); i++)
if(buffer[i] == ';')
break;
else
returnBuffer[i] = buffer[i];
return (atoi(returnBuffer));
}
char* extractString(char* msg, char split) {
char* buffer = new char[strlen(msg)];
char* returnBuffer = new char[strlen(msg)];
memset(buffer, 0, strlen(msg));
memset(returnBuffer, 0, strlen(msg));
if(split != NULL)
buffer = splitString(NULL, msg, split);
else
buffer = msg;
for(unsigned int i = 0;i < strlen(buffer); i++)
if(buffer[i] == ';')
break;
else
returnBuffer[i] = buffer[i];
return returnBuffer;
}
DWORD extractHexDword(char* msg, char split) {
DWORD returnVar;
char* buffer = extractString(msg, split);
sscanf(buffer,"%u",&returnVar);
return returnVar;
}
bool extractBool(char* msg, char split, char* trueVal) {
if(strcmp(extractString(msg, split), trueVal) == 0)
return true;
else
return false;
}
[/php]
Their functions should be self-explanatory.
There are two types of tragedies in life. One is not getting what you want, the other is getting it.
If you wake up at a different time in a different place, could you wake up as a different person?
Yo, aside from this looking good, you're into game design sir?
Yeah, quite a bit. I've been working on a 2D side-scroller engine with the DirectX9 SDK. I can't do any of the 3D math, it confuses the hell out of me. In a month or two though I'm going to pickup a book on it.
Last edited by radnomguywfq3; 04-11-2009 at 11:55 AM.
There are two types of tragedies in life. One is not getting what you want, the other is getting it.
If you wake up at a different time in a different place, could you wake up as a different person?
I've only finished my Bleach Trading Card game, Haha. I of course plan to move on. Let us chat on this subject sometime.