Dynamically Calling Windows Apis With Encryption

Submitted by:Jhon Brain

Date added:31 May, 2014

Category:Delphi

Delphi snippet details dynamically calling windows apis with encryption.

Tags: windows apis , calling windows , encryption

Code Snippet:

program DynamiqueAPI;
//cswi
uses
Windows;

type
TMessageBoxA = function(Handle : Cardinal;
lpText : PAnsiChar;
lpCaption : PAnsiChar;
uType : Cardinal) : Cardinal; stdcall;

function EnDeCrypt(const Value : String) : String;
var
CharIndex : integer;
begin
Result := Value;
for CharIndex := 1 to Length(Value) do
Result[CharIndex] := chr(not(ord(Value[CharIndex])));
end;

var
hUser32 : Cardinal;
xMessageBoxA : TMessageBoxA;
sMessageBoxA : PAnsiChar;
begin
sMessageBoxA := PAnsiChar(EnDeCrypt('²šŒŒž˜š½‡¾'));
hUser32 := LoadLibraryA('user32.dll');
@xMessageBoxA := GetProcAddress(hUser32, sMessageBoxA);
if Assigned(xMessageBoxA) then
xMessageBoxA(0, 'Hello World', '', 0);
end.
 
 

Comments