SRL Archive - OSR Help

Help with extension:Unknown identifier 'ThreadSafeCall'


rj

2013-06-10 11:30:30

Trying to make an extension but i get the error:

Unknown identifier 'ThreadSafeCall' 


This is how i initialize it:

procedure SafeInitForm;
var
v: TVariantArray;
begin
SetLength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
DsgnForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetLength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
(*
Auther: Officer Barbrady
*)
procedure OnClick(Sender: TObject);
begin
SafeInitForm;
SafeShowFormModal;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;

procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_Menu.Visible := True;
Simba_MainMenu.Items.ADD(Simba_Menu);

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Name := 'Script Scanner';
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);

Simba_MainMenu.Items.Items[8].Insert(5, Simba_Menu);
end;

begin
ClearDebug;
Init;
end.

Used @Awkwardsaw's example but can't seem to get it to work

Kevin

2013-06-10 11:45:41

Doesn't this require some sort of include?

rj

2013-06-10 11:47:31

From: Kevin
Doesn't this require some sort of include?


No idea I have only the documentation which is pretty much the same info as what awkwardsaw gave me

If your talking about the SRL include, it gives me an error if I try to enabled it, but the script doesn't require any include

Kevin

2013-06-10 12:00:01

Have you tried looking at any other extension (like ODTM) and seeing how it's setup?

rj

2013-06-10 12:11:53

K, I got it to appear in the Simba toolbar but it's not adding menuitems?

procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_Menu.Visible := True;
Simba_MainMenu.Items.ADD(Simba_Menu);

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Name := 'Script Scanner';
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);

Simba_MainMenu.Items.Items[13].Insert(1, Simba_Menu);
end;

begin
//ClearDebug;
Init;
end.

Kevin

2013-06-10 12:20:18

Shouldn't your menu add occur after you add the item? So like this:
procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_Menu.Visible := True;

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Name := 'Script Scanner';
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);
Simba_MainMenu.Items.ADD(Simba_Menu);

// Simba_MainMenu.Items.Items[13].Insert(1, Simba_Menu); idk if this is even needed?
end;

begin
//ClearDebug;
Init;
end.

rj

2013-06-10 12:25:32

From: Kevin
Shouldn't your menu add occur after you add the item? So like this:
procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_Menu.Visible := True;

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Name := 'Script Scanner';
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);
Simba_MainMenu.Items.ADD(Simba_Menu);

// Simba_MainMenu.Items.Items[13].Insert(1, Simba_Menu); idk if this is even needed?
end;

begin
//ClearDebug;
Init;
end.

After I ran that it no longer even adds it to the simba menu, even when i uncomment out the line that you commented out

Kevin

2013-06-10 13:26:46

procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_MainMenu.ITEMS.ADD(Simba_Menu);

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);
end;

begin
//ClearDebug;
Init;
end.
Try that?

rj

2013-06-10 13:29:00

From: Kevin
procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_MainMenu.ITEMS.ADD(Simba_Menu);

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);
end;

begin
//ClearDebug;
Init;
end.
Try that?


Well that did add the menu items thanks but it did not initialize the form?



Form code:

procedure InitForm;
Var
i, c, k, g:Integer;
Strings:TStringArray;
Points, Sizes:TPointArray;
Parents:TIntegerArray;
begin
DsgnForm:=TForm.Create(nil);
with DsgnForm do
begin
Caption:='Simba script scanner Version ' + ToStr(VERSION) + ' By Officer Barbrady and Janilabo';
Left:=377;
Top:=380;
Width:=750;
Height:=460;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
begin
P := TPageControl.Create(DsgnForm);
P.Parent := DsgnForm;
P.SetBounds(0, 0, 750, 460);
Tab1 := TTabSheet.Create(P);
Tab1.Caption := 'Script input';
Tab1.Visible := true;
Tab1.PageControl := P;
Tab2 := TTabSheet.Create(P);
Tab2.Caption := 'Scan settings';
Tab2.Visible := true;
Tab2.PageControl := P;
tab2.PageControl := P;
End;
Strings := ['Paste script into this box, it will look for suspicious lines of code',''];
Points := [Point(120,80),Point(160,90)];
Sizes := [Point(481,177),Point(160,90)];
Parents := [0, 1];
begin
ScriptEdit := TMemo.Create(DsgnForm);
ScriptEdit.Parent:=P.Pages[0];
ScriptEdit.Left := 120;
ScriptEdit.Top := 80;
ScriptEdit.Width := 481;
ScriptEdit.Height := 177;
ScriptEdit.Font.Name := default;
with ScriptEdit.Lines do Add('Paste script into this box, it will look for suspicious lines of code');
ScriptEdit.ScrollBars := ssBoth;
ScriptEdit.TabOrder := 0;
end;

