Your best source of information and news about Vista hardware , winvista and software on the internet 您的最佳信息來源和新聞關於Vista的硬件winvista軟件在互聯網上

Vista ARTICLES Vista的文章 TOP 50前50名 Vista VIDEOS Vista的影片 Vista SOFT Vista的軟 Vista HELP Vista幫助

In Vista, How Does the FLAGS Switch of REG.EXE Work?在Vista中,請問國旗開關reg.exe工作?


Note: this content originally from 注意:此內容原本由 http://mygreenpaste.blogspot.com http://mygreenpaste.blogspot.com . If you are reading it from some other site, please take the time to visit 如果你是讀它從其他一些網站上,請採取的時間訪問 My Green Paste, Inc 我的綠色粘貼,公司 . Thank you. 謝謝您。


A while back, there was a topic (而回,有一個話題( Virtual Registry vs. "Real registry"虛擬註冊表與“真正的註冊表” ) in the ) ,在 Sysinternals Forums的Sysinternals論壇 that brought up the question of how to set the virtualization-related flags of a registry key programmatically in Vista, rather than through the use of the REG.EXE tool's FLAGS switch.帶來了問題,如何設置虛擬化有關的旗幟,一個註冊表項以編程方式在Vista ,而不是通過使用該reg.exe工具的國旗開關。 (For more information on the flags, see (更多信息,對國旗,見 Mark Russinovich馬克russinovich 's article in TechNet Magazine, "奇摩文章在TechNet雜誌, “ Inside Windows Vista User Account Control內Windows Vista的使用者帳戶控制 "). Even before that topic in the forum, I had wondered how it was done but had not had a chance to explore. It didn't seem that many others were curious about it. That topic had resurrected the idea, but it quickly fell to the bottom of the list. I've finally gotten around to experimenting, and that leads to this write-up. I still don't see much in the way of this discussed anywhere, by searching for terms involved (data types, function param names, etc.), so hopefully this will help someone. (Keep in mind that there very well may be a reason Microsoft hasn't made this available through another, more direct API.) “ ) ,即使之前的話題,在論壇上,我已不知道它是怎麼做,但沒有機會去探索。似乎沒有什麼,很多人好奇。這一議題已復活的想法,但很快下降到列表的底部,我已經終於周圍的試點,導致這寫了,我仍然沒有看到很大的方式,這個討論在任何地方,通過搜索的條款所涉及的(數據類型,功能參數的名稱等) ,所以希望這將有助於有人。 (請記住,還有很可能是一個原因,微軟並沒有作出這可通過另一個,更直接的API ) 。


In the referenced topic, I had gotten so far as determining that REG.EXE was doing its work through the use of NtSetInformationKey, an "undocumented" API in NTDLL.DLL.在引用的話題,我曾得到到目前為止,作為認定reg.exe做其工作,通過使用ntsetinformationkey ,一個“無證件”在空氣污染指數的Ntdll.dll 。


 NTSYSAPI ntsysapi 

NTSTATUS ntstatus

NTAPI ntapi

NtSetInformationKey( ntsetinformationkey (

IN HANDLE KeyHandle,在處理keyhandle ,

IN KEY_SET_INFORMATION_CLASS InformationClass,在key_set_information_class informationclass ,

IN PVOID KeyInformationData,在pvoid keyinformationdata ,

IN ULONG DataLength );在ulong datalength ) ;


