[HELP] Complex addresses and zero-length arrays

Ask for Help on Using the Language With Memory Hacking Software

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

[HELP] Complex addresses and zero-length arrays

Postby CoMPMStR » Mon Mar 31, 2008 5:36 am

Well, Ive read the help I needed to get this far but now I'm stuck and I can't find anyone who had this problem already.

I have a pointer that I use in MHS (eg: [[[[[[12345678]+0xD24]+0]+0x3C]+0xC]+0x188]+0x12) and as you can see, for one of them it's +0. I understand how to create the structure and then use it, what I don't understand is how to declare a zero-length array or at least something that would make it work the same. I even tried declaring it as shown below but it doesn't work as expected.

Code: Select all
extern struct teststruct {
   BYTE bBuffer[0xD24]; //+D24
   struct {
      BYTE bBuffer; //+0
      struct {
       BYTE bBuffer[0x3C]; //+3C
         struct {
            BYTE bBuffer[0xC]; //+C
            struct {
               BYTE bBuffer[0x188]; //+188
               struct {
                  BYTE bBuffer[0x12]; //+12
                  FLOAT fValue;
               } * poObj;
            } * poObj;
         } * poObj;
      } * poObj;
   } * poObj;
} * poBase = { "", 0x12345678 };



Would it be possible to do the following? (or something else instead of poBase->poObj->poObj->poObj->poObj->poObj->fValue = 123.4567;)

Code: Select all
teststruct test;
test->fValue = 123.4567;




Also, another problem I'm having is with this piece of code.

Code: Select all
  DWORD * dwPtr = (DWORD*)0x3419B631;
  dwPtr = 0;


According to another help topic I read, this is supposed to read the value at 0x3419B631 and then write 0 to it. I think I might have to use an extern variable for this but I wanted to ask about it first. It all compiles successfully but it just doesn't work.
Image

______________________________________________________
My Utilities:
CT <-> LSSAVE Converter
LSS Visual Dialog Designer
.NET Trainer Helper Library

~Whether you think you can or you think you can't, you're right.

L. Spiro wrote:In my left hand is a red pill. If you take it I will show you the truth. I lost my right hand in the war, so I’m afraid you’re stuck with the red pill.
User avatar
CoMPMStR
(P)ot (I)n (M)y (P)ipe
 
Posts: 451
Joined: Thu Mar 06, 2008 7:50 am
Location: Best Place

Re: [HELP] Complex addresses and zero-length arrays

Postby liqmysaq » Mon Mar 31, 2008 8:19 am

yea i found the answer to this in some forgotten post somewhere, cant even refind it to give u a link lol. but anyway, this is the solve. take out the "BYTE bBuffer; //+0" line but keep the "struct {". it should look like this:
Code: Select all
extern struct teststruct {
   BYTE bBuffer[0xD24]; //+D24
   struct {
      struct {
       BYTE bBuffer[0x3C]; //+3C
         struct {
            BYTE bBuffer[0xC]; //+C
            struct {
               BYTE bBuffer[0x188]; //+188
               struct {
                  BYTE bBuffer[0x12]; //+12
                  FLOAT fValue;
               } * poObj;
            } * poObj;
         } * poObj;
      } * poObj;
   } * poObj;
} * poBase = { "", 0x12345678 };
User avatar
liqmysaq
I Know Your Poop
 
Posts: 538
Joined: Tue Jan 01, 2008 2:02 am

Re: [HELP] Complex addresses and zero-length arrays

Postby L. Spiro » Mon Mar 31, 2008 9:30 am

CoMPMStR wrote:Also, another problem I'm having is with this piece of code.

Code: Select all
  DWORD * dwPtr = (DWORD*)0x3419B631;
  dwPtr = 0;


According to another help topic I read, this is supposed to read the value at 0x3419B631 and then write 0 to it. I think I might have to use an extern variable for this but I wanted to ask about it first. It all compiles successfully but it just doesn't work.

It needs to be extern and it should either be:

Code: Select all
  DWORD * dwPtr = { "", 0x3419B631 };
  (*dwPtr) = 0;


or

Code: Select all
  DWORD dwPtr = { "", 0x3419B631 };
  dwPtr = 0;



