vista開發一些總結

 
權限提升與盾牌
Vista下進程默認運行權限爲標準用戶權限,是受限的,無寫系統目錄、註冊表(HKEY_CURRENT_USER除外)權限,對於有些需要管理員權限才能進行的操作,vista下提供了提升功能。
可給菜單、按鈕加上盾牌風格,提示用戶需要提升才能運行。
添加辦法:
       SendMessagehBtnWnd,BCM_SETSHIELD, 0, 1
進程運行權限判斷:
OpenProcessToken
TOKEN_ELEVATION te;
GetTokenInformation(hToken,(TOKEN_INFORMATION_CLASS)(
TokenElevation),&te,sizeof( te ),    &dwReturnLength)
       通過te.TokenIsElevated來得到進程權限是否提升。
提示用戶高權限運行方式:
       Verb參數設爲runas,方式調用ShellExecuteEx
會話
XP、Vista引入會話概念,運行進程都屬於某個會話,一般服務運行於session 0
,用戶登錄後啓動的進程運行於同一session ,不同session進程間通訊 可能需要特殊機制(管道、共享內存、com),但消息傳遞會失敗。Winlogon以system權限運行於登錄用戶會話。
進程間通訊
Vista下低權限進程向高權限進程發送消息號大於WM_USER會被攔截,除非在接收方調用ChangeWindowMessageFilter指定可接收該消息。
保護模式
Vista下對象安全級別英文叫:mandatory integrity level,mandatory:強制的, 託管的
強制完整性級別,共四個級別:
  • System: Used by OS components, should not be used by applications.
  • High: Processes that are running elevated with full admin rights.
  • Medium: Processes launched in the normal fashion.
  • Low: Used by IE and Windows Mail to provide protected mode.
進程運行時刻決定屬於哪個級別,並且不能更改。
劃分主要的三個作用:
  1.  Any securable objects that the process creates get that same integrity level.
  2. The process cannot access a resource whose integrity level is higher than the process's own level.
  3. The process cannot send window messages to a process that has a higher integrity level.
 
Virtualization虛擬化)、Redirection
    攔截或者說不讓進程寫保護的註冊表和文件系統區域,但依然讓進程正常運行,稱爲虛擬化。
對於Medium級別受限寫的區域包括:
      HKLM,
       system32
   Program Files 等等
   而對於low-integrity更加受限。
當低權限進程試圖寫受限區域,系統會重定位到當前進程可操作目錄
比方:
       虛擬化前C:/ ProgramData
       虛擬化後:C:/Users/test/AppData/Local/Microsoft/Windows/Temporary Internet Files/Virtualized/C/ProgramData/
 
內核對象
A進程創建的內核對象如event 或 mutex,如果低權限的B進程要使用,則必須減低內核對象的ACL和integrity-level。具體可參見文獻SetObjectToLowIntegrity函數。
參考文獻
l        A Developer's Survival Guide to IE Protected Mode
http://www.codeproject.com/vista-security/PMSurvivalGuide.asp
 
發佈了27 篇原創文章 · 獲贊 7 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章