📄 dll_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Crypto++: dll.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.2 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Compound Members</a> | <a class="qindex" href="globals.html">File Members</a></div><h1>dll.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// dll.cpp - written and placed in the public domain by Wei Dai</span>00002 00003 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span>00004 <span class="preprocessor"></span>00005 <span class="preprocessor">#define CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES</span>00006 <span class="preprocessor"></span>00007 <span class="preprocessor">#include "dll.h"</span>00008 <span class="preprocessor">#pragma warning(default: 4660)</span>00009 <span class="preprocessor"></span>00010 <span class="preprocessor">#include <windows.h></span>00011 <span class="preprocessor">#include <new.h></span>00012 00013 <span class="preprocessor">#include "strciphr.cpp"</span>00014 <span class="preprocessor">#include "algebra.cpp"</span>00015 <span class="preprocessor">#include "eprecomp.cpp"</span>00016 <span class="preprocessor">#include "eccrypto.cpp"</span>00017 <span class="preprocessor">#include "iterhash.cpp"</span>00018 <span class="preprocessor">#include "oaep.cpp"</span>00019 00020 <span class="keyword">static</span> <span class="keyword">const</span> byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = <span class="stringliteral">"reserved for mac"</span>;00021 <span class="keyword">static</span> HMODULE s_hModule = NULL;00022 00023 NAMESPACE_BEGIN(CryptoPP)00024 00025 <span class="keyword">template</span><> <span class="keyword">const</span> byte PKCS_DigestDecoration<SHA>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};00026 <span class="keyword">template</span><> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> PKCS_DigestDecoration<SHA>::length = <span class="keyword">sizeof</span>(PKCS_DigestDecoration<SHA>::decoration);00027 00028 <span class="keywordtype">void</span> DoDllPowerUpSelfTest()00029 {00030 <span class="keywordtype">char</span> moduleFileName[_MAX_PATH];00031 GetModuleFileNameA(s_hModule, moduleFileName, <span class="keyword">sizeof</span>(moduleFileName));00032 CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac);00033 }00034 00035 NAMESPACE_END00036 00037 <span class="preprocessor">#endif</span>00038 <span class="preprocessor"></span>00039 <span class="preprocessor">#ifdef CRYPTOPP_EXPORTS</span>00040 <span class="preprocessor"></span>00041 USING_NAMESPACE(CryptoPP)00042 00043 <span class="keyword">static</span> PNew s_pNew = NULL;00044 <span class="keyword">static</span> PDelete s_pDelete = NULL;00045 00046 <span class="keyword">static</span> <span class="keywordtype">void</span> SetNewAndDeleteFunctionPointers()00047 {00048 <span class="keywordtype">void</span> *p = NULL;00049 HMODULE hModule = NULL;00050 MEMORY_BASIC_INFORMATION mbi;00051 00052 <span class="keywordflow">while</span> (<span class="keyword">true</span>)00053 {00054 VirtualQuery(p, &mbi, <span class="keyword">sizeof</span>(mbi));00055 00056 <span class="keywordflow">if</span> (p >= (<span class="keywordtype">char</span> *)mbi.BaseAddress + mbi.RegionSize)00057 <span class="keywordflow">break</span>;00058 00059 p = (<span class="keywordtype">char</span> *)mbi.BaseAddress + mbi.RegionSize;00060 00061 <span class="keywordflow">if</span> (!mbi.AllocationBase || mbi.AllocationBase == hModule)00062 <span class="keywordflow">continue</span>;00063 00064 hModule = HMODULE(mbi.AllocationBase);00065 00066 PGetNewAndDelete pGetNewAndDelete = (PGetNewAndDelete)GetProcAddress(hModule, <span class="stringliteral">"GetNewAndDeleteForCryptoPP"</span>);00067 <span class="keywordflow">if</span> (pGetNewAndDelete)00068 {00069 pGetNewAndDelete(s_pNew, s_pDelete);00070 <span class="keywordflow">return</span>;00071 }00072 00073 PSetNewAndDelete pSetNewAndDelete = (PSetNewAndDelete)GetProcAddress(hModule, <span class="stringliteral">"SetNewAndDeleteFromCryptoPP"</span>);00074 <span class="keywordflow">if</span> (pSetNewAndDelete)00075 {00076 _set_new_mode(1);00077 s_pNew = &malloc;00078 s_pDelete = &free;00079 pSetNewAndDelete(s_pNew, s_pDelete, &_set_new_handler);00080 <span class="keywordflow">return</span>;00081 }00082 }00083 00084 hModule = GetModuleHandle(<span class="stringliteral">"msvcrtd"</span>);00085 <span class="keywordflow">if</span> (!hModule)00086 hModule = GetModuleHandle(<span class="stringliteral">"msvcrt"</span>);00087 <span class="keywordflow">if</span> (hModule)00088 {00089 s_pNew = (PNew)GetProcAddress(hModule, <span class="stringliteral">"??2@YAPAXI@Z"</span>); <span class="comment">// operator new</span>00090 s_pDelete = (PDelete)GetProcAddress(hModule, <span class="stringliteral">"??3@YAXPAX@Z"</span>); <span class="comment">// operator delete</span>00091 <span class="keywordflow">return</span>;00092 }00093 00094 OutputDebugString(<span class="stringliteral">"Crypto++ was not able to obtain new and delete function pointers.\n"</span>);00095 <span class="keywordflow">throw</span> 0;00096 }00097 00098 <span class="keywordtype">void</span> * _cdecl operator new (size_t size)00099 {00100 <span class="keywordflow">if</span> (!s_pNew)00101 SetNewAndDeleteFunctionPointers();00102 00103 <span class="keywordflow">return</span> s_pNew(size);00104 }00105 00106 <span class="keywordtype">void</span> _cdecl operator delete (<span class="keywordtype">void</span> * p)00107 {00108 s_pDelete(p);00109 }00110 00111 BOOL APIENTRY DllMain(HANDLE hModule, 00112 DWORD ul_reason_for_call, 00113 LPVOID lpReserved)00114 {00115 <span class="keywordflow">if</span> (ul_reason_for_call == DLL_PROCESS_ATTACH)00116 {00117 s_hModule = (HMODULE)hModule;00118 DoDllPowerUpSelfTest();00119 }00120 <span class="keywordflow">return</span> TRUE;00121 }00122 00123 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:12 2003 for Crypto++ by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -