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
Solved

Hide C++-Exported class in dll?

Posted on 2000-03-09
6
339 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

839 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