Skip to content

Instantly share code, notes, and snippets.

@Fonger
Last active January 3, 2018 12:26
Show Gist options
  • Save Fonger/e748b315d479c2d8fdba7a92227458ae to your computer and use it in GitHub Desktop.
Save Fonger/e748b315d479c2d8fdba7a92227458ae to your computer and use it in GitHub Desktop.
VMProtect 64 bit masm header file for MASM for x64(ml64.exe) on Visual Studio
include VMProtectSDK.inc
.data
MyTestFunctionMarker db "MyTestFunctionMarker", 0
.code
MyTestFunction proc
lea rcx, MyTestFunctionMarker ;don't need to keep rcx, VMProtect will handle this properly
call VMProtectBegin
add rcx, rdx ;the rcx here is the original rcx, not MyTestFunctionMarker.
mov rax, rcx
call VMProtectEnd
ret
MyTestFunction endp
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
extern "C" long long MyTestFunction(long long a, long long b);
int main(int argc, TCHAR *argv[])
{
cout << MyTestFunction(1,2) << endl; // will print 3 (1+2)
system("PAUSE");
return 0;
}
; protection
VMProtectBegin PROTO :DWORD
VMProtectBeginVirtualization PROTO :DWORD
VMProtectBeginMutation PROTO :DWORD
VMProtectBeginUltra PROTO :DWORD
VMProtectBeginVirtualizationLockByKey PROTO :DWORD
VMProtectBeginUltraLockByKey PROTO :DWORD
VMProtectEnd PROTO
; utils
VMProtectIsProtected PROTO
VMProtectIsDebuggerPresent PROTO :DWORD
VMProtectIsVirtualMachinePresent PROTO
VMProtectIsDebuggerPresent PROTO :DWORD
VMProtectDecryptStringA PROTO :DWORD
VMProtectDecryptStringW PROTO :DWORD
VMProtectFreeString PROTO :DWORD
; licensing
SERIAL_STATE_SUCCESS equ 0
SERIAL_STATE_FLAG_CORRUPTED equ 0x00000001
SERIAL_STATE_FLAG_INVALID equ 0x00000002
SERIAL_STATE_FLAG_BLACKLISTED equ 0x00000004
SERIAL_STATE_FLAG_DATE_EXPIRED equ 0x00000008
SERIAL_STATE_FLAG_RUNNING_TIME_OVER equ 0x00000010
SERIAL_STATE_FLAG_BAD_HWID equ 0x00000020
SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED equ 0x00000040
VMProtectDate STRUCT
wYear WORD ?
bMonth BYTE ?
bDay BYTE ?
VMProtectDate ENDS
VMProtectSerialNumberData STRUCT
nState DWORD ? ; VMProtectSerialStateFlags
wUserName WORD[256] ; user name
wEMail WORD[256] ; email
dtExpire VMProtectDate <> ; date of serial number expiration
dtMaxBuild VMProtectDate <> ; max date of build, that will accept this key
bRunningTime DWORD ? ; running time in minutes
nUserDataLength BYTE ? ; length of user data in bUserData
bUserData BYTE[255] ? ; up to 255 bytes of user data
VMProtectSerialNumberData ENDS
VMProtectSetSerialNumber PROTO :DWORD
VMProtectGetSerialNumberState PROTO
VMProtectGetSerialNumberData PROTO :DWORD,:DWORD
VMProtectGetCurrentHWID PROTO :DWORD,:DWORD
; activation
ACTIVATION_OK equ 0
ACTIVATION_SMALL_BUFFER equ 1
ACTIVATION_NO_CONNECTION equ 2
ACTIVATION_BAD_REPLY equ 3
ACTIVATION_BANNED equ 4
ACTIVATION_CORRUPTED equ 5
ACTIVATION_BAD_CODE equ 6
ACTIVATION_ALREADY_USED equ 7
ACTIVATION_SERIAL_UNKNOWN equ 8
ACTIVATION_NOT_AVAILABLE equ 9
VMProtectActivateLicense PROTO :DWORD,:DWORD,:DWORD
VMProtectDeactivateLicense PROTO :DWORD
VMProtectGetOfflineActivationString PROTO :DWORD,:DWORD,:DWORD
VMProtectGetOfflineDeactivationString PROTO :DWORD,:DWORD,:DWORD
; libs
includelib VMProtectSDK64.lib
@Fonger
Copy link
Author

Fonger commented Dec 20, 2016

This header file for x64 is missing from VMProtect official SDK /Include/ASM/VMProtectSDK.inc
VMProtect only provide 64bit version for C. This is tested and worked on Visual Studio 2013, 2015

The difference between VMProtectSDK64.inc and original VMProtectSDK.inc are:
WCHAR[256] -> WORD[256]
includelib VMProtectSDK32.lib -> includelib VMProtectSDK64.lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment