Thread: Class Variable = Error?

  1. #1
    Registered User
    Join Date
    Dec 2001

    Class Variable = Error?

    UseDriver _Driver;
    bool main(){
            BYTE _Buffer[] = { 0xE9, 0xAB, 0x02, 0x00, 0x00 };
            BYTE * pBuffer = _Buffer;
            //Unrelated junk.
            if(!_Driver.Detour((pBuffer, sizeof(_Buffer)))
                    return false;
            return true;
    class UseDriver
            bool Detour(BYTE * Buffer, int Size);
            //Unrelated junk
            char _Buffer[300];
            bool PtB(BYTE * Buffer, int Size);
            //Unrelated junk
    bool UseDriver::Detour(BYTE * Buffer, int Size)
            PtB(Buffer, Size);
            //Unrelated junk
            return true;
    bool UseDriver::PtB(BYTE * Buffer, int Size)
            for(int i = 0; i < Size; i++)
                    _Buffer[i] = Buffer[i];
            return true;
    The operation in PtB() crashes my program.
    Last edited by Denethor2000; 11-09-2005 at 11:04 PM.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Is size larger than 300? Is size larger than the size of Buffer? What's a BYTE?

  3. #3
    Registered User
    Join Date
    Jan 2005
    A BYTE is (usually) a typedef for unsigned char.

    That code shouldn't compile, there is an extra parenthesis in your call to Detour. If you fix that, it compiles and runs without a crash, so your problem is probably in the unrelated junk.

    Identifiers that start with an underscore followed by a capital letter are reserved, so you shouldn't be putting the underscore at the front of your variable names in case they clash with implementation macros. Also, main must specify int as its return value, not bool.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  4. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM