Hardcoding main() as main[]

MosaicFuneral 0 Tallied Votes 140 Views Share

Useless novelty code.

#include <stdio.h>

#if !(defined __i386__ || defined _M_IX86)
  #error Unknown target platform.

int rerun = 0;

int real_code()
    if(rerun) return(0);



#ifdef _MSC_VER
#pragma warning(disable : 4309)
extern "C"
char main[] = { 0x55,       /*push %ebp*/
                0x89, 0xE5, /*mov  %ebp, %esp*/
                0xE8, (char)(((&real_code)()>>24)&0xFF),
                      (char)((&real_code)()&0xFF), /*call real_code*/
                0x33, 0xC0, /*xorl %eax, %eax*/
                0xC9,       /*leave*/
                0xC3 };     /*ret*/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.