EP_ProtectedStringByID

Post here any topics that related to Enigma Protector, its functionality, your misunderstanding, offers to improvements etc etc etc
Post Reply
Mr. Data
Posts: 3
Joined: Sat Nov 13, 2010 11:03 pm

EP_ProtectedStringByID

Post 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?
Enigma
Site Admin
Posts: 3085
Joined: Wed Aug 20, 2008 2:24 pm

Re: EP_ProtectedStringByID

Post 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 );
Enigma
Site Admin
Posts: 3085
Joined: Wed Aug 20, 2008 2:24 pm

Re: EP_ProtectedStringByID

Post 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!
Mr. Data
Posts: 3
Joined: Sat Nov 13, 2010 11:03 pm

Re: EP_ProtectedStringByID

Post by Mr. Data »

Problem solved! Thanks :)
Post Reply