Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Can your C compiler do this:

Name: Anonymous 2010-05-15 15:06


int main()
{
  int *p;
  p  = 0;
  *p = 0;
  return 0;
}


?

Name: Anonymous 2010-05-16 0:20

>>18
Why is it a horrible idea?
It would certainly be fixed to a CPU and an OS, but it's most certainly doable.

On Win32, I'd make a SEH or VEH handler which catches access violations (EXCEPTION_ACCESS_VIOLATION), then I would access the ExceptionInformation field of the EXCEPTION_RECORD structure and see what the address is. If the address is 0, I would have to use a disassembler(or hardcode the disassembly if it's simple enough) and check what the instruction at EIP is. Depending on the instruction, it would do the things it expected you to do (dereferencing with writing would get the exception passed up, if it's just reading, return a pointer to some nulls, so you'd get your empty string).

As you can see, this behaviour is perfectly achievable, but obtaining it is very platform specific.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List