2009年5月15日星期五

嚴重警告!!
以下內容極度無趣、乏味可能令您感到不安、恐懼,閱讀前敬請注意,並請身體不適者、心臟病患者、高血壓或是孕婦,按上一頁離開,如果在閱讀後出現嘔吐、心悸或是陽萎者請立刻停止閱讀,謝謝合作。


==================== 不怕死分隔線 ====================

這一陣子工作有一個不同的經驗,就是要對我們目前開發的軟體作 Windows Vista 的 Logo 認證,剛好前兩天又看到微軟決定停產XP要推Vista的新聞,不過雖然停產但是還是會繼續維護到2014年,對於使用者而言差別就是要換一個作業系統不過對於軟體開發者而言可是要將程式重新調整來適用新的Vista系統。Vista推出其實有一段時間不過感覺上用的人沒有很多,大部分人的抱怨就是過去軟體相容性的問題,還有惱人的UAC(User Account Control)功能,其實這兩個問題可以當作同一個問題,因為關鍵都是 使用者存取權限 的問題,以前我們用XP或是2000的時候都會習慣將我們的使用者權限調整到管理者(Administrator),所以在使用上幾乎可以存取磁碟上所有的空間跟檔案,也就是這樣Windows才會容易淪為木馬程式或是病毒的殂上肉,因為這樣所以新一代的Vista作業系統對於軟體應用程式(Software Application)在執行上所給予的權限只有標準使用者的權限(Standard User),這個標準使用者可以把他當作用Guest帳號登入的權限,也就是因為這樣舊有可以在XP上默認Admin權限使用的程式在Vista上通通會吃鱉,這就是為何多數一般使用者甚至軟體開發者對Vista望之卻步的原因。

這裡我會"概略"提一些將軟體從XP移轉到Vista上的關鍵,還有一些取得Software Vista Logo 認證的一些流程跟須知,細部研究還是要靠自己...或是靠朋友。

=============== XP 跟 Vista 的主要差異分隔線================

關鍵一. Manifest XML File檔案:這是啥?Vista作業系統上對於每個"可"執行檔內都必須包含manifest file,他的內容類似如下




其中要注意的是requestedExecutionLevel的值,一般來說會用asInvoker或是requireAdministrator,普通的應用程式應該都要用asInvoker來執行,他的意思是就依照目前你登入Vista帳號的權限執行,requireAdministrator顧名思義就是要你啟動管理者權限才能執行,這裡是Vista會不會跳出UAC權限允許視窗的重點,如果用了asInvoker應該就不會再跳出了,如果程式中沒有manifest則預設為requireAdministrator權限,requestedExecutionLevel為requireAdministrator的可執行檔案前面都會有一個小盾牌提醒使用者。

我是用VC2008編譯,VC2008內有manifest的設定頁,VC6沒有...要自己來。囧rz

關鍵二. 存取檔案的問題:這個問題應該是最討厭的問題也最讓人摸不著頭緒的問題,以前一般的應用程式會將成是本身的設定檔、紀錄檔或是Log都會寫在程式安裝目錄的資料夾裡面,例如 C:\Program Files 底下,不過在Vista上只要打開 UAC 在這個目錄寫檔案就會失敗,那如果這裡不能寫入檔案哪裡可以呢?是有一些地方可以提供選擇,%USERPROFILE% (每個使用者自己所用的文件夾) 或是 %ALLUSERSPROFILE% (程式共用區用),當然還有其他的位置這裡我只提出兩個,我個人建議都放在 %USERPROFILE% 裡面,為何呢?放在共用區大家用不是很好嗎?Vista上有一個特性,假如 A 使用者建立了 A.TXT檔案那麼 B 使用者就無法修改 A.TXT ,因為 A.TXT 隸屬於 A,那如果 B 使用者是管理者權限呢?那結果會有些不同,B 可以刪除 A.TXT 但是一樣無法修改,基於這個理由所以建議將各自使用者的設定相關檔案放在自己的目錄內而別放在共用區,大家只要進一步了解 UAC 的防護機制後就比較能夠避免寫出與他衝突的程式碼了吧。
總之,檔案別再亂放了。XD

滿足了上面兩個 XP 跟 Vista 主要差異後你的程式應該可以順利啟動,至於能不能正常運作那還有得改哩。

=============== 獲得 Vista 應用程式軟體認證分隔線 ===============
為何要申請 Vista Software Logo?
這個問題我想了很久...我想應該就跟冷凍豬肉要用CAS的標章是一樣的吧。要如何申請?
流程如何?簡單的順序如下
1.申請加入微軟合作夥伴(MSPP)。
2.在合作夥伴的網頁登入要驗證的程式。
3.利用Microsoft Product Identification產生程式的身分.XML檔案。
4.申請VeriSign的Certificate。
5.在Windows Quality Online Services(Winqual)網站以公司身分註冊一個帳號。
6.下載Winqual.exe並將Verisign取得的簽章簽入Winqual.exe內,此一行為代表此簽章等於本公司產品申請驗證所要用的簽章。
7.上傳已經簽好的Winqual.exe到Winqual網站,完成此步驟本公司在Winqual的帳號才算註冊完成。
8.提交完成後保留對方給予的檔案跟ID,日後再提交測試到VeriTest的時候會用到。
9.到VeriTest網站註冊並填寫申請資料。(要信用卡繳錢)
10.並填寫放棄測試的項目申請書(WaiverSubmission.doc)針對不相干的Test Case部分跳過。
11.提交程式。(一併提交其他相關測試附件)
12.等結果。
看似簡單其實對於英文破破的我來說還真的很怕看錯,可以自己看

這裡有兩個地方要您花錢,一個是從 VeriSign 買數位簽章另一個是給 VeriTest 測試你的軟體,自己看
不過大略的步驟就跟我上面說的一樣吧。
接下來,我來介紹一下送交VeriTest驗證時會碰到的考古題,在這之前大家可能要先看 Requirements for the Windows Vista Logo Program for Software 這一份文件,這份文件是建立考古題的依據,分成三大類
1.Security and Compatibility(安全性跟相容性)
2.Installation(安裝)
3.Reliability(可靠度)
看過Requirements之後會比較容易了解Test Cases 是在玩什麼花樣
CertifiedforWindowsVistaProgramTestCases.doc(所有的考古題來自這份文件,下方有相關連結)

TEST CASE 1.Verify all of the application’s executables contain an embedded manifest that define its execution level. 只是用CFF Explorer來檢視程式內的可執行檔requestedExecutionLevel level,很容易。

TEST CASE 2.Verify Least-Privilege Users can not modify other users documents or files.利用Vista的切換使用者來各自執行程式並刻意去存取另外使用者的文件夾。

TEST CASE 3.Verify Least-Privilege user is not able to save files to Windows System directory. 讓程式去存取Windows目錄底下的檔案。

TEST CASE 4.Verify application installer does not have a 16-Bit installer, does not use or rely on 16-Bit code or components and does not attempt to install any non 64-Bit drivers on x64 versions of Windows regardless if application is a Win32 application or is native to 64-bit.把程式安裝到 x64 version of Windows Vista Ultimate,並執行運作。

TEST CASE 5.Verify application installed executables and files are signed.檢查安裝路徑下所有可執行的檔案類型是否都有加入數位簽章。

TEST CASE 6.Verify all kernel-mode drivers installed by the application are signed.Driver需要數位簽章。

TEST CASE 7.Verify application properly checks for Operating System version. 使用AppVerifier驗證所有的執行檔是否有呼叫 GetVersion() or GetVersionEx()的API。

TEST CASE 8.Verify application launches and executes properly using Fast User Switching.用Vista上切換不同使用者(權限)各自執行程式看看有無問題。

TEST CASE 9.Verify application launches and executes properly using Remote Desktop.利用Vista遠端桌面來執行程式並作一般操作測試。

TEST CASE 10.Verify drivers and services start in Safe-Mode. Driver或是Service在安全模式下執行運作。

TEST CASE 11.Verify application installer uses Windows Installer. 驗證安裝檔案是否包裝成.MSI的格式。

TEST CASE 12.Verify application’s MSI installer does not receive any errors from the Internal Consistency Evaluators. 透過Orca軟體安裝程式的.msi程式過程中不能出現特定的錯誤。

TEST CASE 13.Verify application’s installer contains an embedded manifest. 用Resource Hacker 3.4 檢查安裝檔是否有 manifest execution level 的 requestedExecutionLevel。

TEST CASE 14.Verify application launches with installed user token.用Resource Hacker 3.4 驗證安裝檔跟執行檔是否有相同的 requestedExecutionLevel。
如果是用MSI封裝則此步驟可以忽略。

TEST CASE 15.Verify application installs to the correct folders by default.利用AppVerifier檢查安裝路徑是否有產生錯誤。

TEST CASE 16.Verify ClickOnce application is signed with a valid Authenticode Certificate.這個 Test Case 是針對clockOnce的安裝放式來作驗證。

TEST CASE 17.Verify ClickOnce application only stores data in installed user’s folders.同 Test Case 16,資料存放在自己的資料夾內。

TEST CASE 18.Verify Windows Installer package contains ProductName, Manufacturer, ProductVersion (major and minor), UpgradeCode, ProductCode and ProductLanguage property tags and that they are not null.用Orca來檢查安裝檔.MSI是否有包含必要相關資訊。

TEST CASE 19.Verify application creates uninstall registry key and values.使用Orca來檢查安裝後是否有在 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\ 內寫入 Uninstall的資訊。

TEST CASE 20.Verify application does not try to write to or replace any WRP registry keys or files.用AppVerifier檢驗安裝過程中不會寫入任何的WRP Registry Key或是Windows System File。

TEST CASE 21.Verify the application does not use nested install custom actions.用Orca打開安裝程式.MSI檢查CustomAction table沒有作不允許的安裝動作。

TEST CASE 22.Verify the application does not add custom columns to the Windows Installer’s standard tables and that any custom tables or properties are not prefixed with ‘msi’.用Orca檢查安裝的.MSI檔案跟Schema.msi比較內部的Standard Table欄位不可以有變更,自訂欄位的話則要有"msi"的prefix.

TEST CASE 23.Verify the application rolls back the install and restores machine back to previous state.複製並製造一個會安裝失敗的.MSI檔案,比較安裝前跟安裝失敗後系統是否有恢復安裝前的狀態。

TEST CASE 24.Verify the application does not force a reboot during install.用Orca檢查.MSI檔案內是否有ForceReboot的設定。

TEST CASE 25.Verify the application properly handles files in use during install. 用Orca檢查 MsiRMFilesInUse property,如果沒有存在的話必須加入對應的Dialog跟property。

TEST CASE 26.Verify the application can be installed quietly from the command line.用 Orca檢查FASTOEM欄位,並且測試安靜安裝。

TEST CASE 27.Verify the application’s Windows Installer ComponentID table does not contain null values.用Orca檢查.MSI檔案內 Component Table必要欄位不可以為NULL。

TEST CASE 28.Verify the application’s Windows Installer Package does not contain more than one COM Server for each Component.用Orca檢查.MSI檔案內 Component Table檢查不能有超過一個以上的COM Server。

TEST CASE 29.Verify the application’s Windows Installer Package does not contain more than one shortcut for each component. 用Orca檢查.MSI檔案內 Component Table檢查每個component不能有一個以上的捷徑。

TEST CASE 30.Verify the application is Restart Manager Aware.用Restart Manager Tool(rmtool.exe)來測試WM_ENDSESSION or WM_QUERYENDSESSION訊息。

TEST CASE 31.Verify application does not break into debugger with the specified AppVerifier checks.執行程式用 AppVerifier開啟Debug模式並執行操作。

TEST CASE 32.Verify that he application’s UI thread only handles exceptions that are known and expected.使用ThreadHijacker來讓程式產生 Access Violation,然後會產生 Windows Error Reporting(就是錯誤回報或是要你Debug那個視窗)。

總結:
大家可以概略看出這些Test Case主要的精神就是前面提到的三大Requirements,不過更實際來看就是
1.你的程式要在UAC下正常運作,不可以亂存取禁止的目錄 。
2.安裝程式必須用MicroSoft的MSI格式或是ClickOnce方式 。
3.萬一程式發生錯誤能夠透過 Windows Error Report 來回報錯誤並紀錄錯誤資訊 。
4.數位簽章 。

雖然有些Case我也是很模糊XD,真怕我接下來要準備送驗的過程會出差錯....唉,該好好唸英文了。Orz
跟我一樣被指派申請Vista Logo認證的苦主 http://www.codeproject.com/KB/vista/certificationbyexample.aspx (VB.Net + C#)
已經獲得Vista Logo認證的程式 http://support.microsoft.com/kb/933305
申請VeriSign的數位簽章憑證流程 http://www.wosign.hk/support/MS_Authenticode_DigitalID_guide.htm
針對某些Test Case詳解 http://blogs.msdn.com/amitava/rss.xml
提供其他Vista Logo相關連結 http://dotnet.org.za/ahmeds/archive/2006/12/15/Vista-Logo-Links.aspx
MSDN http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=904&SiteID=1

没有评论: