Valhalla Legends Forums Archive | C/C++ Programming | Problem printing users names using pointers (reverse engineering bw)

AuthorMessageTime
warz
Alright, user names in memory are in an array, 8 DWORDs apart (0x48, int 72). The memory address of the first character, in the first username is at 0x00658e48. I've done this before, but I'm redoing it in a manner that I believe is much more efficient. Anyways, my variables are defined like so..

in .h/.cpp respectively..
[code]
extern unsigned long offset_playernames;
unsigned long offset_playernames = 0x00658e48;
[/code]

My function looks like...

[code]
inline unsigned long playernames(int x) { return offset_playernames + (x * 0x48); };
[/code]

What this does is accept an int value, x, and returns the base username address plus x times the length of one username location. In english, you tell this which username you want the address of, and it returns the address of the first character in that username. I'm not sure if this is the source of the problem or not.

Next, I call my function like so..

[code]
void printpatchproc(void) {
for(int x = 0; x <= (offsets->totalplayers()-1); x++) {
global->native.PrintText(0x00, (00 + (x * 10)), "%d", players[x].id);
global->native.PrintText(0x00, (00 + (x * 10)), "%s", (char*)offsets->playernames(x));
}
}
[/code]

PrintText just calls brood wars native priting routine. 0x00 is the x coordinate, and the 00 + x*10 is the y coordinate.

Now, this is very similar to how I did it in my previous dll, and the previous one worked. The only difference is the offsets of the usernames were hardcoded in my old dll. Does anyone see anything possibly wrong with why this isn't working?

Note: Sometimes it'll print the first 3 letters of a random username.
May 24, 2006, 4:23 AM

Search