Subversion Repositories userdetect2

Compare Revisions

No changes between revisions

Regard whitespace Rev 88 → Rev 89

/trunk/UserDetect2/Plugins/DriveSerial.cfg
0,0 → 1,38
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST
/trunk/UserDetect2/Plugins/DriveSerial.dof
0,0 → 1,140
[FileVersion]
Version=7.0
[Compiler]
A=8
B=0
C=1
D=1
E=0
F=0
G=1
H=1
I=1
J=0
K=0
L=1
M=0
N=1
O=1
P=1
Q=0
R=0
S=0
T=0
U=0
V=1
W=0
X=1
Y=1
Z=1
ShowHints=1
ShowWarnings=1
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
NamespacePrefix=
SymbolDeprecated=1
SymbolLibrary=1
SymbolPlatform=1
UnitLibrary=1
UnitPlatform=1
UnitDeprecated=1
HResultCompat=1
HidingMember=1
HiddenVirtual=1
Garbage=1
BoundsError=1
ZeroNilCompat=1
StringConstTruncated=1
ForLoopVarVarPar=1
TypedConstVarPar=1
AsgToTypedConst=1
CaseLabelRange=1
ForVariable=1
ConstructingAbstract=1
ComparisonFalse=1
ComparisonTrue=1
ComparingSignedUnsigned=1
CombiningSignedUnsigned=1
UnsupportedConstruct=1
FileOpen=1
FileOpenUnitSrc=1
BadGlobalSymbol=1
DuplicateConstructorDestructor=1
InvalidDirective=1
PackageNoLink=1
PackageThreadVar=1
ImplicitImport=1
HPPEMITIgnored=1
NoRetVal=1
UseBeforeDef=1
ForLoopVarUndef=1
UnitNameMismatch=1
NoCFGFileFound=1
MessageDirective=1
ImplicitVariants=1
UnicodeToLocale=1
LocaleToUnicode=1
ImagebaseMultiple=1
SuspiciousTypecast=1
PrivatePropAccessor=1
UnsafeType=0
UnsafeCode=0
UnsafeCast=0
[Linker]
MapFile=0
OutputObjs=0
ConsoleApp=1
DebugInfo=0
RemoteSymbols=0
MinStackSize=16384
MaxStackSize=1048576
ImageBase=4194304
ExeDescription=
[Directories]
OutputDir=
UnitOutputDir=
PackageDLLOutputDir=
PackageDCPOutputDir=
SearchPath=
Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP
Conditionals=
DebugSourceDirs=
UsePackages=0
[Parameters]
RunParams=
HostApplication=..\UserDetect2.exe
Launcher=
UseLauncher=0
DebugCWD=..\
[Language]
ActiveLang=
ProjectLang=
RootDir=
[Version Info]
IncludeVerInfo=1
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=1
Locale=1033
CodePage=1252
[Version Info Keys]
CompanyName=ViaThinkSoft
FileDescription=DriveSerial plugin for UserDetect2
FileVersion=1.0.0.0
InternalName=UD2-DriveSerial
LegalCopyright=(C) 2016 ViaThinkSoft
LegalTrademarks=
OriginalFilename=DriveSerial.dll
ProductName=UserDetect2
ProductVersion=2.2.0.0
Website=www.viathinksoft.de
Project leader=Daniel Marschall - www.daniel-marschall.de
[HistoryLists\hlUnitAliases]
Count=1
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
/trunk/UserDetect2/Plugins/DriveSerial.dpr
0,0 → 1,115
library DriveSerial;
 
uses
Windows,
SysUtils,
Classes,
ActiveX,
UD2_PluginIntf in '..\UD2_PluginIntf.pas',
UD2_PluginUtils in '..\UD2_PluginUtils.pas',
UD2_PluginStatus in '..\UD2_PluginStatus.pas',
hddinfo in 'Utils\hddinfo.pas';
 
{$R *.res}
 
const
PLUGIN_GUID: TGUID = '{2978C8D6-02A8-4D29-83D7-62EA5252F807}';
 
function PluginIdentifier: TGUID; cdecl;
begin
result := PLUGIN_GUID;
end;
 
function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
begin
result := UD2_STATUS_NOTAVAIL_ONLY_ACCEPT_DYNAMIC;
end;
 
function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
var
stPluginName: WideString;
primaryLangID: Byte;
begin
primaryLangID := wLangID and $00FF;
if primaryLangID = LANG_GERMAN then
stPluginName := 'Datenträger-Seriennummer'
else
stPluginName := 'Drive Serial Number';
result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
end;
 
function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
begin
result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
end;
 
function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
begin
result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
end;
 
function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
var
stIdentificationMethodName: WideString;
begin
stIdentificationMethodName := 'DriveSerial';
result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
end;
 
function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
begin
result := UD2_STATUS_OK_LICENSED;
end;
 
function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
begin
// This function does not use non-generic status codes
result := FALSE;
end;
 
function DynamicIdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD; lpDynamicData: LPWSTR): UD2_STATUS; cdecl;
var
stIdentifier: WideString;
driveletter: char;
begin
try
if Copy(string(lpDynamicData), 2, 1) <> ':' then
begin
result := UD2_STATUS_FAILURE_INVALID_ARGS;
exit;
end;
 
driveletter := Copy(UpperCase(lpDynamicData), 1, 1)[1];
 
