Improve company productivity with a Business Account.Sign Up


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
  • 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.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.


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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

607 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