<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Fabio Pintos</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/fpintos/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/fpintos/feed.xml</link>
    <description />
    <lastBuildDate>Thu, 28 Jun 2018 01:29:36 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>OneDrive not updated after upgrade to Windows 10 1709</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/onedrive-not-updated-after-upgrade-to-windows-10-1709</link>
      <pubDate>Wed, 18 Oct 2017 03:15:46 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/?p=105</guid>
      <description><![CDATA[For whatever reason, OneDrive did not update in one of my machines after I upgraded to the new...]]></description>
      <content:encoded><![CDATA[For whatever reason, OneDrive did not update in one of my machines after I upgraded to the new Windows 10, 1709.

I was able to bump it up by downloading the setup file from here:
<a href="https://oneclient.sfx.ms/Win/Prod/17.3.7064.1005/OneDriveSetup.exe">https://oneclient.sfx.ms/Win/Prod/17.3.7064.1005/OneDriveSetup.exe</a>

&nbsp;

I found the address in the AppData\Local\Microsoft\OneDrive\StandaloneUpdater\Update.xml file.
It was pointing to the old version, so I've got the new version number from another machine and downloaded the installer directly.

I suppose <a href="https://onedrive.live.com/about/en-us/download/">https://onedrive.live.com/about/en-us/download/</a> will eventually point to that as well (or a similar link).]]></content:encoded>
    </item>
    <item>
      <title>CompatTelRunner.exe running disk hot and consuming too many resources in Windows 10</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/compattelrunner-exe-running-disk-hot-and-consuming-too-many-resources-in-windows-10</link>
      <pubDate>Thu, 24 Nov 2016 01:29:04 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/?p=95</guid>
      <description><![CDATA[Lots of people have reported having disk usage at 100% after booting Windows 10, and seeing...]]></description>
      <content:encoded><![CDATA[<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">Lots of people have reported having disk usage at 100% after booting Windows 10, and seeing CompatTelRunner.exe scanning a lot of files.</p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">(See <a href="https://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/anyone-know-what-compattelrunnerexe-isdoes/768b3521-4c85-482f-bb41-5de611cda7f0">Anyone know what CompatTelRunner.exe is/does</a>?)</p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff"></p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">Using procexp.exe, I found that the offending process was started from a scheduled task, namely, Microsoft Compatibility Appraiser, which is found in <strong>Computer Manager</strong> under <strong>Task Scheduler\Microsoft\Windows\Application Experience\ProgramDataUpdater</strong>. There are three tasks in that folder.</p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff"></p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">The description of the task says "<em>Collects program telemetry information if opted-in to the Microsoft Customer Experience Improvement Program</em>.", so I suppose we can simply opt-out from the telemetry program and this should not run anymore. I believe that is in Settings-&gt;Privacy-&gt;Feedback.</p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff"></p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">However, Windows Insider machines probably require this to be on, in which case we can go about disabling the tasks in Task Scheduler.</p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff"></p>
<p style="margin: 0px;padding: 0px;font-family: 'Segoe UI', Arial, sans-serif;font-size: 15px;font-style: normal;font-weight: normal;letter-spacing: normal;text-align: start;text-indent: 0px;border: 0px;vertical-align: top;min-height: 19px;color: #333333;background-color: #ffffff">While I do not consider this an 'official'  solution, it alleviated the problem in my machines as far as I can tell.</p>]]></content:encoded>
    </item>
    <item>
      <title>Is it just me or Windows 10 is looking like Windows 1.0?</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/is-it-just-me-or-windows-10-is-looking-like-windows-1-0</link>
      <pubDate>Wed, 15 Apr 2015 00:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/2015/04/15/is-it-just-me-or-windows-10-is-looking-like-windows-1-0/</guid>
      <description><![CDATA[The Windows 10 UI is still being polished and worked on, but between the "hamburger" icon,...]]></description>
      <content:encoded><![CDATA[<p>The Windows 10 UI is still being polished and worked on, but between the "hamburger" icon, border-less windows, auto-tiling, flat icons and a flat taskbar, Windows 10 is finally bringing back the glory days of Windows 1.0!</p>
<p><br />In honor of the good-old-days, I have recreated the Windows 1.0 screenshot from the <a title="Windows History" href="https://windows.microsoft.com/en-US/windows/history?woldogcb=0#T1=era1" target="_blank">Windows History</a>, using Windows 10 programs and Outlook:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/24/90/2664.Windows1.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-24-90/2664.Windows1.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/24/90/2664.Windows1.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-24-90/2664.Windows1.jpg" alt="" border="0" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/24/90/4743.Windows10.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-24-90/4743.Windows10.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/24/90/4743.Windows10.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-24-90/4743.Windows10.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>What other features of Windows 1.0 should we expect from Windows 10?</p>
<p>But more importantly...if the trend continues, will Windows 13 look like Windows 3.1?</p>
<p>Only time will tell...</p>
<p>&nbsp;</p>
<p>PS: while you are here, don't forget to <a title="run MSDOS in your Windows Phone" href="https://www.windowsphone.com/en-us/store/app/ms-dos-mobile/8573c4a8-b9df-4409-90a6-dad2dc0b6b26" target="_blank">run MSDOS in your Windows Phone</a>&nbsp;- they are already bringing back Win 3.1, so you can start getting used to it again.</p>
<p>&nbsp;</p>
<p>:-)</p>]]></content:encoded>
    </item>
    <item>
      <title>How to get game "coins" without paying for it (or Why you should encrypt settings related to in-app purchases).</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/how-to-get-game-coins-without-paying-for-it-or-why-you-should-encrypt-settings-related-to-in-app-purchases</link>
      <pubDate>Tue, 04 Mar 2014 02:07:08 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/2014/03/04/how-to-get-game-coins-without-paying-for-it-or-why-you-should-encrypt-settings-related-to-in-app-purchases/</guid>
      <description><![CDATA[My son and I were playing a Windows 8 game where we would get coins for completing each level and...]]></description>
      <content:encoded><![CDATA[<p>My son and I were playing a Windows 8 game where we would get coins for completing each level and then we had to spend coins to be able to beat the next level.</p>
<p>Obviously, it was taking forever to get any meaningful amount of coins - which is by design, I get it. The game allows you to pay real cash for these virtual coins, in the hopes that the emotional connection you have with the game will make you think it is worth paying for.</p>
<p>Unlike my kid, I have lost the energy to spend on such endeavors so I began wondering how the game implemented their 'coin storage'.</p>
<p>In this particular game, which I'll leave unnamed for the sake of the developers, you can buy coins over and over, so my instinct was to assume they were simply storing the amount of coins a gamer has in the <strong>LocalSettings</strong> of the <strong>ApplicationData</strong> class, which are implemented in Win8 using Registry hives. That being the case, we can load and inspect hives manually in the registry, so I decided to give it a try.</p>
<p>I loaded the <strong>Registry Editor</strong>, selected the <strong>HKEY_LOCAL_MACHINE</strong> root and chose <strong>File-&gt;Load Hive</strong>. The <strong>%USERPROFILE%\AppData\Local\Packages</strong> folder contains user settings for the modern Win8 applications. Each app has its own folder and under that there is the <strong>Settings\settings.dat</strong> file, which happens to be a registry hive. We loaded that and explored the keys and values. As luck would have it, this particular game happens to store the number of coins the games has with a setting named, guess what, "coins".</p>
<p>Oh, that's too easy...</p>
<p>WinRT settings uses binary blobs to store the values in the registry, but I noticed a pattern among them, so it was a safe bet that part of the blob was encoding the type of the data ("integer" in this case) while the first 4 bytes of the "coins" value&nbsp;were the raw hex value of the number of coins we had accumulated so far in the game.</p>
<p>I just bumped that value up to FFFFFFFF and unloaded the hive. To be honest, I expected the app to crash, but after restarting the game I found that I was the (not so proud) owner of a lot of coins and that we could use them at will. There were other settings as well in the game that you could buy with the coins, and I suppose I could have tweaked them as well.</p>
<p>The whole process took a couple of minutes, if that much. Again, way to easy....</p>
<p>&nbsp;</p>
<p>Out of that little exercise in cheating I came up with three lessons:</p>
<ol>
<li><strong>For the kids who love playing the game:</strong><br /> The game lost its appeal. If you want to keep playing that funny addictive game you love so much, don't cheat!&nbsp;After all, if&nbsp;you cheat and 'beat' the game like this you lose the emotional connection you would otherwise have with the game and then it is just not that much fun anymore.<br />&nbsp;</li>
<li><strong>For the kids whose dads (like me) just won't let them pay for games on a daily-basis</strong>, or if you just want to see how the game works without having to play for endless hours:<br />Emotional-connection? Yeah, right. We can try to tweak the game settings and see what happens - with the usual disclaimer that doing so can render the game unplayable if you don't know what you are doing. There is also the option of running in the debugger - that's always fun... :-)<br />&nbsp;</li>
<li><strong>And the real objective of this post, is for developers out there:</strong><br />Do add a minimum of encryption on top of these things that people are supposed to pay for, otherwise it is a lost opportunity for profit. A little work with the DataProtectionProvider or some other API will protect these settings from quick tweaks like&nbsp;this and that translates to either an actual purchase or at least some more hours of game play and the ads that come along with them, and those are money in the pocket, so there's no reason to leave things in the open.</li>
</ol>
<p>&nbsp;</p>
<p>Obviously, not every game out there makes this mistake, so this only&nbsp;works on a case-by-case basis.</p>
<p>And it is likely that the popular games that you REALLY want to do something like this will be exactly the ones where they will protect themselves.</p>
<p>:-)</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Inside the Exchange 2010 Web Management Interface – Part I</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/inside-the-exchange-2010-web-management-interface-part-i</link>
      <pubDate>Wed, 29 Jul 2009 04:11:55 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/2009/07/29/inside-the-exchange-2010-web-management-interface-part-i/</guid>
      <description><![CDATA[It has been a while since my last post, as I was finishing up work on the upcoming Exchange 2010 Web...]]></description>
      <content:encoded><![CDATA[<p>It has been a while since my last post, as I was finishing up work on the upcoming Exchange 2010 Web Management Interface, internally known as the “Exchange Control Panel” or simply ECP, so it seems fit to give you a peak of what is inside the hood.</p>  <p>Exchange Control Panel is a web application designed to provide self-service management of Exchange features to end-users and administrators alike. </p>  <p>For the end-user, ECP appears as the OWA Options page, where one goes to customize a number of settings, like Inbox Rules, Out-of-Office and <a href="https://msexchangeteam.com/archive/2009/06/22/451667.aspx" target="_blank">Voice Mail</a> settings – you can see a complete list in this <a href="https://help.outlook.com/en-us/140/ms.exch.owap.optionspremium.aspx" target="_blank">online help topic</a>. ECP is also integrated with Outlook 2010 in the sense that the UI for certain options in Outlook are in fact implemented by the ECP application.</p>  <p>ECP lights up additional options when a user with administrative permissions logs in and presents options such as management of mailboxes, groups and external contacts as well as other scenarios like <a href="https://help.outlook.com/en-us/140/ms.exch.ecp.resetpassword_password.aspx" target="_blank">Reset Passwords</a>, <a href="https://msexchangeteam.com/archive/2009/06/26/451680.aspx" target="_blank">Delivery Reports</a>, configuration of mailbox service plans and user roles, all according to the user’s rights specified by Exchange’s Role Based Access Control (RBAC).</p>  <p><strong></strong></p>  <p><strong>ECP Architecture</strong></p>  <p>ECP is designed as an ASP.net AJAX application, built on top of business logic provided by the Exchange <a href="https://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">PowerShell</a> cmdlets and using WCF web services and JSON to communicate between the client application and the server application.</p>  <p>The client side of ECP runs in <a href="https://help.outlook.com/en-us/140/bb899685.aspx" target="_blank">multiple browsers</a> while the server side runs in Windows 2008+IIS7, in an Exchange server setup as a Client Access Server.</p>  <p>ECP uses the same <a href="https://help.outlook.com/en-us/140/cc546278.aspx" target="_blank">PowerShell cmdlets</a> available in the command line interface, keeping our motto that <em>‘anything you can do in the UI, you can do in the command line’</em>. The same set of RBAC permissions controls what a user can do in PowerShell and in the ECP UI.</p>  <p>From a logical point of view, ECP is divided in three parts:</p>  <ul>   <li><strong>Common Infrastructure        <br /></strong>Several pieces that make ECP work are part of a common infrastructure shared with other Exchange applications, like Outlook Web Access (OWA) and Exchange Management Web Service (EMWS). These include things like Live ID authentication, RBAC, PowerShell and more mundane things like tracing, performance counters, event log, etc. Several teams work with this code one way or another.       <br />      <br /></li>    <li><strong>ECP Application Infrastructure        <br /></strong>ECP itself provides an infrastructure of common controls, scripts, services and resources necessary to build Exchange features. There's usually nothing too particular to Exchange itself in this code as one could use it to build other types of applications with it. Infrastructure code can be simple or complex depending on the needs of all features that use it. It eventually stops growing as it meets the requirements of all features. The idea is that only the ECP team deals with this code. <strong>       <br />        <br /></strong></li>    <li><strong>Feature Code        <br /></strong>Finally, in ECP there are pages and controls that implement one particular feature of Exchange. This is the part of ECP that grows over time, as more and more features are added to it. The idea is to make writing feature code so easy that we can let component teams write their own feature UI, just like they build their own cmdlets. In most cases, feature UI in ECP boils down to a list view or a form, with web services used as data source. </li> </ul>  <p>Physically, ECP code can be divided in four main groups:</p>  <ul>   <li><strong>Server Controls        <br /></strong>Server-side controls written in C# gives us the necessary functionality and abstractions that simplify the creation of markup files. They are part of ECP's Infrastructure.       <br />      <br /></li>    <li><strong>ECP Client Library        <br /></strong>The ECP client-side application is written in Script#, compiled into JavaScript and executed on the browser. For the most part it is all Infrastructure code although complex features have scripts of their own.       <br />      <br /></li>    <li><strong>ECP Web Services        <br /></strong>A set of C# WCF web services with JSON behavior provide the client library with the necessary entry points to invoke cmdlets in the server. Each feature provides its own data contracts and the final web service code, which is implemented with the help of base classes provided by the Infrastructure.       <br />      <br /><em>NOTE: the web services endpoints exposed by ECP are not regarded as public API and serve only the needs of the ECP application – they are not to be used as a general programming endpoint as their requirements can change from version to version. Applications that wish to call Exchange management functions remotely must use Remote PowerShell.</em>       <br />      <br /></li>    <li><strong>UI Markup</strong>       <br />ECP UI is built with ASPX and ASCX markup files, where we define the controls to show, the web service that provides data for the page, client side data-bindings and the RBAC permissions required by each control.       <br />      <br />The markup pages are divided in the following groups:       <ul>       <li>Infrastructure pages provide the main frame and a set of error pages for the application. </li>        <li>Feature List View pages, shows a list of objects and their associated commands. </li>        <li>Feature Form Pages, shows a form where users can edit the properties of an object. </li>     </ul>   </li> </ul>  <blockquote>   <p>In most cases feature-specific pages do not require any additional code-behind, since all the heavy lifting is done by the infrastructure controls, either on server code or client code. </p> </blockquote>  <p>&#160;</p>  <p>The following diagram gives us a high level view of how the pieces come together to form ECP:<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/fpintos/WindowsLiveWriter/087e7dbac389_D481/ECP%20Architecture_2.png" original-url="https://blogs.msdn.com/blogfiles/fpintos/WindowsLiveWriter/087e7dbac389_D481/ECP%20Architecture_2.png"><img style="border-right-width: 0px; margin: 10px auto 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ECP Architecture" border="0" alt="ECP Architecture" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/fpintos/WindowsLiveWriter/087e7dbac389_D481/ECP%20Architecture_thumb.png" original-url="https://blogs.msdn.com/blogfiles/fpintos/WindowsLiveWriter/087e7dbac389_D481/ECP%20Architecture_thumb.png" width="560" height="500" /></a></p>  <p>The ECP client library and the <a href="https://www.asp.net/ajax/" target="_blank">Microsoft AJAX</a> framework run in the client browser.</p>  <p>Browser requests are handled by IIS and are authenticated with either Windows Live ID, Windows or OWA’s Form Based Authentication, depending if we are in a datacenter or in an enterprise deployment.</p>  <p>After the request is authenticated we build the user session, where we keep track of the user settings and in particular of the user’s permissions. At this point we can authorize the request.</p>  <p>Requests for UI components is handled by the ASPX handler of each page. Feature pages and application wide pages (such as default.aspx and error.aspx) rely on the server controls infrastructure to render the proper HTML and JavaScript to be executed by the browser. RBAC is involved to hide portions of the UI that the user does not have permissions to use, or to make them read-only.</p>  <p>Web service calls are handled by the respective WCF service, exposed by a JSON end-point. Each specific feature provides its own web service with a set of well-known contracts understood by the server controls and the client library. While the contracts are generic, allowing each feature to control exactly what comes in and what goes out in each web service call, all features look and behave the same, allowing a single set of controls to work seamlessly across all features.</p>  <p>The feature web services uses infrastructure code to translate data between WCF data contracts and PowerShell cmdlets, to invoke the respective cmdlets and to return data from PowerShell to the client application to consume. RBAC is involved to restrict access to just the cmdlets and parameters that the user has access.</p>  <p>Once the request reaches cmdlet code the operation is persisted in the system by the appropriate business logic.</p>  <p>&#160;</p>  <p><strong>Summary</strong></p>  <ul>   <li>Exchange 2010 Web Management Interface, aka, Exchange Control Panel is an ASP.Net application running in an Exchange Client Access server. </li>    <li>Uses ASP.net to render HTML UI. </li>    <li>Uses Script# to compile C# into JavaScript. </li>    <li>Client code runs in multiple browsers. </li>    <li>Uses WCF+JSON to respond to web service calls from the client application. </li>    <li>Uses RBAC to control what users can see or not in the application UI and what cmdlets and parameters can be used in web services. </li>    <li>Uses Exchange PowerShell Cmdlets to execute business logic. </li> </ul>  <p>In future articles we will look at those individual pieces in more details.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to properly convert SecureString to String</title>
      <link>https://docs.microsoft.com/archive/blogs/fpintos/how-to-properly-convert-securestring-to-string</link>
      <pubDate>Fri, 12 Jun 2009 11:44:13 GMT</pubDate>
      <dc:creator><![CDATA[Fabio Pintos - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/fpintos/2009/06/12/how-to-properly-convert-securestring-to-string/</guid>
      <description><![CDATA[It feels like forever since SecureString has been introduced in the .Net Framework and yet I keep...]]></description>
      <content:encoded><![CDATA[<p>It feels like forever since SecureString has been introduced in the .Net Framework and yet I keep seeing it being mishandled, in particular by code that returns or receives passwords in clear text, so in this post I’ll show what you should be looking for when doing code reviews and finding conversions from SecureString to string.</p> <p>The main idea with SecureString is that you would never store a password or other textual secret in plain text, unencrypted memory – at least not in a System.String instance. Unfortunately, SecureString was introduced in the framework only after plenty of APIs were built and shipped using passwords stored in String, such as System.Net.NetworkCredential, so an application that must use these APIs has no option but to convert SecureStrings to strings.</p> <p>However, the SecureString class itself doesn’t provide any methods to get back a plain string with its content, exactly to discourage this type of usage. What a developer has to do is use functions from System.Runtime.InteropServices.Marshal to get a native buffer with the plain string, marshal the value into a managed string then – very importantly – free the native buffer. </p> <p>And this is where I’ve seen people people making mistakes. You can certainly spot the problems in the following functions:</p> <blockquote><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> BAD_ConvertToUnsecureString(<span class="kwrd">this</span> SecureString securePassword)
{
    IntPtr unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(securePassword);
    var s = Marshal.PtrToStringUni(unmanagedString);
    Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
    <span class="kwrd">return</span> s;
}

<span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> REALLY_BAD_ConvertToUnsecureString(<span class="kwrd">this</span> SecureString securePassword)
{
    IntPtr unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(securePassword);
    <span class="kwrd">return</span> Marshal.PtrToStringUni(unmanagedString);
}
</pre></blockquote>
<p>The first one is almost ok, but if an exception happens after the native buffer is allocated then we leak that password. The second one is just plain wrong; the developer completely forgot to free the native buffer, introducing an unconditional leak of that password. </p>
<p>I’ve seen both mistakes being freely cut-and-paste because the original code was embedded in a larger function that was doing multiple things, so the details of the conversion were easy to overlook. Lacking a simple, reusable function leads to that, so don’t let these bugs creep into your project.</p>
<p>The correct implementation is to use a try/finally block to free the native buffer. Here’s an example, using SecureStringToGlobalAllocUnicode and ZeroFreeGlobalAllocUnicode:</p>
<blockquote><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> ConvertToUnsecureString(<span class="kwrd">this</span> SecureString securePassword)
{
    <span class="kwrd">if</span> (securePassword == <span class="kwrd">null</span>)
        <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentNullException(<span class="str">"securePassword"</span>);

    IntPtr unmanagedString = IntPtr.Zero;
    <span class="kwrd">try</span>
    {
        unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(securePassword);
        <span class="kwrd">return</span> Marshal.PtrToStringUni(unmanagedString);
    }
    <span class="kwrd">finally</span>
    {
        Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
    }
}
</pre></blockquote>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>

<p>Please understand that a little village bursts on fire every time you call such a function, but if you do need it, write it like this, so there’s no excuse for anyone to write that code again.</p>
<p>The extension method syntax makes it easy to call the conversion as if it was part of SecureString itself:</p>
<blockquote><pre class="csharpcode">SecureString password = someCodeToGetSecureString();
var credentials = <span class="kwrd">new</span> NetworkCredential(userName, password.ConvertToUnsecureString())</pre></blockquote>
<p>While at it you may want to provide the counterpart that converts a plain String to a SecureString. Following the same pattern as above we’ll have:</p>
<blockquote><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> SecureString ConvertToSecureString(<span class="kwrd">this</span> <span class="kwrd">string</span> password)
{
    <span class="kwrd">if</span> (password == <span class="kwrd">null</span>)
        <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentNullException(<span class="str">"password"</span>);

    <span class="kwrd">unsafe</span>
    {
        <span class="kwrd">fixed</span> (<span class="kwrd">char</span>* passwordChars = password)
        {
            var securePassword = <span class="kwrd">new</span> SecureString(passwordChars, password.Length);
            securePassword.MakeReadOnly();
            <span class="kwrd">return</span> securePassword;
        }
    }
}
</pre></blockquote>
<p>The important point here is to mark the secure string as read-only before returning it – it is very unlikely that you’ll need to edit a secure string that was created from an existing string. You’ll also note that in the above example I used unsafe code to initialize the SecureString from its fixed/char* representation, which is about 10x faster than using AppendChar. If you are not allowed to use unsafe code, don’t worry, just write it using AppendChar and it works fine.</p>
<p>I’m not proud to have clear text passwords in my process memory, but we’ll have to live with it until the day somebody updates the framework to use SecureString everywhere, particularly in System.Net. </p>
<p><em>If you need to learn more about SecureString this post is a great start: </em><a title="https://blogs.msdn.com/shawnfa/archive/2004/05/27/143254.aspx" href="https://blogs.msdn.com/shawnfa/archive/2004/05/27/143254.aspx"><em>https://blogs.msdn.com/shawnfa/archive/2004/05/27/143254.aspx</em></a><em>. </em></p>]]></content:encoded>
    </item>
  </channel>
</rss>