473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Non public wrappers on unmanaged C functions & C++ class

Hello,

in the last few days I've made my first few attempts at creating mixed
C++ managed-unmanaged assemblies and looking afterwards with ILDASM
at what is visible in those assemblies from a managed point-of-view
I've noticed that:

1) for each managed and unmanaged C function (not C++ classes) I get a
public managed static method (defined on a 'Global Functions' class)
in the generated assembly with an export name of the form
xyz.FunctionName, where xyz looks like a C++ mangled random name. As
global methods of this 'Global Functions' class also appear the main
and _mainCRTStartup functions and any other C library function that
gets used inside the defined managed or unmanaged C functions. In my
simple sample applications, for example, I'm using the printf C
standard library function inside my definined functions and when
looking at the generated assembly with ILDASM I find a public managed
static method with the same name.

2) for each unmanaged C++ class I get a public managed structure
(value class) with no managed method visible. Including any C++
standard library (such as iostrem, string, ecc.) in a project also
adds a lot of managed objects in the form of public managed
structures (value classes). And this happens even if none of the
included C++ standard library classes gets used in the defined
managed/unmanaged C++ classes.

All of the above happens when compiling assemblies in release mode and
having specified to have the compiler produce NO debugging
information. Incredibly I discovered that even for release compiled
assemblies some debugging information still is produced and inserted
into the assembly. Look under "Project Properties -> C/C++ ->
General" and set Debug Information Format to Disabled to stop debug
info from being placed into your assemblies.

Now, what I'd like to do is:

(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but
most of all

(2) I'd like to have all these managed structures (value classes)
created around my managed/unmanaged C functions and unmanaged C++
classes to be PRIVATE and NOT PUBLIC as their are created now.

I've tried defining as static both the managed and unmanaged C
functions but this does not seem to change anything. As for the C++
unmanaged classes it seems that access specifiers (public, private,
protected) may only be applied to managed classes and so on this
front I have not been able to do anything.

Can anyone help me out???
Thx

Bob Rock

Nov 17 '05 #1
2 2009
Bob,

This is hardly a complete response to your question but, regarding 2, if you
look at the managed value types that the compiler generates to represent
your native classes you will see that they contain no members. The have a
size that is accurate, and that is all. Aside from their name and size,
nothing is exposed about your native types to the managed side. That they
are empty means that noone could really do much with those types without the
header files that declare them - if that is what you are partly concerned
about.

Bern McCarty
Bentley Systems, Inc.

"Bob Rock" <ye********************@hotmail-dot-com.no-spam.invalid> wrote in
message news:40**********@127.0.0.1...
Hello,

in the last few days I've made my first few attempts at creating mixed
C++ managed-unmanaged assemblies and looking afterwards with ILDASM
at what is visible in those assemblies from a managed point-of-view
I've noticed that:

1) for each managed and unmanaged C function (not C++ classes) I get a
public managed static method (defined on a 'Global Functions' class)
in the generated assembly with an export name of the form
xyz.FunctionName, where xyz looks like a C++ mangled random name. As
global methods of this 'Global Functions' class also appear the main
and _mainCRTStartup functions and any other C library function that
gets used inside the defined managed or unmanaged C functions. In my
simple sample applications, for example, I'm using the printf C
standard library function inside my definined functions and when
looking at the generated assembly with ILDASM I find a public managed
static method with the same name.

2) for each unmanaged C++ class I get a public managed structure
(value class) with no managed method visible. Including any C++
standard library (such as iostrem, string, ecc.) in a project also
adds a lot of managed objects in the form of public managed
structures (value classes). And this happens even if none of the
included C++ standard library classes gets used in the defined
managed/unmanaged C++ classes.

All of the above happens when compiling assemblies in release mode and
having specified to have the compiler produce NO debugging
information. Incredibly I discovered that even for release compiled
assemblies some debugging information still is produced and inserted
into the assembly. Look under "Project Properties -> C/C++ ->
General" and set Debug Information Format to Disabled to stop debug
info from being placed into your assemblies.

Now, what I'd like to do is:

