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.*")>
|
||||
@@ -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>
|
||||
@@ -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).
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user