After a bit of plonking around in WinDbg, I've come up with the following following details.後一點plonking左右,在windbg ,我已經有了以下以下細節。 REG.EXE calls reg.exe呼籲 NtSetInformationKey ntsetinformationkey , specifying a value of 2 for the InformationClass parameter. ,指定值2為informationclass參數。 This parameter is of type KEY_SET_INFORMATION_CLASS, which wdm.h tells us is an enum:這個參數的類型key_set_information_class , wdm.h告訴我們,是的ENUM :


 typedef enum _KEY_SET_INFORMATION_CLASS { typedef的ENUM _key_set_information_class ( 

KeyWriteTimeInformation, keywritetimeinformation ,

KeyWow64FlagsInformation, keywow64flagsinformation ,

KeyControlFlagsInformation, keycontrolflagsinformation ,

KeySetVirtualizationInformation, keysetvirtualizationinformation ,

KeySetDebugInformation, keysetdebuginformation ,

MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum maxkeysetinfoclass / / maxkeysetinfoclass要始終成為最後的ENUM

} KEY_SET_INFORMATION_CLASS; ) key_set_information_class ;


So the 2 for the InformationClass parameter would correspond to KeyControlFlagsInformation.因此,二為informationclass參數,將對應於keycontrolflagsinformation 。 WDM.H also suggests that this class has a type that one passes for the KeyInformationData parameter - KEY_CONTROL_FLAGS_INFORMATION: wdm.h還表明,這個類有一個類型,一通為keyinformationdata參數-k ey_control_flags_information:


 typedef struct _KEY_CONTROL_FLAGS_INFORMATION { typedef結構_key_control_flags_information ( 

ULONG ControlFlags; ulong controlflags ;

} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; ) key_control_flags_information , * pkey_control_flags_information ;


We have a basic idea of how to call NtSetInformationKey now.我們有一個基本的想法如何調用ntsetinformationkey現在。 But what are the values that the ControlFlags member of KEY_CONTROL_FLAGS_INFORMATION can be set to?但什麼是價值觀認為, controlflags成員key_control_flags_information可以設定? It would appear that the following (self-made) enum covers the pertinent flags - at least the ones REG.EXE FLAGS can handle (there may be more):這樣看來,以下(自製)的ENUM涵蓋了相關的國旗-至少那些r eg.exe國旗可以處理(可能有更多的) :


 typedef enum _CONTROL_FLAGS { typedef的ENUM _control_flags ( 

RegKeyClearFlags = 0, regkeyclearflags = 0 ,

RegKeyDontVirtualize = 2, regkeydontvirtualize = 2 ,

RegKeyDontSilentFail = 4, regkeydontsilentfail = 4 ,

RegKeyRecurseFlag = 8 regkeyrecurseflag = 8

} CONTROL_FLAGS; ) control_flags ;


The control flags are a bitmask, so you can OR them to set more than one.控制國旗是一個位掩碼,所以你可以或他們設置一個以上。


Now that we have this information, what's left?現在我們有了這方面的資料,什麼剩下的? We need to put it all together in a call to NtSetInformationKey.我們需要把它所有在同一個電話ntsetinformationkey 。 So, we need to get a pointer to the function in NTDLL.DLL.因此,我們必須取得一個指針的功能在的Ntdll.dll 。 Then, we can declare a struct of type KEY_CONTROL_FLAGS_INFORMATION, set the ControlFlags member to be what we wish, and open a key to the desired location in the registry, that can be passed to NtSetInformationKey.然後,我們可以宣布某一結構類型的key_control_flags_information ,設置controlflags會員要什麼我們希望,並打開一個關鍵是要想要的位置在註冊表中,即可以通過ntsetinformationkey 。 In the end, we wind up with something like the following (error handling has been omitted):在最後,我們的風起來像以下(錯誤處理已省略) :


 typedef NTSYSAPI NTSTATUS (NTAPI* FuncNtSetInformationKey) ( typedef ntsysapi ntstatus ( ntapi * funcntsetinformationkey ) ( 

HANDLE KeyHandle,處理keyhandle ,

KEY_SET_INFORMATION_CLASS InformationClass, key_set_information_class informationclass ,

PVOID KeyInformationData, pvoid keyinformationdata ,

ULONG DataLength ); ulong datalength ) ;

//...

