Rachana George.NET Security, Summer 2010. Introduction Sample Unmanaged C++ Library Retrieve Exported Information from the DLL Perform Platform Invoke.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Advertisements

Outline 1 Introduction 2 Base Classes and Derived Classes 3 protected Members 4 Relationship between Base Classes and Derived Classes 5 Case Study: Three-Level.
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Best Practices for Interop with Visual C++ Boris Jabes Program Manager Microsoft Corporation.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Inheritance Inheritance Reserved word protected Reserved word super
C++ Inheritance Systems Programming.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Advanced Object-Oriented Programming Features
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
OOP Languages: Java vs C++
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Introduction to .Net Framework
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Taken from slides of Starting Out with C++ Early Objects Seventh Edition.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Inheritance Inheritance – most important and a useful feature of OOPs supported by C++ | Website for Students | VTU -NOTES -Question Papers.
.NET Framework & C#.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Obsydian OLE Automation Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Classes: A Deeper Look Part.
.NET Framework Danish Sami UG Lead.NetFoundry
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Ni.com Understanding COM/ActiveX Jeff Paulter Staff Software Engineer Thurs Aug 17 10:15-11:30 a.m., 1:45-3:00 p.m. Ash (10A) Jeff Paulter Staff Software.
Software Engineering in Robotics Interfacing to external functions Henrik I. Christensen –
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
CSE 222: Software Components in Engineering (SCE) – Introduction Instructor: Jimmy Voss Disclaimer: Not all material is original. Some is taken from the.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Module 14: Attributes. Overview Overview of Attributes Defining Custom Attributes Retrieving Attribute Values.
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
.NET Mobile Application Development Messaging & Communication from Mobile Devices.
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
Object-Oriented Programming. Objectives Distinguish between object-oriented and procedure-oriented design. Define the terms class and object. Distinguish.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Chapter -6 Polymorphism
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
PROGRAMMING 1 – HELPER INSTRUCTIONS ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED BY NANCY M. AMATO AND JORY DENNY 1.
Class Inheritance Inheritance as an is-a relationship Public derive one class from another Protected access Initializer lists in constructor Upcasting.
© 2009 Artisan Software Tools. All rights reserved. Testing Solutions with UML/SysML Andrew Stuart, Matthew Hause.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Part -1 © by Pearson Education, Inc. All Rights Reserved.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
Copyright © Jim Fawcett Spring 2017
SECTION 4 GSE IMPORT METHOD.
Jim Fawcett CSE775 – Distributed Objects Spring 2009
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Jim Fawcett CSE687-OnLine – Object Oriented Design Summer 2017
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
3 Fundamentals of Object-Oriented Programming
Chapter 9 Classes: A Deeper Look, Part 1
Lecture 22 Inheritance Richard Gesick.
.NET and .NET Core 10. Enabling Contracts Pan Wuming 2017.
Inheritance Dr. Bhargavi Goswami Department of Computer Science
Virtual Functions Polymorphism is supported by C++ both at compile time and at run time. Compile-time polymorphism is achieved by overloading functions.
CISC/CMPE320 - Prof. McLeod
Overview of C++ Polymorphism
CIS 199 Final Review.
COP 3330 Object-oriented Programming in C++
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2006
CORBA and COM TIP Two practical techniques for object composition
Presentation transcript:

Rachana George.NET Security, Summer 2010

Introduction Sample Unmanaged C++ Library Retrieve Exported Information from the DLL Perform Platform Invoke Wrap all Imports in Managed Classes Conclusion References Overview

Why re-use unmanaged C/C++ libraries? Approach to reusing the unmanaged libraries  IJW : It Just Works –Just recompile old code!  COM: Component Object Model – Works on both managed and unmanaged environments!  P/Invoke: Platform Invoke – Allows you to import a class as functions at the attribute level! Introduction

Sample Unmanaged C++ Library

First, import class methods from the DLL. Using the Microsoft dumping tool “dumpbin.exe” to retrieve the decorated name for each function from the DLL. After executing "dumpbin /exports CppWin32Dll.dll", we get: Retrieve Exported Information from the DLL

Mapping mangled names to class members

Four methods have been imported : the constructor, the destructor, GetId, and Move, and put them in another unmanaged class called "VehicleUnman" Perform Platform Invoke

Import the exported public methods/members only. Don't import compiler-added members. They are mostly internals, and not all of them are accessible. Every imported function takes the current pointer as an input parameter, in addition to the original input parameter(s). The DLL uses this pointer to call the function properly via the decorated name or which is how the C++ compiler handles classes internally. Virtual Table or VTB has been added manually to handle virtual methods, and it contains function pointers for all virtual methods.

Wrap all the Imports in Managed Classes

Don't derive the managed "VehicleWrap" from the unmanaged "VehicleUnman". Unmanaged wrappers merely provide the storage for the original class members, including data and methods, whereas managed ones handle the class relationship. More importantly, you pass the unmanaged object to the DLL, not the managed one. Derive "CarWrap" from "VehicleWrap" to recover the original inheritance between the two unmanaged classes. This way, we don't have to handle the inheritance manually in the managed classes.

Final Output

This is an approach to reusing unmanaged C++ libraries, particularly when direct importing from unmanaged DLLs becomes necessary. The three steps to wrap unmanaged C++ DLLs for use in.NET applications:  Retrieve class member data from the DLL.  Import required class methods.  Wrap up all the imports in a managed class. Conclusion

ophttp:// op US/vbgeneral/thread/ a-bbd7-4b19-811c- bda211d2d87chttp://social.msdn.microsoft.com/Forums/en- US/vbgeneral/thread/ a-bbd7-4b19-811c- bda211d2d87c us/library/ms235636(VS.80).aspxhttp://msdn.microsoft.com/en- us/library/ms235636(VS.80).aspx References