Chris Jackson The App Compat Guy Microsoft Corporation WCL302 Microsoft Confidential Microsoft Confidential.

Download Report

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

Chris Jackson The App Compat Guy Microsoft Corporation WCL302

Microsoft Confidential

Microsoft Confidential

Microsoft Confidential

Don’t make me chant “App compat … App compat …”

Microsoft Confidential

Windows 7 Builds on Windows Vista

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 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 R2 Broad ISV outreach for critical applications

Strategies

Scale our compatibility efforts Automation (AAF), Telemetry Prevent using education, tools, engagement Internal resources for compatibility & impact Detect compatibility issues upstream Quality Gates for application / public API removal Mitigate compatibility issues Shim infrastructure, switchback, telemetry Partner and engage with ISVs Tools, 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 back There 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 Issues

New Issues Since Windows Vista

Operating System Version

Windows 7 is … Windows 6.1?

dwMajorVersion stays the same dwMinorVersion changes Remediation Check for features, not versions Use the > key Version lies

Why Version 6.1?

Some applications only check dwMajorVersion Some applications tried to do the right thing, but implemented it incorrectly if (majorVersion > 5 && minorVersion > 1)

OS

Windows 2000 Windows XP Windows Vista Windows 7

Version

5.0

5.1

6.0

6.1

T T T

Major > 5

T T F T

Minor > 1

F T F T

Result

F

Desired?

Yes Yes NO Yes

xxxVersionLie

Symptoms

“Unsupported operating system”

Fix description

Lies

Version Lie Shims

Win95VersionLie WinNT4SP5VersionLie Win98VersionLie Win2000VersionLie Win2000SP1VersionLie Win2000SP2VersionLie Win2000SP3VersionLie WinXPVersionLie WinXPSP1VersionLie WinXPSP2VersionLie Win2K3RTMVersionLie Win2K3SP1VersionLie VistaRTMVersionLie VistaSP1VersionLie VistaSP2VersionLie

Version Lie Layers

Win95 NT4SP5 Win98 Win2000 Win2000SP2 Win2000SP3 WinXP WinXPSP1 WinXPSP2 WinXPSP2VersionLie WinSrv03 WinSrv03SP1 VistaRTM VistaSP1 VistaSP2

Compatibility Tab

Shims and Layers

Application Child Application Shim Layer Windows

Layers: More Than Version Lies

VistaRTM Layer: DelayAppDllMain ElevateCreateProcess FailObsoleteShellAPIs FaultTolerantHeap GlobalMemoryStatus2GB HandleBadPtr NoGhost RedirectMP3Codec VirtualRegistry VistaRTMVersionLie WRPDllRegister WRPMitigation

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

Detect Features Define compatibility modes

Specifying Compatibility Mode

My Web Page

Content goes here.

IIS Compatibility Mode

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 of your choice – or the mail client winmail.exe no longer on the system Publicly documented APIs work APIs that display UI break (silently fail) Protocol handlers and file extensions not registered Remediation Remove calls to deprecated APIs Detect if a mail handler is installed Install a mail application

CoStartOutlookExpress

msoert2.dll Section .text (0x43D01000) CALL DWORD PTR [KERNEL32.DLL!GetModuleFileNameW] TEST EAX,EAX JZ 0x43D0A613 LEA EAX,[EBP-0x20C] PUSH EAX CALL DWORD PTR [SHLWAPI.DLL!PathFindFileNameW] TEST EAX,EAX JZ 0x43D0A60C PUSH 'WinMail.exe' PUSH EAX CALL DWORD PTR [MSVCRT.DLL!_wcsicmp]

How to Write Apps that Break

Ignore published APIs Reverse engineer Windows Write code depending on what you reversed, assuming that we’ll never change Windows Wait for us to change Windows

Windows Movie Maker Deprecated

MovieMaker binaries and shortcuts removed Attempts to launch the application fail Plug-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 required Minor version changes: existing indexes OK, new strings can now be sorted

