473,320 Members | 1,829 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,320 software developers and data experts.

ExecutionEngineException trying to override IInternetSecurityManager

I'm going to try to post this without having to paste in hundreds of lines
of code.

I'm trying to override IInternetSecurityManager. I'm taking sort of a
minimalist approach and adding code as I take each step because I'm not 100%
sure about what I'm doing here.

First of all, I've created a WebBrowser class. It is defined as:

public class WebBrowser : AxSHDocVw.AxWebBrowser,
IOleClientSite,
IInternetSecurityManager,
IDocHostUIHandler,
IServiceProvider

The relevant interface definitions are listed at the bottom of this post.
The interface for IDocHostUIHandler comes from MsHtmHstInterop.dll.

Now, for every implementation, I'm doing a Debug.WriteLine() with the method
name so I can see what's getting called.

My QueryService implementation is as follows:

public void QueryService(ref Guid guidService, ref Guid riid, out object
ppvObject)
{
Debug.WriteLine("QueryService");
Guid guid1 = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
if (guidService == guid1 &&
riid == guid1)
{
ppvObject = (object) this;
return;
}
ppvObject = null;
throw new COMException("", E_NO_INTERFACE);
}

QueryService gets called a bunch of times, twice matching the
IInternetSecurityManager guid.

The only other two methods called are GetHostInfo and GetOptionKeyPath. Both
methods do:

throw new COMException("", S_OK);

None of the methods in the IInternetSecurityManager interface implementation
get called.

When I call:

_webBrowser.Navigate2(ref page, ref ob, ref ob, ref ob, ref ob);

where page is: "about:blank"

After a number of QueryService calls, the two other calls mentioned, and a
bunch more QueryService calls, the Navigate2 throws a
System.ExecutionEngineException and I'm dead in the water.

