Exemple #1
0
//------------------------------------------------------------------------------------------
//	Function name:	HookAPI
//	Description:	Hooking the real functions and our intercepted ones.
//------------------------------------------------------------------------------------------
void HookAPI()
{
	if(DetourTransactionBegin() != NO_ERROR)
	{
		LOGFILE("Hook Transcation Failed");	
		exit(-1);
	}
	DetourUpdateThread(GetCurrentThread());
	if(DetourAttach(&(PVOID&)Real_Direct3DCreate9, Mine_Direct3DCreate9) != NO_ERROR)
	{
		LOGFILE("Hook Directx 3d Failed");	
		exit(-1);
	}
	/*if(DetourAttach(&(PVOID&)Real_CreateWindowExA,Mine_CreateWindowExA) != NO_ERROR)
	{
		LOGFILE("Hook CreateWindowsExA Failed");	
		exit(-1);
	}
	if(DetourAttach(&(PVOID&)Real_CreateWindowExW, Mine_CreateWindowExW) != NO_ERROR)
	{
		LOGFILE("Hook CreateWindowsExw Failed");	
		exit(-1);
	}*/

	if(DetourTransactionCommit() != NO_ERROR)
	{
		LOGFILE("Hook Transcation Commit Failed");	
		exit(-1);
	}
	
}
static void log_frame(char *tag, uint8_t *data)
{
	int i;

	LOGFILE("%s", tag);
	for (i = 0; i < 23; i++)
		LOGFILE(" %02x", *data++);
	LOGFILE("\n");
}
Exemple #3
0
//------------------------------------------------------------------------------------------
//	Function name:	Mine_Direct3DCreate9
//	Description:	The trampoline for Direct3DCreate9 call. In it we create our own IDirect3D9 
//					object, which inherits IDirect3D9. It enables us to manipulate calls used
//					for this device as we are the middle man in this configuration.
//	Parameters:		SDKVersion : The SDK version for us to use.
//	Returns:		Our IDirect3D9 instance which encapsulate a real IDirect3D9
//------------------------------------------------------------------------------------------
IDirect3D9* WINAPI Mine_Direct3DCreate9(UINT SDKVersion)
{
	LOGFILE("Direct3DCreate9 called.\n");
	IDirect3D9* Direct3D = Real_Direct3DCreate9(SDKVersion);
	IDirect3D9* Mine_Direct3D = new Direct3D9Wrapper(Direct3D);
	return Mine_Direct3D;
}
static void log_pm(void)
{
	int count = 0, i;

	LOGFILE("[power]\n");
	log_time();
	log_gps();
	for (i = 0; i <= 1023; i++) {
		if ((pm[i].flags & INFO_FLG_PM)) {
			if (!count)
				LOGFILE("arfcn %d", i);
			LOGFILE(" %d", pm[i].rxlev);
			count++;
			if (count == 12) {
				LOGFILE("\n");
				count = 0;
			}
		} else {
			if (count) {
				LOGFILE("\n");
				count = 0;
			}
		}
	}
	if (count)
		LOGFILE("\n");

	LOGFILE("\n");
	LOGFLUSH();
}
static void log_time(void)
{
	time_t now;

	if (g.enable && g.valid)
		now = g.gmt;
	else
		time(&now);
	LOGFILE("time %lu\n", now);
}
static void log_sysinfo(void)
{
	struct rx_meas_stat *meas = &ms->meas;
	struct gsm48_sysinfo *s = &sysinfo;
	int8_t rxlev;
	char ta_str[32] = "";

	if (log_si.ta != 0xff)
		sprintf(ta_str, " TA=%d", log_si.ta);

	LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
		arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
		gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);

	LOGFILE("[sysinfo]\n");
	LOGFILE("arfcn %d\n", s->arfcn);
	log_time();
	log_gps();
	LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
	rxlev = meas->rxlev / meas->frames - 110;
	LOGFILE("rxlev %d\n", rxlev);
	if (s->si1)
		log_frame("si1", s->si1_msg);
	if (s->si2)
		log_frame("si2", s->si2_msg);
	if (s->si2bis)
		log_frame("si2bis", s->si2b_msg);
	if (s->si2ter)
		log_frame("si2ter", s->si2t_msg);
	if (s->si3)
		log_frame("si3", s->si3_msg);
	if (s->si4)
		log_frame("si4", s->si4_msg);
	if (log_si.ta != 0xff)
		LOGFILE("ta %d\n", log_si.ta);

	LOGFILE("\n");
	LOGFLUSH();
}
HRESULT	myIDirect3DDevice8::copyDataToMemory(IDirect3DDevice8* device)
{
	performanceDebugClock=clock();
	//===============Memory Check=======================
	HRESULT hRes = S_FALSE;
	if(badMemory)
	{
		DXLOG("Sorry !Memory!");
	
		return S_FALSE;
	}
	if(lpvMem==NULL)//Memory INIT;
	{
		badMemory=!setupSharedMemory();
		if(badMemory)
		{
			DXLOG("Sorry !Memory!");
			return S_FALSE;
		}
	}
	if(!isMemoryWritable())
	{
		DXLOG("Memory not writable");
		return S_FALSE;
	}
	//================FPS CHECK========================
	if(lastRecordTime==0)
	{
		lastRecordTime=clock();
	}
	else
	{
		long inteval=clock()-lastRecordTime;
		if(inteval<1000/MAXFPS)
		{
			//DXLOG("FPS QUICK");
			return S_FALSE;
		}
		else
		{
			//DXLOG("FPS OK");
			lastRecordTime=clock();
		}
	}
	//=================================================
	IDirect3DSurface8 *pBackBuffer;
	
	if (FAILED(device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) 
	{
		DXLOG("PBACKBUFEER");
		return hRes;
	}
	D3DSURFACE_DESC surfaceDesc;
	pBackBuffer->GetDesc(&surfaceDesc);
	dumpSurfaceSettings(surfaceDesc);
	if(pSurfLocal==NULL)
	{
		DXLOG("SURFLOCAL CREATING");
		
		hRes = device->CreateImageSurface(surfaceDesc.Width,// RWIDTH,
												surfaceDesc.Height,//RHEIGHT,
												surfaceDesc.Format,
												&pSurfLocal);
		if (FAILED(hRes))
		{
			DXLOG("SURFLOCAL CREATING FAILED");
			SafeRelease(pBackBuffer);
			return hRes;
		}
		
	}
	
	hRes=device->CopyRects(pBackBuffer,NULL,0,pSurfLocal,NULL);
	if (FAILED(hRes))
	{
		DXLOG("COPY RECT FAILED");
		SafeRelease(pBackBuffer);
		return hRes;
	}
	//device->GetRenderTargetData(pBackBuffer, pSurfLocal);
	
	D3DLOCKED_RECT lockedRect;
	if(FAILED(pSurfLocal->LockRect(&lockedRect, NULL, D3DLOCK_READONLY)))
	{
			DXLOG("Lock FAILED");
			SafeRelease(pBackBuffer);
			return hRes;
	}
	
	//================BPP ADJUSTMENT=====================
	UINT bpp=4;
	int bppformat=-1;
	switch(surfaceDesc.Format)
	{

		case D3DFMT_R5G6B5:
			bpp = 2;
			bppformat=2;
			break;
		case D3DFMT_X1R5G5B5:
			bpp = 2;
			bppformat=3;
			break;
		case D3DFMT_A8R8G8B8:
		case D3DFMT_X8R8G8B8:
			bpp = 4;
			bppformat=1;
			break;
		default:
			bpp = 4;
			bppformat=1;
			break;//Most cards are gonna support A8R8G8B8/X8R8G8B8 anyway
	}
	UINT copySize=surfaceDesc.Width*surfaceDesc.Height*bpp;
	UINT surfaceHeight=surfaceDesc.Height;
	UINT surfaceWidth=surfaceDesc.Width;
	//======================Memory Copy=============================
	memcpy(lpvMem+(SHAREDMEMSIZE-RESERVEDMEMORY)/8,(void *)&copySize,sizeof(UINT));
	memcpy(lpvMem+(SHAREDMEMSIZE-RESERVEDMEMORY)/8+sizeof(UINT),(void *)&surfaceHeight,sizeof(UINT));
	memcpy(lpvMem+(SHAREDMEMSIZE-RESERVEDMEMORY)/8+sizeof(UINT)*2,(void *)&surfaceWidth,sizeof(UINT));
	memcpy(lpvMem+(SHAREDMEMSIZE-RESERVEDMEMORY)/8+sizeof(UINT)*3,(void *)&bppformat,sizeof(int));
	memcpy(lpvMem, lockedRect.pBits,copySize);
	setMemoryReadable();
	//===================================================
	pSurfLocal->UnlockRect();
	SafeRelease(pBackBuffer);
	LOGFILE(clock()-performanceDebugClock);
	return hRes;
}
static void log_gps(void)
{
	if (!g.enable || !g.valid)
		return;
	LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
}