Pulling License Data results in crash of program

Post here messages if you have any problems with working of Enigma Protector
Post Reply
zyNoT
Posts: 4
Joined: Fri Nov 03, 2017 5:49 am

Pulling License Data results in crash of program

Post by zyNoT » Mon Jan 21, 2019 11:38 pm

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?

Enigma
Site Admin
Posts: 2521
Joined: Wed Aug 20, 2008 2:24 pm

Re: Pulling License Data results in crash of program

Post by Enigma » Tue Jan 22, 2019 11:29 am

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

zyNoT
Posts: 4
Joined: Fri Nov 03, 2017 5:49 am

Re: Pulling License Data results in crash of program

Post by zyNoT » Tue Jan 22, 2019 9:02 pm

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+

Enigma
Site Admin
Posts: 2521
Joined: Wed Aug 20, 2008 2:24 pm

Re: Pulling License Data results in crash of program

Post by Enigma » Wed Jan 23, 2019 7:45 am

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

Post Reply