Post on 01-Jan-2016
Are You Breaking My Stuff Again? The Windows 7 App Compat Story
Chris JacksonThe App Compat GuyMicrosoft CorporationWCL302
Microsoft Confidential
Mr. Jackson
Microsoft Confidential
I will fix app compat
for my apps for
Windows 7.
Microsoft Confidential
Don’t make me chant
“App compat…
App compat…”
Microsoft Confidential
Few Changes: Most software that runs on Windows Vista will run on Windows 7 - exceptions will be low level code (AV, Firewall, Imaging, etc).
Hardware that runs Windows Vista well will run Windows 7 well.
Few Changes: Focus on quality and reliability improvements
Windows 7 Builds on Windows Vista
Deep Changes: New models for security, drivers, deployment, and networking
Windows 7 Goals
Applications that worked on Windows Vista and Windows Server 2008 continue to work on Windows 7 / Windows Server 2008 R2Broad ISV outreach for critical applications
Strategies
Scale our compatibility effortsAutomation (AAF), Telemetry
Prevent using education, tools, engagementInternal resources for compatibility & impact
Detect compatibility issues upstreamQuality Gates for application / public API removal
Mitigate compatibility issuesShim infrastructure, switchback, telemetry
Partner and engage with ISVsTools, services and labs
The Net Result
There is no new “special sauce” that makes all software magically start working on Windows 7 if it didn’t work on Windows Vista
The security bets we made in Windows Vista were good ones, and we’re not taking them backThere are incremental targeted fixes – new shims have been created for some applications
If you work on Windows Vista, you probably work on Windows 7, unless…
Application Compatibility IssuesNew Issues Since Windows Vista
Operating System Version
Windows 7 is … Windows 6.1?dwMajorVersion stays the samedwMinorVersion changes
RemediationCheck for features, not versionsUse the > keyVersion lies
Why Version 6.1?
Some applications only check dwMajorVersionSome applications tried to do the right thing, but implemented it incorrectly
if (majorVersion > 5 && minorVersion > 1)
OS Version Major > 5 Minor > 1 Result Desired?
Windows 2000 5.0 T F F Yes
Windows XP 5.1 T T T YesWindows Vista 6.0 T F F NO
Windows 7 6.1 T T T Yes
xxxVersionLie
Symptoms“Unsupported operating system”
Fix descriptionLies
Version Lie ShimsWin95VersionLieWinNT4SP5VersionLieWin98VersionLieWin2000VersionLieWin2000SP1VersionLieWin2000SP2VersionLieWin2000SP3VersionLie
WinXPVersionLieWinXPSP1VersionLieWinXPSP2VersionLieWin2K3RTMVersionLieWin2K3SP1VersionLieVistaRTMVersionLieVistaSP1VersionLieVistaSP2VersionLie
Version Lie LayersWin95NT4SP5Win98Win2000Win2000SP2Win2000SP3WinXP
WinXPSP1WinXPSP2WinXPSP2VersionLieWinSrv03WinSrv03SP1VistaRTMVistaSP1VistaSP2
Compatibility Tab
Layers
Shims and Layers
Windows
Shim
Application Child Application
Layer
Layers: More Than Version Lies
VistaRTM Layer:DelayAppDllMainElevateCreateProcessFailObsoleteShellAPIsFaultTolerantHeapGlobalMemoryStatus2GBHandleBadPtr
NoGhostRedirectMP3CodecVirtualRegistryVistaRTMVersionLieWRPDllRegisterWRPMitigation
IE Version
Without compatibility mode:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
With compatibility mode:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Detecting IE More Effectively
http://msdn.microsoft.com/en-us/ library/ms537509.aspxDetect FeaturesDefine compatibility modes
Specifying Compatibility Mode
<html><head> <!-- Mimic Internet Explorer 7 --> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title>My Web Page</title></head><body> <p>Content goes here.</p></body></html>
IIS Compatibility Mode
<?xml version="1.0" encoding="utf-8"?><configuration> <system.webServer> <httpProtocol> <customHeaders> <clear /> <add name="X-UA-Compatible" value="IE=EmulateIE7" /> </customHeaders> </httpProtocol> </system.webServer></configuration>
Detecting Compat Mode
engine = null;if (window.navigator.appName == "Microsoft Internet Explorer"){ // This is an IE browser. What mode is the engine in? if (document.documentMode) // IE8 engine = document.documentMode; else // IE 5-7 { engine = 5; // Assume quirks mode unless proven otherwise if (document.compatMode) { if (document.compatMode == "CSS1Compat") engine = 7; // standards mode } } // the engine variable now contains the document compatibility mode.}
Windows Mail Deprecated
Replaced with Windows Live Mail – or the mail client of your choicewinmail.exe no longer on the systemPublicly documented APIs work
APIs that display UI break (silently fail)Protocol handlers and file extensions not registeredRemediation
Remove calls to deprecated APIsDetect if a mail handler is installedInstall a mail application
CoStartOutlookExpress
msoert2.dll Section .text (0x43D01000)CALL DWORD PTR [KERNEL32.DLL!GetModuleFileNameW]TEST EAX,EAXJZ 0x43D0A613LEA EAX,[EBP-0x20C]PUSH EAXCALL DWORD PTR [SHLWAPI.DLL!PathFindFileNameW]TEST EAX,EAXJZ 0x43D0A60CPUSH 'WinMail.exe'PUSH EAXCALL DWORD PTR [MSVCRT.DLL!_wcsicmp]
How to Write Apps that Break
Ignore published APIsReverse engineer WindowsWrite code depending on what you reversed, assuming that we’ll never change WindowsWait for us to change Windows
Windows Movie Maker Deprecated
MovieMaker binaries and shortcuts removedAttempts to launch the application failPlug-ins will remain installed, but will not be exposed to the user
NLS Sorting Changes
New versions of Windows almost invariably incorporate changes
Major version changes: re-indexing requiredMinor version changes: existing indexes OK, new strings can now be sorted
Operating System NLS Version
Windows XP (No GetNLSVersion API)
Windows Server 2003 0x00 0000 01
Windows Vista 0x00 0405 00
Windows Server 2008 0x00 0501 00
Windows 7 0x00 0600 00
NLS Sorting Changes
Our most common question from English-only audiences: “What are you talking about?”Examples:
The ligature æ typically equates to ae, but Icelandic sorts it after zThe A Ring Å typically sorts as diacritic difference from A, but Swedish sorts it after Z
CompareStringEx attempts to capture these locale-specific differencesCode points are added, and changes/fixes made
NLS Sorting Changes
If you do not check GetNLSVersion / GetNLSVersionEx (Vista+) and re-index on change:
May fail to sort correctlyMay fail to provide requested results
Sort Change Robustness Diagnostic Tool can help you diagnose
Removal of Registry Reflection
For x64 versions of Windows, we added Registry Reflection
HKLM\Software\ClassesHKLM\Software\Microsoft\COM3HKLM\Software\Microsoft\EventSystemHKLM\Software\Microsoft\OleHKLM\Software\Microsoft\RpcHKEY_USERS\*\Software\ClassesHKEY_USERS\*_Classes
Removal of Registry Reflection
KEY_WOW64_64KEY
KEY_WOW64_32KEY
Value ValueValue from
64Value from
32Value from
64Value from
32
Removal of Registry Reflection
Only known consumer: COMCOM was updated to not assume this
Motivation: feature caused inconsistencies in the state of the registryMitigations:
Use non-redirected registry keysExplicitly use KEY_WOW64_64KEYRead information from a known correct location
Windows Portable Devices
wpdusb.sys replaced by winusb.sysConsumers of WPD API are fineConsumers of (private) IOCTL codes will breakRemediation
Rewrite to leverage WPD APIs
New Low-Level Binaries
To improve the foundations of Windows, we have reorganizedExample: functionality from kernel32.dll and advapi32.dll moved to kernelbase.dllExported functions are forwardedApplications depending on offsets and undocumented APIs can breakRemediation:
Rewrite to use documented APIsSee Mark Russinovich’s Kernel Changes
IE DEP Enabled by Default
Data Execution Prevention (NX) now enabled by default
Vista – you had to elevate IE to enablePlug-ins that have an issue with DEP may cause the browser to crashRemediation:
Use DEP-compatible versions of frameworks (such as ATL)
http://support.microsoft.com/kb/948468 Use the /NXCOMPAT linker option
File Libraries
Default location of common file dialogs: Documents LibraryFile libraries are files (not folders)IFileDialog->GetFolder() + IFileDialog->GetFilename() breaks for library
GetFolder() returns a fileRemediation
Use IFileDialog->GetResult()
How We Help You Express Your Intentions More Clearly
Talk to us.
Switchback
Compatibility section in the manifest: communicate which OS you are designing for
We can make breaking changes to components as long as we keep the old one available for apps designed for a previous OS!
Windows Vista compatibility is the defaultOperating System Context is a property of a process
Switchback SwitchpointsComponent / API Windows Vista Windows 7
RPC Default Thread Pool Default thread pool Private thread pool
DirectDraw Lock Can acquire lock on primary video buffer
Unable to lock the primary video buffer (which disables DWM)
DirectDraw Bit Block Transfer Can blt to the primary video buffer without a clipping window
Must blt to a clipping window
GetOverlappedResult Provides behavior with a race condition
Resolves a race condition where the API can return without resetting the event in the overlapped structure
Program Compatibility Assistant
PCA is enabled – monitoring and mitigating failures
PCA is disabled
Switchback Manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows Vista supported --> <supportedOS id="{e2011457-1546-43c5-a5fe-008deee3d3f0}“/> <!-- Windows 7 supported --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility></assembly>
Switchback Supported OSs
Which operating systems do you choose?All supported operating systems
Nobody knows the Windows 8 GUID (yet)Not even Windows 7
To get Windows 7 switch points in a Windows 8 application, your manifest must include Windows 7 AND Windows 8Try not to rely on the Windows Vista default – if that’s the mode you want, ask for it explicitly (default may change in the future)
What We Made Looka Little NicerEnjoy.
ChooseFont() Dialog
User Account Control
Tools and TipsHelpful?
ACT 5.5
Full module on using the Application Compatibility ToolkitNew for 5.5:
DCP TaggingApplication Verifier 4.0 compatibilityAdditional compatibility fix documentationWindows 7 deprecation checksReport filtering
Problem Step Recorder
%windir%\system32\psr.exeAllows testers and users to track, step by step, exactly what an application is doing, creating an MHT file with screenshots illustrating the bug reproCreates a zip file containing an mhtIntegrated with Watson
Windows Troubleshooting
Built-in troubleshooting for common problems accessible from the Action CenterExtensible
%sdkdir%\bin\tspbuilder\builder.exeImplement using PowerShell scriptshttp://www.withinwindows.com/2009/01/12/crash-course-on-authoring-windows-7-troubleshooting-packs/
http://www.appcompatguy.comchris.jackson@microsoft.com
question & answer
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learningMicrosoft Certification and Training Resources
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
Related Content
Breakout Sessions (session codes and titles)WCL302 – Are You Breaking my Stuff Again? The Windows 7 App Compat StoryWCL304 – Fix Your Broken Applications: The Black Art of ShimsWCL401 – Not for the Faint of Heart: Hard Core App Compat Debugging
Track Resources→Want to find out which Windows Client sessions are best suited to help you in your deployment lifecycle? →Want to talk face-to-face with folks from the Windows Product Team?
Meet us today at the
Springboard Series Lounge, or visit us at www.microsoft.com/springboard
Springboard SeriesThe Springboard Series empowers you to select the right resources, at the right technical
level, at the right point in your Windows® Client adoption and management process. Come see why Springboard Series is your destination for Windows 7.
Complete an evaluation on CommNet and enter to win!
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.