format of container of memory address problem

This is a discussion on format of container of memory address problem within the C++ Programming forums, part of the General Programming Boards category; hi, i'm working on an anticheat but now i have problem at detecting client program version: i have problem with ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    8

    Post format of container of memory address problem

    hi, i'm working on an anticheat but now i have problem at detecting client program version:

    i have problem with that

    Code:
    
    void* FindVersion(void)
    {
    
    	return (void*)*(DWORD*)0x01EA2B00;
    }
    
    
    
    struct cl_funcs_s	ofuncs;
    cl_funcs_s *pfuncs	= (cl_funcs_s*) FindVersion();
    it doesn't return address right, so it crash application

    if i just make
    Code:
    struct cl_funcs_s	ofuncs;
    cl_funcs_s *pfuncs	= (cl_funcs_s*) 0x01EA2B00;
    so it is all ok, but i need function there, i think i'm useing wrong format for return

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Accessing the contents of any specific memory address is bad news. The actual address where the item in question is located will vary with the linker and the exact code being linked. I'm not surprised that dereferencing some "random" pointer is causing a crash.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    8
    i know that, but i need it =\
    crash is caused only by my function returned address, if i just writedown an address instead of function calling returning it, it's all ok

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Do you really mean to READ the value at 0x01EA2B00, or return a pointer of that value? Since the first fragment you post reads what is at that memory address, whilst the second code-fragment is just setting the pointer to a permanent value.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    8
    i think i need to return a pointer of that value

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So then you should remove the star between void * and DWORD * casts. By the way, you don't need to cast twice...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    8
    return (void*)(DWORD*)0x01EA2B00;
    still crashes

    return (void*)0x01EA2B00;
    crashes too =\

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And your pfuncs = 0x01EA... doesn't? Very strange.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    8
    no, my 2nd code with just address ,from 1st post here works fine =\

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Could you post a more complete example of working/nonworking code? Because I don't really see how it would be different - in fact, if the compiler is optimizing things, it would even make the function into a constant assignment.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    8
    i use visual studio 2008

    working code
    Code:
    struct cl_funcs_s	ofuncs;
    cl_funcs_s *pfuncs	= (cl_funcs_s*) 0x01EA2B00;
    non working code

    [os.cpp]
    Code:
    void* FindVersion(void)
    {
    
    	return (void*)0x01EA2B00;
    }
    [main.cpp]
    Code:
    #include "os.cpp"
    
    struct cl_funcs_s	ofuncs;
    cl_funcs_s *pfuncs	= (cl_funcs_s*) FindVersion();

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sorry, not able to figure out anything wrong.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM
  3. What does this do (Windows API)?
    By EVOEx in forum Windows Programming
    Replies: 4
    Last Post: 12-19-2008, 09:48 AM
  4. I thought pointers were pointers...
    By keira in forum C Programming
    Replies: 19
    Last Post: 08-15-2007, 11:48 PM
  5. Memory Problem - I think...
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-24-2001, 12:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21