Re: PostMessage from a DLL

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



One way around this that I've used is to subclass within the DLL. For example,

class CMyPublicInterface : public CSomeWndClass {
public:
static CMyPublicInterface * Create(...);
void DoThis();
void DoThat();
...
protected:
CMyPublicInterface();
public:
virtual ~CMyPublicInterface();
};

and in the DLL I do

class CMyPrivateInterface : public CMyPublicInterface {
protected:
int thing;
int object;
CWhatever stuff;
};

Because I have a protected constructor, the user cannot create an instance of the object
outside the DLL. The virtual destructor (always a good practice) means that the correct
object will be destroyed.

/* static */ CMyPublicInterface * CMyPubicInterface::Create(...)
{
return (CMyPublicInterface *)new CMyPrivateInterface(...);
//...or
return static_cast<CMyPublicInterface *>new CMyPrivateInterface(...);
}

void CMyPublicInterface::DoThis()
{
ASSERT_KINDOF(this, CMyPrivateInterface);
CMyPrivateInterface * p = (CMyPrivateInterface *)this;
// ... or
CMyPrivateInterface * p = dynamic_cast<CMyPrivateInterface *>(this);
p->DoThis();
}

A bit hokey, but it let me protect all the interface information so I could change the
implementation but not the public interface.
joe

On 14 Dec 2005 08:30:37 -0800, "Ajay Kalra" <ajaykalra@xxxxxxxxx> wrote:

>One way you can do it to use forward declaration:
>
>class CAnotherClass;
>
>class AFX_EXT_CLASS CComunication
>{
>public:
> SomeMethods
> SomeAttributes
>private:
> CAnotherClass* m_pManager;
>
>}
>
>Now you are not including the header file.
>
>----------
>Ajay Kalra
>ajaykalra@xxxxxxxxx
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: ASP.NET 2005 hack-proof?
    ... Obfuscation is not fool-proof once the DLL is obtained. ... So, the amount of trouble, time, and expense to protect intellectual ... >> It will deter the casual decompiler, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Word VBA obfuscation?
    ... > reason to protect your efforts. ... > Takes less than 5 minutes, without a password cracker. ... > Write code that installs the DLL, ... How do I create a DLL from a Word VBA project in Word? ...
    (microsoft.public.word.vba.general)
  • Re: Program protection - can not be copied
    ... The reason I cannot retrieve a dll from the image, ... That kind of thing might involve a filter driver or something ... I am trying to extract a DLL from an existing build. ... It seems that there is no any direct method to protect the program from ...
    (microsoft.public.windowsce.platbuilder)
  • Re: How do I stop my software from getting cracked?
    ... cracking it quite difficult for an inexperienced cracker. ... Write that DLL in a good ole C. Make calls into that DLL ... And it all depends on the software that you try to protect. ... commercial obfuscator for missile defence system software... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Decompiling C#?!?!? Where is the privacy?
    ... > C# back as a managed C++ DLL because he thinks that he can protect the ... No one will want to decompile *all* of your code, ... lengthen the amount of time, it will not remove it completely. ... > like that even his DLL will be reverse engineerable. ...
    (microsoft.public.dotnet.languages.csharp)