Debugging EP_ProtectedStringBy*
Debugging EP_ProtectedStringBy*
Hi,
I have a program using EP_ProtectedStringBy* functions in a few critical places and I would like to debug them. The problem is that if I protect the code with Enigma I can't run it in the debugger, but if I don't protect it I don't get the strings... Any advice?
Thanks in advance,
I have a program using EP_ProtectedStringBy* functions in a few critical places and I would like to debug them. The problem is that if I protect the code with Enigma I can't run it in the debugger, but if I don't protect it I don't get the strings... Any advice?
Thanks in advance,
Re: Debugging EP_ProtectedStringBy*
Hi iaanus, frustrating, but debugging is not possible using Enigma Protector.
But, why you can't run your program under debugger? If you are using Enigma API, then compiled application will require enigma_ide.dll. To run compiled application without protection simply take enigma_ide.dll from the installation folder of Enigma Protector and place it to the same folder with your compiled program. After that you will be able to run your program in debugger, just EP_ProtectedStringBy* will fail (until file is protected)
But, why you can't run your program under debugger? If you are using Enigma API, then compiled application will require enigma_ide.dll. To run compiled application without protection simply take enigma_ide.dll from the installation folder of Enigma Protector and place it to the same folder with your compiled program. After that you will be able to run your program in debugger, just EP_ProtectedStringBy* will fail (until file is protected)
Re: Debugging EP_ProtectedStringBy*
Yes, yes, I can run the program in the debugger using enigma_ide.dll, I just don't get the protected strings because EP_ProtectedStringBy* fails. The problem is that I can't debug the code that depends on those strings to be present I think I'll resort to macros that expand to string literals in debug mode and to EP_ProtectedStringBy* calls in release mode.
Re: Debugging EP_ProtectedStringBy*
yes, just simply use macros or IFDEF for Delphi.
For example, something like this may be used (Delphi):
For example, something like this may be used (Delphi):
Code: Select all
var
str : string;
cnt : integer;
begin
...
{$IFDEF DEBUG}
str := 'my hidden string';
{$ELSE}
cnt := EP_ProtectedStringById(12345, nil, 0);
SetLength(str, cnt);
EP_ProtectedStringById(12345, pointer(str), cnt);
{$ENDIF}
...
end;
Re: Debugging EP_ProtectedStringBy*
In case anyone is interested, I am using this in C++:
Code: Select all
#ifdef _DEBUG
#define EP_PROTECTED_STRING(id, str) std::string(str)
#else
#define EP_PROTECTED_STRING(id, str) getEPProtectedString(id)
static std::string getEPProtectedString(int id)
{
int size = EP_ProtectedStringByID(id, 0, 0);
std::string result(size, '\0');
EP_ProtectedStringByID(id, &result[0], size);
return result;
}
#endif
Re: Debugging EP_ProtectedStringBy*
thanks iaanus for the useful code!
-
- Posts: 17
- Joined: Wed Oct 10, 2012 8:09 am
Re: Debugging EP_ProtectedStringBy*
In BCB I'm using this macro
Code: Select all
#ifdef DEBUG
#define PROTECTED_STRING_BY_ID(id, str) str
#else
#define PROTECTED_STRING_BY_ID(id, str) GetProtectedStringByID(id)
#endif
String __fastcall TfrmMain::GetProtectedStringByID(int id)
{
#include "Enigma\vm_begin.inc"
int len = EP_ProtectedStringByID( id, NULL, 0 );
char* str = new char[len + 1];
memset(str , 0, len + 1);
EP_ProtectedStringByID( id, str, len );
#include "Enigma\vm_end.inc"
return ((String)str);
}
Re: Debugging EP_ProtectedStringBy*
Thanks mtx-electronics, I will test it out and add this function to the enigma_ide.h!