Hi, I had uesd vmp to encrypt cpp project.
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?
Thanks a lot
Problem: Address is already used by another function
Re: Problem: Address is already used by another function
Please send us a test example that shows your problem.
Re: Problem: Address is already used by another function
I can show you the case I mentionedAdmin wrote:Please send us a test example that shows your problem.
function A and function B are both defined in test.cppfunction A address is Already use by funtion B
Code: Select all
namespace test
{
int function A()
{
VMProtectBegin("functionA")
.....
VMProtectEnd()
}
void function B()
{
VMProtectBegin("functionB")
...
function A()
VMProtectEnd()
}
}
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?
Thanks for your help
Re: Problem: Address is already used by another function
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
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.
Code: Select all
__declspec(noinline) int function A()
{
VMProtectBegin("functionA")
.....
VMProtectEnd()
}
Re: Problem: Address is already used by another function
It looks like your compiler is performing optimization and embedding the body of function A in function B, so the tokens are also nested.STpehn wrote:I can show you the case I mentionedAdmin wrote:Please send us a test example that shows your problem.function A and function B are both defined in test.cppfunction A address is Already use by funtion B
Then I sufferd this problemCode: Select all
namespace test { int function A() { VMProtectBegin("functionA") ..... VMProtectEnd() } void function B() { VMProtectBegin("functionB") ... function A() VMProtectEnd() } }
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?
Thanks for your help
You need to disable this optimization. For example https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
Re: Problem: Address is already used by another function
thanks! it do help me to fix this problempetko123 wrote: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
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.Code: Select all
__declspec(noinline) int function A() { VMProtectBegin("functionA") ..... VMProtectEnd() }
Re: Problem: Address is already used by another function
thanks a lot ! I have fixed this problem~Catharsis wrote:It looks like your compiler is performing optimization and embedding the body of function A in function B, so the tokens are also nested.STpehn wrote:I can show you the case I mentionedAdmin wrote:Please send us a test example that shows your problem.function A and function B are both defined in test.cppfunction A address is Already use by funtion B
Then I sufferd this problemCode: Select all
namespace test { int function A() { VMProtectBegin("functionA") ..... VMProtectEnd() } void function B() { VMProtectBegin("functionB") ... function A() VMProtectEnd() } }
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?
Thanks for your help
You need to disable this optimization. For example https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170