Subversion Repositories userdetect2

Compare Revisions

Regard whitespace Rev 86 → Rev 85

/trunk/UserDetect2/UD2_Main.pas
49,8 → 49,8
ErrorsMemo: TMemo;
Memo1: TMemo;
Panel1: TPanel;
OpenTDFButton: TButton;
SaveTDFButton: TButton;
Button1: TButton;
Button2: TButton;
TasksPopupMenu: TPopupMenu;
Run1: TMenuItem;
Properties1: TMenuItem;
62,17 → 62,12
MenuItem1: TMenuItem;
Panel2: TPanel;
Image2: TImage;
DynamicTestGroupbox: TGroupBox;
DynamicTestPluginComboBox: TComboBox;
DynamicTestPluginLabel: TLabel;
DynamicTestDataLabel: TLabel;
DynamicTestDataEdit: TEdit;
DynamicTestButton: TButton;
Button5: TButton;
procedure FormDestroy(Sender: TObject);
procedure TasksListViewDblClick(Sender: TObject);
procedure TasksListViewKeyPress(Sender: TObject; var Key: Char);
procedure OpenTDFButtonClick(Sender: TObject);
procedure SaveTDFButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure URLLabelClick(Sender: TObject);
procedure TasksPopupMenuPopup(Sender: TObject);
procedure Run1Click(Sender: TObject);
84,7 → 79,7
procedure LoadedPluginsPopupMenuPopup(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DynamicTestButtonClick(Sender: TObject);
procedure Button5Click(Sender: TObject);
protected
ud2: TUD2;
procedure LoadTaskList;
91,7 → 86,6
procedure LoadDetectedIDs;
procedure LoadINITemplate;
procedure LoadLoadedPluginList;
procedure LoadDynamicPluginList;
function GetIniFileName: string;
procedure DoRun(ShortTaskName: string);
procedure CheckForErrors;
355,12 → 349,8
SubItems.Add(pl.PluginName);
SubItems.Add(pl.PluginVersion);
SubItems.Add(pl.IdentificationMethodName);
if pl.AcceptsDynamicRequests then
SubItems.Add('Yes')
else
SubItems.Add('No');
SubItems.Add(IntToStr(pl.DetectedIdentifications.Count));
SubItems.Add(Format(LNG_MS, [Max(1,pl.time)])); // at least show 1ms, otherwise it would look unloggical
SubItems.Add(Format(LNG_MS, [Max(1,pl.time)])); // at least show 1ms, otherwise it would be unloggical
SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed);
SubItems.Add(pl.PluginGUIDString);
end;
390,7 → 380,7
end;
end;
 
procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject);
procedure TUD2MainForm.Button1Click(Sender: TObject);
var
cmd: TUD2Command;
begin
401,7 → 391,7
UD2_RunCMD(cmd);
end;
 
procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject);
procedure TUD2MainForm.Button2Click(Sender: TObject);
begin
if CompatSaveDialogExecute(SaveDialog1) then
begin
571,7 → 561,6
LoadDetectedIDs;
LoadINITemplate;
LoadLoadedPluginList;
LoadDynamicPluginList;
CheckForErrors;
 
Visible := true;
585,46 → 574,32
PageControl1.ActivePage := TasksTabSheet;
end;
 
procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject);
procedure TUD2MainForm.Button5Click(Sender: TObject);
var
p: TUD2Plugin;
x: TArrayOfString;
newStuff: boolean;
resourcestring
LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:';
idTerm: string;
cmds: TUD2CommandArray;
sCmds: string;
i: integer;
begin
if DynamicTestPluginComboBox.ItemIndex = -1 then
// TODO xxx: Auch eine Möglichkeit geben, einfach nur "Testecho(abc)" einzugeben und es kommt was bei raus
 
