Last active
January 4, 2017 13:15
-
-
Save vovanre/ed23045d62030cd2cc67c0525520544a to your computer and use it in GitHub Desktop.
Обёртка над функциями шифрования строк VMProtect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//VMPString.hpp | |
#pragma once | |
#ifndef SECURE_STRING | |
#ifndef _DEBUG | |
#define SECURE_STRING | |
#endif | |
#endif | |
#ifdef SECURE_STRING | |
#include "VMProtect.h" | |
#include <memory> | |
#define S(str) std::make_shared<SecureString<char>>(VMProtectDecryptStringA(str), sizeof(str))->get() | |
#define W_S(str) std::make_shared<SecureString<wchar_t>>(VMProtectDecryptStringW(str), sizeof(str))->get() | |
template <typename T> | |
class SecureString | |
{ | |
T* _buff; | |
size_t _buffSize; | |
public: | |
SecureString(T* buff, size_t buffSize) : _buff(buff), _buffSize(buffSize) | |
{ | |
} | |
~SecureString() | |
{ | |
SecureZeroMemory(_buff, _buffSize); | |
VMProtectFreeString(reinterpret_cast<void*>(_buff)); | |
} | |
T* get() const | |
{ | |
return _buff; | |
} | |
}; | |
#else | |
#define S(str) str | |
#define W_S(str) str | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment