Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:49:06+00:00 2026-06-03T07:49:06+00:00

If I try to create an environment block from within a 32 bit process

  • 0

If I try to create an environment block from within a 32 bit process (on a 64 bit OS) using CreateEnvironmentBlock() the environment block I get seems to be mostly correct but it has a few differences from one that gets created automatically by CreateProcess. Most notably PROCESSOR_ARCHITECTURE is usually x86 on 32 bit processes but the one from CreateEnvironmentBlock is 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);

Produces the following output:

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;

So is CreateEnvironmentBlock just broken on wow64? Also, the system environment seems to be defined in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

How come there’s no wow64 equivalent of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:49:08+00:00Added an answer on June 3, 2026 at 7:49 am

    This is a bug with CreateEnvironmentBlock(), MS are aware of the issue and have promised to fix it in some unspecified future release.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try create method for get the connection string value but without value for
I try to create a very simple app using windows API. I've done some
I try to create unit test cases to check my table values are correct
when I try to create a virtualenv that uses python2.5 I get the following
I am try to get the android environment setup for phone gap and I
I why can't I return the image I get from the url from within
I want to try create something like Zend's Server Pagecache. What I want to
I try to create a new file inside a JSP and try to save
I try to create a thread in QT, can declare, create and start it,
I try to create 2 buttons inside my app case WM_CREATE:{ hWnd =CreateWindowEx(NULL, LBUTTON,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.