(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but
most of all

(2) I'd like to have all these managed structures (value classes)
created around my managed/unmanaged C functions and unmanaged C++
classes to be PRIVATE and NOT PUBLIC as their are created now.

I've tried defining as static both the managed and unmanaged C
functions but this does not seem to change anything. As for the C++
unmanaged classes it seems that access specifiers (public, private,
protected) may only be applied to managed classes and so on this
front I have not been able to do anything.

Can anyone help me out???
Thx

Bob Rock

Nov 17 '05 #2
This is true, but it's also true that you can't even name mangle a
mixed-mode C++ assembly without paying $800 for one of the commercial
obfuscators. Which means that your managed classes reveal pretty much their
source code, and your unmanaged classes make it obvious what they do. I
suppose you could code in mangled names, but our Mac guys would go beserk if
I checked in a load of cross platform classes called A, B and C.... :-)

Steve

"Bern McCarty" <be**********@bentley.com> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
Bob,

This is hardly a complete response to your question but, regarding 2, if you look at the managed value types that the compiler generates to represent
your native classes you will see that they contain no members. The have a
size that is accurate, and that is all. Aside from their name and size,
nothing is exposed about your native types to the managed side. That they
are empty means that noone could really do much with those types without the header files that declare them - if that is what you are partly concerned
about.

Bern McCarty
Bentley Systems, Inc.

"Bob Rock" <ye********************@hotmail-dot-com.no-spam.invalid> wrote in message news:40**********@127.0.0.1...
Hello,

in the last few days I've made my first few attempts at creating mixed
C++ managed-unmanaged assemblies and looking afterwards with ILDASM
at what is visible in those assemblies from a managed point-of-view
I've noticed that:

1) for each managed and unmanaged C function (not C++ classes) I get a
public managed static method (defined on a 'Global Functions' class)
in the generated assembly with an export name of the form
xyz.FunctionName, where xyz looks like a C++ mangled random name. As
global methods of this 'Global Functions' class also appear the main
and _mainCRTStartup functions and any other C library function that
gets used inside the defined managed or unmanaged C functions. In my
simple sample applications, for example, I'm using the printf C
standard library function inside my definined functions and when
looking at the generated assembly with ILDASM I find a public managed
static method with the same name.

2) for each unmanaged C++ class I get a public managed structure
(value class) with no managed method visible. Including any C++
standard library (such as iostrem, string, ecc.) in a project also
adds a lot of managed objects in the form of public managed
structures (value classes). And this happens even if none of the
included C++ standard library classes gets used in the defined
managed/unmanaged C++ classes.

All of the above happens when compiling assemblies in release mode and
having specified to have the compiler produce NO debugging
information. Incredibly I discovered that even for release compiled
assemblies some debugging information still is produced and inserted
into the assembly. Look under "Project Properties -> C/C++ ->
General" and set Debug Information Format to Disabled to stop debug
info from being placed into your assemblies.

Now, what I'd like to do is:

(1) hide, if possible, any managed objects (value classes, arrays and
fields) created around my unmanaged C functions and C++ classes, but
most of all

(2) I'd like to have all these managed structures (value classes)
created around my managed/unmanaged C functions and unmanaged C++
classes to be PRIVATE and NOT PUBLIC as their are created now.

I've tried defining as static both the managed and unmanaged C
functions but this does not seem to change anything. As for the C++
unmanaged classes it seems that access specifiers (public, private,
protected) may only be applied to managed classes and so on this
front I have not been able to do anything.

Can anyone help me out???
Thx

Bob Rock


Nov 17 '05 #3

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

Similar topics

2
by: Marek Malowidzki | last post by:
Hi all, I am writing a component that exposes a C++ library as a .NET component. The approach is somewhat automatic: every library C++ class has its managed C++ counterpart that keeps a pointer...
1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
0
by: _N | last post by:
I'm trying to use an unmanaged legacy DLL in a C# project. I'd like to avoid P/Invoke because of the number of odd datatypes in the original DLL. So... I've generated an unmanaged C++ class to...
0
by: david chang via DotNetMonster.com | last post by:
Hi, guys I am trapped into a big trouble on how to use unmanaged class library code in a C# web application. Now, I am working on a project to develop a web interface for SPlus, a statistical...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
6
by: nicolas.hilaire | last post by:
Hi all, i'm not totally clear with some concepts about managed and unmanaged code. I'm asking myself some questions : - i've a MFC app, i want to use the framework dotnet by switching to...
2
by: jason | last post by:
Please pardon my completely lack of understanding on the topic. I have a website I developed with another developer. We are both far from experts in VB.NET and OOP. We developed the site WITHOUT...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.