Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given a .winmd file, where can we find the real implementation DLL?

I have question that given a .winmd file, where can we find the real implementation is? .winmd files just like a head file or dynamic library's .lib file, it doesn't contain any implementation, I curious that where is its implementation. Thanks.

like image 529
codewarrior Avatar asked Mar 12 '14 07:03

codewarrior


3 Answers

Disclaimer: This answer describes undocumented implementation details that can change at any time without prior notice.

For types defined in Windows.winmd or any .winmd in C:\windows\system32\WinMetadata, the registry will point you to the actual implementation.

Look for the name of the type at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId\SystemSettings.DataModel.SettingsDatabase and the DllPath value will contain the DLL that implements the type.

like image 200
kiewic Avatar answered Nov 09 '22 09:11

kiewic


You can't. A .winmd file just contains type declarations, it contains no code. It is the exact equivalent to a type library (.tlb) as used in COM Automation. The logical equivalent to a .h file in a C or C++ program.

The .tlb format was too restrictive to support WinRT and was re-engineered into .winmd, the format of the file is identical to .NET metadata and you can use .NET tooling (like ildasm.exe) to see its content. A compiler uses it to know how to generate proper code to use a WinRT component, just like a C++ compiler knows how to use a class library by #including a .h file that contains the class declarations.

And just like a .h file, it is up to you to figure out what executable file implements the types and to deploy it to the user's machine. Unless it is Windows.winmd, the one that declares all the built-in WinRT types, you'd expect the binary component to be very close to the .winmd file. Store requires you to include that binary component in your package. Ask the author of the component for help if you need assistance.

like image 22
Hans Passant Avatar answered Nov 09 '22 10:11

Hans Passant


Hans is pretty much spot on. A winmd file just describes a type's shape (used for the CLR and JS language projection at runtime and the C++ compiler at compile time). At runtime, the RoActivateInstance API (or the RoGetActivationFactory API) take the type name and return an object that implements that type.

For an app specific type, the package manifest's ActivatableClassId entry describes the location of the implementation of the runtime class. For a system specific type, it's located in the registry, but the location of the type may change at any time in the future.

like image 1
ReinstateMonica Larry Osterman Avatar answered Nov 09 '22 10:11

ReinstateMonica Larry Osterman