This code is hook dll to exe. it's doesn't mean this is Q-Dll. you can use other way too hook dll. and if you think it not enough to protect dll.
Code:
#ifdef __GAMEGUARD
void CheckSum::Initialize(void)
{
memset(&this->ulTable, 0, sizeof(this->ulTable));
for(int iCodes = 0; iCodes <= 0xFF; iCodes++)
{
this->ulTable[iCodes] = this->Reflect(iCodes, 8) << 24;
for(int iPos = 0; iPos < 8; iPos++)
{
this->ulTable[iCodes] = (this->ulTable[iCodes] << 1) ^
(this->ulTable[iCodes] & (1 << 31) ? CRC32_POLYNOMIAL : 0);
}
this->ulTable[iCodes] = this->Reflect(this->ulTable[iCodes], 32);
}
}
unsigned long CheckSum::Reflect(unsigned long ulReflect, char cChar)
{
unsigned long ulValue = 0;
for(int iPos = 1; iPos < (cChar + 1); iPos++)
{
if(ulReflect & 1) ulValue |= 1 << (cChar - iPos);
ulReflect >>= 1;
}
return ulValue;
}
unsigned long CheckSum::FileCRC(const char *sFileName)
{
unsigned long ulCRC = 0xffffffff;
FILE *fSource = NULL;
unsigned char sBuf[CRC32BUFSZ];
int iBytesRead = 0;
if( (fSource = fopen(sFileName, "rb")) == NULL)
{
return 0xffffffff;
}
do{
iBytesRead = fread(sBuf, sizeof(char), CRC32BUFSZ, fSource);
this->PartialCRC(&ulCRC, sBuf, iBytesRead);
}while(iBytesRead == CRC32BUFSZ);
fclose(fSource);
return(ulCRC ^ 0xffffffff);
}
unsigned long CheckSum::FullCRC(unsigned char *sData, unsigned long ulLength)
{
unsigned long ulCRC = 0xffffffff;
this->PartialCRC(&ulCRC, sData, ulLength);
return ulCRC ^ 0xffffffff;
}
void CheckSum::PartialCRC(unsigned long *ulInCRC, unsigned char *sData, unsigned long ulLength)
{
while(ulLength--)
{
*ulInCRC = (*ulInCRC >> 8) ^ this->ulTable[(*ulInCRC & 0xFF) ^ *sData++];
}
}
int GetszFile (char *szFileName)
{
DWORD dwSize;
HANDLE hFile;
hFile = CreateFile (szFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL);
dwSize = GetFileSize (hFile,
NULL);
CloseHandle(hFile);
return dwSize;
}
using namespace std;
typedef void (*HackCheck)();
BOOL CallDLL()
{
CheckSum Check;
HackCheck _HackCheck;
HINSTANCE hInstLibrary = LoadLibrary("GameGuard.dll");
// int dwFileSize = GetFileSize("GameGuard.dll",NULL);
// int FileCheckSize = 351232;
if (hInstLibrary)
{
_HackCheck = (HackCheck)GetProcAddress(hInstLibrary,"GasMask_5");
_HackCheck();
if(GetszFile("GameGuard.dll") != 354304)
{
MessageBox( g_Neuz.GetSafeHwnd(), "GameGuard Read Error!", "Error in GameGuard.dll!", MB_OK );
ExitProcess( -1 );
}
Check.Initialize();
long crchash = 0x28061926;
long Player = Check.FileCRC("GameGuard.dll");
if(Player != crchash)
{
MessageBox( g_Neuz.GetSafeHwnd(), "GameGuard Read Error!", "Error in GameGuard.dll!", MB_OK );
ExitProcess( -1 );
}
}
else
{
ExitProcess( -1 );
}
return true;
}
#endif
Easy ?