Strings := ['Script scanner version 2.0','Scan settings'];
Points := [Point(225,20),Point(300,20)];
Parents := [0, 1];
for k:=0 to high(TitleLabel) do
begin
TitleLabel[k]:=TLabel.Create(DsgnForm);
TitleLabel[k].Parent:=P.Pages[(Parents[k])];
TitleLabel[k].Caption:=Strings[k];
TitleLabel[k].Left:=Points[k].x;
TitleLabel[k].Top:=Points[k].y;
TitleLabel[k].Width:=43;
TitleLabel[k].Height:=14;
TitleLabel[k].Font.Name:=default;
TitleLabel[k].Font.Color:=clDefault;
TitleLabel[k].Font.Size:=17;
end;
Strings := ['Scan','Update'];
Points := [Point(175,300),Point(400,300)];
for i:= 0 to high(Buttons) do
begin
Buttons[i] := TButton.Create(DsgnForm);
Buttons[i].Parent:=P.Pages[0];
Buttons[i].Caption := Strings[i];
Buttons[i].Left := Points[i].x;
Buttons[i].Top := Points[i].y;
Buttons[i].Width:=150;
Buttons[i].Height:=25;
Buttons[i].Font.Size:=12;
case (i) of
0: Buttons[i].OnClick:=@SaveFormInfo;
1: Buttons[1].OnClick:=@OpenThread;
end;
end;
Strings := ['Scan for HTTP threats','Scan for Webthreats','Scan for Bad code','Debug filtered script','Filter Comments','Filter strings'];
Points := [Point(200,100),Point(400,100),Point(400,200),Point(200,200),Point(200,300),Point(400,300)];
for c := 0 to high(CheckBoxs) do
begin
CheckBoxs[c] := TCheckBox.Create(DsgnForm);
CheckBoxs[c].Parent:=P.Pages[1];
CheckBoxs[c].Left := Points[c].x;
CheckBoxs[c].Top := Points[c].y;
CheckBoxs[c].Width := 97;
CheckBoxs[c].Caption := Strings[c];
end;
end;
{
procedure SafeInitForm;
var
v: TVariantArray;
begin
SetLength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
DsgnForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetLength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
}
(*
Auther: Officer Barbrady
*)
procedure OnClick(Sender: TObject);
begin
// SafeInitForm;
// SafeShowFormModal;
InitForm;
if pressed then Scan;
originalScriptText := '';
filteredScriptText := '';
displayScriptText := '';
end;
function GetName: string;
begin;
Result := 'Script Scanner';
end;
procedure Init;
begin;
Simba_Menu := TMenuItem.Create(Simba_MainMenu);
Simba_Menu.Caption := GetName;
Simba_MainMenu.ITEMS.ADD(Simba_Menu);

AutoColor_MenuItem := TMenuItem.Create(Simba_Menu);
with AutoColor_MenuItem do
begin
Caption := 'Script Scanner Version 2.00';
OnClick := @OnClick;
end;
Simba_Menu.Add(AutoColor_MenuItem);
end;

begin
//ClearDebug;
Init;
end.

Brandon

2013-06-10 13:29:57

:S Modify this to suit your needs..



var
SimbaMenu, Form: TMenuItem;
frmMain: TForm;


Procedure SomeFunc(Sender: TObject);
Begin
Writeln('Clicked..');
End;

procedure InitialiseForm;
begin
frmMain := TForm.Create(nil);
frmMain.SHOW;
end;

procedure Init;
begin
SimbaMenu := TMenuItem.Create(Simba_MainMenu);
SimbaMenu.Caption := 'ScriptScanner';
Simba_MainMenu.Items.Add(SimbaMenu);
Form := TMenuItem.Create(SimbaMenu);
Form.Caption := 'Run';
Form.ShortCut := 123;
Form.OnClick := @SomeFunc;
SimbaMenu.Add(Form);

end;

function GetName : string;
begin;
result := 'Script Scanner';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

procedure Free;
begin

end;

procedure Attach;
begin
writeln(' Script Scanner ');
Writeln('# Script Scanner Simba Extension #');
InitialiseForm;
end;

Procedure Detach;
begin
writeln('Script Scanner: GoodBye!');
frmMain.close;
frmMain.free;
end;

begin
end.

rj

2013-06-10 13:37:08

From: Brandon
:S Modify this to suit your needs..



var
SimbaMenu, Form: TMenuItem;


Procedure SomeFunc(Sender: TObject);
Begin
Writeln('Clicked..');
End;

procedure Init;
begin
SimbaMenu := TMenuItem.Create(Simba_MainMenu);
SimbaMenu.Caption := 'ScriptScanner';
Simba_MainMenu.Items.Add(SimbaMenu);
Form := TMenuItem.Create(SimbaMenu);
Form.Caption := 'Run';
Form.ShortCut := 123;
Form.OnClick := @SomeFunc;
SimbaMenu.Add(Form);

end;

function GetName : string;
begin;
result := 'Script Scanner';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

procedure Free;
begin

end;

procedure Attach;
begin
writeln(' Script Scanner ');
Writeln('# Script Scanner Simba Extension #');
end;

Procedure Detach;
begin
writeln('Script Scanner: GoodBye!');
end;

begin
end.


It does not start the form, it won't let me use threadsafecall.



EDIT NEVERMIND GOT IT

Brandon

2013-06-10 13:37:36

From: Officer Barbrady
It does not start the form, it won't let me use threadsafecall.



I edited the post.. which shows the form.