Шифрование функции в PE и расшифровка в памяти - C++
I want to keep an important function encrypted in the exe and while running the program, decrypt it at run time from memory. After execution of the function, I will encrypt it back in the memory (so that memory dump can't be analyzed). I am able to decrypt and encrypt it in memory successfully. But I am not sure, keeping a function as encrypted in an exe is possible or not. If possible, how can I do it? I am trying to find the function offset and encrypt the function body. Keeping a function body encrypted will corrupt the exe? Please help me with suggestions. Below given is the memory encryption/decryption code:
Что я уже пробовал:
<pre>void TestFunction() { MessageBoxA(0, "This will be encrypted", "Test", 0); } void stubFunction() { } static bool XORMemory(DWORD pStartAddr, int nLength) { if (!pStartAddr || nLength <= 0) return false; unsigned char* p = (unsigned char*)(pStartAddr); p = p + 4; for (int i = 0; i < nLength; i++) { *p++ ^= 0x5A; } return true; }