部分混淆C代码

时间:2016-10-19 12:58:41

标签: c obfuscation

我有一个很大的项目要分享,有几个文件和链接库。我的合作者需要修改一些特定的功能。有什么方法可以部分模糊代码中不需要开发的区域吗?

3 个答案:

答案 0 :(得分:0)

如果您提到的功能是函数形式,您可以在标题中提供函数指针类型定义,并让用户注册自己的函数。您还应该在标头中添加Register_Func()函数。 此函数修改指向这些函数的静态指针。

标题中的

typedef void (*myfunc_p)(int);

void Register_Func(myfunc_p F);

然后在你的代码中:

static myfunc_p   Modified_Function;

void Register_Func(myfunc_p F)
{
  Modified_Function=F;
}

然后,您只能与标题共享DLL。他们可以注册自定义代码。

答案 1 :(得分:0)

It depends how messy it gets. I'd just create an API that expose the functionalities they need and provide them with the source code they want to modify as a separate library. This way they'll only see the prototypes (and you can obfuscate these with dummy parameters) and any source code examples. That way, for the most part, supply them the .dlls or .so files for them to build against. If they keep asking for more code it might be time to openly refuse.

BTW, if this is a collaboration then you don't have to give them anything but if they've commission you to do some work they may have rights to access all your code if it hasn't been stipulated otherwise. So check your agreement you mightn't have a choice.

In truth if you're using something like C (and a code base of say less than 10,000 lines) it doesn't take much to disassemble code and reverse/back engineer. A good assembly programmer wont have much problems here. Compiling with optimisation will make it slightly more difficult.

答案 2 :(得分:0)

由于我们都将使用VS,我删除了源代码并添加了obj文件。它正在发挥作用。