【发布时间】:2018-06-22 08:03:01
【问题描述】:
我目前正在使用 Visual Studio 2017,并试图让我的应用程序更防篡改。 现在,我想要保护的关键代码函数将在运行时被解密,为此我试图将它们添加到文件中的自定义部分,该部分将被称为 .foobar 作为示例。我正在使用#pragma 指令添加该部分,然后再指定应该在此处链接的函数,但是当我分析 PE 文件时没有 .foobar 部分。
我尝试添加函数的代码如下:
#pragma section(".foobar",execute, read, write)
#pragma comment(linker,"/SECTION:.foobar,ERW")
...
Main() function and others...
...
#pragma code_seg(".foobar")
int IWantThisToBeInFoobar() {...}
我还尝试了以下方法:
int IWantThisToBeInFoobar();
...
#pragma alloc_text(".foobar", IWantThisToBeInFoobar)
...
int IWantThisToBeInFoobar() {...}
到目前为止,这些都不起作用,我正在使用 ExeInfo PE 查看部分,并且任何地方都没有 .foobar 的迹象。
感谢任何帮助或指导。
【问题讨论】:
-
你的编译器是什么?通常我使用
#pragma section <section_name> <funtion_name>。使用稍后在链接器脚本中使用的<section_name>。 -
我正在使用 MSVC17
标签: c visual-studio linker portable-executable pragma