gpt4 book ai didi

windows - 为什么 WOW64 进程上的 CreateEnvironmentBlock 会给我 PROCESSOR_ARCHITECTURE=AMD64

转载 作者:可可西里 更新时间:2023-11-01 10:50:12 26 4
gpt4 key购买 nike

如果我尝试使用 CreateEnvironmentBlock() 从 32 位进程(在 64 位操作系统上)创建环境 block ,我得到的环境 block 似乎大部分是正确的,但它与自动创建的环境 block 有一些不同通过创建过程。最值得注意的是 PROCESSOR_ARCHITECTURE 在 32 位进程上通常是 x86,但来自 CreateEnvironmentBlock 的是 amd64。

BOOL bResult = FALSE;
LPWSTR wszEnvBlock = NULL;
HANDLE tokenHandle;

OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle);

bResult = ::CreateEnvironmentBlock((LPVOID*)&wszEnvBlock, tokenHandle, TRUE);

LPWSTR wszCurrentItem = wszEnvBlock;
LPWSTR wszEqualsSign = NULL;
LPWSTR wszCurrentItemInuse = NULL;

ATL::CStringW wstrCurrentName;
ATL::CStringW wstrCurrentValue;

while (L'\0' != *wszCurrentItem)
{
// Find the equals and temporarily set it to NULL
wszCurrentItemInuse = wszCurrentItem;
wszEqualsSign = wcschr(wszCurrentItem, L'=');
*wszEqualsSign = L'\0';

// Copy the Name and then set the equals back as it was
wstrCurrentName = wszCurrentItem;
*wszEqualsSign = L'=';

// Move the current item to the next character after the equals sign,
// Then copy the Value
wszCurrentItem = ++wszEqualsSign;
wstrCurrentValue = wszCurrentItem;

// Move the current item to the next character after the terminating NULL character.
wszCurrentItem = wcschr(wszCurrentItem, L'\0');
wszCurrentItem++;

// Insert the two read strings into the map
wprintf(L"%s:%s\n", wstrCurrentName, wstrCurrentValue);
}

bResult = DestroyEnvironmentBlock((LPVOID)wszEnvBlock);

产生以下输出:

ADMSOURCE:\ddwds02\platform8\DesktopPersonalisation\Win7\GO\Source\adm ALLUSERSPROFILE:C:\ProgramData APPDATA:C:\Users\bens\AppData\Roaming asl.log:Destination=file AS_WDK6_DIR:C:\WinDDK\6000 AS_WDK7_DIR:C:\WinDDK\7600.16385.0 CLASSPATH:.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip CommonProgramFiles:C:\Program Files (x86)\Common Files CommonProgramFiles(x86):C:\Program Files (x86)\Common Files CommonProgramW6432:C:\Program Files\Common Files COMPUTERNAME:APWADEV03 ComSpec:C:\Windows\system32\cmd.exe CYGWIN:nodosfilewarning DEFAULT_CA_NR:CA100 DEVELOPMENT:c:\development DEVLIBS:C:\development\libs FP_NO_HOST_CHECK:NO HOME:c:\users\bens HOMEDRIVE:C: HOMEPATH:\Users\bens INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\SDK\v1.1\includ e\ LIB:C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\ LOCALAPPDATA:C:\Users\bens\AppData\Local LOCALHOMESHARE:C:\Users\bens LOGONSERVER:\APWADC01 NUMBER_OF_PROCESSORS:2 OS:Windows_NT PATHEXT:.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE:AMD64 PROCESSOR_ARCHITEW6432:AMD64 PROCESSOR_IDENTIFIER:Intel64 Family 6 Model 23 Stepping 10, GenuineIntel PROCESSOR_LEVEL:6 PROCESSOR_REVISION:170a ProgramData:C:\ProgramData ProgramFiles:C:\Program Files (x86) ProgramFiles(x86):C:\Program Files (x86) ProgramW6432:C:\Program Files PSModulePath:C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC:C:\Users\Public PVC_DDK_DIR:C:\WinDDK\6000 QTJAVA:C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip SESSIONNAME:Console SP2C_ROOT:C:\Development\SP2C_Win7 SystemDrive:C: SystemRoot:C:\Windows TEMP:C:\Users\bens\AppData\Local\Temp TMP:C:\Users\bens\AppData\Local\Temp USERPROFILE:C:\Users\bens VisualStudioDir:C:\Users\bens\Documents\Visual Studio 2010 VS100COMNTOOLS:C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools \ VS71COMNTOOLS:C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Common7\T ools\ VS80COMNTOOLS:C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\ VS90COMNTOOLS:c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\ windir:C:\Windows WIX:C:\Program Files (x86)\Windows Installer XML v3\ WTTBIN:C:\Program Files\Microsoft Driver Test Manager\Controller\ _NT_SYMBOL_PATH:srv*c:\ websymbols*http://msdl.microsoft.com/download/symbols;sr v*c:\pdbs PATH:C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\Syst em32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GTK 2-Runtime\bin;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files\ Microsoft Driver Test Manager\Controller\;C:\Program Files (x86)\FogBugz\FogBugz Command Line Client;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\ ;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsof t SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools \Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\B inn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin\;C:\cygwinx\b in;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86 )\Common Files\Teleca Shared;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Progr am Files (x86)\AMD\CodeAnalyst\bin;C:\Program Files (x86)\Nmap;c:\Users\bens\scr ipts\win;C:\Program Files (x86)\Microsoft Visual Studio 10.0\;C:\Program Files ( x86)\Microsoft Visual Studio 10.0\VC\bin;

那么 CreateEnvironmentBlock 是不是刚刚在 wow64 上坏了?此外,系统环境似乎在 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment 中定义

wow64 怎么没有这样的东西?

最佳答案

这是 CreateEnvironmentBlock() 的错误,MS 已意识到该问题并已 promise 在未来某个未指定的版本中修复它。

关于windows - 为什么 WOW64 进程上的 CreateEnvironmentBlock 会给我 PROCESSOR_ARCHITECTURE=AMD64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6749187/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com