考慮我有一個動態的外部庫libExternal.dylib以下功能的外部庫函數: void print(char* str)
{
// Changes the first char to 'a' and prints the string
*str = 'a';
printf("%s\n", str);
}
接下來,我有一個加載這個外部庫和調用可執行(檢查省略
Overriding 'malloc' using the LD_PRELOAD mechanism 如何LD_PRELOAD用於設置ptr爲NULL或任何其他的存儲器地址,以避免懸掛指針漏洞。 void free(void *ptr)
{
real_free(ptr);
ptr = NULL // will only set local ptr to NULL
}
我有一個奇怪的問題。當我使用共享庫的參數調用導入的方法時,在這些方法中我有錯誤的參數。它是這樣的: x = 1; y = 2; z = 3;
(*method)(x,y,z);
在方法,我有: void method(int x, int y, int z){
// x = 2, y = 3, z = 32432423 - something like this
}
這裏我怎