|
Whenever I want to create an out-of-proc COM server,I use MFC application wizard to generate Dialog based Application with Automation support. Then i delete all the dialog related stuff from it, derive a new class from CCmdTarget and implement functions that external applications can call.
Now i want to fire events from such out-of-proc server. Can anyone tell me how can i do so?? Any sample application would be extremely welcome.
|
|
|
|
|
- Create a simple ATL Object.
- Create an event interface (dispinterface, see MSDN docs)
- Right click on the ATL class generated in step 1 and choose Add Connection Point. Select your event interface, and click ok.
- Use the
Fire_XX methods generated by the event proxy class.
It's real easy, you'll figure it out.
--
we dance to the sound of sirens
and we watch genocide to relax
we dance to the sound of sirens
we are the heroes of self-deception
|
|
|
|
|
Hi,
Does somebody know a secure solution to ensure that the DLL an application
is talking to hasn't been replaced with a fake one?
I am thinking about implementing a "handshaking" procedure. With this
method, the application sends a "challenge" random message to the DLL. The DLL responds with a value calculated using a one-way hash function. The application checks the response against its own calculation of the expected hash value. If the values match, the authentication is acknowledged; otherwise the application is terminated.
Do you know other/better solutions? Does COM provides some solution?
Remark: I am developing both the application part and the DLL part.
Thanks.
antoine
|
|
|
|
|
COM itself doesn't provide any solution for this (somehow you can use Licencing, but it is very easy to break).
Your solution can work, but have one weakpoint - it is quite easy to crack, because when the someone would like to switch the DLLs, he needs only to know the one-way hash you are using - if you will choose some standardized, say MD5, he can only with this knowledge calculate correct hash and return it to you exactly as your original DLL does. It is in fact secured only by the alg. of the one-way hash, and this alg. is stored in exe as well as in the DLL, so everybody can look to it and copy it.
Little bit better is a signing the code. If you will use the public key cryptography, the theory is simple, you have to calculate the cryptographic checksum of the DLL. Then the hash result is signed by your private key and stored in DLL.
In runtime, you take this blob from the DLL, calculate hash (of course except modified parts), compare it with the stored one and verify the signature by your public key stored say in a resources of the exe file. If the hashes match and the signature is OK, you are on the safe side.
This method is a bit safer, but also have some problem. It is quite easy to remove the checking code from exe .
In fact, there is no perfect software solution and depends only on the level of security you require for your application.
But in any case, there is a simple helper rule which says, if the system is secured, independently on the method you will use - If the costs for breaking such a system is higher (better significantly higher) than the benefits you can have from it, the system can be considered as safe.
Sorry for such an elaborate, but it is a deep night here and I cannot sleep somehow today...
|
|
|
|
|
Forget dynamic linking if you want security. There are about 1001 different ways of intercepting a dynamically loaded DLL.
To make it as hard as possible, do static linking. At least then you put the cracker to work.
To be real pessimistic, there is no real way to protect software in currently available mainstream operating systems. Nobody has a rigid set of security policies implemented. There will always be ways to trick the system, some harder than others.
--
we dance to the sound of sirens
and we watch genocide to relax
we dance to the sound of sirens
we are the heroes of self-deception
|
|
|
|
|
IEnumVARIANT *scrap;
IUnknownPtr Collection;
ConstraintsPtr ConstraintsList(GetConstraintsDispatch());
if (ConstraintsList->GetCount() > 0)
{
Collection = ConstraintsList->Get_NewEnum();
Collection->QueryInterface(IID_IEnumVARIANT, (void **)&scrap);
For some inexplicable reason the QueryInterface call above has suddenly stopped working...returning E_NOINTERFACE. It worked last week. It works on other machines in the office. It just doesn't work on mine. (This is old code that hasn't been modified in years and has never failed before...)
Any ideas? Tips? Anything? Anyone?
Please
Dan
|
|
|
|
|
Sussed it, the following registry sub-keys, inexplicably, were AWOL:
[HKEY_CLASSES_ROOT\Interface\{00020404-0000-0000-C000-000000000046}\NumMethods]
@="7"
[HKEY_CLASSES_ROOT\Interface\{00020404-0000-0000-C000-000000000046}\ProxyStubClsid]
@="{00020421-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{00020404-0000-0000-C000-000000000046}\ProxyStubClsid32]
@="{00020421-0000-0000-C000-000000000046}"
Mad!
Dan
|
|
|
|
|
Can I define an Interface, to have member variables in addition to pure virtual functions ?
Hara
|
|
|
|
|
By design no. IDL interfaces are only exposing properties (which are special methods) and methods.
Members are contained in the actual implementation class :
class IMyInterface : public IUnknown
{
virtual HRESULT __stdcall Method1(...)=0;
virtual HRESULT __stdcall Method2(...)=0;
};
class MyInterfaceImpl : public IMyInterface
{
protected:
int m_SomeMember;
public:
virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
virtual ULONG __stdcall AddRef() ;
virtual ULONG __stdcall Release() ;
virtual HRESULT __stdcall Method1(...);
virtual HRESULT __stdcall Method2(...);
}
|
|
|
|
|
Thanks for your response. But The interface, that I want to design must have
an aggregation relation ship with some other interface.
How to do this ?
Hara
|
|
|
|
|
Can you give a little more info? 1) Do you mean your COM object will be aggregated or that your COM object will aggregate the other COM object?; 2) Are you using ATL?
things could always be worse...
|
|
|
|
|
Hi
I would like to describe the problem refering a picture in my word document.
Neither, I could insert my document nor even the picture.
Can you please send me your E-mail ID , so that I can mail you my document with detailed problem description of the problem.
Regards
Hara
Hara
|
|
|
|
|
I've downloaded http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=midi in order to implement a midi song in my app.
But the play(midi) command only works in a [STAThread] model and it stop my app until the music end.
I've few experience in C#.
Any way to fix it??
Any clue???
|
|
|
|
|
Hi, I read the articles about COM basic and still have problems. I try to write a simple console application in vc++ 6.0. I want to use ActiveDesktop componet to handle some info about wallpaper and patern. Also I have an example code. But there is no info about following thing.
In the code there are some variables like CLSID_ActiveDesktop or CLSCTX_INPROC_SERVER.
in which header they are defined. If your answer is comdef.h I include it and it only have some structs IActiveDesktop. Also I found that CLSCTX_INPROC_SERVER is defined in objbase.h but it still get error when I use CLSCTX_INPROC_SERVER. When I write 1 it is ok.
Another thing I could not get last parameter of CoCreateInstance.
here what I try to work and it gives 4 error.
<br />
<br />
#include<iostream.h><br />
#include<objbase.h><br />
#include<comdef.h><br />
<br />
HRESULT hr;<br />
int main()<br />
{<br />
IActiveDesktop *pIActiveDesktop;<br />
<br />
CoInitialize ( NULL ); <br />
<br />
hr = CoCreateInstance( CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,<br />
IID_IActiveDesktop, &pIActiveDesktop);<br />
<br />
cout<<hr<<"\n";<br />
<br />
return 0; <br />
}
karanba
|
|
|
|
|
check if you have correctly set the switches or how it is called.
for example if it is defined in your stdafx.h (or simply before you include any of windows/com headers):
#ifndef _WIN32_WINNT<br />
#define _WIN32_WINNT 0x0400<br />
#endif
Possibly you will need to define also version of your explorer etc.
This is because some definitions in standard windows headers are conditionally compiled and if you do not define correct switches, some functions and constants are simply ommited by the compiler - even if you can see it in headers....
|
|
|
|
|
Ok well this is the code and it gives only error at the line which I put a confused face image near it. VC++6.0 says that
\selman\desktop\workarea\comclienta\cpp1.cpp(27) : error C2664: 'CoCreateInstance' : cannot convert parameter 1 from 'char [37]' to 'const struct _GUID &'
Reason: cannot convert from 'char [37]' to 'const struct _GUID'
No constructor could take the source type, or constructor overload resolution was ambiguous But I check many things that I could not found the reason. please give me an explanation
#include<iostream.h>
#include<objbase.h>
#include<comdef.h>
HRESULT hr;
int main()
{
IActiveDesktop *pIActiveDesktop;
CoInitialize ( NULL );
hr = CoCreateInstance( "75048700-ef1f-11d0-9888-006097deacf9",
NULL,
CLSCTX_INPROC_SERVER,
"f490eb00-1240-11d1-9888-006097deacf9",
(void**) &pIActiveDesktop);
cout<<hr<<"\n";
cout<<hr;
return 0;
}
karanba
|
|
|
|
|
I see. The problem is in parameter "f490eb00-1240-11d1-9888-006097deacf9", this and "75048700-ef1f-11d0-9888-006097deacf9". The CoCreateInstance is not designed to handle GUIDs in such a way.
It expect pointer/reference to some memory where GUID is stored in numeric format.
For calls to functions you can use the symbolic names like
CLSID_ActiveDesktop instead of "75048700-ef1f-11d0-9888-006097deacf9"
and IID_IActiveDesktop instead of the second one.
Then the call should looks like that (I hope so):
hr = CoCreateInstance( CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER, IID_IActiveDesktop,(void**) &pIActiveDesktop);
But for easier coding I would recomend you to use smart pointers from ATL, then the code will looks like this one:
<br />
CComPtr<IActiveDesktop> spActDesktop;<br />
spActDesktop.CoCreateInstance( CLSID_ActiveDesktop );
which is much easier to read, and also the smart pointer takes a care about reference counting.
|
|
|
|
|
thax geo_m it works now
I add following to the code and you are true
DEFINE_GUID( CLSID_ActiveDesktop, 0x75048700L, 0xEF1F, 0x11D0, 0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9);
DEFINE_GUID( IID_IActiveDesktop, 0xF490EB00L, 0x1240, 0x11D1, 0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9);
Now I will try to write my own com component there I want to ask a new questions.
There must be an IDL file for every COM componets or when they are needed
karanba
|
|
|
|
|
Hi,
I'm working on a C# Winform application to manage content in a electronical schoolbook. One of the key feautures is a WYSIWYG HTML editor, where the author can format the output text on her own.
At the moment I don't quite know where to start building this feauture. I've done some research, and figured out that there are two components i could use, a) the DHTMLEdit ActiveX component, or b) the MSHTML COM objecct (correct me if I'm wrong). Most of the information i could find about the DHTMLEdit is datet 1998/1999, and is "old". I've allso seen some newsgroup post saying that Microsoft is outfasing DHTMLEdit, and are suggesting you to use the MSHTML object.
What i wan't to know, is witch one of these two components i should use to build my WYSIWYG HTML Editor. What's the main differences, and how could i as easy as possible implement the feauture in my application. The best thing whould be if i could buy a out of the box editor, witch I could include in my project. I know there are plenty of webbased editors out there, but i wan't something that's winforms.
I would allso appreciate any kind of good information about witch path to take.
Thank you
Jonas Follesø
Developer, GreIT AS
http://www.greit.no
|
|
|
|
|
Hello,
I created a COM DLL. (with VC++.NET but this is not important).
And created some assembly the has a function, that create instance from the
COM class, and call some function from the COM object.
When I call the functions of the assembly as simple as possible, from some
console app, this is work.!
But if I do it via remoting, it isn't work!! and give this exception:
Unhandled Exception: System.InvalidCastException: QueryInterface for
interface ScreenCamaraASM.IScreenCapturing failed.
Server stack trace:
at ScreenCamaraASM.CScreenCapturingClass.GetNumber()
at RCServerNP.RCServer.GetScreenPicture() in d:\mydocs\visual studio
projects
\remotecommunication\rcserver\rcserver.cs:line 24
at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(M
ethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInC
ontext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMes
sage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)
at RCServerNP.RCServer.GetScreenPicture() in d:\mydocs\visual studio
projects
\remotecommunication\rcserver\rcserver.cs:line 21
at Testing.Class1.Main(String[] args) in D:\MyDocs\Visual Studio
Projects\Rem
oteCommunication\Testing\Class1.cs:line 36.
Please, any solution?
Thank's, Itay.
|
|
|
|
|
Hello guys,
Where can I find a good implementation of IClassFactory2, whitout using that DECLARE_CLASSFACTORY2(CMyLicense) macro, to perform licensing capabilities to my software?
Thanks in advance,
Raphael Amorim Dantas Leite
VC++, VB, Java, .NET and eMbedded Programmer
|
|
|
|
|
Hello,
I had a problem in registering a sink I made.I made the dll and
make a client com to test that the dll is registerd correctly
then I register the sink using the smtpreg.vbs
but when I send an e-mail from another terminal my sink wasnot called
I donot know why??Could you help??
By the way I have a network 2 pcs I installed win2000 Advanced server
and Exchange 2000 server on one and made it the server and installed
win2000 professional on the other and I use visual studio.net to make
the sink ATL Project.
|
|
|
|
|
Hi everybody,
I've asked this question before, and I'M NOW WILLING TO PAY (with PayPal) for a solution that fits my needs because time is not a thing I have in abundance and I need this thing quickly!
Here's, from a user point of view, what I want the resulting solution app to do:
####
When pressing a modifier key (ctrl for example), clicking (right or left mouse) ANY text-based string in ANY application or object (folder names, titles, list items, etc) in the operating system (win95+), a small window should appear next to the clicked-on text informing the user what text he/she has clicked on.
####
Two approaches (as far as I know) are possible: Either you can go the OCR (Optical Character Recognition) way where you actually capture and analyze what the screen pixels look like. An OCR engine is hard to develop yourself and expensive to license or buy. Or you can use the MS Accessibility API to do this... (fairly undocumented but supposed to do the trick). This is an API used for developing apps that for instance can read text on the screen out loud.
Anyone with the appropriate knowledge and skills who want to take this on?
We can discuss the details more privately when a first contact has been established. Thx everybody and thx for a great forum!
/Tommy
|
|
|
|
|
I've already posted this on the main c++ forum. I didn't notice this COM forum first. Sorry for that.
I want to use the internet explorer inside my application. This works fine:
AtlAxWinInit();
HWND hwndChild=::CreateWindow( "AtlAxWin",
"Shell.Explorer.1",
WS_CHILD|WS_VISIBLE,
0,0,0,0,
hwnd,NULL,
::GetModuleHandle(NULL),
NULL);
IUnknown *pUnk=NULL;
AtlAxGetControl(hwndChild,&pUnk);
CComPtr<IWebBrowser2> spBrowser;
pUnk->QueryInterface(IID_IWebBrowser2,(void**)&spBrowser);
if(spBrowser)
spBrowser->put_Visible(VARIANT_TRUE);
But, I want this to be more abstract. How can I use the interface IDispatch instead.
My attempt to abstract it returned a DISP_E_UNKNOWNNAME while calling GetIDsOfNames with "Visible" and VARIANT_TRUE.
It has to be something like that...
using: [VISUAL STUDIO 6.0] [WIN98/2]
|
|
|
|
|
We have a COM+ server application that runs under a local user account. The application is marked as queued which automatically creates some MSMQ private queues. However the system does to add the required permissions for the user (Full Control) to the queues. Is this a bug? Or do we have to set these permissions ourselves? Can this be done programatically?
|
|
|
|
|