RTE Labels

Each RTE block is determined by start (PCG_CRYPT_START) and end (PCG_CRYPT_END) labels.

RTE labels (PCG_CRYPT_START, PCG_CRYPT_END)  for 32 bit applications are based on fixed byte arrays and are defined in rte.h header file for c/c++ applications.

In case of 64bit Windows applications RTE labels are based on calls to two functions exported from protection interface 64bit version of interface dll. Both rte64.h and pcgint.h header files are required and included in full featured version.

For Delphi applications start and end labels are defined  in pcg_crypt_start.inc and pcg_crypt_end.inc

Sample Visual Studio C/C++ (32/64 bit), Delphi (32/64 bit) and C++ Builder (32/64 bit) RTE source code projects are available in full featured version.

Using RTE labels

The most important thing is correct implementation of start and end labels. Using labels in not appropriate way can generate unexpected errors.

1) Correct implementation

...
PCG_CRYPT_START                <--- block 1 start

        MessageBox(NULL , "This part of code is available ...", "MyApp", MB_OK);

PCG_CRYPT_END                <--- block 1 end
...
PCG_CRYPT_START                <--- block 2 start

        MessageBox(NULL , "... in unlocked application only!", "MyApp", MB_OK);

PCG_CRYPT_END                <--- block 2 end
...

2) You can put unlimited number of start-end labels in your code but you can not nest one start-end block inside another one.

!!! The following implementation is not correct. Only code between "block 1 start" and "block 2 end" would be encrypted !!!

...
PCG_CRYPT_START                <--- block 1 start
...
        PCG_CRYPT_START         <--- block 2 start
                ...
        PCG_CRYPT_END                <--- block 2 end
...
PCG_CRYPT_END                <--- block 1 end
...

3) You must end previous block before marking new one!

!!! The following implementation is not correct as only block 1 would be encrypted !!!

...
PCG_CRYPT_START                <--- block 1 start
...
        PCG_CRYPT_START                <--- block 2 start
...
PCG_CRYPT_END                <--- block 1 end
...
        PCG_CRYPT_END                <--- block 2 end
...

4) End label must be reached before the start label is executed again!

!!! The following implementation is not correct as the end of block 1 is never reached !!!

PCG_CRYPT_START                <--- block 1 start        (code is decrypted here)

        MessageBox(NULL , "This part of code is available ...", "MyApp", MB_OK);

    return;        <-- return from this function, end of block 1 is never reached so the code stays decrypted. 

PCG_CRYPT_END                <--- block 1 end (code must be encrypted again at this point!)

5) 64bit (x64) C/C++ void functions

In case of void functions avoid using PCG_CRYPT_END block as the last instruction as this could lead to "Invalid RTE block end label detected!" errors during protection process. We suggest converting such functions to bool instead of void and adding return true; as the last instruction in function.

Example:

void test() {

PCG_CRYPT_START

    ...
    ...

PCG_CRYPT_END

}

should be converted to:

bool test() {

PCG_CRYPT_START

    ...
    ...

PCG_CRYPT_END

    return true;
}

6) Always test protected application after inserting new start-end fragments.

Use PLAIN protection method for this purpose. Closely watch the usage of variables inside and outside encrypted blocks of code.