473,729 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exporting C++ classes as ordinals (via a def file)

I want to export my C++ classes in a DLL, using ordinal # - rather than
by name. Will anyone care to enumerate through the steps required to do
this?

I am already failiar with exporting classes and symbols (both C++ and C)
from a DLL. In the case of C functions, i also know how to export them
by ordinal # - my main problem revolves around how to do the ff:

1). Obtaining the mangled names from the C++ DLL
2). How to map them (if any mapping is required) to the names in the def
file.
Apr 18 '07 #1
12 7253

"2b|!2b==?" <ro**@your.box. comwrote in message
news:wc******** *************@b t.com...
>I want to export my C++ classes in a DLL, using ordinal # - rather than by
name. Will anyone care to enumerate through the steps required to do this?

I am already failiar with exporting classes and symbols (both C++ and C)
from a DLL. In the case of C functions, i also know how to export them by
ordinal # - my main problem revolves around how to do the ff:

1). Obtaining the mangled names from the C++ DLL
Dependency Walker is your friend.
2). How to map them (if any mapping is required) to the names in the def
file.

Apr 18 '07 #2


Ben Voigt wrote:
"2b|!2b==?" <ro**@your.box. comwrote in message
news:wc******** *************@b t.com...
>>I want to export my C++ classes in a DLL, using ordinal # - rather than by
name. Will anyone care to enumerate through the steps required to do this?

I am already failiar with exporting classes and symbols (both C++ and C)
from a DLL. In the case of C functions, i also know how to export them by
ordinal # - my main problem revolves around how to do the ff:

1). Obtaining the mangled names from the C++ DLL


Dependency Walker is your friend.
Surely, there must be a better way than manually going through (copy and
paste?) over 100+ (Class::methods ) PER Dll ?

>
>>2). How to map them (if any mapping is required) to the names in the def
file.
Do I use the same decorated names in the .def file, or do I need to
"munge" (i.e. transform) the names into something else using another
tool for example ?
Apr 18 '07 #3
"2b|!2b==?" <ro**@your.box. comwrote in message
news:of******** *************** *******@bt.com. ..
>

Ben Voigt wrote:
>"2b|!2b==?" <ro**@your.box. comwrote in message news:wc******** *************@b t.com...
>>>I want to export my C++ classes in a DLL, using ordinal # - rather than by name. Will
anyone care to enumerate through the steps required to do this?

I am already failiar with exporting classes and symbols (both C++ and C) from a DLL. In
the case of C functions, i also know how to export them by ordinal # - my main problem
revolves around how to do the ff:

1). Obtaining the mangled names from the C++ DLL


Dependency Walker is your friend.

Surely, there must be a better way than manually going through (copy and paste?) over 100+
(Class::methods ) PER Dll ?

>>
>>>2). How to map them (if any mapping is required) to the names in the def file.

Do I use the same decorated names in the .def file, or do I need to "munge" (i.e.
transform) the names into something else using another tool for example ?


Are you talking about class members? If yes, stop here, you can't call methods from managed
code, only C style exports can be called via PInvoke, you need to wrap them in managed
classes using C++/CLI.
If you are talking about C style functions, you'll have to find the export ordinals using -
dumpbin /exports <dllnameand add them manually into your DllImports, IMO there is no tools
to do this automatically.

Willy.

Apr 18 '07 #4


Willy Denoyette [MVP] wrote:
"2b|!2b==?" <ro**@your.box. comwrote in message
news:of******** *************** *******@bt.com. ..
>>

Ben Voigt wrote:
>>"2b|!2b==?" <ro**@your.box. comwrote in message
news:wc****** *************** @bt.com...

I want to export my C++ classes in a DLL, using ordinal # - rather
than by name. Will anyone care to enumerate through the steps
required to do this?

I am already failiar with exporting classes and symbols (both C++
and C) from a DLL. In the case of C functions, i also know how to
export them by ordinal # - my main problem revolves around how to do
the ff:

1). Obtaining the mangled names from the C++ DLL

Dependency Walker is your friend.

Surely, there must be a better way than manually going through (copy
and paste?) over 100+ (Class::methods ) PER Dll ?

>>>
2). How to map them (if any mapping is required) to the names in the
def file.


Do I use the same decorated names in the .def file, or do I need to
"munge" (i.e. transform) the names into something else using another
tool for example ?


Are you talking about class members? If yes, stop here, you can't call
methods from managed code, only C style exports can be called via
PInvoke, you need to wrap them in managed classes using C++/CLI.
If you are talking about C style functions, you'll have to find the
export ordinals using - dumpbin /exports <dllnameand add them manually
into your DllImports, IMO there is no tools to do this automatically.

Willy.
Hmmm, neither of the above. I'm not using C# (I was under the impression
that this was a C++ specific ng). This is a C++ only framework.

I am already exporting my classes etc by name - but I want to export the
classes using ordinal numbers (for consumption by other C++ projects).

As I mentioned before, I already know this involves using .def file
(again I have experience of using def files to export C functions by
ordinal). My SPECIFIC question is how may I export C++ classes by
ORDINAL #, for use in other C++ libraries ?
Apr 18 '07 #5
Do I use the same decorated names in the .def file, or do I need to
"munge" (i.e. transform) the names into something else using another
tool for example ?

Are you talking about class members? If yes, stop here, you can't call
methods from managed code, only C style exports can be called via
PInvoke, you need to wrap them in managed classes using C++/CLI.
If you are talking about C style functions, you'll have to find the
export ordinals using - dumpbin /exports <dllnameand add them manually
into your DllImports, IMO there is no tools to do this automatically.

Willy.

Hmmm, neither of the above. I'm not using C# (I was under the impression
that this was a C++ specific ng). This is a C++ only framework.

I am already exporting my classes etc by name - but I want to export the
classes using ordinal numbers (for consumption by other C++ projects).

As I mentioned before, I already know this involves using .def file
(again I have experience of using def files to export C functions by
ordinal). My SPECIFIC question is how may I export C++ classes by
ORDINAL #, for use in other C++ libraries ?
Hi,

Maybe I am missing something, but why would you want to export by ordinal if
you are going to use it in other C++ projects anyway?
Why don't you simply export your C++ class by name?

Classes are nothing but a collection of functions. A class does not really
exist in binary, only mangled functions do.
To export by ordinal you'd have to somehow export each member by ordinal in
the correct order, and hope that you never have to insert a new member
because therwise the ordinals will all be messed up.
I don't think this is possible at all.
--
Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"

Apr 19 '07 #6
>
Hi,

Maybe I am missing something, but why would you want to export by ordinal
if
you are going to use it in other C++ projects anyway?
Why don't you simply export your C++ class by name?

Classes are nothing but a collection of functions. A class does not really
exist in binary, only mangled functions do.
To export by ordinal you'd have to somehow export each member by ordinal
in
the correct order, and hope that you never have to insert a new member
because therwise the ordinals will all be messed up.
I don't think this is possible at all.
I think the problem is going to be *importing* the functions by ordinal, is
there some syntax akin to __declspec(dlli mport, ordinal)?

Certainly, as long as the ordinals are assigned manually, the "insert a new
member" problem goes away. Indexes are certainly a feasible way to call
member functions because this is how COM works, it's an index into the
v-table instead of into the import table, but as long as you can control the
ordering and preserve it across versions, that should protect you against
changes in the name-mangling convention between compiler versions as long as
the calling convention doesn't change. And name-mangling changes are
coming, because they're needed to fix
https://connect.microsoft.com/Visual...dbackID=100917
Apr 19 '07 #7
On Apr 19, 4:36 pm, "Ben Voigt" <r...@nospam.no spamwrote:
Hi,
Maybe I am missing something, but why would you want to export by ordinal
if
you are going to use it in other C++ projects anyway?
Why don't you simply export your C++ class by name?
Classes are nothing but a collection of functions. A class does not really
exist in binary, only mangled functions do.
To export by ordinal you'd have to somehow export each member by ordinal
in
the correct order, and hope that you never have to insert a new member
because therwise the ordinals will all be messed up.
I don't think this is possible at all.

I think the problem is going to be *importing* the functions by ordinal, is
there some syntax akin to __declspec(dlli mport, ordinal)?
Indeed. It would be usefull if the OP explained us how it intends to
*use* this DLL in client code, because I do not believe it would be
possible to call methods on those classes using normal C++ syntax.
It would probably be possible to import them as "C" style functions,
and call them by passing explicitely the "this" argument, but I do not
see any interest to the exercise.

