2

I want to extend the original File DSC resource to add support for ensuring that files not present in the source are deleted in the destination. To do this, I'd like to know at least how the original one is implemented by checking it's code on a disassembler or try to find it's implementation in places like ReferenceSource, but I can't for the life of me find where the dll that implements the resource is located on my computer.

When I issue a Get-DscResource File command in PowerShell, the Module property is empty. I then tried inspecting the object itself to see if anything came up, but the Path property is also empty, while the ParentPath property points to C:\Windows\system32\Configuration\Schema\MSFT_FileDirectoryConfiguration, which only contains the metadata files and not the binary dll.

I know I could probably work around this using the method described in the other question I linked, but we need a lot of folders with this behavior and it would be a problem to maintain those scripts like that.

Ideally it would be possible to extend the original class and add this behavior to it, but I'm not counting on this being possible. I just wanted to have the original implementation as a baseline to add this feature.

With all this in mind, where can I find the actual dll that implements the functionality of a given binary DSC resource?

Community
  • 1
  • 1
julealgon
  • 7,072
  • 3
  • 32
  • 77

1 Answers1

2

I've done a little bit of digging around and unless I've missed something painfully obvious, I think the File resource lives in "C:\Windows\System32\DscCoreConfProv.dll".

You've already found MSFT_FileDirectoryConfiguration - the WMI class for this lives in the root\Microsoft\Windows\DesiredStateConfiguration namespace:

> Get-WmiObject -Namespace "root\Microsoft\Windows\DesiredStateConfiguration" -List | `
  Where-Object { $_.Name -eq "MSFT_FileDirectoryConfiguration" } | `
  ft

   NameSpace: ROOT\Microsoft\Windows\DesiredStateConfiguration

Name                                Methods              Properties
----                                -------              ----------
MSFT_FileDirectoryConfiguration     {GetTargetResourc... {Attributes,     Checksum, Contents, CreatedDate...}

and that's handled by the dsccore and DSCCoreProviders WMI Providers:

> Get-WmiObject -Namespace "root\Microsoft\Windows\DesiredStateConfiguration" -Class "__Win32Provider" | `
  Select-Object @( "Name", "CLSID" ) | `
  ft *

Name             CLSID
----             -----
dsccore          {BADCC35D-8542-4A5C-A457-0ECCCF62508A}
DSCCoreProviders {F04C3F9B-20B3-40E1-A824-3A41FE3D7931}

Assuming it's the DSCCoreProviders provider, find the dll behind the CLSID:

> New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT"
> (Get-ItemProperty -LiteralPath "HKCR:\CLSID\{F04C3F9B-20B3-40E1-A824-3A41FE3D7931}\InProcServer32")."(default)"

C:\Windows\system32\DscCoreConfProv.dll

However, after all that, the file isn't a .NET Framework dll, so you might have trouble disassembling it.

mclayton
  • 8,025
  • 2
  • 21
  • 26
  • Amazing stuff... I feel frustrated for not knowing how this stuff works. I know nothing about WMI or even CLSID, even though I've heard about and saw them a number of times. It's the same feeling of working with ASP.Net Web Forms knowing almost nothing of CSS, html and JavaScript. The fact that it is a native dll is a bummer though... I was hoping for a .Net dll. I really don't want to reimplement the potentially complex logic that this resource is already doing. I'm not even capable of validating your answer, so if you could perhaps confirm it is there I'd mark it as the answer. – julealgon May 15 '15 at 19:03