FuncNtSetInformationKey ntsik = (FuncNtSetInformationKey)GetProcAddress( funcntsetinformationkey ntsik = ( funcntsetinformationkey ) getprocaddress (

GetModuleHandle( _T("ntdll.dll") ), "NtSetInformationKey" ); getmodulehandle ( _t ( “的Ntdll.dll ” ) ) , “ ntsetinformationkey ” ) ;

KEY_CONTROL_FLAGS_INFORMATION kcfi = {0}; key_control_flags_information kcfi = ( 0 ) ;

kcfi.ControlFlags = RegKeyDontVirtualize | RegKeyRecurseFlag; kcfi.controlflags = regkeydontvirtualize | regkeyrecurseflag ;

HKEY hTheKey = NULL; hkey hthekey =空;

RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Whatever"), 0, KEY_ALL_ACCESS, &hTheKey ); regopenkeyex ( hkey_local_machine , _t (以下簡稱“軟件\ \無論” ) , 0 , key_all_access , & hthekey ) ;

ntsik( hTheKey, KeyControlFlagsInformation, &kcfi, sizeof( KEY_CONTROL_FLAGS_INFORMATION ) ); ntsik ( hthekey , keycontrolflagsinformation , & kcfi , sizeof ( key_control_flags_information ) ) ;

RegCloseKey( hTheKey ); regclosekey ( hthekey ) ;

hTheKey = NULL; hthekey =空;



The code above is the equivalent of invoking REG.EXE FLAGS HKLM\Software\Whatever SET DONT_VIRTUALIZE RECURSE_FLAGS .上面的代碼是相當於援引reg.exe國旗將HKLM \軟件 \ 無論設置dont_virtualize recurse_flags To clear the flags, just set kcfi.ControlFlags to RegKeyClearFlags (same as REG.EXE FLAGS HKLM\Software\Whatever SET) .以清除旗幟,剛剛成立kcfi.controlflags ,以regkeyclearflags (同reg.exe國旗將HKLM \軟件\無論集)

Hopefully, this will prove useful to those that have wished to set these flags programmatically.希望這將證明是有用的,以那些有希望設置這些國旗編程。 In a future post, I hope to explore querying for these flags, ala REG.EXE FLAGS HKLM\Software\Whatever QUERY .在未來的職位,我希望探索質疑為國旗和區旗,助理法律顧問reg.exe國旗將HKLM \軟件\無論查詢


Note that this exploration was done on Windows Vista SP1.請注意,這是做了探索,在Windows Vista SP1的。 I would expect the content here to also apply to Windows Vista (no SP) as well as Windows Server 2008, but...我期望的內容,在這裡也適用於Windows Vista的(沒有SP ) ,以及在Windows Server 2008 ,但...

Popularity: 4%人氣: 4 %


Written by «/\/\Ø|ö±ò\/»®©. 寫â « / \ / \ ã 〜 | ã ¶ â ± ã ² \ / â » â ® â © 。 Read more great feeds at is source 閱讀更多偉大的飼料是來源 WEBSITE 網站
no comments 沒有評論 .
Read more articles on 閱讀更多的文章 flags 國旗 and NtSetInformationKey ntsetinformationkey and REG_KEY_DONT_VIRTUALIZE reg_key_dont_virtualize and Sysinternals Forum 的Sysinternals論壇 and reg.exe flags reg.exe國旗 and registry virtualization 註冊表虛擬化 and reg 條例 and REG_KEY_DONT_SILENT_FAIL reg_key_dont_silent_fail and Troubleshooting 疑難解答 and vista Vista的 and windbg windbg and otherSoftware othersoftware and registry 註冊表 and Virtualization 虛擬化 .

No comments沒有評論

There are still no comments on this article.仍然有沒有評論這篇文章。

Leave your comment...離開您的評論...

If you want to leave your comment on this article, simply fill out the next form:如果您想留下您的評論關於此文章,只需填寫未來的形式:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .您可以利用這些資料的XHTML標籤:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite="">的<code>的<em> < i > <strike>的<strong> 。