Can we use VMProtect offline in dotnet C#?

Issues related to VMProtect
Post Reply
kkwong95
Posts: 3
Joined: Mon Apr 08, 2024 10:53 am

Can we use VMProtect offline in dotnet C#?

Post by kkwong95 »

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++
Here's a simple use case in our project.

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());
    }
}
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#?
Admin
Site Admin
Posts: 2686
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Can we use VMProtect offline in dotnet C#?

Post by Admin »

We have tried using VMProtect.SDK but the functions in the SDK always fails.
Could you provide more detailed information about this problem?
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++
This scheme will never work.
kkwong95
Posts: 3
Joined: Mon Apr 08, 2024 10:53 am

Re: Can we use VMProtect offline in dotnet C#?

Post by kkwong95 »

Could you provide more detailed information about this problem?
VMProtect.SDK.ActivateLicense returns BadCode status.

VMProtect.SDK.GetOfflineActivationString returns Ok status but the buffer is always "Sdk OfflineActivationString".

VMProtect.SDK.SetSerialNumber returns Invalid (serial number from activated license).
Admin
Site Admin
Posts: 2686
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Can we use VMProtect offline in dotnet C#?

Post by Admin »

It seems you work in the test mode:
https://vmpsoft.com/vmprotect/user-manu ... pplication

For real mode you have to protect your application with vmprotect.
kkwong95
Posts: 3
Joined: Mon Apr 08, 2024 10:53 am

Re: Can we use VMProtect offline in dotnet C#?

Post by kkwong95 »

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:
weloveayaka
Posts: 66
Joined: Wed Jul 05, 2023 6:21 am

Re: Can we use VMProtect offline in dotnet C#?

Post by weloveayaka »

did you try .NET vmprotect sdk?
Located at Lib\windows\Net\VMProtect.SDK.dll
Admin
Site Admin
Posts: 2686
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Can we use VMProtect offline in dotnet C#?

Post by Admin »

Compile the program without the debug information, but in the linker settings we enable creating of the MAP-file
MAP/PDB aren't required for .NET files because .NET files already contain all symbols inside.
Post Reply