/trunk/UserDetect2/UD2_Main.dfm |
---|
1,9 → 1,9 |
object UD2MainForm: TUD2MainForm |
Left = 190 |
Top = 177 |
Width = 784 |
Height = 440 |
ActiveControl = IdentificationsListView |
Left = 202 |
Top = 139 |
Width = 897 |
Height = 519 |
ActiveControl = IniTemplateMemo |
Caption = 'ViaThinkSoft UserDetect2' |
Color = clBtnFace |
Font.Charset = DEFAULT_CHARSET |
20,9 → 20,9 |
object PageControl1: TPageControl |
Left = 0 |
Top = 0 |
Width = 768 |
Height = 402 |
ActivePage = TabSheet2 |
Width = 881 |
Height = 481 |
ActivePage = TabSheet3 |
Align = alClient |
TabOrder = 0 |
object TasksTabSheet: TTabSheet |
30,8 → 30,8 |
object TasksListView: TVTSListView |
Left = 0 |
Top = 0 |
Width = 760 |
Height = 374 |
Width = 873 |
Height = 453 |
Align = alClient |
Columns = <> |
Items.Data = { |
49,14 → 49,11 |
object TabSheet2: TTabSheet |
Caption = 'Identifications' |
ImageIndex = 1 |
DesignSize = ( |
760 |
374) |
object IdentificationsListView: TVTSListView |
Left = 0 |
Top = 0 |
Width = 760 |
Height = 374 |
Width = 873 |
Height = 376 |
Align = alClient |
Columns = < |
item |
77,6 → 74,7 |
item |
Caption = 'GUID of Plugin' |
end> |
HideSelection = False |
ReadOnly = True |
RowSelect = True |
PopupMenu = IdentificationsPopupMenu |
84,17 → 82,60 |
ViewStyle = vsReport |
OnCompare = ListViewCompare |
end |
object Button5: TButton |
Left = 616 |
Top = 320 |
Width = 129 |
Height = 41 |
Anchors = [akRight, akBottom] |
Caption = 'Test dynamic' |
object DynamicTestGroupbox: TGroupBox |
Left = 0 |
Top = 376 |
Width = 873 |
Height = 77 |
Align = alBottom |
Caption = 'Check Dynamic Query' |
TabOrder = 1 |
OnClick = Button5Click |
DesignSize = ( |
873 |
77) |
object DynamicTestPluginLabel: TLabel |
Left = 16 |
Top = 24 |
Width = 29 |
Height = 13 |
Caption = 'Plugin' |
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 |
101,8 → 142,8 |
object IniTemplateMemo: TMemo |
Left = 0 |
Top = 0 |
Width = 760 |
Height = 323 |
Width = 873 |
Height = 402 |
Align = alClient |
Font.Charset = ANSI_CHARSET |
Font.Color = clWindowText |
109,6 → 150,7 |
Font.Height = -12 |
Font.Name = 'Courier New' |
Font.Style = [] |
HideSelection = False |
ParentFont = False |
ReadOnly = True |
ScrollBars = ssBoth |
117,16 → 159,16 |
end |
object Panel1: TPanel |
Left = 0 |
Top = 323 |
Width = 760 |
Top = 402 |
Width = 873 |
Height = 51 |
Align = alBottom |
BevelOuter = bvNone |
TabOrder = 1 |
DesignSize = ( |
760 |
873 |
51) |
object Button1: TButton |
object OpenTDFButton: TButton |
Left = 8 |
Top = 8 |
Width = 209 |
134,10 → 176,10 |
Anchors = [akLeft, akTop, akBottom] |
Caption = 'Open current Task Definition File' |
TabOrder = 0 |
OnClick = Button1Click |
OnClick = OpenTDFButtonClick |
end |
object Button2: TButton |
Left = 541 |
object SaveTDFButton: TButton |
Left = 654 |
Top = 8 |
Width = 209 |
Height = 33 |
144,7 → 186,7 |
Anchors = [akTop, akRight, akBottom] |
Caption = 'Save as new Task Definition File' |
TabOrder = 1 |
OnClick = Button2Click |
OnClick = SaveTDFButtonClick |
end |
end |
end |
154,8 → 196,8 |
object LoadedPluginsListView: TVTSListView |
Left = 0 |
Top = 0 |
Width = 760 |
Height = 374 |
Width = 873 |
Height = 453 |
Align = alClient |
Columns = < |
item |
179,6 → 221,9 |
Width = 100 |
end |
item |
Caption = 'Dynamic?' |
end |
item |
Caption = 'Detected IDs' |
end |
item |
191,6 → 236,7 |
Caption = 'GUID of Plugin' |
Width = 100 |
end> |
HideSelection = False |
ReadOnly = True |
RowSelect = True |
PopupMenu = LoadedPluginsPopupMenu |
203,8 → 249,8 |
Caption = 'About' |
ImageIndex = 4 |
DesignSize = ( |
760 |
374) |
873 |
453) |
object Image1: TImage |
Left = 8 |
Top = 8 |
624,9 → 670,10 |
object Memo1: TMemo |
Left = 264 |
Top = 8 |
Width = 482 |
Height = 356 |
Width = 595 |
Height = 435 |
Anchors = [akLeft, akTop, akRight, akBottom] |
HideSelection = False |
Lines.Strings = ( |
' GNU GENERAL PUBLIC LICENSE' |
' Version 3, 29 June 2007' |
2103,9 → 2150,10 |
object ErrorsMemo: TMemo |
Left = 49 |
Top = 0 |
Width = 711 |
Height = 374 |
Width = 824 |
Height = 453 |
Align = alClient |
HideSelection = False |
Lines.Strings = ( |
'') |
ReadOnly = True |
2116,7 → 2164,7 |
Left = 0 |
Top = 0 |
Width = 49 |
Height = 374 |
Height = 453 |
Align = alLeft |
BevelOuter = bvNone |
TabOrder = 1 |
/trunk/UserDetect2/UD2_Main.pas |
---|
49,8 → 49,8 |
ErrorsMemo: TMemo; |
Memo1: TMemo; |
Panel1: TPanel; |
Button1: TButton; |
Button2: TButton; |
OpenTDFButton: TButton; |
SaveTDFButton: TButton; |
TasksPopupMenu: TPopupMenu; |
Run1: TMenuItem; |
Properties1: TMenuItem; |
62,12 → 62,17 |
MenuItem1: TMenuItem; |
Panel2: TPanel; |
Image2: TImage; |
Button5: TButton; |
DynamicTestGroupbox: TGroupBox; |
DynamicTestPluginComboBox: TComboBox; |
DynamicTestPluginLabel: TLabel; |
DynamicTestDataLabel: TLabel; |
DynamicTestDataEdit: TEdit; |
DynamicTestButton: TButton; |
procedure FormDestroy(Sender: TObject); |
procedure TasksListViewDblClick(Sender: TObject); |
procedure TasksListViewKeyPress(Sender: TObject; var Key: Char); |
procedure Button1Click(Sender: TObject); |
procedure Button2Click(Sender: TObject); |
procedure OpenTDFButtonClick(Sender: TObject); |
procedure SaveTDFButtonClick(Sender: TObject); |
procedure URLLabelClick(Sender: TObject); |
procedure TasksPopupMenuPopup(Sender: TObject); |
procedure Run1Click(Sender: TObject); |
79,7 → 84,7 |
procedure LoadedPluginsPopupMenuPopup(Sender: TObject); |
procedure MenuItem1Click(Sender: TObject); |
procedure FormCreate(Sender: TObject); |
procedure Button5Click(Sender: TObject); |
procedure DynamicTestButtonClick(Sender: TObject); |
protected |
ud2: TUD2; |
procedure LoadTaskList; |
86,6 → 91,7 |
procedure LoadDetectedIDs; |
procedure LoadINITemplate; |
procedure LoadLoadedPluginList; |
procedure LoadDynamicPluginList; |
function GetIniFileName: string; |
procedure DoRun(ShortTaskName: string); |
procedure CheckForErrors; |
349,8 → 355,12 |
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 be unloggical |
SubItems.Add(Format(LNG_MS, [Max(1,pl.time)])); // at least show 1ms, otherwise it would look unloggical |
SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed); |
SubItems.Add(pl.PluginGUIDString); |
end; |
380,7 → 390,7 |
end; |
end; |
procedure TUD2MainForm.Button1Click(Sender: TObject); |
procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject); |
var |
cmd: TUD2Command; |
begin |
391,7 → 401,7 |
UD2_RunCMD(cmd); |
end; |
procedure TUD2MainForm.Button2Click(Sender: TObject); |
procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject); |
begin |
if CompatSaveDialogExecute(SaveDialog1) then |
begin |
561,6 → 571,7 |
LoadDetectedIDs; |
LoadINITemplate; |
LoadLoadedPluginList; |
LoadDynamicPluginList; |
CheckForErrors; |
Visible := true; |
574,32 → 585,46 |
PageControl1.ActivePage := TasksTabSheet; |
end; |
procedure TUD2MainForm.Button5Click(Sender: TObject); |
procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject); |
var |
idTerm: string; |
cmds: TUD2CommandArray; |
sCmds: string; |
i: integer; |
p: TUD2Plugin; |
x: TArrayOfString; |
newStuff: boolean; |
resourcestring |
LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:'; |
begin |
// 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 |
if DynamicTestPluginComboBox.ItemIndex = -1 then |
begin |
SetLength(cmds, 0); |
cmds := ud2.CheckTerm(idTerm); |
ShowMessage('Please select a plugin that is accepting dynamic requests.'); |
exit; |
end; |
sCmds := ''; |
for i := Low(cmds) to High(cmds) do |
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 |
begin |
sCmds := sCmds + cmds[i].executable + #13#10; |
LoadDetectedIDs; |
LoadINITemplate; |
end; |
end; |
if Length(cmds) = 0 then |
ShowMessage('No commands would be executed.') |
else |
showmessage('Following commands would be executed:' + #13#10#13#10 + sCmds); |
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); |
end; |
LoadDetectedIDs; |
end; |
end; |
end. |
/trunk/UserDetect2/UD2_Obj.pas |
---|
22,6 → 22,7 |
// 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; |
28,6 → 29,7 |
PluginVendor: WideString; |
PluginVersion: WideString; |
IdentificationMethodName: WideString; |
AcceptsDynamicRequests: boolean; |
// ONLY contains the non-failure status code of IdentificationStringW |
IdentificationProcedureStatusCode: UD2_STATUS; |
40,7 → 42,8 |
constructor Create; |
function AddIdentification(IdStr: WideString): TUD2IdentificationEntry; |
function InvokeDynamicCheck(dynamicData: string): boolean; |
function InvokeDynamicCheck(dynamicData: string; var outIDs: TArrayOfString): boolean; overload; |
function InvokeDynamicCheck(dynamicData: string): boolean; overload; |
function GetDynamicRequestResult(dynamicData: string): TArrayOfString; |
function EqualsMethodNameOrGuid(idMethodNameOrGUID: string): boolean; |
192,31 → 195,36 |
FDetectedIdentifications := TObjectList{<TUD2IdentificationEntry>}.Create(true); |
end; |
function TUD2Plugin.InvokeDynamicCheck(dynamicData: string): boolean; |
function TUD2Plugin.InvokeDynamicCheck(dynamicData: string; var outIDs: TArrayOfString): 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 |
// The dynamic content was already evaluated (and therefore is already added in FDetectedIdentifications). |
Exit; |
l := Length(outIDs); |
SetLength(outIDs, l+1); |
outIDs[l] := ude.FIdentificationString; |
end; |
end; |
SetLength(ids, 0); |
ids := GetDynamicRequestResult(dynamicData); |
// The dynamic content was already evaluated (and therefore is already added in FDetectedIdentifications). |
if Length(outIDs) > 0 then exit; |
for i := 0 to Length(ids)-1 do |
outIDs := GetDynamicRequestResult(dynamicData); |
for i := 0 to Length(outIDs)-1 do |
begin |
id := ids[i]; |
id := outIDs[i]; |
ude := AddIdentification(id); |
ude.dynamicDataUsed := true; |
248,6 → 256,13 |
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); |
747,12 → 762,16 |
Exit; |
end; |
fDynamicIdentificationStringW := nil; |
pl := TUD2Plugin.Create; |
pl.PluginDLL := dllFile; |
@fDynamicIdentificationStringW := GetProcAddress(dllHandle, mnDynamicIdentificationStringW); |
pl.AcceptsDynamicRequests := Assigned(fDynamicIdentificationStringW); |
fIdentificationStringW := nil; |
if useDynamicData then |
begin |
@fDynamicIdentificationStringW := GetProcAddress(dllHandle, mnDynamicIdentificationStringW); |
if not Assigned(fDynamicIdentificationStringW) then |
if not pl.AcceptsDynamicRequests 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. |
813,9 → 832,6 |
Exit; |
end; |
pl := TUD2Plugin.Create; |
pl.PluginDLL := dllFile; |
if not _ApplyCompatibilityGUID then |
begin |
@fPluginIdentifier := GetProcAddress(dllHandle, mnPluginIdentifier); |
/trunk/UserDetect2/UD2_Utils.pas |
---|
29,6 → 29,7 |
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; |
480,4 → 481,16 |
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. |