{"id":14,"date":"2008-09-07T03:07:51","date_gmt":"2008-09-07T03:07:51","guid":{"rendered":"http:\/\/www.themissingdocs.net\/wordpress\/?p=14"},"modified":"2008-09-07T03:07:51","modified_gmt":"2008-09-07T03:07:51","slug":"about-time-to-post-again","status":"publish","type":"post","link":"https:\/\/www.themissingdocs.net\/?p=14","title":{"rendered":"About time to post again"},"content":{"rendered":"<p>Its been a while, but I plan a couple of posts.<\/p>\n<p>Firstly, I was recently reminded of a .Net &#8216;trick&#8217; I learnt from a friend.  We recently took this trick to a new level of &#8216;evil&#8217;.<\/p>\n<p>Strings are immutable right&#8230; well sort of.<\/p>\n<blockquote><p>          string a = &#8220;a&#8221;;<br \/>\n            GCHandle handle = GCHandle.Alloc(a, GCHandleType.Pinned);<br \/>\n            char[] newString = new char[] {&#8216;b&#8217;};<br \/>\n            Marshal.Copy(newString, 0, handle.AddrOfPinnedObject(), 1);<br \/>\n            Console.Out.WriteLine(a);<br \/>\n            Console.ReadKey();\n<\/p><\/blockquote>\n<p>This program outputs the character b.  All without actually using the unsafe keyword.  The unsafe APIs already exist there to use. (They all have unmanaged permission link demand on them.)<\/p>\n<p>Taking things to the next level however, allows for a bit of fun.<\/p>\n<p>Examples include:<br \/>\nEnvironment.NewLine, change it to any two characters of your choice.<br \/>\nException messages, cause it once, change it and from then on it says whatever you like.<\/p>\n<p>With a bit of reflection however, you can do alot of damage.  For instance, change every string which can be found by walking the object hierarchy starting from static fields.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Its been a while, but I plan a couple of posts. Firstly, I was recently reminded of a .Net &#8216;trick&#8217; I learnt from a friend. We recently took this trick to a new level of &#8216;evil&#8217;. Strings are immutable right&#8230; well sort of. string a = &#8220;a&#8221;; GCHandle handle = GCHandle.Alloc(a, GCHandleType.Pinned); char[] newString = &hellip; <a href=\"https:\/\/www.themissingdocs.net\/?p=14\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">About time to post again<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-net-stuff"],"_links":{"self":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":0,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}