Anyone have any ideas? Thanks.
Interface definitions are below:
[ComImport,
Guid("00000118-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, ref object ppmk);
void GetContainer(ref object ppContainer);
void ShowObject();
void OnShowWindow(bool fShow);
void RequestNewObjectLayout();
}

[ComImport, GuidAttribute("79EAC9EE-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
public interface IInternetSecurityManager
{
[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetSecuritySite([In] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecuritySite([Out] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int MapUrlToZone([In,MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
out UInt32 pdwZone, UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
[MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId,
ref UInt32 pcbSecurityId, uint dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int ProcessUrlAction([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy,
byte pContext, UInt32 cbContext, UInt32 dwFlags,
UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int QueryCustomPolicy([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy,
ref byte pContext, UInt32 cbContext, UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetZoneMapping(UInt32 dwZone,
[In,MarshalAs(UnmanagedType.LPWStr)] string lpszPattern,
UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetZoneMappings(UInt32 dwZone, out UCOMIEnumString ppenumString,
UInt32 dwFlags);
}

[ComImport, GuidAttribute("6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
public interface IServiceProvider
{
void QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}


Oct 8 '06 #1
2 4337
Okay, I came across a posting with something that I tried and it worked
(sort of) and I have absolutely NO idea why.

I changed QueryService from:

void QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);

to:

void QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out IInternetSecurityManager
ppvObject);
Why would that work? Isn't it just an address at the end of the day?

Okay, so now my app goes much further and all sorts of stuff gets called.
Unfortunately, it dies yet again with a null refrence exception in:

System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop

Anyone have any idea what might be causing that?

"Fredo" <fr***@hotmail.comwrote in message
news:S6******************************@giganews.com ...
I'm going to try to post this without having to paste in hundreds of lines
of code.

I'm trying to override IInternetSecurityManager. I'm taking sort of a
minimalist approach and adding code as I take each step because I'm not
100% sure about what I'm doing here.

First of all, I've created a WebBrowser class. It is defined as:

public class WebBrowser : AxSHDocVw.AxWebBrowser,
IOleClientSite,
IInternetSecurityManager,
IDocHostUIHandler,
IServiceProvider

The relevant interface definitions are listed at the bottom of this post.
The interface for IDocHostUIHandler comes from MsHtmHstInterop.dll.

Now, for every implementation, I'm doing a Debug.WriteLine() with the
method name so I can see what's getting called.

My QueryService implementation is as follows:

public void QueryService(ref Guid guidService, ref Guid riid, out object
ppvObject)
{
Debug.WriteLine("QueryService");
Guid guid1 = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
if (guidService == guid1 &&
riid == guid1)
{
ppvObject = (object) this;
return;
}
ppvObject = null;
throw new COMException("", E_NO_INTERFACE);
}

QueryService gets called a bunch of times, twice matching the
IInternetSecurityManager guid.

The only other two methods called are GetHostInfo and GetOptionKeyPath.
Both methods do:

throw new COMException("", S_OK);

None of the methods in the IInternetSecurityManager interface
implementation get called.

When I call:

_webBrowser.Navigate2(ref page, ref ob, ref ob, ref ob, ref ob);

where page is: "about:blank"

After a number of QueryService calls, the two other calls mentioned, and a
bunch more QueryService calls, the Navigate2 throws a
System.ExecutionEngineException and I'm dead in the water.

Anyone have any ideas? Thanks.
Interface definitions are below:
[ComImport,
Guid("00000118-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, ref object ppmk);
void GetContainer(ref object ppContainer);
void ShowObject();
void OnShowWindow(bool fShow);
void RequestNewObjectLayout();
}

[ComImport, GuidAttribute("79EAC9EE-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
public interface IInternetSecurityManager
{
[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetSecuritySite([In] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecuritySite([Out] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int MapUrlToZone([In,MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
out UInt32 pdwZone, UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
[MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId,
ref UInt32 pcbSecurityId, uint dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int ProcessUrlAction([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy,
byte pContext, UInt32 cbContext, UInt32 dwFlags,
UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int QueryCustomPolicy([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy,
ref byte pContext, UInt32 cbContext, UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetZoneMapping(UInt32 dwZone,
[In,MarshalAs(UnmanagedType.LPWStr)] string lpszPattern,
UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetZoneMappings(UInt32 dwZone, out UCOMIEnumString ppenumString,
UInt32 dwFlags);
}

[ComImport, GuidAttribute("6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
public interface IServiceProvider
{
void QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}


Oct 8 '06 #2
Of course, about 3 second after I made that post, I found and fixed the
problem.

I still have one issue remaining which is my ProcessUrlAction is never
called, kind of defeating the purpose of this entire exercise.

Other stuff is getting called in the IInternetSecurityManager interface.

Here's what I get from all my Debug.WriteLines. In the interest of saving
space, wherever QueryService was called multiple times, I've put it in
brackets. Otherwise there'd be about 100 of them. As you can see, though,
GetHostSecurityId is called numerous times, so it's clearly getting to my
IInternetSecurityInterface.

Any ideas?

[QueryService]
GetHostInfo
QueryService
GetOptionKeyPath
[QueryService]
GetSecurityId
[QueryService]
GetSecurityId
[QueryService]
UpdateUI
[QueryService]
HideUI
[QueryService]
TranslateUrl
GetSecurityId
[QueryService]
UpdateUI
[QueryService]
GetSecurityId
GetSecurityId
[QueryService]
GetSecurityId
GetSecurityId
GetSecurityId
GetSecurityId
GetSecurityId
GetHostInfo
[QueryService]
UpdateUI
[QueryService]
GetHostInfo
QueryService
GetOptionKeyPath
[QueryService]
GetSecurityId
[QueryService]
GetSecurityId
[QueryService]
GetSecurityId
GetSecurityId
MapUrlToZone
MapUrlToZone
GetSecurityId
GetSecurityId
[QueryService]
HideUI
[QueryService]
UpdateUI
Oct 8 '06 #3

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

Similar topics

6
by: Magnus Ullberg | last post by:
How do i convert the following structure declaration from c++ to c#? #pragma pack(push,1) //Byte alignment struct TtsrPlayerInfo { int PlayerID; int ChannelID; char NickName; int...
0
by: BeeFirst | last post by:
hi, i meet a problem when i try to develop an application with an ocx in c#. the same ocx works well in vc,but not in c#,the Microsoft .NET common language runtime throw a...
2
by: Diablo | last post by:
Hi, I am trying to get DeviceType and Serial number of a drive using WMI. ObjectQuery cmd = new ObjectQuery("select * from Win32_LogicalDisk"); ManagementObjectSearcher search = new...
2
by: TT (Tom Tempelaere) | last post by:
Hi people, In my code I get an ExecutionEngineException. I don't know what to do with it, and I can't seem to get rid of it. How can I figure out what is causing it? It always appears on the...
14
by: TT (Tom Tempelaere) | last post by:
Hi people, The code that follows throws an ExecutionEngineException. This was written in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1 (7.1.3088). The framework is .NET...
0
by: Franck | last post by:
Hi, I'm taking control over an XLS Spreadsheet in my WebService. Got a class with an Excel.Application Object which I initiate. At random time, I get a System.ExecutionEngineException error when...
3
by: NormD | last post by:
An exception 'System.ExecutionEngineException' has occurred in servername I have deployed a windows application on a server; I'm running the same on my pc using...
0
by: sagar.jawale | last post by:
Hi, In my c# windows application, i am using AxSHDocVw.AxWebBrowser. I am displaying a generated receipt html in this browser. Also, for printing the same html, i am using the following command...
0
by: selvialagar | last post by:
i've done a calibration tool. In that, there will be list of parameters and the value for the parameters are coming from the external device using TCP communication. The Screen will be refreshed once...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.