identifier for unique id

10/15/2012 20:08 syndrah#1
in order for me to properly store any default values such as your nation when to activate spy mode i need some sort of value that is unique to the character such as char id or something else related to that.

anyone care to offer insight?

PHP Code:
int tempnat = *(DWORD*)(ADDR_BASE+A_NATION);

void Start(){
    while (
1){
        if(
GetKeyState(VK_F9) < 0){
            if(
spy == 0){
                
spy 1;
            }else if(
spy == 1){
                
spy 0;
            }
            
Sleep(1000);
        }
        if(
spy == 1){
            
DWORD NATION = *(DWORD*)ADDR_BASE;*(DWORD*)(NATION+A_NATION) = 3;
        }else if(
spy == 0){
            
DWORD NATION = *(DWORD*)ADDR_BASE;*(DWORD*)(NATION+A_NATION) = tempnat;
        }
    }

this is my sample code to enable "spy". what i want this to do is the tempnat var will store your "real" nation, so when you toggle it goes to gm and then tempnat. its semi working but its going to no nation which i believe the var is being taken when the game loads up and thus does not have a char to be used. So i need a check in my code that would detect that a character is being used.
10/16/2012 00:22 кev#2
Quote:
Originally Posted by syndrah View Post
this is my sample code to enable "spy". what i want this to do is the tempnat var will store your "real" nation, so when you toggle it goes to gm and then tempnat. its semi working but its going to no nation which i believe the var is being taken when the game loads up and thus does not have a char to be used. So i need a check in my code that would detect that a character is being used.
A hackish way would be to grab the value before you first modify it. There's naturally no nation value when the DLL is attached.

Alternatively you could poll the game state to (re)initialize the value every time you switch characters etc.

..Or switch to GM nation only temporarily, which is what I do. Save the nation > set it to GM > sleep few seconds > restore.

BTW, why on earth are you constantly writing the nation value regardless if it has changed or not?
10/16/2012 01:47 syndrah#3
Quote:
Originally Posted by кev View Post
A hackish way would be to grab the value before you first modify it. There's naturally no nation value when the DLL is attached.

Alternatively you could poll the game state to (re)initialize the value every time you switch characters etc.

..Or switch to GM nation only temporarily, which is what I do. Save the nation > set it to GM > sleep few seconds > restore.

BTW, why on earth are you constantly writing the nation value regardless if it has changed or not?
yes i noticed that too that the value ios being written constantly. ill change it around. i tried to store it as a temp value when i activate it, but couldnt get it to work right, the value kept getting ..."lost"...?

ill update my code in a bit and let you know how it went.

also kev can you calrify what you mean by poll?
10/16/2012 12:16 кev#4
Quote:
Originally Posted by syndrah View Post
yes i noticed that too that the value ios being written constantly. ill change it around. i tried to store it as a temp value when i activate it, but couldnt get it to work right, the value kept getting ..."lost"...?
For example; initially set the tempnat to -1. When you activate the nation change, check if tempnat's -1 and if it is, read the nation value into tempnat. But like I said, that's a tad hackish.

Quote:
Originally Posted by syndrah View Post
also kev can you calrify what you mean by poll?
There's an address which holds the current gamestate (pre-login, server / char selection, in-game, etc). I don't have the address nor the pattern to give you right now but I'm pretty sure it's mentioned somewhere around this forum. You simply check it's value periodically and use it to reinitialize tempnat every time it goes from char select to in-game.

Plus some nuances. Instead of int, bools or bool[] work better for simple toggle flags, even if just for clarity's sake. And toggling is more readable with spy = !spy instead of that 5 line if-else.
10/19/2012 19:43 syndrah#5
hi kev, thanks for your input.

im still trying to store in your "real" nation but it wont work.....it keep getting 0 or null...

PHP Code:
tempnat = *(DWORD*)(ADDR_BASE+A_NATION); 
the address base and nation address is correct as i use it to toggle, it just goes back to no nation instead of cap/proc :(
10/20/2012 10:14 кev#6
Quote:
Originally Posted by syndrah View Post
hi kev, thanks for your input.

im still trying to store in your "real" nation but it wont work.....it keep getting 0 or null...

PHP Code:
tempnat = *(DWORD*)(ADDR_BASE+A_NATION); 
the address base and nation address is correct as i use it to toggle, it just goes back to no nation instead of cap/proc :(
Your writes work fine but read doesn't because you're doing 'address-of-base + offset = value' instead of 'address-contained-in-base + offset = value'. There's a difference in pointer arithmetic of your reads and writes - compare them and you'll see the bug.
10/22/2012 22:20 syndrah#7
got it to work my way

PHP Code:
DWORD TNAT = *(DWORD*)ADDR_BASE;
tempnat = *(DWORD*)(TNAT+A_NATION); 
10/24/2012 02:47 кev#8
Quote:
Originally Posted by syndrah View Post
got it to work my way

PHP Code:
DWORD TNAT = *(DWORD*)ADDR_BASE;
tempnat = *(DWORD*)(TNAT+A_NATION); 
And you missed the point.
10/24/2012 02:52 syndrah#9
can you show, im not quite getting what you mean.