6
© 2002 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 1 Windows 7 Windows 7兼容性系列课程 兼容性系列课程(3) (3)有针对的兼容性开发 有针对的兼容性开发() 吴慧锋 MVP 测试与技术支持工程师 www.ssw.com.au E-mail / MSN: [email protected] 议程 议程 WRP WRP保护资源 保护资源 程序兼容性助手 程序兼容性助手 映射网络驱动器 映射网络驱动器 安装识别 安装识别 安装识别 安装识别 正确文件目录 正确文件目录 操作系统版本检测 操作系统版本检测 Session Session 0 议程 议程 WRP WRP保护资源 保护资源 程序兼容性助手 程序兼容性助手 映射网络驱动器 映射网络驱动器 安装识别 安装识别 安装识别 安装识别 正确文件目录 正确文件目录 操作系统版本检测 操作系统版本检测 Session Session 0 Windows Windows资源保护 资源保护 何为 何为TrustedInstaller TrustedInstaller c: c:\Windows> Windows>icacls icacls explorer.exe explorer.exe explorer.exe NT SERVICE explorer.exe NT SERVICE\TrustedInstaller TrustedInstaller:(F) :(F) BUILTIN BUILTIN\Administrators:(RX) Administrators:(RX) NT AUTHORITY NT AUTHORITY\SYSTEM:(RX) SYSTEM:(RX) BUILTIN BUILTIN\Users:(RX) Users:(RX) Successfully processed 1 files; Failed processing 0 files Successfully processed 1 files; Failed processing 0 files c: c:\Windows> Windows>psgetsid psgetsid "NT SERVICE "NT SERVICE\TrustedInstaller TrustedInstaller" PsGetSid PsGetSid v1.43 v1.43 - Translates SIDs to names and vice versa Translates SIDs to names and vice versa C i ht (C) 1999 C i ht (C) 1999 2006 M kR i ih 2006 M kR i ih Copyright (C) 1999 Copyright (C) 1999-2006 Mark Russinovich 2006 Mark Russinovich Sysinternals Sysinternals - www.sysinternals.com www.sysinternals.com SID for NT SERVICE SID for NT SERVICE\TrustedInstaller TrustedInstaller: S-1-5-80 80-956008885 956008885-3418522649 3418522649-1831038044 1831038044-1853292631 1853292631-2271478464 2271478464 c: c:\Windows>sc Windows>sc showsid showsid trustedinstaller trustedinstaller NAME: NAME: trustedinstaller trustedinstaller SERVICE SID: SERVICE SID: S-1-5-80 80-956008885 956008885-3418522649 3418522649-1831038044 1831038044-1853292631 1853292631-2271478464 2271478464 c: c:\Windows>sc Windows>sc getdisplayname getdisplayname trustedinstaller trustedinstaller [SC] [SC] GetServiceDisplayName GetServiceDisplayName SUCCESS SUCCESS Name = Windows Modules Installer Name = Windows Modules Installer WRP WRP 的保护内容 的保护内容 大多核心操作系统文件 大多核心操作系统文件 大多核心操作系统的注册表项 大多核心操作系统的注册表项 操作系统进程级别的目录 操作系统进程级别的目录 对于安装程式将没有限制 对于安装程式将没有限制 对于安装程式将没有限制 对于安装程式将没有限制 取决于服务的 取决于服务的SID SID TrustedInstaller TrustedInstaller是服务而不是账户 是服务而不是账户!

Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

Embed Size (px)

Citation preview

Page 1: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 1

Windows 7Windows 7兼容性系列课程兼容性系列课程(3)(3)::有针对的兼容性开发有针对的兼容性开发((上上))

吴慧锋MVP 测试与技术支持工程师www.ssw.com.auE-mail / MSN: [email protected]

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

WindowsWindows资源保护资源保护

何为何为TrustedInstallerTrustedInstallerc:c:\\Windows>Windows>icaclsicacls explorer.exeexplorer.exeexplorer.exe NT SERVICEexplorer.exe NT SERVICE\\TrustedInstallerTrustedInstaller:(F):(F)

