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

Safe / Unsafe Native Methods

Hi there,

I am currently moving my API declarations into relevant classes for Safe
and Unsafe methods. My understanding is that unsafe methods are ones that
require elevated security priviledges in order to perform their function.
Is there a reference available as to what methods are safe and which unsafe?

For example I cam currently looking at the method SHGetFileInfo, I
presume this is unsafe as you would need to have priviledges in order to
view the information on specific files. Any advice on this would be greatly
appreciated.

Also, one other quick thing. Presumable <DllImport()> can be used for
*all* API declarations? I am making them all declared in a consistent way
and thought I'd best check that I'm not going to run into any weird
problems.

Cheers again and thanks in advance for any help!

Nick.
May 10 '06 #1
2 3368
> I am currently moving my API declarations into relevant classes for Safe
and Unsafe methods. My understanding is that unsafe methods are ones that
require elevated security priviledges in order to perform their function.
Is there a reference available as to what methods are safe and which unsafe?

For example I cam currently looking at the method SHGetFileInfo, I
presume this is unsafe as you would need to have priviledges in order to
view the information on specific files. Any advice on this would be greatly
appreciated.
Do you use the SuppressUnmanagedCodeSecurity attribute? If not, it
doesn't really matter if you consider a function safe or unsafe, any
calling code will need permission to call unmanaged code (which
basically means it needs full trust).

Also, one other quick thing. Presumable <DllImport()> can be used for
*all* API declarations?


Yes
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 10 '06 #2
Hi Mattias,
Do you use the SuppressUnmanagedCodeSecurity attribute? If not, it
doesn't really matter if you consider a function safe or unsafe, any
calling code will need permission to call unmanaged code (which
basically means it needs full trust).
Yup.
Yes


Okay cool, I guess its just a matter of trial and error to see if the
attribute causes any issues than. Thanks for your help, much appreciated.

Nick.
May 12 '06 #3

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

Similar topics

2
by: Elidel | last post by:
Is the use of a COM object in a c# program considered 'unsafe' code ? Does the method that calls the COM object need the 'unsafe' keyword ? Is code that calls a COM object considered unmanaged?...
4
by: CodeTyro | last post by:
My native language being C++, I've got a few questions that a couple of hours of searching on msdn didn't answer. First, when using unsafe code and pointers, what is the C# equivalent to the C++...
2
by: Aaron Cutlip | last post by:
I have been looking all over and have seen many possible ways to create a Syncronized Shared Function in VB.NET, but I would like some advice that will make my life easier. Given the following...
2
by: Jeff Chan | last post by:
I have read the documentation from msdn to try to understanding the concept of "Type safe". Would someone give me an example of code segment illustrating what is *Non* type safe? Many Thanks,...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
1
by: ltmonu | last post by:
my form is opening from menu . in which on selecting test students records are displayed in datagrid.. this record should be editable so i want to display students marks in textbox(in datagrid) ...
4
by: George2 | last post by:
Hello everyone, Here is Bjarne's exception safe sample, http://www.research.att.com/~bs/3rd_safe.pdf template <class Tclass Safe {
44
by: climber.cui | last post by:
Hi all, Does anyone have experience on the thread-safty issue with malloc()? Some people said this function provided in stdlib.h is not thread- safe, but someone said it is thread safe. Is it...
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.