我不是C ++程序员,我只是想在VS2010中基于crypto ++库编译一个旧的DLL(我认为是VS6),以便对其进行调试以了解其工作原理,因为我必须在其中编写一些代码。能够读取其加密内容的另一种语言
当我尝试编译DLL时,在这段代码中的第一个类型名上出现错误C2664
#else /* _ITERATOR_DEBUG_LEVEL == 0 */
_Vector_val(_Alloc _Al = _Alloc())
: _Alval(_Al)
{ // construct allocator from _Al
typename _Alloc::template rebind<_Container_proxy>::other
_Alproxy(_Alval);
this->_Myproxy = _Alproxy.allocate(1);
_Cons_val(_Alproxy, this->_Myproxy, _Container_proxy());
this->_Myproxy->_Mycont = this;
_Myfirst = 0;
_Mylast = 0;
_Myend = 0;
}
~_Vector_val()
{ // destroy proxy
typename _Alloc::template rebind<_Container_proxy>::other
_Alproxy(_Alval);
this->_Orphan_all();
_Dest_val(_Alproxy, this->_Myproxy);
_Alproxy.deallocate(this->_Myproxy, 1);
this->_Myproxy = 0;
}
#endif /* _ITERATOR_DEBUG_LEVEL == 0 */
我有一个Google,但我对答案的了解不足,无法更改它
构建中显示的实际错误是这样的
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(441): error C2664: 'CryptoPP::AllocatorWithCleanup<T>::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup<T> &)' : cannot convert parameter 1 from 'CryptoPP::AllocatorWithCleanup<T>' to 'const CryptoPP::AllocatorWithCleanup<T> &'
但是我不确定双击它所指向的行有什么关系,因为我似乎找不到它使用的任何单词?
非常感谢您的时间和协助
PS我看不到该库的较新版本,它可能会编译,因为我不知道它们是否更改了所用的任何加密方法
这是输出窗口的全部内容
1>------ Build started: Project: dfxext, Configuration: Debug Win32 ------
1> StdAfx.cpp
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1> CDialogSK.cpp
1> CMSDialog.cpp
1> CtlStockIcon.cpp
1> DonorflexDLL.cpp
1>c:\users\andrew.cmac\documents\temp c++ project search\common\c++\agk_vs2010_dfxext\donorflexdll.cpp(63): warning C4996: 'CWinApp::SetDialogBkColor': CWinApp::SetDialogBkColor is no longer supported. Instead, handle WM_CTLCOLORDLG in your dialog
1> c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(5365) : see declaration of 'CWinApp::SetDialogBkColor'
1> DonProgress.cpp
1> EnterpriseRegistrationDialog.cpp
1> GradientFillBox.cpp
1> interfaces.cpp
1>c:\users\andrew.cmac\documents\temp c++ project search\common\c++\agk_vs2010_dfxext\interfaces.cpp(308): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\users\andrew.cmac\documents\temp c++ project search\common\c++\agk_vs2010_dfxext\interfaces.cpp(508): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
1>c:\users\andrew.cmac\documents\temp c++ project search\common\c++\agk_vs2010_dfxext\interfaces.cpp(538): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(441): error C2664: 'CryptoPP::AllocatorWithCleanup<T>::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup<T> &)' : cannot convert parameter 1 from 'CryptoPP::AllocatorWithCleanup<T>' to 'const CryptoPP::AllocatorWithCleanup<T> &'
1> with
1> [
1> T=std::_Container_proxy
1> ]
1> and
1> [
1> T=CryptoPP::HuffmanDecoder::CodeInfo
1> ]
1> and
1> [
1> T=std::_Container_proxy
1> ]
1> Reason: cannot convert from 'CryptoPP::AllocatorWithCleanup<T>' to 'const CryptoPP::AllocatorWithCleanup<T>'
1> with
1> [
1> T=CryptoPP::HuffmanDecoder::CodeInfo
1> ]
1> and
1> [
1> T=std::_Container_proxy
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(437) : while compiling class template member function 'std::_Vector_val<_Ty,_Alloc>::_Vector_val(_Alloc)'
1> with
1> [
1> _Ty=CryptoPP::HuffmanDecoder::CodeInfo,
1> _Alloc=CryptoPP::AllocatorWithCleanup<CryptoPP::HuffmanDecoder::CodeInfo>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1> with
1> [
1> _Ty=CryptoPP::HuffmanDecoder::CodeInfo,
1> _Alloc=CryptoPP::AllocatorWithCleanup<CryptoPP::HuffmanDecoder::CodeInfo>
1> ]
1> c:\users\andrew.cmac\documents\temp c++ project search\common\c++\libcrypto\zinflate.h(79) : see reference to class template instantiation 'std::vector<_Ty,_Ax>' being compiled
1> with
1> [
1> _Ty=CryptoPP::HuffmanDecoder::CodeInfo,
1> _Ax=CryptoPP::AllocatorWithCleanup<CryptoPP::HuffmanDecoder::CodeInfo>
1> ]
1> MD5Checksum.cpp
1> ProgressDialog.cpp
1> SmallProgressDialog.cpp
1> SplashScreen.cpp
1> SplashScreenIdleThread.cpp
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
在整个libraray中,唯一对文本“ max_size”的引用就是这些,它们全部位于一个名为secblock.h的文件中。
size_type max_size() const {return ~size_type(0)/sizeof(T);} // switch to std::numeric_limits<T>::max later
size_type max_size() const {return 0;}
size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);}
这是interfaces.cpp文件。希望那是你的意思
// DonorflexDLL.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "constants.h"
#include "interfaces.h"
#include "DonProgress.h"
#include "..\libzipproxy\zipproxy.h"
#include "MD5Checksum.h"
#include "GradientFillBox.h"
#include <NamedPipeClient.h>
#include <PCREWrapper.h>
#include "EnterpriseRegistrationDialog.h"
#include "SplashScreen.h"
#include "SplashScreenIdleThread.h"
#include <InstanceManagerClient.h>
// Headers to support cryptography:
#include <string> // STL
#include <default.h> // Crypto++ libraries.
#include <hex.h> // Hex Encoders and Decords from CryptoPP
#include <base64.h> // base64 Encoders and Decords from CryptoPP
#include <zlib.h> // Compression
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define LIBVER 95
using namespace ui;
using namespace threads;
using namespace std;
using namespace CryptoPP;
/////////////////////////////////////////////////////////////////////////////
// CDon32App
/////////////////////////////////////////////////////////////////////////////
// CDon32App construction
/////////////////////////////////////////////////////////////////////////////
// The one and only CDon32App object
// Global functions for access from DataFlex:
UINT DFXAPI DON32_Version() {
// Version: 1.0 01/05/1997
// Purpose:
// To supply the current version of the library to the Donorflex base system:
// Local Variables:
// Code:
return LIBVER; // Define globally in Don32.h
}
void DFXAPI DON32_About() {
// Version: 1.0 01/05/1997
// Purpose:
// To show the Donorflex Gi About screen.
// Local variables:
// Code:
// TODO
}
HIMAGELIST DFXAPI DON32_GetImageList(UINT uiWhich) {
// Version: 1.0 01/05/1997
// Purpose:
// To return the handle of the standard image list.
// Local variables:
// Code:
// TODO:
// Returns:
return NULL;
}
void DFXAPI DON32_AddBubbleMessage(LPCSTR lpszMsg, DWORD iFont) {
}
// InitBubble, resets the contents of the string arrays and font type,
// must be called before using the bubble routine.
void DFXAPI DON32_InitBubbleWindow(void) {
}
// Tip of the day support:
void DFXAPI DON32_TipAtStartup(void) {
}
void DFXAPI DON32_TipOfTheDay(void) {
}
// Progress Box Thread Control:
/*
Purpose / Description:
This interface is historic and was imported from the original DON32 library
*/
void DFXAPI DON32_BeginProgressThread(HWND hWndParent, DWORD dwAnim, LPSTR lpsCaption, LPSTR lpsTitle, LPSTR lpsMsg, int iCancel) {
CDonProgressThread *instance = CDonProgressThread::GetInstance(hWndParent, dwAnim, lpsCaption, lpsTitle, lpsMsg, iCancel, RGB(0,0x65,0xFF)); // TODO replace this with proper default colour.
}
void DFXAPI DFX_SmallProgress(HWND hWndParent, DWORD dwAnim, LPSTR lpsTitle, LPSTR lpsMsg) {
CDonProgressThread *instance = CDonProgressThread::GetInstance(hWndParent, dwAnim, lpsTitle, lpsMsg);
}
/*
Description:
New interface as of 26/01/2004 by EN to facilitate setting of theme colours
throughout the donorflex application.
*/
void DFXAPI DFX_Progress(HWND hWndParent, DWORD dwAnim, LPSTR lpsCaption, LPSTR lpsTitle, LPSTR lpsMsg, int iCancel, COLORREF gradientColour) {
CDonProgressThread *instance = CDonProgressThread::GetInstance(hWndParent, dwAnim, lpsCaption, lpsTitle, lpsMsg, iCancel, gradientColour);
}
void DFXAPI DON32_EndProgressThread(void) {
CDonProgressThread *instance = CDonProgressThread::GetInstance();
if (instance) instance->CloseInstance();
}
void DFXAPI DON32_ProgressSuspend(void) {
// NOTE: This function is not implemeted in Donorflex.
}
// Progress Box Control:
void DFXAPI DON32_ProgressMsgA(LPSTR lpszMsg) {
CDonProgressThread *instance = CDonProgressThread::GetInstance();
if (instance) instance->SetDialogMessageA(lpszMsg);
}
void DFXAPI DON32_ProgressMsgB(LPSTR lpszMsg) {
CDonProgressThread *instance = CDonProgressThread::GetInstance();
if (instance) instance->SetDialogMessageB(lpszMsg);
}
void DFXAPI DON32_ProgressMeter(int iLow, int iHigh) {
}
void DFXAPI DON32_ProgressSet(int iPos) {
}
void DFXAPI DON32_ProgressStep() {
}
DWORD DFXAPI DON32_QueryProgress(void) {
DWORD dword = FALSE;
CDonProgressThread *instance = CDonProgressThread::GetInstance();
if (instance) dword = (DWORD)instance->isCancelled();
return dword;
}
void DFXAPI DON32_ProgressResume(void) {
CDonProgressThread *instance = CDonProgressThread::GetInstance();
if (instance) instance->ResetDialog();
}
void DFXAPI DON32_EnableSysTray(HWND hwndTarget) {
}
HWND DFXAPI DON32_ShowBubbleWindow(HWND hParent, DWORD bClose) {
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
// CCMAC32App
/////////////////////////////////////////////////////////////////////////////
// CCMAC32App construction
/////////////////////////////////////////////////////////////////////////////
// The one and only CCMAC32App object
// CCMAC32App theApp;
////////////////////////////
// Globals
int DFXAPI CMAC32_GetPassword(LPCSTR lpszTitle, LPCSTR lpszValue) {
return 0;
}
int DFXAPI CMAC32_ChangePassword(LPCSTR lpszValue, LPSTR lpszNew) {
return 0;
}
int DFXAPI CMAC32_Dialog(DWORD wRscId) {
return 0;
}
int DFXAPI CMAC32_SysLog(DWORD wType) {
return 0;
}
UINT DFXAPI CMAC32_Version(void) {
return LIBVER;
}
// New interfaces for Donorflex 6 / 9:
void DFXAPI AMO_Begin(void)
{
// TODO Needs reworking to fit 6.1 service process architecture
}
// NEW!! Introduced for revised who's logged in processing,
// returns nonzero on success.
BOOL DFXAPI AMO_SetDetails(LPCSTR lpUserId, LPCSTR lpDetails)
{
//client::InstanceManagerClient c;
return false; //c.RegisterInstance(::GetCurrentProcessId(), lpUserId, NULL, lpDetails);
}
char current_user_id[24];
BOOL DFXAPI AMO_SetUserId(LPCSTR userId)
{
//AMO_SetDetails(userId, TEXT("No Details specified"));
//strncpy(current_user_id, userId, sizeof(current_user_id));
return false; // TODO
}
BOOL DFXAPI AMO_Workspace(LPCSTR lpWorkspace)
{
// Overwrite the previous details against the current process id, based on the stored user name above.
AMO_SetDetails(current_user_id, lpWorkspace);
return false; // TODO
}
BOOL DFXAPI AMO_NextMessage(LPSTR buffer)
{
return false; // TODO current indicates no more messages.
}
BOOL DFXAPI AMO_Broadcast(void)
{
// TODO
return false;
}
void DFXAPI CMS_Begin(HWND hwnd)
{
return; // TODO
}
BOOL DFXAPI CMS_SendMessage(LPCSTR lpMsg)
{
return false; // TODO
}
BOOL DFXAPI CMS_SendMessage2(LPCSTR lpMsg, LPCSTR lpUserName)
{
// TODO: Support for user name passing.
return false;
}
// MD5 interface:
BOOL DFXAPI MD5_Hash(LPCSTR lpSource, UINT nLength, LPSTR lpResult)
{
CString result;
LPTSTR lptResult;
result = core::CMD5Checksum::GetMD5((BYTE*)lpSource, nLength);
lptResult = result.LockBuffer();
strcpy(lpResult, lptResult);
result.UnlockBuffer();
return FALSE;
}
BOOL DFXAPI UTL_CheckExclusive(LPCSTR sFilename)
{
// Purpose
// To determine whether or not a file can be open exclusively.
// Returns:
// true if file can be accessed exclusively
// false if file cannot be accessed exclusively
// Locals:
CFile oFile;
CFileException oFileException;
BOOL bRetcode;
// Code:
bRetcode = oFile.Open(sFilename, CFile::modeRead|CFile::shareExclusive, &oFileException);
return bRetcode;
}
/*
Purpose / Description:
This interface provides a means by which a dataflex window can be
dynamically subclassed to provide a gradient fill mechanism suitable
for all colours and gradients.
Arguments:
hWnd - a handle of a window to be dynamically subclassed.
red, green, blue - the colour.
*/
BOOL DFXAPI DFX_SubclassGradient(HWND hWnd, COLORREF col)
{
if (CWnd::FromHandlePermanent(hWnd)) return true;
CGradientFillBox *wnd = new CGradientFillBox(col);
BOOL ret = wnd->SubclassWindow(hWnd);
if (!ret) delete wnd;
return ret;
}
/*
General purpose window subclassing.
*/
BOOL DFXAPI DFX_Subclass(HWND hWnd, int type, LPVOID lpExtra) {
/*
if (CWnd::FromHandlePermanent(hWnd)) return true;
// TODO CGradientFillBox *wnd = new CGradientFillBox(col);
BOOL ret = wnd->SubclassWindow(hWnd);
if (!ret) delete wnd;
return ret;
*/
return false;
}
BOOL DFXAPI DFX_Unsubclass(HWND hWnd) {
CWnd *wnd = CWnd::FromHandlePermanent(hWnd);
if (!wnd) return false;
wnd->UnsubclassWindow();
return true;
}
/*
Purpose / Description:
This is a general purpose interface for subclassing windows
for any type. It should be used in preference to the DFX_SubclassGradient
function.
Arguments:
*/
/*
Purpose / Description:
This interface allows the dataflex system to notify the subclassed window
that a change in window colour has occured.
Arguments:
hWnd - The handle of the window to take the notification
COLORREF - The color reference that should be used from now on.
*/
BOOL DFXAPI DFX_NotifyColourChange (HWND hWnd, COLORREF col) {
CGradientFillBox *wnd;
// Get the window class that is mapped to this
wnd = DYNAMIC_DOWNCAST(CGradientFillBox, CWnd::FromHandlePermanent(hWnd));
// If the window handle is null then return the error condition:
ASSERT(wnd);
if (!wnd) return true;
// Now update the COLOREF value associated with the window class:
wnd->SetTargetColour(col);
return false;
}
BOOL DFXAPI DFX_GradientFillDirection(HWND hWnd, int direction) {
CGradientFillBox *wnd;
wnd = DYNAMIC_DOWNCAST(CGradientFillBox, CWnd::FromHandlePermanent(hWnd));
ASSERT(wnd);
if (!wnd) return true;
wnd->SetFillDirection(direction);
return false;
}
// Integer value that governs if thin client mode is active or not:
int operatingmode = OM_NORMAL;
/*
Description:
This API provides a method of switching off the animation and colour
used in the user interactive side of the DLL.
This is required in order to reduce bandwidth required to operate
version 6+ of donorflex.
Assumptions & Pre-conditions:
None
Arguments:
mode - Can either be 0 for standard or 1 for thin terminal services mode.
*/
int DFXAPI DFX_SetOperatingMode(int mode) {
operatingmode = mode;
return mode;
}
int DFXAPI DFX_GetOperatingMode() {
return operatingmode;
}
int DFXAPI DFX_ShowSplashScreen(LPCSTR lpsFilename, COLORREF transparency, LPCSTR lpsRegName, LPCSTR lpsSerialNo, int regx, int regy, int serx, int sery)
{
CPoint reg_point(regx, regy);
CPoint ser_point(serx, sery);
SplashScreenIdleThread::Show(lpsFilename, transparency, lpsRegName, lpsSerialNo, reg_point, ser_point);
return 0;
}
int DFXAPI DFX_HideSplashScreen(HWND hwParent)
{
SplashScreenIdleThread::Hide(hwParent);
return 0;
}
// 13.04.2005: EN : New string encryption routine:
int DFXAPI DFX_EncryptString(const char * encoding, const char * instring, char * outstring, int outbuffsize, const char * passphrase)
{
// Encrypts the given string buffer using the given passphrase and returns the output in the
// buffer provided. Make sure that the size of the passed buffer is adequate.
string ls;
BufferedTransformation * encryptor = NULL;
try {
if (!strcmp(encoding, "base64")) encryptor = new DefaultEncryptorWithMAC(passphrase, new Base64Encoder(new StringSink(ls), false));
if (!strcmp(encoding, "hex")) encryptor = new DefaultEncryptorWithMAC(passphrase, new HexEncoder(new StringSink(ls)));
if (!strcmp(encoding, "zlib")) encryptor = new DefaultEncryptorWithMAC (passphrase, new ZlibCompressor(new StringSink(ls)));
if (!strcmp(encoding, "none")) encryptor = new DefaultEncryptorWithMAC (passphrase, new StringSink(ls));
encryptor->Put((byte *)instring, strlen(instring));
encryptor->MessageEnd();
}
catch (...) {
// Catch all errors
ls = "ERROR";
}
// Cleanup:
if (encryptor!=NULL) delete encryptor;
// Copy returned string into the output buffer:
strncpy(outstring, ls.c_str(), (size_t)outbuffsize);
return ls.size();
}
int DFXAPI DFX_DecryptString(const char * encoding, const char * instring, char * outstring, int outbuffsize, const char * passphrase)
{
string ls;
BufferedTransformation * decryptor = NULL;
try {
if (!strcmp(encoding, "base64")) decryptor = new Base64Decoder(new DefaultDecryptorWithMAC(passphrase, new StringSink(ls)));
if (!strcmp(encoding, "hex")) decryptor = new HexDecoder(new DefaultDecryptorWithMAC(passphrase, new StringSink(ls)));
if (!strcmp(encoding, "zlib")) decryptor = new ZlibDecompressor (new DefaultDecryptorWithMAC(passphrase, new StringSink(ls)));
if (!strcmp(encoding, "none")) decryptor = new DefaultDecryptorWithMAC(passphrase, new StringSink(ls));
decryptor->Put((byte *)instring, strlen(instring));
decryptor->MessageEnd();
}
catch (...) {
// Stop any errors causing a complete mess.
ls = "ERROR";
}
// Cleanup:
if (decryptor != NULL) delete decryptor;
// Copy returned string into the output buffer:
strncpy(outstring, ls.c_str(), (size_t)outbuffsize);
return ls.size(); // No error.
}
最佳答案
您可能需要更新Crypto ++。
Google对此的热门搜索:https://www.google.co.uk/search?q=crypto%2B%2B+HuffManDecoder+compile+error&oq=crypto%2B%2B+HuffManDecoder+compile+error&sourceid=chrome&es_sm=122&ie=UTF-8&gws_rd=ssl
关于c++ - 错误C2664基于旧的crypto++库编译DLL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27291653/