Beispiel #1
0
VOID DumpGDT()
{
	int i;
	GDTINFO gdtinfo;
	unsigned long gdtbase;
	PDESCRIPTOR_ENTRY pcgd_base;

	__asm sgdt gdtinfo
	gdtbase = MAKELONG(gdtinfo.BaseLow, gdtinfo.BaseHigh);
	
	DbgPrint("Rootkit: got GDT base address 0x%08X", gdtbase);
	conprintf("GDTBase=0x%08X  Limit=0x%04X\r\n", gdtbase, gdtinfo.BaseLimit);
	DbgPrint("Rootkit: sizeof( DESCRIPTOR_ENTRY ) %d", sizeof(DESCRIPTOR_ENTRY) );
	DbgPrint("Rootkit: sizeof( SUBTYPE ) %d", sizeof(SUBTYPE) );

	// enumerate all entries in the GDT
	// we can use the callgate descriptor structure because it
	// carries common members w/ other GDT entry types
	pcgd_base = (PDESCRIPTOR_ENTRY) gdtbase;
	for(i=1;i<=gdtinfo.BaseLimit>>3;i++)
	{
		conprintf("%04X    %24s  %08X  %08X  %d    %s\t%s \r\n",
					i * 8,
					GetDescriptorType(&pcgd_base[i]),
					0,
					0,
					pcgd_base[i].dpl,
					pcgd_base[i].present ? "P" : "NP",
					"??" );
	}
}
Beispiel #2
0
DWORD __stdcall MyCallGateFunction(PMYCALL_FRAME f)
{
	//conprintf(	"hello callgate, you passed:\r\n arg_0: 0x%08X \r\n arg_1: 0x%08X \r\n arg_2: 0x%08X \r\n arg_3: 0x%08X \r\n calling_eip: 0x%08X \r\n calling_cs: 0x%08X \r\n",
	//	f->arg_0,
	//	f->arg_1,
	//	f->arg_2,
	//	f->arg_3,
	//	f->calling_eip,
	//	f->calling_cs );

	conprintf("CALL_FRAME: 0x%08X\r\n", f);
	conprintf("arg_0: 0x%08X\r\n", f->arg_0);
	conprintf("arg_0: 0x%08X\r\n", f->arg_1);
	conprintf("arg_0: 0x%08X\r\n", f->arg_2);
	conprintf("arg_0: 0x%08X\r\n", f->arg_3);

	return 0;
}
Beispiel #3
0
EXPORT_C_(void) s2r_replay(HWND hwnd, HINSTANCE hinst, LPSTR filename, int nCmdShow)
{
#ifndef ENABLE_NEW_IOPDMA_SPU2
	int events=0;

	Running = true;

#ifdef WIN32
	AllocConsole();
	SetConsoleCtrlHandler(HandlerRoutine, TRUE);
	
	conprintf("Playing %s file on %x...",filename,hwnd);

#endif

	// load file
	FILE *file=fopen(filename,"rb");

	if(!file)
	{
		conprintf("Could not open the replay file.");
		return;
	}
	// if successful, init the plugin

#define TryRead(dest,size,count,file) if(fread(dest,size,count,file)<count) { conprintf("Error reading from file.");  goto Finish;  /* Need to exit the while() loop and maybe also the switch */ }

	TryRead(&CurrentIOPCycle,4,1,file);
	
	replay_mode=true;

	InitWaitSync(); // Initialize the WaitSync stuff

	SPU2init();
	SPU2irqCallback(dummy1,dummy4,dummy7);
	SPU2setClockPtr(&CurrentIOPCycle);
	SPU2open(&hwnd);

	CurrentIOPCycle=0;

	SPU2async(0);

	while(!feof(file) && Running)
	{
		u32 ccycle=0;
		u32 evid=0;
		u32 sval=0;
		u32 tval=0;

		TryRead(&ccycle,4,1,file);
		TryRead(&sval,4,1,file);

		evid=sval>>29;
		sval&=0x1FFFFFFF;

		u32 TargetCycle = ccycle * 768;

		while(TargetCycle > CurrentIOPCycle)
		{
			u32 delta = WaitSync(TargetCycle);
			SPU2async(delta);
		}
		
		switch(evid)
		{
		case 0:
			SPU2read(sval);
			break;
		case 1:
			TryRead(&tval,2,1,file);
			SPU2write(sval,tval);
			break;
		case 2:
			TryRead(dmabuffer,sval,2,file);
			SPU2writeDMA4Mem(dmabuffer,sval);
			break;
		case 3:
			TryRead(dmabuffer,sval,2,file);
			SPU2writeDMA7Mem(dmabuffer,sval);
			break;
		default:
			// not implemented
			return;
			break;
		}
		events++;
	}

Finish:

	//shutdown
	SPU2close();
	SPU2shutdown();
	fclose(file);

	conprintf("Finished playing %s file (%d cycles, %d events).",filename,CurrentIOPCycle,events);

#ifdef WIN32
	FreeConsole();
#endif

	replay_mode=false;
#endif
}