Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Hide C++-Exported class in dll?

Posted on 2000-03-09
Medium Priority
Last Modified: 2010-04-10
I have a C++-DLL (non mfc) that exports a C++-Class now since I don't want everyone to see what functions this class has, I would like to hide the names of the functions
and the class in the relase dll.
Anyone done that already?
Question by:connex
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 22

Accepted Solution

nietod earned 300 total points
ID: 2600143
Are you saying you want the functions to be accessible by some users and not by others?

One way you can do that is with the use of virtual functions.  Virtual functions don't have to be exported from the DLL.  So you can declare these functions as virtual in the "real" class declaration, one that is provided for people why can call these functions.  But you also create a "crippled" class declaration for use by people that can't call the functions.  This declaration will have all the virtual functions listed without parameter and return value as with meaningless names, like reserved1(), reserved2(), etc.

Is that what you are asking for?

If not, can you explain?

Author Comment

ID: 2600378
What i have is:
I have DLL exporting
class __declspec(dllexport) CExportClass
  (Static funtions that need to be called)

  virtual (a bunch of virtuals that need to be overwritten)

Now I want the resulting DLL hiding the function names.
E.g. I make test.exe which has CMyExportClass : public CExportClass

The export.dll i want to give to users along with test.exe shall not show that there is a function e.g. "CExportClass::EncryptPassword" in it.

LVL 22

Expert Comment

ID: 2600492
I think I see.  when you do

class __declspec(dllexport) CExportClass

it tells the compiler to export all the functions in a class.  But you ohnly want to export specific functions.  To do that declare the class as usual and declare the functiosn to be exported with __declspec(dllexport).  Like

class CExportClass
   void EncryptPassword(char *); // not exported
__declspec(dllexport) bool EnterPassword(char *); // Exported.

Now you can give the user of this DLL this very class definition if you want.  they will not be able to call the non-exported functions (like EncryptPassword()) becuase they will get link errors.  Or you can give them  an altered class defintion that doesn't list the non-exported members.

Note for this to work, the non-exported members may not be virtual.  if any are virtual, you need to use my first suggestion for them.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 2600564
That's not the problem.

I just want to prevent that DLL lists the function names etc. when viewing it with dpwalk or stuff like that.

The users of the dll will always get the complete definition. But Endusers shall not be able to reverse engineer it without mayor efforts .)

LVL 22

Expert Comment

ID: 2600654
>> That's not the problem.
What are you referring to?  Are you saying I haven't answered the question?

>> prevent that DLL lists the function names etc.
>> when viewing it with dpwalk
Are you saying you want to let the user's call the functions, but don't want them listed in the DLL?  Why?  You can use virtual functions for that, but why bother?

>> The users of the dll will always get the complete
>> definition. But Endusers shall not be able to reverse
>> engineer it
What are you hoping to d that will make reverse engenering harder?  
LVL 22

Expert Comment

ID: 2619358
Has this been answered then?

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question