X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Glaux" Newsgroups: comp.os.msdos.djgpp Subject: Re: still no support/alternative to __attribute__((naked)) ? Date: 2 Mar 2007 06:42:52 -0800 Organization: http://groups.google.com Lines: 29 Message-ID: <1172846572.384653.223190@p10g2000cwp.googlegroups.com> References: <1172695353 DOT 457041 DOT 104610 AT h3g2000cwc DOT googlegroups DOT com> <1172781205 DOT 878725 DOT 126010 AT 8g2000cwh DOT googlegroups DOT com> NNTP-Posting-Host: 212.158.158.242 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1172846578 14992 127.0.0.1 (2 Mar 2007 14:42:58 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Fri, 2 Mar 2007 14:42:58 +0000 (UTC) In-Reply-To: <1172781205.878725.126010@8g2000cwh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse AT google DOT com Injection-Info: p10g2000cwp.googlegroups.com; posting-host=212.158.158.242; posting-account=79KgoA0AAADKuOLK3k0Y3qVqk-KGfm77 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Ha, finally found what I need. I use asm label to make a pointer, it works, something like this: void ring0_function(void) // need to be __attribute__ ((naked)) { asm("my_label:"); ...code asm("lret"); } and then use in main printf("f: %lX\n",(DWord)ring0_function+3); // function pointer behind prologue asm __volatile__ ("movl $my_label,%%eax" : "=a" (ring0_addr)); // naked function pointer made of label printf("PTR: %lXh\n",ring0_addr); it compiles to 00401380 push ebp 00401381 mov ebp,esp 00401383 ...code 00401385 retf 004013CD mov eax,401383h 004013D2 mov [00404010],eax