Add Original SDK
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("7ABF47DE-D659-4F87-ABD9-80E04F5307EB")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.*")>
|
||||
283
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/Form1.resx
Normal file
283
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/Form1.resx
Normal file
@@ -0,0 +1,283 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="groupBox1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="groupBox1.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
<data name="groupBox1.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="groupBox1.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="groupBox1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expyearText.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expyearText.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="expyearText.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label5.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label5.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label5.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expmonthText.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expmonthText.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="expmonthText.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label4.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label4.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label4.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expdayText.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="expdayText.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="expdayText.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label3.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label3.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label3.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label2.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label2.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label2.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="machineIDText.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="machineIDText.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="machineIDText.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="softwareKey.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="softwareKey.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="softwareKey.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="encryptShellData.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="encryptShellData.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="encryptShellData.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="lockSoftware.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="lockSoftware.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="lockSoftware.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="programDongleMod.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="programDongleMod.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="programDongleMod.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="programDongle.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="programDongle.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="programDongle.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="dapfFile.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="dapfFile.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="dapfFile.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>Form1</value>
|
||||
</data>
|
||||
</root>
|
||||
485
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/Form1.vb
Normal file
485
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/Form1.vb
Normal file
@@ -0,0 +1,485 @@
|
||||
' !! We strongly recommend that you read the "readme.txt" file in the sample code folder.
|
||||
' !! It contains important instructions on how to use the sample code
|
||||
|
||||
Imports System.Runtime.InteropServices ' so we can marshall our structures
|
||||
|
||||
Public Class Form1
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
Public Const AppName As String = "dapfTest"
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
'Add any initialization after the InitializeComponent() call
|
||||
|
||||
End Sub
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
Friend WithEvents groupBox2 As System.Windows.Forms.GroupBox
|
||||
Friend WithEvents label6 As System.Windows.Forms.Label
|
||||
Friend WithEvents maxDaysText As System.Windows.Forms.TextBox
|
||||
Friend WithEvents demoSoftwareKey As System.Windows.Forms.Button
|
||||
Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
|
||||
Friend WithEvents expyearText As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label5 As System.Windows.Forms.Label
|
||||
Friend WithEvents expmonthText As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label4 As System.Windows.Forms.Label
|
||||
Friend WithEvents expdayText As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label3 As System.Windows.Forms.Label
|
||||
Friend WithEvents label2 As System.Windows.Forms.Label
|
||||
Friend WithEvents machineIDText As System.Windows.Forms.TextBox
|
||||
Friend WithEvents tempSoftwareKey As System.Windows.Forms.Button
|
||||
Friend WithEvents encryptShellData As System.Windows.Forms.Button
|
||||
Friend WithEvents lockSoftware As System.Windows.Forms.Button
|
||||
Friend WithEvents programDongleMod As System.Windows.Forms.Button
|
||||
Friend WithEvents programDongle As System.Windows.Forms.Button
|
||||
Friend WithEvents dapfFile As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label1 As System.Windows.Forms.Label
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.groupBox2 = New System.Windows.Forms.GroupBox
|
||||
Me.label6 = New System.Windows.Forms.Label
|
||||
Me.maxDaysText = New System.Windows.Forms.TextBox
|
||||
Me.demoSoftwareKey = New System.Windows.Forms.Button
|
||||
Me.groupBox1 = New System.Windows.Forms.GroupBox
|
||||
Me.expyearText = New System.Windows.Forms.TextBox
|
||||
Me.label5 = New System.Windows.Forms.Label
|
||||
Me.expmonthText = New System.Windows.Forms.TextBox
|
||||
Me.label4 = New System.Windows.Forms.Label
|
||||
Me.expdayText = New System.Windows.Forms.TextBox
|
||||
Me.label3 = New System.Windows.Forms.Label
|
||||
Me.label2 = New System.Windows.Forms.Label
|
||||
Me.machineIDText = New System.Windows.Forms.TextBox
|
||||
Me.tempSoftwareKey = New System.Windows.Forms.Button
|
||||
Me.encryptShellData = New System.Windows.Forms.Button
|
||||
Me.lockSoftware = New System.Windows.Forms.Button
|
||||
Me.programDongleMod = New System.Windows.Forms.Button
|
||||
Me.programDongle = New System.Windows.Forms.Button
|
||||
Me.dapfFile = New System.Windows.Forms.TextBox
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
Me.groupBox1.SuspendLayout()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'groupBox2
|
||||
'
|
||||
Me.groupBox2.Controls.Add(Me.label6)
|
||||
Me.groupBox2.Controls.Add(Me.maxDaysText)
|
||||
Me.groupBox2.Controls.Add(Me.demoSoftwareKey)
|
||||
Me.groupBox2.Location = New System.Drawing.Point(16, 390)
|
||||
Me.groupBox2.Name = "groupBox2"
|
||||
Me.groupBox2.Size = New System.Drawing.Size(336, 96)
|
||||
Me.groupBox2.TabIndex = 17
|
||||
Me.groupBox2.TabStop = False
|
||||
Me.groupBox2.Text = "Demo Software Key"
|
||||
'
|
||||
'demoSoftwareKey
|
||||
'
|
||||
Me.demoSoftwareKey.Location = New System.Drawing.Point(64, 56)
|
||||
Me.demoSoftwareKey.Name = "demoSoftwareKey"
|
||||
Me.demoSoftwareKey.Size = New System.Drawing.Size(208, 23)
|
||||
Me.demoSoftwareKey.TabIndex = 15
|
||||
Me.demoSoftwareKey.Text = "Create Demo Template"
|
||||
'
|
||||
'label6
|
||||
'
|
||||
Me.label6.Location = New System.Drawing.Point(24, 24)
|
||||
Me.label6.Name = "label6"
|
||||
Me.label6.Size = New System.Drawing.Size(100, 20)
|
||||
Me.label6.TabIndex = 18
|
||||
Me.label6.Text = "Max Days:"
|
||||
Me.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
|
||||
'
|
||||
'maxDaysText
|
||||
'
|
||||
Me.maxDaysText.Location = New System.Drawing.Point(128, 24)
|
||||
Me.maxDaysText.Name = "maxDaysText"
|
||||
Me.maxDaysText.Size = New System.Drawing.Size(184, 20)
|
||||
Me.maxDaysText.TabIndex = 19
|
||||
Me.maxDaysText.Text = ""
|
||||
'
|
||||
'groupBox1
|
||||
'
|
||||
Me.groupBox1.Controls.Add(Me.expyearText)
|
||||
Me.groupBox1.Controls.Add(Me.label5)
|
||||
Me.groupBox1.Controls.Add(Me.expmonthText)
|
||||
Me.groupBox1.Controls.Add(Me.label4)
|
||||
Me.groupBox1.Controls.Add(Me.expdayText)
|
||||
Me.groupBox1.Controls.Add(Me.label3)
|
||||
Me.groupBox1.Controls.Add(Me.label2)
|
||||
Me.groupBox1.Controls.Add(Me.machineIDText)
|
||||
Me.groupBox1.Controls.Add(Me.tempSoftwareKey)
|
||||
Me.groupBox1.Location = New System.Drawing.Point(16, 251)
|
||||
Me.groupBox1.Name = "groupBox1"
|
||||
Me.groupBox1.Size = New System.Drawing.Size(336, 128)
|
||||
Me.groupBox1.TabIndex = 7
|
||||
Me.groupBox1.TabStop = False
|
||||
Me.groupBox1.Text = "Temporary Software Key"
|
||||
'
|
||||
'tempSoftwareKey
|
||||
'
|
||||
Me.tempSoftwareKey.Location = New System.Drawing.Point(64, 88)
|
||||
Me.tempSoftwareKey.Name = "tempSoftwareKey"
|
||||
Me.tempSoftwareKey.Size = New System.Drawing.Size(208, 23)
|
||||
Me.tempSoftwareKey.TabIndex = 16
|
||||
Me.tempSoftwareKey.Text = "Create Software Key"
|
||||
'
|
||||
'expyearText
|
||||
'
|
||||
Me.expyearText.Location = New System.Drawing.Point(240, 56)
|
||||
Me.expyearText.Name = "expyearText"
|
||||
Me.expyearText.Size = New System.Drawing.Size(32, 20)
|
||||
Me.expyearText.TabIndex = 15
|
||||
Me.expyearText.Text = "yyyy"
|
||||
'
|
||||
'label5
|
||||
'
|
||||
Me.label5.Location = New System.Drawing.Point(224, 56)
|
||||
Me.label5.Name = "label5"
|
||||
Me.label5.Size = New System.Drawing.Size(8, 20)
|
||||
Me.label5.TabIndex = 14
|
||||
Me.label5.Text = "/"
|
||||
Me.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
|
||||
'
|
||||
'expmonthText
|
||||
'
|
||||
Me.expmonthText.Location = New System.Drawing.Point(184, 56)
|
||||
Me.expmonthText.Name = "expmonthText"
|
||||
Me.expmonthText.Size = New System.Drawing.Size(32, 20)
|
||||
Me.expmonthText.TabIndex = 13
|
||||
Me.expmonthText.Text = "mm"
|
||||
'
|
||||
'label4
|
||||
'
|
||||
Me.label4.Location = New System.Drawing.Point(168, 56)
|
||||
Me.label4.Name = "label4"
|
||||
Me.label4.Size = New System.Drawing.Size(8, 20)
|
||||
Me.label4.TabIndex = 12
|
||||
Me.label4.Text = "/"
|
||||
Me.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
|
||||
'
|
||||
'expdayText
|
||||
'
|
||||
Me.expdayText.Location = New System.Drawing.Point(128, 56)
|
||||
Me.expdayText.Name = "expdayText"
|
||||
Me.expdayText.Size = New System.Drawing.Size(32, 20)
|
||||
Me.expdayText.TabIndex = 11
|
||||
Me.expdayText.Text = "dd"
|
||||
'
|
||||
'label3
|
||||
'
|
||||
Me.label3.Location = New System.Drawing.Point(24, 56)
|
||||
Me.label3.Name = "label3"
|
||||
Me.label3.Size = New System.Drawing.Size(100, 20)
|
||||
Me.label3.TabIndex = 10
|
||||
Me.label3.Text = "Expiry Date:"
|
||||
Me.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
|
||||
'
|
||||
'label2
|
||||
'
|
||||
Me.label2.Location = New System.Drawing.Point(24, 24)
|
||||
Me.label2.Name = "label2"
|
||||
Me.label2.Size = New System.Drawing.Size(100, 20)
|
||||
Me.label2.TabIndex = 8
|
||||
Me.label2.Text = "Machine ID:"
|
||||
Me.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
|
||||
'
|
||||
'machineIDText
|
||||
'
|
||||
Me.machineIDText.Location = New System.Drawing.Point(128, 24)
|
||||
Me.machineIDText.Name = "machineIDText"
|
||||
Me.machineIDText.Size = New System.Drawing.Size(184, 20)
|
||||
Me.machineIDText.TabIndex = 9
|
||||
Me.machineIDText.Text = ""
|
||||
'
|
||||
'encryptShellData
|
||||
'
|
||||
Me.encryptShellData.Location = New System.Drawing.Point(80, 203)
|
||||
Me.encryptShellData.Name = "encryptShellData"
|
||||
Me.encryptShellData.Size = New System.Drawing.Size(208, 23)
|
||||
Me.encryptShellData.TabIndex = 6
|
||||
Me.encryptShellData.Text = "Encrypt Shell Data Files"
|
||||
'
|
||||
'lockSoftware
|
||||
'
|
||||
Me.lockSoftware.Location = New System.Drawing.Point(80, 163)
|
||||
Me.lockSoftware.Name = "lockSoftware"
|
||||
Me.lockSoftware.Size = New System.Drawing.Size(208, 23)
|
||||
Me.lockSoftware.TabIndex = 5
|
||||
Me.lockSoftware.Text = "Lock Software"
|
||||
'
|
||||
'programDongleMod
|
||||
'
|
||||
Me.programDongleMod.Location = New System.Drawing.Point(80, 123)
|
||||
Me.programDongleMod.Name = "programDongleMod"
|
||||
Me.programDongleMod.Size = New System.Drawing.Size(208, 23)
|
||||
Me.programDongleMod.TabIndex = 4
|
||||
Me.programDongleMod.Text = "Program Dongle with modification"
|
||||
'
|
||||
'programDongle
|
||||
'
|
||||
Me.programDongle.Location = New System.Drawing.Point(80, 83)
|
||||
Me.programDongle.Name = "programDongle"
|
||||
Me.programDongle.Size = New System.Drawing.Size(208, 23)
|
||||
Me.programDongle.TabIndex = 3
|
||||
Me.programDongle.Text = "Program Dongle"
|
||||
'
|
||||
'dapfFile
|
||||
'
|
||||
Me.dapfFile.Location = New System.Drawing.Point(16, 35)
|
||||
Me.dapfFile.Name = "dapfFile"
|
||||
Me.dapfFile.Size = New System.Drawing.Size(344, 20)
|
||||
Me.dapfFile.TabIndex = 2
|
||||
Me.dapfFile.Text = ""
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.Location = New System.Drawing.Point(16, 19)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(416, 16)
|
||||
Me.label1.TabIndex = 1
|
||||
Me.label1.Text = "Full path of dapf file:"
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.ClientSize = New System.Drawing.Size(376, 496)
|
||||
Me.Controls.Add(Me.groupBox2)
|
||||
Me.Controls.Add(Me.groupBox1)
|
||||
Me.Controls.Add(Me.encryptShellData)
|
||||
Me.Controls.Add(Me.lockSoftware)
|
||||
Me.Controls.Add(Me.programDongleMod)
|
||||
Me.Controls.Add(Me.programDongle)
|
||||
Me.Controls.Add(Me.dapfFile)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Name = "Form1"
|
||||
Me.Text = "Form1"
|
||||
Me.groupBox1.ResumeLayout(False)
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
' The sample code contains 5 functions. You will not need to use all these functions in your code.
|
||||
' Just use which ever functions are most appropriate and customise in your own way. The sample code
|
||||
' is just a guide.
|
||||
'
|
||||
' There are two methods to loading a DAPF file. These are shown in the first two functions
|
||||
' programDongle_Click and programDongleMod_Click:
|
||||
'
|
||||
' programDongle_Click: we load the DAPF file from disk and get a handle and use it "as is" using the API
|
||||
' call LoadDAPFFromFile. You can make some limited changes to overwrite the default
|
||||
' behaviour by using API flags.
|
||||
'
|
||||
' programDongleMod_Click: we load the DAPF file from disk and load into structures. We can then modify the
|
||||
' DAPF settings by modifying this structure. This method uses the API calls
|
||||
' ReadDAPFEx and LoadDAPF.
|
||||
'
|
||||
' The other functions use the first method (as it is simpler) but you can use the second method instead if
|
||||
' you prefer.
|
||||
'
|
||||
' Note - an alternative to using the programDongleMod_Click technique is to modify the DAPF file on disk
|
||||
' and then use the programDongle_Click technique. To modify a binary DAPF you would use the binary structures
|
||||
' that are defined in dapf.h. To modify JSON DAPF you would need to use a JSON parser.
|
||||
'
|
||||
' lockSoftware_Click : locks software (protect it) to a dongle as specified by the DAPF file.
|
||||
'
|
||||
' encryptShellData_Click: encrypts the shell data files specified in the DAPF file (this is used with encrypting
|
||||
' data file if you use the Shell Method with "Data File Encryption" enabled).
|
||||
'
|
||||
' tempSoftwareKey_Click: creates a Temporary Software Key based on the DAPF file and settings the user has entered.
|
||||
'
|
||||
' demoSoftwareKey_Click: creates a Demo Software Key Template based on the DAPF file and settings the user has entered.
|
||||
|
||||
Private Sub programDongle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles programDongle.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
Dim dongle_number As UInt32
|
||||
|
||||
' load DAPF from File into memory
|
||||
dapfHandle = LoadDAPFFromFile(dapfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' program dongle as specified by the DAPF file
|
||||
err_code = AddProtection(dapfHandle, ACTION_PROGRAM_DONGLE, 0, 0, dongle_number)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
#If VBC_VER >= 14 Then
|
||||
#Disable Warning BC42108, BC42030 'This line is used in Visual Studio 2015 (and newer) to remove warnings in this function
|
||||
#End If
|
||||
Private Sub programDongleMod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles programDongleMod.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code, dummy1, dummy2 As Integer
|
||||
Dim dongle_number As UInt32
|
||||
Dim MyDinkeyInfo As DINKEYINFO
|
||||
Dim LicenceInfoArray() As LICENCEINFO
|
||||
Dim FileInfoArray() As FILEINFO
|
||||
Dim AlgorithmArray() As ALGORITHM
|
||||
Dim DataFileEncArray() As DATAFILEENC
|
||||
|
||||
' in this case we need to read the DAPF into our structures, so that the DAPF values can be modified
|
||||
err_code = ReadDAPFEx(dapfFile.Text, MyDinkeyInfo, LicenceInfoArray, FileInfoArray, AlgorithmArray, DataFileEncArray, dummy1, dummy2)
|
||||
If err_code <> 0 Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' patch new values
|
||||
LicenceInfoArray(0).Features = Convert.ToUInt32(12345)
|
||||
LicenceInfoArray(0).Execs = 100
|
||||
LicenceInfoArray(0).LicenceName = "fred"
|
||||
|
||||
' get DAPF handle
|
||||
dapfHandle = LoadDAPF(MyDinkeyInfo, LicenceInfoArray, FileInfoArray, AlgorithmArray, DataFileEncArray, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' program dongle
|
||||
err_code = AddProtection(dapfHandle, ACTION_PROGRAM_DONGLE, 0, 0, dongle_number)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
#If VBC_VER >= 14 Then
|
||||
#Enable Warning BC42108, BC42030 'This line is used in Visual Studio 2015 (and higher) to remove warnings
|
||||
#End If
|
||||
' load a DAPF file from disk and protect the files specified
|
||||
' (in practice it is better to protect the files one at a time and output messages as you go along, similar to DinkeyAdd.exe)
|
||||
' In this example we specify the flag to overwrite any existing output file that might exist.
|
||||
Private Sub lockSoftware_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lockSoftware.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
Dim dummy As UInt32
|
||||
|
||||
' load DAPF from File into memory
|
||||
dapfHandle = LoadDAPFFromFile(dapfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' protect all the files listed in the DAPF file
|
||||
err_code = AddProtection(dapfHandle, ACTION_PROTECT_SOFTWARE, -1, FLAGS_OVERWRITE_OUTPUT, dummy)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
|
||||
Private Sub encryptShellData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles encryptShellData.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
|
||||
' load DAPF from File into memory
|
||||
dapfHandle = LoadDAPFFromFile(dapfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' encrypt all the shell data files listed in the DAPF file
|
||||
err_code = EncryptShellDataFiles(dapfHandle, -1, FLAGS_OVERWRITE_OUTPUT)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
|
||||
Private Sub tempSoftwareKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tempSoftwareKey.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
Dim swkey_info As TEMP_SWKEY_INFO
|
||||
|
||||
' load DAPF from File into memory
|
||||
dapfHandle = LoadDAPFFromFile(dapfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' fill out the SWKEY structure from the values the user entered
|
||||
swkey_info.Size = Marshal.SizeOf(swkey_info.GetType)
|
||||
swkey_info.MachineID = Convert.ToUInt32(machineIDText.Text, 16)
|
||||
swkey_info.ExpiryDay = Convert.ToInt32(expdayText.Text, 10)
|
||||
swkey_info.ExpiryMonth = Convert.ToInt32(expmonthText.Text, 10)
|
||||
swkey_info.ExpiryYear = Convert.ToInt32(expyearText.Text, 10)
|
||||
' !!!! in this case we just choose Pro Plus. You could load the DAPF file into structures and see which model is selected.
|
||||
' If there is more than one model selected you can ask the customer to choose which model they want.
|
||||
swkey_info.DongleModel = SWKEY_MODEL_PRO_PLUS
|
||||
swkey_info.DongleNumber = Convert.ToUInt32(0)
|
||||
|
||||
' attempt to create the Temporary Software Key
|
||||
err_code = CreateTempSoftwareKey(dapfHandle, swkey_info, 0)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
|
||||
Private Sub demoSoftwareKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles demoSoftwareKey.Click
|
||||
Dim dapfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
Dim swkey_info As DEMO_SWKEY_INFO
|
||||
|
||||
' load DAPF from File into memory
|
||||
dapfHandle = LoadDAPFFromFile(dapfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(dapfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' fill out the SWKEY structure from the values the user entered
|
||||
swkey_info.Size = Marshal.SizeOf(swkey_info.GetType)
|
||||
swkey_info.MaxDays = Convert.ToInt32(maxDaysText.Text, 10)
|
||||
' !!!! in this case we just choose the default model (assuming you only selected one in the DAPF file).
|
||||
' If you want to specify more than one model then OR the flags together. e.g. SWKEY_BITMAP_PRO_LITE Or SWKEY_BITMAP_PRO_PLUS
|
||||
swkey_info.Models = SWKEY_BITMAP_DEFAULT
|
||||
|
||||
' attempt to create the Demo Software Key Template
|
||||
err_code = CreateDemoSoftwareKeyTemplate(dapfHandle, swkey_info, 0)
|
||||
|
||||
' Unload DAPF from memory
|
||||
UnloadDAPF(dapfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -0,0 +1,50 @@
|
||||
dapfTest - sample code to call DinkeyAdd Module in VB.NET
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This project is written in Visual Studio 2002 but will work in more recent
|
||||
versions of Visual Studio (they will upgrade the Project to the latest version.
|
||||
If prompted you should also upgrade the .NET framework the project requires).
|
||||
|
||||
For users of Visual Studio 2005 or higher, the default setting to projects is to
|
||||
compile for the Target Platform "Any". This means that on 32-bit Windows, your
|
||||
code will run as 32-bit code (and needs to call DinkeyAdd32.dll) and under 64-bit
|
||||
Windows your code will run as 64-bit code (and needs to call DinkeyAdd64.dll).
|
||||
The sample code works this out automatically. If you select the target platform as "x86"
|
||||
then it will always be 32-bit and so you only need to use DinkeyAdd32.dll. If you
|
||||
select "x64" then your code will be 64-bit and you only need to use DinkeyAdd64.dll.
|
||||
|
||||
The main source files in the project are:
|
||||
|
||||
dapf.vb - the source file contains declarations of our API. We automatically
|
||||
work out whether your code is running in 32-bit or 64-bit and load
|
||||
the appropriate DinkeyAdd module.
|
||||
|
||||
Form1.vb - this is the sample code giving an example on how you can call our API.
|
||||
It contains 5 functions. Just use which ever functions are most appropriate
|
||||
and customise in your own way.
|
||||
|
||||
The best approach is to compile the sample code and see how it works and then to take
|
||||
the appropriate code and apply it to your own project. You should include the dapf.vb
|
||||
file in your project and use/modify which ever functions from Form1.vb you feel are
|
||||
appropriate. The dapf.vb file should not be modified.
|
||||
|
||||
The sample code is just a guide. As none of the parameters are security sensitive then
|
||||
there is no need to implement strong security in calling DinkeyAdd.
|
||||
|
||||
Make sure you remember to do the following when creating your own project:
|
||||
|
||||
1) Insert the following namespaces in your code file:
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
2) Insert the dapf.vb file in your project.
|
||||
|
||||
3) You need to put DinkeyAdd32.dll and/or DinkeyAdd64.dll into the folder that
|
||||
contains dapfTest. Otherwise the message "Unable to open DLL (DinkeyAdd32.dll)" or
|
||||
the System.DllNotFoundException error will appear when you run dapfTest.
|
||||
|
||||
Notes on Debugging 64-bit Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
When you use the 64-bit module (DinkeyAdd64.dll) the anti-debug code is so strong
|
||||
that if you are debugging your code, after calling our API then it will crash with
|
||||
an SEH exception. There are no debug modules for DinkeyAdd so you will have to find
|
||||
other ways of debugging your code (for example taking out the call altogether).
|
||||
467
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/dapf.vb
Normal file
467
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyAdd/dapf.vb
Normal file
@@ -0,0 +1,467 @@
|
||||
' !! this file should not be modified
|
||||
|
||||
' DAPF file is in the following format:
|
||||
' DINKEYINFO
|
||||
' LICENCEINFO (however many are needed)
|
||||
' FILEINFO (however many are needed)
|
||||
' ALGORITHM (however many are needed)
|
||||
' DATAFILEENC (however many are needed)
|
||||
|
||||
Imports System
|
||||
Imports System.Runtime.InteropServices ' so we can marshal the structures as a block of memory
|
||||
Imports System.Text ' for StringBuilder
|
||||
|
||||
' *********** define structures that make up the DAPF file *******************
|
||||
|
||||
Module dapf_code
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DINKEYINFO
|
||||
Dim Header1 As Byte ' should be set to "DAPF"
|
||||
Dim Header2 As Byte
|
||||
Dim Header3 As Byte
|
||||
Dim Header4 As Byte
|
||||
Dim Version As Integer ' version of this structure. Currently 9.
|
||||
Dim SelectedModels As Integer ' BIT0 = Dinkey Pro Lite, BIT1 = Dinkey Pro Plus, BIT2 = Dinkey Pro Net etc...
|
||||
<VBFixedString(12), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
|
||||
Dim ProdCode As String
|
||||
Dim PerLicence As Integer ' 1 = per licence, 0 = per product (default)
|
||||
Dim MaxNetUsers As Integer ' product net users, unlimited = -1, no entry = -2
|
||||
Dim RangeSettings As Integer ' 0 = any number, 1 = dongle in computer, 2 = range
|
||||
Dim RangeMin As UInt32
|
||||
Dim RangeMax As UInt32
|
||||
Dim NumLicences As Integer ' number of LICENCEINFO structures in this DAPF file
|
||||
Dim NumProgs As Integer ' number of FILEINFO structures in this DAPF file
|
||||
Dim NumAlgs As Integer
|
||||
Dim DataSizeType As Integer ' 1 = set the zero data size, 0 = use file to initialise data area
|
||||
Dim ZeroDataSize As Integer ' size of the data area area in bytes
|
||||
' NB some of these entries were for an older (deprecated) FD model. Now marked as deprecated. These fields are ignored.
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim DataFile As String ' path to data file (0 = no data file)
|
||||
Dim DataAreaSize As Integer ' file size in bytes, -1 = file not found
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellSuccessMsg As String ' Shell Method messages...
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellNoDongleMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellExpiryDateMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellExpiryExecsMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellWarnDateMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellWarnExecsMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellNetUserLimitMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellOtherErrorMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ShellBackgroundMsg As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim NetNoServerMsg As String
|
||||
<VBFixedArray(12), MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> _
|
||||
Dim rwalg As Byte() ' coded form of rw algorithm (0 = no algorithm)
|
||||
Dim SecOptions As Integer ' BIT0: DRIS encryption, BIT1: Data encryption, BIT2: Data enc with alg, BIT3: only secure update codes
|
||||
Dim SecDRISEncKey1 As Byte ' DRIS encryption parameters
|
||||
Dim SecDRISEncKey2 As Byte
|
||||
Dim SecDRISEncKey3 As Byte
|
||||
Dim Ignored1 As Byte ' this byte is ignored
|
||||
Dim SecDataEncKey1 As Byte ' API Data encryption parameters
|
||||
Dim SecDataEncKey2 As Byte
|
||||
Dim SecDataEncKey3 As Byte
|
||||
Dim Ignored2 As Byte ' this byte is ignored
|
||||
Dim ProtectionType As Integer ' 0 = software + dongle, 1 = dongle only, 2 = program only
|
||||
<VBFixedString(12), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
|
||||
Dim DataEncKeyProdCode As String ' Alternative Product Code used to generate internal encryption keys. Normally set to 0.
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim Notes As String ' user-defined notes
|
||||
Dim LockDongle As Integer ' 0 = don't lock (default), 1 = lock dongle to user's computer
|
||||
Dim Reserved1 As Integer ' must be 0
|
||||
Dim Reserved2 As Integer ' must be 0
|
||||
Dim AdvancedOptions As Integer ' BIT0 = do not allow usb-over-network for non-Net dongles, BIT1 = do not check for Software Key at Runtime.
|
||||
Dim NumDataFileEnc As Integer ' Number of data files in our encryption list
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure LICENCEINFO
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim LicenceName As String ' licence name
|
||||
Dim MaxDays As Integer ' -1 = no limit
|
||||
Dim ExpiryDay As Integer ' -1 = no limit, 0 = no change
|
||||
Dim ExpiryMonth As Integer
|
||||
Dim ExpiryYear As Integer
|
||||
Dim Execs As Integer ' -1 = no limit
|
||||
Dim ExecsWarn As Integer ' 0 = no warning (just for Shell method)
|
||||
Dim DaysWarn As Integer ' 0 = no warning (just for Shell method)
|
||||
Dim Features As Uint32
|
||||
Dim LicenceNetUsers As Integer ' unlimited = -1 (-2 = not needed (this is for display only))
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure FILEINFO
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim InputName As String ' input file (full path)
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim OutputName As String ' output file/folder
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim CallingProg As String ' calling program name
|
||||
Dim LicenceIndex As Integer ' index (of licence) in the LicenceInfo structure (1-based index. 0 = no selection)
|
||||
Dim Method As Integer ' 0-api, 1-shell, 2-shell & api
|
||||
Dim ShellFlags As Integer ' same bit flag values as in dris. i.e. 1 = DEC_ONE_EXEC, 4 = START_NET_USER
|
||||
Dim BackGround As Integer ' 0=no background, 1=1min, 2=5min, 3=10min, 4=30min, 5=60min
|
||||
Dim OtherShellOptions As Integer ' BIT0 = Shell Data Encryption Enabled, BIT1: Extra Anti-Debug is disabled, BIT2: Extra Anti-Piracy is disabled
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim EncFileList As String ' files (or file types) that the Shell-protected program will treat as encrypted (separated by ':')
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ExceptList As String ' files (or file types) that are exceptions to the above list (separated by ':')
|
||||
Dim ExtraAntiPiracy As Integer ' 0 = off, 1=min, 10=max
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure ALGORITHM
|
||||
<VBFixedArray(12), MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> _
|
||||
Dim alg As Byte() ' coded form of algorithm
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DATAFILEENC
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim InputName As String ' file name, wild cards are allowed
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim OutputName As String ' file name (or folder name if input is a wildcard)
|
||||
End Structure
|
||||
|
||||
' this structure is used for creating Temporary Software Keys
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure TEMP_SWKEY_INFO
|
||||
Dim Size As Integer
|
||||
Dim MachineID As UInt32
|
||||
Dim ExpiryDay As Integer
|
||||
Dim ExpiryMonth As Integer
|
||||
Dim ExpiryYear As Integer
|
||||
Dim DongleModel As Integer
|
||||
Dim DongleNumber As UInt32
|
||||
End Structure
|
||||
|
||||
' this structure is used for creating Demo Software Key Templates
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DEMO_SWKEY_INFO
|
||||
Dim Size As Integer
|
||||
Dim MaxDays As Int32 ' max days demo swkey installation is valid (0-60)
|
||||
Dim Models As Int32 ' bitmap of valid dongle models. See constant values below. 0 = default (only use if only one model is selected in DINKEYINFO)
|
||||
End Structure
|
||||
|
||||
' ********************** DinkeyAdd Module Imports ************************
|
||||
|
||||
' Loads DAPF from disk and returns handle
|
||||
Declare Ansi Function LoadDAPFFromFile32 Lib "DinkeyAdd32.dll" Alias "LoadDAPFFromFile" (ByVal dapf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
Declare Ansi Function LoadDAPFFromFile64 Lib "DinkeyAdd64.dll" Alias "LoadDAPFFromFile" (ByVal dapf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
|
||||
' Loads DAPF from disk into structures supplied (so we can modify DAPF in memory)
|
||||
Declare Ansi Function ReadDAPFEx32 Lib "DinkeyAdd32.dll" Alias "ReadDAPFEx" (ByVal dapf_file As String, ByRef MyDinkeyInfo As DINKEYINFO, ByVal licence_bytes() As Byte, _
|
||||
ByVal fileinfo_bytes() As Byte, ByVal alg_bytes() As Byte, ByVal datafile_bytes() As Byte, ByRef dapf_version As Integer, ByRef dapf_format As Integer) As Integer
|
||||
Declare Ansi Function ReadDAPFEx64 Lib "DinkeyAdd64.dll" Alias "ReadDAPFEx" (ByVal dapf_file As String, ByRef MyDinkeyInfo As DINKEYINFO, ByVal licence_bytes() As Byte, _
|
||||
ByVal fileinfo_bytes() As Byte, ByVal alg_bytes() As Byte, ByVal datafile_bytes() As Byte, ByRef dapf_version As Integer, ByRef dapf_format As Integer) As Integer
|
||||
|
||||
' Loads DAPF from structures and returns a handle
|
||||
Declare Ansi Function LoadDAPF32 Lib "DinkeyAdd32.dll" Alias "LoadDAPF" (ByRef MyDinkeyInfo As DINKEYINFO, ByVal licence_bytes() As Byte, ByVal fileinfo_bytes() As Byte, _
|
||||
ByVal alg_bytes() As Byte, ByVal datafile_bytes() As Byte, ByRef ret_code As Integer) As IntPtr
|
||||
Declare Ansi Function LoadDAPF64 Lib "DinkeyAdd64.dll" Alias "LoadDAPF" (ByRef MyDinkeyInfo As DINKEYINFO, ByVal licence_bytes() As Byte, ByVal fileinfo_bytes() As Byte, _
|
||||
ByVal alg_bytes() As Byte, ByVal datafile_bytes() As Byte, ByRef ret_code As Integer) As IntPtr
|
||||
|
||||
' saves the DAPF file to disk
|
||||
Declare Ansi Function WriteDAPFEx32 Lib "DinkeyAdd32.dll" Alias "WriteDAPFEx" (ByVal dapf_handle As IntPtr, ByVal dapf_file As String, ByVal dapf_format As Integer, _
|
||||
ByVal dapf_version As Integer, ByVal flags As Integer) As Integer
|
||||
Declare Ansi Function WriteDAPFEx64 Lib "DinkeyAdd64.dll" Alias "WriteDAPFEx" (ByVal dapf_handle As IntPtr, ByVal dapf_file As String, ByVal dapf_format As Integer, _
|
||||
ByVal dapf_version As Integer, ByVal flags As Integer) As Integer
|
||||
|
||||
' unloads the DAPF file
|
||||
Declare Ansi Sub UnloadDAPF32 Lib "DinkeyAdd32.dll" Alias "UnloadDAPF" (ByRef dapf_handle As IntPtr)
|
||||
Declare Ansi Sub UnloadDAPF64 Lib "DinkeyAdd64.dll" Alias "UnloadDAPF" (ByRef dapf_handle As IntPtr)
|
||||
|
||||
'main functions
|
||||
Declare Ansi Function AddProtection32 Lib "DinkeyAdd32.dll" Alias "AddProtection" (ByVal dapf_handle As IntPtr, ByVal action As Integer, ByVal file_num As Integer, _
|
||||
ByVal flags As Integer, ByRef dongle_number As UInt32) As Integer
|
||||
Declare Ansi Function AddProtection64 Lib "DinkeyAdd64.dll" Alias "AddProtection" (ByVal dapf_handle As IntPtr, ByVal action As Integer, ByVal file_num As Integer, _
|
||||
ByVal flags As Integer, ByRef dongle_number As UInt32) As Integer
|
||||
|
||||
Declare Ansi Function CreateTempSoftwareKey32 Lib "DinkeyAdd32.dll" Alias "CreateTempSoftwareKey" (ByVal dapf_handle As IntPtr, ByRef my_swkey_info As TEMP_SWKEY_INFO, _
|
||||
ByVal flags As Integer) As Integer
|
||||
Declare Ansi Function CreateTempSoftwareKey64 Lib "DinkeyAdd64.dll" Alias "CreateTempSoftwareKey" (ByVal dapf_handle As IntPtr, ByRef my_swkey_info As TEMP_SWKEY_INFO, _
|
||||
ByVal flags As Integer) As Integer
|
||||
|
||||
Declare Ansi Function CreateDemoSoftwareKeyTemplate32 Lib "DinkeyAdd32.dll" Alias "CreateDemoSoftwareKeyTemplate" (ByVal dapf_handle As IntPtr, ByRef my_swkey_info As DEMO_SWKEY_INFO, _
|
||||
ByVal flags As Integer) As Integer
|
||||
Declare Ansi Function CreateDemoSoftwareKeyTemplate64 Lib "DinkeyAdd64.dll" Alias "CreateDemoSoftwareKeyTemplate" (ByVal dapf_handle As IntPtr, ByRef my_swkey_info As DEMO_SWKEY_INFO, _
|
||||
ByVal flags As Integer) As Integer
|
||||
|
||||
Declare Ansi Function EncryptShellDataFiles32 Lib "DinkeyAdd32.dll" Alias "EncryptShellDataFiles" (ByVal dapf_handle As IntPtr, ByVal file_num As Integer, _
|
||||
ByVal flags As Integer) As Integer
|
||||
Declare Ansi Function EncryptShellDataFiles64 Lib "DinkeyAdd64.dll" Alias "EncryptShellDataFiles" (ByVal dapf_handle As IntPtr, ByVal file_num As Integer, _
|
||||
ByVal flags As Integer) As Integer
|
||||
|
||||
' get the message output by DinkeyAdd
|
||||
Declare Ansi Sub GetLastMessage32 Lib "DinkeyAdd32.dll" Alias "GetLastMessage" (ByVal message As StringBuilder, ByVal buffer_size As Integer, ByRef message_length As Integer)
|
||||
Declare Ansi Sub GetLastMessage64 Lib "DinkeyAdd64.dll" Alias "GetLastMessage" (ByVal message As StringBuilder, ByVal buffer_size As Integer, ByRef message_length As Integer)
|
||||
|
||||
' get the extended error (set if an error occurs)
|
||||
Declare Ansi Function GetLastExtendedError32 Lib "DinkeyAdd32.dll" Alias "GetLastExtendedError" () As Integer
|
||||
Declare Ansi Function GetLastExtendedError64 Lib "DinkeyAdd64.dll" Alias "GetLastExtendedError" () As Integer
|
||||
|
||||
' ********************** Constants ************************
|
||||
Public Const DAPF_VERSION As Integer = 9 ' current DAPF version
|
||||
|
||||
' WriteDAPFEx API flags
|
||||
Public Const FLAGS_LOSE_FEATURES As Integer = 1 ' means that you can save the DAPF file to an earlier version even if it means losing some new features that have been currently set
|
||||
|
||||
' AddProtection API action values
|
||||
Public Const ACTION_USE_DAPF_SETTINGS As Integer = 0 ' means you just ignore the action value and use the default dapf settings
|
||||
Public Const ACTION_PROGRAM_DONGLE As Integer = 1 ' program the dongle only
|
||||
Public Const ACTION_PROTECT_SOFTWARE As Integer = 2 ' protect a software file (index indicated by separate parameter)
|
||||
Public Const ACTION_PROGRAM_AND_PROTECT As Integer = 3 ' program the dongle and protect software
|
||||
|
||||
' AddProtection API flags values
|
||||
Public Const FLAGS_OVERWRITE_OUTPUT As Integer = 1 ' overwrite the output file if it already exists (default is to give an error)
|
||||
|
||||
' CreateSoftwareKey API flags
|
||||
Public Const FLAGS_OVERWRITE_SWKEY As Integer = 1 ' ovewrite an existing swkey with the new one
|
||||
Public Const FLAGS_EXPIRY_DONTCARE As Integer = 2 ' create the Software Key even though the expiry date (or max days) is less than the expiry date of the key itself.
|
||||
|
||||
' constants for dapf_format in ReadDAPFEx and WriteDAPFEx functions
|
||||
Public Const DAPF_FORMAT_BINARY As Integer = 1
|
||||
Public Const DAPF_FORMAT_JSON As Integer = 2
|
||||
Public Const DAPF_FORMAT_JSON_MIN As Integer = 3 ' this value is only used with WriteDAPEx. ReadDAPFEx cannot return this value.
|
||||
|
||||
' constants for values for model in the TEMP_SWKEY_INFO structure
|
||||
Public Const SWKEY_MODEL_PRO_LITE As Integer = 0
|
||||
Public Const SWKEY_MODEL_PRO_PLUS As Integer = 1
|
||||
Public Const SWKEY_MODEL_PRO_NET As Integer = 2
|
||||
Public Const SWKEY_MODEL_FD_LITE As Integer = 3
|
||||
Public Const SWKEY_MODEL_FD_PLUS As Integer = 4
|
||||
Public Const SWKEY_MODEL_FD_NET As Integer = 5
|
||||
|
||||
' constants for models bitmap in the DEMO_SWKEY_INFO structure
|
||||
Public Const SWKEY_BITMAP_DEFAULT As Integer = 0 ' use default value set in DINKEYINFO.SelectedModels
|
||||
Public Const SWKEY_BITMAP_PRO_LITE As Integer = 1 ' BIT0
|
||||
Public Const SWKEY_BITMAP_PRO_PLUS As Integer = 2 ' BIT1
|
||||
Public Const SWKEY_BITMAP_PRO_NET As Integer = 4 ' BIT2
|
||||
Public Const SWKEY_BITMAP_FD_LITE As Integer = 8 ' BIT3
|
||||
Public Const SWKEY_BITMAP_FD_PLUS As Integer = 16 ' BIT4
|
||||
Public Const SWKEY_BITMAP_FD_NET As Integer = 32 ' BIT5
|
||||
|
||||
' private constants
|
||||
Private Const MAX_LICENCES As Integer = 255 ' max number of licences in a DAPF file
|
||||
Private Const MAX_FILE_INFO As Integer = 1000 ' theoretically unlimited but in practice it is easier if we limit it
|
||||
Private Const MAX_USER_ALGS As Integer = 20 'max number of user algs in DAPF file
|
||||
Private Const MAX_DATA_ENCS As Integer = 255 ' max number of Shell data encryption files in DAPF file
|
||||
|
||||
' ********************** API Functions ************************
|
||||
' We only want to load the correct DLL for the bit-ness of the computer. The other DLL may not exist.
|
||||
' if the appropriate DLL does not exist in the same directory as this test program you will receive a DllNotFoundException
|
||||
|
||||
' call the correct dll depending on whether we are running 32-bit or 64-bit code
|
||||
Function LoadDAPFFromFile(ByVal dapf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
If (IntPtr.Size = 4) Then
|
||||
LoadDAPFFromFile = LoadDAPFFromFile32(dapf_file, err_code)
|
||||
Else
|
||||
LoadDAPFFromFile = LoadDAPFFromFile64(dapf_file, err_code)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' we have to do some marshalling of arrays of bytes into arrays of structures
|
||||
Function ReadDAPFEx(ByVal dapf_file As String, ByRef MyDinkeyInfo As DINKEYINFO, ByRef LicenceInfoArray() As LICENCEINFO, ByRef FileInfoArray() As FILEINFO, _
|
||||
ByRef AlgorithmArray() As ALGORITHM, ByRef DataFileEncArray() As DATAFILEENC, ByRef dapf_version As Integer, ByRef dapf_format As Integer) As Integer
|
||||
Dim i As Integer
|
||||
Dim MyLicenceInfo As New LICENCEINFO
|
||||
Dim licence_bytes(MAX_LICENCES * Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim licence_bytes_one_struct(Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim MyFileInfo As New FILEINFO
|
||||
Dim fileinfo_bytes(MAX_FILE_INFO * Marshal.SizeOf(MyFileInfo)) As Byte
|
||||
Dim fileinfo_bytes_one_struct(Marshal.SizeOf(MyFileInfo)) As Byte
|
||||
Dim MyAlgorithm As New ALGORITHM
|
||||
Dim alg_bytes(MAX_USER_ALGS * Marshal.SizeOf(MyAlgorithm)) As Byte
|
||||
Dim alg_bytes_one_struct(Marshal.SizeOf(MyAlgorithm)) As Byte
|
||||
Dim MyDataFileEnc As New DATAFILEENC
|
||||
Dim datafile_bytes(MAX_DATA_ENCS * Marshal.SizeOf(MyDataFileEnc)) As Byte
|
||||
Dim datafile_bytes_one_struct(Marshal.SizeOf(MyDataFileEnc)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
MyDinkeyInfo = New DINKEYINFO
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
ReadDAPFEx = ReadDAPFEx32(dapf_file, MyDinkeyInfo, licence_bytes, fileinfo_bytes, alg_bytes, datafile_bytes, dapf_version, dapf_format)
|
||||
Else
|
||||
ReadDAPFEx = ReadDAPFEx64(dapf_file, MyDinkeyInfo, licence_bytes, fileinfo_bytes, alg_bytes, datafile_bytes, dapf_version, dapf_format)
|
||||
End If
|
||||
|
||||
If ReadDAPFEx <> 0 Then
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' convert byte array to an array of structs
|
||||
ReDim LicenceInfoArray(MyDinkeyInfo.NumLicences)
|
||||
For i = 0 To MyDinkeyInfo.NumLicences - 1
|
||||
LicenceInfoArray(i) = New LICENCEINFO
|
||||
Array.Copy(licence_bytes, i * Marshal.SizeOf(MyLicenceInfo.GetType), licence_bytes_one_struct, 0, Marshal.SizeOf(MyLicenceInfo.GetType))
|
||||
MyGC = GCHandle.Alloc(licence_bytes_one_struct, GCHandleType.Pinned)
|
||||
LicenceInfoArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyLicenceInfo.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
ReDim FileInfoArray(MyDinkeyInfo.NumProgs)
|
||||
For i = 0 To MyDinkeyInfo.NumProgs - 1
|
||||
FileInfoArray(i) = New FILEINFO
|
||||
Array.Copy(fileinfo_bytes, i * Marshal.SizeOf(MyFileInfo.GetType), fileinfo_bytes_one_struct, 0, Marshal.SizeOf(MyFileInfo.GetType))
|
||||
MyGC = GCHandle.Alloc(fileinfo_bytes_one_struct, GCHandleType.Pinned)
|
||||
FileInfoArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyFileInfo.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
ReDim AlgorithmArray(MyDinkeyInfo.NumAlgs)
|
||||
For i = 0 To MyDinkeyInfo.NumAlgs - 1
|
||||
AlgorithmArray(i) = New ALGORITHM
|
||||
Array.Copy(alg_bytes, i * Marshal.SizeOf(MyAlgorithm.GetType), alg_bytes_one_struct, 0, Marshal.SizeOf(MyAlgorithm.GetType))
|
||||
MyGC = GCHandle.Alloc(alg_bytes_one_struct, GCHandleType.Pinned)
|
||||
AlgorithmArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyAlgorithm.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
ReDim DataFileEncArray(MyDinkeyInfo.NumDataFileEnc)
|
||||
For i = 0 To MyDinkeyInfo.NumDataFileEnc - 1
|
||||
DataFileEncArray(i) = New DATAFILEENC
|
||||
Array.Copy(datafile_bytes, i * Marshal.SizeOf(MyDataFileEnc.GetType), datafile_bytes_one_struct, 0, Marshal.SizeOf(MyDataFileEnc.GetType))
|
||||
MyGC = GCHandle.Alloc(datafile_bytes_one_struct, GCHandleType.Pinned)
|
||||
DataFileEncArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyDataFileEnc.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
Function LoadDAPF(ByRef MyDinkeyInfo As DINKEYINFO, ByRef LicenceInfoArray() As LICENCEINFO, ByRef FileInfoArray() As FILEINFO, _
|
||||
ByRef AlgorithmArray() As ALGORITHM, ByRef DataFileEncArray() As DATAFILEENC, ByRef ret_code As Integer) As IntPtr
|
||||
Dim i As Integer
|
||||
Dim MyLicenceInfo As New LICENCEINFO
|
||||
Dim licence_bytes(MAX_LICENCES * Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim licence_bytes_one_struct(Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim MyFileInfo As New FILEINFO
|
||||
Dim fileinfo_bytes(MAX_FILE_INFO * Marshal.SizeOf(MyFileInfo)) As Byte
|
||||
Dim fileinfo_bytes_one_struct(Marshal.SizeOf(MyFileInfo)) As Byte
|
||||
Dim MyAlgorithm As New ALGORITHM
|
||||
Dim alg_bytes(MAX_USER_ALGS * Marshal.SizeOf(MyAlgorithm)) As Byte
|
||||
Dim alg_bytes_one_struct(Marshal.SizeOf(MyAlgorithm)) As Byte
|
||||
Dim MyDataFileEnc As New DATAFILEENC
|
||||
Dim datafile_bytes(MAX_DATA_ENCS * Marshal.SizeOf(MyDataFileEnc)) As Byte
|
||||
Dim datafile_bytes_one_struct(Marshal.SizeOf(MyDataFileEnc)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
|
||||
' convert array of structs to byte arrays
|
||||
For i = 0 To MyDinkeyInfo.NumLicences - 1
|
||||
MyGC = GCHandle.Alloc(licence_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(LicenceInfoArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(licence_bytes_one_struct, 0, licence_bytes, i * Marshal.SizeOf(MyLicenceInfo.GetType), Marshal.SizeOf(MyLicenceInfo.GetType))
|
||||
Next
|
||||
|
||||
For i = 0 To MyDinkeyInfo.NumProgs - 1
|
||||
MyGC = GCHandle.Alloc(fileinfo_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(FileInfoArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(fileinfo_bytes_one_struct, 0, fileinfo_bytes, i * Marshal.SizeOf(MyFileInfo.GetType), Marshal.SizeOf(MyFileInfo.GetType))
|
||||
Next
|
||||
|
||||
For i = 0 To MyDinkeyInfo.NumAlgs - 1
|
||||
MyGC = GCHandle.Alloc(alg_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(AlgorithmArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(alg_bytes_one_struct, 0, alg_bytes, i * Marshal.SizeOf(MyAlgorithm.GetType), Marshal.SizeOf(MyAlgorithm.GetType))
|
||||
Next
|
||||
|
||||
For i = 0 To MyDinkeyInfo.NumDataFileEnc - 1
|
||||
MyGC = GCHandle.Alloc(datafile_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(DataFileEncArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(datafile_bytes_one_struct, 0, datafile_bytes, i * Marshal.SizeOf(MyDataFileEnc.GetType), Marshal.SizeOf(MyDataFileEnc.GetType))
|
||||
Next
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
LoadDAPF = LoadDAPF32(MyDinkeyInfo, licence_bytes, fileinfo_bytes, alg_bytes, datafile_bytes, ret_code)
|
||||
Else
|
||||
LoadDAPF = LoadDAPF64(MyDinkeyInfo, licence_bytes, fileinfo_bytes, alg_bytes, datafile_bytes, ret_code)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Function WriteDAPFEx(ByVal dapf_handle As IntPtr, ByVal dapf_file As String, ByVal dapf_format As Integer, ByVal dapf_version As Integer, ByVal flags As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
WriteDAPFEx = WriteDAPFEx32(dapf_handle, dapf_file, dapf_format, dapf_version, flags)
|
||||
Else
|
||||
WriteDAPFEx = WriteDAPFEx64(dapf_handle, dapf_file, dapf_format, dapf_version, flags)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Sub UnloadDAPF(ByRef dapf_handle As IntPtr)
|
||||
If (IntPtr.Size = 4) Then
|
||||
UnloadDAPF32(dapf_handle)
|
||||
Else
|
||||
UnloadDAPF64(dapf_handle)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Function AddProtection(ByVal dapf_handle As IntPtr, ByVal action As Integer, ByVal file_num As Integer, ByVal flags As Integer, ByRef dongle_number As UInt32) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
AddProtection = AddProtection32(dapf_handle, action, file_num, flags, dongle_number)
|
||||
Else
|
||||
AddProtection = AddProtection64(dapf_handle, action, file_num, flags, dongle_number)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function CreateTempSoftwareKey(ByVal dapf_handle As IntPtr, ByRef swkey_info As TEMP_SWKEY_INFO, ByVal flags As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
CreateTempSoftwareKey = CreateTempSoftwareKey32(dapf_handle, swkey_info, flags)
|
||||
Else
|
||||
CreateTempSoftwareKey = CreateTempSoftwareKey64(dapf_handle, swkey_info, flags)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function CreateDemoSoftwareKeyTemplate(ByVal dapf_handle As IntPtr, ByRef swkey_info As DEMO_SWKEY_INFO, ByVal flags As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
CreateDemoSoftwareKeyTemplate = CreateDemoSoftwareKeyTemplate32(dapf_handle, swkey_info, flags)
|
||||
Else
|
||||
CreateDemoSoftwareKeyTemplate = CreateDemoSoftwareKeyTemplate64(dapf_handle, swkey_info, flags)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function EncryptShellDataFiles(ByVal dapf_handle As IntPtr, ByVal file_num As Integer, ByVal flags As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
EncryptShellDataFiles = EncryptShellDataFiles32(dapf_handle, file_num, flags)
|
||||
Else
|
||||
EncryptShellDataFiles = EncryptShellDataFiles64(dapf_handle, file_num, flags)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' do a bit of work here to make the function easier to use for VB.NET
|
||||
Function GetLastMessage() As String
|
||||
Dim length, dummy As Integer
|
||||
Dim message As StringBuilder
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
GetLastMessage32(Nothing, 0, length)
|
||||
message = New StringBuilder(length)
|
||||
GetLastMessage32(message, length, dummy)
|
||||
Else
|
||||
GetLastMessage64(Nothing, 0, length)
|
||||
message = New StringBuilder(length)
|
||||
GetLastMessage64(message, length, dummy)
|
||||
End If
|
||||
|
||||
Return message.ToString()
|
||||
End Function
|
||||
|
||||
Function GetLastExtendedError() As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
GetLastExtendedError = GetLastExtendedError32()
|
||||
Else
|
||||
GetLastExtendedError = GetLastExtendedError64()
|
||||
End If
|
||||
End Function
|
||||
|
||||
End Module
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "dapfTest", "dapfTest.vbproj", "{35022C29-459B-4D19-BC69-5133B03CD7FF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{35022C29-459B-4D19-BC69-5133B03CD7FF}.Debug.ActiveCfg = Debug|.NET
|
||||
{35022C29-459B-4D19-BC69-5133B03CD7FF}.Debug.Build.0 = Debug|.NET
|
||||
{35022C29-459B-4D19-BC69-5133B03CD7FF}.Release.ActiveCfg = Release|.NET
|
||||
{35022C29-459B-4D19-BC69-5133B03CD7FF}.Release.Build.0 = Release|.NET
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,121 @@
|
||||
<VisualStudioProject>
|
||||
<VisualBasic
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.0.9466"
|
||||
SchemaVersion = "1.0"
|
||||
ProjectGuid = "{35022C29-459B-4D19-BC69-5133B03CD7FF}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "dapfTest"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
AssemblyOriginatorKeyMode = "None"
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "WinExe"
|
||||
OptionCompare = "Binary"
|
||||
OptionExplicit = "On"
|
||||
OptionStrict = "Off"
|
||||
RootNamespace = "dapfTest"
|
||||
StartupObject = "dapfTest.Form1"
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "true"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "true"
|
||||
IncrementalBuild = "true"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "false"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "false"
|
||||
IncrementalBuild = "false"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
</References>
|
||||
<Imports>
|
||||
<Import Namespace = "Microsoft.VisualBasic" />
|
||||
<Import Namespace = "System" />
|
||||
<Import Namespace = "System.Collections" />
|
||||
<Import Namespace = "System.Data" />
|
||||
<Import Namespace = "System.Drawing" />
|
||||
<Import Namespace = "System.Diagnostics" />
|
||||
<Import Namespace = "System.Windows.Forms" />
|
||||
</Imports>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "dapf.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.vb"
|
||||
SubType = "Form"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.resx"
|
||||
DependentUpon = "Form1.vb"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "readme.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</VisualBasic>
|
||||
</VisualStudioProject>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("28D149B1-ABE4-47E0-80D4-DAE95B6F9862")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.*")>
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ChangeTest", "ChangeTest.vbproj", "{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}.Debug.ActiveCfg = Debug|.NET
|
||||
{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}.Debug.Build.0 = Debug|.NET
|
||||
{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}.Release.ActiveCfg = Release|.NET
|
||||
{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}.Release.Build.0 = Release|.NET
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,121 @@
|
||||
<VisualStudioProject>
|
||||
<VisualBasic
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{5F1FF5B9-0F39-4DF7-B37A-CD1A84027EDB}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "ChangeTest"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
AssemblyOriginatorKeyMode = "None"
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "WinExe"
|
||||
OptionCompare = "Binary"
|
||||
OptionExplicit = "On"
|
||||
OptionStrict = "Off"
|
||||
RootNamespace = "ChangeTest"
|
||||
StartupObject = "ChangeTest.Form1"
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "true"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "true"
|
||||
IncrementalBuild = "true"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "false"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "false"
|
||||
IncrementalBuild = "false"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
</References>
|
||||
<Imports>
|
||||
<Import Namespace = "Microsoft.VisualBasic" />
|
||||
<Import Namespace = "System" />
|
||||
<Import Namespace = "System.Collections" />
|
||||
<Import Namespace = "System.Data" />
|
||||
<Import Namespace = "System.Drawing" />
|
||||
<Import Namespace = "System.Diagnostics" />
|
||||
<Import Namespace = "System.Windows.Forms" />
|
||||
</Imports>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "DinkeyChange.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.vb"
|
||||
SubType = "Form"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.resx"
|
||||
DependentUpon = "Form1.vb"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "readme.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</VisualBasic>
|
||||
</VisualStudioProject>
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
' !! this file should not be modified
|
||||
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Text
|
||||
|
||||
Module DinkeyChange_code
|
||||
|
||||
' declarations for functions exported by DinkeyChange.dll
|
||||
Declare Ansi Function DCGetInfo32 Lib "DinkeyChange.dll" Alias "DCGetInfo" (ByVal type_mask As Integer, ByVal model_mask As Integer, ByVal prodcode_mask As String, ByVal array_length As Integer, _
|
||||
ByRef num_found As Integer, ByVal type_array() As Integer, ByVal model_array() As Integer, ByVal prodcode_array() As Byte, ByVal dongle_number() As UInt32, ByVal update_number() As Integer) As Integer
|
||||
Declare Ansi Function DCGetDiagnosticInfo32 Lib "DinkeyChange.dll" Alias "DCGetDiagnosticInfo" (ByVal filename As String) As Integer
|
||||
Declare Ansi Function DCDoUpdateCodeString32 Lib "DinkeyChange.dll" Alias "DCDoUpdateCodeString" (ByVal update_code_string As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDoUpdateCodeFromFile32 Lib "DinkeyChange.dll" Alias "DCDoUpdateCodeFromFile" (ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCRestoreDinkeyFDLite32 Lib "DinkeyChange.dll" Alias "DCRestoreDinkeyFDLite" () As Integer
|
||||
Declare Ansi Function DCGetMachineID32 Lib "DinkeyChange.dll" Alias "DCGetMachineID" (ByRef machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDownloadTempSoftwareKey32 Lib "DinkeyChange.dll" Alias "DCDownloadTempSoftwareKey" (ByVal machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDownloadDemoSoftwareKey32 Lib "DinkeyChange.dll" Alias "DCDownloadDemoSoftwareKey" (ByVal machineID As UInt32, ByVal prodcode As String, ByVal model As Integer, ByRef extended_error As Integer) As Integer
|
||||
|
||||
' declarations for functions exported by DinkeyChange64.dll
|
||||
Declare Ansi Function DCGetInfo64 Lib "DinkeyChange64.dll" Alias "DCGetInfo" (ByVal type_mask As Integer, ByVal model_mask As Integer, ByVal prodcode_mask As String, ByVal array_length As Integer, _
|
||||
ByRef num_found As Integer, ByVal type_array() As Integer, ByVal model_array() As Integer, ByVal prodcode_array() As Byte, ByVal dongle_number() As UInt32, ByVal update_number() As Integer) As Integer
|
||||
Declare Ansi Function DCGetDiagnosticInfo64 Lib "DinkeyChange64.dll" Alias "DCGetDiagnosticInfo" (ByVal filename As String) As Integer
|
||||
Declare Ansi Function DCDoUpdateCodeString64 Lib "DinkeyChange64.dll" Alias "DCDoUpdateCodeString" (ByVal update_code_string As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDoUpdateCodeFromFile64 Lib "DinkeyChange64.dll" Alias "DCDoUpdateCodeFromFile" (ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCRestoreDinkeyFDLite64 Lib "DinkeyChange64.dll" Alias "DCRestoreDinkeyFDLite" () As Integer
|
||||
Declare Ansi Function DCGetMachineID64 Lib "DinkeyChange64.dll" Alias "DCGetMachineID" (ByRef machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDownloadTempSoftwareKey64 Lib "DinkeyChange64.dll" Alias "DCDownloadTempSoftwareKey" (ByVal machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DCDownloadDemoSoftwareKey64 Lib "DinkeyChange64.dll" Alias "DCDownloadDemoSoftwareKey" (ByVal machineID As UInt32, ByVal prodcode As String, ByVal model As Integer, ByRef extended_error As Integer) As Integer
|
||||
|
||||
'routines that ensure the relevant dll is called depending on whether we are running on 32-bit or 64-bit Windows
|
||||
Function DCGetInfo(ByVal type_mask As Integer, ByVal model_mask As Integer, ByVal prodcode_mask As String, ByVal array_length As Integer, _
|
||||
ByRef num_found As Integer, ByVal type_array() As Integer, ByVal model_array() As Integer, ByVal prodcode_array() As Byte, ByVal dongle_number() As UInt32, ByVal update_number() As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCGetInfo = DCGetInfo32(type_mask, model_mask, prodcode_mask, array_length, num_found, type_array, model_array, prodcode_array, dongle_number, update_number)
|
||||
Else
|
||||
DCGetInfo = DCGetInfo64(type_mask, model_mask, prodcode_mask, array_length, num_found, type_array, model_array, prodcode_array, dongle_number, update_number)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCGetDiagnosticInfo(ByVal filename As String) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCGetDiagnosticInfo = DCGetDiagnosticInfo32(filename)
|
||||
Else
|
||||
DCGetDiagnosticInfo = DCGetDiagnosticInfo64(filename)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCDoUpdateCodeString(ByVal update_code_string As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCDoUpdateCodeString = DCDoUpdateCodeString32(update_code_string, confirmation_code, extended_error)
|
||||
Else
|
||||
DCDoUpdateCodeString = DCDoUpdateCodeString64(update_code_string, confirmation_code, extended_error)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCDoUpdateCodeFromFile(ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCDoUpdateCodeFromFile = DCDoUpdateCodeFromFile32(filename, confirmation_code, extended_error)
|
||||
Else
|
||||
DCDoUpdateCodeFromFile = DCDoUpdateCodeFromFile64(filename, confirmation_code, extended_error)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCRestoreDinkeyFDLite() As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCRestoreDinkeyFDLite = DCRestoreDinkeyFDLite32()
|
||||
Else
|
||||
DCRestoreDinkeyFDLite = DCRestoreDinkeyFDLite64()
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCGetMachineID(ByRef machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCGetMachineID = DCGetMachineID32(machineID, extended_error)
|
||||
Else
|
||||
DCGetMachineID = DCGetMachineID64(machineID, extended_error)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCDownloadTempSoftwareKey(ByVal machineID As UInt32, ByRef extended_error As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCDownloadTempSoftwareKey = DCDownloadTempSoftwareKey32(machineID, extended_error)
|
||||
Else
|
||||
DCDownloadTempSoftwareKey = DCDownloadTempSoftwareKey64(machineID, extended_error)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DCDownloadDemoSoftwareKey(ByVal machineID As UInt32, ByVal prodcode As String, ByVal model As Integer, ByRef extended_error As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DCDownloadDemoSoftwareKey = DCDownloadDemoSoftwareKey32(machineID, prodcode, model, extended_error)
|
||||
Else
|
||||
DCDownloadDemoSoftwareKey = DCDownloadDemoSoftwareKey64(machineID, prodcode, model, extended_error)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' routine to extract product code string from array of product codes
|
||||
Function GetProductCode(ByRef prodcode() As Byte, ByVal index As Integer) As String
|
||||
Dim i As Integer
|
||||
Dim ascii As New ASCIIEncoding()
|
||||
|
||||
For i = 0 To 8
|
||||
If prodcode((index * 9) + i) = 0 Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Return ascii.GetString(prodcode, index * 9, i)
|
||||
End Function
|
||||
|
||||
' maximum number of USB devices that can be attached to a machine at any time
|
||||
Public Const MAX_USB_DEVICES As Integer = 128
|
||||
Public Const MAX_PRODCODE_LEN As Integer = 9
|
||||
|
||||
' mask values
|
||||
Public Const TYPE_MASK_PRO As Integer = 1
|
||||
Public Const TYPE_MASK_FD As Integer = 2
|
||||
Public Const TYPE_MASK_ALL As Integer = TYPE_MASK_PRO Or TYPE_MASK_FD
|
||||
|
||||
Public Const MODEL_MASK_LITE As Integer = 1
|
||||
Public Const MODEL_MASK_PLUS As Integer = 2
|
||||
Public Const MODEL_MASK_NET As Integer = 4
|
||||
Public Const MODEL_MASK_ALL As Integer = MODEL_MASK_LITE Or MODEL_MASK_PLUS Or MODEL_MASK_NET
|
||||
Public Const MODEL_MASK_DEFAULT As Integer = MODEL_MASK_PLUS Or MODEL_MASK_NET
|
||||
|
||||
' type values for DCGetInfo (returned in the array)
|
||||
Public Const TYPE_PRO As Integer = 1
|
||||
Public Const TYPE_FD As Integer = 2
|
||||
|
||||
' model values for DCGetInfo (returned in the array)
|
||||
Public Const MODEL_LITE As Integer = 1
|
||||
Public Const MODEL_PLUS As Integer = 2
|
||||
Public Const MODEL_NET5 As Integer = 4
|
||||
Public Const MODEL_NETU As Integer = 7
|
||||
|
||||
' model values for DCDownloadDemoSoftwareKey
|
||||
Public Const SWKEY_MODEL_DEFAULT As Integer = &HFFFFFFFF ' NB this assumes that the Demo Software Key Template was created with only one valid dongle model
|
||||
Public Const SWKEY_MODEL_PRO_LITE As Integer = 0
|
||||
Public Const SWKEY_MODEL_PRO_PLUS As Integer = 1
|
||||
Public Const SWKEY_MODEL_PRO_NET As Integer = 2
|
||||
Public Const SWKEY_MODEL_FD_LITE As Integer = 3
|
||||
Public Const SWKEY_MODEL_FD_PLUS As Integer = 4
|
||||
Public Const SWKEY_MODEL_FD_NET As Integer = 5
|
||||
|
||||
End Module
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="GetDongleInfo.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="GetDongleInfo.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="GetDongleInfo.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="label1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DiagFilename.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DiagFilename.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="DiagFilename.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="WriteDiags.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="WriteDiags.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="WriteDiags.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeString.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeString.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeString.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="UpdateCodeString.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="UpdateCodeString.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="UpdateCodeString.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="Label2.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="Label2.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="Label2.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeFile.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeFile.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DoUpdateCodeFile.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="UpdateCodeFile.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="UpdateCodeFile.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="UpdateCodeFile.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="Label3.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="Label3.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="Label3.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="RestoreFDLite.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="RestoreFDLite.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="RestoreFDLite.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="GetMachineID.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="GetMachineID.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="GetMachineID.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DownloadSoftwareKey.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="DownloadSoftwareKey.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="DownloadSoftwareKey.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="ShowMachineID.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="ShowMachineID.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="ShowMachineID.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>Form1</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
</root>
|
||||
458
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyChange/Form1.vb
Normal file
458
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyChange/Form1.vb
Normal file
@@ -0,0 +1,458 @@
|
||||
' !! We strongly recommend that you read the "readme.txt" file in the sample code folder.
|
||||
' !! It contains important instructions on how to use the sample code
|
||||
|
||||
Imports System.Text
|
||||
|
||||
Public Class Form1
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
'Add any initialization after the InitializeComponent() call
|
||||
|
||||
End Sub
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
Friend WithEvents GetDongleInfo As System.Windows.Forms.Button
|
||||
Friend WithEvents label1 As System.Windows.Forms.Label
|
||||
Friend WithEvents DiagFilename As System.Windows.Forms.TextBox
|
||||
Friend WithEvents WriteDiags As System.Windows.Forms.Button
|
||||
Friend WithEvents DoUpdateCodeString As System.Windows.Forms.Button
|
||||
Friend WithEvents UpdateCodeString As System.Windows.Forms.TextBox
|
||||
Friend WithEvents Label2 As System.Windows.Forms.Label
|
||||
Friend WithEvents DoUpdateCodeFile As System.Windows.Forms.Button
|
||||
Friend WithEvents Label3 As System.Windows.Forms.Label
|
||||
Friend WithEvents UpdateCodeFile As System.Windows.Forms.TextBox
|
||||
Friend WithEvents RestoreFDLite As System.Windows.Forms.Button
|
||||
Friend WithEvents GetMachineID As System.Windows.Forms.Button
|
||||
Friend WithEvents DownloadTempSoftwareKey As System.Windows.Forms.Button
|
||||
Friend WithEvents ShowMachineID As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label4 As System.Windows.Forms.Label
|
||||
Friend WithEvents ProdCode As System.Windows.Forms.TextBox
|
||||
Friend WithEvents DownloadDemoSoftwareKey As System.Windows.Forms.Button
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.GetDongleInfo = New System.Windows.Forms.Button
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
Me.DiagFilename = New System.Windows.Forms.TextBox
|
||||
Me.WriteDiags = New System.Windows.Forms.Button
|
||||
Me.DoUpdateCodeString = New System.Windows.Forms.Button
|
||||
Me.UpdateCodeString = New System.Windows.Forms.TextBox
|
||||
Me.Label2 = New System.Windows.Forms.Label
|
||||
Me.DoUpdateCodeFile = New System.Windows.Forms.Button
|
||||
Me.UpdateCodeFile = New System.Windows.Forms.TextBox
|
||||
Me.Label3 = New System.Windows.Forms.Label
|
||||
Me.RestoreFDLite = New System.Windows.Forms.Button
|
||||
Me.GetMachineID = New System.Windows.Forms.Button
|
||||
Me.DownloadTempSoftwareKey = New System.Windows.Forms.Button
|
||||
Me.ShowMachineID = New System.Windows.Forms.TextBox
|
||||
Me.label4 = New System.Windows.Forms.Label
|
||||
Me.ProdCode = New System.Windows.Forms.TextBox
|
||||
Me.DownloadDemoSoftwareKey = New System.Windows.Forms.Button
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'GetDongleInfo
|
||||
'
|
||||
Me.GetDongleInfo.Location = New System.Drawing.Point(48, 24)
|
||||
Me.GetDongleInfo.Name = "GetDongleInfo"
|
||||
Me.GetDongleInfo.Size = New System.Drawing.Size(216, 24)
|
||||
Me.GetDongleInfo.TabIndex = 0
|
||||
Me.GetDongleInfo.Text = "Get Dongle Information"
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.Location = New System.Drawing.Point(16, 72)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(296, 16)
|
||||
Me.label1.TabIndex = 1
|
||||
Me.label1.Text = "Enter diagnostic filename:"
|
||||
'
|
||||
'DiagFilename
|
||||
'
|
||||
Me.DiagFilename.Location = New System.Drawing.Point(16, 88)
|
||||
Me.DiagFilename.Name = "DiagFilename"
|
||||
Me.DiagFilename.Size = New System.Drawing.Size(288, 20)
|
||||
Me.DiagFilename.TabIndex = 2
|
||||
Me.DiagFilename.Text = ""
|
||||
'
|
||||
'WriteDiags
|
||||
'
|
||||
Me.WriteDiags.Location = New System.Drawing.Point(56, 120)
|
||||
Me.WriteDiags.Name = "WriteDiags"
|
||||
Me.WriteDiags.Size = New System.Drawing.Size(192, 23)
|
||||
Me.WriteDiags.TabIndex = 3
|
||||
Me.WriteDiags.Text = "Write Diagnostics to File"
|
||||
'
|
||||
'Label2
|
||||
'
|
||||
Me.Label2.Location = New System.Drawing.Point(16, 171)
|
||||
Me.Label2.Name = "Label2"
|
||||
Me.Label2.Size = New System.Drawing.Size(296, 16)
|
||||
Me.Label2.TabIndex = 4
|
||||
Me.Label2.Text = "Enter short Update Code here:"
|
||||
'
|
||||
'UpdateCodeString
|
||||
'
|
||||
Me.UpdateCodeString.Location = New System.Drawing.Point(16, 187)
|
||||
Me.UpdateCodeString.Name = "UpdateCodeString"
|
||||
Me.UpdateCodeString.Size = New System.Drawing.Size(288, 20)
|
||||
Me.UpdateCodeString.TabIndex = 5
|
||||
Me.UpdateCodeString.Text = ""
|
||||
'
|
||||
'DoUpdateCodeString
|
||||
'
|
||||
Me.DoUpdateCodeString.Location = New System.Drawing.Point(56, 219)
|
||||
Me.DoUpdateCodeString.Name = "DoUpdateCodeString"
|
||||
Me.DoUpdateCodeString.Size = New System.Drawing.Size(192, 23)
|
||||
Me.DoUpdateCodeString.TabIndex = 6
|
||||
Me.DoUpdateCodeString.Text = "Make Changes"
|
||||
'
|
||||
'Label3
|
||||
'
|
||||
Me.Label3.Location = New System.Drawing.Point(16, 272)
|
||||
Me.Label3.Name = "Label3"
|
||||
Me.Label3.Size = New System.Drawing.Size(296, 16)
|
||||
Me.Label3.TabIndex = 7
|
||||
Me.Label3.Text = "Enter path to Update Code file:"
|
||||
'
|
||||
'UpdateCodeFile
|
||||
'
|
||||
Me.UpdateCodeFile.Location = New System.Drawing.Point(16, 288)
|
||||
Me.UpdateCodeFile.Name = "UpdateCodeFile"
|
||||
Me.UpdateCodeFile.Size = New System.Drawing.Size(288, 20)
|
||||
Me.UpdateCodeFile.TabIndex = 8
|
||||
Me.UpdateCodeFile.Text = ""
|
||||
'
|
||||
'DoUpdateCodeFile
|
||||
'
|
||||
Me.DoUpdateCodeFile.Location = New System.Drawing.Point(56, 320)
|
||||
Me.DoUpdateCodeFile.Name = "DoUpdateCodeFile"
|
||||
Me.DoUpdateCodeFile.Size = New System.Drawing.Size(192, 23)
|
||||
Me.DoUpdateCodeFile.TabIndex = 9
|
||||
Me.DoUpdateCodeFile.Text = "Make Changes"
|
||||
'
|
||||
'RestoreFDLite
|
||||
'
|
||||
Me.RestoreFDLite.Location = New System.Drawing.Point(56, 376)
|
||||
Me.RestoreFDLite.Name = "RestoreFDLite"
|
||||
Me.RestoreFDLite.Size = New System.Drawing.Size(192, 23)
|
||||
Me.RestoreFDLite.TabIndex = 10
|
||||
Me.RestoreFDLite.Text = "Restore FD Lite"
|
||||
'
|
||||
'GetMachineID
|
||||
'
|
||||
Me.GetMachineID.Location = New System.Drawing.Point(24, 432)
|
||||
Me.GetMachineID.Name = "GetMachineID"
|
||||
Me.GetMachineID.Size = New System.Drawing.Size(128, 23)
|
||||
Me.GetMachineID.TabIndex = 11
|
||||
Me.GetMachineID.Text = "Get Machine ID"
|
||||
'
|
||||
'ShowMachineID
|
||||
'
|
||||
Me.ShowMachineID.Location = New System.Drawing.Point(168, 432)
|
||||
Me.ShowMachineID.Name = "ShowMachineID"
|
||||
Me.ShowMachineID.Size = New System.Drawing.Size(136, 20)
|
||||
Me.ShowMachineID.TabIndex = 12
|
||||
Me.ShowMachineID.Text = ""
|
||||
'
|
||||
'DownloadTempSoftwareKey
|
||||
'
|
||||
Me.DownloadTempSoftwareKey.Location = New System.Drawing.Point(56, 488)
|
||||
Me.DownloadTempSoftwareKey.Name = "DownloadTempSoftwareKey"
|
||||
Me.DownloadTempSoftwareKey.Size = New System.Drawing.Size(192, 23)
|
||||
Me.DownloadTempSoftwareKey.TabIndex = 13
|
||||
Me.DownloadTempSoftwareKey.Text = "Download Temporary Software Key"
|
||||
'
|
||||
'label4
|
||||
'
|
||||
Me.label4.Location = New System.Drawing.Point(16, 541)
|
||||
Me.label4.Name = "label4"
|
||||
Me.label4.Size = New System.Drawing.Size(296, 16)
|
||||
Me.label4.TabIndex = 14
|
||||
Me.label4.Text = "Demo Software Key Product Code:"
|
||||
'
|
||||
'ProdCode
|
||||
'
|
||||
Me.ProdCode.Location = New System.Drawing.Point(16, 557)
|
||||
Me.ProdCode.Name = "ProdCode"
|
||||
Me.ProdCode.Size = New System.Drawing.Size(288, 20)
|
||||
Me.ProdCode.TabIndex = 15
|
||||
Me.ProdCode.Text = ""
|
||||
'
|
||||
'DownloadTempSoftwareKey
|
||||
'
|
||||
Me.DownloadDemoSoftwareKey.Location = New System.Drawing.Point(56, 590)
|
||||
Me.DownloadDemoSoftwareKey.Name = "DownloadDemoSoftwareKey"
|
||||
Me.DownloadDemoSoftwareKey.Size = New System.Drawing.Size(192, 23)
|
||||
Me.DownloadDemoSoftwareKey.TabIndex = 16
|
||||
Me.DownloadDemoSoftwareKey.Text = "Download Demo Software Key"
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.ClientSize = New System.Drawing.Size(320, 636)
|
||||
Me.Controls.Add(Me.DownloadDemoSoftwareKey)
|
||||
Me.Controls.Add(Me.ProdCode)
|
||||
Me.Controls.Add(Me.label4)
|
||||
Me.Controls.Add(Me.ShowMachineID)
|
||||
Me.Controls.Add(Me.DownloadTempSoftwareKey)
|
||||
Me.Controls.Add(Me.GetMachineID)
|
||||
Me.Controls.Add(Me.RestoreFDLite)
|
||||
Me.Controls.Add(Me.DoUpdateCodeFile)
|
||||
Me.Controls.Add(Me.UpdateCodeFile)
|
||||
Me.Controls.Add(Me.Label3)
|
||||
Me.Controls.Add(Me.DoUpdateCodeString)
|
||||
Me.Controls.Add(Me.UpdateCodeString)
|
||||
Me.Controls.Add(Me.Label2)
|
||||
Me.Controls.Add(Me.WriteDiags)
|
||||
Me.Controls.Add(Me.DiagFilename)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Controls.Add(Me.GetDongleInfo)
|
||||
Me.Name = "Form1"
|
||||
Me.Text = "ChangeTest"
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
' Get Dongle Information
|
||||
Private Sub GetDongleInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetDongleInfo.Click
|
||||
Dim sType, sModel, sProdCode, sDisplay As String
|
||||
Dim ret_code, i, num_found As Integer
|
||||
' our arrays
|
||||
Dim type(MAX_USB_DEVICES), model(MAX_USB_DEVICES), update_number(MAX_USB_DEVICES) As Integer
|
||||
Dim prodcode(MAX_USB_DEVICES * MAX_PRODCODE_LEN) As Byte
|
||||
Dim dongle_number(MAX_USB_DEVICES) As UInt32
|
||||
|
||||
' find dongle information for all dongle types, Plus & Net models, for all product codes
|
||||
' NB In practice you will probably want to set the prodcode_mask to the value of your product code
|
||||
ret_code = DCGetInfo(TYPE_MASK_ALL, MODEL_MASK_DEFAULT, Nothing, MAX_USB_DEVICES, num_found, type, model, prodcode, dongle_number, update_number)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code = 401 Then
|
||||
MsgBox("No dongles detected matching the search criteria specified", MsgBoxStyle.OkOnly, "Error")
|
||||
Exit Sub
|
||||
ElseIf ret_code <> 0 Then
|
||||
MsgBox("Error " + Str(ret_code) + " getting dongle information", MsgBoxStyle.OkOnly, "Error")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' display info from the dongles detected
|
||||
sDisplay = ""
|
||||
For i = 0 To num_found - 1
|
||||
' get type of dongle
|
||||
If type(i) = TYPE_PRO Then
|
||||
sType = "Pro"
|
||||
Else
|
||||
sType = "FD"
|
||||
End If
|
||||
' get model of dongle
|
||||
If model(i) = MODEL_LITE Then
|
||||
sModel = "Lite"
|
||||
ElseIf model(i) = MODEL_PLUS Then
|
||||
sModel = "Plus"
|
||||
Else
|
||||
sModel = "Net"
|
||||
End If
|
||||
' get product code
|
||||
sProdCode = GetProductCode(prodcode, i)
|
||||
sDisplay = sDisplay + Str(i + 1) + ". Dinkey " + sType + " " + sModel + " with dongle number: " + dongle_number(i).ToString + ", product code: " + sProdCode + ", update number: " + Str(update_number(i)) + vbNewLine
|
||||
Next
|
||||
MsgBox(sDisplay, MsgBoxStyle.OkOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
|
||||
' Write Dongle Diagnostics to file
|
||||
Private Sub WriteDiags_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WriteDiags.Click
|
||||
Dim ret_code As Integer
|
||||
|
||||
ret_code = DCGetDiagnosticInfo(DiagFilename.Text)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code = 754 Then
|
||||
MsgBox("Could not create the diagnostic file. Please check that the path exists: " + DiagFilename.Text, MsgBoxStyle.OkOnly, "Error")
|
||||
Exit Sub
|
||||
ElseIf ret_code <> 0 Then
|
||||
MsgBox("Error " + Str(ret_code) + " writing diagnostic information", MsgBoxStyle.OkOnly, "Error")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' display success
|
||||
MsgBox("Diagnostic file written successfully.", MsgBoxStyle.OkOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
|
||||
' Apply short update code entered manually
|
||||
Private Sub DoUpdateCodeString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoUpdateCodeString.Click
|
||||
Dim ret_code, confirmation_code, extended_error As Integer
|
||||
|
||||
ret_code = DCDoUpdateCodeString(UpdateCodeString.Text, confirmation_code, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' display success
|
||||
MsgBox("Dongle updated successfully!" + vbNewLine + "Confirmation code is : " + Hex(confirmation_code), MsgBoxStyle.OkOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
Private Sub DoUpdateCodeFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoUpdateCodeFile.Click
|
||||
Dim ret_code, confirmation_code, extended_error As Integer
|
||||
|
||||
ret_code = DCDoUpdateCodeFromFile(UpdateCodeFile.Text, confirmation_code, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' display success
|
||||
MsgBox("Dongle updated successfully!" + vbNewLine + "Confirmation code is : " + Hex(confirmation_code), MsgBoxStyle.OkOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
Private Sub RestoreFDLite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RestoreFDLite.Click
|
||||
Dim ret_code As Integer
|
||||
|
||||
ret_code = DCRestoreDinkeyFDLite()
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' display success
|
||||
MsgBox("Dinkey FD Lite updated successfully!", MsgBoxStyle.OKOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
Private Sub GetMachineID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetMachineID.Click
|
||||
Dim ret_code, extended_error As Integer
|
||||
Dim machineID As UInt32
|
||||
|
||||
ret_code = DCGetMachineID(machineID, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' success - display the machineID
|
||||
ShowMachineID.Text = String.Format("{0:X8}", machineID)
|
||||
End Sub
|
||||
|
||||
Private Sub DownloadTempSoftwareKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadTempSoftwareKey.Click
|
||||
Dim ret_code, extended_error As Integer
|
||||
Dim machineID As UInt32
|
||||
|
||||
' first get the machine ID
|
||||
ret_code = DCGetMachineID(machineID, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' ...then try to download the temporary software key
|
||||
ret_code = DCDownloadTempSoftwareKey(machineID, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
MsgBox("The Temporary Software Key has been downloaded successfully!", MsgBoxStyle.OKOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
Private Sub DownloadDemoSoftwareKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadDemoSoftwareKey.Click
|
||||
Dim ret_code, extended_error As Integer
|
||||
Dim machineID As UInt32
|
||||
|
||||
' first get the machine ID
|
||||
ret_code = DCGetMachineID(machineID, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' ...then try to download the demo software key
|
||||
' (NB we are assuming only one dongle model is set in the Demo Software Template.
|
||||
' If multiple models are set you will also need to specify the exact model)
|
||||
ret_code = DCDownloadDemoSoftwareKey(machineID, ProdCode.Text, SWKEY_MODEL_DEFAULT, extended_error)
|
||||
|
||||
' check error code and display error if an error occurs
|
||||
If ret_code <> 0 Then
|
||||
DisplayError(ret_code, extended_error)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
MsgBox("The Demo Software Key has been downloaded successfully!", MsgBoxStyle.OKOnly, "Dongle Information")
|
||||
End Sub
|
||||
|
||||
' look at the error code and try to display an appropriate message
|
||||
Private Sub DisplayError(ByVal ret_code As Integer, ByVal extended_error As Integer)
|
||||
Select Case ret_code
|
||||
Case 401
|
||||
MsgBox("Error! No dongles detected that meet the search criteria", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 409
|
||||
MsgBox("Error! The dongle detected has not been programmed by DinkeyAdd.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 758
|
||||
MsgBox("Error! Cannot open the Update Code file specified.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 759
|
||||
MsgBox("Error! The file specified is not a valid Update Code file.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 762, 763, 764
|
||||
MsgBox("Error! Update Code is not in a correct format / update code file is corrupt.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 765
|
||||
MsgBox("Error! The Update Code does not match any dongle attached to your machine.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 766
|
||||
MsgBox("Error! The update number for this Update Code is too high. You need to first enter an update code that was previously sent to you.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 767
|
||||
MsgBox("Error! You have already entered this Update Code.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1905
|
||||
MsgBox("Error! There is no Software Key available for download.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1907
|
||||
MsgBox("Error! The Temporary Software Key has expired. Cannot download it.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1910
|
||||
MsgBox("Error! The Software Key has already been downloaded.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1921
|
||||
MsgBox("Error! You specified the 'default model' but there is more than one model available. You need to specify a specific dongle model.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1922:
|
||||
MsgBox("Error! The model you requested is not available.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1923:
|
||||
MsgBox("Error! The Demo Software Key Template has been disabled.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case 1924:
|
||||
MsgBox("Error! You have run out of Demo Software Key activations. You need to order some more.", MsgBoxStyle.OkOnly, "Error")
|
||||
Case Else
|
||||
MsgBox("An error occurred checking the dongle. Error: " + Str(ret_code) + ". Extended Error: " + Str(extended_error) + ".", MsgBoxStyle.OkOnly, "Error")
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,61 @@
|
||||
ChangeTest - sample code to call DinkeyChange.dll (DinkeyChange64.dll) in VB.NET
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This project is written in Visual Studio 2003 but will work in more recent versions of
|
||||
Visual Studio (they will upgrade the Project to the latest version. If prompted you
|
||||
should also upgrade the .NET framework the project requires).
|
||||
|
||||
For users of Visual Studio 2005 or higher, the default setting to projects is to compile
|
||||
for the Target Platform "Any". This means that on 32-bit Windows, your code will run as
|
||||
32-bit code (and needs to call DinkeyChange.dll) and under 64-bit Windows your code will
|
||||
run as 64-bit code (and needs to call DinkeyChange64.dll). The sample code works this out
|
||||
automatically. If you select the target platform as "x86" then it will always be 32-bit
|
||||
and so you only need to use DinkeyChange.dll. If you select "x64" then your code will be
|
||||
64-bit and you only need to use DinkeyChange64.dll.
|
||||
|
||||
The main source files in the project are:
|
||||
|
||||
DinkeyChange.vb - the source file contains declarations of our API. We automatically
|
||||
work out whether your code is running in 32-bit or 64-bit and load the
|
||||
appropriate DinkeyChange module.
|
||||
|
||||
Form1.vb - this is the sample code giving an example on how you can call our API.
|
||||
It contains 7 functions. Just use which ever functions are most appropriate
|
||||
and customise in your own way.
|
||||
|
||||
The best approach is to compile the sample code and see how it works and then to take the
|
||||
appropriate code and apply it to your own project. You should include the DinkeyChange.vb
|
||||
file in your project and use/modify which ever functions from Form1.vb you feel are
|
||||
appropriate. The DinkeyChange.vb file should not be modified.
|
||||
|
||||
The sample code is just a guide. As none of the parameters are security sensitive then
|
||||
there is no need to implement strong security in calling DinkeyChange.
|
||||
|
||||
Make sure you remember to do the following when creating your own project:
|
||||
|
||||
1) Insert the DinkeyChange.vb file in your project.
|
||||
|
||||
2) You need to put DinkeyChange.dll and/or DinkeyChange64.dll into the folder that
|
||||
contains your EXE file. Otherwise the message "Unable to open DLL (DinkeyChange.dll)" or
|
||||
the System.DllNotFoundException error will appear when you run ChangeTest.
|
||||
|
||||
You can rename DinkeyChange.dll (DinkeyChange64.dll) to a name of your choice. In this
|
||||
case you will need to modify the dll name in the DinkeyChange.vb file.
|
||||
|
||||
Notes on Debugging 64-bit Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
When you use the 64-bit module (DinkeyChange64.dll) the anti-debug code is so strong that
|
||||
if you are debugging your code, after calling our API then it will crash with an SEH
|
||||
exception. If you want to be able to debug your code then you can setup your project so
|
||||
that your code calls the debug module (DinkeyChange64Debug.dll) in your "debug" build and
|
||||
the standard module (DinkeyChange64.dll) in your release build. In this case you will
|
||||
need to modify the declarations of our API in DinkeyChange.vb. This is an example for
|
||||
DCDoUpdateCodeFromFile64:
|
||||
|
||||
#if DEBUG ' debug module
|
||||
Declare Ansi Function DCDoUpdateCodeFromFile64 Lib "DinkeyChange64Debug.dll" Alias "DCDoUpdateCodeFromFile" _
|
||||
(ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
#else ' standard module
|
||||
Declare Ansi Function DCDoUpdateCodeFromFile64 Lib "DinkeyChange64.dll" Alias "DCDoUpdateCodeFromFile" _
|
||||
(ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("55F0697F-F4D4-48FB-8AF8-4F148DDBDA0B")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.*")>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>Form1</value>
|
||||
</data>
|
||||
</root>
|
||||
179
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyRemote/Form1.vb
Normal file
179
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyRemote/Form1.vb
Normal file
@@ -0,0 +1,179 @@
|
||||
' !! We strongly recommend that you read the "readme.txt" file in the sample code folder.
|
||||
' !! It contains important instructions on how to use the sample code
|
||||
|
||||
Imports System.Runtime.InteropServices ' so we can marshal our structures in drpf.vb
|
||||
|
||||
|
||||
Public Class Form1
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
Public Const AppName As String = "drpfTest"
|
||||
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
'Add any initialization after the InitializeComponent() call
|
||||
|
||||
End Sub
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
Friend WithEvents updatecodeMod As System.Windows.Forms.Button
|
||||
Friend WithEvents updatecode As System.Windows.Forms.Button
|
||||
Friend WithEvents drpfFile As System.Windows.Forms.TextBox
|
||||
Friend WithEvents label1 As System.Windows.Forms.Label
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.updatecodeMod = New System.Windows.Forms.Button
|
||||
Me.updatecode = New System.Windows.Forms.Button
|
||||
Me.drpfFile = New System.Windows.Forms.TextBox
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'updatecodeMod
|
||||
'
|
||||
Me.updatecodeMod.Location = New System.Drawing.Point(88, 128)
|
||||
Me.updatecodeMod.Name = "updatecodeMod"
|
||||
Me.updatecodeMod.Size = New System.Drawing.Size(264, 23)
|
||||
Me.updatecodeMod.TabIndex = 7
|
||||
Me.updatecodeMod.Text = "Generate Update Code with modifications "
|
||||
'
|
||||
'updatecode
|
||||
'
|
||||
Me.updatecode.Location = New System.Drawing.Point(88, 88)
|
||||
Me.updatecode.Name = "updatecode"
|
||||
Me.updatecode.Size = New System.Drawing.Size(264, 23)
|
||||
Me.updatecode.TabIndex = 6
|
||||
Me.updatecode.Text = "Generate Update Code"
|
||||
'
|
||||
'drpfFile
|
||||
'
|
||||
Me.drpfFile.Location = New System.Drawing.Point(8, 40)
|
||||
Me.drpfFile.Name = "drpfFile"
|
||||
Me.drpfFile.Size = New System.Drawing.Size(424, 20)
|
||||
Me.drpfFile.TabIndex = 5
|
||||
Me.drpfFile.Text = ""
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.Location = New System.Drawing.Point(8, 24)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(440, 16)
|
||||
Me.label1.TabIndex = 4
|
||||
Me.label1.Text = "Full path of drpf file:"
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.ClientSize = New System.Drawing.Size(456, 174)
|
||||
Me.Controls.Add(Me.updatecodeMod)
|
||||
Me.Controls.Add(Me.updatecode)
|
||||
Me.Controls.Add(Me.drpfFile)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Name = "Form1"
|
||||
Me.Text = "Form1"
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
' The sample code contains 2 functions. Use which ever functions are most appropriate and customise
|
||||
' in your own way. The sample code is just a guide.
|
||||
'
|
||||
' There are two methods to loading a DRPF file. These are shown in the these two functions
|
||||
' updatecode_Click and updatecodeMod_Click:
|
||||
'
|
||||
' updatecode_Click: we load the DRPF file from disk and get a handle and use it "as is" using the API
|
||||
' call LoadDRPFFromFile. You can make some limited changes to overwrite the default
|
||||
' behaviour by using API flags.
|
||||
'
|
||||
' updatecodeMod_Click: we load the DRPF file from disk and load into structures. We can then modify the
|
||||
' DRPF settings by modifying this structure. This method uses the API calls
|
||||
' ReadDRPFEx and LoadDRPF.
|
||||
|
||||
|
||||
Private Sub updatecode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updatecode.Click
|
||||
Dim drpfHandle As IntPtr
|
||||
Dim err_code As Integer
|
||||
Dim Outputs As New UPDATE_CODE_OUTPUTS
|
||||
|
||||
' load DRPF from File into memory
|
||||
drpfHandle = LoadDRPFFromFile(drpfFile.Text, err_code)
|
||||
If IntPtr.Zero.Equals(drpfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' generate update code as specified by the DRPF file
|
||||
err_code = GenerateUpdateCode(drpfHandle, Convert.ToUInt32(0), 0, Nothing, Nothing, Outputs)
|
||||
|
||||
' Unload DRPF from memory
|
||||
UnloadDRPF(drpfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
#If VBC_VER >= 14 Then
|
||||
#Disable Warning BC42108, BC42030 'This line is used in Visual Studio 2015 (and newer) to remove warnings in this function
|
||||
#End If
|
||||
Private Sub updatecodeMod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updatecodeMod.Click
|
||||
Dim drpfHandle As IntPtr
|
||||
Dim err_code, dummy1, dummy2 As Integer
|
||||
Dim MyRemoteInfo As REMOTEINFO
|
||||
Dim LicenceInfoArray() As LICENCEINFO
|
||||
Dim AlgChangesArray() As ALGCHANGE
|
||||
Dim DataChangesArray() As DATACHANGE
|
||||
Dim Outputs As New UPDATE_CODE_OUTPUTS
|
||||
|
||||
' in this case we need to read the DRPF into our structures, so that the DRPF values can be modified
|
||||
err_code = ReadDRPFEx(drpfFile.Text, MyRemoteInfo, LicenceInfoArray, AlgChangesArray, DataChangesArray, dummy1, dummy2)
|
||||
If err_code <> 0 Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' patch new values
|
||||
LicenceInfoArray(0).FeaturesFlag = 1 ' so that the features value below will be recognised
|
||||
LicenceInfoArray(0).Features = Convert.ToUInt32(12345)
|
||||
LicenceInfoArray(0).AddSetExecs = 1 ' so the executions will be added to existing
|
||||
LicenceInfoArray(0).Execs = 100
|
||||
|
||||
' get DRPF handle
|
||||
drpfHandle = LoadDRPF(MyRemoteInfo, LicenceInfoArray, AlgChangesArray, DataChangesArray, err_code)
|
||||
If IntPtr.Zero.Equals(drpfHandle) Then
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Exclamation, AppName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' generate update code as specified by the modified DRPF file
|
||||
err_code = GenerateUpdateCode(drpfHandle, Convert.ToUInt32(0), 0, Nothing, Nothing, Outputs)
|
||||
|
||||
' Unload DRPF from memory
|
||||
UnloadDRPF(drpfHandle)
|
||||
|
||||
' display message (error or success)
|
||||
MsgBox(GetLastMessage(), MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, AppName)
|
||||
End Sub
|
||||
#If VBC_VER >= 14 Then
|
||||
#Enable Warning BC42108, BC42030 'This line is used in Visual Studio 2015 (and higher) to restore warnings
|
||||
#End If
|
||||
End Class
|
||||
@@ -0,0 +1,50 @@
|
||||
drpfTest - sample code to call DinkeyRemote Modules in VB.NET
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This project is written in Visual Studio 2002 but will work in more recent
|
||||
versions of Visual Studio (they will upgrade the Project to the latest version.
|
||||
If prompted you should also upgrade the .NET framework the project requires).
|
||||
|
||||
For users of Visual Studio 2005 or higher, the default setting to projects is to
|
||||
compile for the Target Platform "Any". This means that on 32-bit Windows, your
|
||||
code will run as 32-bit code (and needs to call DinkeyRemote32.dll) and under 64-bit
|
||||
Windows your code will run as 64-bit code (and needs to call DinkeyRemote64.dll).
|
||||
The sample code works this out automatically. If you select the target platform as "x86"
|
||||
then it will always be 32-bit and so you only need to use DinkeyRemote32.dll. If you
|
||||
select "x64" then your code will be 64-bit and you only need to use DinkeyRemote64.dll.
|
||||
|
||||
The main source files in the project are:
|
||||
|
||||
drpf.vb - the source file contains declarations of our API. We automatically
|
||||
work out whether your code is running in 32-bit or 64-bit and load
|
||||
the appropriate DinkeyRemote module.
|
||||
|
||||
Form1.vb - this is the sample code giving an example on how you can call our API.
|
||||
It contains 2 functions. Just use the function most appropriate for you
|
||||
and customise in your own way.
|
||||
|
||||
The best approach is to compile the sample code and see how it works and then to take
|
||||
the appropriate code and apply it to your own project. You should include the drpf.vb
|
||||
file in your project and use/modify which ever functions from Form1.vb you feel are
|
||||
appropriate. The drpf.vb file should not be modified.
|
||||
|
||||
The sample code is just a guide. As none of the parameters are security sensitive then
|
||||
there is no need to implement strong security in calling DinkeyRemote.
|
||||
|
||||
Make sure you remember to do the following when creating your own project:
|
||||
|
||||
1) Insert the following namespaces in your code file:
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
2) Insert the drpf.cs file in your project.
|
||||
|
||||
3) You need to put DinkeyRemote32.dll and/or DinkeyRemote64.dll into the folder that
|
||||
contains drpfTest. Otherwise the message "Unable to open DLL (DinkeyRemote32.dll)" or
|
||||
the System.DllNotFoundException error will appear when you run drpfTest.
|
||||
|
||||
Notes on Debugging 64-bit Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
When you use the 64-bit module (DinkeyRemote64.dll) the anti-debug code is so strong
|
||||
that if you are debugging your code, after calling our API then it will crash with
|
||||
an SEH exception. There are no debug modules for DinkeyRemote so you will have to
|
||||
find other ways of debugging your code (for example taking out the call altogether).
|
||||
321
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyRemote/drpf.vb
Normal file
321
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/DinkeyRemote/drpf.vb
Normal file
@@ -0,0 +1,321 @@
|
||||
' !! this file should not be modified
|
||||
|
||||
' DRPF file is in the following format:
|
||||
' REMOTEINFO
|
||||
' LICENCEINFO (however many are needed)
|
||||
' ALGCHANGE (however many are needed)
|
||||
' DATACHANGE blocks (however many are needed) - may refer to external files.
|
||||
|
||||
' Remember: you only need to specify a value if you want to change it. Otherwise you
|
||||
' specify the default "no change" setting. For most entries this is indicated by 0.
|
||||
' However, for MaxNetUsers and LicenceNetUsers it is "-2" because 0 is a valid value to change to.
|
||||
|
||||
Imports System
|
||||
Imports System.Runtime.InteropServices ' so we can marshal our structures as a block of memory
|
||||
Imports System.Text ' for StringBuilder
|
||||
|
||||
' *********** define structures that make up the DRPF file *******************
|
||||
|
||||
Module drpf_code
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure REMOTEINFO
|
||||
Dim Header1 As Byte ' Should be set to "DRPF" = DinkeyRemote Parameter File
|
||||
Dim Header2 As Byte
|
||||
Dim Header3 As Byte
|
||||
Dim Header4 As Byte
|
||||
Dim Version As Integer ' version of this structure - currently 2
|
||||
<VBFixedString(12), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
|
||||
Dim ProdCode As String ' Product Code
|
||||
Dim DongleNumber As UInt32
|
||||
Dim UpdateNumber As Integer
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim Notes As String ' user-defined notes
|
||||
Dim NumLicences As Integer
|
||||
Dim NumAlgs As Integer ' number of algs to set (incl r/w alg)
|
||||
Dim NumDataChanges As Integer ' number of data change blocks specified
|
||||
Dim DataAreaSize As Integer ' -1 = increase as necessary. specifies the new size of the data area
|
||||
Dim PerLicence As Integer ' 0 = no change, 1 = per licence net users, 2 = per product net users
|
||||
Dim MaxNetUsers As Integer ' product net users, unlimited = -1, no change = -2
|
||||
Dim LastUsedDay As Integer ' Day = 0 (only) -> no change
|
||||
Dim LastUsedMonth As Integer
|
||||
Dim LastUsedYear As Integer
|
||||
<VBFixedString(12), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
|
||||
Dim DataEncKeyProdCode As String
|
||||
Dim ChangeCodeType As Integer ' 0 = no change, bit0 = only accept secure codes, bit1 = accept secure & short codes
|
||||
Dim CodeType As Integer ' type of code to generate. 0 = secure code, 1 = short code
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim OutputFileName As String ' name of file to output code to. Null (default) -> UpdateCode.ducf
|
||||
Dim LockDongle As Integer ' 1 = lock dongle to user's computer
|
||||
Dim ResetDongleLock As Integer ' 1 = reset the dongle lock so that the dongle can be locked to a new machine
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure LICENCEINFO
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim LicenceName As String ' licence name
|
||||
Dim Action As Integer ' 0 = change, 1 = delete, 2 = add
|
||||
Dim AddSetExecs As Integer ' 0 = no change to execs, 1 = add, 2 = set
|
||||
Dim Execs As Integer ' -1 = no limit
|
||||
Dim ExecsWarn As Integer ' 0 = remove warning, -1 = no change
|
||||
Dim ExpiryDay As Integer ' -1 = no limit, 0 = no change
|
||||
Dim ExpiryMonth As Integer
|
||||
Dim ExpiryYear As Integer
|
||||
Dim AddSetMaxDays As Integer ' 0 = no change, 1 = add, 2 = set
|
||||
Dim MaxDays As Integer ' -1 = no limit
|
||||
Dim DaysWarn As Integer ' 0 = remove warning, -1 = no change
|
||||
Dim FeaturesFlag As Integer ' 0 = don't change features, 1 = change features
|
||||
Dim Features As UInt32 ' all values OK
|
||||
Dim LicenceNetUsers As Integer ' unlimited = -1, no change = -2
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure ALGCHANGE
|
||||
Dim alg_number As Integer ' number of algorithm to set (0 = r/w algorithm)
|
||||
<VBFixedArray(12), MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> _
|
||||
Dim alg As Byte() ' coded form of algorithm
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DATACHANGE
|
||||
Dim type As Integer ' 1 = file, 2 = hex data, 3 = ascii, 4 = ascii null-term string
|
||||
Dim offset As Integer ' offset in dongle data memory to write data
|
||||
Dim length As Integer ' length of data to change
|
||||
<VBFixedArray(256), MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> _
|
||||
Dim data As Byte() ' data to write OR name of data file depending on which method set
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure UPDATE_CODE_OUTPUTS
|
||||
<VBFixedString(128*3), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128*3)> _
|
||||
Dim ShortCode As String ' the update code (for short update codes only)
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim UpdateCodeFile As String ' the output ducf that contains the update code
|
||||
<VBFixedString(8), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=8)> _
|
||||
Dim ConfirmationCode As String ' the confirmation code
|
||||
End Structure
|
||||
|
||||
' ********************** DinkeyRemote Module Imports ************************
|
||||
|
||||
' Loads DRPF from disk and returns handle
|
||||
Declare Ansi Function LoadDRPFFromFile32 Lib "DinkeyRemote32.dll" Alias "LoadDRPFFromFile" (ByVal drpf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
Declare Ansi Function LoadDRPFFromFile64 Lib "DinkeyRemote64.dll" Alias "LoadDRPFFromFile" (ByVal drpf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
|
||||
' Loads DRPF from disk into structures supplied (so we can modify DRPF in memory)
|
||||
Declare Ansi Function ReadDRPFEx32 Lib "DinkeyRemote32.dll" Alias "ReadDRPFEx" (ByVal drpf_file As String, ByRef MyRemoteInfo As REMOTEINFO, ByVal licence_bytes() As Byte, _
|
||||
ByVal algchange_bytes() As Byte, ByVal datachange_bytes() As Byte, ByRef drpf_version As Integer, ByRef drpf_format As Integer) As Integer
|
||||
Declare Ansi Function ReadDRPFEx64 Lib "DinkeyRemote64.dll" Alias "ReadDRPFEx" (ByVal drpf_file As String, ByRef MyRemoteInfo As REMOTEINFO, ByVal licence_bytes() As Byte, _
|
||||
ByVal algchange_bytes() As Byte, ByVal datachange_bytes() As Byte, ByRef drpf_version As Integer, ByRef drpf_format As Integer) As Integer
|
||||
|
||||
' Loads DRPF from structures and returns a handle
|
||||
Declare Ansi Function LoadDRPF32 Lib "DinkeyRemote32.dll" Alias "LoadDRPF" (ByRef MyRemoteInfo As REMOTEINFO, ByVal licence_bytes() As Byte, ByVal algchange_bytes() As Byte, _
|
||||
ByVal datachange_bytes() As Byte, ByRef ret_code As Integer) As IntPtr
|
||||
Declare Ansi Function LoadDRPF64 Lib "DinkeyRemote64.dll" Alias "LoadDRPF" (ByRef MyRemoteInfo As REMOTEINFO, ByVal licence_bytes() As Byte, ByVal algchange_bytes() As Byte, _
|
||||
ByVal datachange_bytes() As Byte, ByRef ret_code As Integer) As IntPtr
|
||||
|
||||
' saves the DRPF file to disk
|
||||
Declare Ansi Function WriteDRPFEx32 Lib "DinkeyRemote32.dll" Alias "WriteDRPFEx" (ByVal drpf_handle As IntPtr, ByVal drpf_file As String, ByVal drpf_format As Integer, _
|
||||
ByVal drpf_version As Integer, ByVal flags As Integer) As Integer
|
||||
Declare Ansi Function WriteDRPFEx64 Lib "DinkeyRemote64.dll" Alias "WriteDRPFEx" (ByVal drpf_handle As IntPtr, ByVal drpf_file As String, ByVal drpf_format As Integer, _
|
||||
ByVal drpf_version As Integer, ByVal flags As Integer) As Integer
|
||||
|
||||
' unloads the DRPF file
|
||||
Declare Ansi Sub UnloadDRPF32 Lib "DinkeyRemote32.dll" Alias "UnloadDRPF" (ByRef drpf_handle As IntPtr)
|
||||
Declare Ansi Sub UnloadDRPF64 Lib "DinkeyRemote64.dll" Alias "UnloadDRPF" (ByRef drpf_handle As IntPtr)
|
||||
|
||||
'main functions
|
||||
Declare Ansi Function GenerateUpdateCode32 Lib "DinkeyRemote32.dll" Alias "GenerateUpdateCode" (ByVal drpf_handle As IntPtr, ByVal dongle_number As UInt32, _
|
||||
ByVal update_number As Integer, ByVal ducf_file As String, ByVal logfile As String, ByRef Outputs As UPDATE_CODE_OUTPUTS) As Integer
|
||||
Declare Ansi Function GenerateUpdateCode64 Lib "DinkeyRemote64.dll" Alias "GenerateUpdateCode" (ByVal drpf_handle As IntPtr, ByVal dongle_number As UInt32, _
|
||||
ByVal update_number As Integer, ByVal ducf_file As String, ByVal logfile As String, ByRef Outputs As UPDATE_CODE_OUTPUTS) As Integer
|
||||
|
||||
' get the message output by DinkeyRemote
|
||||
Declare Ansi Sub GetLastMessage32 Lib "DinkeyRemote32.dll" Alias "GetLastMessage" (ByVal message As StringBuilder, ByVal buffer_size As Integer, ByRef message_length As Integer)
|
||||
Declare Ansi Sub GetLastMessage64 Lib "DinkeyRemote64.dll" Alias "GetLastMessage" (ByVal message As StringBuilder, ByVal buffer_size As Integer, ByRef message_length As Integer)
|
||||
|
||||
' get the extended error (set if an error occurs)
|
||||
Declare Ansi Function GetLastExtendedError32 Lib "DinkeyRemote32.dll" Alias "GetLastExtendedError" () As Integer
|
||||
Declare Ansi Function GetLastExtendedError64 Lib "DinkeyRemote64.dll" Alias "GetLastExtendedError" () As Integer
|
||||
|
||||
' ********************** Constants ************************
|
||||
Public Const DRPF_VERSION As Integer = 2 ' current DRPF version
|
||||
|
||||
' WriteDRPFEx API flags
|
||||
Public Const FLAGS_LOSE_FEATURES As Integer = 1 ' means that you can save the DRPF file to an earlier version even if it means losing some new features that have been currently set
|
||||
|
||||
' constants for drpf_format in ReadDRPFEx and WriteDRPFEx functions
|
||||
Public Const DRPF_FORMAT_BINARY As Integer = 1
|
||||
Public Const DRPF_FORMAT_JSON As Integer = 2
|
||||
Public Const DRPF_FORMAT_JSON_MIN As Integer = 3 ' this value is only used with WriteDRPEx. ReadDRPFEx cannot return this value.
|
||||
|
||||
' private constants
|
||||
Private const MAX_LICENCES As Integer = 255 ' max number of licence changes in a DRPF file (theoretically unlimited but easier if we limit it)
|
||||
Private Const MAX_ALG_CHANGES As Integer = 21 ' max number of alg changes in DRPF file
|
||||
Private Const MAX_DATA_CHANGES As Integer = 127 ' max number of data area changes in DRPF file
|
||||
|
||||
' ********************** API Functions ************************
|
||||
' We only want to load the correct DLL for the bit-ness of the computer. The other DLL may not exist.
|
||||
' if the appropriate DLL does not exist in the same directory as this test program you will receive a DllNotFoundException
|
||||
|
||||
' call the correct dll depending on whether we are running 32-bit or 64-bit code
|
||||
Function LoadDRPFFromFile(ByVal drpf_file As String, ByRef err_code As Integer) As IntPtr
|
||||
If (IntPtr.Size = 4) Then
|
||||
LoadDRPFFromFile = LoadDRPFFromFile32(drpf_file, err_code)
|
||||
Else
|
||||
LoadDRPFFromFile = LoadDRPFFromFile64(drpf_file, err_code)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' we have to do some marshalling of arrays of bytes into arrays of structures
|
||||
Function ReadDRPFEx(ByVal drpf_file As String, ByRef MyRemoteInfo As REMOTEINFO, ByRef LicenceInfoArray() As LICENCEINFO, ByRef AlgChangesArray() As ALGCHANGE, _
|
||||
ByRef DataChangesArray() As DATACHANGE, ByRef drpf_version As Integer, ByRef drpf_format As Integer) As Integer
|
||||
Dim i As Integer
|
||||
Dim MyLicenceInfo As New LICENCEINFO
|
||||
Dim licence_bytes(MAX_LICENCES * Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim licence_bytes_one_struct(Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim MyAlgChanges As New ALGCHANGE
|
||||
Dim algchange_bytes(MAX_ALG_CHANGES * Marshal.SizeOf(MyAlgChanges)) As Byte
|
||||
Dim algchange_bytes_one_struct(Marshal.SizeOf(MyAlgChanges)) As Byte
|
||||
Dim MyDataChanges As New DATACHANGE
|
||||
Dim datachange_bytes(MAX_DATA_CHANGES * Marshal.SizeOf(MyDataChanges)) As Byte
|
||||
Dim datachange_bytes_one_struct(Marshal.SizeOf(MyDataChanges)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
MyRemoteInfo = New REMOTEINFO
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
ReadDRPFEx = ReadDRPFEx32(drpf_file, MyRemoteInfo, licence_bytes, algchange_bytes, datachange_bytes, drpf_version, drpf_format)
|
||||
Else
|
||||
ReadDRPFEx = ReadDRPFEx64(drpf_file, MyRemoteInfo, licence_bytes, algchange_bytes, datachange_bytes, drpf_version, drpf_format)
|
||||
End If
|
||||
|
||||
If ReadDRPFEx <> 0 Then
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' convert byte array to an array of structs
|
||||
ReDim LicenceInfoArray(MyRemoteInfo.NumLicences)
|
||||
For i = 0 To MyRemoteInfo.NumLicences - 1
|
||||
LicenceInfoArray(i) = New LICENCEINFO
|
||||
Array.Copy(licence_bytes, i * Marshal.SizeOf(MyLicenceInfo.GetType), licence_bytes_one_struct, 0, Marshal.SizeOf(MyLicenceInfo.GetType))
|
||||
MyGC = GCHandle.Alloc(licence_bytes_one_struct, GCHandleType.Pinned)
|
||||
LicenceInfoArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyLicenceInfo.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
ReDim AlgChangesArray(MyRemoteInfo.NumAlgs)
|
||||
For i = 0 To MyRemoteInfo.NumAlgs - 1
|
||||
AlgChangesArray(i) = New ALGCHANGE
|
||||
Array.Copy(algchange_bytes, i * Marshal.SizeOf(MyAlgChanges.GetType), algchange_bytes_one_struct, 0, Marshal.SizeOf(MyAlgChanges.GetType))
|
||||
MyGC = GCHandle.Alloc(algchange_bytes_one_struct, GCHandleType.Pinned)
|
||||
AlgChangesArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyAlgChanges.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
ReDim DataChangesArray(MyRemoteInfo.NumDataChanges)
|
||||
For i = 0 To MyRemoteInfo.NumDataChanges - 1
|
||||
DataChangesArray(i) = New DATACHANGE
|
||||
Array.Copy(datachange_bytes, i * Marshal.SizeOf(MyDataChanges.GetType), datachange_bytes_one_struct, 0, Marshal.SizeOf(MyDataChanges.GetType))
|
||||
MyGC = GCHandle.Alloc(datachange_bytes_one_struct, GCHandleType.Pinned)
|
||||
DataChangesArray(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyDataChanges.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
Function LoadDRPF(ByRef MyRemoteInfo As REMOTEINFO, ByRef LicenceInfoArray() As LICENCEINFO, ByRef AlgChangesArray() As ALGCHANGE, ByRef DataChangesArray() As DATACHANGE, _
|
||||
ByRef ret_code As Integer) As IntPtr
|
||||
Dim i As Integer
|
||||
Dim MyLicenceInfo As New LICENCEINFO
|
||||
Dim licence_bytes(MAX_LICENCES * Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim licence_bytes_one_struct(Marshal.SizeOf(MyLicenceInfo)) As Byte
|
||||
Dim MyAlgChanges As New ALGCHANGE
|
||||
Dim algchange_bytes(MAX_ALG_CHANGES * Marshal.SizeOf(MyAlgChanges)) As Byte
|
||||
Dim algchange_bytes_one_struct(Marshal.SizeOf(MyAlgChanges)) As Byte
|
||||
Dim MyDataChanges As New DATACHANGE
|
||||
Dim datachange_bytes(MAX_DATA_CHANGES * Marshal.SizeOf(MyDataChanges)) As Byte
|
||||
Dim datachange_bytes_one_struct(Marshal.SizeOf(MyDataChanges)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
|
||||
' convert array of structs to byte arrays
|
||||
For i = 0 To MyRemoteInfo.NumLicences - 1
|
||||
MyGC = GCHandle.Alloc(licence_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(LicenceInfoArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(licence_bytes_one_struct, 0, licence_bytes, i * Marshal.SizeOf(MyLicenceInfo.GetType), Marshal.SizeOf(MyLicenceInfo.GetType))
|
||||
Next
|
||||
|
||||
For i = 0 To MyRemoteInfo.NumAlgs - 1
|
||||
MyGC = GCHandle.Alloc(algchange_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(AlgChangesArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(algchange_bytes_one_struct, 0, algchange_bytes, i * Marshal.SizeOf(MyAlgChanges.GetType), Marshal.SizeOf(MyAlgChanges.GetType))
|
||||
Next
|
||||
|
||||
For i = 0 To MyRemoteInfo.NumDataChanges - 1
|
||||
MyGC = GCHandle.Alloc(datachange_bytes_one_struct, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(DataChangesArray(i), MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
Array.Copy(datachange_bytes_one_struct, 0, datachange_bytes, i * Marshal.SizeOf(MyDataChanges.GetType), Marshal.SizeOf(MyDataChanges.GetType))
|
||||
Next
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
LoadDRPF = LoadDRPF32(MyRemoteInfo, licence_bytes, algchange_bytes, datachange_bytes, ret_code)
|
||||
Else
|
||||
LoadDRPF = LoadDRPF64(MyRemoteInfo, licence_bytes, algchange_bytes, datachange_bytes, ret_code)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Function WriteDRPFEx(ByVal drpf_handle As IntPtr, ByVal drpf_file As String, ByVal drpf_format As Integer, ByVal drpf_version As Integer, ByVal flags As Integer) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
WriteDRPFEx = WriteDRPFEx32(drpf_handle, drpf_file, drpf_format, drpf_version, flags)
|
||||
Else
|
||||
WriteDRPFEx = WriteDRPFEx64(drpf_handle, drpf_file, drpf_format, drpf_version, flags)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Sub UnloadDRPF(ByRef drpf_handle As IntPtr)
|
||||
If (IntPtr.Size = 4) Then
|
||||
UnloadDRPF32(drpf_handle)
|
||||
Else
|
||||
UnloadDRPF64(drpf_handle)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Function GenerateUpdateCode(ByVal drpf_handle As IntPtr, ByVal dongle_number As UInt32, ByVal update_number As Integer, ByVal ducf_file As String, _
|
||||
ByVal logfile As String, ByRef Outputs As UPDATE_CODE_OUTPUTS) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
GenerateUpdateCode = GenerateUpdateCode32(drpf_handle, dongle_number, update_number, ducf_file, logfile, Outputs)
|
||||
Else
|
||||
GenerateUpdateCode = GenerateUpdateCode64(drpf_handle, dongle_number, update_number, ducf_file, logfile, Outputs)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' do a bit of work here to make the function easier to use for VB.NET
|
||||
Function GetLastMessage() As String
|
||||
Dim length, dummy As Integer
|
||||
Dim message As StringBuilder
|
||||
|
||||
If (IntPtr.Size = 4) Then
|
||||
GetLastMessage32(Nothing, 0, length)
|
||||
message = New StringBuilder(length)
|
||||
GetLastMessage32(message, length, dummy)
|
||||
Else
|
||||
GetLastMessage64(Nothing, 0, length)
|
||||
message = New StringBuilder(length)
|
||||
GetLastMessage64(message, length, dummy)
|
||||
End If
|
||||
|
||||
Return message.ToString()
|
||||
End Function
|
||||
|
||||
Function GetLastExtendedError() As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
GetLastExtendedError = GetLastExtendedError32()
|
||||
Else
|
||||
GetLastExtendedError = GetLastExtendedError64()
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
End Module
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "drpfTest", "drpfTest.vbproj", "{35F04638-E647-4D07-A165-876D21B435B1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{35F04638-E647-4D07-A165-876D21B435B1}.Debug.ActiveCfg = Debug|.NET
|
||||
{35F04638-E647-4D07-A165-876D21B435B1}.Debug.Build.0 = Debug|.NET
|
||||
{35F04638-E647-4D07-A165-876D21B435B1}.Release.ActiveCfg = Release|.NET
|
||||
{35F04638-E647-4D07-A165-876D21B435B1}.Release.Build.0 = Release|.NET
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,121 @@
|
||||
<VisualStudioProject>
|
||||
<VisualBasic
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.0.9466"
|
||||
SchemaVersion = "1.0"
|
||||
ProjectGuid = "{35F04638-E647-4D07-A165-876D21B435B1}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "drpfTest"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
AssemblyOriginatorKeyMode = "None"
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "WinExe"
|
||||
OptionCompare = "Binary"
|
||||
OptionExplicit = "On"
|
||||
OptionStrict = "Off"
|
||||
RootNamespace = "drpfTest"
|
||||
StartupObject = "drpfTest.Form1"
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "true"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "true"
|
||||
IncrementalBuild = "true"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "false"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "false"
|
||||
IncrementalBuild = "false"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
</References>
|
||||
<Imports>
|
||||
<Import Namespace = "Microsoft.VisualBasic" />
|
||||
<Import Namespace = "System" />
|
||||
<Import Namespace = "System.Collections" />
|
||||
<Import Namespace = "System.Data" />
|
||||
<Import Namespace = "System.Drawing" />
|
||||
<Import Namespace = "System.Diagnostics" />
|
||||
<Import Namespace = "System.Windows.Forms" />
|
||||
</Imports>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "drpf.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.vb"
|
||||
SubType = "Form"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.resx"
|
||||
DependentUpon = "Form1.vb"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "readme.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</VisualBasic>
|
||||
</VisualStudioProject>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("0D48F329-866C-4C45-AC60-38C686817356")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.*")>
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DllTest", "DllTest.vbproj", "{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}.Debug.ActiveCfg = Debug|.NET
|
||||
{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}.Debug.Build.0 = Debug|.NET
|
||||
{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}.Release.ActiveCfg = Release|.NET
|
||||
{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}.Release.Build.0 = Release|.NET
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,121 @@
|
||||
<VisualStudioProject>
|
||||
<VisualBasic
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.0.9466"
|
||||
SchemaVersion = "1.0"
|
||||
ProjectGuid = "{7C92E3C8-2E6D-4347-B8B3-579231D8E24D}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "DllTest"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
AssemblyOriginatorKeyMode = "None"
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "WinExe"
|
||||
OptionCompare = "Binary"
|
||||
OptionExplicit = "On"
|
||||
OptionStrict = "Off"
|
||||
RootNamespace = "DllTest"
|
||||
StartupObject = "DllTest.Form1"
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "true"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "true"
|
||||
IncrementalBuild = "true"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
BaseAddress = "285212672"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = ""
|
||||
DefineDebug = "false"
|
||||
DefineTrace = "true"
|
||||
DebugSymbols = "false"
|
||||
IncrementalBuild = "false"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "1"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
</References>
|
||||
<Imports>
|
||||
<Import Namespace = "Microsoft.VisualBasic" />
|
||||
<Import Namespace = "System" />
|
||||
<Import Namespace = "System.Collections" />
|
||||
<Import Namespace = "System.Data" />
|
||||
<Import Namespace = "System.Drawing" />
|
||||
<Import Namespace = "System.Diagnostics" />
|
||||
<Import Namespace = "System.Windows.Forms" />
|
||||
</Imports>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "dris.vb"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.vb"
|
||||
SubType = "Form"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Form1.resx"
|
||||
DependentUpon = "Form1.vb"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "readme.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</VisualBasic>
|
||||
</VisualStudioProject>
|
||||
|
||||
105
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/Form1.resx
Normal file
105
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/Form1.resx
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Assembly</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>Form1</value>
|
||||
</data>
|
||||
</root>
|
||||
988
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/Form1.vb
Normal file
988
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/Form1.vb
Normal file
@@ -0,0 +1,988 @@
|
||||
' !! We strongly recommend that you read the "readme.txt" file in the sample code folder.
|
||||
' !! It contains important instructions on how to use the sample code
|
||||
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
Public Class Form1
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
#Region " Windows Form Designer generated code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
'This call is required by the Windows Form Designer.
|
||||
InitializeComponent()
|
||||
|
||||
'Add any initialization after the InitializeComponent() call
|
||||
|
||||
End Sub
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
Friend WithEvents Label1 As System.Windows.Forms.Label
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.Label1 = New System.Windows.Forms.Label()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'Label1
|
||||
'
|
||||
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.Label1.Location = New System.Drawing.Point(72, 80)
|
||||
Me.Label1.Name = "Label1"
|
||||
Me.Label1.Size = New System.Drawing.Size(168, 40)
|
||||
Me.Label1.TabIndex = 0
|
||||
Me.Label1.Text = "It Worked!"
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.ClientSize = New System.Drawing.Size(304, 213)
|
||||
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1})
|
||||
Me.Name = "Form1"
|
||||
Me.Text = "Form1"
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
' The sample code contains 11 functions. You will not need to use all these
|
||||
' functions in your code. Just use which ever functions are most appropriate
|
||||
' and customise in your own way. The sample code is just a guide. You should
|
||||
' implement the protection in a stronger way using the techniques described in
|
||||
' the "Increasing your Protection" chapter of the manual.
|
||||
'
|
||||
' The 11 functions are:
|
||||
' ProtCheck a standard protection check
|
||||
' ProtCheckWithAlg a protection check & executing an Algorithm
|
||||
' WriteBytes a protection check & write data to the dongle
|
||||
' ReadBytes a protection check & read data from the dongle
|
||||
' EncryptUserData a protection check,& encrypting data and then decrypting the data
|
||||
'
|
||||
' these functions are the same as the functions listed above but encrypting all parameters passed to our API
|
||||
' ProtCheckEnc a standard protection check
|
||||
' ProtCheckWithAlgEnc a protection check & executing an Algorithm
|
||||
' WriteBytesEnc a protection check & write data to the dongle
|
||||
' ReadBytesEnc a protection check & read data from the dongle
|
||||
' EncryptUserDataEnc a protection check & encrypting data and then decrypting the data
|
||||
|
||||
' this function displays the current network users
|
||||
' DisplayNetUsers
|
||||
|
||||
' !!!!
|
||||
Public Const MY_SDSN As Integer = 10101 ' !!!! change this value to be the value of your SDSN (demo = 10101)
|
||||
Public Const MY_PRODCODE As String = "DEMO" ' !!!! change this value to match the Product Code in the dongle
|
||||
|
||||
' If you are using Dinkey Lite then you can only use 4 functions:
|
||||
' ProtCheck, ProtCheckWithAlg, ProtCheckEnc, ProtCheckWithAlgEnc
|
||||
|
||||
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
|
||||
|
||||
' call the function(s) of your choice here
|
||||
' here I have chosen a standard protection check
|
||||
If ProtCheck() <> 0 Then
|
||||
End 'terminate
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
' ************************* our 10 functions **********************************
|
||||
|
||||
' ************************** ProtCheck ***************************************
|
||||
Function ProtCheck() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = PROTECTION_CHECK ' standard protection check
|
||||
dris.flags = 0 ' no extra flags, but you may want to specify some if you want to start a network user or decrement execs,...
|
||||
|
||||
ret_code = DDProtCheck(dris, Nothing)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ProtCheck = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheck = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
If (GetProductCode(dris) <> MY_PRODCODE) Then
|
||||
MsgBox("Incorrect Product Code! Please modify your source code so that MY_PRODCODE is set to be the Product Code in the dongle.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheck = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheck = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
|
||||
' NB if you are using a network dongle and you want to list the network users then use this function:
|
||||
' DisplayNetUsers(dris.net_users, dris.model)
|
||||
|
||||
ProtCheck = 0
|
||||
Exit Function
|
||||
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ProtCheck = -1
|
||||
End Function
|
||||
|
||||
|
||||
' ************************** ProtCheckWithAlg ******************************
|
||||
|
||||
' !!!! You should replace this function with the one generated by the
|
||||
' "generate source code" button in Algorithm tab for DinkeyAdd (if you have specified an algorithm)
|
||||
' or from DinkeyLook if you are using Dinkey Lite dongles.
|
||||
' see readme.txt notes concerning using the algorithm in vb.net
|
||||
Private Function MyAlgorithm(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Integer, ByVal h As Integer) As Integer
|
||||
MyAlgorithm = a + b + c + d + e + f + g + h
|
||||
End Function
|
||||
|
||||
' NB for this to work you must program at least "user algorithm" into the dongle
|
||||
' NB We have used a very simple algorithm here (in the MyAlgorithm function). You must patch this with the
|
||||
' sample code generated by DinkeyAdd for the algorithm that you are using.
|
||||
Function ProtCheckWithAlg() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = EXECUTE_ALGORITHM ' standard protection check & execute algorithm
|
||||
dris.flags = 0 ' no extra flags, but you may want to specify some if you want to start a network user or decrement execs,...
|
||||
dris.alg_number = 1 ' execute first algorithm (you do not need to specify this field for Dinkey Lite dongles)
|
||||
' you should remove these entries if you are using Dinkey Lite so that algorithm arguments are random
|
||||
dris.var_a = 1 ' sample values
|
||||
dris.var_b = 2
|
||||
dris.var_c = 3
|
||||
dris.var_d = 4
|
||||
dris.var_e = 5
|
||||
dris.var_f = 6
|
||||
dris.var_g = 7
|
||||
dris.var_h = 8
|
||||
|
||||
ret_code = DDProtCheck(dris, Nothing)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ProtCheckWithAlg = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlg = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlg = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' if you want you can check the algorithm answer - however if algorithm is from your code then best to just use the answer in your code
|
||||
' NB read the note in the "readme.txt" about possible overflow errors in VB.NET
|
||||
' !!!! Make sure you have replaced the MyAlgorithm routine with the algorithm you have specified in DinkeyAdd
|
||||
If (MyAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h) <> dris.alg_answer) Then
|
||||
MsgBox("Dinkey protection error!\nYou have not patched your algorithm in the MyAlgorithm routine", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlg = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
ProtCheckWithAlg = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ProtCheckWithAlg = -1
|
||||
End Function
|
||||
|
||||
' ************************** WriteBytes ******************************
|
||||
' This writes the data array 0,1,2,3,4,5,6,7,8,9 to the dongle data area at offset 7
|
||||
' In order for this function to work you will need to have a data area in your dongle that is at least 18 bytes long.
|
||||
' if you want to write a string then you need to convert it to a byte array first:
|
||||
' encoding.GetBytes(your_string, 0, your_string.Length, data, 0) where encoding is declared: Dim encoding As New ASCIIEncoding() You also need to include System.Text
|
||||
Function WriteBytes() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = WRITE_DATA_AREA ' standard protection check & write data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_offset = 7
|
||||
dris.rw_length = data.Length
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
WriteBytes = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
WriteBytes = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
WriteBytes = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
WriteBytes = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
WriteBytes = -1
|
||||
End Function
|
||||
|
||||
' ************************ ReadBytes ************************************
|
||||
' This reads 10 bytes of data from offset 7 in the dongle data area
|
||||
' In order for this function to work you will need to have a data area in your dongle that is at least 18 bytes long.
|
||||
' if you want to read a string then you need to convert it from a byte array (via an array of char). You also need to include System.Text
|
||||
' CharArray = encoding.GetChars(data); where CharArray is of type char[] and encoding is of type ASCIIEncoding
|
||||
' your_string = new String(CharArray, 0, your_string_length);
|
||||
Function ReadBytes() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
Dim data(10) As Byte
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = READ_DATA_AREA ' standard protection check & read data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_offset = 7
|
||||
dris.rw_length = data.Length
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ReadBytes = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ReadBytes = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ReadBytes = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
MsgBox("Dinkey Dongle Data Area, offset 7 is : " + Str(data(0)) + "," + Str(data(1)) + "," + Str(data(2)) + "," + Str(data(3)) + "," + _
|
||||
Str(data(4)) + "," + Str(data(5)) + "," + Str(data(6)) + "," + Str(data(7)) + "," + Str(data(8)) + "," + Str(data(9)), MsgBoxStyle.OkOnly)
|
||||
ReadBytes = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ReadBytes = -1
|
||||
End Function
|
||||
|
||||
' ************************** EncryptUserData ************************************
|
||||
' This function will do a protection check and ask the dongle to encrypt some data using encryption key 1
|
||||
' It will then do another protection check & decrypt the data
|
||||
' to encrypt or decrypt strings please read notes for WriteBytes and ReadBytes functions
|
||||
Function EncryptUserData() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = ENCRYPT_USER_DATA ' standard protection check & encrypt data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_length = data.Length
|
||||
dris.data_crypt_key_num = 1
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
EncryptUserData = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' ... could add code to check other elements of the DRIS, e.g. ret_code, sdsn, ...
|
||||
|
||||
' Now decrypt the same data to get the original values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = DECRYPT_USER_DATA ' standard protection check & decrypt data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_length = data.Length
|
||||
dris.data_crypt_key_num = 1
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
EncryptUserData = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
EncryptUserData = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
EncryptUserData = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
MsgBox("Decrypted data is : " + Str(data(0)) + "," + Str(data(1)) + "," + Str(data(2)) + "," + Str(data(3)) + "," + _
|
||||
Str(data(4)) + "," + Str(data(5)) + "," + Str(data(6)) + "," + Str(data(7)) + "," + Str(data(8)) + "," + Str(data(9)), MsgBoxStyle.OkOnly)
|
||||
EncryptUserData = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
EncryptUserData = -1
|
||||
End Function
|
||||
|
||||
' !!!!!!!!!!! all the functions listed below encrypt all parameters to our API !!!!!!!!!!!!!!!!!!!!!
|
||||
' In order for them to work properly you need to choose "Encrypt DRIS" and "Encrypt Data passed to API"
|
||||
' in the Extra Security tab of DinkeyAdd. In this example, for Data Encryption I use the r/w algorithm
|
||||
' but the code can be modified easily to use the 3 encryption parameters.
|
||||
|
||||
' !!!! please overwrite this function with the one generated by DinkeyAdd for R/W Algorithm
|
||||
Private Function MyRWAlgorithm(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Integer, ByVal h As Integer) As Integer
|
||||
MyRWAlgorithm = a Xor b Xor c Xor d Xor e Xor f
|
||||
MyRWAlgorithm = MyRWAlgorithm And &HFFFFFF ' we only use bottom 3 bytes. -ve numbers can cause problems for CryptApiData
|
||||
End Function
|
||||
|
||||
' !!!! please overwrite this function with the one generated by DinkeyAdd
|
||||
Private Sub CryptDRIS(ByRef dris As DRIS)
|
||||
Dim i, j, k, t As Integer
|
||||
Dim bigseed(255) As Byte
|
||||
Dim S(255) As Byte
|
||||
Dim temp As Byte
|
||||
Dim temp_dris(Marshal.SizeOf(dris) - 1) As Byte
|
||||
|
||||
DrisToByteArray(dris, temp_dris) ' convert DRIS to byte array so we can encrypt it
|
||||
|
||||
For i = 0 To 255 Step 8
|
||||
Call Set4Bytes(bigseed, i, dris.seed1)
|
||||
Call Set4Bytes(bigseed, i + 4, dris.seed2)
|
||||
Next
|
||||
For i = 0 To 255
|
||||
S(i) = i
|
||||
Next
|
||||
j = 0
|
||||
For i = 0 To 255
|
||||
j = (j + CInt(S(i)) + CInt(bigseed(i)) + 123) Mod 256
|
||||
temp = S(i)
|
||||
S(i) = S(j)
|
||||
S(j) = temp
|
||||
Next
|
||||
i = 0
|
||||
j = 0
|
||||
For k = 16 To Marshal.SizeOf(dris) - 1
|
||||
i = (i + 1) Mod 256
|
||||
j = (j + CInt(S(i)) + 212) Mod 256
|
||||
temp = S(i)
|
||||
S(i) = S(j)
|
||||
S(j) = temp
|
||||
t = (CInt(S(i)) + CInt(S(j)) + 97) Mod 256
|
||||
temp_dris(k) = temp_dris(k) Xor S(t)
|
||||
Next
|
||||
|
||||
ByteArrayToDris(temp_dris, dris) ' convert it back again
|
||||
End Sub
|
||||
|
||||
|
||||
' !!!! please overwrite this function with the one generated by DinkeyAdd
|
||||
Private Sub CryptApiData(ByVal dris As DRIS, ByVal data() As Byte, ByVal length As Integer, ByVal alg_answer As Integer)
|
||||
Dim i, j, k, t As Integer
|
||||
Dim bigseed(255) As Byte
|
||||
Dim S(255) As Byte
|
||||
Dim temp As Byte
|
||||
|
||||
For i = 0 To 255 Step 8
|
||||
Call Set4Bytes(bigseed, i, dris.seed1)
|
||||
Call Set4Bytes(bigseed, i + 4, dris.seed2)
|
||||
Next
|
||||
For i = 0 To 255
|
||||
S(i) = i
|
||||
Next
|
||||
j = 0
|
||||
For i = 0 To 255
|
||||
j = (j + CInt(S(i)) + CInt(bigseed(i)) + (alg_answer And &HFF)) Mod 256
|
||||
temp = S(i)
|
||||
S(i) = S(j)
|
||||
S(j) = temp
|
||||
Next
|
||||
i = 0
|
||||
j = 0
|
||||
For k = 0 To length - 1
|
||||
i = (i + 1) Mod 256
|
||||
j = (j + CInt(S(i)) + ((alg_answer \ &H100) And &HFF)) Mod 256
|
||||
temp = S(i)
|
||||
S(i) = S(j)
|
||||
S(j) = temp
|
||||
t = (CInt(S(i)) + CInt(S(j)) + ((alg_answer \ &H10000) And &HFF)) Mod 256
|
||||
data(k) = data(k) Xor S(t)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
' ************************** ProtCheckEnc ************************************
|
||||
' We encrypt the DRIS passed to the API. Patch the CryptDRIS function in this file from source code generated by DinkeyAdd.
|
||||
Function ProtCheckEnc() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = PROTECTION_CHECK ' standard protection check
|
||||
dris.flags = 0 ' no extra flags, but you may want to specify some if you want to start a network user or decrement execs,...
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, Nothing)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ProtCheckEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
If (GetProductCode(dris) <> MY_PRODCODE) Then
|
||||
MsgBox("Incorrect Product Code! Please modify your source code so that MY_PRODCODE is set to be the Product Code in the dongle.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
ProtCheckEnc = 0
|
||||
Exit Function
|
||||
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ProtCheckEnc = -1
|
||||
End Function
|
||||
|
||||
|
||||
' ************************** ProtCheckWithAlgEnc ****************************
|
||||
' NB for this to work you must program at least "user algorithm" into the dongle
|
||||
' NB We have used a very simple algorithm here (in the MyAlgorithm function). You must patch this with the
|
||||
' sample code generated by DinkeyAdd for the algorithm that you are using. For Dinkey Lite get source from DinkeyLook.
|
||||
' We encrypt the DRIS passed to the API. Patch the CryptDRIS function in this file from source code generated by DinkeyAdd.
|
||||
Function ProtCheckWithAlgEnc() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code As Integer
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris)
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = EXECUTE_ALGORITHM ' standard protection check & execute algorithm
|
||||
dris.flags = 0 ' no extra flags, but you may want to specify some if you want to start a network user or decrement execs,...
|
||||
dris.alg_number = 1 ' execute first algorithm (you do not need to specify this field for Dinkey Lite dongles)
|
||||
' you should remove these entries if you are using Dinkey Lite so that algorithm arguments are random
|
||||
dris.var_a = 1 ' sample values
|
||||
dris.var_b = 2
|
||||
dris.var_c = 3
|
||||
dris.var_d = 4
|
||||
dris.var_e = 5
|
||||
dris.var_f = 6
|
||||
dris.var_g = 7
|
||||
dris.var_h = 8
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, Nothing)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ProtCheckWithAlgEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlgEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlgEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' if you want you can check the algorithm answer - however if algorithm is from your code then best to just use the answer in your code
|
||||
' !!!! Make sure you have replaced the MyAlgorithm routine with the algorithm you have specified in DinkeyAdd
|
||||
If (MyAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h) <> dris.alg_answer) Then
|
||||
MsgBox("Dinkey protection error!\nYou have not patched your algorithm in the MyAlgorithm routine", MsgBoxStyle.OkOnly, "Error")
|
||||
ProtCheckWithAlgEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
ProtCheckWithAlgEnc = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ProtCheckWithAlgEnc = -1
|
||||
End Function
|
||||
|
||||
' ************************** WriteBytesEnc ******************************
|
||||
' This writes the data array 0,1,2,3,4,5,6,7,8,9 to the dongle data area at offset 7
|
||||
' In order for this function to work you will need to have a data area in your dongle that is at least 18 bytes long.
|
||||
' We encrypt the DRIS and Data passed to the API. Patch the CryptDRIS and CryptApiData functions in this file from source code generated by DinkeyAdd.
|
||||
' to write string data please read notes for WriteBytes
|
||||
Function WriteBytesEnc() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code, alg_ans As Integer
|
||||
Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris) ' sets DRIS to have random values including seed1, seed2 and var_a..var_h
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = WRITE_DATA_AREA ' standard protection check & write data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_offset = 7
|
||||
dris.rw_length = data.Length
|
||||
dris.var_a = dris.var_a And &HFFFFFF ' restrict to 24-bit to prevent potential overflow in algorithm
|
||||
dris.var_b = dris.var_b And &HFFFFFF
|
||||
dris.var_c = dris.var_c And &HFFFFFF
|
||||
dris.var_d = dris.var_d And &HFFFFFF
|
||||
dris.var_e = dris.var_e And &HFFFFFF
|
||||
dris.var_f = dris.var_f And &HFFFFFF
|
||||
dris.var_g = dris.var_g And &HFFFFFF
|
||||
dris.var_h = dris.var_h And &HFFFFFF
|
||||
|
||||
' calculate r/w algorithm answer - NB need to replace MyRWAlgorithm code with code for r/w algorithm
|
||||
alg_ans = MyRWAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h)
|
||||
|
||||
' encrypt data we want to write.
|
||||
CryptApiData(dris, data, data.Length, alg_ans)
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
WriteBytesEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
WriteBytesEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
WriteBytesEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
WriteBytesEnc = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
WriteBytesEnc = -1
|
||||
End Function
|
||||
|
||||
' ************************ ReadBytesEnc ************************************
|
||||
' This reads 10 bytes of data from offset 7 in the dongle data area
|
||||
' In order for this function to work you will need to have a data area in your dongle that is at least 18 bytes long.
|
||||
' We encrypt the DRIS and Data passed from the API. Patch the CryptDRIS and CryptApiData functions in this file from source code generated by DinkeyAdd.
|
||||
' to read string data please notes for ReadBytes function
|
||||
Function ReadBytesEnc() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code, alg_ans As Integer
|
||||
Dim data(10) As Byte
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris) ' sets DRIS to have random values including seed1, seed2 and var_a..var_h
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = READ_DATA_AREA ' standard protection check & read data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_offset = 7
|
||||
dris.rw_length = data.Length
|
||||
dris.var_a = dris.var_a And &HFFFFFF ' restrict to 24-bit to prevent potential overflow in algorithm
|
||||
dris.var_b = dris.var_b And &HFFFFFF
|
||||
dris.var_c = dris.var_c And &HFFFFFF
|
||||
dris.var_d = dris.var_d And &HFFFFFF
|
||||
dris.var_e = dris.var_e And &HFFFFFF
|
||||
dris.var_f = dris.var_f And &HFFFFFF
|
||||
dris.var_g = dris.var_g And &HFFFFFF
|
||||
dris.var_h = dris.var_h And &HFFFFFF
|
||||
|
||||
' calculate r/w algorithm answer - NB need to replace MyRWAlgorithm code with code for r/w algorithm
|
||||
alg_ans = MyRWAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h)
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
ReadBytesEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
ReadBytesEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
ReadBytesEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' decrypt data just read.
|
||||
CryptApiData(dris, data, data.Length, alg_ans)
|
||||
MsgBox("Dinkey Dongle Data Area, offset 7 is : " + Str(data(0)) + "," + Str(data(1)) + "," + Str(data(2)) + "," + Str(data(3)) + "," + _
|
||||
Str(data(4)) + "," + Str(data(5)) + "," + Str(data(6)) + "," + Str(data(7)) + "," + Str(data(8)) + "," + Str(data(9)), MsgBoxStyle.OkOnly)
|
||||
ReadBytesEnc = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
ReadBytesEnc = -1
|
||||
End Function
|
||||
|
||||
' ************************** EncryptUserDataEnc *********************************
|
||||
' This function will do a protection check and ask the dongle to encrypt some data using encryption key 1
|
||||
' It will then do another protection check & decrypt the data
|
||||
' We encrypt the DRIS and Data passed to/from the API. Patch the CryptDRIS and CryptApiData functions in this file from source code generated by DinkeyAdd.
|
||||
' to encrypt or decrypt strings please read notes for WriteBytes and ReadBytes functions
|
||||
Function EncryptUserDataEnc() As Integer
|
||||
Dim dris As DRIS = New DRIS
|
||||
Dim ret_code, alg_ans As Integer
|
||||
Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
On Error GoTo Protection_Err
|
||||
|
||||
' set the DRIS to have random values
|
||||
Call RandomSet(dris) ' sets DRIS to have random values including seed1, seed2 and var_a..var_h
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = ENCRYPT_USER_DATA ' standard protection check & encrypt data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_length = data.Length
|
||||
dris.data_crypt_key_num = 1
|
||||
dris.var_a = dris.var_a And &HFFFFFF ' restrict to 24-bit to prevent potential overflow in algorithm
|
||||
dris.var_b = dris.var_b And &HFFFFFF
|
||||
dris.var_c = dris.var_c And &HFFFFFF
|
||||
dris.var_d = dris.var_d And &HFFFFFF
|
||||
dris.var_e = dris.var_e And &HFFFFFF
|
||||
dris.var_f = dris.var_f And &HFFFFFF
|
||||
dris.var_g = dris.var_g And &HFFFFFF
|
||||
dris.var_h = dris.var_h And &HFFFFFF
|
||||
|
||||
' calculate r/w algorithm answer - NB need to replace MyRWAlgorithm code with code for r/w algorithm
|
||||
alg_ans = MyRWAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h)
|
||||
|
||||
' encrypt data we pass to our API
|
||||
CryptApiData(dris, data, data.Length, alg_ans)
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
EncryptUserDataEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' ... could add code to check other elements of the DRIS, e.g. ret_code, sdsn, ...
|
||||
|
||||
' Now decrypt the same data to get the original values
|
||||
Call RandomSet(dris) ' sets DRIS to have random values including seed1, seed2 and var_a..var_h
|
||||
' then set the values we want to use
|
||||
dris.header1 = Asc("D")
|
||||
dris.header2 = Asc("R")
|
||||
dris.header3 = Asc("I")
|
||||
dris.header4 = Asc("S")
|
||||
dris.size = Marshal.SizeOf(dris)
|
||||
dris.myfunction = DECRYPT_USER_DATA ' standard protection check & decrypt data
|
||||
dris.flags = USE_FUNCTION_ARGUMENT ' you have to do it this way in vb.net
|
||||
dris.rw_length = data.Length
|
||||
dris.data_crypt_key_num = 1
|
||||
dris.var_a = dris.var_a And &HFFFFFF ' restrict to 24-bit to prevent potential overflow in algorithm
|
||||
dris.var_b = dris.var_b And &HFFFFFF
|
||||
dris.var_c = dris.var_c And &HFFFFFF
|
||||
dris.var_d = dris.var_d And &HFFFFFF
|
||||
dris.var_e = dris.var_e And &HFFFFFF
|
||||
dris.var_f = dris.var_f And &HFFFFFF
|
||||
dris.var_g = dris.var_g And &HFFFFFF
|
||||
dris.var_h = dris.var_h And &HFFFFFF
|
||||
|
||||
Call CryptDRIS(dris) ' encrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
ret_code = DDProtCheck(dris, data)
|
||||
|
||||
Call CryptDRIS(dris) ' decrypt DRIS (!!!!you should separate from DDProtCheck for greater security)
|
||||
|
||||
If (ret_code <> 0) Then
|
||||
Call DisplayError(ret_code, dris.ext_err)
|
||||
EncryptUserDataEnc = ret_code
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' calculate r/w algorithm answer - NB need to replace MyRWAlgorithm code with code for r/w algorithm
|
||||
alg_ans = MyRWAlgorithm(dris.var_a, dris.var_b, dris.var_c, dris.var_d, dris.var_e, dris.var_f, dris.var_g, dris.var_h)
|
||||
|
||||
' later in your code you can check other values in the DRIS...
|
||||
If (dris.sdsn <> MY_SDSN) Then
|
||||
MsgBox("Incorrect SDSN! Please modify your source code so that MY_SDSN is set to be your SDSN.", MsgBoxStyle.OkOnly, "Error")
|
||||
EncryptUserDataEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' later on in your program you can check the return code again
|
||||
If (dris.ret_code <> 0) Then
|
||||
MsgBox("Dinkey Dongle protection error", MsgBoxStyle.OkOnly, "Error")
|
||||
EncryptUserDataEnc = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' decrypt data just returned by API.
|
||||
CryptApiData(dris, data, data.Length, alg_ans)
|
||||
MsgBox("Decrypted data is : " + Str(data(0)) + "," + Str(data(1)) + "," + Str(data(2)) + "," + Str(data(3)) + "," + _
|
||||
Str(data(4)) + "," + Str(data(5)) + "," + Str(data(6)) + "," + Str(data(7)) + "," + Str(data(8)) + "," + Str(data(9)), MsgBoxStyle.OkOnly)
|
||||
EncryptUserDataEnc = 0
|
||||
Exit Function
|
||||
Protection_Err: ' see readme.txt for explanation of this exception handler
|
||||
Protection_Exception()
|
||||
EncryptUserDataEnc = -1
|
||||
End Function
|
||||
|
||||
|
||||
' *********************** DisplayNetUsers *******************************
|
||||
' This function displays the current network users (for DinkeyNet only).
|
||||
' The DDProtCheck function must be called before this function is called.
|
||||
' (Normally you would use DinkeyServer to view the network users but this enables you to do it from the client if you want)
|
||||
Function DisplayNetUsers(net_users As Integer, model As Integer) As Integer
|
||||
Dim num_net_users, extended_error, ret_code, i, max_net_users As Integer
|
||||
Dim DisplayString As String
|
||||
|
||||
If net_users = -1 Then
|
||||
max_net_users = 100 ' if unlimited network users are allowed then display up to 100 users (for example)
|
||||
Else
|
||||
max_net_users = net_users
|
||||
End If
|
||||
|
||||
If max_net_users = 0 Then ' no network users are allowed, so nothing to do!
|
||||
DisplayNetUsers = 0
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
If model < 3 Then
|
||||
MsgBox("A network dongle has not been detected. Therefore you cannot display the network users.", MsgBoxStyle.OKOnly)
|
||||
DisplayNetUsers = -1
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
Dim nu_info_array(max_net_users) As NU_INFO
|
||||
|
||||
' now get net users
|
||||
ret_code = DDGetNetUserList(Nothing, num_net_users, nu_info_array, max_net_users, extended_error)
|
||||
|
||||
If ret_code <> 0 Then
|
||||
MsgBox("Error " + Str(ret_code) + "/" + Str(extended_error) + " finding network user information.", MsgBoxStyle.OKOnly)
|
||||
Else
|
||||
DisplayString = "number of net users: " + Str(num_net_users) + Environment.NewLine
|
||||
For i = 0 To num_net_users - 1
|
||||
DisplayString = DisplayString + Str(i + 1) + ". licence: " + nu_info_array(i).LicenceName + ", user: " + nu_info_array(i).UserName + ", computer: " + nu_info_array(i).ComputerName + ", ip address: " + nu_info_array(i).IPAddress + Environment.NewLine
|
||||
Next
|
||||
MsgBox(DisplayString, MsgBoxStyle.OKOnly, "Net Users")
|
||||
End If
|
||||
DisplayNetUsers = ret_code
|
||||
|
||||
End Function
|
||||
|
||||
' look at the error code and try to display an appropriate message
|
||||
' you may want to change these messages and specify your own
|
||||
Public Sub DisplayError(ByVal ret_code As Integer, ByVal extended_error As Integer)
|
||||
Select Case ret_code
|
||||
Case 401
|
||||
MsgBox("Error! No dongles detected!", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 403
|
||||
MsgBox("Error! A dongle was detected but it was a different type to the one specified in DinkeyAdd.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 404
|
||||
MsgBox("Error! A dongle was detected but it was a different model to those specified in DinkeyAdd.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 409
|
||||
MsgBox("Error! The dongle detected has not been programmed by DinkeyAdd.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 410
|
||||
MsgBox("Error! A dongle was detected but it has a different Product Code to the one specified in DinkeyAdd.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 411
|
||||
MsgBox("Error! The dongle detected does not contain the licence associated with this program.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 413
|
||||
MsgBox("Error! This program has not been protected by DinkeyAdd. For guidance please read the DinkeyAdd chapter of the Dinkey manual.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 417
|
||||
MsgBox("Error! One or more of the parameters set in the DRIS is incorrect. This could be caused if you are encrypting the DRIS in your code but did not specify DRIS encryption in DinkeyAdd - or vice versa.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 423
|
||||
MsgBox("Error! The number of network users has been exceeded.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 435
|
||||
MsgBox("Error! DinkeyServer has not been detected on the network.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case 922
|
||||
MsgBox("Error! The Software Key has expired.", MsgBoxStyle.OKOnly, "Error")
|
||||
Case Else
|
||||
MsgBox("An error occurred checking the dongle. Error: " + Str(ret_code) + ". Extended Error: " + Str(extended_error) + ".", MsgBoxStyle.OKOnly, "Error")
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
' if an error exception occurs during a protection check function then display an appropiate message
|
||||
' see readme.txt for an explaination
|
||||
Sub Protection_Exception()
|
||||
If (TypeOf Err.GetException() Is DllNotFoundException) Then
|
||||
If (IntPtr.Size = 4) Then
|
||||
MsgBox("Error! Cannot find dpwin32.dll. This should be in the same folder that DLLTest.exe is in.", MsgBoxStyle.OKOnly, "Error")
|
||||
Else
|
||||
MsgBox("Error! Cannot find dpwin64.dll. This should be in the same folder that DLLTest.exe is in.", MsgBoxStyle.OKOnly, "Error")
|
||||
End If
|
||||
Else
|
||||
MsgBox("Error! An exception occurred: " + Err.GetException.Message, MsgBoxStyle.OKOnly, "Error")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
180
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/README.txt
Normal file
180
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/README.txt
Normal file
@@ -0,0 +1,180 @@
|
||||
DllTest - sample code to call the Runtime Module in VB.NET
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This project is written in Visual Studio 2002 but will work in more recent versions of Visual Studio
|
||||
(it will upgrade the Project to the latest version. If prompted you should also upgrade the .NET
|
||||
framework the project requires).
|
||||
|
||||
The main source files in the project are:
|
||||
|
||||
File name Description
|
||||
Form1.vb main source code file for VB.NET
|
||||
dris.vb contains the DRIS structure and low-level functions to manipulate it.
|
||||
|
||||
The best approach is to compile the sample code and see how it works and then to take the appropriate code
|
||||
and apply it to your own project. You should include the dris.vb file in your project and use/modify which
|
||||
ever functions from form1.vb you feel are appropriate. The dris.vb file should not be modified.
|
||||
|
||||
The sample code contains 11 functions. You will not need to use all these functions in your code. Just use
|
||||
which ever functions are most appropriate and customise in your own way. The sample code is just a guide.
|
||||
You should implement the protection in a stronger way using the techniques described in the
|
||||
"Increasing your Protection" chapter of the manual.
|
||||
|
||||
Code marked with !!!! are places where you should customise the sample code so that it will work properly:
|
||||
|
||||
* Change the MY_SDSN value to the value of your SDSN
|
||||
* Change the MY_PRODCODE value to the Product Code in the dongle
|
||||
* Change the MyAlgorithm code (if you call a user algorithm)
|
||||
* Change the CryptDRIS code (if you encrypt the DRIS)
|
||||
* Change the CryptApiData (if you encrypt Data you send to our API)
|
||||
* Change the MyRWAlgorithm code (if encrypt Data you send to our API using the R/W algorithm)
|
||||
|
||||
You will also probably want to replace our error messages with your own. However, you should still
|
||||
display or log any error codes returned by the protection check otherwise you will not be able to
|
||||
identify the cause of the error. (You can look up error codes in our knowledge base: microcosm.com/kb).
|
||||
|
||||
For users of Visual Studio 2005 or higher, the default setting for projects is to compile for the Target
|
||||
Platform "Any". This means that on 32-bit Windows, your code will run as 32-bit code (and needs to call
|
||||
dpwin32.dll) and under 64-bit Windows your code will run as 64-bit code (and needs to call dpwin64.dll).
|
||||
The sample code works this out automatically. If you select the target platform as "x86" then it will
|
||||
always be 32-bit and so you only need to use dpwin32.dll. If you select "x64" then your code will be
|
||||
64-bit and you only need to use dpwin64.dll.
|
||||
|
||||
Note - as you are using the API method in this sample you should protect dpwin32.dll and/or dpwin64.dll
|
||||
and not your program. Because your program is linked to the DLL it is protected. You can also protect
|
||||
your program with the Shell Method should you wish.
|
||||
|
||||
Note - if you are compiling for the Platform target "Any" (and therefore need to protect both dpwin32.dll
|
||||
and dpwin64.dll) then you will probably want to protect these modules to the same licence so that they share
|
||||
a common set of protection parameters.
|
||||
|
||||
Make sure you remember to do the following:
|
||||
|
||||
1) Insert the following namespaces in your code file:
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
2) Insert the dris.vb file in your project.
|
||||
|
||||
3) The protected dpwin32.dll (dpwin64.dll) should be output to the folder that contains your EXE file.
|
||||
Otherwise the message "Unable to open DLL (dpwin32.dll)" or System.DllNotFoundException error will appear
|
||||
when you run DllTest. Unfortunately, when the system displays these exceptions, it gives the choice of
|
||||
"Continue" which will return from the program assuming it returned success - and thereby bypassing the
|
||||
protection check. To combat this we have added the Protection_Err exception handler to handle exceptions.
|
||||
This behaviour appears to be unique to VB.NET.
|
||||
|
||||
If you wish you can rename dpwin32.dll (dpwin64.dll) to a name of your choice. In this case you will need to
|
||||
modify the dll name in the dris.vb file.
|
||||
|
||||
Note - VB.NET is an interpreted language and so it is easier to decompile than other languages. You can
|
||||
improve security if you use an obfuscator to obfuscate your code. Or - even better - you could use the
|
||||
Shell Method to protect your executable. This encrypts your code (making it impossible to decompile).
|
||||
|
||||
Note for using strings in DRIS
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
To set the alt_licence_name field and read the prodcode field in the DRIS you need to use the
|
||||
SetAltLicenceName and GetProductCode functions. You can use other fields directly, e.g. dris.sdsn
|
||||
|
||||
Notes on Debugging 64-bit Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
When you use the 64-bit runtime module (dpwin64.dll) to protect your software the anti-debug code is so
|
||||
strong that if you are debugging your code, after the call DDProtCheck then it will crash with an SEH
|
||||
exception. If you want to be able to debug your code then you can setup your project so that your code
|
||||
calls the debug module (dpwin64debug.dll) in your "debug" build and the standard module (dpwin64.dll)
|
||||
in your release build. You can do this by modifying the declaration of DDProtCheck64 in dris.vb like this:
|
||||
|
||||
#if DEBUG ' debug module
|
||||
Declare Function DDProtCheck64 Lib "dpwin64debug.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
#else ' standard module
|
||||
Declare Function DDProtCheck64 Lib "dpwin64.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
#endif
|
||||
|
||||
Note - the debug module has the following restrictions:
|
||||
|
||||
1) It will not correctly start a network user (network dongles only). However, other than that the protection
|
||||
check will function correctly and return success.
|
||||
2) You will not be able to encrypt the DRIS. (If you do encrypt the DRIS in your release build then you
|
||||
should make sure that CryptDRIS does not get called in your debug build).
|
||||
3) The protection check will take slightly longer than normal.
|
||||
4) The DDGetNetUserList function will return error 428 (not implemented).
|
||||
5) A temporary subprocess is created which may be (falsely) detected as malicious by anti-virus programs.
|
||||
|
||||
This behaviour does not occur in 32-bit code, so if you are using dpwin32.dll then you can debug your code.
|
||||
|
||||
Special Note for using Algorithms in VB.NET
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The algorithms are calculated using 32-bit integers (Integer in vb.net). It is quite possible for the
|
||||
MyAlgorithm and MyRWAlgorithm functions to overflow if the values provided are too big. In the dongle the
|
||||
algorithms can never overflow - if the answer is too big then the high part of the answer is ignored.
|
||||
In practical terms:
|
||||
|
||||
When you are using the r/w algorithm it is best not to pass random 32-bit integers. It is better to restrict
|
||||
the variables to 24-bit to avoid the possibility of overflows. You can see this implemented in the MyRWAlgorithm
|
||||
and WriteBytesEnc function, for example.
|
||||
|
||||
You can also use this technique with the user algorithms. Another option in MyAlgorithm is to convert each input
|
||||
to 64-bit, apply the algorithm and then convert back to 32-bit to return the answer.
|
||||
|
||||
When using a user algorithm it will behave exactly as the corresponding MyAlgorithm function will in VB
|
||||
except it will not give overflow errors.
|
||||
|
||||
Important Note for UWP app Developers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Universal Windows Platform (UWP) application (previously called Windows Store Apps or Metro Apps) are not
|
||||
compatible with Lite or Plus dongles because the restrictions imposed by these applications. However, you
|
||||
can protect these Apps with network dongles (because the restrictive access is performed by the non-UWP
|
||||
DinkeyServer process). If you do this you will need to enable the "Private Networks (Client and Server)"
|
||||
Capability in your package manifest.
|
||||
|
||||
.NET Core / .NET 5+
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The sample code provided also works with .NET Core. However, .NET Core also supports Linux and macOS as well
|
||||
as other platforms. If you want to support these OS then please replace dris.vb with dris_dotnetcore.vb.
|
||||
The files are very similar but dris_dotnetcore.vb will load the relevant native runtime module (dpwin32.dll
|
||||
under 32-bit Windows; dpwin64.dll under 64-bit Windows; dplin64.so under Linux OS; dpmac64debug.dylib under
|
||||
macOS - unfortunately the release module is not compatible with the .NET Core framework so you have to use
|
||||
the debug one. This also means that our solution is not compatible with ARM-based macOS - because the debug
|
||||
modules do not exist).
|
||||
|
||||
If you are using .NET Core version earlier than 3.0 then Windows.Forms are not supported and you will have to
|
||||
replace the MessageBox.Show lines with Console.WriteLine.
|
||||
|
||||
The Shell Method is compatible with .NET Core Console, Windows.Forms and WPF applications. It is supported
|
||||
under Windows and Linux but not macOS. It is only supported for .NET Core version 3.0 or higher. If you are
|
||||
using the Shell Method then you should protect your compiled dll and not the "appHost" (this is a native
|
||||
executable which is just a stub program that loads the assemblies in your dll). Also do not use "dotnet run"
|
||||
to launch your application - it will run the unprotected version. Either launch the executable or run using
|
||||
"dotnet <program.dll>".
|
||||
|
||||
If you publish a "single-file executable" file then although this file can be protected we do not recommend
|
||||
it because it is not secure. (The single-file executable just comprises a stub loader with your compiled
|
||||
assemblies and configuration files appended to the end of the executable. These files are just considered as
|
||||
data appended to the executable file in a custom format and therefore are not protected. When you shell
|
||||
protect your executable you are just protecting the loader but not your assemblies). Instead you need to
|
||||
build your code and then add protection before publishing. You should protect your assemblies in the obj
|
||||
directory (and in the platform type you specified) e.g. obj/Release/net5.0/win-x64, because the publish
|
||||
process takes your assemblies from this location when it builds the single-file executable. You will also
|
||||
need to distribute all the extra files that DinkeyAdd generates. e.g. <file>.dp64.dll.
|
||||
|
||||
If you publish using the ReadytoRun compilation this will not work because it includes mixtures of .NET
|
||||
assemblies and native code and the .NET Shell Method does not support that.
|
||||
|
||||
Visual Studio Installer Projects Extension
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can use this extension to create a project in your solution that will create an installation program / msi
|
||||
file. Please note that after your application has been built you need to protect it with DinkeyAdd before you
|
||||
can invoke the installer project. You can do this manually by building your application project (not the entire
|
||||
solution); then adding protection to your application using DinkeyAdd; then building your installer project.
|
||||
Or you can automate this by executing DinkeyAddCmd as a post-build step. For example:
|
||||
"c:\program files (x86)\Dinkey Pro 7.6.0\DinkeyAdd\DinkeyAddCmd.exe" c:\adir\mydapf.dapfj /a2
|
||||
|
||||
Note - if you specify "primary output" in your installer project then it will take the files from
|
||||
obj\Release\net5.0 (for example), rather than bin\Release\net5.0. So, you need to add protection to your files
|
||||
in this folder.
|
||||
|
||||
Note - if you use the API Method you will also need to include the protected runtime modules that you use
|
||||
(e.g. dpwin64.dll). If you use the Shell Method you will also need to include in your installer project all
|
||||
of the output files mentioned by DinkeyAdd. e.g. <application_name>.dp64.dll
|
||||
218
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/dris.vb
Normal file
218
Dinkey Pro 7.6.1/Samples/Visual Basic .NET/Runtime/dris.vb
Normal file
@@ -0,0 +1,218 @@
|
||||
' !! this file should not be modified
|
||||
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Text
|
||||
|
||||
Module dris_code
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DRIS
|
||||
' the first 4 fields are never encrypted
|
||||
Dim header1 As Byte ' should be set to 'DRIS'
|
||||
Dim header2 As Byte
|
||||
Dim header3 As Byte
|
||||
Dim header4 As Byte
|
||||
' inputs
|
||||
Dim size As Integer ' size of this structure
|
||||
Dim seed1 As Integer ' seed for data/dris encryption
|
||||
Dim seed2 As Integer ' as above
|
||||
' (maybe encrypted from now on)
|
||||
Dim myfunction As Integer ' specify only one function
|
||||
Dim flags As Integer ' options for the function selected. To use more than one OR them together: OPTION1 Or OPTION2...
|
||||
Dim execs_decrement As UInt32 ' amount by which to dec execs if we use flag: DEC_MANY_EXECS
|
||||
Dim data_crypt_key_num As Integer ' number of the key (1-3) that the dongle uses to encrypt or decrypt user data
|
||||
Dim rw_offset As Integer ' offset in the dongle data area to read or write data
|
||||
Dim rw_length As Integer ' length of data are to read/write/encrypt/decrypt
|
||||
Dim DoNotUse As IntPtr ' do not use the rw_data_ptr element use the "Data" argument of the DDProtCheck function
|
||||
' to set this field use the function SetAltLicenceName instead
|
||||
<VBFixedArray(256), MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Dim _alt_licence_name As Byte()
|
||||
Dim var_a As Integer ' variable values for user algorithm
|
||||
Dim var_b As Integer
|
||||
Dim var_c As Integer
|
||||
Dim var_d As Integer
|
||||
Dim var_e As Integer
|
||||
Dim var_f As Integer
|
||||
Dim var_g As Integer
|
||||
Dim var_h As Integer
|
||||
Dim alg_number As Integer ' the number of the user algorithm that you want to execute
|
||||
' outputs
|
||||
Dim ret_code As Integer ' return code from the protection check
|
||||
Dim ext_err As Integer ' extended error
|
||||
Dim type As Integer ' type of dongle detected. 1 = Pro, 2 = FD
|
||||
Dim model As Integer ' model of dongle detected. 1 = Lite, 2 = Plus, 4 = Net 5, 7 = Net Unlimited
|
||||
Dim sdsn As Integer ' Software Developer's Serial Number
|
||||
'to read this field use the function GetProductCode instead
|
||||
<VBFixedArray(12), MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Dim _prodcode As Byte()
|
||||
Dim dongle_number As UInt32
|
||||
Dim update_number As Integer
|
||||
Dim data_area_size As UInt32 ' size of the data area in the dongle detected
|
||||
Dim max_alg_num As Integer ' the maximum algorithm number in the dongle detected
|
||||
Dim execs As Integer ' executions left: -1 indicates 'no limit'
|
||||
Dim exp_day As Integer ' expiry day: -1 indicates 'no limit'
|
||||
Dim exp_month As Integer ' expiry month: -1 indicates 'no limit'
|
||||
Dim exp_year As Integer ' expiry year: -1 indicates 'no limit'
|
||||
Dim features As UInt32 ' features value
|
||||
Dim net_users As Integer ' maximum number of network users for the dongle detected: -1 indicates 'mo limit'
|
||||
Dim alg_answer As Integer ' answer to the user algorithm executed with the given variable values
|
||||
Dim fd_capacity As UInt32 ' capacity of the data area in FD dongle. Currently fixed at ~10MB but may change in the future.
|
||||
'to read this field use the function GetFDDrive instead
|
||||
<VBFixedArray(128), MarshalAs(UnmanagedType.ByValArray, SizeConst:=128)> Dim _fd_drive As Byte()
|
||||
Dim swkey_type As Integer ' 0 = no swkey detected, 1 = temporary software key, 2 = demo software key
|
||||
Dim swkey_exp_day As Integer ' software key expiry date (if software key detected)
|
||||
Dim swkey_exp_month As Integer
|
||||
Dim swkey_exp_year As Integer
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure NU_INFO
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim LicenceName As String
|
||||
<VBFixedString(50), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=50)> _
|
||||
Dim UserName As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ComputerName As String
|
||||
<VBFixedString(16), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=16)> _
|
||||
Dim IPAddress As String
|
||||
End Structure
|
||||
|
||||
' functions exported from dpwin32.dll / dpwin32.dll - do 32-bit and 64-bit separately
|
||||
|
||||
' DDProtCheck
|
||||
Declare Function DDProtCheck32 Lib "dpwin32.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
Declare Function DDProtCheck64 Lib "dpwin64.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
|
||||
' DDGetNetUserList
|
||||
Declare Ansi Function DDGetNetUserList32 Lib "dpwin32.dll" Alias "DDGetNetUserList" (ByVal licence_name As String, ByRef num_net_users As Integer, _
|
||||
ByVal nu_info_bytes() As Byte, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DDGetNetUserList64 Lib "dpwin64.dll" Alias "DDGetNetUserList" (ByVal licence_name As String, ByRef num_net_users As Integer, _
|
||||
ByVal nu_info_bytes() As Byte, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
|
||||
' call the correct dll depending on whether we are running 32-bit or 64-bit code
|
||||
Function DDProtCheck(ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
If (IntPtr.Size = 4) Then
|
||||
DDProtCheck = DDProtCheck32(mydris, data)
|
||||
Else
|
||||
DDProtCheck = DDProtCheck64(mydris, data)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DDGetNetUserList(ByVal licence_name As String, ByRef num_net_users As Integer, ByRef nu_info_array() As NU_INFO, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
Dim i As Integer
|
||||
Dim my_nu_info As New NU_INFO ' NB this only exists so we can get the size of the NU_INFO stucture
|
||||
Dim nu_info_bytes(num_info_structs * Marshal.SizeOf(my_nu_info)) As Byte
|
||||
Dim nu_info_one_struct(Marshal.SizeOf(my_nu_info)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
|
||||
' call the function and get info as a byte array
|
||||
If (IntPtr.Size = 4) Then
|
||||
DDGetNetUserList = DDGetNetUserList32(licence_name, num_net_users, nu_info_bytes, num_info_structs, extended_error)
|
||||
Else
|
||||
DDGetNetUserList = DDGetNetUserList64(licence_name, num_net_users, nu_info_bytes, num_info_structs, extended_error)
|
||||
End If
|
||||
|
||||
' convert byte array to an array of structs
|
||||
For i = 0 To num_net_users - 1
|
||||
nu_info_array(i) = New NU_INFO
|
||||
Array.Copy(nu_info_bytes, i * Marshal.SizeOf(my_nu_info.GetType), nu_info_one_struct, 0, Marshal.SizeOf(my_nu_info.GetType))
|
||||
MyGC = GCHandle.Alloc(nu_info_one_struct, GCHandleType.Pinned)
|
||||
nu_info_array(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, my_nu_info.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
' Functions
|
||||
Public Const PROTECTION_CHECK As Integer = 1 ' checks for dongle, check program params...
|
||||
Public Const EXECUTE_ALGORITHM As Integer = 2 ' protection check + calculate answer for specified algorithm with specified inputs
|
||||
Public Const WRITE_DATA_AREA As Integer = 3 ' protection check + writes dongle data area
|
||||
Public Const READ_DATA_AREA As Integer = 4 ' protection check + reads dongle data area
|
||||
Public Const ENCRYPT_USER_DATA As Integer = 5 ' protection check + the dongle will encrypt user data
|
||||
Public Const DECRYPT_USER_DATA As Integer = 6 ' protection check + the dongle will decrypt user data
|
||||
Public Const FAST_PRESENCE_CHECK As Integer = 7 ' checks for the presence of the correct dongle only with minimal security, no flags allowed
|
||||
Public Const STOP_NET_USER As Integer = 8 ' stops a network user (a protection check is NOT performed)
|
||||
|
||||
' Flags
|
||||
Public Const DEC_ONE_EXEC As Integer = 1 ' decrement execs by 1
|
||||
Public Const DEC_MANY_EXECS As Integer = 2 ' decrement execs by number specified in execs
|
||||
Public Const START_NET_USER As Integer = 4 ' starts a network user
|
||||
Public Const USE_FUNCTION_ARGUMENT As Integer = 16 ' use the extra argument in the function for pointers
|
||||
Public Const CHECK_LOCAL_FIRST As Integer = 32 ' always look in local ports before looking in network ports
|
||||
Public Const CHECK_NETWORK_FIRST As Integer = 64 ' always look on the network before looking in local ports
|
||||
Public Const USE_ALT_LICENCE_NAME As Integer = 128 ' use name specified in alt_licence_name instead of the default one
|
||||
Public Const DONT_SET_MAXDAYS_EXPIRY As Integer = 256 ' if the max days expiry date has not been calculated then do not do it this time
|
||||
Public Const MATCH_DONGLE_NUMBER As Integer = 512 ' restrict the search to match the dongle number specified in the DRIS
|
||||
Public Const DONT_RETURN_FD_DRIVE As Integer = 1024 ' if an FD dongle has been detected then don't return the flash drive/mount name in the DRIS
|
||||
|
||||
Public Const NU_INFO_SIZE As Integer = (256 + 50 + 256 + 16) ' size of NU_INFO structure (for listing network users)
|
||||
|
||||
' ********************** useful functions for use in sample code ***************************
|
||||
' use this function to set the alt_licence_name field of the DRIS
|
||||
Public Sub SetAltLicenceName(ByVal mydris As DRIS, ByVal altlicencename As String)
|
||||
Dim i, num_bytes As Integer
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim temp As Byte()
|
||||
|
||||
temp = ascii.GetBytes(altlicencename)
|
||||
num_bytes = ascii.GetByteCount(altlicencename)
|
||||
For i = 0 To num_bytes - 1
|
||||
mydris._alt_licence_name(i) = temp(i)
|
||||
Next
|
||||
mydris._alt_licence_name(num_bytes) = 0 'null-terminate string
|
||||
End Sub
|
||||
|
||||
' use this function to read the prodcode field of the DRIS
|
||||
Public Function GetProductCode(ByVal mydris As DRIS) As String
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim i As Integer
|
||||
For i = 0 To 11
|
||||
If mydris._prodcode(i) = 0 Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Return ascii.GetString(mydris._prodcode, 0, i)
|
||||
End Function
|
||||
|
||||
' use this function to read the fd_drive field of the DRIS
|
||||
Public Function GetFDDrive(ByVal mydris As DRIS) As String
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim i As Integer
|
||||
For i = 0 To 127
|
||||
If mydris._fd_drive(i) = 0 Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Return ascii.GetString(mydris._fd_drive, 0, i)
|
||||
End Function
|
||||
|
||||
' copies an integer to offset "index" in trhe specified byte array
|
||||
Public Sub Set4Bytes(ByVal data() As Byte, ByVal index As Integer, ByVal value As Integer)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(value, GCHandleType.Pinned)
|
||||
Dim AddressOfValue As IntPtr = MyGC.AddrOfPinnedObject()
|
||||
Marshal.Copy(AddressOfValue, data, index, 4)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' converts to DRIS structure to a byte array (so we can do encryption)
|
||||
Public Sub DrisToByteArray(ByVal mydris As DRIS, ByVal data() As Byte)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(mydris, MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' converts a byte array to the DRIS structure (so we can do encryption)
|
||||
Public Sub ByteArrayToDris(ByVal data() As Byte, ByRef mydris As DRIS)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
|
||||
mydris = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, mydris.GetType)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' initialise the DRIS with random values
|
||||
Public Sub RandomSet(ByRef mydris As DRIS)
|
||||
Dim temp_dris(Marshal.SizeOf(mydris) - 1) As Byte
|
||||
Dim rnd As New Random
|
||||
|
||||
rnd.NextBytes(temp_dris)
|
||||
ByteArrayToDris(temp_dris, mydris)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -0,0 +1,236 @@
|
||||
' !! this file should not be modified
|
||||
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Text
|
||||
|
||||
Module dris_code
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure DRIS
|
||||
' the first 4 fields are never encrypted
|
||||
Dim header1 As Byte ' should be set to 'DRIS'
|
||||
Dim header2 As Byte
|
||||
Dim header3 As Byte
|
||||
Dim header4 As Byte
|
||||
' inputs
|
||||
Dim size As Integer ' size of this structure
|
||||
Dim seed1 As Integer ' seed for data/dris encryption
|
||||
Dim seed2 As Integer ' as above
|
||||
' (maybe encrypted from now on)
|
||||
Dim myfunction As Integer ' specify only one function
|
||||
Dim flags As Integer ' options for the function selected. To use more than one OR them together: OPTION1 Or OPTION2...
|
||||
Dim execs_decrement As UInt32 ' amount by which to dec execs if we use flag: DEC_MANY_EXECS
|
||||
Dim data_crypt_key_num As Integer ' number of the key (1-3) that the dongle uses to encrypt or decrypt user data
|
||||
Dim rw_offset As Integer ' offset in the dongle data area to read or write data
|
||||
Dim rw_length As Integer ' length of data are to read/write/encrypt/decrypt
|
||||
Dim DoNotUse As IntPtr ' do not use the rw_data_ptr element use the "Data" argument of the DDProtCheck function
|
||||
' to set this field use the function SetAltLicenceName instead
|
||||
<VBFixedArray(256), MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Dim _alt_licence_name As Byte()
|
||||
Dim var_a As Integer ' variable values for user algorithm
|
||||
Dim var_b As Integer
|
||||
Dim var_c As Integer
|
||||
Dim var_d As Integer
|
||||
Dim var_e As Integer
|
||||
Dim var_f As Integer
|
||||
Dim var_g As Integer
|
||||
Dim var_h As Integer
|
||||
Dim alg_number As Integer ' the number of the user algorithm that you want to execute
|
||||
' outputs
|
||||
Dim ret_code As Integer ' return code from the protection check
|
||||
Dim ext_err As Integer ' extended error
|
||||
Dim type As Integer ' type of dongle detected. 1 = Pro, 2 = FD
|
||||
Dim model As Integer ' model of dongle detected. 1 = Lite, 2 = Plus, 4 = Net 5, 7 = Net Unlimited
|
||||
Dim sdsn As Integer ' Software Developer's Serial Number
|
||||
'to read this field use the function GetProductCode instead
|
||||
<VBFixedArray(12), MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Dim _prodcode As Byte()
|
||||
Dim dongle_number As UInt32
|
||||
Dim update_number As Integer
|
||||
Dim data_area_size As UInt32 ' size of the data area in the dongle detected
|
||||
Dim max_alg_num As Integer ' the maximum algorithm number in the dongle detected
|
||||
Dim execs As Integer ' executions left: -1 indicates 'no limit'
|
||||
Dim exp_day As Integer ' expiry day: -1 indicates 'no limit'
|
||||
Dim exp_month As Integer ' expiry month: -1 indicates 'no limit'
|
||||
Dim exp_year As Integer ' expiry year: -1 indicates 'no limit'
|
||||
Dim features As UInt32 ' features value
|
||||
Dim net_users As Integer ' maximum number of network users for the dongle detected: -1 indicates 'mo limit'
|
||||
Dim alg_answer As Integer ' answer to the user algorithm executed with the given variable values
|
||||
Dim fd_capacity As UInt32 ' capacity of the data area in FD dongle. Currently fixed at ~10MB but may change in the future.
|
||||
'to read this field use the function GetFDDrive instead
|
||||
<VBFixedArray(128), MarshalAs(UnmanagedType.ByValArray, SizeConst:=128)> Dim _fd_drive As Byte()
|
||||
Dim swkey_type As Integer ' 0 = no swkey detected, 1 = temporary software key, 2 = demo software key
|
||||
Dim swkey_exp_day As Integer ' software key expiry date (if software key detected)
|
||||
Dim swkey_exp_month As Integer
|
||||
Dim swkey_exp_year As Integer
|
||||
End Structure
|
||||
|
||||
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
|
||||
Structure NU_INFO
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim LicenceName As String
|
||||
<VBFixedString(50), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=50)> _
|
||||
Dim UserName As String
|
||||
<VBFixedString(256), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
|
||||
Dim ComputerName As String
|
||||
<VBFixedString(16), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=16)> _
|
||||
Dim IPAddress As String
|
||||
End Structure
|
||||
|
||||
' functions exported from runtime module e.g. dpwin64.dll etc
|
||||
|
||||
' DDProtCheck
|
||||
Declare Function DDProtCheckWin32 Lib "dpwin32.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
Declare Function DDProtCheckWin64 Lib "dpwin64.dll" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
Declare Function DDProtCheckLin64 Lib "dplin64.so" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
Declare Function DDProtCheckMac64 Lib "dpmac64debug.dylib" Alias "DDProtCheck" (ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
|
||||
' DDGetNetUserList - NB not supported for macOS as this function does not exist in the debug module
|
||||
Declare Ansi Function DDGetNetUserListWin32 Lib "dpwin32.dll" Alias "DDGetNetUserList" (ByVal licence_name As String, ByRef num_net_users As Integer,
|
||||
ByVal nu_info_bytes() As Byte, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DDGetNetUserListWin64 Lib "dpwin64.dll" Alias "DDGetNetUserList" (ByVal licence_name As String, ByRef num_net_users As Integer,
|
||||
ByVal nu_info_bytes() As Byte, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
Declare Ansi Function DDGetNetUserListLin64 Lib "dplin64.so" Alias "DDGetNetUserList" (ByVal licence_name As String, ByRef num_net_users As Integer,
|
||||
ByVal nu_info_bytes() As Byte, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
|
||||
' call the correct dll depending on whether we are running 32-bit or 64-bit code
|
||||
Function DDProtCheck(ByRef mydris As DRIS, ByVal data() As Byte) As Integer
|
||||
If (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) Then
|
||||
If (Environment.Is64BitProcess) Then
|
||||
DDProtCheck = DDProtCheckWin64(mydris, data)
|
||||
Else
|
||||
DDProtCheck = DDProtCheckWin32(mydris, data)
|
||||
End If
|
||||
ElseIf (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) Then
|
||||
DDProtCheck = DDProtCheckLin64(mydris, data)
|
||||
ElseIf (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) Then
|
||||
DDProtCheck = DDProtCheckMac64(mydris, data)
|
||||
Else
|
||||
DDProtCheck = -1 ' OS not supported
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function DDGetNetUserList(ByVal licence_name As String, ByRef num_net_users As Integer, ByRef nu_info_array() As NU_INFO, ByVal num_info_structs As Integer, ByRef extended_error As Integer) As Integer
|
||||
Dim i As Integer
|
||||
Dim my_nu_info As New NU_INFO ' NB this only exists so we can get the size of the NU_INFO stucture
|
||||
Dim nu_info_bytes(num_info_structs * Marshal.SizeOf(my_nu_info)) As Byte
|
||||
Dim nu_info_one_struct(Marshal.SizeOf(my_nu_info)) As Byte
|
||||
Dim MyGC As GCHandle
|
||||
|
||||
' call the function and get info as a byte array
|
||||
If (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) Then
|
||||
If (Environment.Is64BitProcess) Then
|
||||
DDGetNetUserList = DDGetNetUserListWin64(licence_name, num_net_users, nu_info_bytes, num_info_structs, extended_error)
|
||||
Else
|
||||
DDGetNetUserList = DDGetNetUserListWin32(licence_name, num_net_users, nu_info_bytes, num_info_structs, extended_error)
|
||||
End If
|
||||
ElseIf (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) Then
|
||||
DDGetNetUserList = DDGetNetUserListLin64(licence_name, num_net_users, nu_info_bytes, num_info_structs, extended_error)
|
||||
Else
|
||||
DDGetNetUserList = -1 ' OS not supported (this includes macOS)
|
||||
End If
|
||||
|
||||
' convert byte array to an array of structs
|
||||
For i = 0 To num_net_users - 1
|
||||
nu_info_array(i) = New NU_INFO
|
||||
Array.Copy(nu_info_bytes, i * Marshal.SizeOf(my_nu_info.GetType), nu_info_one_struct, 0, Marshal.SizeOf(my_nu_info.GetType))
|
||||
MyGC = GCHandle.Alloc(nu_info_one_struct, GCHandleType.Pinned)
|
||||
nu_info_array(i) = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, my_nu_info.GetType)
|
||||
MyGC.Free()
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
' Functions
|
||||
Public Const PROTECTION_CHECK As Integer = 1 ' checks for dongle, check program params...
|
||||
Public Const EXECUTE_ALGORITHM As Integer = 2 ' protection check + calculate answer for specified algorithm with specified inputs
|
||||
Public Const WRITE_DATA_AREA As Integer = 3 ' protection check + writes dongle data area
|
||||
Public Const READ_DATA_AREA As Integer = 4 ' protection check + reads dongle data area
|
||||
Public Const ENCRYPT_USER_DATA As Integer = 5 ' protection check + the dongle will encrypt user data
|
||||
Public Const DECRYPT_USER_DATA As Integer = 6 ' protection check + the dongle will decrypt user data
|
||||
Public Const FAST_PRESENCE_CHECK As Integer = 7 ' checks for the presence of the correct dongle only with minimal security, no flags allowed
|
||||
Public Const STOP_NET_USER As Integer = 8 ' stops a network user (a protection check is NOT performed)
|
||||
|
||||
' Flags
|
||||
Public Const DEC_ONE_EXEC As Integer = 1 ' decrement execs by 1
|
||||
Public Const DEC_MANY_EXECS As Integer = 2 ' decrement execs by number specified in execs
|
||||
Public Const START_NET_USER As Integer = 4 ' starts a network user
|
||||
Public Const USE_FUNCTION_ARGUMENT As Integer = 16 ' use the extra argument in the function for pointers
|
||||
Public Const CHECK_LOCAL_FIRST As Integer = 32 ' always look in local ports before looking in network ports
|
||||
Public Const CHECK_NETWORK_FIRST As Integer = 64 ' always look on the network before looking in local ports
|
||||
Public Const USE_ALT_LICENCE_NAME As Integer = 128 ' use name specified in alt_licence_name instead of the default one
|
||||
Public Const DONT_SET_MAXDAYS_EXPIRY As Integer = 256 ' if the max days expiry date has not been calculated then do not do it this time
|
||||
Public Const MATCH_DONGLE_NUMBER As Integer = 512 ' restrict the search to match the dongle number specified in the DRIS
|
||||
Public Const DONT_RETURN_FD_DRIVE As Integer = 1024 ' if an FD dongle has been detected then don't return the flash drive/mount name in the DRIS
|
||||
|
||||
Public Const NU_INFO_SIZE As Integer = (256 + 50 + 256 + 16) ' size of NU_INFO structure (for listing network users)
|
||||
|
||||
' ********************** useful functions for use in sample code ***************************
|
||||
' use this function to set the alt_licence_name field of the DRIS
|
||||
Public Sub SetAltLicenceName(ByVal mydris As DRIS, ByVal altlicencename As String)
|
||||
Dim i, num_bytes As Integer
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim temp As Byte()
|
||||
|
||||
temp = ascii.GetBytes(altlicencename)
|
||||
num_bytes = ascii.GetByteCount(altlicencename)
|
||||
For i = 0 To num_bytes - 1
|
||||
mydris._alt_licence_name(i) = temp(i)
|
||||
Next
|
||||
mydris._alt_licence_name(num_bytes) = 0 'null-terminate string
|
||||
End Sub
|
||||
|
||||
' use this function to read the prodcode field of the DRIS
|
||||
Public Function GetProductCode(ByVal mydris As DRIS) As String
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim i As Integer
|
||||
For i = 0 To 11
|
||||
If mydris._prodcode(i) = 0 Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Return ascii.GetString(mydris._prodcode, 0, i)
|
||||
End Function
|
||||
|
||||
' use this function to read the fd_drive field of the DRIS
|
||||
Public Function GetFDDrive(ByVal mydris As DRIS) As String
|
||||
Dim ascii As New ASCIIEncoding
|
||||
Dim i As Integer
|
||||
For i = 0 To 127
|
||||
If mydris._fd_drive(i) = 0 Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Return ascii.GetString(mydris._fd_drive, 0, i)
|
||||
End Function
|
||||
|
||||
' copies an integer to offset "index" in trhe specified byte array
|
||||
Public Sub Set4Bytes(ByVal data() As Byte, ByVal index As Integer, ByVal value As Integer)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(value, GCHandleType.Pinned)
|
||||
Dim AddressOfValue As IntPtr = MyGC.AddrOfPinnedObject()
|
||||
Marshal.Copy(AddressOfValue, data, index, 4)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' converts to DRIS structure to a byte array (so we can do encryption)
|
||||
Public Sub DrisToByteArray(ByVal mydris As DRIS, ByVal data() As Byte)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
|
||||
Marshal.StructureToPtr(mydris, MyGC.AddrOfPinnedObject, False)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' converts a byte array to the DRIS structure (so we can do encryption)
|
||||
Public Sub ByteArrayToDris(ByVal data() As Byte, ByRef mydris As DRIS)
|
||||
Dim MyGC As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
|
||||
mydris = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, mydris.GetType)
|
||||
MyGC.Free()
|
||||
End Sub
|
||||
|
||||
' initialise the DRIS with random values
|
||||
Public Sub RandomSet(ByRef mydris As DRIS)
|
||||
Dim temp_dris(Marshal.SizeOf(mydris) - 1) As Byte
|
||||
Dim rnd As New Random
|
||||
|
||||
rnd.NextBytes(temp_dris)
|
||||
ByteArrayToDris(temp_dris, mydris)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
Reference in New Issue
Block a user