473,832 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.FunctionNam e, 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 2061
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************ ********@hotmai l-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.FunctionNam e, 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**********@b entley.com> wrote in message
news:eD******** ******@TK2MSFTN GP09.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************ ********@hotmai l-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.FunctionNam e, 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
1959
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 to the unmanaged class instance. As usually in such a scenario, the IDisposable/Dispose()/Dispose(bool) pattern should be used. The problem is that in my approach it is often impractical, as the library's unmanaged objects are quite small and
1
741
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 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...
19
2355
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
995
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 wrap the unmanaged DLL. This class localizes the odd datatypes and allows most of the functions to be called with a minimal number of parameters. That class is in turn, wrapped in a managed C++ class. The objective is to get something that...
0
1312
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 software tool. By intuitive, I plan to apply C# to develop web side, which will invoke some unmanaged code to use functions of SPlus. I have developed a unmanaged C++ class UM_A to use SPlus functions, and also developed a wrapped managed C ++ class...
1
2605
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, System::EventArgs * e) { MyDLLInit(MyAppDisplayFunction); }
6
1462
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 /clr compilation mode. Is my app in CLR, or only the call to the
2
1348
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 VS.NET, compiling vb.net code into a common dll in the bin directory off the root of the website. That one vb code creates a namespace we import in all of our ASP.NET code. Compiling was done fromt he command line use vbc.exec. The site works...
2
12367
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 classes in managed C++ as a wrapper to the unmanaged C++ classes or is there an easier way? Essentially what I have done is written a C++ kernel mode driver and I want to use it from my C# program. Because it requires some setup outside the...
0
9795
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9642
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
10498
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
10540
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
6951
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
5623
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...
1
4421
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
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.