BUILTINBUILTIN\\Administrators:(RX)Administrators:(RX)NT AUTHORITYNT AUTHORITY\\SYSTEM:(RX)SYSTEM:(RX)BUILTINBUILTIN\\Users:(RX)Users:(RX)

Successfully processed 1 files; Failed processing 0 filesSuccessfully processed 1 files; Failed processing 0 files

c:c:\\Windows>Windows>psgetsidpsgetsid "NT SERVICE"NT SERVICE\\TrustedInstallerTrustedInstaller""PsGetSidPsGetSid v1.43 v1.43 -- Translates SIDs to names and vice versaTranslates SIDs to names and vice versaC i ht (C) 1999C i ht (C) 1999 2006 M k R i i h2006 M k R i i hCopyright (C) 1999Copyright (C) 1999--2006 Mark Russinovich2006 Mark RussinovichSysinternalsSysinternals -- www.sysinternals.comwww.sysinternals.comSID for NT SERVICESID for NT SERVICE\\TrustedInstallerTrustedInstaller::SS--11--55--8080--956008885956008885--34185226493418522649--18310380441831038044--18532926311853292631--22714784642271478464

c:c:\\Windows>sc Windows>sc showsidshowsid trustedinstallertrustedinstallerNAME: NAME: trustedinstallertrustedinstallerSERVICE SID: SERVICE SID: SS--11--55--8080--956008885956008885--34185226493418522649--18310380441831038044--18532926311853292631--22714784642271478464c:c:\\Windows>sc Windows>sc getdisplaynamegetdisplayname trustedinstallertrustedinstaller[SC] [SC] GetServiceDisplayNameGetServiceDisplayName SUCCESSSUCCESSName = Windows Modules InstallerName = Windows Modules Installer

WRP WRP 的保护内容的保护内容

大多核心操作系统文件大多核心操作系统文件

大多核心操作系统的注册表项大多核心操作系统的注册表项

操作系统进程级别的目录操作系统进程级别的目录

对于安装程式将没有限制对于安装程式将没有限制对于安装程式将没有限制对于安装程式将没有限制

取决于服务的取决于服务的SIDSIDTrustedInstallerTrustedInstaller是服务而不是账户是服务而不是账户!!

Page 2: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 2

WindowsWindows资源保护资源保护

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

程序兼容性助程序兼容性助手手

只适用于客户端应用程序只适用于客户端应用程序

仅当运行失败时触发仅当运行失败时触发

PCAPCA在如下情况被触发:在如下情况被触发:在在“Program Files”“Program Files”目录下创建一个子目录目录下创建一个子目录在在 Program FilesProgram Files 目录下创建 个子目录目录下创建 个子目录

将文件复制到新目录中将文件复制到新目录中

利用虚拟化事件利用虚拟化事件

PCAPCA安装失败安装失败

程序兼容性助手程序兼容性助手

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

正确文件目录正确文件目录正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

Page 3: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 3

映映射网射网络驱动器络驱动器

在每个用户登录会话中单独存放在每个用户登录会话中单独存放

管理员权限用户登录具有两个会话管理员权限用户登录具有两个会话未提升权限的会话未提升权限的会话

提升权限的会话提升权限的会话

管理员权限用户具有两个驱动器映射集管理员权限用户具有两个驱动器映射集

HKLMHKLM\\SOFTWARESOFTWARE\\MicrosoftMicrosoft\\WindowsWindows\\CurrentVersionCurrentVersion\\PoliciesPolicies\\SystemSystem\\EnableLinkedConnectionsEnableLinkedConnections = (= (dworddword)1)1http://support.microsoft.com/kb/937624http://support.microsoft.com/kb/937624

驱动器映射与驱动器映射与UACUAC

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

安装识别安装识别

