Page 1 of 1

Basic tutorial for Risc VM markers C++ Gcc

Posted: Tue Aug 28, 2018 5:16 am
by d.darko
Hi,
I am using Enigma Protector x64 6.30, and would like to protect some functions with the markers option.
Compiling with gcc under mingw64.

There are only examples for delphi in the EP directory.
Could you please just write a short tutorial on how to properly use markers in C++ gcc ?

Help pages shows this example:

Code: Select all

#include "include/enigma_api64.h" // the module contains definitions of Enigma API

EP_Marker("vm_begin");

EP_Marker("vm_end");
But that has to be something old, because there is no enigma_api64.h :)

I found that i should include vm_risc_begin.inc, and vm_risc_end.inc around the code i want to protect, but is that enough?
Also i found here on forum that EP_Marker('vm_risc_begin') exists, is that Delphi only?

A short example would be really helpful.
Thanks

Re: Basic tutorial for Risc VM markers C++ Gcc

Posted: Tue Aug 28, 2018 11:30 am
by Enigma
Hi,

Yes, there is a small typo in the help, the file should be enigma_ide64.h, not enigma_api64.h
Inside enigma_ide64.h you find declaration of EP_Marker function together with other Enigma API.

So, how to embed markers for C++ x64? For x86 you can use .inc files that contain assembler code, but for x64 C++ does not allow to use assemler, so for x64 you need to use EP_Marker function only.

You need to put your code between begin and end markers, like this:

Code: Select all

EP_Marker("vm_begin");
// YOUR CODE HERE
EP_Marker("vm_end");
The example above performs code virtualization with Classic virtual machine, if you would like to use RISC vm, then do the following:

Code: Select all

EP_Marker("vm_risc_begin");
// YOUR CODE HERE
EP_Marker("vm_risc_end");
It is very important to check if protection processed all markers correctly and there is no problems.
In the protection log carefully check if all markers are found and no errors or warnings appeared.

Re: Basic tutorial for Risc VM markers C++ Gcc

Posted: Tue Aug 28, 2018 1:35 pm
by d.darko
Thanks for your reply, so it is enough to surround my functions with the markers, nothing else to do.
I also read your tips in another thread regarding how to use the markers.

Thank you i will try it out.

Re: Basic tutorial for Risc VM markers C++ Gcc

Posted: Tue Aug 28, 2018 1:41 pm
by Enigma
Great, just double check the protection log, it has to show information that markers are found.

Re: Basic tutorial for Risc VM markers C++ Gcc

Posted: Tue Aug 28, 2018 7:47 pm
by d.darko
As i am using c++ and gcc , not ms vc++ i had to define the risc markers this way:

Code: Select all

#define ENIGMA_VM_START do{ \
asm __volatile__ (".byte 0xEB");\
asm __volatile__ (".byte 0x08");\
asm __volatile__ (".byte 0x56");\
asm __volatile__ (".byte 0x4D");\
asm __volatile__ (".byte 0x42");\
asm __volatile__ (".byte 0x45");\
asm __volatile__ (".byte 0x47");\
asm __volatile__ (".byte 0x49");\
asm __volatile__ (".byte 0x4E");\
asm __volatile__ (".byte 0x31");\
} while (0)

#define ENIGMA_VM_END do{ \
asm __volatile__ (".byte 0xEB");\
asm __volatile__ (".byte 0x08");\
asm __volatile__ (".byte 0x56");\
asm __volatile__ (".byte 0x4D");\
asm __volatile__ (".byte 0x45");\
asm __volatile__ (".byte 0x4E");\
asm __volatile__ (".byte 0x44");\
asm __volatile__ (".byte 0x31");\
asm __volatile__ (".byte 0x00");\
asm __volatile__ (".byte 0x00");\
} while (0)
in the log i get :

Code: Select all

[21:43:53] Search markers...
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x004482F6
[21:43:53] Marker found: vm_risc_end, virtual address: 0x004486FA
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x00457C2D
[21:43:53] Marker found: vm_risc_end, virtual address: 0x00458A69
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x0045A0C0
[21:43:53] Marker found: vm_risc_end, virtual address: 0x0045A90E
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x0045AC56
[21:43:53] Marker found: vm_risc_end, virtual address: 0x0045AF9C
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x0045B441
[21:43:53] Marker found: vm_risc_end, virtual address: 0x0045B738
[21:43:53] Marker found: vm_risc_begin, virtual address: 0x0045F5DA
[21:43:53] Marker found: vm_risc_end, virtual address: 0x0045F7A6
[21:43:54] - 1 function(s) processed with RISC virtual machine
[21:43:54] Process Virtual Machine ...
I guess everything went ok, as the .exe size doubled compared to when i wasnt using markers.

Re: Basic tutorial for Risc VM markers C++ Gcc

Posted: Wed Aug 29, 2018 7:55 am
by Enigma
Great, I confirm that it works as expected, good way!