Click here to Skip to main content
11,929,939 members (49,169 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C Errors cryptography
Hello. I have such function. But there is an error: "R6010 - abort has been called". Could anyone help me with this error?
void Encrypt (char *pszFile, char *pszSecret) {
	int size;
	char *buf;
	_bstr_t cipherText;
	string name;
	ifstream in (pszFile, ios::in | ios::binary | ios::ate);
	ofstream out;
	IAlgorithmPtr algo;
	IEncryptedDataPtr encryptor;
	if ( !in.is_open() )
		cout << szErrNoFile << std::endl;
	else {
		size = in.tellg();
		buf = new char[size + 1];
		buf[size] = 0;
		in.seekg(0, ios::beg);, size);
		encryptor->PutContent(_bstr_t (buf)); //I THINK ERROR IS HERE

		algo = encryptor->GetAlgorithm();
		encryptor->SetSecret(_bstr_t (pszSecret), CAPICOM_SECRET_PASSWORD);
		cipherText = encryptor->Encrypt(CAPICOM_ENCODE_BASE64);
		name = pszFile;
		name.append(".encrypted");, ios::out | ios::binary);

		if ( !out.is_open() )
			cout << szErrWrite << endl;
		else {
			out << cipherText;
Posted 1-Feb-13 7:47am
jibesh 1-Feb-13 13:55pm
are you sure you have downloaded the Platform SDK with this 'Capicom.dll' and registered in your PC?

Read this article

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That's an unusual error. R6010 is an abort from the C library, MSVCRT in this case. I'd check that your program really gets as far as the line you've indicated. (by setting a breakpoint) If so then you must be doing some serious memory corruption. If not than my guess would be you've got the wrong libraries linked up and your program is failing on startup. Don't usually see an R6010 except during startup. Have you doctored the /ENTRYPOINT or something?
Anyway if it is getting to the point you've marked make sure encryptor is initialised correctly so you can assign to it and don't use BSTRs unless you absolutely have to, they're not know as BeeStings for nothing. You could also try a larger buffer in case encryption is increasing the length of your data.
By the time you've tried all that you'll probably have spotted some mistake that I missed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100