为什么我的程序会以提升权限被运行为什么我的程序会以提升权限被运行因为因为WindowsWindows 77认为它是一个安装包认为它是一个安装包

具体的安装包具体的安装包

通用的安装包通用的安装包通用的安装包通用的安装包

具体的非安装包具体的非安装包

安装识别安装识别

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

Page 4: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 4

正确文件目正确文件目录录 (1/2)(1/2)以前的路径以前的路径 新路径新路径

c:windowsc:windows %%windirwindir%%

%%windirwindir%%\\rundll32.exerundll32.exe %%systemdirsystemdir%%\\rundll32.exerundll32.exe

%%windirwindir%%\\rundll.exerundll.exe %%systemdirsystemdir%%\\rundll32.exerundll32.exe

%%windirwindir%%\\write.exewrite.exe %%systemdirsystemdir%%\\write.exewrite.exe

%%windirwindir%%\\wordpad.exewordpad.exe %%programfilesprogramfiles%%\\windows windows ntnt\\accessoriesaccessories\\wordpad.exewordpad.exe

%%programfilesprogramfiles%%\\accessoriesaccessories\\wordpad.exewordpad.exe %%programfilesprogramfiles%%\\windows windows ntnt\\accessoriesaccessories\\wordpad.exewordpad.exe

%%windirwindir%%\\dxdiag.exedxdiag.exe %%systemdirsystemdir%%\\dxdiag.exedxdiag.exe

%%windirwindir%%\\start menustart menu %%userstartmenuuserstartmenu%%

%%windirwindir%%\\desktopdesktop %%userdesktopuserdesktop%%

%windir%%windir%\\favoritesfavorites %%userfavoritesuserfavorites%%

正确文件目正确文件目录录 (2/2)(2/2)以前的路径以前的路径 新路径新路径

%%windirwindir%%\\profilesprofiles\\%username%%username%\\startstart menumenu %%userstartmenuuserstartmenu%%

%%windirwindir%%\\profilesprofiles\\%username%%username%\\desktopdesktop %%userdesktopuserdesktop%%

%%windirwindir%%\\profilesprofiles\\%username%%username%\\favoritesfavorites %%userfavoritesuserfavorites%%

%%windirwindir%%\\profilesprofiles\\all usersall users\\start menustart menu %%allstartmenuallstartmenu%%pp

%%windirwindir%%\\profilesprofiles\\all usersall users\\desktopdesktop %%alldesktopalldesktop

%%windirwindir%%\\profilesprofiles\\all usersall users\\favoritesfavorites %%userfavoritesuserfavorites%%

ddhelp.exeddhelp.exe ddraw.dllddraw.dll

ddraw16.dllddraw16.dll ddraw.dllddraw.dll

dsound.vxddsound.vxd Ddraw.dllDdraw.dll

%%userstartmenuuserstartmenu%% %%allstartmenuallstartmenu%%

正确文件目录正确文件目录

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

WindowsWindows版本纵览版本纵览

操作系统操作系统 版本版本 发布时间发布时间

Windows 1.0Windows 1.0 1.041.04 19851985

WindowsWindows 2.02.0 2.112.11 19871987

Windows 3.0Windows 3.0 3.003.00 19901990

Windows NT 3.1Windows NT 3.1 3.10.5283.10.528 19931993

Windows for Workgroups 3.11Windows for Workgroups 3.11 3.113.11 19931993

Windows NT Workstation 3.5Windows NT Workstation 3.5 3.5.8073.5.807 19941994

Windows NT Workstation 3.51Windows NT Workstation 3.51 3.51.10573.51.1057 19951995

Windows 95Windows 95 4.0.9504.0.950 19951995

Windows NT Workstation 4.0Windows NT Workstation 4.0 4.0.13814.0.1381 19961996

Windows 98Windows 98 4.1.19984.1.1998 19981998

Windows 98 Second EditionWindows 98 Second Edition 4.1.22224.1.2222 19991999

Windows MeWindows Me 4.90.30004.90.3000 20002000

