//------------------------------------------------------------------- // printmac.cpp // // This application prints the unique hardware address of this // workstation's RealTek 8139 Network Interface Controller, if // the kernel's 'sys_call_table[]' has been patched with a new // system-call which implements that functionality in place of // the unimplemented system-call for the obsolete 'sys_break'. // // programmer: ALLAN CRUSE // written on: 15 MAY 2005 //------------------------------------------------------------------- #include // for printf() #include // for __NR_break int get_mac_address( unsigned char *addrbuf ) { int retval = 0; asm(" movl %0, %%eax " : : "i" (__NR_break) ); asm(" movl %0, %%ebx " : : "m" (addrbuf) ); asm(" int $0x80 "); asm(" movl %%eax, %0 " : "=m" (retval) ); return retval; } int main( void ) { unsigned char hwaddr[ 6 ] = {0}; get_mac_address( hwaddr ); printf( "\nnetwork interface address: " ); for (int i = 0; i < 6; i++) { printf( "%02X", hwaddr[ i ] ); if ( i < 5 ) printf( ":" ); } printf( "\n\n" ); }