Exemplo n.º 1
0
int Assembl(char *answer,ulong parm) {
  int i,j,k,n,good;
  char s[TEXTLEN];
  t_asmmodel model,attempt;
  t_memory *pmem;
  t_dump *pasm;
  // Visualize changes.
  Setcpu(0,address,0,0,CPU_ASMHIST|CPU_ASMCENTER);
  if (string[0]=='\0')                 // No immediate command
    Sendshortcut(PM_DISASM,address,WM_CHAR,0,0,' ');
  else {
    // Assemble immediate command. If there are several possible encodings,
    // select the shortest one.
    model.length=0;
    for (j=0; ; j++) {                 // Try all possible encodings
      good=0;
      for (k=0; k<4; k++) {            // Try all possible constant sizes
        n=Assemble(string,address,&attempt,j,k,model.length==0?answer:s);
        if (n>0) {
          good=1;
          // If another decoding is found, check if it is shorter.
          if (model.length==0 || n<model.length)
            model=attempt;             // Shortest encoding so far
          ;
        };
      };
      if (good==0) break;              // No more encodings
    };
    if (model.length==0)
      return -1;                       // Invalid command
    // Check for imprecise parameters.
    k=model.mask[0];
    for (i=1; i<model.length; i++) k&=model.mask[i];
    if (k!=0xFF) {
      strcpy(answer,"Command contains imprecise operands");
      return -1; };
    // If there is no backup copy, create it. Dump window always assumes that
    // backup has the same base and size as the dump, so check it to avoid
    // strange ireproducible errors.
    pmem=Findmemory(address);
    if (pmem==NULL) {
      //strcpy(answer,"Attempt to assemble to non-existing memory");
      wsprintf(answer,"%X",model.code[0]);
      for(i=1; i<model.length; i++) {
        wsprintf(answer,"%s%X",answer,model.code[i]);
      }
      return -1; };
    pasm=(t_dump *)Plugingetvalue(VAL_CPUDASM);
    if (pasm!=NULL && pmem->copy==NULL && pmem->base==pasm->base && pmem->size==pasm->size)
      Dumpbackup(pasm,BKUP_CREATE);
    // Now write assembled code to memory.
    Writememory(model.code,address,model.length,MM_RESTORE|MM_DELANAL);
  };
  return 0;
};
Exemplo n.º 2
0
bool ESPRun(void)
{
    DWORD EIP,ESP,ESP2;
	ulong cpuid;

    cpuid = Getcputhreadid();

	t_thread *pt = Findthread(cpuid);
    EIP = pt->reg.ip;
	ESP = pt->reg.r[4];

/*
    char code[2]={0};
	char pushad=0x60;
	char pushaf=0x9c;
	uint pushwf=0x669c;

   	Readmemory(code,EIP,1,MM_RESTORE);
	t_status st =  Getstatus();
	
	try
	{
		while(code[0] != pushad)
		{

          int er=Go(cpuid, 0, STEP_IN, 1, 1);
		  st =  Getstatus();
		  Suspendprocess(cpuid);
		  t_thread *pt = Findthread(cpuid);
		  EIP = pt->reg.ip;
		  Readmemory(code,EIP,1,MM_RESTORE);
		  Runsinglethread(cpuid);
		  st =  Getstatus();
		}
	}

	catch (...)
	{
		cout <<"error";
		exit(100);
	}


    ESP2 = pt->reg.r[4];
	DWORD tmpesp =ESP2 - 8;
*/
	ESP=ESP-0x04;
	Sethardwarebreakpoint(ESP, 1, HB_WRITE);
	Sendshortcut(PM_MAIN, 0, WM_KEYDOWN, 0, 1, VK_F9); 

    return true;
}
Exemplo n.º 3
0
int Dorigin(char *answer,ulong parm) {
  Sendshortcut(PM_DISASM,0,WM_CHAR,0,0,'*');
  return 0;
};