{ USER DLL EXAMPLE -
  ------------------

  Here is a basic example of making a plugin for Assasin 2.0

  To use the functions below in the Assasin 2.0 client you must
  first,

  1.) upload the dll through the user plugin window in the client
  2.) refresh the user dll list
  3.) select the dll
  4.) in Data to send input the strings for your engine eg -

        getwindir*

        OR

        getsysdir*

        OR

        sendmsg*1*3*hello*hi people!*

  5.) click the Send Command button
  6.) in the returned data box you will see what the dll returned

  Example written by ~LOM~
}

library pluginexample;

uses
  Windows,
  Classes,
  Sysutils;

//==procedures to call==
function MsgBox(pIcon, pButton: Integer; pCaption, pMessages: String): String;
var
  Icon, Button, OutPut: Integer;
  Caption, Messages: PChar;
begin
  Icon := 0;

  Case PIcon of
    1 : Icon := MB_ICONEXCLAMATION;
    2 : Icon := MB_ICONSTOP;
    3 : Icon := MB_ICONQUESTION;
    4 : Icon := MB_ICONINFORMATION;
      else Icon := MB_ICONSTOP;
  end;

  Case PButton of
    1 : Button := MB_OK;
    2 : Button := MB_OKCANCEL;
    3 : Button := MB_YESNO;
    4 : Button := MB_YESNOCANCEL;
    5 : Button := MB_ABORTRETRYIGNORE;
      else Button := MB_OK
  end;

  Caption := PChar(pCaption);
  Messages := PChar(pMessages);

  MessageBox(0, Messages, Caption, Icon + Button + MB_SYSTEMMODAL);
end;

function GetWinDir: string;
var
  pWindowsDir: array [0..255] of char;
  sWindowsDir: string;
begin
  GetWindowsDirectory(pWindowsDir, 255);
  sWindowsDir := StrPas(pWindowsDir);
  swindowsdir := swindowsdir;
  Result := sWindowsDir;
end;

function GetSysDir: String;
var
  pSystemDir: array [0..255] of char;
  sSystemDir: string;
begin
  GetSystemDirectory(pSystemDir, 255);
  sSystemDir := String(pSystemDir);
  sSystemDir := sSystemDir;

  If Length(sSystemDir) = 0 then
    Result := GetWinDir
  else
    Result := sSystemDir;
end;
//==end procedure to call==

//==engine settings==
//procedure for splitting a string into indexed values
procedure StrToStrList(Str, Del: String; var List: TStringList);
var
  PosOfSlash: Integer;
begin
  List.Clear;
  While Length(Str) > 0 do
  begin
    PosOfSlash := Pos(Del, Str);
    If PosOfSlash = 0 then PosOfSlash := length(Str) + 1;
    List.Add(Copy(Str, 1, PosOfSlash - 1));

    Str := Copy(Str, PosOfSlash + 1, length(Str) - PosOfSlash);
  end;
end;

{example of usage :

  getwindir*
  getsysdir*
  sendmsg*2*3*hello people*yo whats up guys*}

function Eng(Strm: Pchar): Pchar;  StdCall;
var
  Lst: TStringList;
  TmpPtr: String;
begin
  Try
    //swap the data over in case the strm pointer gets cleared in shared mem
    TmpPtr := String(Strm);
    Strm := '';

    //Create a string list
    Lst := TStringList.Create;
    //Split the list into section and give it an index
    StrToStrList(TmpPtr, '*', Lst);

    //check to see if the first param is = to one of the below
    If LowerCase(Lst.Strings[0]) = 'getwindir' then
    begin
      Result := Pchar(GetWinDir);
    end;

    If LowerCase(Lst.Strings[0]) = 'getsysdir' then
      Result := Pchar(GetSysDir);

    //example of using multiple params!
    If LowerCase(Lst.Strings[0]) = 'sendmsg' then
    begin
      MsgBox(StrToInt(Lst.Strings[1]), StrToInt(Lst.Strings[2]),
             Lst.Strings[3], Lst.Strings[4]);
      Result := 'Message was received';
    end;

    //checks to see if anything has been returned, if not
    //its possible the user entered an incorrect command
    //or one of the functions returned 0 length

    If Length(Result) = 0 then
      Result := 'Parameter incorrect, or error';

  Finally
    TmpPtr := '';
    FreeAndNil(Lst);
  end;
end;
//==end of engine==

exports Eng;

begin

end.
 