Accessing .NET private members
-
I haven't seen the review yet, although with a little creative casting (yea, I'm a C++ programmer) almost any private member can be accessed. I'm not sure why you would want to do that though... :~ What's the point? Martin C Cook Who needs cyberspace when you have CP space? :)
Martin C Cook wrote: with a little creative casting (yea, I'm a C++ programmer) almost any private member can be accessed Yeah but it's more work, and you may very well be wrong depending on the compiler, etc. The article review implied that you could do this pretty easily and accurately, using introspection, and some of the assembly tools(?). Anyways just seemed kind of funny. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
-
I haven't seen the review yet, although with a little creative casting (yea, I'm a C++ programmer) almost any private member can be accessed. I'm not sure why you would want to do that though... :~ What's the point? Martin C Cook Who needs cyberspace when you have CP space? :)
I take back my previous post-it's not hard at all in C++ - I'd never even thought about it before, but just saw an example in one of hte postings. Doh :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
-
Martin C Cook wrote: with a little creative casting (yea, I'm a C++ programmer) almost any private member can be accessed Yeah but it's more work, and you may very well be wrong depending on the compiler, etc. The article review implied that you could do this pretty easily and accurately, using introspection, and some of the assembly tools(?). Anyways just seemed kind of funny. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
Jim Crafton wrote: The article review implied that you could do this pretty easily and accurately, using introspection, and some of the assembly tools(?). Anyways just seemed kind of funny. Well, for $10, I'll splurge to possibly learn something new. Umm, the next thing I was about to say would be very unethical, not to mention illegal. :-O (Although, I must say, this guy looks like he's got quite the racket going--lots of little $10, 50 page books. Maybe this is the future of publishing, eh?) Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
Every line of code is a liability - Taka Muraoka
Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files" -
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
I really like the:
#define private public
#define protected publicway of doing it in C++... does this work.. can't try it here. Regards, Brian Dela :-)
-
I really like the:
#define private public
#define protected publicway of doing it in C++... does this work.. can't try it here. Regards, Brian Dela :-)
Brian Delahunty wrote: I really like the: #define private public #define protected public way of doing it in C++... does this work.. can't try it here. Yes, it does work in VS 6. ------------------------------------------ "What happened in that Rhode Island club is shocking. To think that over a hundred people would attend a Great White concert." - The Onion
-
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
Jim Crafton wrote: I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. I never tried to do such a thing. In fact, IMHO, it is an abomination. But if .NET allows you to do this, I bet you can do it through Reflection or through IL. For, e.g., a field, maybe through reflection, using a FieldInfo object, you could set/get a field value. If this doesn’t work, I bet the ldfield/ldsfield opcode would do the trick. My latest article: GBVB - Converting VB.NET code to C#
-
Jim Crafton wrote: The article review implied that you could do this pretty easily and accurately, using introspection, and some of the assembly tools(?). Anyways just seemed kind of funny. Well, for $10, I'll splurge to possibly learn something new. Umm, the next thing I was about to say would be very unethical, not to mention illegal. :-O (Although, I must say, this guy looks like he's got quite the racket going--lots of little $10, 50 page books. Maybe this is the future of publishing, eh?) Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
Every line of code is a liability - Taka Muraoka
Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files" -
Brian Delahunty wrote: I really like the: #define private public #define protected public way of doing it in C++... does this work.. can't try it here. Yes, it does work in VS 6. ------------------------------------------ "What happened in that Rhode Island club is shocking. To think that over a hundred people would attend a Great White concert." - The Onion
Brit wrote: Yes, it does work in VS 6. Cool :-D Regards, Brian Dela :-)
-
this guy? You've never heard of Dan Appleman? Pretty big in the vb world. He's written a pretty good whitepaper (and book too) on regex.
tidge wrote: this guy? You've never heard of Dan Appleman? I must confess my ignorance. But then again, I am happy to remain ignorant of everything, especially having to do with the VB world. :-D Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
Every line of code is a liability - Taka Muraoka
Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files" -
tidge wrote: this guy? You've never heard of Dan Appleman? I must confess my ignorance. But then again, I am happy to remain ignorant of everything, especially having to do with the VB world. :-D Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
Every line of code is a liability - Taka Muraoka
Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files" -
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
It is done through reflection... But you also need to give your code the rights to query for private members... Use the "Administrative Tools/Microsoft .NET Framework Configuration" utility to create permission sets and assign them to code groups (assemblies) When running your code from the VS.NET IDE you might actually have those rights, even though your code don't have those right when run as standalone. I dunno why this is, but one should keep it in mind when developing/using this ability... Even though one would expect privates to remain private whatsoever, this feature can come in quite handy when it comes to creating your own generic classes for serialization/deserialization. (Been there, done that...)
-
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
I consider it rude, not to mention an invasion of privacy, to access anyone's private members on the 'net. There oughtta be a law!:mad:
"Ask not for whom the bell tolls;
It tolls for thee..." -
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
It's obvious that they haven't spent all that much time with .NET. They're going at it a completely roundabout way. You can do it very easily through Reflection.
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
-
It's obvious that they haven't spent all that much time with .NET. They're going at it a completely roundabout way. You can do it very easily through Reflection.
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
Reflection allows you to easily list the members of a class (even private) but can you actually call those members easily? cheers, Chris Maunder
-
I just noticed a book review[^] on slashdot regarding techniques that allow you to access private members of classes. Anyone here know or has heard anything about this? Thought it was interesting, not sure how big a deal it is, though the book review seems to imply that it is not very difficult to do at all. Seems weird. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
The comments under this are truly great: "OMG .NET sucks and is so secure. Perl is SO much better because you can do this anyway. Man - Microsoft really screwed up letting this bug through QA. Lucky that Java sandboxes everything so you can't do this so it's more secure. Blah blah blah blah blah". yaawwwwwwn cheers, Chris Maunder
-
I consider it rude, not to mention an invasion of privacy, to access anyone's private members on the 'net. There oughtta be a law!:mad:
"Ask not for whom the bell tolls;
It tolls for thee..."Roger Wright wrote: to access anyone's private members on the 'net :laugh: How about "In C++, only your
friend
s can handle yourprivate
parts" ?
Vikram. ----------------------------- My site due for a massive update Radioactive cats have 18 half-lives. "Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design. -
I consider it rude, not to mention an invasion of privacy, to access anyone's private members on the 'net. There oughtta be a law!:mad:
"Ask not for whom the bell tolls;
It tolls for thee..."Good one! :laugh: I don't keep much
private
these days, but I do like to feelprotected
. ;) Anna :rose: Homepage | My life in tears "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work. Trouble with resource IDs? Try the Resource ID Organiser Visual C++ Add-In