L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Re: [HELP] Complex addresses and zero-length arrays

Postby CoMPMStR » Mon Mar 31, 2008 12:45 pm

liqmysaq wrote:yea i found the answer to this in some forgotten post somewhere, cant even refind it to give u a link lol. but anyway, this is the solve. take out the "BYTE bBuffer; //+0" line but keep the "struct {". it should look like this:
Code: Select all
extern struct teststruct {
   BYTE bBuffer[0xD24]; //+D24
   struct {
      struct {
       BYTE bBuffer[0x3C]; //+3C
         struct {
            BYTE bBuffer[0xC]; //+C
            struct {
               BYTE bBuffer[0x188]; //+188
               struct {
                  BYTE bBuffer[0x12]; //+12
                  FLOAT fValue;
               } * poObj;
            } * poObj;
         } * poObj;
      } * poObj;
   } * poObj;
} * poBase = { "", 0x12345678 };


Thanks liq and spiro! I've edited the structure as necessary but it still doesn't work. I'm trying to do it something like this:

Code: Select all
//get the position when dead
FLOAT curPos = poBase->poObj->poObj->poObj->poObj->poObj->fValue;

//set value to respawn - (not the problem anymore)
DWORD dwPtr = {"", 0x3419B631};
dwPtr = 0;

//set position back to previous
poBase->poObj->poObj->poObj->poObj->poObj->fValue = curPos;


When I press the hotkey, it respawns perfectly, but not in the spot I died. Is there any other way to store the position in a variable then set it from the variable afterward? Because I don't understand why it's not working now.
Image

______________________________________________________
My Utilities:
CT <-> LSSAVE Converter
LSS Visual Dialog Designer
.NET Trainer Helper Library

~Whether you think you can or you think you can't, you're right.

L. Spiro wrote:In my left hand is a red pill. If you take it I will show you the truth. I lost my right hand in the war, so I’m afraid you’re stuck with the red pill.
User avatar
CoMPMStR
(P)ot (I)n (M)y (P)ipe
 
Posts: 451
Joined: Thu Mar 06, 2008 7:50 am
Location: Best Place

Postby L. Spiro » Mon Mar 31, 2008 1:59 pm

Position is a vector, not a float.

And if it still does not work use PrintF() to ensure you are reading the correct location. It may be a problem in your structure declaration.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby mezzo » Mon Mar 31, 2008 4:09 pm

DWORD dwPtr = {"", 0x3419B631};


isn't this supposed to be an extern ?
- No thanks, I already have a penguin -
User avatar
mezzo
El Mariachi
 
Posts: 739
Joined: Mon Apr 30, 2007 10:27 pm
Location: Antwerp

Postby CoMPMStR » Thu Apr 10, 2008 2:31 am

mezzo wrote:
DWORD dwPtr = {"", 0x3419B631};


isn't this supposed to be an extern ?


Yes it's an extern, this isn't the problem though. I just copied what Spiro put.


I used PrintF and I came to the conclusion that I can't use structures to define pointers. I will have to do it the old fashion way but I'm having problems, again. :roll:

This is what I'm going to do now:

Code: Select all
  extern DWORD dwPtr = {"", 0x12345678};
  DWORD dwPos = dwPtr + 0xD24;


Now dwPos holds the correct pointer to the next address I need to read but my problem is this, how can I define an extern variable using another variable? I tried this:

Code: Select all
  extern DWORD dwPtr0 = ("", dwPos);


But that results in a syntax error. Is there another way I can do this?
Image

______________________________________________________
My Utilities:
CT <-> LSSAVE Converter
LSS Visual Dialog Designer
.NET Trainer Helper Library

~Whether you think you can or you think you can't, you're right.

L. Spiro wrote:In my left hand is a red pill. If you take it I will show you the truth. I lost my right hand in the war, so I’m afraid you’re stuck with the red pill.
User avatar
CoMPMStR
(P)ot (I)n (M)y (P)ipe
 
Posts: 451
Joined: Thu Mar 06, 2008 7:50 am
Location: Best Place

Postby L. Spiro » Thu Apr 10, 2008 9:56 am

Code: Select all
extern DWORD dwPtr0 = {"", dwPos};


And yes you can use structures to map external variables, even pointers.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron