Jump to content
Krakatoa

PidGenX UDF and example PidChecker

Recommended Posts

Krakatoa
Posted (edited)

PidGenX UDF

PidGenX.au3

; ===========================================================================
; Title:          PidGenX
; AutoIt Version: 3.3.14.5
; Author:         Krakatoa
; Description:    Windows and Office Pid Checker
; Parameters:
;   $ProductKey   Product Key
;   $PKeyPath     xrm-ms file path
; Return Value:
;   Success:      array
;     [0] = ProductID
;     [1] = ExtendedPID
;     [2] = ActivationID
;     [3] = EditionType
;     [4] = EditionID
;     [5] = KeyType
;     [6] = EULA
;   Failure:
;     1 - Error in DllStructCreate
;     2 - Error in DllCall
;     3 - Invalid Arguments
;     4 - Invalid Key
;     5 - File xrm.ms not found
;     6 - Invalid Input
; ===========================================================================

Global Const $PIDGENX_PRODUCTID    = 0
Global Const $PIDGENX_EXTENDEDPID  = 1
Global Const $PIDGENX_ACTIVATIONID = 2
Global Const $PIDGENX_EDITIONTYPE  = 3
Global Const $PIDGENX_EDITIONID    = 4
Global Const $PIDGENX_KEYTYPE      = 5
Global Const $PIDGENX_EULA         = 6

Func _PidGenX ($ProductKey, $PKeyPath)

    $PID = DllStructCreate("byte[50]")
    If @error Then Return SetError(1, 1, "Error in DllStructCreate")
    DllStructSetData($PID, 1, 50, 1)
    $DPID = DllStructCreate("byte[164]")
    If @error Then Return SetError(1, 2, "Error in DllStructCreate")
    DllStructSetData($DPID, 1, 164, 1)
    $DPID4 = DllStructCreate("byte[1272]")
    If @error Then Return SetError(1, 3, "Error in DllStructCreate")
    DllStructSetData($DPID4, 1, 248, 1)
    DllStructSetData($DPID4, 1, 4, 2)
    $result = DllCall("PidGenX.dll", "int", "PidGenX", _
      "wstr", $ProductKey, _
      "wstr", $PKeyPath, _
      "wstr", "00000", _
      "int", 0, _
      "INT_PTR", DllStructGetPtr($PID), _
      "INT_PTR", DllStructGetPtr($DPID), _
      "INT_PTR", DllStructGetPtr($DPID4))
    If @error Then Return SetError(2, 0, "Error in DllCall")
    If $result[0] = 0 Then
        Local $PidGenX[7]
        $PidGenX[0] = StringStripWS(BinaryToString(DllStructGetData($PID, 1), 2),15)
        $dpid4Result = DllStructGetData($DPID4, 1)
        $PidGenX[1] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 9, 128), 2),15)
        $PidGenX[2] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 137, 128), 2),15)
        $PidGenX[3] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 281, 512), 2),15)
        $PidGenX[4] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 889, 128), 2),15)
        $PidGenX[5] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 1017, 128), 2),15)
        $PidGenX[6] = StringStripWS(BinaryToString(BinaryMid($dpid4Result, 1145, 128), 2),15)
        Return $PidGenX
    Else
        If($result[0] == -2147024809) Then
            Return SetError(3, 0, "Invalid Arguments")
        ElseIf($result[0] == -1979645695) Then
            Return SetError(4, 0, "Invalid Key")
        ElseIf($result[0] == -2147024894) Then
            Return SetError(5, 0, "File xrm.ms not found")
        Else
            Return SetError(6, 0, "Invalid Input")
        EndIf
    EndIf

EndFunc

Example PidChecker

PidChecker.au3

#include "PidGenX.au3"
Opt("TrayIconHide", 1)

$hGUI = GUICreate("PidChecker", 540, 340)

GUICtrlCreateGroup("xrm-ms file path", 10, 10, 420, 55)
$idComboBox = GUICtrlCreateCombo("C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms", 20, 30, 400, 20)
GUICtrlSetData($idComboBox, _
    "C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig-downlevel.xrm-ms" & _
    "|" & "C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig-csvlk.xrm-ms" & _
    "|" & @ScriptDir & "\xrm-ms\win81_pkeyconfig.xrm-ms" & _
    "|" & @ScriptDir & "\xrm-ms\win7_pkeyconfig.xrm-ms" & _
    "|C:\Program Files\Microsoft Office\root\Office16\pkeyconfig-office.xrm-ms" & _
    "|C:\Program Files\Microsoft Office\root\Office15\pkeyconfig-office.xrm-ms")
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Product Key", 10, 75, 420, 55)
$Input = GUICtrlCreateInput("", 20, 95, 260, 20)
$idCheck = GUICtrlCreateButton("CHECK", 320, 90, 85, 30)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Output Data", 10, 140, 520, 185)
$info = GUICtrlCreateEdit( "", 20, 160, 500, 150, 2048)
GUICtrlSetFont($info, 9, 0, 0, "Consolas")
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case -3
            ExitLoop
        Case $idCheck
            $aPidGenX = _PidGenX (GUICtrlRead($Input), GUICtrlRead($idComboBox))
            If @error Then
                $Output  = _
                    "Product Key:   " & GUICtrlRead($Input) & @CRLF & _
                    "Error:         " & $aPidGenX
                GUICtrlSetData($info, $Output)
            Else
                $Output  = _
                    "Product Key:   " & GUICtrlRead($Input) & @CRLF & _
                    "Key Status:    " & "Valid" & @CRLF & _
                    "Product ID:    " & $aPidGenX[$PIDGENX_PRODUCTID] & @CRLF & _
                    "Extended PID:  " & $aPidGenX[$PIDGENX_EXTENDEDPID] & @CRLF & _
                    "Activation ID: " & $aPidGenX[$PIDGENX_ACTIVATIONID] & @CRLF & _
                    "Edition Type:  " & $aPidGenX[$PIDGENX_EDITIONTYPE] & @CRLF & _
                    "Edition ID:    " & $aPidGenX[$PIDGENX_EDITIONID] & @CRLF & _
                    "Key Type:      " & $aPidGenX[$PIDGENX_KEYTYPE] & @CRLF & _
                    "EULA:          " & $aPidGenX[$PIDGENX_EULA]
                GUICtrlSetData($info, $Output)
                GUICtrlSetState ($info, 256)
            EndIf
    EndSwitch
WEnd

GUIDelete($hGUI)

Info for example PidChecker:

  • Windows 10 installed (C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms = Windows 10 xrm-ms file)
  • Office 2016/2019 installed (C:\Program Files\Microsoft Office\root\Office16\pkeyconfig-office.xrm-ms = Office 2016/2019 xrm-ms file)
  • Office 2016/2019 installed (C:\Program Files\Microsoft Office\root\Office15\pkeyconfig-office.xrm-ms = Office 2013 xrm-ms file)
  • "\xrm-ms\win81_pkeyconfig.xrm-ms" from Windows 8.1 iso
  • "\xrm-ms\win7_pkeyconfig.xrm-ms" from Windows 7 iso

Screen:

PidChecker.png.d6788b9514f68e247277a556d58027ec.png

Edited by Krakatoa
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×