#include "rar.hpp"
#if defined(_WIN_ALL) && !defined(CHROMIUM_UNRAR)
typedef BOOL (WINAPI *CRYPTPROTECTMEMORY)(LPVOID pData,DWORD cbData,DWORD dwFlags);
typedef BOOL (WINAPI *CRYPTUNPROTECTMEMORY)(LPVOID pData,DWORD cbData,DWORD dwFlags);
#ifndef CRYPTPROTECTMEMORY_BLOCK_SIZE
#define CRYPTPROTECTMEMORY_BLOCK_SIZE …
#define CRYPTPROTECTMEMORY_SAME_PROCESS …
#define CRYPTPROTECTMEMORY_CROSS_PROCESS …
#endif
class CryptLoader
{
private:
HMODULE hCrypt;
bool LoadCalled;
public:
CryptLoader()
{
hCrypt=NULL;
pCryptProtectMemory=NULL;
pCryptUnprotectMemory=NULL;
LoadCalled=false;
}
~CryptLoader()
{
if (hCrypt!=NULL)
FreeLibrary(hCrypt);
hCrypt=NULL;
pCryptProtectMemory=NULL;
pCryptUnprotectMemory=NULL;
};
void Load()
{
if (!LoadCalled)
{
hCrypt = LoadSysLibrary(L"Crypt32.dll");
if (hCrypt != NULL)
{
pCryptProtectMemory = (CRYPTPROTECTMEMORY)GetProcAddress(hCrypt, "CryptProtectMemory");
pCryptUnprotectMemory = (CRYPTUNPROTECTMEMORY)GetProcAddress(hCrypt, "CryptUnprotectMemory");
}
LoadCalled=true;
}
}
CRYPTPROTECTMEMORY pCryptProtectMemory;
CRYPTUNPROTECTMEMORY pCryptUnprotectMemory;
};
static CryptLoader GlobalCryptLoader;
#endif
SecPassword::SecPassword()
{ … }
SecPassword::~SecPassword()
{ … }
void SecPassword::Clean()
{ … }
void cleandata(void *data,size_t size)
{ … }
void SecPassword::Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstSize,bool Encode)
{ … }
void SecPassword::Get(wchar *Psw,size_t MaxSize)
{ … }
void SecPassword::Get(std::wstring &Psw)
{ … }
void SecPassword::Set(const wchar *Psw)
{ … }
size_t SecPassword::Length()
{ … }
bool SecPassword::operator == (SecPassword &psw)
{ … }
void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess)
{ … }