Thread: Passing structures problem

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    55

    Passing structures problem

    I have looked at several samples and I am still extremely frustrated because, it seems no matter which way I try it, it gives me the same errors and warnings each time.

    /* Preprocessor directives : */


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <tlhelp32.h>
    #include <tchar.h>
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Contants : */
    
    
    #define WIN32_LEAN_AND_MEAN /* Trims all the lard from windows */
    
    
    /* check if a Win32 API virtual-key is pressed */
    #define VKEY_IS_PRESSED(vk)	( GetAsyncKeyState(vk) & 0x8000 )
    
    
    /* Win32 API virtual-keys to be handled:
       http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
     */
    enum VKey {
        VKEY_EXIT = VK_ESCAPE,
    	VKEY_PG_UP = VK_PRIOR,
    	VKEY_PG_DN = VK_NEXT
    };
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Struct for use in this small debugger */
    
    
    typedef struct MEMORY_ADDRESSES
    {
        void * Address1;
        void * Address2;
        void * Address3;
        void * Address4;
        void * Address5;
        void * Address6;
        void * Address7;
        void * Address8;
        void * Address9;
        void * Address10;
    
    
    } ProcessMem;
    
    
    ProcessMem MyProcess[1] = {};
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Function Prototypes : */
    
    
    HANDLE GetRobloxProcess( );
    static int DebuggerInit( HANDLE Roblox, ProcessMem * WriteToStruct, ProcessMem ReadStructInfo );
    
    
    static void PearnetLogo( );
    
    
    static void cls( HANDLE hConsole );
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Main entry point */
    
    
    int main( )
    {
        /* Displays my logo on the screen */
        PearnetLogo();
        /* -------------------------------*/
    
    
        /* Finds the roblox game */
    
    
        HANDLE Roblox;
    
    
        do
        {
            if ( ( Roblox = GetRobloxProcess() ) != NULL ) { break; }
            Sleep(1000);
        } while (1);
    
    
        /* -------------------------------*/
    
    
        /* Initializes the information we need in our struct */
    
    
        static int DebuggerInit( Roblox, &(MyProcess + 0), *(MyProcess + 0) );
    
    
        /* -------------------------------*/
        /* Exit the proccess with 0, as required by the function declaration */
    
    
        return 0;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    HANDLE GetRobloxProcess( )
    {
    
    
        HANDLE hProcessSnap;
        HANDLE hProcess;
        HANDLE DummyHandle = NULL;
        PROCESSENTRY32 pe32;
    
    
        /* Take a snapshot of all processes in the system. */
        hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
        if( hProcessSnap == INVALID_HANDLE_VALUE )
        {
            return DummyHandle;
        }
    
    
        /* Set the size of the structure before using it. */
        pe32.dwSize = sizeof( PROCESSENTRY32 );
    
    
        if( !Process32First( hProcessSnap, &pe32 ) )
        {
        CloseHandle( hProcessSnap );
        exit(EXIT_FAILURE);
        }
    
    
        /* Walk through the snapshot, and return roblox when
           found. */
    
    
        do
        {
            if (strcmp(pe32.szExeFile, "RobloxPlayer.exe") == 0)
            {
                CloseHandle( hProcessSnap );
                hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
                return hProcess;
            }
        } while( Process32Next( hProcessSnap, &pe32 ) );
    
    
      CloseHandle( hProcessSnap );
    
    
      return DummyHandle;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    static int DebuggerInit( HANDLE Roblox, ProcessMem * WriteToStruct, ProcessMem ReadStructInfo );
    {
        return 0;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    static void PearnetLogo( )
    {
        HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
        WORD wOldColorAttrs;
        CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    
    
        /*
        * First save the current color information
        */
        GetConsoleScreenBufferInfo(h, &csbiInfo);
        wOldColorAttrs = csbiInfo.wAttributes;
    
    
        /*
        * Set the new color information
        */
        SetConsoleTextAttribute ( h, FOREGROUND_GREEN );
    
    
        putchar('\n');
        puts("                                     /");
        puts("                                    ±±");
        puts("                                   ±±±±");
        puts("                                  ±±±±±±");
        puts("                                 ±±±±±±±±");
        puts("                                ±±±±±±±±±±");
        puts("                               ±±±±±±±±±±±±");
        puts("                               ±±±±±±±±±±±±");
        puts("                                ±±±±±±±±±±");
        putchar('\n');
        putchar('\n');
        puts("   ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ       Û       ÛÛÛÛÛÛÛÛ ÛÛÛ     Û ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛ");
        puts("   Û      Û Û            Û Û      Û      Û Û Û     Û Û            Û");
        puts("   Û      Û Û           Û   Û     Û      Û Û  Û    Û Û            Û");
        puts("   ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ    ÛÛÛÛÛÛÛ    ÛÛÛÛÛÛÛÛ Û   Û   Û ÛÛÛÛÛÛÛÛ     Û");
        puts("   Û        Û         Û       Û   Û   Û    Û    Û  Û Û            Û");
        puts("   Û        Û        Û         Û  Û    Û   Û     Û Û Û            Û");
        puts("   Û        ÛÛÛÛÛÛÛ Û           Û Û     Û  Û      ÛÛ ÛÛÛÛÛÛÛÛ     Û");
        putchar('\n');
        putchar('\n');
        putchar('\n');
        puts("\t\t\t   [TRAINER FOR ROBLOX]");
    
    
        Sleep(1000);
    
    
        HANDLE hStdout;
    	hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    
    
    	cls(hStdout);
    
    
        /*
        * Restore the original colors
        */
        SetConsoleTextAttribute ( h, wOldColorAttrs);
    
    
        return;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Credit for this function goes to Microsoft's website's help section here: */
    /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms682022%28v=vs.85%29.aspx */
    
    
    static void cls( HANDLE hConsole )
    {
    	COORD coordScreen = { 0, 0 };    /* home for the cursor */
    	DWORD cCharsWritten;
    	CONSOLE_SCREEN_BUFFER_INFO csbi;
    	DWORD dwConSize;
    
    
    	/* Get the number of character cells in the current buffer. */
    	if ( !GetConsoleScreenBufferInfo(hConsole, &csbi) )
    	{
    		return;
    	}
    
    
    	dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    
    
    	/* Fill the entire screen with blanks. */
    	if (
    	!FillConsoleOutputCharacter(
    		hConsole,		/* Handle to console screen buffer */
    		(TCHAR) ' ',		/* Character to write to the buffer */
    		dwConSize,		/* Number of cells to write */
    		coordScreen,		/* Coordinates of first cell */
    		&cCharsWritten )	/* Receive number of characters written */
    	){
    		return;
    	}
    
    
    	/* Get the current text attribute. */
    	if ( !GetConsoleScreenBufferInfo(hConsole, &csbi) )
    	{
    		return;
    	}
    
    
    	/* Set the buffer's attributes accordingly. */
    	if (
    	!FillConsoleOutputAttribute(
    		hConsole,		/* Handle to console screen buffer */
    		csbi.wAttributes,	/* Character attributes to use */
    		dwConSize,		/* Number of cells to set attribute */
    		coordScreen,		/* Coordinates of first cell */
    		&cCharsWritten )	/* Receive number of characters written */
    	){
    		return;
    	}
    
    
    	/* Put the cursor at its home coordinates. */
    	SetConsoleCursorPosition( hConsole, coordScreen );
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    I get the following errors when compiling :

    Code:
    |In function 'main':|
    |79|error: expected ')' before '&' token|
    |134|error: expected identifier or '(' before '{' token|

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    #define WIN32_LEAN_AND_MEAN /* Trims all the lard from windows */
    O_o

    By this point, you've already included "windows.h"; you are much too late to trim anything.

    Also, "mixed declarations" are C99; are you compiling as C99?

    Soma

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    55
    No, I'm not compiling as C99.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    No, I'm not compiling as C99.
    O_o

    That was more of a hint than a question.

    Search around for "mixed declarations".

    Soma

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    You've provided a typical example of having copied a function declaration and then attempted to call that function without understanding the meaning of the declaration.

    First, remove the "static int" from this;
    Code:
    static int DebuggerInit( Roblox, &(MyProcess + 0), *(MyProcess + 0) );
    Second, you've also mixed up the types. Eliminate the unnecessary pointer hackery and make things type correct.
    Code:
    DebuggerInit( Roblox, &MyProcess[0], MyProcess[0] );
    Whether that does what you intend ..... no idea.

    It would probably be a good idea to do something with the value the function returns. But since the function does nothing other than "return 0", that is a moot point at present.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    This looks more like a function definition, not a function call:
    Code:
    static int DebuggerInit( Roblox, &(MyProcess + 0), *(MyProcess + 0) );
    It should be something like this:
    Code:
    DebuggerInit( Roblox, MyProcess, *MyProcess );
    And this
    Code:
    static int DebuggerInit( HANDLE Roblox, ProcessMem * WriteToStruct, ProcessMem ReadStructInfo );
    {
        return 0;
    }
    should not have the semicolon after the closing parens on the first line.

    And as phantom said, you need to put the define for WIN32_LEAN_AND_MEAN before the include for windows.h, otherwise it has no effect.

  7. #7
    Registered User
    Join Date
    Jan 2013
    Posts
    55
    My function only returns 0 at the moment because I didn't want to add more code before fixing the bugs already there. I just wanted to add enough so my compilier wouldn't yell at me for no return value or something.

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    My function only returns 0 at the moment because I didn't want to add more code before fixing the bugs already there. I just wanted to add enough so my compilier wouldn't yell at me for no return value or something.
    O_o

    You aren't particularly good at listening are you?

    oogabooga simply does not care about your desires for the definition of the function; he has told you that no valid definition exists because of a syntax or typing bug.

    Soma

  9. #9
    Registered User
    Join Date
    Jan 2013
    Posts
    55
    Now that I got my code fixed, I have a new problem. For some reason, my program fails at ReadProcessMemory with "No error" as the message. I suspect I may have a made a logic error or done something wrong that is unknown to my current knowledge.

    Code:
    /* Preprocessor directives : */
    
    
    #include <stdio.h>
    #include <stdlib.h>
    
    
    #define WIN32_LEAN_AND_MEAN /* Trims all the lard from windows */
    
    
    #include <windows.h>
    #include <tlhelp32.h>
    #include <tchar.h>
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Contants : */
    
    
    /* check if a Win32 API virtual-key is pressed */
    #define VKEY_IS_PRESSED(vk)    ( GetAsyncKeyState(vk) & 0x8000 )
    
    
    /* Win32 API virtual-keys to be handled:
       http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
     */
    enum VKey {
        VKEY_EXIT = VK_ESCAPE,
        VKEY_PG_UP = VK_PRIOR,
        VKEY_PG_DN = VK_NEXT
    };
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Struct for use in this small debugger */
    
    
    typedef struct MEMORY_ADDRESSES
    {
        void * Address1;
        void * Address2;
        void * Address3;
        void * Address4;
        void * Address5;
        void * Address6;
        void * Address7;
        void * Address8;
        void * Address9;
        void * Address10;
    
    
    } ProcessMem;
    
    
    ProcessMem MyProcess[1] = {};
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Function Prototypes : */
    
    
    HANDLE GetRobloxProcess( );
    static void DebuggerInit( HANDLE Roblox, ProcessMem * WriteToStruct, ProcessMem ReadStructInfo );
    
    
    static void PearnetLogo( );
    
    
    static void cls( HANDLE hConsole );
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Main entry point */
    
    
    int main( )
    {
        /* -------------------------------*/
        /* Displays my logo on the screen */
    
    
        PearnetLogo();
        /* -------------------------------*/
        /* Finds the roblox game */
    
    
        HANDLE Roblox;
    
    
        do
        {
            if ( ( Roblox = GetRobloxProcess() ) != NULL ) { break; }
            Sleep(1000);
        } while (1);
    
    
        /* -------------------------------*/
        /* Initializes the information we need in our struct */
    
    
        DebuggerInit( Roblox, &MyProcess[0], MyProcess[0] );
    
    
        /* -------------------------------*/
        /* Close the process handle to avoid nasty memory leaks */
    
    
        CloseHandle( Roblox );
    
    
        /* -------------------------------*/
        /* Exit the proccess with 0, as required by the function declaration */
    
    
        return 0;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    HANDLE GetRobloxProcess( )
    {
    
    
        HANDLE hProcessSnap;
        HANDLE hProcess;
        HANDLE DummyHandle = NULL;
        PROCESSENTRY32 pe32;
    
    
        /* Take a snapshot of all processes in the system. */
        hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
        if( hProcessSnap == INVALID_HANDLE_VALUE )
        {
            return DummyHandle;
        }
    
    
        /* Set the size of the structure before using it. */
        pe32.dwSize = sizeof( PROCESSENTRY32 );
    
    
        if( !Process32First( hProcessSnap, &pe32 ) )
        {
        CloseHandle( hProcessSnap );
        exit(EXIT_FAILURE);
        }
    
    
        /* Walk through the snapshot, and return roblox when
           found. */
    
    
        do
        {
            if (strcmp(pe32.szExeFile, "RobloxPlayer.exe") == 0)
            {
                CloseHandle( hProcessSnap );
                hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
                return hProcess;
            }
        } while( Process32Next( hProcessSnap, &pe32 ) );
    
    
      CloseHandle( hProcessSnap );
    
    
      return DummyHandle;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    static void DebuggerInit( HANDLE Roblox, ProcessMem * WriteToStruct, ProcessMem ReadStructInfo )
    {
        /* -------------------------------*/
        /* Get roblox's base address */
    
    
        void * BaseAddress = ( void * ) Roblox;
    
    
        /* -------------------------------*/
    
    
        /* Stores 10 bytes from Roblox's process in tempStorage */
    
    
        BYTE tempStorage[10];
    
    
        if ( !ReadProcessMemory( Roblox, BaseAddress, tempStorage, 10, NULL ) )
        {
            fprintf( stderr, _strerror(NULL) );
            exit(EXIT_FAILURE);
        }
    
    
        /* -------------------------------*/
    
    
        /* Fills the structure with the starting addresses */
    
    
        WriteToStruct->Address1 = BaseAddress + 0;                      /* 1 */
        WriteToStruct->Address2 = BaseAddress + (sizeof(BYTE));         /* 2 */
        WriteToStruct->Address3 = BaseAddress + (sizeof(BYTE) * 2);     /* 3 */
        WriteToStruct->Address4 = BaseAddress + (sizeof(BYTE) * 3);     /* 4 */
        WriteToStruct->Address5 = BaseAddress + (sizeof(BYTE) * 4);     /* 5 */
        WriteToStruct->Address6 = BaseAddress + (sizeof(BYTE) * 5);     /* 6 */
        WriteToStruct->Address7 = BaseAddress + (sizeof(BYTE) * 6);     /* 7 */
        WriteToStruct->Address8 = BaseAddress + (sizeof(BYTE) * 7);     /* 8 */
        WriteToStruct->Address9 = BaseAddress + (sizeof(BYTE) * 8);     /* 9 */
        WriteToStruct->Address10 = BaseAddress + (sizeof(BYTE) * 9);    /* 10 */
    
    
        /* -------------------------------*/
    
    
        /* Print out the starting information, then return to main */
    
    
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address1 , tempStorage[0] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address2 , tempStorage[0 + 1] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address3 , tempStorage[0 + 2] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address4 , tempStorage[0 + 3] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address5 , tempStorage[0 + 4] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address6 , tempStorage[0 + 5] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address7 , tempStorage[0 + 6] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address8 , tempStorage[0 + 7] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address9 , tempStorage[0 + 8] );
        fprintf(stdout, "\t %p = %2X \n", &ReadStructInfo.Address10 , tempStorage[0 + 9] );
    
    
        return;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    
    
    static void PearnetLogo( )
    {
        HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
        WORD wOldColorAttrs;
        CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    
    
        /*
        * First save the current color information
        */
        GetConsoleScreenBufferInfo(h, &csbiInfo);
        wOldColorAttrs = csbiInfo.wAttributes;
    
    
        /*
        * Set the new color information
        */
        SetConsoleTextAttribute ( h, FOREGROUND_GREEN );
    
    
        putchar('\n');
        puts("                                     /");
        puts("                                    ±±");
        puts("                                   ±±±±");
        puts("                                  ±±±±±±");
        puts("                                 ±±±±±±±±");
        puts("                                ±±±±±±±±±±");
        puts("                               ±±±±±±±±±±±±");
        puts("                               ±±±±±±±±±±±±");
        puts("                                ±±±±±±±±±±");
        putchar('\n');
        putchar('\n');
        puts("   ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ       Û       ÛÛÛÛÛÛÛÛ ÛÛÛ     Û ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛ");
        puts("   Û      Û Û            Û Û      Û      Û Û Û     Û Û            Û");
        puts("   Û      Û Û           Û   Û     Û      Û Û  Û    Û Û            Û");
        puts("   ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ    ÛÛÛÛÛÛÛ    ÛÛÛÛÛÛÛÛ Û   Û   Û ÛÛÛÛÛÛÛÛ     Û");
        puts("   Û        Û         Û       Û   Û   Û    Û    Û  Û Û            Û");
        puts("   Û        Û        Û         Û  Û    Û   Û     Û Û Û            Û");
        puts("   Û        ÛÛÛÛÛÛÛ Û           Û Û     Û  Û      ÛÛ ÛÛÛÛÛÛÛÛ     Û");
        putchar('\n');
        putchar('\n');
        putchar('\n');
        puts("\t\t\t   [TRAINER FOR ROBLOX]");
    
    
        Sleep(1000);
    
    
        HANDLE hStdout;
        hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    
    
        cls(hStdout);
    
    
        /*
        * Restore the original colors
        */
        SetConsoleTextAttribute ( h, wOldColorAttrs);
    
    
        return;
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    /* Credit for this function goes to Microsoft's website's help section here: */
    /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms682022%28v=vs.85%29.aspx */
    
    
    static void cls( HANDLE hConsole )
    {
        COORD coordScreen = { 0, 0 };    /* home for the cursor */
        DWORD cCharsWritten;
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        DWORD dwConSize;
    
    
        /* Get the number of character cells in the current buffer. */
        if ( !GetConsoleScreenBufferInfo(hConsole, &csbi) )
        {
            return;
        }
    
    
        dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    
    
        /* Fill the entire screen with blanks. */
        if (
        !FillConsoleOutputCharacter(
            hConsole,        /* Handle to console screen buffer */
            (TCHAR) ' ',        /* Character to write to the buffer */
            dwConSize,        /* Number of cells to write */
            coordScreen,        /* Coordinates of first cell */
            &cCharsWritten )    /* Receive number of characters written */
        ){
            return;
        }
    
    
        /* Get the current text attribute. */
        if ( !GetConsoleScreenBufferInfo(hConsole, &csbi) )
        {
            return;
        }
    
    
        /* Set the buffer's attributes accordingly. */
        if (
        !FillConsoleOutputAttribute(
            hConsole,        /* Handle to console screen buffer */
            csbi.wAttributes,    /* Character attributes to use */
            dwConSize,        /* Number of cells to set attribute */
            coordScreen,        /* Coordinates of first cell */
            &cCharsWritten )    /* Receive number of characters written */
        ){
            return;
        }
    
    
        /* Put the cursor at its home coordinates. */
        SetConsoleCursorPosition( hConsole, coordScreen );
    }
    
    
    /* -------------------------------------------------------------------------------------------------- */
    Last edited by BatchProgrammer; 06-14-2013 at 08:14 PM.

  10. #10
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    Quote Originally Posted by BatchProgrammer View Post
    For some reason, my program fails at ReadProcessMemory with "No error" as the message.
    Try calling GetLastError() to check if there was an error. Code to display such an error:

    Code:
    /* ... */
    DWORD   dwerr;
    BYTE    abErrMsg[128];
    
    /* ... */
        dwErr = GetLastError();
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
            NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
            (LPTSTR) abErrMsg, sizeof(abErrMsg), NULL );
        printf("\nError code %u:%s\n", dwErr, abErrMsg);
    Last edited by rcgldr; 06-14-2013 at 08:23 PM.

  11. #11
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    To get the error info you need to use the MS function GetLastError (and FormatMessage), not the standard library error functions.

    EDIT: rcgldr shows the way!

  12. #12
    Registered User
    Join Date
    Jan 2013
    Posts
    55
    It says it was error code 299 : Only a partial request of ReadProcessMemory() or WriteProcessMemory() was completed. I tried executing it with a simpler game, such as minesweeper with admin access, but still the same error. Is there some kind of command I should invoke to get more priveleges, or what?

  13. #13
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    It seems weird that you're setting the BaseAddress for ReadProcessMemory to Roblox (the process handle).
    I don't know what it should be set to, but try something like this:
    Code:
    void * BaseAddress = ( void * ) (0x10000);  // or some other value

  14. #14
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Roblox seems to be an MMO. Are we helping someone write a cheat application here?!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    I'm closing this for rule 6
    Announcements - C Programming

    The OP isn't the original author, they're just another wannabe with found code.
    This code was originally posted on the roblox.com forum itself, but has since been deleted for obvious reasons (I found it in google cache).

    For info, these threads also have code extractions from the same original found code.
    Asm code hook/ modification problem
    WriteProcessMemory() problem on Windows 7 64-bit - C programming
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM
  2. Replies: 6
    Last Post: 02-15-2005, 11:20 PM
  3. passing structures??
    By justin69enoch in forum C Programming
    Replies: 6
    Last Post: 03-08-2003, 03:33 AM
  4. Passing Structures ??
    By justin69enoch in forum C Programming
    Replies: 7
    Last Post: 02-11-2003, 06:39 PM
  5. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM