C語言使用函數指針跳轉到程序固定地址(0x8000)執行程序的方法
使用函數指針,把一個純數據強制轉換爲函數指針類型。
int main(void)
{void (* my_function)(void);
//int *my_address = 0x8000;
my_function = (void (*)()) (0x8000);
my_function();
}
其實更簡單,不適用中間變量,直接一步到位:
(*(void(*)())0x8000)();
轉成彙編就佔兩條指令.
C語言使用函數指針跳轉到程序固定地址(0x8000)執行程序的方法
使用函數指針,把一個純數據強制轉換爲函數指針類型。
int main(void)
{}
其實更簡單,不適用中間變量,直接一步到位:
(*(void(*)())0x8000)();
轉成彙編就佔兩條指令.