|
Thanks for the pointers, I guess you are right. I am shooting in dark, I will go through the book by Don Box.
Well since I am calling WMI from inside a WMI Provider calling CoInitializeSecurity[^] gives me error. Let me check out the CoQueryProxyBlanket[^].
I couldn't get back since I don't have a internet connection at me residence, it will get up and running this weekend. Hopefully then there won't be such a long gap.
|
|
|
|
|
Thanks for the pointers, I was able to solve the problem. Actually inside the WMI Provider I was not cloaking the call to next call of WMI. I did this and it works perfectly fine:
hr = CoSetProxyBlanket(WbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_DEFAULT ,
NULL, RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DYNAMIC_CLOAKING);
The last parameter I set as EOAC_DYNAMIC_CLOAKING.
|
|
|
|
|
In a programme there is a follwing error message from the system..
message
"The .Net Data OLE DB Provider(System.Oledb.Data) requires Microsoft Data Access Components(MDAC)version 2.6 or later, version 2.10.3711.9 was found currently installed"
This result the database connection not working, pl. any one to help to solve this problem
rajagopal
rajkottayam@rediffmail.com
|
|
|
|
|
I have loaded a Typelib of ("C:\\WINDOWS\\system32\\FM20.DLL")
ITypeLib* m_pTypeLib;
HRESULT hr = ::LoadTypeLib(ws_type_lib_file.c_str(), &m_pTypeLib);
And got the TypeInfo of below Guid
CString strClsid= "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}";
CLSID clsid;
BSTR bstrClassId;
bstrClassId = strClsid.AllocSysString();
VERIFY(NOERROR == CLSIDFromString(bstrClassId, &clsid));
::SysFreeString(bstrClassId);
ITypeInfo* m_pCurITypeInfo;
m_pTypeLib->GetTypeInfoOfGuid(clsid,&m_pCurITypeInfo);
This is an co class. Which has two interface.(Copied form Ole view)
[
uuid(8BD21D40-EC42-11CE-9E0D-00AA006002F3),
helpcontext(0x001e8656),
noncreatable,
control
]
coclass CheckBox {
[default] interface IMdcCheckBox;
[default, source] dispinterface MdcCheckBoxEvents;
};
How can I get the default interface of this coclass.Actually i need need the property and method name of IMdcCheckBox.(But i will not be having the Giud of IMdcCheckBox)
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Try the __uuidof operator on IMdcCheckBox
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Auctully i need to get the CoClass default interface,as in C++\CLI:
Interop.Microsoft.TLI.InterfaceInfo DefaultInterface { get; }
(Member of Interop.Microsoft.TLI.CoClassInfo)
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Hello vibindia,
Try out the following code :
int main()
{
ITypeLib* pITypeLib = NULL;
HRESULT hrRet = S_OK;
hrRet = LoadTypeLibEx
(
(LPCOLESTR)(L"C:\\WINDOWS\\system32\\FM20.DLL"),
(ITypeLib**)&pITypeLib
);
if (pITypeLib)
{
ITypeInfo *pITypeInfo_Coclass = NULL;
CLSID clsid;
CLSIDFromString
(
L"{8BD21D40-EC42-11CE-9E0D-00AA006002F3}",
&clsid
);
pITypeLib -> GetTypeInfoOfGuid(clsid, &pITypeInfo_Coclass);
if (pITypeInfo_Coclass)
{
TYPEATTR* pTYPEATTR = NULL ;
pITypeInfo_Coclass -> GetTypeAttr (&pTYPEATTR);
// For each implemented interface in this coclass, get its name and determine if it is the default interface.
int i ;
for (i = 0 ; i < (pTYPEATTR->cImplTypes); i ++)
{
HREFTYPE hRefType = NULL;
pITypeInfo_Coclass->GetRefTypeOfImplType (i, &hRefType);
if (hRefType)
{
ITypeInfo* pRefTypeInfo = NULL;
BSTR bstrName = NULL;
pITypeInfo_Coclass->GetRefTypeInfo (hRefType, &pRefTypeInfo);
if (pRefTypeInfo)
{
pRefTypeInfo->GetDocumentation(MEMBERID_NIL, &bstrName, NULL, NULL, NULL);
int iImplTypeFlags = 0;
pITypeInfo_Coclass->GetImplTypeFlags
(
i,
&iImplTypeFlags
);
if (iImplTypeFlags & IMPLTYPEFLAG_FDEFAULT)
{
if (iImplTypeFlags & IMPLTYPEFLAG_FSOURCE)
{
printf ("[default, source] interface is [%s].\r\n", (LPCTSTR)_bstr_t(bstrName));
}
else
{
printf ("[default] interface is [%s].\r\n", (LPCTSTR)_bstr_t(bstrName));
}
}
pRefTypeInfo->Release();
pRefTypeInfo = NULL;
}
if (bstrName)
{
::SysFreeString(bstrName);
bstrName = NULL;
}
}
}
pITypeInfo_Coclass->ReleaseTypeAttr(pTYPEATTR);
pTYPEATTR = NULL;
pITypeInfo_Coclass->Release();
pITypeInfo_Coclass = NULL;
}
pITypeLib->Release();
pITypeLib = NULL;
}
return 0;
}
Note that there could be two default interfaces : one being the default incoming interface (i.e. [default]) and the other a default source interface (i.e. [default, source].
The important method to use is ITypeInfo::GetImplTypeFlags(). Call it on the ITypeInfo interface of the coclass that you are interested in e.g. :
pITypeInfo_Coclass->GetImplTypeFlags
(
i,
&iImplTypeFlags
);
This method will return a IMPLTYPEFLAGS. The code to obtain the default interface should be self-explanatory.
The calls to GetRefTypeOfImplType() and GetRefTypeInfo() are so that we can get the ITypeInfo interface on each of the interfaces of the coclass.
Best Regards,
Bio.
modified on Monday, June 8, 2009 12:08 AM
|
|
|
|
|
Hi,
This is manjari.I hv some problem while customise the print dialog.In comdlg32.dll -in dialogs-i hv inserted some controls for customise for username and password in no of copies panel.i want to replace the customised comdlg32.dll in systm32.here i used one patch wfp10 for disabling the windows file protection .then i used inuse for replacing the comdlg and rebooting.but it didnt replace.tell me the process how to do.plz help me as soon as possible.
thanks,
regards,
manjari
How i will design a a form in windows service to print a document.
|
|
|
|
|
Hi,
I happen to create a WMI push provider, when I am creating the instance of it I get the error.
The provider is written in VC++, I was wondering if there is a way of debugging the code when I try to create the instance through WMI Studio.
I had tried by attaching the debugging process in Visual Studio to "wmiprvse.exe", but could not find a solution.
Thanks
Krish
|
|
|
|
|
Same as debugging any in-process (i.e. DLL based) COM server - specify the executable that will be creating instances of it.
So, open the WMI providers project/solution in VC++. In the project properties, set the debug executable to be WMI Studio. Set breakpoints in your DLL's source code. Debug the project - WMI Studio should start, so you can do what you need to instantiate your provider and start debugging!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have Visual Studio 2005, in project properties for debugger to launch option I am not able to see option for "WMI Studio". The options which come up are:
a) Local Windows Debugger
b) Remote Windows Debugger
c) Web Services Debugger
d) MPI Cluster Debugger
Do I need to install some debugging add-on?
|
|
|
|
|
Local Windows Debugger, set the Command proprty to be the path to the WMI Studio executable.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have WMI Studio which works as a activeX control on IE, instances/query is run from WMI Studio. I tired attaching the IE process and wmiprvse.exe process, when I execute the query on my WMI management class it runs as "LOCAL SERVICE" instead of "SYSTEM".
I tried attaching to both the instances, but could not debug. In visual studio after attaching the process I press F5 to run it.
Either debugger is not getting attached to the process or I am not placing debug pointer at the correct location. Is there a way that automatically it steps into the code, without me figuring out the locations where to place the debug point?
|
|
|
|
|
So...which process is your WMI provider loaded into?! Until you know that, you're going to have trouble debugging it!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hey, thanks for the prompt reponse(s).
I am using WMI CIM Studio supplied by MS for viewing instances of the my management class.
Though my management class is for touchscreen, but I am having same problem with the code from GWYN COLE's book "Developing WMI Solution" and compiled and regsitered it. The namespace is "WMIBook" and class is "SampleWINNet_Basket", there is method for enumeration.
I guess when I try to view the instances of Baskets in WMI Studio, I get a "WMI:Provider load failure". In order to figure the error, I am trying to get into debugging.
|
|
|
|
|
So, it sounds like WMI CIM Studio is trying to load your provider (I presume your provider is a DLL?), which means that the process trying to load your provider is Internet Explorer? In that case, you want to specify Internet Explorer as your debug executable and set breakpoints in your provider source code. I would suggest the Initialize method of IWbemProviderInit as a good place to start?
If that method's never reached, then it suggests that the system is having trouble locating your provider, which suggests that the registration of your management class is incorrect.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
My provider is a DLL, I tried attaching it to Internet Explorer but didn't work even after placing breakpoints in the Initialize method of IWbemProviderInit.
I am creating a new WMI Management object with its WMI provider, the class will only do enumeration. Let me check how it goes, I guess it will take me half an hour to try out all the above permutation and combinations. Will definitely get back.
|
|
|
|
|
I just Googled for "debug wmi provider dll". Found a couple of things:
From Wikipedia:
WinMgmt.exe: WinMgmt.exe is not a tool; it is the executable that implements the WMI Core service. Under the Windows NT family of operating systems, WMI runs as a service. On computers running Windows 98, Windows 95 or Windows Me, WMI runs as an application. Under the Windows NT family of operating systems, it is also possible to run this executable as an application, in which case, the executable runs in the current user context. For this, the WMI service must be stopped first. The executable supports some switches that can be useful when starting WMI as a service or as an application. WMI provider developers who may want to debug their providers essentially need to run the WMI service as an application.
From this CodeProject article[^]:
Debugging WMI provider critta 4:39 11 Jan '06
Step 1:
stop the Windows Management Instrumentation Service
(control panel-->administrative tools---> services, or Start-->Run--> services.msc)
Step 2:
In your VS click go to Build/Start Debug / Go, a dialog appears and asks for "Executable for Debug Session" here specify the path to the winmgmt.exe (should be under %systemroot%/system32/wbem.
That's it !
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Tried attaching it to winmgmt.exe, I get the following critical error and debugging stops.
"Debugging information for 'winmgmt.exe' cannot be found or does not match. No symbols loaded."
|
|
|
|
|
I tried again by creating a simple management class which only supports enumeration. Same problem "WMI:Provider load failure", the MOF file and Enumeration function code is below:
MOF File
---------
#pragma namespace("\\\\.\\root")
Instance of __Namespace
{
Name = "KI";
};
#pragma namespace("\\\\.\\root\\KI")
instance of __Win32Provider as $P
{
Name = "KI_Country";
ClsId = "{8A203B80-841D-4274-B753-8A30D8AB862D}";
ClientLoadableCLSID = NULL;
DefaultMachineName = NULL;
ImpersonationLevel = 1;
InitializationReentrancy = 0;
InitializeAsAdminFirst = FALSE;
PerLocaleInitialization = FALSE;
PerUserInitialization = TRUE;
Pure = TRUE;
UnloadTimeout = NULL;
HostingModel = "LocalServiceHost";
};
instance of __InstanceProviderRegistration
{
Provider = $P;
SupportsGet = TRUE;
SupportsEnumeration = TRUE;
};
[
dynamic: ToInstance,
provider("KI_Country"): ToInstance
]
class Country
{
[key] string Name;
uint8 Population;
};
Source code for method for enumeration
---------------------------------------
void CCKICountry::OnCountryInstances(CWbemInstanceList& instList, LPWBEMMETHODCTX ptrs)
{
// Create instance!
LPWBEMINSTANCE pInst = CreateWbemInstance(ptrs);
if (pInst)
{
CComVariant varCapacity(11);
varCapacity.ChangeType(VT_UI1);
// Set property
pInst->SetProperty(L"Name", L"Argentina");
pInst->SetProperty(L"Population", varCapacity);
instList.Add(pInst);
pInst->SetProperty(L"Name", L"Brazil");
pInst->SetProperty(L"Population", varCapacity);
instList.Add(pInst);
}
}
IDL definition
---------------
import "oaidl.idl";
import "ocidl.idl";
import "wbemprov.idl";
[
object,
uuid(7E9375F5-7033-4991-9602-1A406A8BDED5),
helpstring("ICKICountry Interface"),
pointer_default(unique)
]
interface ICKICountry : IUnknown{
};
[
uuid(8A203B80-841D-4274-B753-8A30D8AB862D),
version(1.0),
helpstring("Test4 1.0 Type Library")
]
library Test4Lib
{
importlib("stdole2.tlb");
[
uuid(397891B8-804F-45E6-9D8D-2AF808AE2B49),
helpstring("CKICountry Class")
]
coclass CKICountry
{
[default] interface IWbemProviderInit;
interface IWbemServices;
};
};
|
|
|
|
|
I was able to remove the error "WMI:Provider load failuer". The problem was with the CLSID, in the MOF I was using the wrong CLSID. rectified it and now I am not getting this error.
But I am still not able to get into the debugger, for debugging I have tried using "wmic.exe" from command line. E.g.,
>wmic /NAMESPACE:\\root\KI path "Country" get name
this returns me the result.
I have tried to attach to "wmic.exe" and "cmd.exe", both didn't work.
One thing I noted was that the breakpoint shows up as a empty ring with warning sign, the message being displayed in tool tip is "The breakpoint will not be currently hit. No symbols have been loaded for the document."
Any pointers?
|
|
|
|
|
|
Ooh...I tried the as mentioned in the "Microsoft's instructions for debugging a DLL".
I have specified "C:\WINDOWS\System32\Wbem\wmic.exe", when debugging is started it opens a command prompt. In the command prompt I type:
wmic:root\cli> /NAMESPACE:\\root\KI path "Country" get name
I get the output, but does not enter debugger. I think wmic.exe does not create the DLL, how do I figure which executable or DLL is hosting my DLL in process? Possibly point to that executable in project properties may help.
|
|
|
|
|
Hey, Got it working.
Attached the process to "wmiprvse.exe" instead of specifying the command line. Now able to debug.
Thanks Stuart for all the help, your pointers helped me be on track.
Thanks once again.
|
|
|
|
|
Excellent Now you've got the debugging working, you can get back to the primary problem - i.e. getting the provider working
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|