1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[C++] Reading multi level pointers?

Discussion in 'Programming' started by Wallz, Aug 3, 2010.

  1. Wallz

    Wallz Member

    I have tries several ways to get this to work but I can't seem to grasp it. Any ideas on how to do it?
     
  2. Danny1994

    Danny1994 Likes to contribute Coder

    Define them first, like this. (Old Pointer Addys and Offsets - Update)
    This is were the Trainner will read them.
    IDC_MOUSEY will be getting writting then.

    If you dont want to read the Pointer on a Static Text thing this will may help you - orginal Kitterz source part :
     
  3. Wallz

    Wallz Member

    Nvm I got it working thanks
     
  4. Brandon

    Brandon New Member

    Here's also a pretty cool function to read multi-level pointers. I found it on CEF (written by Irwin) & fixed an error.

    Code (Text):
    1. #include <stdarg.h>
    2.  
    3. #define OFFSETS_END 0xDEADBEEF
    4.  
    5. __checkReturn BOOL _ReadPointer(__out PULONG_PTR pulValue, __in LPCVOID lpcvBase, ...)
    6. {
    7.   ULONG_PTR ulTemp;
    8.   va_list   pArguments;
    9.   BOOL      bRET;
    10.   int       iOffset;
    11.  
    12.   __try {
    13.     ulTemp = (ULONG_PTR)lpcvBase;
    14.     va_start(pArguments, lpcvBase);
    15.     while ((iOffset = va_arg(pArguments, int)) != OFFSETS_END)
    16.       ulTemp = (*(ULONG_PTR*)ulTemp) + iOffset;
    17.     va_end(pArguments);
    18.     *pulValue = ulTemp == (ULONG_PTR)lpcvBase ? *(ULONG_PTR*)ulTemp : ulTemp;
    19.     bRET = TRUE;
    20.   }
    21.   __except(EXCEPTION_EXECUTE_HANDLER) {
    22.     bRET = FALSE;
    23.   }
    24.  
    25.   return bRET;
    26. }
    27.  
    28. #define ReadPointer(x, y, ...) _ReadPointer(x, y, __VA_ARGS__, OFFSETS_END)
     

Share This Page