EP_ProtectedStringByID
The EP_ProtectedStringByID function returns protected strings. See also Protection Features - Protected Strings.
Parameters
- ID - the ID of the protected string - an integer value.
- Buffer - a pointer to the buffer for the protected string. If this parameter is NULL, the function returns the necessary size of buffer.
- Len - the size of the Buffer for the protected string.
Return Value
The function returns the size of the buffer for a protected string or 0 if the function fails.
Remark
The function fails in the following cases:
- there is no protected string with the specified ID;
- the application is not protected.
Definition
Show/Hide C++ function definition
extern "C" __declspec( dllimport ) __stdcall int EP_ProtectedStringByID( int Total, char* Buffer, int Len);
Show/Hide Delphi function definition
function EP_ProtectedStringByID(ID : integer; Buffer : pointer; Len : integer) : integer; stdcall;
Show/Hide Visual Basic function definition
Public Declare Function EP_ProtectedStringByID Lib "enigma_ide.dll" (ByVal ID As Long, ByVal Str As String, ByVal Length As Byte) As Byte
Show/Hide C# (.NET) function definition
public class Enigma_IDE
{
[DllImport("enigma_ide.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int32 EP_ProtectedStringByID(Int32 ID, IntPtr Buffer, Int32 Len);
}
Examples
Show/Hide Delphi function example
uses
enigma_ide;
procedure TForm1.FormShow(Sender: TObject);
var
str : shortstring;
len : byte;
arr : array [0..MAX_STRING_SIZE - 1] of char;
buflen : integer;
buf : pointer;
begin
len := EP_ProtectedStringByKey('fyi6z02Y', @str[1], sizeof(str));
if len > 0 then
begin
str[0] := char(len);
Edit1.Text := str;
end;
ZeroMemory(@arr, sizeof(arr));
if EP_ProtectedStringByID(1, @arr, sizeof(arr)) > 0 then
begin
Edit2.Text := arr;
end;
buflen := EP_ProtectedStringByKey('26Lu66Er', nil, 0);
if buflen > 0 then
begin
GetMem(buf, buflen + 1);
ZeroMemory(buf, buflen + 1);
if EP_ProtectedStringByKey('26Lu66Er', buf, buflen) > 0 then
begin
Edit3.Text := PAnsiChar(buf);
end;
FreeMem(buf);
end;
end;
Show/Hide C# (.NET) function example
public class Enigma_IDE
{
public static string EP_ProtectedStringByIDAsAnsiString(int ID)
{
Int32 len = EP_ProtectedStringByID(ID, IntPtr.Zero, 0);
if (len > 0)
{
byte[] buffer = new byte[len];
if (EP_ProtectedStringByID(ID, Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0), len) > 0)
{
return Encoding.ASCII.GetString(buffer);
}
}
return string.Empty;
}
public static string EP_ProtectedStringByIDAsWideString(int ID)
{
Int32 len = EP_ProtectedStringByID(ID, IntPtr.Zero, 0);
if (len > 0)
{
byte[] buffer = new byte[len];
if (EP_ProtectedStringByID(ID, Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0), len) > 0)
{
return Encoding.Unicode.GetString(buffer);
}
}
return string.Empty;
}
}
private void Form1_Shown(object sender, EventArgs e)
{
textBox1.Text = Enigma_IDE.EP_ProtectedStringByIDAsAnsiString(1);
textBox2.Text = Enigma_IDE.EP_ProtectedStringByIDAsWideString(2);
}
Show/Hide Visual Basic function example
Private Sub Form_Load()
Dim Lenght As Byte
Dim Str As String
Length = EP_ProtectedStringByKey("fyi6z02Y", vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByKey("fyi6z02Y", Str, Length) > 0 Then
Text1.Text = Str
End If
Length = EP_ProtectedStringByID(1, vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByID(1, Str, Length) > 0 Then
Text2.Text = Str
End If
Length = EP_ProtectedStringByKey("26Lu66Er", vbNullString, 0)
Str = String$(Length, 0)
If EP_ProtectedStringByKey("26Lu66Er", Str, Length) > 0 Then
Text3.Text = Str
End If
See function examples in the installation folder, Examples\ProtectedStrings subfolder.