Accessing object vtables

  • Thread starter Thread starter schoenfeld1
  • Start date Start date
S

schoenfeld1

I'm trying to workaround a microsoft bug by overring one of their
methods without subclassing.

I need to basically change a Control's vtable entry for the method
PaintBackground method and point it to my own custom method.

Are there facilities to inspect / modify an object vtable with the
standard .net libraries?

If not, what does the object format look like in memory?
 
I'm trying to workaround a microsoft bug by overring one of their
methods without subclassing.

I need to basically change a Control's vtable entry for the method
PaintBackground method and point it to my own custom method.

Are there facilities to inspect / modify an object vtable with the
standard .net libraries?

If not, what does the object format look like in memory?

I would certainly *hope* that you couldn't do that - the security
implications are horrific. You certainly won't be able to do it in safe
code.
 
Jon Skeet said:
I would certainly *hope* that you couldn't do that - the security
implications are horrific. You certainly won't be able to do it in safe
code.

The MethodRental class offers something similar, actually. It should be
possible in safe code, just not trusted code, IMHO.
 
Daniel O'Connell said:
The MethodRental class offers something similar, actually. It should be
possible in safe code, just not trusted code, IMHO.

Similar yes, but not usable in this scenario. SwapMethodBody is only for
user created dynamic modules and types.

Willy.
 
Willy said:
Similar yes, but not usable in this scenario. SwapMethodBody is only for
user created dynamic modules and types.

Willy.

It should be possible generally, given that all modules reside in a
single process boundary. I found a "better" solution to this problem
anyway (decompile microsoft code, fix the bug, and recompile it).
 
And break your license agreement! If you ever succeed in (successfully)
recompiling a complete assembly :-)

Willy.
 
Willy said:
And break your license agreement! If you ever succeed in (successfully)
recompiling a complete assembly :-)

Willy.

Not the entire assembly, just a few controls. The bug was Microsoft
failure to support XP themes in windows forms.

MSDN claims it does, but if anyone actually bothered to test it they
would see a totally different story:

1. nested groupbox's labels are totally screwed up.
2. tabpage does not color using xp theme.
3. group box does not color using xp theme.

These bugs have been well known for years yet no one in MS bothered to
fix it. All they did was update MSDN with claims that xp themes are
fully supported in .net.
 
Willy Denoyette said:
Similar yes, but not usable in this scenario. SwapMethodBody is only for
user created dynamic modules and types.

Yeah, I couldn't recall if that restriction was there or not. The docs I
have are kinda weak right now. Still, with a little ingenuity...
 
MSDN claims it does, but if anyone actually bothered to test it they
would see a totally different story:

1. nested groupbox's labels are totally screwed up.
2. tabpage does not color using xp theme.
3. group box does not color using xp theme.

These bugs have been well known for years yet no one in MS bothered to
fix it.

For #1 you have this

FIX: The captions of the GroupBox controls in your Windows Forms
application may be truncated and may appear in the wrong font after
you install the .NET Framework 1.1 Service Pack 1
http://support.microsoft.com/?kbid=890828




Mattias
 
Back
Top