Message-ID: Date: Mon, 30 Aug 1999 14:42:24 +0100 To: Eli Zaretskii Cc: djgpp AT delorie DOT com From: Dave Bird Subject: Re: Error General Fault Protection on quit??? References: <$QodhXALbXy3EwjC AT xemu DOT demon DOT co DOT uk> In-Reply-To: MIME-Version: 1.0 X-Mailer: Turnpike (32) Version 4.01 Reply-To: djgpp AT delorie DOT com In message , Eli Zaretskii writes >> I don't know whether it is possible to right a function which >> tests for an invalid pointer without bombing. > >How about this (UNTESTED)? > > void validate_or_die (void *ptr) > { > if ( (unsigned)p < 0x1000) > abort (); > } Sounds possible... I'd prefer to log or report rather than abort, and is there an upper limit?? Also to have it as a test you could put, at least at infrequently used gateways. Also to report IP and pointer variable used, which helps if it's in some static or auto variable [though is less help in some dynamically allocated item]. const void *LO_LIMIT=0x1000 void *HI_LIMIT=0; //assign value int verify(void **PtrLoc){ void *Ptr=(*PtrLoc), *Rtn=NULL; asm( 'mov (%ebp+4),%eax\r', 'mov %eax,(Rtn)\r' //syntax????? : : %eax : //????? ); if( LO_LIMIT <= (unsigned)Ptr && (unsigned)Ptr < HI_LIMIT){ ; return 1; }; printf("Instr@%x used Pointer @%x contains %x",Rtn,PtrLoc,Loc); printf(" outside range %x to %x\n", LO_LIMIT, HI_LIMIT); ; return 0; }; Assuming of course that RhinoHIDE can turn a numerical code address back to a function name, and data address back to a variable name. -- ^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/ (..)__u news:alt.smoking.mooses