VxLang SDK Tutorial — Linking with VxLang-Core
Overview
Runtime Code Encryption is a VxLang protection feature that decrypts the code of a designated function only when it is needed for execution and re-encrypts it when the protected region is no longer in use.
This tutorial explains how to link function-level code protection with VxLang-Core (the packer core) using the SDK markers VL_ENCRYPT_OBFUSCATION_BEGIN and VL_ENCRYPT_OBFUSCATION_END.
This approach is designed to make it harder to recover the original protected code in a single operation, even if the packer shell is removed through static unpacking or the running process is dumped from memory. Because the decrypted state depends on execution timing and VxLang-Core operation, AI-assisted dynamic analysis also requires additional steps to collect and reconstruct the code.
Important: The goal is not to make analysis impossible. It is to reduce the duration and scope of plaintext code exposure and increase the difficulty of collecting code through static and dynamic analysis.
1. How Runtime Code Encryption Works
With conventional executable packing, it may be possible to inspect or dump executable code from memory after unpacking. Runtime Code Encryption reduces this exposure by decrypting code when it is needed and re-encrypting it afterward.
- Distribution: The designated protected code is stored in encrypted form.
- Execution preparation: When a protected function is needed, its code is decrypted in coordination with VxLang-Core.
- Protected code execution: The decrypted code executes within the required region.
- Completion: Once the protected region is no longer in use, the code is encrypted again.
VxLang-Core dependency: VxLang-Core must be loaded and operating for protected code to be decrypted and executed correctly. Removing only the packer shell does not automatically recover the original code or make it independently executable.
2. SDK Example
First, include the VxLang SDK header in your project and enable SDK markers.
#define USE_VL_MACRO
#include "vxlib.h"
void LinkTest() {
VL_ENCRYPT_OBFUSCATION_BEGIN;
// Code to protect in conjunction with VxLang-Core
volatile int value = 10;
value = value * 2 + 5;
(void)value;
VL_ENCRYPT_OBFUSCATION_END;
}
When USE_VL_MACRO is enabled, the two markers are defined in the provided SDK header as follows:
#define VL_ENCRYPT_OBFUSCATION_BEGIN VxObfuscationBegin(); VxLinkExtsBegin()
#define VL_ENCRYPT_OBFUSCATION_END VxLinkExtsEnd(); VxObfuscationEnd()
These markers designate both an Obfuscation protection region and a Runtime Code Encryption protection region. The example demonstrates how to place the SDK markers; the actual protection transformation is performed during the VxLang build process.
If
USE_VL_MACROis not defined, these markers expand to empty macros. Make sure the SDK markers are enabled in your protection build.
3. Protection Benefits
| Analysis scenario | Expected benefit |
|---|---|
| Static Unpacking | Removing the packer shell alone does not readily expose the original code in the Runtime Code Encryption region. |
| Memory Dumping | Because protected code is not continuously present in plaintext form, collecting all of it through a single memory snapshot becomes more difficult. |
| AI-Assisted Dynamic Analysis | Automated code collection and analysis become more complex because the decrypted execution state and its interaction with VxLang-Core must be tracked. |
| Static Analysis | Encrypting protected regions in the distributed binary makes direct analysis of their original machine instructions more difficult. |
These benefits vary depending on the analysis environment and the code being protected. Decrypted code may still be observed dynamically while it is executing. This feature does not guarantee that all dumping, tracing, or reconstruction attempts will be blocked.
4. Important Considerations
- VxLang-Core is required. Do not assume that code protected with Runtime Code Encryption can be decrypted and executed independently without VxLang-Core.
- Place BEGIN/END markers correctly. Both markers should clearly enclose the intended code region within the same function.
- Be careful with exceptions and abnormal control flow. Code that exits the protected region unexpectedly through
return, an exception, or a long jump requires additional testing. - Test multithreaded behavior. The feature is designed with reference-count-based thread safety in mind, but concurrent calls and reentrancy must still be tested in the actual application.
- Watch for compiler optimization and function inlining. Verify that the intended SDK protection boundaries remain intact in the compiled binary. Limit optimization for the affected function when necessary.
- Measure compatibility and performance. Decryption and re-encryption introduce runtime costs as well as protection benefits. Benchmark functions that are called very frequently before enabling this feature.
5. Summary
VL_ENCRYPT_OBFUSCATION_BEGIN / VL_ENCRYPT_OBFUSCATION_END are SDK markers that designate both code obfuscation and Runtime Code Encryption.
By working with VxLang-Core to decrypt the original code only when needed, they add a layer of defense against attempts to recover code through static unpacking alone, bulk memory dumping, and AI-assisted automated dynamic analysis.
The central principle is:
Unpacking the executable does not mean recovering the original code.
VxLang SDK Tutorial · Runtime Code Encryption
