Пример #1
0
void createSegment(unsigned int start, unsigned int size, unsigned char *content, 
                   unsigned int clen, const char *name) {
   segment_t s;
   //create ida segment to hold headers
   memset(&s, 0, sizeof(s));
   s.startEA = start;
   s.endEA = start + size;
   s.align = saRelPara;
   s.comb = scPub;
   s.perm = SEGPERM_WRITE | SEGPERM_READ;
   s.bitness = 1;
   s.type = SEG_DATA;
   s.color = DEFCOLOR;
   if (add_segm_ex(&s, name, "DATA", ADDSEG_QUIET | ADDSEG_NOSREG)) {
      //zero out the newly created segment
      for (ea_t ea = s.startEA; ea < s.endEA; ea++) {
         patch_byte(ea, 0);
      }
      if (content) {
         patch_many_bytes(s.startEA, content, clen ? clen : size);
      }
#ifdef DEBUG
      msg("segment created %x-%x\n", s.startEA, s.endEA);
#endif
   }
   else {
#ifdef DEBUG
      msg("seg create failed\n");
#endif
   }
}
void IDAMemCopyPaste::paste_buffer(ea_t eaStartAddr, ea_t eaEndAddr) 
{
	ssize_t size;

	// Work out the size, make sure it doesn't exceed the buffer
	// we have allocated.
	size = eaEndAddr - eaStartAddr;
	if (size > MAX_COPYPASTE)
	{
		warning("You can only copy a max of %d bytes\n", MAX_COPYPASTE);
		return;
	}
	// Patch the binary (paste)
	patch_many_bytes(eaStartAddr, data, size);
	msg("Patched %d bytes at %a.\n", size, eaStartAddr); 
}
Пример #3
0
/*
#<pydoc>
def assemble(ea, cs, ip, use32, line):
    """
    Assemble an instruction into the database (display a warning if an error is found)
    @param ea: linear address of instruction
    @param cs: cs of instruction
    @param ip: ip of instruction
    @param use32: is 32bit segment?
    @param line: line to assemble

    @return: Boolean. True on success.
    """
#</pydoc>
*/
bool assemble(
      ea_t ea,
      ea_t cs,
      ea_t ip,
      bool use32,
      const char *line)
{
  int inslen;
  char buf[MAXSTR];
  PYW_GIL_CHECK_LOCKED_SCOPE();
  bool rc = false;
  Py_BEGIN_ALLOW_THREADS;
  if (ph.notify != NULL)
  {
    inslen = ph.notify(ph.assemble, ea, cs, ip, use32, line, buf);
    if (inslen > 0)
    {
      patch_many_bytes(ea, buf, inslen);
      rc = true;
    }
  }
  Py_END_ALLOW_THREADS;
  return rc;
}