Pascalscript ve Anivirus programları

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
PROGRAMADOR
Üye
Mesajlar: 239
Kayıt: 04 Oca 2008 01:53
Konum: Karşıyaka/İzmir

Pascalscript ve Anivirus programları

Mesaj gönderen PROGRAMADOR »

Merhaba,

Kod: Tümünü seç

unit ufrmMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
   uPSCompiler,
  uPSRuntime, Vcl.StdCtrls;

type
  TfrmMain = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;



var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure MyOwnFunction(const Data: string);
begin
  // Do something with Data
  ShowMessage(Data);
end;

{$IFDEF UNICODE}
function ScriptOnUses(Sender: TPSPascalCompiler; const Name: AnsiString): Boolean;
{$ELSE}
function ScriptOnUses(Sender: TPSPascalCompiler; const Name: string): Boolean;
{$ENDIF}

{ the OnUses callback function is called for each "uses" in the script.
  It's always called with the parameter 'SYSTEM' at the top of the script.
  For example: uses ii1, ii2;
  This will call this function 3 times. First with 'SYSTEM' then 'II1' and then 'II2'.
}
begin
  if Name = 'SYSTEM' then
  begin
    Sender.AddDelphiFunction('procedure MyOwnFunction(Data: string)');
    { This will register the function to the script engine. Now it can be used from
      within the script.}

    Result := True;
  end else
    Result := False;
end;


procedure ExecuteScript(const Script: string);
var
  Compiler: TPSPascalCompiler;
  { TPSPascalCompiler is the compiler part of the scriptengine. This will
    translate a Pascal script into a compiled form the executer understands. }
  Exec: TPSExec;
   { TPSExec is the executer part of the scriptengine. It uses the output of
    the compiler to run a script. }
  {$IFDEF UNICODE}Data: AnsiString;{$ELSE}Data: string;{$ENDIF}
begin
  Compiler := TPSPascalCompiler.Create; // create an instance of the compiler.
  Compiler.OnUses := ScriptOnUses; // assign the OnUses event.
  if not Compiler.Compile(Script) then  // Compile the Pascal script into bytecode.
  begin
    Compiler.Free;
     // You could raise an exception here.
    Exit;
  end;

  Compiler.GetOutput(Data); // Save the output of the compiler in the string Data.
  Compiler.Free; // After compiling the script, there is no need for the compiler anymore.

  Exec := TPSExec.Create;  // Create an instance of the executer.
  Exec.RegisterDelphiFunction(@MyOwnFunction, 'MYOWNFUNCTION', cdRegister);
  { This will register the function to the executer. The first parameter is a
    pointer to the function. The second parameter is the name of the function (in uppercase).
	And the last parameter is the calling convention (usually Register). }

  if not  Exec.LoadData(Data) then // Load the data from the Data string.
  begin
    { For some reason the script could not be loaded. This is usually the case when a
      library that has been used at compile time isn't registered at runtime. }
    Exec.Free;
     // You could raise an exception here.
    Exit;
  end;

  Exec.RunScript; // Run the script.
  Exec.Free; // Free the executer.
end;

const
  Script = 'var s: string; begin s := ''Test''; S := s + ''ing;''; MyOwnFunction(s); end.';

procedure TfrmMain.Button1Click(Sender: TObject);
begin
  ExecuteScript(Script);
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
//

end;

end.

Bu kodu derliyorum programda ama exe oluşur oluşmaz Comodo exe'yi karantinaya taşıyor. Pascal scriptte antivirus programlarına takılmamanın yolu var mı?
In dubio pro reo...
Şüpheden sanık/özgürlük yararlanır...
omurolmez
Üye
Mesajlar: 187
Kayıt: 31 Eki 2012 11:41

Re: Pascalscript ve Anivirus programları

Mesaj gönderen omurolmez »

Innosetup kullanıyorum. Innosetup kendi içinde pascalScript kullanıyor. Ne kendi bilgisayarımda ne de müşterilerde hiçbir sorun yaşamadım. Kendi bilgisayarımda farklı zamanlarda Kaspersky ve Trendmicro antivirüs yazılımları kullandım. Müşterilerde de zaman zaman çeşitli antivirüs yazılımlarına denk geliyoruz.
Ömür Ölmez
PROGRAMADOR
Üye
Mesajlar: 239
Kayıt: 04 Oca 2008 01:53
Konum: Karşıyaka/İzmir

Re: Pascalscript ve Anivirus programları

Mesaj gönderen PROGRAMADOR »

ExecuteScript(Script);

kodunu yazınca maalesef Comodo programı karantinaya alıyor.
In dubio pro reo...
Şüpheden sanık/özgürlük yararlanır...
Cevapla