Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting... Please check out the Community Guidelines in the
Announcements and Administration Category, below.

WMI Provider

This is a very general question. I am trying to create a WMI Provider. I used the sample named "InstProv", which is a microsoft provided sample available in WindowsSDK7-Samples

https://github.com/pauldotknopf/WindowsSDK7-Samples/tree/master/sysmgmt/wmi/vc/instprov

What I have done:
1. I opened the sample project using visual studio 2013 and run build command.
2. I loaded the dll using the command regsvr32 InstProv.dll
3. I compiled the mof file the command mofcomp instprov.mof
4. I opened a powershelll ant typed the following command
Get-WmiObject -namespace root\default InstProvSamp

The result is following

Name Methods Properties
--------- ------- ----------
InstProvSamp {} {MyKey, MyValue}

5. Get-WmiObject -namespace root\default InstProvSamp
it gives the following result

__GENUS : 2
__CLASS : InstProvSamp
__SUPERCLASS :
__DYNASTY : InstProvSamp
__RELPATH : InstProvSamp.MyKey="a"
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER : JACK-W02
__NAMESPACE : root\default
__PATH : \\JACK-W02\root\default:InstProvSamp.MyKey="a"
MyKey : a
MyValue : 1
PSComputerName : JACK-W02
*
*
*
*******************************************************


In a nut shell, everything works fine !!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Real Issue
Just copy the binaries to a different machine and repeat steps 2 to 5. You can see following error on the fifth step,

Get-WmiObject : Provider load failure
At line:1 char:2
+ Get-WmiObject -namespace root\default InstProvSamp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

I am very curious about this issue. It is fresh sample and i did not modify anything. Any help will be much appreciated.

Important Points to take are when you load dll on another machine:
1. the dll wont load on other machines, unless you change the run time library to Multi-threaded (/MT)

I invite your suggestions as this is a high priority issue for me

Comments

  • Tim_RobertsTim_Roberts Posts: 12,568
    On Oct 21, 2017, at 12:20 AM, xxxxx@gmail.com <xxxxx@lists.osr.com> wrote:
    >
    > Real Issue
    > Just copy the binaries to a different machine and repeat steps 2 to 5. You can see following error on the fifth step,
    >
    > Get-WmiObject : Provider load failure

    Is it possible you built a 64-bit binary and this is a 32-bit system? Are they the same operating systems?

    You might see if you can find a copy of Depends.exe and run it on the second system to see if there is some missing DLL.

    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Hey Tim
    Thank you very much for your quick reply.

    >>>>>Are they the same operating systems?
    Yes. They are Windows 10 64 bit machines,, one with visual studio installed and other is a test machine.

    >>>>>>>>>You might see if you can find a copy of Depends.exe and run it on the =
    >>>>>>>>>second system to see if there is some missing DLL.
    I tried running depend.exe on both machines and obtained exactly similar results.
    There were two types on errors.

    1. "Error opeing files. System cannot find the path specified (2").(It complaints about missing API-MS-WIN-XXX- XXX.dll files)

    2."Modules with different CPU types were found". ( It complaints about lots of system DLLs like kernel32.dll,GDI32.dll,NTDLL.dll, stating that the CPU types of these DLLs are x64)

    Still, I did not get a clue how it works on first machine.


    One important Point:

    The sample project has only one configuration type listed under the configuration properties. I could not choose x64 while building my project. Is it better two rewrite the sample by creating an empty Dll project and building it in x64 mode?

    I really appreciate your help on this


    Thanks
    Midhun.k
  • Hi midhun,

    Could you please check that you were building the project in release
    mode...to recheck it...

    Its look like dll missing and not executed.

    Regards,
    Prabhakar V

    On Sat, Oct 21, 2017 at 11:26 PM, xxxxx@gmail.com
    wrote:

    > Hey Tim
    > Thank you very much for your quick reply.
    >
    > >>>>>Are they the same operating systems?
    > Yes. They are Windows 10 64 bit machines,, one with visual studio
    > installed and other is a test machine.
    >
    > >>>>>>>>>You might see if you can find a copy of Depends.exe and run it on
    > the =
    > >>>>>>>>>second system to see if there is some missing DLL.
    > I tried running depend.exe on both machines and obtained exactly similar
    > results.
    > There were two types on errors.
    >
    > 1. "Error opeing files. System cannot find the path specified (2").(It
    > complaints about missing API-MS-WIN-XXX- XXX.dll files)
    >
    > 2."Modules with different CPU types were found". ( It complaints about
    > lots of system DLLs like kernel32.dll,GDI32.dll,NTDLL.dll, stating that
    > the CPU types of these DLLs are x64)
    >
    > Still, I did not get a clue how it works on first machine.
    >
    >
    > One important Point:
    >
    > The sample project has only one configuration type listed under the
    > configuration properties. I could not choose x64 while building my project.
    > Is it better two rewrite the sample by creating an empty Dll project and
    > building it in x64 mode?
    >
    > I really appreciate your help on this
    >
    >
    > Thanks
    > Midhun.k
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > Visit the list online at: showlists.cfm?list=ntdev>
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and
    > software drivers!
    > Details at
    >
    > To unsubscribe, visit the List Server section of OSR Online at <
    > http://www.osronline.com/page.cfm?name=ListServer>;
    >
  • Hey Prabhakar

    >>>>> Could you please check that you were building the project in release
    >>>>> mode...to recheck it...

    I tried to build the project both in release mode and debug mode. In both cases, the .dll is loaded successfully. The error comes only in step no .5

    Thanks
    Midhun.k
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!