15-11-2008, 03:35 AM
|
#1 (permalink)
|
|
Amigo SW
Registrado em: Nov 2008
Posts: 104
Agradecido 239 Vezes em 56 Posts
Achei Ruim:
Acharam ruim Vezes em Posts
|
[Source]Comando /hide
Passeando por outro forum, encontrei isoo:
olá, resolvi liberar esta source, porque umas pessoas pediram para mim a um tempo atraz.
Isso nao funciona apenas para MuOnline, isso pode funcionar em outros games e programas, mas nós fizemos para MuOnline. =)
Okay, vamo la.
Crie em seu projeto, o arquivo CRC.h
e coloque este código:
Citação:
// ----------------------------------------------------
// File Name: CRC.h
// Creation Date: 2008-09-24
// Author: SmallHabit / SmallHabit
// ----------------------------------------------------
#ifndef _CCRC32_H
#define _CCRC32_H
// This is the official polynomial used by CRC-32 in PKZip, WinZip and Ethernet.
#define CRC32_POLYNOMIAL 0x04c11db7
#define CRC32BUFSZ 1024 //Used for FileCRC()
class CCRC32{
public:
void Initialize(void);
unsigned long FileCRC(const char *sFileName);
unsigned long FullCRC(unsigned char *sData, unsigned long ulLength);
void PartialCRC(unsigned long *ulInCRC, unsigned char *sData, unsigned long ulLength);
private:
unsigned long Reflect(unsigned long ulReflect, char cChar);
unsigned long ulTable[256]; // CRC lookup table array.
};
#endif
|
Agora crie CRC.cpp, e coloque isso:
Citação:
// ----------------------------------------------------
// File Name: CRC.cpp
// Creation Date: 2008-09-24
// Author: SmallHabit / [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
// ----------------------------------------------------
#ifndef _CCRC32_CPP
#define _CCRC32_CPP
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "CRC.H"
void CCRC32::Initialize(void)
{
memset(&this->ulTable, 0, sizeof(this->ulTable));
// 256 values representing ASCII character codes.
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);
}
}
// Reflection is a requirement for the official CRC-32 standard.
// You can create CRCs without it, but they won't conform to the standard.
unsigned long CCRC32::Reflect(unsigned long ulReflect, char cChar)
{
unsigned long ulValue = 0;
// Swap bit 0 for bit 7 bit 1 For bit 6, etc....
for(int iPos = 1; iPos < (cChar + 1); iPos++)
{
if(ulReflect & 1) ulValue |= 1 << (cChar - iPos);
ulReflect >>= 1;
}
return ulValue;
}
unsigned long CCRC32::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 CCRC32::FullCRC(unsigned char *sData, unsigned long ulLength)
{
unsigned long ulCRC = 0xffffffff;
this->PartialCRC(&ulCRC, sData, ulLength);
return ulCRC ^ 0xffffffff;
}
//For Example usage example, see FileCRC().
void CCRC32::PartialCRC(unsigned long *ulInCRC, unsigned char *sData, unsigned long ulLength)
{
while(ulLength--)
{
*ulInCRC = (*ulInCRC >> 8) ^ this->ulTable[(*ulInCRC & 0xFF) ^ *sData++];
}
}
#endif
|
Agora abra o seu .cpp onde a função esta chamando o MAIN. (exemplo)
maindll.cpp)
Adicione isso :
[code]
//CheckSum
#include "crc.h"
/code]
para outros includes.
agora vá para a função LOAD, a minha está
Citação:
|
extern "C" __declspec(dllexport) void Load() {
|
e ponha este código onde você quiser:
Citação:
//CheckSum32
CCRC32 MyCRC32;
MyCRC32.Initialize(); //Only have to do this once.
unsigned long ulCRC1 = MyCRC32.FileCRC("Data/Player/Player.bmd");
if(ulCRC1 != 0xXXXXXXXX)
{
MessageBox(0,"CRC32: Error","Player.bmd",0);
::ExitProcess(0);
}
|
Creditos do cara que posto o tutorial: Crazy ADM
|
|
|