We are trying to write our code protection in dotnet C# but we can't seems to get it to work. We have tried using VMProtect.SDK but the functions in the SDK always fails. So far we have attempted the following:
import VMProtectSDK64.dll into the c# project (example below)
writing a wrapper dll to call VMProtect functions in C++
[DllImport("VMProtectSDK64.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int VMProtectGetOfflineActivationString(
string code,
[Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder buffer,
ref int bufferSize);
public static void Main(string[] args)
{
int bufferSize = 1024;
StringBuilder stringBuilder = new StringBuilder(bufferSize);
int res = VMProtectGetOfflineActivationString(code, stringBuilder, ref bufferSize);
if (res == 0)
{
Console.WriteLine(stringBuilder.ToString());
}
}
The result is that stringBuilder either contains garbage value or just being empty. This is similiar to ActivateLicense function where it would always return BadCode status. Is VMProtect usable in C#?
Hi, the user manual is written for C++ apps, but we are writing our app in C#. Is there any specific steps we need to follow in order to enable real mode?
Particularly this step, it's not an option available in C# dotnet projects.
Compile the program without the debug information, but in the linker settings we enable creating of the MAP-file – we will need it to work with VMProtect. After we run the program, we should see the following text: