Open source Windows 7 product key checker

Discussion in 'MDL Projects and Applications' started by Daz, Oct 15, 2009.

  1. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    ok, i will look into this... at the moment struggling to get my COM object to work on X64 system, damn incompatibilities :(
     
  2. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    i can test with my x64 machine if you want. and i think i used the x86 pidgenx.dll in mine and it works fine on a x64 machine
     
  3. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    I can't load pidgenx.dll (x86 taken form VAMT) on x64, it this dll from VAMT available in X64 version?
     
  4. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    can i look at your source?
     
  5. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    pm sent, so go check it ;)
     
  6. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
  7. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    #87 PAYMYRENT, Nov 10, 2009
    Last edited: Nov 11, 2009
    EDIT: Removed Link
     
  8. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    #88 MasterDisaster, Nov 10, 2009
    Last edited by a moderator: Apr 20, 2017
    DllImport looks for the dll in the current directory and then in the system directory. You cannot specify the path of the dll, only workaround is to change the current directory.

    Code:
    Environment.CurrentDirectory = @"C:\Win7";
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    FreeStyler sent you PM for DllImport workaround.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,460
    420
    60
    #90 PAYMYRENT, Nov 11, 2009
    Last edited by a moderator: Feb 27, 2013
    new link for the compiled version of my key checker

    and like before dont complain about it if you dont like it use the online one

    PIDCHECK ER
     
  11. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    #91 MasterDisaster, Nov 11, 2009
    Last edited by a moderator: Apr 20, 2017
    To load the dll from dynamic paths you need to call LoadLibrary() from kernel32.dll. Here's the code snippet on how to do it.

    Code:
    [DllImport("kernel32", SetLastError = true)]
    public static extern IntPtr LoadLibrary(string fileName);
    
    [DllImport("kernel32", SetLastError = true)]
    public static extern bool FreeLibrary(IntPtr hModule);
    
    [DllImport("pidgenx.dll", EntryPoint = "PidGenX", CharSet = CharSet.Auto)]
    static extern int PidGenX(string ProductKey, string PkeyPath, string MSPID, int UnknownUsage, IntPtr ProductID, IntPtr DigitalProductID, IntPtr DigitalProductID4);
    
    private string CheckProductKey(string ProductKey)
    {
        string dllPath = temp + "\\pidgenx.dll";        //temp is the folder path that has the dll and config file
        IntPtr dllHandle = LoadLibrary(dllPath);
        .
        .
        .
        string PKeyPath = temp + "\\pkeyconfig.xrm-ms";
        .
        .
        .
        Marshal.FreeHGlobal(PID);
        Marshal.FreeHGlobal(DPID);
        Marshal.FreeHGlobal(DPID4);
        bool clear  = true;
        while(clear)                                 //Must be run thrice in order to dereference the pointer
            clear = FreeLibrary(dllHandle); 
        return result;
    }
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    hey great, thx
    gonna give it a shot :)
     
  13. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    The error occurs when wrong arguments are passed to the unmanaged function.

    GetProcAddress is used along with Marshal.GetDelegateForFunctionPointer Method. Its an alternative method to DllImport which uses delegates to invoke the function.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    You got it to work without this error? weird... u used included VBScript example? (try to run it a few times in a row, after a while i got that error)
     
  15. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    If the VBScript is run from elevated prompt there is no error.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    I keep getting that error, even when ran from command prompt opened with Administrator privileges, what do OS do you run it on? X64 or X32?
     
  17. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    #98 MasterDisaster, Nov 12, 2009
    Last edited: Nov 12, 2009
    I run it on Vista 32 bit.

    EDIT: I am using the Visual Studio command Prompt.

    Checked it in normal command prompt and i get that error too.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. FreeStyler

    FreeStyler MDL Guru

    Jun 23, 2007
    3,557
    3,832
    120
    i'm @work now, here i have Vista X32 as well, but keep getting the error (@home i had the same issue, although this was X64)

    You altered the example by any chance? The first key (Win7) is being validated just fine, when it tries to validate the 2nd key (Vista) it fails with the error described using the VAMT pidgenx.dll
     
  19. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    No i did not alter the example file.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...