if InputQuery('Enter example term', 'Example: Testecho(abc):abc=calc.exe', idTerm) then
begin
ShowMessage('Please select a plugin that is accepting dynamic requests.');
exit;
end;
SetLength(cmds, 0);
cmds := ud2.CheckTerm(idTerm);
 
p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin;
 
newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, x);
showmessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10));
 
if newStuff then
sCmds := '';
for i := Low(cmds) to High(cmds) do
begin
LoadDetectedIDs;
LoadINITemplate;
sCmds := sCmds + cmds[i].executable + #13#10;
end;
end;
 
procedure TUD2MainForm.LoadDynamicPluginList;
var
i: integer;
p: TUD2Plugin;
begin
for i := 0 to ud2.LoadedPlugins.Count-1 do
begin
p := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
if p.AcceptsDynamicRequests then
begin
DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p);
if Length(cmds) = 0 then
ShowMessage('No commands would be executed.')
else
showmessage('Following commands would be executed:' + #13#10#13#10 + sCmds);
end;
LoadDetectedIDs;
end;
end;
 
end.
/trunk/UserDetect2/UD2_Obj.pas
22,7 → 22,6
// This flag will be set if "AutoOSNotSupportedCompatibility" of the INI manifest had to be enforced/used
OSNotSupportedEnforced: boolean;
 
// TODO: this stuff should be read-only...
PluginDLL: string;
PluginGUID: TGUID;
PluginName: WideString;
29,7 → 28,6
PluginVendor: WideString;
PluginVersion: WideString;
IdentificationMethodName: WideString;
AcceptsDynamicRequests: boolean;
 
// ONLY contains the non-failure status code of IdentificationStringW
IdentificationProcedureStatusCode: UD2_STATUS;
42,8 → 40,7
constructor Create;
function AddIdentification(IdStr: WideString): TUD2IdentificationEntry;
 
function InvokeDynamicCheck(dynamicData: string; var outIDs: TArrayOfString): boolean; overload;
function InvokeDynamicCheck(dynamicData: string): boolean; overload;
function InvokeDynamicCheck(dynamicData: string): boolean;
function GetDynamicRequestResult(dynamicData: string): TArrayOfString;
 
function EqualsMethodNameOrGuid(idMethodNameOrGUID: string): boolean;
195,36 → 192,31
FDetectedIdentifications := TObjectList{<TUD2IdentificationEntry>}.Create(true);
end;
 
function TUD2Plugin.InvokeDynamicCheck(dynamicData: string; var outIDs: TArrayOfString): boolean;
function TUD2Plugin.InvokeDynamicCheck(dynamicData: string): boolean;
var
ude: TUD2IdentificationEntry;
i: integer;
ids: TArrayOfString;
id: string;
l: integer;
begin
result := false;
 
SetLength(outIDs, 0);
 
for i := 0 to FDetectedIdentifications.Count-1 do
begin
ude := FDetectedIdentifications.Items[i] as TUD2IdentificationEntry;
if ude.dynamicDataUsed and (ude.dynamicData = dynamicData) then
begin
l := Length(outIDs);
SetLength(outIDs, l+1);
outIDs[l] := ude.FIdentificationString;
// The dynamic content was already evaluated (and therefore is already added in FDetectedIdentifications).
Exit;
end;
end;
 
// The dynamic content was already evaluated (and therefore is already added in FDetectedIdentifications).
if Length(outIDs) > 0 then exit;
SetLength(ids, 0);
ids := GetDynamicRequestResult(dynamicData);
 
outIDs := GetDynamicRequestResult(dynamicData);
 
for i := 0 to Length(outIDs)-1 do
for i := 0 to Length(ids)-1 do
begin
id := outIDs[i];
id := ids[i];
 
ude := AddIdentification(id);
ude.dynamicDataUsed := true;
256,13 → 248,6
SameText(GUIDToString(PluginGUID), idMethodNameOrGUID)
end;
 
function TUD2Plugin.InvokeDynamicCheck(dynamicData: string): boolean;
var
dummy: TArrayOfString;
begin
result := InvokeDynamicCheck(dynamicData, dummy)
end;
 
{ TUD2IdentificationEntry }
 
procedure TUD2IdentificationEntry.GetIdNames(sl: TStrings);
762,16 → 747,12
Exit;
end;
 
pl := TUD2Plugin.Create;
pl.PluginDLL := dllFile;
 
@fDynamicIdentificationStringW := GetProcAddress(dllHandle, mnDynamicIdentificationStringW);
pl.AcceptsDynamicRequests := Assigned(fDynamicIdentificationStringW);
 
fDynamicIdentificationStringW := nil;
fIdentificationStringW := nil;
if useDynamicData then
begin
if not pl.AcceptsDynamicRequests then
@fDynamicIdentificationStringW := GetProcAddress(dllHandle, mnDynamicIdentificationStringW);
if not Assigned(fDynamicIdentificationStringW) then
begin
// TODO xxx: Darf hier ein fataler Fehler entstehen, obwohl dieses Szenario nur durch die INI file auftreten kann?
// TODO (allgemein): In der Modulübersicht soll auch gezeigt werden, ob dieses Modul dynamischen Content erlaubt.
832,6 → 813,9
Exit;
end;
 
pl := TUD2Plugin.Create;
pl.PluginDLL := dllFile;
 
if not _ApplyCompatibilityGUID then
begin
@fPluginIdentifier := GetProcAddress(dllHandle, mnPluginIdentifier);
/trunk/UserDetect2/UD2_Utils.pas
29,7 → 29,6
end;
 
function SplitString(const aSeparator, aString: string; aMax: Integer = 0): TArrayOfString;
function MergeString(ary: TArrayOfString; glue: string): string;
function BetterInterpreteBool(str: string): boolean;
function GetOwnCmdName: string;
function ExpandEnvStr(const szInput: string): string;
481,16 → 480,4
end;
end;
 
function MergeString(ary: TArrayOfString; glue: string): string;
var
i: integer;
begin
result := '';
for i := Low(ary) to High(ary) do
begin
if result <> '' then result := result + glue;
result := result + ary[i];
end;
end;
 
end.
/trunk/UserDetect2/UD2_Main.dfm
1,9 → 1,9
object UD2MainForm: TUD2MainForm
Left = 202
Top = 139
Width = 897
Height = 519
ActiveControl = IniTemplateMemo
Left = 190
Top = 177
Width = 784
Height = 440
ActiveControl = IdentificationsListView
Caption = 'ViaThinkSoft UserDetect2'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
20,9 → 20,9
object PageControl1: TPageControl
Left = 0
Top = 0
Width = 881
Height = 481
ActivePage = TabSheet3
Width = 768
Height = 402
ActivePage = TabSheet2
Align = alClient
TabOrder = 0
object TasksTabSheet: TTabSheet
30,8 → 30,8
object TasksListView: TVTSListView
Left = 0
Top = 0
Width = 873
Height = 453
Width = 760
Height = 374
Align = alClient
Columns = <>
Items.Data = {
49,11 → 49,14
object TabSheet2: TTabSheet
Caption = 'Identifications'
ImageIndex = 1
DesignSize = (
760
374)
object IdentificationsListView: TVTSListView
Left = 0
Top = 0
Width = 873
Height = 376
Width = 760
Height = 374
Align = alClient
Columns = <
item
74,7 → 77,6
item
Caption = 'GUID of Plugin'
end>
HideSelection = False
ReadOnly = True
RowSelect = True
PopupMenu = IdentificationsPopupMenu
82,60 → 84,17
ViewStyle = vsReport
OnCompare = ListViewCompare
end
object DynamicTestGroupbox: TGroupBox
Left = 0
Top = 376
Width = 873
Height = 77
Align = alBottom
Caption = 'Check Dynamic Query'
object Button5: TButton
Left = 616
Top = 320
Width = 129
Height = 41
Anchors = [akRight, akBottom]
Caption = 'Test dynamic'
TabOrder = 1
DesignSize = (
873
77)
object DynamicTestPluginLabel: TLabel
Left = 16
Top = 24
Width = 29
Height = 13
Caption = 'Plugin'
OnClick = Button5Click
end
object DynamicTestDataLabel: TLabel
Left = 272
Top = 24
Width = 67
Height = 13
Caption = 'Dynamic Data'
end
object DynamicTestPluginComboBox: TComboBox
Left = 16
Top = 40
Width = 225
Height = 21
Style = csDropDownList
ItemHeight = 13
TabOrder = 0
end
object DynamicTestDataEdit: TEdit
Left = 272
Top = 40
Width = 441
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 1
end
object DynamicTestButton: TButton
Left = 736
Top = 32
Width = 121
Height = 33
Anchors = [akTop, akRight]
Caption = 'Query'
TabOrder = 2
OnClick = DynamicTestButtonClick
end
end
end
object TabSheet3: TTabSheet
Caption = 'Task Definition File Template'
ImageIndex = 2
142,8 → 101,8
object IniTemplateMemo: TMemo
Left = 0
Top = 0
Width = 873
Height = 402
Width = 760
Height = 323
Align = alClient
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
150,7 → 109,6
Font.Height = -12
Font.Name = 'Courier New'
Font.Style = []
HideSelection = False
ParentFont = False
ReadOnly = True
ScrollBars = ssBoth
159,16 → 117,16
end
object Panel1: TPanel
Left = 0
Top = 402
Width = 873
Top = 323
Width = 760
Height = 51
Align = alBottom
BevelOuter = bvNone
TabOrder = 1
DesignSize = (
873
760
51)
object OpenTDFButton: TButton
object Button1: TButton
Left = 8
Top = 8
Width = 209
176,10 → 134,10
Anchors = [akLeft, akTop, akBottom]
Caption = 'Open current Task Definition File'
TabOrder = 0
OnClick = OpenTDFButtonClick
OnClick = Button1Click
end
object SaveTDFButton: TButton
Left = 654
object Button2: TButton
Left = 541
Top = 8
Width = 209
Height = 33
186,7 → 144,7
Anchors = [akTop, akRight, akBottom]
Caption = 'Save as new Task Definition File'
TabOrder = 1
OnClick = SaveTDFButtonClick
OnClick = Button2Click
end
end
end
196,8 → 154,8
object LoadedPluginsListView: TVTSListView
Left = 0
Top = 0
Width = 873
Height = 453
Width = 760
Height = 374
Align = alClient
Columns = <
item
221,9 → 179,6
Width = 100
end
item
Caption = 'Dynamic?'
end
item
Caption = 'Detected IDs'
end
item
236,7 → 191,6
Caption = 'GUID of Plugin'
Width = 100
end>
HideSelection = False
ReadOnly = True
RowSelect = True
PopupMenu = LoadedPluginsPopupMenu
249,8 → 203,8
Caption = 'About'
ImageIndex = 4
DesignSize = (
873
453)
760
374)
object Image1: TImage
Left = 8
Top = 8
670,10 → 624,9
object Memo1: TMemo
Left = 264
Top = 8
Width = 595
Height = 435
Width = 482
Height = 356
Anchors = [akLeft, akTop, akRight, akBottom]
HideSelection = False
Lines.Strings = (
' GNU GENERAL PUBLIC LICENSE'
' Version 3, 29 June 2007'
2150,10 → 2103,9
object ErrorsMemo: TMemo
Left = 49
Top = 0
Width = 824
Height = 453
Width = 711
Height = 374
Align = alClient
HideSelection = False
Lines.Strings = (
'')
ReadOnly = True
2164,7 → 2116,7
Left = 0
Top = 0
Width = 49
Height = 453
Height = 374
Align = alLeft
BevelOuter = bvNone
TabOrder = 1