I used VMProtectBegin(“xxx”) / VMProtectEnd() to mark functions
I had marked 100+ functions by doing this way.
When I imported dll into vmp software, and I clicked Compile
While compiling in vmp, I suffered this problem
VMProtectMarker “functionA”.18071B842: address is already used by function “ VMProtectMarker “function B”
And When I check the vmp software,
functionA address is:000000018071B842,while function B address is:000000018071B624. So it is stranged for me.
And I also Checked my cpp source code:
function A and functionB are indeed marked with a different string, which means that the parameters passed into the function(VMProtectBegin) are different
I wonder why this happens? Is there anything I can pay attention to or check?
function A and function B are both defined in test.cpp
namespace test
{
int function A()
{
VMProtectBegin("functionA")
.....
VMProtectEnd()
}
void function B()
{
VMProtectBegin("functionB")
...
function A()
VMProtectEnd()
}
}
Then I sufferd this problem
So, Is it normal for this problem to occur? Beacuse At this Solution(Visual Stuido projetc) In function B ,I alse call many function who are protected by VMP but defined in other project;
And Also,I want to know If function A is only called in function B, is there no need to use vmp markersfor function A?
I think this happens due to compiler optimization. Compiler is most likely inlines functionA() inside functionB() so that’s why VMprotect throws that error. You could explicitly tell to compiler that you don’t want functionB() to be inlined by adding __declspec(noinline) before function name, like this
__declspec(noinline) int function A()
{
VMProtectBegin("functionA")
.....
VMProtectEnd()
}
If you’re calling that function multiple times then compiler is most likely not going to inline it so you don’t need to worry about it, but if you’re only calling it once it’s most likely inlined. Hope that helps.
It looks like your compiler is performing optimization and embedding the body of function A in function B, so the tokens are also nested.
You need to disable this optimization. For example /Ob (Inline Function Expansion) | Microsoft Learn