Article View: comp.std.c
Article #2344pointers to functions, dereferencing, first byte of func
From: Donald McLachlan
Date: Wed, 30 Jan 1991 03:13
Date: Wed, 30 Jan 1991 03:13
24 lines
1017 bytes
1017 bytes
I recently wanted to write a nastly bit of code for a PC (self modifying) so ... char *c; extern char func(); c = func; some code putting new hex values into the address space of the function now for the fun stuff. Under microsoft C, c[1] ... c[MAX_INT] worked, but c[0] would sometimes bugger me up. *c had the exact same unreliable results (as it should since *c is supposed to be identicle to c[0]). what I had to do to get at the first byte of executable code was ... char *c1; c1 = &(c[1]); --c1; /* should equal c[0] */ *c1 = char constant. hows that for bastardising code to fool a compiler!!!
Technical Details
Message-ID:
<1991Jan30.031315.9427@dgbt.doc.ca>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!cunews!dgbt!donShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!dgbt!don From: don@dgbt.doc.ca (Donald McLachlan) Subject: pointers to functions, dereferencing, first byte of func Message-ID: <1991Jan30.031315.9427@dgbt.doc.ca> Sender: don@dgbt.doc.ca (Donald McLachlan) Organization: The Communications Research Centre, Ottawa, Canada Distribution: na Date: Wed, 30 Jan 91 03:13:15 GMT