Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

58

Transcript of Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Page 1: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.
Page 2: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Are You Breaking My Stuff Again? The Windows 7 App Compat Story

Chris JacksonThe App Compat GuyMicrosoft CorporationWCL302

Page 3: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Microsoft Confidential

Mr. Jackson

Page 4: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Microsoft Confidential

I will fix app compat

for my apps for

Windows 7.

Page 5: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.
Page 6: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Microsoft Confidential

Page 7: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Don’t make me chant

“App compat…

App compat…”

Page 8: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Microsoft Confidential

Page 9: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 10: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 11: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 12: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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…

Page 13: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Application Compatibility IssuesNew Issues Since Windows Vista

Page 14: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Operating System Version

Windows 7 is … Windows 6.1?dwMajorVersion stays the samedwMinorVersion changes

RemediationCheck for features, not versionsUse the > keyVersion lies

Page 15: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 16: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

xxxVersionLie

Symptoms“Unsupported operating system”

Fix descriptionLies

Page 17: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Version Lie ShimsWin95VersionLieWinNT4SP5VersionLieWin98VersionLieWin2000VersionLieWin2000SP1VersionLieWin2000SP2VersionLieWin2000SP3VersionLie

WinXPVersionLieWinXPSP1VersionLieWinXPSP2VersionLieWin2K3RTMVersionLieWin2K3SP1VersionLieVistaRTMVersionLieVistaSP1VersionLieVistaSP2VersionLie

Page 18: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Version Lie LayersWin95NT4SP5Win98Win2000Win2000SP2Win2000SP3WinXP

WinXPSP1WinXPSP2WinXPSP2VersionLieWinSrv03WinSrv03SP1VistaRTMVistaSP1VistaSP2

Page 19: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Compatibility Tab

Layers

Page 20: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Shims and Layers

Windows

Shim

Application Child Application

Layer

Page 21: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Layers: More Than Version Lies

VistaRTM Layer:DelayAppDllMainElevateCreateProcessFailObsoleteShellAPIsFaultTolerantHeapGlobalMemoryStatus2GBHandleBadPtr

NoGhostRedirectMP3CodecVirtualRegistryVistaRTMVersionLieWRPDllRegisterWRPMitigation

Page 22: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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)

Page 23: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Detecting IE More Effectively

http://msdn.microsoft.com/en-us/ library/ms537509.aspxDetect FeaturesDefine compatibility modes

Page 24: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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>

Page 25: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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>

Page 26: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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.}

Page 27: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 28: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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]

Page 29: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 30: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 31: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 32: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 33: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 34: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 35: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Removal of Registry Reflection

KEY_WOW64_64KEY

KEY_WOW64_32KEY

Value ValueValue from

64Value from

32Value from

64Value from

32

Page 36: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 37: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 38: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 39: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 40: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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()

Page 41: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

How We Help You Express Your Intentions More Clearly

Talk to us.

Page 42: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 43: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 44: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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>

Page 45: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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)

Page 46: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

What We Made Looka Little NicerEnjoy.

Page 47: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

ChooseFont() Dialog

Page 48: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

User Account Control

Page 49: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Tools and TipsHelpful?

Page 50: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 51: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 52: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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/

Page 54: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 55: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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

Page 56: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

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.

Page 57: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

Complete an evaluation on CommNet and enter to win!

Page 58: Chris Jackson The App Compat Guy Microsoft Corporation WCL302.

© 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.