Skip to content

Commit 9329abe

Browse files
committed
1. add ControlUnit, WinBioUnlockUnit, WinBioLockUnit
2. Add SetupApi for dll import from advapi32.dll and setupapi.dll 3. Add firmware and sn information. 4. Add "Identify the key(LED)" button
1 parent f4daa61 commit 9329abe

File tree

12 files changed

+470
-61
lines changed

12 files changed

+470
-61
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ Thumbs.db
3939
obj/
4040
[Rr]elease*/
4141
_ReSharper*/
42-
[Tt]est[Rr]esult*
42+
[Tt]est[Rr]esult*
43+
*.opendb
44+
*.db

ConsoleTest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
[assembly: AssemblyTitle("ConsoleTest for WinBioNET")]
88
[assembly: AssemblyDescription("")]
99
[assembly: AssemblyConfiguration("")]
10-
[assembly: AssemblyCompany("JcBernack")]
10+
[assembly: AssemblyCompany("AuthenTrend Technology Inc")]
1111
[assembly: AssemblyProduct("ConsoleTest for WinBioNET")]
12-
[assembly: AssemblyCopyright("Copyright © 2015")]
12+
[assembly: AssemblyCopyright("Copyright © 2015-2017")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace WinBioNET.Enums
2+
{
3+
public enum WinBioComponentType : uint
4+
{
5+
sensor = 1,
6+
engine = 2,
7+
storage = 3
8+
}
9+
10+
public enum SensorLEDType : byte
11+
{
12+
NO_LED_MODE = 8,
13+
STEADY_RED,
14+
STEADY_GREEN,
15+
STEADY_BLUE,
16+
ONE_SEC_RED,
17+
ONE_SEC_GREEN,
18+
ONE_SEC_BLUE,
19+
FLASHING_RED,
20+
FLASHING_GREEN,
21+
FLASHING_BLUE
22+
}
23+
}

WinBioNET/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
[assembly: AssemblyTitle("WinBioNET")]
88
[assembly: AssemblyDescription("")]
99
[assembly: AssemblyConfiguration("")]
10-
[assembly: AssemblyCompany("JcBernack")]
10+
[assembly: AssemblyCompany("AuthenTrend Technology Inc")]
1111
[assembly: AssemblyProduct("WinBioNET")]
12-
[assembly: AssemblyCopyright("Copyright © 2015")]
12+
[assembly: AssemblyCopyright("Copyright © 2015-2017")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

WinBioNET/WinBio.cs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
11
using System;
22
using System.Runtime.InteropServices;
33
using WinBioNET.Enums;
4-
using System.Text;
54

65
namespace WinBioNET
76
{
87
//[SuppressUnmanagedCodeSecurity]
98
public class WinBio
109
{
11-
public enum SID_NAME_USE
12-
{
13-
SidTypeUser = 1,
14-
SidTypeGroup,
15-
SidTypeDomain,
16-
SidTypeAlias,
17-
SidTypeWellKnownGroup,
18-
SidTypeDeletedAccount,
19-
SidTypeInvalid,
20-
SidTypeUnknown,
21-
SidTypeComputer
22-
}
23-
24-
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
25-
public extern static bool LookupAccountSid(
26-
string lpSystemName,
27-
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
28-
StringBuilder lpName,
29-
ref uint cchName,
30-
StringBuilder ReferencedDomainName,
31-
ref uint cchReferencedDomainName,
32-
out SID_NAME_USE peUse);
33-
3410
protected const string LibName = "winbio.dll";
3511

3612
[DllImport(LibName, EntryPoint = "WinBioOpenSession")]
@@ -191,6 +167,25 @@ public static int Identify(
191167
return unitId;
192168
}
193169

170+
[DllImport(LibName, EntryPoint = "WinBioControlUnit")]
171+
public extern static WinBioErrorCode ControlUnit(
172+
WinBioSessionHandle sessionHandle,
173+
int unitId,
174+
WinBioComponentType componentType,
175+
uint controlCode,
176+
byte[] sendBuffer,
177+
int sendBufferSize,
178+
IntPtr receiveBuffer,
179+
int receiveBufferSize,
180+
ref int receiveDataSize,
181+
ref uint statusCode);
182+
183+
[DllImport("Winbio.dll", EntryPoint = "WinBioUnlockUnit")]
184+
public extern static WinBioErrorCode UnlockUnit(WinBioSessionHandle SessionHandle, int UnitId);
185+
186+
[DllImport("Winbio.dll", EntryPoint = "WinBioLockUnit")]
187+
public extern static WinBioErrorCode LockUnit(WinBioSessionHandle SessionHandle, int UnitId);
188+
194189
[DllImport(LibName, EntryPoint = "WinBioEnumEnrollments")]
195190
private extern static WinBioErrorCode EnumEnrollments(
196191
WinBioSessionHandle sessionHandle,

WinBioNET/WinBioNET.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<Compile Include="Enums\WinBioBirDataFlags.cs" />
4646
<Compile Include="Enums\WinBioBirPurpose.cs" />
4747
<Compile Include="Enums\WinBioCapabilitySensor.cs" />
48+
<Compile Include="Enums\WinBioComponentType.cs" />
4849
<Compile Include="Enums\WinBioDatabaseId.cs" />
4950
<Compile Include="Enums\WinBioDatabaseFlag.cs" />
5051
<Compile Include="Enums\WinBioErrorCode.cs" />

WindowsFormsTest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
[assembly: AssemblyTitle("WindowsFormsTest For WinBioNET")]
88
[assembly: AssemblyDescription("")]
99
[assembly: AssemblyConfiguration("")]
10-
[assembly: AssemblyCompany("JcBernack")]
10+
[assembly: AssemblyCompany("AuthenTrend Technology Inc")]
1111
[assembly: AssemblyProduct("WindowsFormsTest For WinBioNET")]
12-
[assembly: AssemblyCopyright("Copyright © 2015")]
12+
[assembly: AssemblyCopyright("Copyright © 2015-2017")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

WindowsFormsTest/SetupAPI.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using System.Text;
4+
5+
namespace WindowsFormsTest
6+
{
7+
class SetupAPI
8+
{
9+
public enum SID_NAME_USE
10+
{
11+
SidTypeUser = 1,
12+
SidTypeGroup,
13+
SidTypeDomain,
14+
SidTypeAlias,
15+
SidTypeWellKnownGroup,
16+
SidTypeDeletedAccount,
17+
SidTypeInvalid,
18+
SidTypeUnknown,
19+
SidTypeComputer
20+
}
21+
22+
// Use this to get user name
23+
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
24+
public extern static bool LookupAccountSid(
25+
string lpSystemName,
26+
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
27+
StringBuilder lpName,
28+
ref uint cchName,
29+
StringBuilder ReferencedDomainName,
30+
ref uint cchReferencedDomainName,
31+
out SID_NAME_USE peUse);
32+
33+
public enum RegPropertyType
34+
{
35+
SPDRP_DEVICEDESC = 0x00000000, // DeviceDesc (R/W)
36+
SPDRP_HARDWAREID = 0x00000001, // HardwareID (R/W)
37+
SPDRP_COMPATIBLEIDS = 0x00000002, // CompatibleIDs (R/W)
38+
SPDRP_UNUSED0 = 0x00000003, // unused
39+
SPDRP_SERVICE = 0x00000004, // Service (R/W)
40+
SPDRP_UNUSED1 = 0x00000005, // unused
41+
SPDRP_UNUSED2 = 0x00000006, // unused
42+
SPDRP_CLASS = 0x00000007, // Class (R--tied to ClassGUID)
43+
SPDRP_CLASSGUID = 0x00000008, // ClassGUID (R/W)
44+
SPDRP_DRIVER = 0x00000009, // Driver (R/W)
45+
SPDRP_CONFIGFLAGS = 0x0000000A, // ConfigFlags (R/W)
46+
SPDRP_MFG = 0x0000000B, // Mfg (R/W)
47+
SPDRP_FRIENDLYNAME = 0x0000000C, // FriendlyName (R/W)
48+
SPDRP_LOCATION_INFORMATION = 0x0000000D,// LocationInformation (R/W)
49+
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E, // PhysicalDeviceObjectName (R)
50+
SPDRP_CAPABILITIES = 0x0000000F, // Capabilities (R)
51+
SPDRP_UI_NUMBER = 0x00000010, // UiNumber (R)
52+
SPDRP_UPPERFILTERS = 0x00000011, // UpperFilters (R/W)
53+
SPDRP_LOWERFILTERS = 0x00000012, // LowerFilters (R/W)
54+
SPDRP_BUSTYPEGUID = 0x00000013, // BusTypeGUID (R)
55+
SPDRP_LEGACYBUSTYPE = 0x00000014, // LegacyBusType (R)
56+
SPDRP_BUSNUMBER = 0x00000015, // BusNumber (R)
57+
SPDRP_ENUMERATOR_NAME = 0x00000016, // Enumerator Name (R)
58+
SPDRP_SECURITY = 0x00000017, // Security (R/W, binary form)
59+
SPDRP_SECURITY_SDS = 0x00000018, // Security (W, SDS form)
60+
SPDRP_DEVTYPE = 0x00000019, // Device Type (R/W)
61+
SPDRP_EXCLUSIVE = 0x0000001A, // Device is exclusive-access (R/W)
62+
SPDRP_CHARACTERISTICS = 0x0000001B, // Device Characteristics (R/W)
63+
SPDRP_ADDRESS = 0x0000001C, // Device Address (R)
64+
SPDRP_UI_NUMBER_DESC_FORMAT = 0x0000001E, // UiNumberDescFormat (R/W)
65+
SPDRP_MAXIMUM_PROPERTY = 0x0000001F // Upper bound on ordinals
66+
}
67+
68+
public enum DiGetClassFlags : uint
69+
{
70+
DIGCF_DEFAULT = 0x00000001, // only valid with DIGCF_DEVICEINTERFACE
71+
DIGCF_PRESENT = 0x00000002,
72+
DIGCF_ALLCLASSES = 0x00000004,
73+
DIGCF_PROFILE = 0x00000008,
74+
DIGCF_DEVICEINTERFACE = 0x00000010,
75+
}
76+
77+
[StructLayout(LayoutKind.Sequential)]
78+
public struct SP_DEVINFO_DATA
79+
{
80+
public int cbSize;
81+
public Guid ClassGuid;
82+
public int DevInst;
83+
public int Reserved;
84+
}
85+
// Device interface detail data
86+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
87+
public struct DATA_BUFFER
88+
{
89+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
90+
public string Buffer;
91+
}
92+
// use this to get SPDRP_HARDWAREID
93+
[DllImport("setupapi.dll", CharSet = CharSet.Auto)]
94+
public extern static IntPtr SetupDiGetClassDevs( // 1st form using a ClassGUID only, with null Enumerator
95+
ref Guid ClassGuid,
96+
IntPtr Enumerator,
97+
IntPtr hwndParent,
98+
DiGetClassFlags Flags
99+
);
100+
[DllImport("setupapi.dll", CharSet = CharSet.Auto)] // 2nd form uses an Enumerator only, with null ClassGUID
101+
public extern static IntPtr SetupDiGetClassDevs(
102+
IntPtr ClassGuid,
103+
string Enumerator,
104+
IntPtr hwndParent,
105+
DiGetClassFlags Flags
106+
);
107+
108+
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
109+
public static extern bool SetupDiGetDeviceInstanceId(
110+
IntPtr DeviceInfoSet,
111+
ref SP_DEVINFO_DATA DeviceInfoData,
112+
StringBuilder DeviceInstanceId,
113+
uint DeviceInstanceIdSize,
114+
out UInt32 RequiredSize
115+
);
116+
117+
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
118+
public extern static bool SetupDiGetDeviceRegistryProperty(
119+
IntPtr deviceInfoSet,
120+
ref SP_DEVINFO_DATA deviceInfoData,
121+
RegPropertyType property,
122+
out UInt32 propertyRegDataType,
123+
StringBuilder DeviceInstanceId,
124+
uint propertyBufferSize,
125+
out UInt32 requiredSize
126+
);
127+
128+
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
129+
public extern static bool SetupDiEnumDeviceInfo(
130+
IntPtr DeviceInfoSet,
131+
int Index,
132+
ref SP_DEVINFO_DATA DeviceInfoData
133+
);
134+
[DllImport("setupapi.dll", SetLastError = true)]
135+
public static extern bool SetupDiDestroyDeviceInfoList(
136+
IntPtr DeviceInfoSet);
137+
}
138+
}

0 commit comments

Comments
 (0)