예제 #1
0
//==================================================================
// Constructor
//==================================================================
CByteArray::CByteArray( int size )
{
	// Allocate space
	m_codeBytes = (unsigned char *)malloc( size );

	if( m_codeBytes )
	{
		m_totalSize = size;

		// Fill with nops
		fill_nop(m_codeBytes, size);

		// Allow patching / execution
		SetMemPatchable(m_codeBytes, size);

		// Set index to 0
		m_curIndex = 0;

		// This was not an existing piece of memory.
		m_bExisting = false;
	}

	else
	{
		printf("Couldn't malloc space for CByteArray!\n");
		return;
	}

}
예제 #2
0
//==================================================================
// Constructor
//==================================================================
CByteArray::CByteArray( void *pMem, int size )
{
	m_codeBytes = NULL;
	m_curIndex = 0;

	if( !pMem )
	{
		printf("Null area of memory passed in!");
		return;
	}

	m_totalSize = size;
	m_codeBytes = (unsigned char *)pMem;
	m_bExisting = true;
	SetMemPatchable(m_codeBytes, m_totalSize);
}
예제 #3
0
void WarpMaxPlayers::Patch() {
	if(m_isPatched) return;

	int offset;

	g_pGameConf->GetMemSig("CTerrorPlayer_WarpGhostToInitialPosition", (void **)&m_pMaxPlayerCount);
	if( !m_pMaxPlayerCount ) {
		g_pSM->LogError(myself, "Can't get the \"CTerrorPlayer_WarpGhostToInitialPosition\" signature: %x", m_pMaxPlayerCount);
		return;
	}

	if( !g_pGameConf->GetOffset("WarpGhost_MaxPlayerCount", &offset) || !offset ) {
		g_pSM->LogError(myself, "WarpGhost -- Could not find 'WarpGhost_MaxPlayerCount' offset");
		return;
	}
	m_pMaxPlayerCount += offset;

	SetMemPatchable(m_pMaxPlayerCount, 1);
	assert(*m_pMaxPlayerCount == 3);
	*m_pMaxPlayerCount = static_cast<uint8_t>(TEAM_SIZE - 1);

	m_isPatched = true;
}