{"id":5933,"date":"2012-12-03T07:00:00","date_gmt":"2012-12-03T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/12\/03\/have-you-found-any-thedailywtf-worthy-code-during-the-development-of-windows-95\/"},"modified":"2012-12-03T07:00:00","modified_gmt":"2012-12-03T07:00:00","slug":"have-you-found-any-thedailywtf-worthy-code-during-the-development-of-windows-95","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121203-00\/?p=5933","title":{"rendered":"Have you found any TheDailyWTF-worthy code during the development of Windows 95?"},"content":{"rendered":"<p>\nMott555 is interested in some\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/07\/20\/10040074.aspx#10040556\">\nsloppy\/ugly code or strange workarounds or code comments\nduring the development of Windows&nbsp;95<\/a>,\nlike &#8220;anything <a HREF=\"http:\/\/www.thedailywtf.com\/\">TheDailyWTF<\/a>-worthy.&#8221;\n<\/p>\n<p>\nI discovered that opening a particular program churned\nthe hard drive a lot when you opened it.\nI decided to hook up the debugger to see what the problem was.\nWhat I discovered was code that went roughly like this,\nin pseudo-code:\n<\/p>\n<pre>\nint TryToCallFunctionX(a, b, c)\n{\n  for each file in (SystemDirectory,\n                    WindowsDirectory,\n                    ProgramFilesDirectory(RecursiveSearch),\n                    KitchenSink,\n                    Uncle.GetKitchenSink)\n  {\n    hInstance = LoadLibrary(file);\n    fn = GetProcAddress(hInstance, \"FunctionX\");\n    if (fn != nullptr) {\n        int result = fn(a,b,c);\n        FreeLibrary(hInstance);\n        return result;\n    }\n    fn = GetProcAddress(hInstance, \"__imp__FunctionX\");\n    if (fn != nullptr) {\n        int result = fn(a,b,c);\n        FreeLibrary(hInstance);\n        return result;\n    }\n    fn = GetProcAddress(hInstance, \"FunctionX@12\");\n    if (fn != nullptr) {\n        int result = fn(a,b,c);\n        FreeLibrary(hInstance);\n        return result;\n    }\n    fn = GetProcAddress(hInstance, \"__imp__FunctionX@12\");\n    if (fn != nullptr) {\n        int result = fn(a,b,c);\n        FreeLibrary(hInstance);\n        return result;\n    }\n    FreeLibrary(hInstance);\n  }\n  return 0;\n}\n<\/pre>\n<p>\nThe code enumerated every file in the system directory,\nWindows directory,\nProgram Files directory,\nand possibly also the kitchen sink\nand their uncle&#8217;s kitchen sink.\nIt tries to load each one as a library,\nand sees if it has an export called\n<code>FunctionX<\/code>.\nFor good measure, it also tries\n<code>__imp__&shy;FunctionX<\/code>,\n<code>FunctionX@12<\/code>, and\n<code>__imp__&shy;FunctionX@12<\/code>.\nIf it finds any match, it calls the function.\n<\/p>\n<p>\nAs it happens, every single call to\n<code>Get&shy;Proc&shy;Address<\/code> failed.\nThe function they were trying to call was an internal\nfunction in the window manager that wasn&#8217;t exported.\nI guess they figured,\n&#8220;Hm, I can&#8217;t find it in <code>user32<\/code>.\nMaybe it moved to some other DLL,&#8221;\nand went through every DLL they could think of.\n<\/p>\n<p>\nI called out this rather dubious programming technique,\nand word got back to the development team for that program.\nThey came back and admitted,\n&#8220;Yeah, we were hoping to call that function,\nbut couldn&#8217;t find it,\nand the code you found is stuff we added during debugging.\nWe have no intention of actually shipping that code.&#8221;\n<\/p>\n<p>\nWell, yeah, but still, what possesses you to try such a crazy technique,\neven if only for debugging?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mott555 is interested in some sloppy\/ugly code or strange workarounds or code comments during the development of Windows&nbsp;95, like &#8220;anything TheDailyWTF-worthy.&#8221; I discovered that opening a particular program churned the hard drive a lot when you opened it. I decided to hook up the debugger to see what the problem was. What I discovered was [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2],"class_list":["post-5933","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Mott555 is interested in some sloppy\/ugly code or strange workarounds or code comments during the development of Windows&nbsp;95, like &#8220;anything TheDailyWTF-worthy.&#8221; I discovered that opening a particular program churned the hard drive a lot when you opened it. I decided to hook up the debugger to see what the problem was. What I discovered was [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/5933","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=5933"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/5933\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=5933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=5933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=5933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}