Add Original SDK

This commit is contained in:
2026-05-06 07:47:36 +02:00
parent 2915e04380
commit 0ed627517a
674 changed files with 89334 additions and 0 deletions

View File

@@ -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.*")>

View 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>

View 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

View File

@@ -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).

View 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

View File

@@ -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

View File

@@ -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>