Btw, one should also consider other aspects, such as stack unwinding
across a DLL boundary in case of exception....

Arnaud
MVP - VC

Apr 19 '07 #8
<ad******@clu b-internet.frwrot e in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On Apr 19, 4:36 pm, "Ben Voigt" <r...@nospam.no spamwrote:
Hi,
Maybe I am missing something, but why would you want to export by
ordinal
if
you are going to use it in other C++ projects anyway?
Why don't you simply export your C++ class by name?
Classes are nothing but a collection of functions. A class does not
really
exist in binary, only mangled functions do.
To export by ordinal you'd have to somehow export each member by
ordinal
in
the correct order, and hope that you never have to insert a new member
because therwise the ordinals will all be messed up.
I don't think this is possible at all.

I think the problem is going to be *importing* the functions by ordinal,
is
there some syntax akin to __declspec(dlli mport, ordinal)?

Indeed. It would be usefull if the OP explained us how it intends to
*use* this DLL in client code, because I do not believe it would be
possible to call methods on those classes using normal C++ syntax.
It would probably be possible to import them as "C" style functions,
and call them by passing explicitely the "this" argument, but I do not
see any interest to the exercise.

Btw, one should also consider other aspects, such as stack unwinding
across a DLL boundary in case of exception....
I don't have any experience doing it, but it's got to be possible as the MFC
dlls do exactly this: export the class member functions using
[decorated_fname @ ordinal NONAME] in a def file, and I assume the import
libs take care of the linking requirements.
--
Jeff Partch [VC++ MVP]
Apr 19 '07 #9
I don't have any experience doing it, but it's got to be possible as the
MFC dlls do exactly this: export the class member functions using
[decorated_fname @ ordinal NONAME] in a def file, and I assume the import
libs take care of the linking requirements.
Entries in import libraries are resolved based on the linker matching the
mangled name, but the mangled name is prone to change even when the function
signature is compatible.
--
Jeff Partch [VC++ MVP]


Apr 19 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8010
by: Chris | last post by:
Could someone please provide me an effective means of exporting data from a data set (or data grid) to Excel?
5
5535
by: Jayjay | last post by:
Is it possible to export a report to word and have it include the graphics that are in the report? I'd like to take some of our reports and export them to word so we can email those to the client, but when I export, I lose the logo as well as any graphics (grey line separaters, etc) and only get the text of the reports.
1
3969
by: nunYa | last post by:
I am trying to use the DoCmd.TransferText method to export an access table to a Tab Delimited Text File. I have put the code behind the onclick event of a button and keep getting the error "Run-time error '32027': Cannot update. Database or object is read-only" Code I using is: Private Sub ExportButton_Click()
4
1795
by: Joshua Emele | last post by:
Hello - I am new to c# having come from the land of c. With c, I could create a .def file: library cdll exports foo @1 bar @2
2
2262
by: paul | last post by:
I am exporting a class from a managed dll created in Visual C++ 2005 Express. In A.h header file I have // A.h public ref class A {}; In the same module, I create a new class to be exported which will use A as its base class.
8
1593
by: Alfonso Morra | last post by:
I am familiar with creating lean and mean WIN32 DLLS and exporting C functions via a DEF file (or cconv decorators), but I am wndering how I can export my C++ objects from my DLLs? Ideally, I would be able to use the classes (and their methods) by calling the objects and invoking their methods - is this possible, given the fact that the C++ compiler decorates names ? looking forward to an informed answer -tkx
2
3184
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
15
7393
by: Grey Alien | last post by:
I have a class that contains a std::map variable. I need to export the class via a DLL. the class looks something like this: class MyClass { public: MyClass(); MyClass(const MyClass&); private:
1
4917
by: Marty Klunk | last post by:
I have an Access97 data base where we are exporting records out to a text file that is then sent to a customer via EDI transmission. The problem I am having is that during the export process access is converting my number fields to scientific notation and they are getting bounced by our customer's EDI program. Example is .0027 is showing in the text file as 2.7E-3. I have tried setting formatting to fixed with 4 decimals, general with 4, no...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.