Page 2 of 3

Re: EP_CryptEncryptBuffer

Posted: Tue Nov 02, 2010 3:56 pm
by Enigma
elore wrote:It happens if you include "enigma_ide.h" more than once in the project. In examples you include it only one time.
Very interesting, agree, I never tried to include this more than once! Feeling it is not a big deal to change definitions.
elore wrote:And to do that I need correct version of EP_RegHardwareIDA(), which is not working for me now.
I think it is better for your project (since it is unicode and seems you do not make support for Win9x) to use unicode version of this API, EP_RegHardwareIDW and also enable Unicode style for licensing in Registration Features - Common panel.

Really, there is no difference what kind of EP_RegHardwareID function you will use. All of them, always, return same results, only difference that W - returns wide string, A - ansi string. The function without prefix EP_RegHardwareID is the same as ansi kind, and it was made just for compatibility with previous versions.

Re: EP_CryptEncryptBuffer

Posted: Tue Nov 02, 2010 8:30 pm
by elore
I need to use the function EP_RegHardwareIDA() to get ANSI string for hardware ID to use here as Key parameter:

Code: Select all

EP_CryptEncryptBuffer encrypts a buffer with the defined key.

Parameters
Buffer - pointer to the memory buffer for encrypting. 
Size - size of the memory buffer. 
Key - pointer to ANSI, null terminated string that will be used as a key for encryption. 

Re: EP_CryptEncryptBuffer

Posted: Wed Nov 03, 2010 7:29 am
by Enigma
Yes, you may use EP_RegHardwareIDA, for example, you may re-declare this function something like this:

Code: Select all

char* __declspec(dllimport) __stdcall EP_RegHardwareIDA();
And put the result of this function to EP_CryptEncryptBuffer.

But, EP_RegHardwareIDW also could be used. There are the couple of the encryption/decryption functions that allows to enter size of the key buffer in bytes, so you may use it:

Code: Select all

void __declspec(dllimport) __stdcall EP_CryptEncryptBufferEx( byte* InBuffer, byte* OutBuffer, int Size, byte* Key, int KeySize);
void __declspec(dllimport) __stdcall EP_CryptDecryptBufferEx( byte* InBuffer, byte* OutBuffer, int Size, byte* Key, int KeySize);

Re: EP_CryptEncryptBuffer

Posted: Wed Nov 03, 2010 8:15 am
by elore
Ok, thanks. I will change the definition for EP_RegHardwareIDA().

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 12:26 am
by elore
Okay, I've done it. But...

Don't know why it happens but if I save and load and decrypt all the registration data myself and if I use only function EP_RegCheckKeyW(sName, sKey) then it crashes in the first section marked with this:

#include "enigma/reg_crypt_begin1.inc"

But if I change EP_RegCheckKeyW(sName, sKey) to EP_RegCheckAndSaveKeyW(sName, sKey) it all works well. Just one single change. How could this happens?...

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 9:48 am
by Enigma
Opps, yes, I forgot to warn you about Crypt Sections. Imagine, the code between RegCrypt markers is decrypted (if registration key allows decryption) at file start. In your case, Enigma does not have valid registration key at start and it does not decrypt the marker.

Once you have registered your application, you should restart it to successfully decrypt RegCrypt markers.

So in your case RegCrypt markers stay encrypted, but program tries to run it, and due to this there is a crash.

How to solve this... hm... it is better if I make an encryption of registration information and encryption it with hardware id. Will try to make it as soon as possible (within weekend). Will update this thread when done!

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 10:25 am
by elore
Ahhhh... Now I understand... I didn't know that I need to restart the app after registration... I actually thought all the encrypted sections are decrypted on the fly each time it executed...

That makes it a bit difficult... I have multi-threaded application and what will happens when during the registration process one thread will go thru encrypted sections which weren't decrypted at start... Very interesting...

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 10:32 am
by Enigma
Application will crash if after successful registration your application will go through RegCrypt. If you are using such kind of markers, then you have to restart program immediately after registering. Only this kind of markers has such limitations.

Anyway, even if you restart program after registration, RegCrypt markers will not be decrypted because at startup Enigma will try to load license from a file (that is absent because you store license in own file). So, shortly, if you plan to store license in own file, you will not be able to use RegCrypt markers.

No worry, I will make all options that you require soon!

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 10:36 am
by elore
I see, thanks a lot!

Re: EP_CryptEncryptBuffer

Posted: Fri Nov 05, 2010 10:39 am
by elore
BTW, Is it possibly to keep application in UNREGISTERED state after successful registration until I restart it? To avoid any crashes in all running threads.

I think it could be very easy for you to do...