I am wondering if the encryption (part) of your process memory will end with a chicken egg problem. I mean, the password for encryption / decryption of the memory block (s) of interest should be somewhere in the memory, inside the address space of your process. If any malicious code can access / check the address space of your process at runtime, you are not going to solve the problem (but you make the life of the observer more difficult;))
If you work in user space, you can create some kind of shell to encrypt / decrypt your variables / memory using any available cryptography library (i.e. OpenSSL libcrypto), I think. You can create some kind of “protected variable” object, but keep in mind that some cryptographic algorithms require filling (the size of the basic types may need to be changed accordingly) In kernel space, you can use LKCF (Cernel Crypto API)
sergico
source share