Page 1 of 1

EP_ProtectedStringByID

Posted: Tue Nov 16, 2010 1:07 am
by Mr. Data
i'm having problem working with EP_ProtectedStringByID


int len = EP_ProtectedStringByID( 1, NULL, 0 );
char *str_001 = new char[ len ];
EP_ProtectedStringByID( 1, str_001, len );


For most of strings it's working good (i've 17 protected strings) , but in one it's returning trash characters at the end of the string, and i don't have a clue why, any ideas?

Re: EP_ProtectedStringByID

Posted: Tue Nov 16, 2010 9:16 am
by Enigma
Hi Mr. Data, strange, there should not be any problem.

We did not face any problem with this feature, so can't advice anything without test files.. Could you at least send me your project file (.enigma) at support@enigmaprotector.com and I will try to check this out?

I'm also worrying about the code, maybe it should look like:

Code: Select all

int len = EP_ProtectedStringByID( 1, NULL, 0 );
char str_001 = new char[ len ];
EP_ProtectedStringByID( 1, &str_001, len );
or

Code: Select all

int len = EP_ProtectedStringByID( 1, NULL, 0 );
char str_001[len];
EP_ProtectedStringByID( 1, &str_001, len );

Re: EP_ProtectedStringByID

Posted: Tue Nov 16, 2010 5:45 pm
by Enigma
I've just figured out what is wrong there. There is a problem with your code.

Since you are using Protected Strings as ansi-strings, each ansi string should be terminated with zero symbol. In your case, you are allocating the array for string, but forgot the termination zero.

So the code should look like:

Code: Select all

int len = EP_ProtectedStringByID( 1, NULL, 0 );
char* str_001 = new char[ len + 1 ];
memset(str_001 , 0, len + 1);
EP_ProtectedStringByID( 1, str_001, len );
I think this should work correctly!

Re: EP_ProtectedStringByID

Posted: Wed Nov 17, 2010 1:03 am
by Mr. Data
Problem solved! Thanks :)