extern char*, char[] doesn't compile

Need Help With an Existing Feature in Memory Hacking Software? Ask Here

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

extern char*, char[] doesn't compile

Postby robrave » Thu Sep 20, 2007 9:05 am

i use
Code: Select all
extern char * variablename = { "", address };


i can't see any problem with it

Image
User avatar
robrave
Hacker Smacker
 
Posts: 41
Joined: Sat Sep 15, 2007 3:27 pm
Location: Philippines

Postby L. Spiro » Thu Sep 20, 2007 1:32 pm

If the variable is global then address has to be a constant.

If not, you should post the error message.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby robrave » Thu Sep 20, 2007 3:08 pm

huh?? :?: i don't get it.. http://www.rob-soft.com/cantcompile.jpg here's the image of the code
User avatar
robrave
Hacker Smacker
 
Posts: 41
Joined: Sat Sep 15, 2007 3:27 pm
Location: Philippines

Postby L. Spiro » Thu Sep 20, 2007 7:18 pm

The link to the image is dead.


I am saying that if this variable is declared outside of a function, you must use a constant value for the address.


Code: Select all
void Func() {
}

extern char * variableName = { "", 0x1005334 };

int Func1() { return 1; }

This compiles because 0x1005334 is constant. variableName is a global here.


Code: Select all
void Func() {
    DWORD dwAddress = 0x1005334;
    extern char * variableName = { "", dwAddress };
}

This compiles because variableName is a local inside a function, so the address can be either constant or variable.


Code: Select all
void Func() {
}
DWORD dwAddress = 0x1005334;
extern char * variableName = { "", dwAddress };

int Func1() { return 1; }

This does not compile because dwAddress is variable and variableName is not declared inside a function.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby robrave » Fri Sep 21, 2007 10:06 am

Thanks! I got it now.. my problem is the same with this thread http://memoryhacking.com/forums/viewtopic.php?t=287

Thanks!!
User avatar
robrave
Hacker Smacker
 
Posts: 41
Joined: Sat Sep 15, 2007 3:27 pm
Location: Philippines


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron