套件支援架構Package Support Framework

套件支援架構是開放原始碼套件,可在您無法存取原始碼時,協助將修正程式套用到現有的 win32 應用程式,使其可以在 MSIX 容器中執行。The Package Support Framework is an open source kit that helps you apply fixes to your existing win32 application when you don't have access to the source code, so that it can run in an MSIX container. 套件支援架構有助於讓應用程式遵循最新執行階段環境的最佳做法。The Package Support Framework helps your application follow the best practices of the modern runtime environment.

以下是一些常見的範例,您可以在此找到實用的套件支援架構:Here are some common examples where you can find the Package Support Framework useful:

  • 您的應用程式在啟動時找不到某些 DLL。Your app can't find some DLLs when launched. 您可能需要設定目前工作目錄。You may need to set your current working directory. 轉換成 MSIX 之前,您可以在原始捷徑中了解所需的目前工作目錄。You can learn about the required current working directory in the original shortcut before you converted to MSIX.
  • 該應用程式會寫入安裝資料夾。The app writes into the install folder. 您通常會在處理程序監視器中看到「拒絕存取」錯誤。You will typically see it by "Access Denied" errors in Process Monitor.
  • 您的應用程式需要在啟動時將參數傳遞給可執行檔。Your app needs to pass parameters to the executable on launch. 您可以在此處深入了解如何識別此問題,也可以在此處深入了解可用的組態。You can learn more about how to identify this issue here and learn more about the available configurations here.

為了建立套件支援架構,我們運用了 Detours 技術,這是由 Microsoft Research (MSR) 開發的開放原始碼架構,可提供 API 重新導向及連結的協助。To create the Package Support Framework, we leveraged the Detours technology which is an open source framework developed by Microsoft Research (MSR) and helps with API redirection and hooking.

此架構是輕量級開放原始碼,可用來快速地解決應用程式問題。This framework is open source, lightweight, and you can use it to address application issues quickly. 這也提供您洽詢全球社群的機會,並以其他項目的投資作為建置基礎。It also gives you the opportunity to consult with the community around the globe, and to build on top of the investments of others.

如需逐步指南,請參閱使用套件支援架構將執行階段修正程式套用到 MSIX 套件For a step-by-step guide, see Apply runtime fixes to an MSIX package by using the Package Support Framework.

快速瀏覽套件支援架構的內部A quick look inside of the Package Support Framework

套件支援架構包含一個可執行檔、一個執行階段管理員 DLL,以及一組執行階段修正程式。The Package Support Framework contains an executable, a runtime manager DLL, and a set of runtime fixes.

套件支援架構

它的運作方式如下:Here's how it works. 您將建立組態檔來指定要套用至您應用程式的修正程式。You'll create a configuration file that specifies the fixes that you want to apply to your application. 然後,您將修改套件來指向套件支援架構 (PSF) 啟動器的可執行檔。Then, you'll modify your package to point to the Package Support Framework (PSF) launcher executable file.

當使用者啟動您的應用程式時,套件支援架構啟動器就會是其執行的第一個可執行檔。When users start your application, the Package Support Framework launcher is the first executable that runs. 該啓動器會讀取組態檔,並將執行階段修正程式和執行階段管理員 DLL 插入至應用程式處理程序。It reads your configuration file and injects the runtime fixes and the runtime manager DLL into the application process. 當應用程式有需要時,執行階段管理員就會套用修正程式,以在 MSIX 容器內執行應用程式。The runtime manager applies the fix when it's needed by the application to run inside of an MSIX container.

套件支援架構 DLL 插入

開始使用套件支援架構Get started using the Package Support Framework

為您的應用程式建立套件之後,請將其安裝並執行,然後觀察其行為。After you create a package for your application, install and run it, and observe its behavior. 您可能會收到可協助您找出相容性問題的錯誤訊息。You might receive error messages that can help you identify a compatibility issue. 您也可以使用處理程序監視器來找出問題。You can also use Process Monitor to identify issues.

發現問題之後,您可以查看我們的 GitHub 頁面,以取得修正程式。After you find an issue, you can check our GitHub page for a fix. 如果您找到修正程式,可以將其套用到您的套件。If you find one, you can apply it to your package. 我們的逐步指南會示範如何執行這項操作。Our step-by-step guide shows you how to do this. 其中也會逐步示範如何對應用程式使用 Visual Studio 偵錯工具,以及如何確認修程式正在運作,並且已解決相容性問題。It will also show you how to use the Visual Studio debugger to step through your application and verify that the fix is working and that it has resolved the compatibility issue.

如果您找不到解決問題所需的執行階段修正程式,您可以建立一個If you can't find a runtime fix that addresses your issue, you can create one. 若要執行此操作,您需找出應用程式在 MSIX 容器中執行時,發生失敗的函式呼叫。To do that, you'll identify which function calls fail when your application runs in an MSIX container. 然後,您可以建立替代函式,讓執行階段管理員改為呼叫該函式。Then, you can create replacement functions that you'd like the runtime manager to call instead. 這可讓您以符合最新執行階段環境規則的行為,取代函式實作。This gives you an opportunity to replace the implementation of a function with behavior that conforms to the rules of the modern runtime environment.

您也可以使用套件支援架構來執行指令碼,以動態方式自訂使用者環境的應用程式。You can also use the Package Support Framework to run scripts to customize an application for the user environment dynamically. 如需詳細資訊,請參閱這篇文章For more information, see this article.

限制Limitations

套件支援架構不支援登錄覆寫。The Package Support Framework does not support registry overrides. 其設計旨在解決執行時間問題。It is designed to resolve run time issues.

資料和遙測Data and telemetry

封裝支援架構包含收集使用資料的遙測,並將其傳送給 Microsoft 以協助改善我們的產品和服務。The Package Support Framework includes telemetry that collects usage data and sends it to Microsoft to help improve our products and services. 請參閱 Microsoft 隱私權聲明以深入了解Read Microsoft's privacy statement to learn more. 不過,只有在符合下列兩個條件時,才會收集資料:However, data will be collected only when both of the following conditions are met:

  • Windows 10 電腦上的 NuGet 套件使用了封裝支援架構二進位檔。The Package Support Framework binaries are used from the NuGet package on a Windows 10 computer.
  • 使用者已在電腦上啟用資料收集。The user has enabled collection of data on the computer.

NuGet 套件包含已簽署的二進位檔,並會從電腦收集使用量資料。The NuGet package contains signed binaries and will collect usage data from the computer. 透過複製存放庫或直接下載二進位檔,以在本機建立二進位檔時,不會收集遙測。Telemetry is not collected when the binaries are built locally by cloning the repo or downloading the binaries directly.