-
Class Variable = Error?
Code:
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
{
public:
bool Detour(BYTE * Buffer, int Size);
//Unrelated junk
private:
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.
-
Is size larger than 300? Is size larger than the size of Buffer? What's a BYTE?
-
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.