From 00e6cad71b5fa6e72d90e2dbd86c8e8c182ae02d Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:29:50 +0800 Subject: [PATCH] [saco] Implement `K_EncodeString` and `K_DecodeString` --- saco/runutil.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- saco/runutil.h | 3 +++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/saco/runutil.cpp b/saco/runutil.cpp index 38d9e76..eb62cbf 100644 --- a/saco/runutil.cpp +++ b/saco/runutil.cpp @@ -234,4 +234,43 @@ void Util_Base64Encode( char *cpInput, char *cpOutput ) return; } -//---------------------------------------------------- \ No newline at end of file +//---------------------------------------------------- +// Simple rotate right 3 character encoding for +// hiding strings in the exe. + +void K_EncodeString(char *szInput, char *szOutput) +{ + char b; + + while(*szInput) { + b = *szInput; + _asm mov bl, b + _asm ror bl, 3 + _asm mov b, bl + *szOutput = b; + szInput++; + szOutput++; + } + *szOutput = 0; +} + +//---------------------------------------------------- + +char * K_DecodeString(unsigned char *szInput) +{ + char b; + char *st = (char *)szInput; + + while(*szInput) { + b = *szInput; + _asm mov bl, b + _asm rol bl, 3 + _asm mov b, bl + *szInput = b; + szInput++; + } + + return st; +} + +//---------------------------------------------------- diff --git a/saco/runutil.h b/saco/runutil.h index dadb861..1ca751b 100644 --- a/saco/runutil.h +++ b/saco/runutil.h @@ -9,4 +9,7 @@ char *Util_strrev(char *str); char * Util_itoa(int v, char *s, int r); void Util_Base64Encode( char *cpInput, char *cpOutput ); +char * K_DecodeString(unsigned char *szInput); +void K_EncodeString(char *szInput, char *szOutput); + //---------------------------------------------------- \ No newline at end of file