Can we use VMProtect offline in dotnet C#?
Posted: Mon Apr 08, 2024 11:11 am
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:
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#?
- import VMProtectSDK64.dll into the c# project (example below)
- writing a wrapper dll to call VMProtect functions in C++
Code: Select all
[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());
}
}