Solved

Hide C++-Exported class in dll?

Posted on 2000-03-09
6
301 Views
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?
0
Comment
Question by:connex
  • 4
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
Comment Utility
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?
0
 
LVL 2

Author Comment

by:connex
Comment Utility
What i have is:
I have DLL exporting
class __declspec(dllexport) CExportClass
{
public:
  (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.

0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
{
public:
   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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Author Comment

by:connex
Comment Utility
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 .)

0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
>> 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?  
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Has this been answered then?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now