By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

supressing runtime security checks in C++

P: n/a
How can I supress runtime security checks in a mixed-mode C++ assembly?

SuppressUnmanagedCodeSecurityAttribute apparently only works for P/Invoke
and COM interop.

I've got a somewhat chatty interface and can clearly see these checks being
made using PerfMon. In this context I can't reduce the chattiness...

Ideas?

Nick Hodapp
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Not sure what counter you are looking at, but IJW should not perform a
stackwalk as the target function is already part of a managed assembly.
In contrast COM and PInvoke interop always calls to an unmanaged assembly,
so here you see security stackwalks unless you suppress them.

Willy.

"Nick Hodapp" <Ni********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
How can I supress runtime security checks in a mixed-mode C++ assembly?

SuppressUnmanagedCodeSecurityAttribute apparently only works for P/Invoke
and COM interop.

I've got a somewhat chatty interface and can clearly see these checks
being
made using PerfMon. In this context I can't reduce the chattiness...

Ideas?

Nick Hodapp

Nov 17 '05 #2

P: n/a
Willy Denoyette [MVP] wrote:
Not sure what counter you are looking at, but IJW should not perform a
stackwalk as the target function is already part of a managed
assembly. In contrast COM and PInvoke interop always calls to an
unmanaged assembly, so here you see security stackwalks unless you
suppress them.


Normally you have an managed c++ assembly only for this reason, that you
either want to call Win32-APIs directly or want to make COM.

And here is the question: How to avoid Runtime-Security cheks in this
transition from managed C++ to the unmanaged world.
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #3

P: n/a

"Jochen Kalmbach" <no********************@holzma.de> wrote in message
news:Xn**********************************@207.46.2 48.16...
Willy Denoyette [MVP] wrote:
Not sure what counter you are looking at, but IJW should not perform a
stackwalk as the target function is already part of a managed
assembly. In contrast COM and PInvoke interop always calls to an
unmanaged assembly, so here you see security stackwalks unless you
suppress them.


Normally you have an managed c++ assembly only for this reason, that you
either want to call Win32-APIs directly or want to make COM.

And here is the question: How to avoid Runtime-Security cheks in this
transition from managed C++ to the unmanaged world.

Consider following sample, here I'm calling into unmanaged code
(_Fillbuffer) and this function calls StringCbCopyW (a safestring function
from safestr.lib).
So there a two transitions from managed to unmanaged code using the IJW
thunk - NOT a PInvoke thunk.
When running this and watching the perfmon counter "CLR security stackwalks"
I see this remain at 0.

//
#include <strsafe.h> // used by safe string functions (strsafe.lib)
#pragma unmanaged
void _FillBuffer(int i)
{
wchar_t *buff = new wchar_t[ 200 ];
// copy some text using safe string functions
StringCbCopyW( ch, 200, L"This text is safely copied to buff");
}
#pragma managed
void main()
System::Console::ReadLine(); // pause to select perfom counters
{
for (int i = 0; i < 10 ; i++)
{
_FillBuffer(i);
}
}

Willy.
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.