After obfuscating a WMI application it is giving error

94 Views Asked by At

The problem i am facing is...during the installation of my WMI application (which has obfuscated dlls) below error is shown: Incorrect usage of [ManagementBind] attribute on a method. 'a' on class 'ak' (ak, Myapp.MyProvider, Version=1.3.0.11, Culture=neutral, PublicKeyToken=213fdfdfdf32dfef) definition. It should be on a static method and there should be one matching parameter for every key defined. "

Please let me know how to resolve this error.

1

There are 1 best solutions below

4
On

It does not sounds logical to obfuscate everything in your WMI provider. Since the metadata (like the names of methods, parameters and classes) describes how your WMI provider looks at the outside. Do you want the users your WMI provider to have a WMI class named ak? And a WMI method named a? I would rather have a MySomethingProvider with a GetInstances method.

But even if you want your users having to deal with obfuscated names, I think this obfuscation does not go well with how the metadata of a Managed WMI Provider should look.

For example, here the ManagementName attribute points to ID, but I bet that obfuscating it will have given ID another name. That is why they don't match

[ManagementBind]
static public WIN32ServiceHost GetInstance([ManagementName("ID")] int processId)
{
}

[ManagementKey]
public int ID

After obfuscation string in ManagementName is still ID, but now the property ID is called A.

[ManagementBind]
static public WIN32ServiceHost a([ManagementName("ID")] int a)
{
}

[ManagementKey]
public int A

So either don't obfuscate at all or only the parts that are not public or are part of your WMI API.