In Vista, How Does the FLAGS Switch of REG.EXE Work? In Vista, come le bandiere Switch REG.EXE di lavoro?
Note: this content originally from Nota: questo il contenuto originario di http://mygreenpaste.blogspot.com http://mygreenpaste.blogspot.com . . If you are reading it from some other site, please take the time to visit Se si sta leggendo è da qualche altro sito, si prega di prendere il tempo di visitare My Green Paste, Inc Incolla il mio verde, inc . . Thank you. Grazie.
A while back, there was a topic ( Un po 'di tempo indietro, vi è stato un argomento ( Virtual Registry vs. "Real registry" C. registro virtuale "Real Registro di sistema" ) in the ) Nel Sysinternals Forums Sysinternals Forum 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. che ha portato la questione di come impostare la virtualizzazione connesse bandiere di una chiave di registro di programmazione in Vista, piuttosto che attraverso l'uso della REG.EXE strumento's BANDIERE interruttore. (For more information on the flags, see (Per maggiori informazioni sulle bandiere, vedere Mark Russinovich Mark Russinovich 's article in TechNet Magazine, " 's articolo TechNet Magazine, " Inside Windows Vista User Account Control All'interno di Windows Vista User Account Control "). 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.) "). Anche prima di tale argomento nel forum, avevo chiesto come è stato fatto ma non aveva avuto la possibilità di esplorare. E non sembra che molti altri sono stati curioso circa. Tale argomento ha avuto l'idea risorto, ma rapidamente caduto in fondo alla lista. ho finalmente ottenuto intorno alla sperimentazione, e che porta a scrivere questo-up. Continuo a non vedere molto nel modo in cui ha discusso della presente ovunque, dalla ricerca di termini in gioco (tipi di dati, param funzione di nomi, ecc), così speriamo, ciò contribuirà a qualcuno. (Tieni presente che non vi molto bene può essere un motivo Microsoft ha reso questo non disponibili tramite un altro, più diretto 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. In tema di riferimento, avevo ottenuto finora come determinare REG.EXE che stava facendo il suo lavoro attraverso l'uso di NtSetInformationKey, un "senza documenti" API in ntdll.dll.
NTSYSAPI
NTSTATUS
NTAPI
NtSetInformationKey( NtSetInformationKey (
IN HANDLE KeyHandle, Gestire in KeyHandle,
IN KEY_SET_INFORMATION_CLASS InformationClass, In KEY_SET_INFORMATION_CLASS InformationClass,
IN PVOID KeyInformationData, In PVOID KeyInformationData,
IN ULONG DataLength ); IN ULONG DataLength);
After a bit of plonking around in WinDbg, I've come up with the following following details. Dopo un po 'di circa plonking in WinDbg, abbiamo elaborato con i seguenti dati. REG.EXE calls Invita REG.EXE NtSetInformationKey , specifying a value of 2 for the InformationClass parameter. , Specificando un valore di 2 per il parametro InformationClass. This parameter is of type KEY_SET_INFORMATION_CLASS, which wdm.h tells us is an enum: Questo parametro è di tipo KEY_SET_INFORMATION_CLASS, che ci dice wdm.h è un enum:
typedef enum _KEY_SET_INFORMATION_CLASS { typedef enum _KEY_SET_INFORMATION_CLASS (
KeyWriteTimeInformation,
KeyWow64FlagsInformation,
KeyControlFlagsInformation,
KeySetVirtualizationInformation,
KeySetDebugInformation,
MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum MaxKeySetInfoClass / / MaxKeySetInfoClass dovrebbe sempre essere l'ultima enum
} KEY_SET_INFORMATION_CLASS; KEY_SET_INFORMATION_CLASS);
So the 2 for the InformationClass parameter would correspond to KeyControlFlagsInformation. Così il 2 per il parametro InformationClass corrisponderebbe a KeyControlFlagsInformation. WDM.H also suggests that this class has a type that one passes for the KeyInformationData parameter - KEY_CONTROL_FLAGS_INFORMATION: WDM.H suggerisce anche che questa classe ha un tipo che si passa per il parametro KeyInformationData - KEY_CONTROL_FLAGS_INFORMATION:
typedef struct _KEY_CONTROL_FLAGS_INFORMATION { typedef struct (_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. Abbiamo una idea di base di come chiamare NtSetInformationKey ora. But what are the values that the ControlFlags member of KEY_CONTROL_FLAGS_INFORMATION can be set to? Ma quali sono i valori che la ControlFlags membro del KEY_CONTROL_FLAGS_INFORMATION può essere impostato per? 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): Sembrerebbe che le seguenti (self-made) enum copre il pertinenti bandiere - almeno quelli REG.EXE BANDIERE in grado di gestire (ci può essere di più):
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. Il controllo flag USE sono un bitmask, in modo che tu possa O loro di più di uno.
Now that we have this information, what's left? Ora che abbiamo queste informazioni, quel che resta? We need to put it all together in a call to NtSetInformationKey. Abbiamo bisogno di mettere tutto insieme in una chiamata a NtSetInformationKey. So, we need to get a pointer to the function in NTDLL.DLL. Quindi, abbiamo bisogno di ottenere un puntatore a funzione in 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. Quindi, siamo in grado di dichiarare una struct di tipo KEY_CONTROL_FLAGS_INFORMATION, impostare il ControlFlags membro ad essere ciò che vogliamo, e aprire una chiave nella posizione desiderata nel Registro di sistema, che può essere passato a NtSetInformationKey. In the end, we wind up with something like the following (error handling has been omitted): Alla fine abbiamo vento fino a qualcosa di simile alla seguente (la gestione degli errori sono stati omessi):
typedef NTSYSAPI NTSTATUS (NTAPI* FuncNtSetInformationKey) ( typedef NTSYSAPI NTSTATUS (NTAPI * FuncNtSetInformationKey) (
HANDLE KeyHandle, MANICO 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 = NULL;
RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Whatever"), 0, KEY_ALL_ACCESS, &hTheKey ); RegOpenKeyEx (HKEY_LOCAL_MACHINE, _T ( "SOFTWARE \ \ Qualunque"), 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 = NULL;
The code above is the equivalent of invoking REG.EXE FLAGS HKLM\Software\Whatever SET DONT_VIRTUALIZE RECURSE_FLAGS . Il codice sopra è l'equivalente di invocare REG.EXE BANDIERE HKLM \ Software \ Qualunque SET DONT_VIRTUALIZE RECURSE_FLAGS. To clear the flags, just set kcfi.ControlFlags to RegKeyClearFlags (same as REG.EXE FLAGS HKLM\Software\Whatever SET) . Per cancellare le bandiere, appena impostato kcfi.ControlFlags a RegKeyClearFlags (le stesse di REG.EXE BANDIERE HKLM \ Software \ Qualunque SET).
Hopefully, this will prove useful to those that have wished to set these flags programmatically. Speriamo, questo sarà utile a coloro che hanno voluto impostare queste bandiere di programmazione. In a future post, I hope to explore querying for these flags, ala REG.EXE FLAGS HKLM\Software\Whatever QUERY . In un futuro post, spero di ricerca per esplorare queste bandiere, ALA REG.EXE BANDIERE HKLM \ Software \ Qualunque query.
Note that this exploration was done on Windows Vista SP1. Tieni presente che questa esplorazione è stato fatto in Windows Vista SP1. I would expect the content here to also apply to Windows Vista (no SP) as well as Windows Server 2008, but... Mi aspetto il contenuto qui per applicarsi anche a Windows Vista (non SP) e Windows Server 2008, ma ...
Popularity: 4% Popularity: 4%
Written by «/\/\Ø|ö±ò\/»®©. Scritto da  «/ \ / \ à ~ |  ¶ à ± à ² \ / »   ® ©. Read more great feeds at is source Per saperne di più grande al feed è fonte WEBSITE SITO WEB
no comments nessun commento . .
Read more articles on Per saperne di più articoli su flags bandiere and e NtSetInformationKey NtSetInformationKey and e REG_KEY_DONT_VIRTUALIZE REG_KEY_DONT_VIRTUALIZE and e Sysinternals Forum Sysinternals Forum and e reg.exe flags reg.exe bandiere and e registry virtualization Registro di sistema di virtualizzazione and e reg Reg and e REG_KEY_DONT_SILENT_FAIL REG_KEY_DONT_SILENT_FAIL and e Troubleshooting Risoluzione dei problemi and e vista Vista and e windbg WinDbg and e otherSoftware otherSoftware and e registry Registro di sistema and e Virtualization Virtualizzazione . .
- [+] Digg [+] Digg : Feature this article : Feature questo articolo
- [+] Del.icio.us [+] Del.icio.us : Bookmark this article : Bookmark questo articolo
- [+] Furl [+] Furl : Bookmark this article : Bookmark questo articolo














