[UNSUPPORTED] Open 7 act*vator by Nononsence [revised by HotCarl] ;-)

Discussion in 'Windows 7' started by HotCarl, Oct 29, 2009.

  1. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30

    Yeah, its frustrating. I have been playing with it for a while...even took a look at Daz's REALbasic version and I am still baffled about what is going wrong. I am getting an obscure error code of "-2147024893" vs. "-2147024894" which means pkeyconfig.xrm-ms is missing...so I am at a total loss. :(
     
  2. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    -2147024809
    i get this every time :p
     
  3. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    #23 MasterDisaster, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    PidGenXX is actually PidGenX

    Your code works perfectly fine. Here's the rest of the code to get info.

    It is in C#
    PHP:
    if (RetID == 0)
    {
        
    byte[] pidb = new byte[100];
        for (
    int i 0pidb.Lengthi++)
        {
            
    pidb[i] = Marshal.ReadByte(genPIDi);
        }
        
    byte[] core = new byte[1272];
        for (
    int i 0core.Lengthi++)
        {
            
    core[i] = Marshal.ReadByte(DPID4i);
        }
        
    Encoding enc Encoding.ASCII;
        
    string pid enc.GetString(pidb).Replace("\0""");              //PID
        
    string epid enc.GetString(core896).Replace("\0""");   //Extendend PID
        
    string aid enc.GetString(core13672).Replace("\0"""); //Activation ID
        
    string edi enc.GetString(core28040).Replace("\0"""); //Edition
        
    string sub enc.GetString(core88820).Replace("\0"""); //SubType
        
    string lit enc.GetString(core101625).Replace("\0"""); //License Type
        
    string lic enc.GetString(core114420).Replace("\0"""); //License Channel
        
    string cid epid.Substring(83);                                         //Crypto ID
    }
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,254
    300
    #24 Daz, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,280
    210
    #25 Alphawaves, Nov 6, 2009
    Last edited: Nov 6, 2009
    Thanks guy's:)

    Im still a toddler when it comes to vb coding, heres what i did using your codes, i added 9 textboxs and 1 button to a form with this code:

    PHP:
    Imports System.Runtime.InteropServices
    Imports System
    .Text

    Public Class Form1
        
    Declare Auto Function PidGenX Lib "pidgenx.dll" (ByVal key As StringByVal pkeyconfigLocation As StringByVal mpcID As StringByVal unknown As IntegerByVal generatedPID As IntPtrByVal oldDigitalPID As IntPtrByVal digitalPID4 As IntPtr) As Integer

        
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load

        End Sub

        
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
            Dim serial 
    As String TextBox1.Text
            TextBox1
    .Clear()
            If 
    serial Nothing Then Exit Sub

            Dim genPID 
    As IntPtr Marshal.AllocHGlobal(100)
            
    Marshal.WriteByte(genPID0, &H32)
            
    Dim clearGenPID As Integer 0
            
    For clearGenPID 1 To 99
                Marshal
    .WriteByte(genPIDclearGenPID, &H0)
            
    Next clearGenPID

            Dim oldPID 
    As IntPtr Marshal.AllocHGlobal(164)
            
    Marshal.WriteByte(oldPID0, &HA4)
            
    Dim clearOldPID As Integer 0
            
    For clearOldPID 1 To 163
                Marshal
    .WriteByte(oldPIDclearOldPID, &H0)
            
    Next clearOldPID

            Dim DPID4 
    As IntPtr Marshal.AllocHGlobal(1272)
            
    Marshal.WriteByte(DPID40, &HF8)
            
    Marshal.WriteByte(DPID41, &H4)
            
    Dim clearDPID4 As Integer 0
            
    For clearDPID4 2 To 1271
                Marshal
    .WriteByte(DPID4clearDPID4, &H0)
            
    Next clearDPID4

            Dim pkeyconfig 
    As String Environment.GetFolderPath(Environment.SpecialFolder.System) + "\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms"
            
    Dim RetID As Integer PidGenX(serialpkeyconfig"XXXXX"0genPIDoldPIDDPID4)

            If 
    RetID 0 Then
                TextBox3
    .AppendText("Valid")
            ElseIf 
    RetID = -2147024894 Then
                TextBox1
    .AppendText("Error: pkeyconfig.xrm-ms is missing")
            ElseIf 
    RetID = -2147024809 Then
                TextBox1
    .AppendText("Error: Invalid arguments")
            ElseIf 
    RetID = -1979645695 Then
                TextBox1
    .AppendText("Error: Invalid key")
            Else
                
    TextBox1.AppendText("Error: Invalid key")
            
    End If


            If 
    RetID 0 Then
                Dim pidb 
    As Byte() = New Byte(99) {}
                For 
    As Integer 0 To pidb.Length 1
                    pidb
    (i) = Marshal.ReadByte(genPIDi)
                
    Next
                Dim core 
    As Byte() = New Byte(1271) {}
                For 
    As Integer 0 To core.Length 1
                    core
    (i) = Marshal.ReadByte(DPID4i)
                
    Next
                Dim enc 
    As Encoding Encoding.ASCII
                Dim pid 
    As String enc.GetString(pidb).Replace(vbNullChar"")
                
    TextBox2.Text pid
                
    'PID 
                Dim epid As String = enc.GetString(core, 8, 96).Replace(vbNullChar, "")
                            '
    Extendend PID 
                Dim aid 
    As String enc.GetString(core13672).Replace(vbNullChar"")
                
    TextBox4.Text aid
                
    'Activation ID 
                Dim edi As String = enc.GetString(core, 280, 40).Replace(vbNullChar, "")
                TextBox5.Text = edi
                '
    Edition 
                Dim 
    [sub] As String enc.GetString(core88820).Replace(vbNullChar"")
                
    TextBox6.Text = [sub]
                
    'SubType 
                Dim lit As String = enc.GetString(core, 1016, 25).Replace(vbNullChar, "")
                TextBox7.Text = lit
                '
    License Type 
                Dim lic 
    As String enc.GetString(core114420).Replace(vbNullChar"")
                
    'License Channel 
                '
    Crypto ID 
                Dim cid 
    As String epid.Substring(83)
                
    TextBox8.Text cid
            End 
    If
        
    End Sub
    End 
    Class

    I think it worked:)

    Alfa:);)
     
  6. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    lolz...everyone can get it to work but not me. Thanks for the help guys, I appreciate it...

    BTW, it does not patter whether I call it PidGenX or PidGenXX, that is just the function name associated with the call... :)
     
  7. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,254
    300
    #27 Daz, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    @ HotCarl
    Actually it does, how else do you think the DLL will know what function to use without using "Alias" either? :p

    Code:
    Declare Auto Function OooItsCustom Lib "pidgenx.dll" Alias "PidGenX" (WindowsKey As String, PkeyPath As String, MPCID As String, UnknownUsage As IntPtr, GeneratedProductID As IntPtr, OldDigitalProductID As IntPtr, DigitalProductID As IntPtr) As Integer
    Or
    Code:
    Declare Auto Function PidGenX Lib "pidgenx.dll" (WindowsKey As String, PkeyPath As String, MPCID As String, UnknownUsage As IntPtr, GeneratedProductID As IntPtr, OldDigitalProductID As IntPtr, DigitalProductID As IntPtr) As Integer
    Anything else will likely throw an error of some sort.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    #28 HotCarl, Nov 6, 2009
    Last edited: Nov 6, 2009
    (OP)

    Ok, I guess it does. That is odd, because I was getting the same error no matter what I called the function... Now it seems to work with how alpha has set it up. Too weird...

    It works now though. Thanks lol...all I did was change the name to PidGenX like you said. It just didnt seem like that would fix it since I got the same error when I named it PidGenX or PidGenXX...but it worked this time.


    Thanks Daz and alphawaves and PAYMYRENT :D


    EDIT: atleast now I know what the error code "-2147024893" means now... :p
     
  9. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    #29 HotCarl, Nov 6, 2009
    Last edited by a moderator: Apr 20, 2017
    (OP)
    In the name of open source, here is what I have now:
    Code:
        Declare Auto Function PidGenX Lib "pidgenx.dll" (ByVal one As String, ByVal two As String, ByVal three As String, ByVal four As Integer, ByVal five As IntPtr, ByVal six As IntPtr, ByVal seven As IntPtr) As Integer
    
        Private Sub Check_Product_Key()
    
            Dim serial As String = keyTextBox.Text
            keyTextBox.Clear()
            If serial = Nothing Then Exit Sub
    
            Dim genPID As IntPtr = Marshal.AllocHGlobal(100)
            Marshal.WriteByte(genPID, 0, &H32)
            Dim clearGenPID As Integer = 0
            For clearGenPID = 1 To 99
                Marshal.WriteByte(genPID, clearGenPID, &H0)
            Next clearGenPID
    
            Dim oldPID As IntPtr = Marshal.AllocHGlobal(164)
            Marshal.WriteByte(oldPID, 0, &HA4)
            Dim clearOldPID As Integer = 0
            For clearOldPID = 1 To 163
                Marshal.WriteByte(oldPID, clearOldPID, &H0)
            Next clearOldPID
    
            Dim DPID4 As IntPtr = Marshal.AllocHGlobal(1272)
            Marshal.WriteByte(DPID4, 0, &HF8)
            Marshal.WriteByte(DPID4, 1, &H4)
            Dim clearDPID4 As Integer = 0
            For clearDPID4 = 2 To 1271
                Marshal.WriteByte(DPID4, clearDPID4, &H0)
            Next clearDPID4
    
            Dim pkeyconfig As String = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms"
            Dim RetID As Integer = PidGenX(serial, pkeyconfig, "XXXXX", 0, genPID, oldPID, DPID4)
    
            If RetID = 0 Then
                outputTextBox.AppendText("Valid")
            ElseIf RetID = -2147024893 Then
                outputTextBox.AppendText("Error: invalid function call")
                outputTextBox.AppendText("Must call 'PidGenX'")
            ElseIf RetID = -2147024894 Then
                outputTextBox.AppendText("Error: pkeyconfig.xrm-ms is missing")
            ElseIf RetID = -2147024809 Then
                outputTextBox.AppendText("Error: Invalid arguments")
            ElseIf RetID = -1979645695 Then
                outputTextBox.AppendText("Error: Invalid key")
            Else
                outputTextBox.AppendText("Error: Invalid key")
            End If
        End Sub
    
    Works great!
     
  10. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,254
    300
    @ HotCarl
    Not sure why you are filling up with nulls, shouldn't be required (as shown via the code I posted). Also you have converted the integers to hex? :confused:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    #31 HotCarl, Nov 6, 2009
    Last edited: Nov 6, 2009
    (OP)
    I guess it isnt necessary, was just clearing that memory space beforehand...
    I can remove it...it just worked perfectly now and I have been messing with it a while, so I didnt want to jinx it :p
    Yes, it does not matter whether you pass hex (as long as the hex represents the intended integer) or integer to the Marshaler, it will still do it's thing with the WriteByte() method. :)

    Thanks Daz, you have been very helpful. +1 repped you and PAYMYRENT. I tried to +rep alpha but then it said I gave out too much rep :( so I will have to do it tomorrow...
     
  12. Daz

    Daz MDL Developer / Admin
    Staff Member

    Jul 31, 2009
    9,534
    67,254
    300
    #32 Daz, Nov 6, 2009
    Last edited: Nov 6, 2009
    Understandable, I can be the same when something that was hard to get working isn't (a complex fiddly API) and then I get it working. It's just odd though since you said you looked at my source that gives them as integers :p

    You're welcome though, it was something I have been meaning to do but never got around to it. If you get it displaying the outputs feel free to drop it in the open source thread I created for it, I already wrote it in 2 languages but this would be a good addiction :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    Yeah...I looked at your source. It just kept on giving me errors no matter what I did, so I tried using hex, then zeroing everything else out beforehand to be sure I was not passing any bad data...

    I am just so glad it works now, I dont wanna mess with it anymore... :p
     
  14. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30

    Just got back from class...

    Yeah, as soon as I get the function done the way I want it, I will be sure to post it in your open source thread. Thanks so much Daz, you are the man. :)
     
  15. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    Updated OP with new v1.0.6 release of O7A. :)

    Temporarily disabled the Activation Backup until the next version until I can fix it...
    Wanted to release this version though because it incorporates the product key checker I wanted to incorporate in the last version.

    Enjoy, and as always, thanks for the suggestions, insights, and help. :D
     
  16. Opa

    Opa MDL Addicted

    Jul 29, 2009
    679
    969
    30
    #36 Opa, Nov 7, 2009
    Last edited: Nov 7, 2009
    good job Carl :D
     
  17. HotCarl

    HotCarl MDL Addicted

    Jul 21, 2009
    831
    16
    30
    #37 HotCarl, Nov 7, 2009
    Last edited by a moderator: Apr 20, 2017
    (OP)

    Thank you :)

    As soon as I figure out to stop/pause the Software Protection Service "sppsvc" in order to restore activation (copy tokens.dat and pkeyconfig.xrm-ms that the user has previously backed-up to their original locations), then I will re-implement the activation backup. No matter what I do in my VB code, sppsvc will not die :p

    Code:
    Imports System.ServiceProcess
    
    Dim sppsvc As New ServiceController
    
    sppsvc.MachineName = "."
    sppsvc.ServiceName = "sppsvc"
    Dim status As String = sppsvc.Status.ToString 'Debug...
    
    'Stop the service
    If status = "Running" Then sppsvc.Stop()
    
    status = sppsvc.Status.ToString 'Debug...
    
    '...code here to restore activation...
    
    If sppsvc.Status.ToString <> "Running" Then sppsvc.Start()
    
    Neither the .Stop() nor the .Pause() methods work on sppsvc, so I have to figure something else out...
     
  18. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,280
    210
    #38 Alphawaves, Nov 7, 2009
    Last edited: Nov 7, 2009
    Will this not work?


    Stop:
    PHP:
     Interaction.Shell("net stop sppsvc"AppWinStyle.MinimizedFocusFalse, -1)
    Start:
    PHP:
     Interaction.Shell("net start sppsvc"AppWinStyle.MinimizedFocusFalse, -1)
    Alfa:)
     
  19. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    ill give you my code for the activation back up when i rewrite it
     
  20. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    #40 PAYMYRENT, Nov 7, 2009
    Last edited by a moderator: Apr 20, 2017
    this is how i did it in token restore maybe you can use it




    Code:
    
            Dim sppsvcoff As New Process
            With sppsvcoff
                .StartInfo.FileName = "sc"
                .StartInfo.Arguments = " stop sppsvc"
                .StartInfo.UseShellExecute = True
                .StartInfo.CreateNoWindow = True
                .StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                .Start()
            End With
            Do Until sppsvcoff.HasExited = True
                Application.DoEvents()
                System.Threading.Thread.Sleep(10)
            Loop
    
            Dim sppsvcon As New Process
            With sppsvcon
                .StartInfo.FileName = "sc"
                .StartInfo.Arguments = " start sppsvc"
                .StartInfo.UseShellExecute = True
                .StartInfo.CreateNoWindow = True
                .StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                .Start()
            End With
            Do Until sppsvcon.HasExited = True
                Application.DoEvents()
                System.Threading.Thread.Sleep(10)
            Loop
    
    
    
    

    oh i almost forgot

    if you add a backgroundworker to the product key checker the ui will not freeze at least it didnt freeze when i tested it