Windows 2000 ProfessionalWindows 2000 Professional 5.0.21955.0.2195 20002000

Windows XPWindows XP 5.1.26005.1.2600 20012001

Windows VistaWindows Vista 6.0.60006.0.6000 20062006

Windows 7Windows 7 6.1.????6.1.???? ????????

版本检测的最佳实践版本检测的最佳实践

不要使用横等方式检测版本不要使用横等方式检测版本如果你的程序需要某项新功能则请直接价差该功能是如果你的程序需要某项新功能则请直接价差该功能是否存在否存在

使用大于好来检测系统版本使用大于好来检测系统版本检查检查WindowsWindows XPXP或后续系统或后续系统 (>= 5.1)(>= 5.1)检查检查 或后续系统或后续系统 ( )( )

特殊的情况是一些商业或法律原因需要做一个版本检特殊的情况是一些商业或法律原因需要做一个版本检查,比如一个管理机构,您需要证明您的应用程序的查,比如一个管理机构,您需要证明您的应用程序的每个操作系统和版本每个操作系统和版本

Page 5: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 5

操作系统版本检测操作系统版本检测

议程议程

WRPWRP保护资源保护资源

程序兼容性助手程序兼容性助手

映射网络驱动器映射网络驱动器

安装识别安装识别安装识别安装识别

正确文件目录正确文件目录

操作系统版本检测操作系统版本检测

SessionSession 00

Session 0Session 0分离原理分离原理

Session 0Session 0

WinSta0WinSta0

D f lt D ktD f lt D ktDefault DesktopDefault Desktop

ServiceService

User ApplicationUser Application

Session 0Session 0分离原理分离原理

Session 1Session 1

WinSta0WinSta0

D f lt D ktD f lt D kt

Session 0Session 0

WinSta0WinSta0

D f lt D ktD f lt D kt Default DesktopDefault Desktop

User ApplicationUser Application

Default DesktopDefault Desktop

ServiceService

Session 0Session 0兼容问题兼容问题

支持远程桌面和快速切换用户的程序都没支持远程桌面和快速切换用户的程序都没有问题有问题

通过通过WindowsWindows MessagesMessages进行交互进行交互

本地命名空间实体本地命名空间实体本地命名空间实体本地命名空间实体

UIUI界面和服务界面和服务

与与SessionSession 00桌面进行交互桌面进行交互UXUX变化巨大变化巨大

ServiceService设计的最佳实践设计的最佳实践

使用第二个程序来显示使用第二个程序来显示UIUI使用使用C/SC/S结构进行交互结构进行交互

RPCRPC命名管道命名管道

尽可能使用尽可能使用ServiceService HardeningHardening删除不必要的权限删除不必要的权限

使用服务的使用服务的SIDSID来安全访问资源来安全访问资源

快速解决方案:快速解决方案:WTSSendMessageWTSSendMessage

Page 6: Windows 7兼容性系列课程(3):有针对的兼容性开发(上)

© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 6

Question & AnswerQuestion & Answer

如需提出问题,请在此区域输入文字,并单击如需提出问题,请在此区域输入文字,并单击““问题和解答问题和解答””右上方的右上方的““提问提问””按钮即可。按钮即可。

您您也可以选择在微软中文技术论坛上寻求帮助,也可以选择在微软中文技术论坛上寻求帮助,MSDNMSDN中文网络中文网络广播的讲师们会定期在论坛上为大家解答与课程相关的技术问题。广播的讲师们会定期在论坛上为大家解答与课程相关的技术问题。http://http://forums.microsoft.com/chinaforums.microsoft.com/china

吴慧锋吴慧锋

WilsonWilson WuWuEmail:Email: [email protected]@gmail.comMSNMSN il @il @

感谢感谢!!

MSN:MSN: [email protected]@ssw.com.auQQ:QQ: 5328646153286461Blog: Blog: http://WilsonWu.cnblogs.comhttp://WilsonWu.cnblogs.com