#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#ifdef __cplusplus
extern "C"
#endif
void * _ReturnAddress(void);
#pragma intrinsic(_ReturnAddress)
//I inserted the following code inside one of the functions
void func()
{
------------
-------
----
-
HMODULE module_handle;
TCHAR module_name[4096];
DWORD flag = 0x00000004;
GetModuleHandleEx(flag, (LPCTSTR) _ReturnAddress(), &module_handle);
GetModuleFileName(module_handle,module_name,4096);
-----
--
}
当我将代码编译为单独的项目时,一切正常。请帮忙。
答案 0 :(得分:1)
编译使用的应用程序 这个函数,将_WIN32_WINNT定义为 0x0501或更高版本。欲获得更多信息, 见Using the Windows Headers。
答案 1 :(得分:1)
即使你得到你的代码进行编译,你正在做什么闻到了错误。
如果您使用返回地址做出任何与安全相关的决定,停止。 You can't trust the return address of the calling function。不,you can't trust the return address of the calling function。