MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / CryptLoader

Class CryptLoader

Libraries/unrar/secpassword.cpp:13–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#endif
12
13class CryptLoader
14{
15 private:
16 HMODULE hCrypt;
17 bool LoadCalled;
18 public:
19 CryptLoader()
20 {
21 hCrypt=NULL;
22 pCryptProtectMemory=NULL;
23 pCryptUnprotectMemory=NULL;
24 LoadCalled=false;
25 }
26 ~CryptLoader()
27 {
28 if (hCrypt!=NULL)
29 FreeLibrary(hCrypt);
30 hCrypt=NULL;
31 pCryptProtectMemory=NULL;
32 pCryptUnprotectMemory=NULL;
33 };
34 void Load()
35 {
36 if (!LoadCalled)
37 {
38 hCrypt = LoadSysLibrary(L"Crypt32.dll");
39 if (hCrypt != NULL)
40 {
41 // Available since Vista.
42 pCryptProtectMemory = (CRYPTPROTECTMEMORY)GetProcAddress(hCrypt, "CryptProtectMemory");
43 pCryptUnprotectMemory = (CRYPTUNPROTECTMEMORY)GetProcAddress(hCrypt, "CryptUnprotectMemory");
44 }
45 LoadCalled=true;
46 }
47 }
48
49 CRYPTPROTECTMEMORY pCryptProtectMemory;
50 CRYPTUNPROTECTMEMORY pCryptUnprotectMemory;
51};
52
53// We need to call FreeLibrary when RAR is exiting.
54CryptLoader GlobalCryptLoader;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected