Ejemplo n.º 1
0
void CRecordingEngExtInterceptor::SteamAPI_UnregisterCallResult(class CCallbackBase *pCallback, SteamAPICall_t hAPICall)
{
	CSteamCallbackRecordingWrapper* wrappee = getOrCreateCallbackWrapper(pCallback);

	if (wrappee->GetFlags() != pCallback->GetFlags()) rehlds_syserror("%s: flags desync", __FUNCTION__);
	if (wrappee->GetICallback() != pCallback->GetICallback()) rehlds_syserror("%s: flags desync", __FUNCTION__);

	CSteamApiUnrigestierCallResultCall fcall(wrappee->getRehldsCallbackId(), hAPICall, wrappee); CRecorderFuncCall frec(&fcall);
	
	PushFunc(&frec);
	
	m_BasePlatform->SteamAPI_UnregisterCallResult(wrappee, hAPICall);
	
	fcall.setResult(wrappee);
	pCallback->SetFlags(wrappee->GetFlags());
	pCallback->SetICallback(wrappee->GetICallback());

	PopFunc(&frec);
}
IGameClient* GetRehldsApiClient(client_t* cl)
{
	int idx = cl - g_psvs.clients;
	if (idx < 0 || idx >= g_psvs.maxclients)
	{
		rehlds_syserror(__FUNCTION__": Invalid client index %d", idx);
	}

	return g_GameClients[idx];
}
Ejemplo n.º 3
0
CRehldsFlightRecorder::CRehldsFlightRecorder() {
	m_MetaRegion = (uint8*) sys_allocmem(META_REGION_SIZE);
	m_DataRegion = (uint8*) sys_allocmem(DATA_REGION_SIZE);

	if (!m_MetaRegion || !m_DataRegion) {
		rehlds_syserror("%s: direct allocation failed", __FUNCTION__);
	}

	//initialize meta region header
	char* metaPos = (char*)m_MetaRegion;
	const char* metaSignature = "REHLDS_FLIGHTREC_META";
	metaPos += sprintf(metaPos, "%s%s%s:", metaSignature, metaSignature, metaSignature);

	m_pMetaHeader = (meta_header*)metaPos;
	metaPos += sizeof(meta_header);
	m_pRecorderState = (recorder_state*)metaPos;
	metaPos += sizeof(recorder_state);

	if ((metaPos - (char*)m_MetaRegion) > META_REGION_HEADER) {
		rehlds_syserror("%s: Meta header overflow", __FUNCTION__);
	}

	//initialize data region header
	char* dataPos = (char*)m_DataRegion;
	const char* dataSignature = "REHLDS_FLIGHTREC_DATA";
	dataPos += sprintf(dataPos, "%s%s%s:", dataSignature, dataSignature, dataSignature);

	m_pDataHeader = (data_header*)dataPos;
	dataPos += sizeof(data_header);

	if ((dataPos - (char*)m_pDataHeader) > DATA_REGION_HEADER) {
		rehlds_syserror("%s: Data header overflow", __FUNCTION__);
	}

	InitHeadersContent();

	m_MetaRegionPtr = m_MetaRegion + META_REGION_HEADER;
	m_DataRegionPtr = m_DataRegion + DATA_REGION_HEADER;
}
Ejemplo n.º 4
0
void CRehldsFlightRecorder::StartMessage(uint16 msg, bool entrance) {
	if (msg == 0 || msg > m_pMetaHeader->numMessages) {
		rehlds_syserror("%s: Invalid message id %u", __FUNCTION__, msg);
	}

	if (entrance) {
		msg = msg | 0x8000;
	}

	if (m_pRecorderState->curMessage != 0) {
		rehlds_syserror("%s: overlapping messages", __FUNCTION__);
	}

	unsigned int sz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (sz < 6) {
		MoveToStart();
	}

	m_pRecorderState->curMessage = msg;
	m_pRecorderState->lastMsgBeginPos = m_pRecorderState->wpos;
	*(uint16*)(m_DataRegionPtr + m_pRecorderState->wpos) = msg;
	m_pRecorderState->wpos += 2;
}
Ejemplo n.º 5
0
void CRehldsFlightRecorder::EndMessage(uint16 msg, bool entrance) {
	if (entrance) {
		msg = msg | 0x8000;
	}

	if (m_pRecorderState->curMessage != msg) {
		rehlds_syserror("%s: invalid message %u", __FUNCTION__, msg);
	}

	unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (freeSz < 2) {
		MoveToStart();
	}

	unsigned int msgSize = m_pRecorderState->wpos - m_pRecorderState->lastMsgBeginPos;
	if (msgSize > MSG_MAX_SIZE) {
		rehlds_syserror("%s: too big message %u; size%u", __FUNCTION__, msg, msgSize);
	}
	*(uint16*)(m_DataRegionPtr + m_pRecorderState->wpos) = msgSize;
	m_pRecorderState->wpos += 2;

	m_pRecorderState->curMessage = 0;
}
Ejemplo n.º 6
0
void CRehldsFlightRecorder::WriteBuffer(const void* data, unsigned int len) {
	if (m_pRecorderState->curMessage == 0) {
		rehlds_syserror("%s: Could not write, invalid state", __FUNCTION__);
	}

	CheckSize(len);
	unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (freeSz < len) {
		MoveToStart();
	}

	memcpy(m_DataRegionPtr + m_pRecorderState->wpos, data, len);
	m_pRecorderState->wpos += len;
}
Ejemplo n.º 7
0
void CRecordingEngExtInterceptor::PopFunc(CRecorderFuncCall* func)
{
	if (func != m_LastFunc)
		rehlds_syserror("%s: stack corrupted", __FUNCTION__);

	writeCall(!func->m_StartWritten, true, func->m_FuncCall);
	if (m_LastFunc->m_Prev == NULL) {
		m_LastFunc = m_RootFunc = NULL;
	}
	else
	{
		m_LastFunc = m_LastFunc->m_Prev;
		m_LastFunc->m_Next = NULL;
	}
}
Ejemplo n.º 8
0
bool CSteamAppsRecordingWrapper::BIsVACBanned()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return false;
}
Ejemplo n.º 9
0
HAuthTicket CSteamGameServerRecordingWrapper::GetAuthSessionTicket(void *pTicket, int cbMaxTicket, uint32 *pcbTicket)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_HAuthTicketInvalid;
}
Ejemplo n.º 10
0
int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *filename)
#endif // REHLDS_FIXES
{
	int chunksize;
	int compressedFileTime;
	FileHandle_t hfile;
	signed int filesize;
	int remaining;
	fragbufwaiting_t *p;
	int send;
	fragbuf_t *buf;
	char compressedfilename[MAX_PATH];
	qboolean firstfragment;
	int bufferid;
	qboolean bCompressed;
	int pos;
	fragbufwaiting_t *wait;
	int uncompressed_size;

	bufferid = 1;
	firstfragment = TRUE;
	bCompressed = FALSE;
	chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);

	Q_snprintf(compressedfilename, sizeof compressedfilename, "%s.ztmp", filename);
	compressedFileTime = FS_GetFileTime(compressedfilename);
	if (compressedFileTime >= FS_GetFileTime(filename) && (hfile = FS_Open(compressedfilename, "rb")))
	{
		filesize = FS_Size(hfile);
		FS_Close(hfile);
		bCompressed = TRUE;
		hfile = FS_Open(filename, "rb");
		if (!hfile)
		{
			Con_Printf("Warning:  Unable to open %s for transfer\n", filename);
			return 0;
		}

		uncompressed_size = FS_Size(hfile);
		if (uncompressed_size > sv_filetransfermaxsize.value)
		{
			FS_Close(hfile);
			Con_Printf("Warning:  File %s is too big to transfer from host %s\n", filename, NET_AdrToString(chan->remote_address));
			return 0;
		}
	}
	else
	{
		hfile = FS_Open(filename, "rb");
		if (!hfile)
		{
			Con_Printf("Warning:  Unable to open %s for transfer\n", filename);
			return 0;
		}
		filesize = FS_Size(hfile);
		if (filesize > sv_filetransfermaxsize.value)
		{
			FS_Close(hfile);
			Con_Printf("Warning:  File %s is too big to transfer from host %s\n", filename, NET_AdrToString(chan->remote_address));
			return 0;
		}

		uncompressed_size = filesize;
		if (sv_filetransfercompression.value != 0.0)
		{
			unsigned char* uncompressed = (unsigned char*)Mem_Malloc(filesize);
			unsigned char* compressed = (unsigned char*)Mem_Malloc(filesize);
			unsigned int compressedSize = filesize;
			FS_Read(uncompressed, filesize, 1, hfile);
			if (BZ_OK == BZ2_bzBuffToBuffCompress((char*)compressed, &compressedSize, (char*)uncompressed, filesize, 9, 0, 30))
			{
				FileHandle_t destFile = FS_Open(compressedfilename, "wb");
				if (destFile)
				{
					Con_DPrintf("Creating compressed version of file %s (%d -> %d)\n", filename, filesize, compressedSize);
					FS_Write(compressed, compressedSize, 1, destFile);
					FS_Close(destFile);
					filesize = compressedSize;
					bCompressed = TRUE;
				}
			}
			Mem_Free(uncompressed);
			Mem_Free(compressed);
		}
	}
	FS_Close(hfile);

	wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu);
	remaining = filesize;
	pos = 0;

	while (remaining)
	{
		send = min(chunksize, remaining);
		buf = Netchan_AllocFragbuf();
		if (!buf)
		{
			Con_Printf("Couldn't allocate fragbuf_t\n");
			Mem_Free(wait);
			if (server)
			{
#ifdef REHLDS_FIXES
				SV_DropClient(&g_psvs.clients[chan->player_slot - 1], 0, "Malloc problem");
#else // REHLDS_FIXES
				SV_DropClient(host_client, 0, "Malloc problem");
#endif // REHLDS_FIXES
				return 0;
			}
			else
			{
				rehlds_syserror("%s: Reverse clientside code", __func__);
				//return 0;
			}
		}

		buf->bufferid = bufferid++;
		SZ_Clear(&buf->frag_message);
		if (firstfragment)
		{
			firstfragment = FALSE;
			MSG_WriteString(&buf->frag_message, filename);
			MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
			MSG_WriteLong(&buf->frag_message, uncompressed_size);
			send -= buf->frag_message.cursize;
		}
		buf->isfile = TRUE;
		buf->iscompressed = bCompressed;
		buf->size = send;
		buf->foffset = pos;

		Q_strncpy(buf->filename, filename, MAX_PATH - 1);
		buf->filename[MAX_PATH - 1] = 0;

		pos += send;
		remaining -= send;

		Netchan_AddFragbufToTail(wait, buf);
	}

	if (!chan->waitlist[FRAG_FILE_STREAM])
	{
		chan->waitlist[FRAG_FILE_STREAM] = wait;
	}
	else
	{
		p = chan->waitlist[FRAG_FILE_STREAM];
		while (p->next)
			p = p->next;

		p->next = wait;
	}

	return 1;
}
Ejemplo n.º 11
0
ISteamHTTP* __cdecl SteamHTTP_hooked()
{
	rehlds_syserror("%s: not implemented", __func__);
	//return NULL;
}
Ejemplo n.º 12
0
void __cdecl SteamAPI_Shutdown_hooked()
{
	rehlds_syserror("%s: not implemented", __func__);
}
Ejemplo n.º 13
0
void __cdecl SteamAPI_SetMiniDumpComment_hooked(const char *pchMsg)
{
	rehlds_syserror("%s: not implemented", __func__);
}
Ejemplo n.º 14
0
void CSteamGameServerRecordingWrapper::GetGameplayStats()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
Ejemplo n.º 15
0
bool CSteamGameServerRecordingWrapper::RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return false;
}
Ejemplo n.º 16
0
EUserHasLicenseForAppResult CSteamGameServerRecordingWrapper::UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_EUserHasLicenseResultDoesNotHaveLicense;
}
Ejemplo n.º 17
0
void CSteamGameServerRecordingWrapper::CancelAuthTicket(HAuthTicket hAuthTicket)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
Ejemplo n.º 18
0
void CSteamGameServerRecordingWrapper::EndAuthSession(CSteamID steamID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
Ejemplo n.º 19
0
EBeginAuthSessionResult CSteamGameServerRecordingWrapper::BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_EBeginAuthSessionResultInvalidTicket;
}
Ejemplo n.º 20
0
void CSteamGameServerRecordingWrapper::SetGameData(const char *pchGameData)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
Ejemplo n.º 21
0
const char* CSteamAppsRecordingWrapper::GetAvailableGameLanguages()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return NULL;
}
Ejemplo n.º 22
0
SteamAPICall_t CSteamGameServerRecordingWrapper::GetServerReputation()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
Ejemplo n.º 23
0
void __cdecl SteamAPI_WriteMiniDump_hooked(uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID)
{
	rehlds_syserror("%s: not implemented", __func__);
}
Ejemplo n.º 24
0
uint32 CSteamGameServerRecordingWrapper::GetPublicIP()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return 0;
}
Ejemplo n.º 25
0
void __cdecl SteamAPI_RegisterCallResult_hooked(class CCallbackBase *pCallback, SteamAPICall_t hAPICall)
{
	rehlds_syserror("%s: not implemented", __func__);
}
Ejemplo n.º 26
0
SteamAPICall_t CSteamGameServerRecordingWrapper::AssociateWithClan(CSteamID steamIDClan)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
Ejemplo n.º 27
0
void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, const char *filename, unsigned char *uncompressed_pbuf, int uncompressed_size)
{
	int chunksize;
	int send;
	fragbufwaiting_t *p;
	fragbuf_t *buf;
	unsigned char *pbuf;
	qboolean bCompressed;
	qboolean firstfragment;
	signed int bufferid;
	int remaining;
	int pos;
	unsigned int size;
	fragbufwaiting_t *wait;

	if (!uncompressed_size)
		return;

	bufferid = 1;
	firstfragment = TRUE;
	size = uncompressed_size;

	pbuf = (unsigned char *)Mem_Malloc(uncompressed_size);
	if (BZ2_bzBuffToBuffCompress((char*)pbuf, &size, (char*)uncompressed_pbuf, uncompressed_size, 9, 0, 30))
	{
		bCompressed = FALSE;
		Mem_Free(pbuf);
		pbuf = uncompressed_pbuf;
		size = uncompressed_size;
	}
	else
	{
		bCompressed = TRUE;
		Con_DPrintf("Compressed %s for transmission (%d -> %d)\n", filename, uncompressed_size, size);
	}

	chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);
	send = chunksize;
	wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu);
	remaining = size;
	pos = 0;

	while (remaining > 0)
	{
		send = min(remaining, chunksize);
		buf = (fragbuf_t *)Netchan_AllocFragbuf();
		if (!buf)
		{
			Con_Printf("Couldn't allocate fragbuf_t\n");
			Mem_Free(wait);
			if (server)
				SV_DropClient(host_client, 0, "Malloc problem");
			else
				rehlds_syserror("%s:Reverse me: client-side code", __func__);

#ifdef REHLDS_FIXES
			if (bCompressed) {
				Mem_Free(pbuf);
			}
#endif
			return;
		}

		buf->bufferid = bufferid++;
		SZ_Clear(&buf->frag_message);
		if (firstfragment)
		{
			firstfragment = FALSE;
			MSG_WriteString(&buf->frag_message, filename);
			MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
			MSG_WriteLong(&buf->frag_message, uncompressed_size);
			send -= buf->frag_message.cursize;
		}

		buf->isbuffer = TRUE;
		buf->isfile = TRUE;
		buf->size = send;
		buf->foffset = pos;

		MSG_WriteBuf(&buf->frag_message, send, &pbuf[pos]);
		pos += send;
		remaining -= send;

		Netchan_AddFragbufToTail(wait, buf);
	}

	if (!chan->waitlist[FRAG_FILE_STREAM]) {
		chan->waitlist[FRAG_FILE_STREAM] = wait;
	}
	else
	{
		p = chan->waitlist[FRAG_FILE_STREAM];
		while (p->next)
			p = p->next;

		p->next = wait;
	}

#ifdef REHLDS_FIXES
	if (bCompressed) {
		Mem_Free(pbuf);
	}
#endif
}
Ejemplo n.º 28
0
SteamAPICall_t CSteamGameServerRecordingWrapper::ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
Ejemplo n.º 29
0
void CSteamGameServerRecordingWrapper::ForceHeartbeat()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
Ejemplo n.º 30
0
void CSteamGameServerRecordingWrapper::SetRegion(const char *pszRegion)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}