{"id":12,"date":"2009-12-18T20:37:00","date_gmt":"2009-12-18T20:37:00","guid":{"rendered":"http:\/\/oguzkartal.net\/blog\/?p=12"},"modified":"2021-10-31T16:05:13","modified_gmt":"2021-10-31T13:05:13","slug":"windows-7-media-center-ve-media-center-sdk-uyumsuzlugu","status":"publish","type":"post","link":"https:\/\/www.oguzkartal.net\/blog\/index.php\/2009\/12\/18\/windows-7-media-center-ve-media-center-sdk-uyumsuzlugu\/","title":{"rendered":"Windows 7 Media Center ve Media Center SDK Uyumsuzlu\u011fu"},"content":{"rendered":"<p>Birka\u00e7 g\u00fcn \u00f6nce kulland\u0131\u011f\u0131m Media Center i\u00e7in plug-in yazma ihtiyac\u0131 do\u011fdu. Bilgisayar\u0131mda ise Windows 7 y\u00fckl\u00fc oldu\u011fundan, Media Center 6.1 versiyonunu kullan\u0131yorum. Plug-in\u2019i yazmak i\u00e7in \u00f6ncelikle Media Center SDK\u2019s\u0131na ihtiyac\u0131m oldu. Media Center plug-in\u2019leri managed ortamda host edildi\u011finden plug-in\u2019lerimizi .NET platformu alt\u0131nda yazmam\u0131z gerekiyor. SDK\u2019y\u0131 indirdim ve Media Center projesini a\u00e7\u0131p plug-in\u2019i yazmaya ba\u015flam\u0131\u015ft\u0131m.\u00a0 Ta ki ilk Build i\u015fleminin ba\u015fars\u0131z olmas\u0131na kadar.<\/p>\n<p>Asl\u0131nda Build i\u015flemi Compiling anlam\u0131nda ba\u015far\u0131l\u0131yd\u0131. Ba\u015far\u0131s\u0131z olan k\u0131s\u0131m compile edilen Media Center plug-in Dll\u2019inin McmlVerifer taraf\u0131ndan verify edilme i\u015fleminde idi. A\u015fa\u011f\u0131da g\u00f6rd\u00fc\u011f\u00fcn\u00fcz post-build s\u0131ras\u0131nda McmlVerifier\u2019in \u00e7\u00f6kmesini g\u00f6r\u00fcyoruz.<\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med0.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-60\" title=\"Med0\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med0.png\" alt=\"\" width=\"671\" height=\"455\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med0.png 839w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med0-300x203.png 300w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/a><\/p>\n<p>Output Window\u2019da ise \u015fu hatay\u0131 g\u00f6rmekteyiz.<\/p>\n<p><span style=\"font-family: 'Courier New';\">Unhandled Exception: System.MissingMethodException: Method not found: &#8216;Void Microsoft.MediaCenter.UI.Application.RegisterUIThread()&#8217;.<br \/>\nat MediaCenter.McmlVerifier.Main()<\/span><\/p>\n<p>Hatadan anlad\u0131\u011f\u0131m\u0131z, <strong>Main<\/strong> metodunda kullan\u0131lan RegisterUIThread() adl\u0131 metodun olmamas\u0131. Bu noktada SDK\u2019n\u0131n post-build event (in\u015fa sonras\u0131 olay) s\u0131ras\u0131nda kulland\u0131\u011f\u0131 McmlVerifer\u2019in neden <strong>RegisterUIThread<\/strong> metodunu bulundurmad\u0131\u011f\u0131 sorusu akl\u0131m\u0131za gelebilir. \u00a0Ben de burada kullan\u0131lan SDK\u2019n\u0131n son s\u00fcr\u00fcm Media Center ile farkl\u0131l\u0131k g\u00f6sterdi\u011fini d\u00fc\u015f\u00fcnd\u00fcm ve bunun do\u011frulu\u011funu kesinle\u015ftirmek i\u00e7in ara\u015ft\u0131rma k\u0131sm\u0131na ge\u00e7tim. \u0130lk \u00f6nce <a href=\"http:\/\/www.red-gate.com\/products\/reflector\/\" target=\"_blank\" rel=\"noopener\">.NET Reflector<\/a> ile McmlVerifier.exe dosyas\u0131n\u0131 inceledim. \u00c7\u00fcnk\u00fc McmlVerifier bir .NET uygulamas\u0131d\u0131r.<\/p>\n<p>McmlVerifier.exe %windir%\\ehome dizini alt\u0131nda bulunmaktad\u0131r.\u00a0 Uygulamay\u0131 .NET Reflector ile y\u00fckleyip Main metodunun kodunu inceledi\u011fimizde ger\u00e7ekten Main metodu i\u00e7inde <strong>RegisterUIThread<\/strong> \u00e7a\u011fr\u0131s\u0131 yap\u0131ld\u0131\u011f\u0131n\u0131 g\u00f6r\u00fcyoruz.<\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-56\" title=\"Med1\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med1.png\" alt=\"\" width=\"647\" height=\"454\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med1.png 809w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med1-300x210.png 300w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/a><\/p>\n<p>Se\u00e7ili sat\u0131rda g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi RegisterUIThread Microsoft.MediaCenter.UI isimli assembly\u2019deki Application s\u0131n\u0131f\u0131na ait static bir metod. Uygulaman\u0131n ald\u0131\u011f\u0131 referansa bakarsak al\u0131nan referans\u0131n ge\u00e7ersiz oldu\u011funu g\u00f6r\u00fcyoruz. \u00c7\u00fcnk\u00fc ortada uygulama ve reference library uyumsuzlu\u011fu mevcut.<\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-57\" title=\"Med2\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med2.png\" alt=\"\" width=\"585\" height=\"454\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med2.png 731w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med2-300x232.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-58\" title=\"Med3\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med3.png\" alt=\"\" width=\"585\" height=\"454\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med3.png 731w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med3-300x233.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><\/p>\n<p>G\u00f6r\u00fcld\u00fc\u011f\u00fc gibi sistemimde y\u00fckl\u00fc Microsoft.MediaCenter.UI assembly\u2019si 6.1 versiyonunda. Burada \u015fu sonucu \u00e7\u0131karabiliriz. Media Center SDK kurulur iken McmlVerifer dosyas\u0131n\u0131 g\u00fcncellemek istemi\u015f ve var olan yeni McmlVerifier.exe \u00fcst\u00fcne overwrite etmi\u015f g\u00f6r\u00fcn\u00fcyor. Zaten incelerken yeni versiyon Microsoft.MediaCenter.UI assembly\u2019sinin Application s\u0131n\u0131f\u0131nda RegisterUIThread metodunun olmad\u0131\u011f\u0131n\u0131 g\u00f6rd\u00fcm. \u0130nceledi\u011fim kadar\u0131 ile bunun sebebi yeni versiyon assembly\u2019nin UI Thread\u2019i haricen register etmesi yerine otomatik olarak kendi i\u00e7erisinde bir Dispatcher yard\u0131m\u0131 ile UI i\u015flemlerini yap\u0131yor olmas\u0131. \u00c7\u00fcnk\u00fc Windows 7 ile gelen Media Center WPF tabanl\u0131 animation y\u00f6ntemlerini kullanmaktad\u0131r ve UI i\u015flemleri i\u00e7in Dispatcher kullan\u0131l\u0131r. Dispatcher sayesinde UI manager\u2019a aktif thread context\u2019inin verilmesine gerek yoktur.<\/p>\n<p>Peki, sorunun belirledi\u011fimize g\u00f6re \u00e7\u00f6z\u00fcmler ne olabilir?<\/p>\n<p>Bu problemin \u00e7\u00f6z\u00fclmesi i\u00e7in ya ilgili McmlVerifer kodunun RegisterUIThread metodunu \u00e7a\u011f\u0131rmas\u0131n\u0131 engellemek ya da orjinal 6.1 versiyon McmlVerifer uygulamas\u0131 ile de\u011fi\u015ftirmek yeterli gelebilir . Ben varolan McmlVerifier\u2019den nas\u0131l RegisterUIThread metodunu devre d\u0131\u015f\u0131 b\u0131rakaca\u011f\u0131n\u0131z\u0131 anlatmak istiyorum.<\/p>\n<p>Hat\u0131rlayal\u0131m. McmlVerifier Main metodu i\u00e7inde RegisterUIThread metodunu \u00e7a\u011f\u0131ran k\u0131s\u0131m<\/p>\n<p><span style=\"font-family: 'Courier New';\">L_000a: call void [Microsoft.MediaCenter.UI]Microsoft.MediaCenter.UI.Application::RegisterUIThread()<\/span><\/p>\n<p>Kodu idi. MSIL olarak g\u00f6stermek bize fayda sa\u011flayacak. Yani metodun 0xA offseti ilgili kodu bar\u0131nd\u0131r\u0131yor. \u015eimdi ilgili metodu patch etmek i\u00e7in ayr\u0131 CFF Explorer ile inceleyelim.<\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-55\" title=\"Med4\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med4.png\" alt=\"\" width=\"704\" height=\"424\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med4.png 880w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med4-300x180.png 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><\/p>\n<p>G\u00f6r\u00fcld\u00fc\u011f\u00fc gibi .NET Directory\u2019si alt\u0131nda .NET\u2019e ait bilgiler bulunuyor. Buradan ilk table d\u00fc\u011f\u00fcm\u00fc de .NET\u2019in Referans, Metod, Field gibi bilgilerini tutmaktad\u0131r. Zaten bu bilgiler sayesinde .NET Reflector gibi uygulamalar .NET uygulamalar\u0131n\u0131 decompile edebiliyorlar. Ve tabi bu bilgiler decompiling i\u00e7in de\u011fil managed bir ortam sa\u011flamak i\u00e7in bulunmas\u0131 gereken bilgiler. Main metodunu g\u00f6r\u00fcyoruz. \u0130lgili metodu MSIL olarak disassembly edelim.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-54\" title=\"Med5\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med5.png\" alt=\"\" width=\"446\" height=\"456\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med5.png 557w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med5-293x300.png 293w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/><\/p>\n<p>Dissambly sonras\u0131 demin \u00f6\u011frendi\u011fimiz gibi 0xA offsetinde ilgili metod \u00e7a\u011fr\u0131s\u0131 ve bu metodun adresi mevcut. Bizim buray\u0131 nop i\u015flemine sokmam\u0131z bu k\u0131sm\u0131 deaktif etmeye yarayacakt\u0131r. Bu uygulama i\u00e7in metodun ham ofset adresi;<\/p>\n<p>RVA: 0x20d0 -&gt; Offset: 0x2d0 + .0xC ( 12 byte NET kod giri\u015f header bilgisi i\u00e7in) + 0xA (RegisterUIThread ofset) = 0x2e6 = Path edilecek offset.<\/p>\n<p>komut uzunlu\u011fumuz ise 0x5 byte.<\/p>\n<p>Bizim bu aray\u0131 MSIL Nop ile doldurmam\u0131z yeterlidir. Yani 0x0. \u00a0Buradaki nop i\u015flemini x86 assembly\u2019deki 0x90 nop ile kar\u0131\u015ft\u0131rmay\u0131n. MSIL x86 instruction set&#8217;ten tamamen farkl\u0131d\u0131r.<\/p>\n<p>Bu i\u015fi kolayl\u0131kla yapabilmeniz i\u00e7in minik bir tool yazd\u0131m. Kaynak kodlar\u0131 ile birlikte verece\u011fim. Ama \u00f6ncelikle nas\u0131l kullan\u0131l\u0131r g\u00f6relim.<\/p>\n<p>Bir console a\u00e7\u0131n. Ama console\u2019u a\u00e7arken \u201c<strong>Run As Administrator<\/strong>\u201d veya \u201c<strong>Y\u00f6netici Olarak \u00c7al\u0131\u015ft\u0131r<\/strong>\u201d se\u00e7ene\u011fi ile a\u00e7man\u0131z gerek. Aksi halde uygulama patch i\u015flemini yapamayabilir. Ben administrator yetkileri ile console\u2019u a\u00e7t\u0131\u011f\u0131n\u0131z\u0131 varsay\u0131yorum. Bu i\u015flemden sonra &#8220;mcmlverifierpatch McmlVeriferPath&#8221; komutunu kullanarak patch i\u015flemini tamaml\u0131yorsunuz. McmlVerifier&#8217;\u0131n varsay\u0131lan olarak yolu\u00a0<strong><em>C:\\Windows\\ehome\\McmlVerifier.exe<\/em><\/strong>\u2019dir.<\/p>\n<p>Patch yapt\u0131ktan sonra .NET Reflector\u2019da ugulamaya bakal\u0131m.<\/p>\n<p><a href=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-53\" title=\"Med6\" src=\"http:\/\/oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med6.png\" alt=\"\" width=\"617\" height=\"454\" srcset=\"https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med6.png 771w, https:\/\/www.oguzkartal.net\/blog\/wp-content\/uploads\/2009\/12\/Med6-300x220.png 300w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/a><\/p>\n<p>Uygulama ba\u015far\u0131yla patchlenmi\u015f. \u015eimdi uygulamay\u0131 rahatl\u0131kla \u00e7al\u0131\u015ft\u0131rabiliriz. Visual Studio ile projemizi yeniden derledi\u011fimizde mutlu sonuca ula\u015f\u0131yoruz.<\/p>\n<p><span style=\"font-family: 'Courier New';\">Compile complete &#8212; 0 errors, 0 warnings<br \/>\nLVMForMediaCenter -&gt; D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\bin\\Debug\\LVMForMediaCenter.dll<br \/>\n%windir%\\eHome\\McmlVerifier.exe -verbose -assemblyredirect:&#8221;D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\bin\\Debug&#8221; -directory:&#8221;D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup&#8221;<br \/>\nMicrosoft (R) MediaCenter Markup Language (MCML) Verifier version 1.00<br \/>\nCopyright (C) Microsoft Corporation 2006. All rights reserved. <\/span><\/p>\n<p><span style=\"font-family: 'Courier New';\">file:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\Button.mcml &#8211; OK!<br \/>\nfile:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\Controls.mcml &#8211; OK!<br \/>\nfile:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\Menu.mcml &#8211; OK!<br \/>\nfile:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\RepeatItem.mcml &#8211; OK!<br \/>\nfile:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\Styles.mcml &#8211; OK!<br \/>\nfile:\/\/D:\\src\\LVMForMediaCenter\\LVMForMediaCenter\\Markup\\Test.mcml &#8211; OK!<br \/>\nNo errors detected.<\/span><\/p>\n<p>Evet. Bu yaz\u0131n\u0131n da sonuna geldim. Umar\u0131m faydal\u0131 olmu\u015ftur. Unutmadan patch tool\u2019u ve kodunu. <a href=\"http:\/\/oguzkartal.net\/files\/mcmlverifierpatch.zip\">Buradan<\/a> indirebilirsiniz.<\/p>\n<p>\u0130yi geceler\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Birka\u00e7 g\u00fcn \u00f6nce kulland\u0131\u011f\u0131m Media Center i\u00e7in plug-in yazma ihtiyac\u0131 do\u011fdu. Bilgisayar\u0131mda ise Windows 7 y\u00fckl\u00fc oldu\u011fundan, Media Center 6.1 versiyonunu kullan\u0131yorum. Plug-in\u2019i yazmak i\u00e7in \u00f6ncelikle Media Center SDK\u2019s\u0131na ihtiyac\u0131m oldu. Media Center plug-in\u2019leri managed ortamda host edildi\u011finden plug-in\u2019lerimizi .NET platformu alt\u0131nda yazmam\u0131z gerekiyor. SDK\u2019y\u0131 indirdim ve Media Center projesini a\u00e7\u0131p plug-in\u2019i yazmaya ba\u015flam\u0131\u015ft\u0131m.\u00a0 Ta&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"twitterCardType":"","cardImageID":0,"cardImage":"","cardTitle":"","cardDesc":"","cardImageAlt":"","cardPlayer":"","cardPlayerWidth":0,"cardPlayerHeight":0,"cardPlayerStream":"","cardPlayerCodec":"","footnotes":""},"categories":[34],"tags":[8,5,6,10,9,7],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-oses","tag-crash","tag-mce","tag-mce-sdk","tag-media-center","tag-visual-studio","tag-windows-7"],"_links":{"self":[{"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":8,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":924,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/posts\/12\/revisions\/924"}],"wp:attachment":[{"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oguzkartal.net\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}