if not (driveletter in ['A'..'Z']) then
begin
result := UD2_STATUS_FAILURE_INVALID_ARGS;
exit;
end;
 
CoInitialize(nil);
try
stIdentifier := GetDiskSerial(driveletter); // driveletter must be upper case
finally
CoUninitialize;
end;
result := UD2_WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
except
on E: Exception do result := UD2_STATUS_HandleException(E);
end;
end;
 
 
exports
PluginInterfaceID name mnPluginInterfaceID,
PluginIdentifier name mnPluginIdentifier,
PluginNameW name mnPluginNameW,
PluginVendorW name mnPluginVendorW,
PluginVersionW name mnPluginVersionW,
IdentificationMethodNameW name mnIdentificationMethodNameW,
IdentificationStringW name mnIdentificationStringW,
CheckLicense name mnCheckLicense,
DescribeOwnStatusCodeW name mnDescribeOwnStatusCodeW,
DynamicIdentificationStringW name mnDynamicIdentificationStringW;
 
end.
/trunk/UserDetect2/Plugins/DriveSerial.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/UserDetect2/Plugins/TestDynamicEcho.cfg
0,0 → 1,38
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST
/trunk/UserDetect2/Plugins/TestDynamicEcho.dof
132,7 → 132,7
LegalTrademarks=
OriginalFilename=TestDynamicEcho.dll
ProductName=UserDetect2
ProductVersion=3.0.0.0
ProductVersion=2.2.0.0
Website=www.viathinksoft.de
Project leader=Daniel Marschall - www.daniel-marschall.de
[HistoryLists\hlUnitAliases]
/trunk/UserDetect2/Plugins/TestDynamicEcho.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/UserDetect2/Plugins/Utils/hddinfo.pas
0,0 → 1,61
// http://stackoverflow.com/questions/5202270/in-delphi7-how-can-i-retrieve-hard-disk-unique-serial-number
 
unit hddinfo;
 
interface
 
function GetDiskSerial(const Drive:AnsiChar):string;
 
implementation
 
uses
SysUtils,
ActiveX,
ComObj,
Variants;
 
function GetDiskSerial(const Drive:AnsiChar):string;
var
FSWbemLocator : OLEVariant;
objWMIService : OLEVariant;
colDiskDrives : OLEVariant;
colLogicalDisks: OLEVariant;
colPartitions : OLEVariant;
objDiskDrive : OLEVariant;
objPartition : OLEVariant;
objLogicalDisk : OLEVariant;
oEnumDiskDrive : IEnumvariant;
oEnumPartition : IEnumvariant;
oEnumLogical : IEnumvariant;
iValue : LongWord;
DeviceID : string;
begin;
Result:='';
FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
objWMIService := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', ''); //Connect to the WMI
colDiskDrives := objWMIService.ExecQuery('SELECT * FROM Win32_DiskDrive','WQL',0);
oEnumDiskDrive:= IUnknown(colDiskDrives._NewEnum) as IEnumVariant;
while oEnumDiskDrive.Next(1, objDiskDrive, iValue) = 0 do
begin
DeviceID := StringReplace(objDiskDrive.DeviceID,'\','\\',[rfReplaceAll]); //Escape the `\` chars in the DeviceID value because the '\' is a reserved character in WMI.
colPartitions := objWMIService.ExecQuery(Format('ASSOCIATORS OF {Win32_DiskDrive.DeviceID="%s"} WHERE AssocClass = Win32_DiskDriveToDiskPartition',[DeviceID]));//link the Win32_DiskDrive class with the Win32_DiskDriveToDiskPartition class
oEnumPartition := IUnknown(colPartitions._NewEnum) as IEnumVariant;
while oEnumPartition.Next(1, objPartition, iValue) = 0 do
begin
colLogicalDisks := objWMIService.ExecQuery('ASSOCIATORS OF {Win32_DiskPartition.DeviceID="'+objPartition.DeviceID+'"} WHERE AssocClass = Win32_LogicalDiskToPartition'); //link the Win32_DiskPartition class with theWin32_LogicalDiskToPartition class.
oEnumLogical := IUnknown(colLogicalDisks._NewEnum) as IEnumVariant;
while oEnumLogical.Next(1, objLogicalDisk, iValue) = 0 do
begin
if objLogicalDisk.DeviceID=(Drive+':') then //compare the device id
begin
Result:=objDiskDrive.SerialNumber;
Exit;
end;
objLogicalDisk:=Unassigned;
end;
objPartition:=Unassigned;
end;
end;
end;
 
end.
/trunk/UserDetect2/Plugins/Utils
Property changes:
Added: svn:ignore
+*.dcu
+*.~*
+__history
+*.local
+*.identcache
/trunk/UserDetect2/UD2_Main.dfm
131,6 → 131,7
Height = 33
Anchors = [akTop, akRight]
Caption = 'Query'
Default = True
TabOrder = 2
OnClick = DynamicTestButtonClick
end
/trunk/UserDetect2/private/TODO.txt
30,3 → 30,6
* Give .udp a file-type (icon)?
* TDF in XML?
* mehrere commandos aufrufen in einer einzigen zeile, ohne BAT ?
* Sollen Plugins sich selbst beschreiben dürfen (welche argumente bekommt ein dynamisches plugin?)
* ist UD2_STATUS_FAILURE_INVALID_ARGS der korrekte fehlercode wenn die eingegebenen dynamischen daten ungültig sind?
* brauchen wir escaping beim idString ?