Exemple #1
0
// CLIENT
bool CGuildMarkImage::SaveBlockFromCompressedData(DWORD posBlock, const BYTE * pbComp, DWORD dwCompSize)
{
	if (posBlock >= BLOCK_TOTAL_COUNT)
		return false;

	Pixel apxBuf[SGuildMarkBlock::SIZE];
	lzo_uint sizeBuf = sizeof(apxBuf);

	if (LZO_E_OK != lzo1x_decompress_safe(pbComp, dwCompSize, (BYTE *) apxBuf, &sizeBuf, CLZO::Instance().GetWorkMemory()))
	{
		sys_err("GuildMarkImage::CopyBlockFromCompressedData: cannot decompress, compressed size = %u", dwCompSize);
		return false;
	}

	if (sizeBuf != sizeof(apxBuf))
	{
		sys_err("GuildMarkImage::CopyBlockFromCompressedData: image corrupted, decompressed size = %u", sizeBuf);
		return false;
	}

	DWORD rowBlock = posBlock / BLOCK_COL_COUNT;
	DWORD colBlock = posBlock % BLOCK_COL_COUNT;

	PutData(colBlock * SGuildMarkBlock::WIDTH, rowBlock * SGuildMarkBlock::HEIGHT, SGuildMarkBlock::WIDTH, SGuildMarkBlock::HEIGHT, apxBuf);

	m_aakBlock[rowBlock][colBlock].CopyFrom(pbComp, dwCompSize, GetCRC32((const char *) apxBuf, sizeof(Pixel) * SGuildMarkBlock::SIZE));
	return true;
}
Exemple #2
0
void SGuildMarkBlock::Compress(const Pixel * pxBuf)
{
	m_sizeCompBuf = MAX_COMP_SIZE;

	if (LZO_E_OK != lzo1x_1_compress((const BYTE *) pxBuf, sizeof(Pixel) * SGuildMarkBlock::SIZE, m_abCompBuf, &m_sizeCompBuf, CLZO::Instance().GetWorkMemory()))
	{
		sys_err("SGuildMarkBlock::Compress: Error! %u > %u", sizeof(Pixel) * SGuildMarkBlock::SIZE, m_sizeCompBuf);
		return;
	}

	//sys_log(0, "SGuildMarkBlock::Compress %u > %u", sizeof(Pixel) * SGuildMarkBlock::SIZE, m_sizeCompBuf);
	m_crc = GetCRC32((const char *) pxBuf, sizeof(Pixel) * SGuildMarkBlock::SIZE);
}
Exemple #3
0
DWORD GetHFILECRC32(HANDLE hFile)
{
	DWORD dwRetCRC32=0;

	DWORD dwFileSize = GetFileSize(hFile, NULL);

	DWORD dataOffset=0;
	DWORD mapSize=dwFileSize;

	SYSTEM_INFO SysInfo;
	GetSystemInfo(&SysInfo);
	
	DWORD dwSysGran = SysInfo.dwAllocationGranularity;
	DWORD dwFileMapStart = (dataOffset / dwSysGran) * dwSysGran;
	DWORD dwMapViewSize = (dataOffset % dwSysGran) + mapSize;
	//INT iViewDelta = dataOffset - dwFileMapStart;

	HANDLE hFM = CreateFileMapping(hFile,				// handle
							  NULL,					// security
							  PAGE_READONLY,		// flProtect
							  0,					// high
							  dataOffset + mapSize,	// low
							  NULL);				// name
	if (hFM)
	{	
		LPVOID lpMapData = MapViewOfFile(hFM,
									FILE_MAP_READ,
									0,
									dwFileMapStart,							
									dwMapViewSize);

		dwRetCRC32=GetCRC32((const char*)lpMapData, dwFileSize);

		
		if (lpMapData)
		{

			UnmapViewOfFile(lpMapData);
		}
		
		CloseHandle(hFM);
	}

	return dwRetCRC32;
}
Exemple #4
0
DWORD GetProcessMemoryCRC(LPCVOID c_pvBaseAddress)
{
	HANDLE hProcess = GetCurrentProcess();
	char * pBuf = new char[1024*1024];
	DWORD dwBytesRead;

	BOOL bRet = ReadProcessMemory(hProcess, c_pvBaseAddress, pBuf, 1024*1024, &dwBytesRead);

	if (!bRet && GetLastError() == ERROR_PARTIAL_COPY)
		bRet = true;

	if (bRet)
	{
		DWORD dwCRC = GetCRC32(pBuf, dwBytesRead);
		delete [] pBuf;
		return dwCRC;
	}

	delete [] pBuf;
	return 0;
}
Exemple #5
0
DWORD DESC_MANAGER::CreateHandshake()
{
	char crc_buf[8];
	crc_t crc;
	DESC_HANDSHAKE_MAP::iterator it;

RETRY:
	do
	{
		DWORD val = thecore_random() % (1024 * 1024);

		*(DWORD *) (crc_buf    ) = val;
		*((DWORD *) crc_buf + 1) = get_global_time();

		crc = GetCRC32(crc_buf, 8);
		it = m_map_handshake.find(crc);
	}
	while (it != m_map_handshake.end());

	if (crc == 0)
		goto RETRY;

	return (crc);
}
int GetHWIDSteamID()
{	VU("GetHWIDSteamID");

	char p[255];
	memset(p, 0, 255);
	DWORD a = 0;
	DWORD b = 0;

	char nickname[100];
	DWORD nnickName = sizeof(nickname);
	GetUserNameA((char*)nickname, &nnickName);

	__asm
	{
		pushad
		mov eax, 2
		cpuid
		mov a, eax
		mov b, edx
		popad
	}

	sprintf(p, V("(-%s-%d-%x-%c-)"), nickname, a, b, GAME_MODE);

	int crc32 = GetCRC32(p, 250);
	info("HWID is '%s', crc32 is %08X", p, crc32);
	
	//delete [] p;

	
	return crc32;
	VE();

	//DWORD res = 0;
	//HKEY hKey2;

	////generate steamid from machine OSid+CPUid
	//if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup", 0L, KEY_READ, &hKey2 ) == ERROR_SUCCESS)
	//{
	//	DWORD dwType;
	//	DWORD dwSize = 32;
	//	DWORD hashData[8];
	//	memset(hashData, 0, 32);

	//	if (RegQueryValueExA(hKey2, "PrivateHash", NULL, &dwType, (unsigned char *)hashData, &dwSize) == ERROR_SUCCESS)
	//	{
	//		res ^= hashData[0] + hashData[2];
	//	}

	//	__asm
	//	{
	//		pushad
	//		mov eax, 2
	//		cpuid
	//		add eax, edx
	//		xor res, eax
	//		popad
	//	}

	//	RegCloseKey(hKey2);
	//}

	//return res;
}
bool GetHWID(DWORD * hwid)
{	VU("GetHWID");

	
	CHwInfo smbios2;

	DWORD hwid_l[3] = {0, 0, 0};

	//old method, w2k+ only...
	//
	//SMBiosData smbios;
	//
	//if (smbios.FetchSMBiosData())
	//{
	//	DWORD dwSize = 0;
	//	BYTE * table = NULL;
	//	
	//	table = smbios.GetTable(1, dwSize);
	//	info("returned size %d table %08X", dwSize, table);
	//	if (dwSize > 4)
	//	{
	//		hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
	//		hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
	//		hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
	//		info("--- table 1 -----");
	//		PrintBuffer(table, dwSize, 16);
	//	}
	//	table = smbios.GetTable(2, dwSize);
	//	info("returned size %d table %08X", dwSize, table);
	//	if (dwSize > 4)
	//	{
	//		hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
	//		hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
	//		hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
	//		info("--- table 2 -----");
	//		PrintBuffer(table, dwSize, 16);
	//	}
	//	table = smbios.GetTable(4, dwSize);
	//	info("returned size %d table %08X", dwSize, table);
	//	if (dwSize > 4)
	//	{
	//		hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
	//		hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
	//		hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
	//		info("--- table 4 -----");
	//		PrintBuffer(table, dwSize, 16);
	//	}
	//	table = smbios.GetTable(11, dwSize);
	//	info("returned size %d table %08X", dwSize, table);
	//	if (dwSize > 4)
	//	{
	//		hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
	//		hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
	//		hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
	//		info("--- table 11 ----");
	//		PrintBuffer(table, dwSize, 16);
	//	}

	//	info("main hwid done, result: %08X %08X %08X", hwid_l[0], hwid_l[1], hwid_l[2]);

	//}

	//hwid_l[0] = 0;
	//hwid_l[1] = 0;
	//hwid_l[2] = 0;


	if (smbios2.GetSMBiosData())
	{
		DWORD dwSize = 0;
		BYTE * table = NULL;
		
		table = smbios2.GetSMBiosStructure(1, dwSize);
		info("returned size %d table %08X", dwSize, table);
		if (dwSize > 4 && table != NULL)
		{
			hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
			hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
			hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
			info("--- table 1 -----");
			PrintBuffer(table, dwSize, 16);
		}
		table = smbios2.GetSMBiosStructure(2, dwSize);
		info("returned size %d table %08X", dwSize, table);
		if (dwSize > 4 && table != NULL)
		{
			hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
			hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
			hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
			info("--- table 2 -----");
			PrintBuffer(table, dwSize, 16);
		}
		table = smbios2.GetSMBiosStructure(4, dwSize);
		info("returned size %d table %08X", dwSize, table);
		if (dwSize > 4 && table != NULL)
		{
			hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
			hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
			hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
			info("--- table 4 -----");
			PrintBuffer(table, dwSize, 16);
		}
		table = smbios2.GetSMBiosStructure(11, dwSize);
		info("returned size %d table %08X", dwSize, table);
		if (dwSize > 4 && table != NULL)
		{
			hwid_l[0] = hwid_l[0] ^ GetCRC32(table, dwSize);
			hwid_l[1] = hwid_l[1] ^ GetCRC32(table+2, dwSize-2);
			hwid_l[2] = hwid_l[2] ^ GetCRC32(table+4, dwSize-4);
			info("--- table 11 ----");
			PrintBuffer(table, dwSize, 16);
		}

		info("main hwid done, result: %08X %08X %08X", hwid_l[0], hwid_l[1], hwid_l[2]);
	}
	else
	{
		hwid_l[0] = GetHWIDchunk(1);
		hwid_l[1] = GetHWIDchunk(2);
		hwid_l[2] = GetHWIDchunk(3);

		info("secondary hwid done, result: %08X %08X %08X", hwid_l[0], hwid_l[1], hwid_l[2]);
	}

	g_HWID_Bak[0] = GetTickCount();
	g_HWID_Bak[1] = hwid_l[0] ^ g_HWID_Bak[0];
	g_HWID_Bak[2] = hwid_l[1] ^ g_HWID_Bak[0];
	g_HWID_Bak[3] = hwid_l[2] ^ g_HWID_Bak[0];

	hwid[0] = 0;
	hwid[1] = hwid_l[0];
	hwid[2] = hwid_l[1];
	hwid[3] = hwid_l[2];

	return true;

	VE();
}
DWORD GetHWIDchunk(int chunk)
{	VU("GetHWIDchunk");

	int res = -1;

	switch (chunk)
	{
	case 1:
		{
			//CPUID
			char cpudata[0x50];
			memset(cpudata, 0, 0x50);
				
			__asm
			{
				pushad
				lea edi, cpudata
				add edi, 0x4C
				mov esi, 0x80000004

				mov eax, 0x80000000
				cpuid
				cmp eax, esi
				jl errora
			loopa:
				mov eax, esi
				cpuid

				mov [edi], edx
				mov [edi-4], ecx
				mov [edi-8], ebx
				mov [edi-12], eax
				sub edi, 0x10

				dec esi
				cmp esi, 0x7FFFFFFF
				jne loopa

				mov res, 1
				jmp exita
			errora:
				mov res, 0
			exita:
				popad
			}

			PrintBuffer((BYTE *)cpudata, 0x50, 16);
			info("GetHWIDchunk(%d) %d res", chunk, res);

			if (res = 1) return GetCRC32(cpudata, 0x50);
		
			info("GetHWIDchunk() Fail, returning default for request %d.", chunk);
			return 0xBAADD00D;
		}
		break;
	case 2:
		{
			//windows installation date
			char windir[256];
			memset(windir, 0, 256);
			GetWindowsDirectoryA(windir, 255);
			info("GetHWIDchunk()  Windows folder = %s", windir);

			struct _stat32 f_stats; 

			if (_stat32(windir, &f_stats) == 0)
			{
				char timebuf[256];
				_ctime32_s(timebuf, 26, &f_stats.st_ctime);
				info("GetHWIDchunk() Windows folder (%s) creation date = %s", windir, timebuf);

				if (strstr(timebuf, V(" 201")) == NULL && strstr(timebuf, V(" 200")) == NULL) return 0xBAADD00D;

				return f_stats.st_ctime ^ GetCRC32(windir, 20);
			}


			info("GetHWIDchunk() Fail, returning default for request %d.", chunk);
			return 0xBAADD00D;
		}
		break;
	case 3:
		{
			char compname[256];
			memset(compname, 0, 256);
			DWORD maxlen = 256;
			GetComputerNameA(compname, &maxlen);

			return GetCRC32(compname, sizeof(compname));
		}
		break;
	default:
		return 0;
	}

	return 0;

	VE();
}