Operating System

Windows XP Windows Server 2003 Windows Vista Windows Server 2008 Windows 7

NLS Version

(No GetNLSVersion API) 0x00 0000 01 0x00 0405 00 0x00 0501 00 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 z The A Ring Å typically sorts as diacritic difference from A, but Swedish sorts it after Z CompareStringEx attempts to capture these locale-specific differences Code 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 correctly May 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\Classes HKLM\Software\Microsoft\COM3 HKLM\Software\Microsoft\EventSystem HKLM\Software\Microsoft\Ole HKLM\Software\Microsoft\Rpc HKEY_USERS\*\Software\Classes HKEY_USERS\*_Classes

Removal of Registry Reflection

KEY_WOW64_64KEY KEY_WOW64_32KEY

Removal of Registry Reflection

Only known consumer: COM COM was updated to not assume this Motivation: feature caused inconsistencies in the state of the registry Mitigations: Use non-redirected registry keys Explicitly use KEY_WOW64_64KEY Read information from a known correct location

Windows Portable Devices

wpdusb.sys replaced by winusb.sys

Consumers of WPD API are fine Consumers of (private) IOCTL codes will break Remediation Rewrite to leverage WPD APIs

New Low-Level Binaries

To improve the foundations of Windows, we have reorganized Example: functionality from kernel32.dll and advapi32.dll moved to kernelbase.dll

Exported functions are forwarded Applications depending on offsets and undocumented APIs can break Remediation: Rewrite to use documented APIs See 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 enable Plug-ins that have an issue with DEP may cause the browser to crash Remediation: 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 Library File libraries are files (not folders) IFileDialog->GetFolder() + IFileDialog->GetFilename() breaks for library GetFolder() returns a file Remediation 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 default Operating System Context is a property of a process

Switchback Switchpoints

Component / API

RPC Default Thread Pool DirectDraw Lock DirectDraw Bit Block Transfer GetOverlappedResult Program Compatibility Assistant

Windows Vista

Default thread pool Can acquire lock on primary video buffer

Windows 7

Private thread pool Unable to lock the primary video buffer (which disables DWM) Must blt to a clipping window Can blt to the primary video buffer without a clipping window Provides behavior with a race condition PCA is enabled – monitoring and mitigating failures Resolves a race condition where the API can return without resetting the event in the overlapped structure PCA is disabled

Switchback Manifest

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 8 Try 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 Look a Little Nicer

Enjoy.

ChooseFont() Dialog

User Account Control

Tools and Tips

Helpful?

ACT 5.5

Full module on using the Application Compatibility Toolkit New for 5.5: DCP Tagging Application Verifier 4.0 compatibility Additional compatibility fix documentation Windows 7 deprecation checks Report filtering

Problem Step Recorder

%windir%\system32\psr.exe

Allows testers and users to track, step by step, exactly what an application is doing, creating an MHT file with screenshots illustrating the bug repro Creates a zip file containing an mht Integrated with Watson

Windows Troubleshooting

Built-in troubleshooting for common problems accessible from the Action Center Extensible %sdkdir%\bin\tspbuilder\builder.exe

Implement using PowerShell scripts http://www.withinwindows.com/2009/01/12/crash -course-on-authoring-windows-7-troubleshooting packs/

http://www.appcompatguy.com

[email protected]

Resources

www.microsoft.com/teched Sessions On-Demand & Community www.microsoft.com/learning Microsoft Certification & Training Resources http://microsoft.com/technet Resources for IT Professionals http://microsoft.com/msdn Resources for Developers www.microsoft.com/learning Microsoft Certification and Training Resources

Related Content

Breakout Sessions (session codes and titles) WCL302 – Are You Breaking my Stuff Again? The Windows 7 App Compat Story WCL304 – Fix Your Broken Applications: The Black Art of Shims WCL401 – 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 Series

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