Solved

Hide C++-Exported class in dll?

Posted on 2000-03-09
6
357 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
[X]
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
6 Comments
 
LVL 22

Accepted Solution

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

Author Comment

by:connex
ID: 2600378
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
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
{
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

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

0
 
LVL 22

Expert Comment

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

Expert Comment

by:nietod
ID: 2619358
Has this been answered then?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 73
designing in object programming 12 131
How to read a c++ line with strings and variable numbers of elements 6 62
learn programming 8 94
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

734 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