// obfuscate.h -- Release build name obfuscation // // Replaces form and control names with generated tokens (C1, C2, ...) // across the compiled module AND the raw .frm text resources. This // hinders casual decompilation by removing meaningful identifiers // from event handler names (e.g., BtnHello_Click -> C3_Click). #ifndef DVXBASIC_OBFUSCATE_H #define DVXBASIC_OBFUSCATE_H #include "../runtime/vm.h" // One .frm text after obfuscation (data is newly-allocated). typedef struct { uint8_t *data; int32_t len; } BasObfFrmT; // Obfuscate form/control names in the module and all .frm texts. // // Reads original names from the Begin declarations in each .frm, // generates C1..Cn, then rewrites: // - The .frm text (form/control name declarations, stripping the // trailing BASIC code section after the outer form closes) // - Module string constants matching any original name // - Procedure names matching _ // - formVarInfo entries keyed by form name // // frmTexts / frmLens: input .frm buffers (one per form). // outFrms: caller-allocated array of frmCount entries; function fills // in .data (malloc'd, caller frees) and .len for each. void basObfuscateNames(BasModuleT *mod, const char **frmTexts, const int32_t *frmLens, int32_t frmCount, BasObfFrmT *outFrms); // Strip comments from .frm text. // // Removes both whole-line comments (lines whose first non-whitespace // token is `'` or `REM`) and trailing comments (everything from the // first unquoted `'` to end of line). Pure-whitespace lines are // dropped. Quoted string literals are preserved as-is. // // srcLen: input length; outBuf: caller-allocated buffer of outCap bytes. // Returns the number of bytes written. int32_t basStripFrmComments(const char *src, int32_t srcLen, uint8_t *outBuf, int32_t outCap); #endif // DVXBASIC_OBFUSCATE_H