jeffkl / ManagedDism

A managed wrapper for the native Deployment Image Servicing and Management (DISM) API.
MIT License
88 stars 19 forks source link

Get and set Windows Editions #94

Open DrEmpiricism opened 4 years ago

DrEmpiricism commented 4 years ago

Any ideas how Dism does this? There is no DismApi documentation on it whatsoever.

One of the PowerShell scripts I use with this (and WimgApi) converts one offline Windows Image edition to another supported edition (i.e. Windows Home to Windows Pro for Workstations). WimgApi can be easily used to change the XML metadata of the image to the new edition's values; however, the DismApi documentations provides no details on how to natively return and/or set Windows Editions so one must use either the Dism command-line or PowerShell Dism cmdlet to do it.

Perhaps I'm missing something?

jeffkl commented 4 years ago

I looked at the source code to dism.exe and this API does not seem to be exposed in a public way. Its made available to dism.exe as sort of an extension. The implementation is in %WinDir%\System32\Dism\TransmogProvider.dll

C:\>dumpbin /exports C:\Windows\System32\Dism\TransmogProvider.dll
Microsoft (R) COFF/PE Dumper Version 14.27.28826.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file C:\Windows\System32\Dism\TransmogProvider.dll

File Type: DLL

  Section contains the following exports for TransmogProvider.DLL

    00000000 characteristics
    AB7A6446 time date stamp
        0.00 version
           1 ordinal base
           5 number of functions
           5 number of names

    ordinal hint RVA      name

          1    0 0001CA10 DLLGetDISMProviderCLSID
          2    1 0001CA40 DllCanUnloadNow
          3    2 0001CA80 DllGetClassObject
          4    3 0001CBC0 DllRegisterServer
          5    4 0001CD00 DllUnregisterServer

  Summary

        3000 .data
        3000 .pdata
       D8000 .rdata
        4000 .reloc
        5000 .rsrc
       5C000 .text
DrEmpiricism commented 4 years ago

Sorry for the delay in my response, but it appears from additional logs I have that DISM uses the TransmogProvider to 'ValidateTransmogrify' any commands that include getting or setting image index editions. Moreover, your dump clearly shows the functions that can be passed to the library.

When I have some free time I am going to toy around with that a bit and see if I can isolate code that can do anything with edition 'transmogrification' natively and will report back if I get anywhere with it.

Thanks for the help!