473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using StructLayout causes app to end - no CLR exception

I've seen a number of people mention potential problems with the
StructLayoutAttribute possibly causing problems and it came up again in Ray
Z's post titled "covert between byte[] and int[]" just a bit earlier in this
newsgroup. So in trying some funky things with StructLayout and FieldOffset
to get a solution to that problem, I wrote some code that should never see
the light of day, but that nonetheless causes a total abnormal end in my
simple example (short, complete console app example posted to my blog here:
http://blogs.geekdojo.net/richard/posts/262.aspx )

What this code does is use two classes and the StructLayoutAttribute to
'unnaturally' manipulate a byte[] to become an int[]. However, after
several iterations of the loop (20 in my case) where it's doing the same
thing the program exits without an exception. Obviously this code is
contrived and not the correct way to marshal this data around. Still I'd
like to know if this is a problem security or framework-wise, or just a
"don't do that".

Thanks,
Richard
--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous voyez
mauvais C #, c'est mon défaut!
Nov 15 '05 #1
1 1278
Have you tried running on a network drive/share or some other untrusted
location? By default anything on your local machine is given full
permissions and can do anything at all (including unsafe and unverifiable
stuff like buffer overruns that crash the runtime).

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:OJ**************@TK2MSFTNGP12.phx.gbl...
I've seen a number of people mention potential problems with the
StructLayoutAttribute possibly causing problems and it came up again in Ray Z's post titled "covert between byte[] and int[]" just a bit earlier in this newsgroup. So in trying some funky things with StructLayout and FieldOffset to get a solution to that problem, I wrote some code that should never see
the light of day, but that nonetheless causes a total abnormal end in my
simple example (short, complete console app example posted to my blog here: http://blogs.geekdojo.net/richard/posts/262.aspx )

What this code does is use two classes and the StructLayoutAttribute to
'unnaturally' manipulate a byte[] to become an int[]. However, after
several iterations of the loop (20 in my case) where it's doing the same
thing the program exits without an exception. Obviously this code is
contrived and not the correct way to marshal this data around. Still I'd
like to know if this is a problem security or framework-wise, or just a
"don't do that".

Thanks,
Richard
--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous voyez mauvais C #, c'est mon défaut!

Nov 15 '05 #2

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

Similar topics

17
57362
by: gokul | last post by:
Hi, Iam a newbie to dotnet and I experience problems in using the Browser control in VB .net. Though Iam able to use it with its basic features, I need to customise it. ...
2
5877
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using...
7
29304
by: Vincent Nguyen | last post by:
Hi, Does anyone know how call Win32 native API GetTokenInformation() by using C#? Any sample code would be helpful. Thanks! Vincent
9
3937
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
8
2061
by: John B | last post by:
ARGGGGGHH I have a database class instantiated with a Using statement, then a reader also instantiated with a using statement. If the command I use to populate the reader throws an exception, then...
15
14822
by: John Alway | last post by:
Hello, I'm using a DLL I wrote in C++, and am attempting to call and use it from VB. This works fine for functions where I pass parameters by value, but I can't get pointers to work. I get...
7
6779
by: Doe | last post by:
Okay, I've given up on using the "new" WebBrowser in 2005 to do what I want to do -- tabbed browsing. It seems I really need RegisterAsBrowser and Application to get each instance of a browser...
3
3205
by: doubts | last post by:
Hi all, I am trying to convert my bulk of code from VC++ 6.0 to VC++.Net. when using std::string type variable, the application causes exception at one instance and does not cause an exception at...
2
9469
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I am trying to find a good example of SendInput. Doing a search on google I found two, one is incomplete and vague from the start and the other I copied the code and tried running it and it was...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
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
7373
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
7432
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...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.