Page 1 of 1

Pulling License Data results in crash of program

Posted: Mon Jan 21, 2019 11:38 pm
by zyNoT
I was able to do this in the past on previous occasions and now it does not work.
The program just doesn't open.

Form1_Load:

Dim Test as String = ""
Dim Test2 as String = ""
EP_RegLoadKeyA(Test, Test2)
Me.Text = "Licensed to: " + Test

No longer functions at all. It used to state who the license was for...

The program opens without the protection on it, but once protected, it never actually opens. Windows Event Viewer shows that it crashed.


UPDATE: Now in further investigation... it appears if I put the application through ILMerge it works after... what's going on here?

Re: Pulling License Data results in crash of program

Posted: Tue Jan 22, 2019 11:29 am
by Enigma
Hi, sorry, is it Visual Basic 6?

Can you change the code to this:

Code: Select all

Dim Test as String
Dim Test2 as String
If EP_RegLoadKeyA(Test, Test2) Then
  Me.Text = "Licensed to: " + Test
EndIf

Re: Pulling License Data results in crash of program

Posted: Tue Jan 22, 2019 9:02 pm
by zyNoT
I will try that, but if I use ILMerge on the application and not even merging it with anything else, it works with the same code I posted above. It's just very strange.


I'm using newer VB.NET, not VB6.
Target = .NETFramework4+

Re: Pulling License Data results in crash of program

Posted: Wed Jan 23, 2019 7:45 am
by Enigma
For VB.NET to load a registration name and key, use functions EP_RegistrationLoadKeyA or EP_RegistrationLoadKeyW (depending on Registration Features - Common - Unicode option) from Enigma_IDE.vb.

It looks as following:

Code: Select all

    Public Shared Function EP_RegistrationLoadKeyA(ByRef Name As String, ByRef Key As String) As Boolean
        Name = InlineAssignHelper(Key, String.Empty)
        Dim namelen As Integer = 0, keylen As Integer = 0
        If EP_RegLoadKeyEx(IntPtr.Zero, namelen, IntPtr.Zero, keylen) <> LOADKEY_REGINFONOTFOUND Then
            Dim namebuf As Byte() = New Byte(namelen - 1) {}
            Dim keybuf As Byte() = New Byte(keylen - 1) {}
            If EP_RegLoadKeyEx(Marshal.UnsafeAddrOfPinnedArrayElement(namebuf, 0), namelen, Marshal.UnsafeAddrOfPinnedArrayElement(keybuf, 0), keylen) = LOADKEY_SUCCEEDED Then
                Name = Encoding.ASCII.GetString(namebuf)
                Key = Encoding.ASCII.GetString(keybuf)
                Return True
            End If
        End If
        Return False
    End Function