Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2004

Tip: Looking for answers? Try searching our database.

Profiling API & '#~' Metadata

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nadav - 08 Oct 2004 15:33 GMT
Hi,

The problem:
**********
I am using the 'MetaData API' ('AssemblyLoadFinished') to manipulate an
assembly being loaded,  I am changing the '#~' section of the metadata, this
section contain the metadata tables, when a class found in the manipulated
assembly is being created I get the following exception: 'Culture name X is
not supported', my assumption is that the .NET framework use the '#~' section
before 'AssemblyLoadFinished' is being called, 'AssemblyLoadFinished' is the
point where I do the metadata manipulation so changing the metadata tabels
after it was consumed by the Framework may cause such an exception.

Some Questions:
*************
A. Does my assumption is true? does 'AssemblyLoadFinished' is called AFTER
the '#~' section was used by the framework?
B. Taking in mind the my assumption ( given in section A ) is true, is there
a point where the '#~' section may be altered BEFORE being used by the .NET
framework? ('AssemblyLoadStarted’ will not be appropriate as there is no way
to get there a pointer to the loaded PE headers… )
C. Any other suggestions to resolve my problem will be appreciated.

P.S.
I have also tried to intercept the 'LoadLibrary' API, apparently the .NET
framework use CreateFile, ReadFile, ... to access a managed assembly, so
intercepting 'LoadLibrary' in this manner cannot help, interception of
CreateFile, ReadFile, ... is really an implementation overkill ( I would
rather write a file system filter driver to achive filesystem level control
of data being extracted from the file ).
Signature

Nadav
   http://www.ddevel.com

Nadav - 08 Oct 2004 21:05 GMT
Another exception generated is 'Could not load type X ...' which make my
assumption even stronger...

> Hi,
>
[quoted text clipped - 26 lines]
> rather write a file system filter driver to achive filesystem level control
> of data being extracted from the file ).
"Jonathan Keljo [MS]" - 13 Oct 2004 17:36 GMT
Nadav,
    What changes are you trying to make to the metadata? There are some
articles on MSDN that are good guides to instrumenting metadata,
particularly this one:
http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfilingAPI/default.aspx

Jonathan

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: Profiling API & '#~' Metadata
| thread-index: AcStchpYQstVSju5SMqlp0NDa9g5vQ==
[quoted text clipped - 43 lines]
| > a point where the '#~' section may be altered BEFORE being used by the .NET
| > framework? ('AssemblyLoadStarted??? will not be appropriate as there is
no way
| > to get there a pointer to the loaded PE headers??? )
| > C. Any other suggestions to resolve my problem will be appreciated.
[quoted text clipped - 6 lines]
| > rather write a file system filter driver to achive filesystem level control
| > of data being extracted from the file ).
Nadav - 14 Oct 2004 14:31 GMT
- Well, Actually, What I am tring to do is to implement some kind of
impersonation mechanism that will enable one managed assembly to be
impersonated to the other, during runtime I wish to replace the impersonated
metadata with the original metadata so the CLR will treat it as the 'real'
assembly, this update is done using the Unmanaged Profiling API.
- updating to the real metadata is done through the 'AssemblyLoadFinished'
callback. apparently, the .NET framework use the metadata before calling
'AssemblyLoadFinished', this impose a problem since there is no place where
the existing metadata cound be replaced beafor teh .NET Framework use it.
- I have considered merging the metadata on runtime BUT, this is not
practical as the tokens will be remapped and the calling IL would have to
updated.

Does what I am trying to achieve is feasible? how? any help comments or
remarks would be appreciated.

> Nadav,
>      What changes are you trying to make to the metadata? There are some
[quoted text clipped - 78 lines]
> control
> | > of data being extracted from the file ).
"Jonathan Keljo [MS]" - 29 Oct 2004 02:02 GMT
Sorry, looks like I'd let this thread drop off my radar.

Wow, what you describe sounds really scary. Can you give me an idea of the
higher-level problem you're trying to solve?

Jonathan

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: Profiling API & '#~' Metadata
| thread-index: AcSx8gxB5cFl+hMfTWqngm+YRX4Ngg==
| X-WBNR-Posting-Host: 192.115.106.236
| From: "=?Utf-8?B?TmFkYXY=?=" <Nadav@discussions.microsoft.com>
| References:  <EFF9CEE6-1659-486E-BE41-4E65E92FD882@microsoft.com>
<A6E63033-D188-4C1F-BB82-006A130FB70A@microsoft.com>
<LpEVALUsEHA.2092@cpmsftngxa10.phx.gbl>
| Subject: RE: Profiling API & '#~' Metadata
| Date: Thu, 14 Oct 2004 06:31:01 -0700
[quoted text clipped - 35 lines]
| > articles on MSDN that are good guides to instrumenting metadata,
| > particularly this one:

http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfilingAPI/default.aspx

| > Jonathan
| >
[quoted text clipped - 57 lines]
| > .NET
| > | > framework? ('AssemblyLoadStarted???????? will not be appropriate as
there is
| > no way
| > | > to get there a pointer to the loaded PE headers??????? )
[quoted text clipped - 11 lines]
| > control
| > | > of data being extracted from the file ).
Nadav - 29 Oct 2004 11:30 GMT
Well, I have worked things out, in a few days you could see a working UPDATED
version at
http://www.ddevel.com/Home/main.asp?Proj=DrNETObfuscator/DrNETObf.asp

> Sorry, looks like I'd let this thread drop off my radar.
>
[quoted text clipped - 150 lines]
> | > control
> | > | > of data being extracted from the file ).

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.