Home » Visual Studio

RedirectStandardInput "A 32 bit processes cannot access modules of a 64 bit process."

Hi again,

After being able to resize and move around the console application I'm trying to tackle the redirect input.


I used the example given in this url:


and it worked great UNTIL I changed the "sort.exe" to be "cmd.exe" or a batch file.


Once I changed the process to start the "cmd.exe" or a very basic batch file (that only does "echo" and "set /p") I wasn't able to start the process anymore.


I went into debugging mode and I noticed that the process exits immediately after it "starts" (if it starts at all).


I dug a little dipper and I noticed that the process MainModule had this exception:

base {System.Runtime.InteropServices.ExternalException} = {"A 32 bit processes cannot access modules of a 64 bit process."}


I'm using Windows 7 Ultimate x64 and visual studio 2010.

I tried compiling the project with every combination of "platform" and "Active platform" (x64, x86, anyPCU for each) and all it got me is that when I used x64 in the "platform" (regardless of the active platform) I got the following exception instead:

base {System.Runtime.InteropServices.ExternalException} = {"Only part of a ReadProcessMemory or WriteProcessMemory request was completed"}


Google wasn't very helpful with either of those exceptions and only led me to a microsoft KB stating they have hotfix for windows visa  (but not for windows 7).


Needless to say that when I use the same code while "process.startinfo.redirectstandardinput = false" it starts the batch file and the "cmd.exe" just fine (without redirecting the input of course).


My question is, how can I redirect the input to a process that starts the "cmd.exe" or a batch file?


Thanks in advance,



I always try to help ;) sometimes I don't know how :(

4 Answers Found


Answer 1

Nobody seems to know the answer so allow me to post a bit  more info:

I have the following code:


Process myProcess = new

myProcess.StartInfo.FileName = @"cmd.exe"

myProcess.StartInfo.UseShellExecute = false

myProcess.StartInfo.RedirectStandardInput = true



I use the same code in both console  application and in windows  form application.

In both cases I have a breakpoint on the "myProcess.Start();" line and I step over it with F10.

In the console application  I have "myProcess.HasExited == false" (which is good) while in the windows application I have it as "myProcess.HasExited == true" (which is bad).

(Please note that if you don't use a breakpoint they both register as "myProcess.HasExited == false" and adding "Thread.Sleep(50);" right after it starts  reproduces the above behavior without a breakpoint).


When in my windows form application I tried both compiling to 32 bit and 64 bit application and I got the problems mentioned above:

When compiling to 64 bit (or AnyCPU) application the "myProcess.MainModule" exits  with exception: {"Only part of a ReadProcessMemory or WriteProcessMemory request was completed"}

When compiling to 32 bit application the "myProcess.MainModule" exits with exception: {"A 32 bit processes  cannot access  modules of a 64 bit process."}


I need to start  a process  of console application (batch file  or cmd.exe mostly but it can be anything the user chooses) from within my windows form application and send strings to it so it'll work like the user typed them in manually.


I would appreciate any and all help you can offer me on this.


Like I said before, I'm using visual  Studio 2010 on Windows 7 x64 ultimate  and my application needs to run on both Windows 7 x64  Ultimate and Windows Server 2008 R2 Enterprise.


Thanks in advance,


I always try to help ;) sometimes I don't know how :(


Answer 2

Can this be a .NET framework bug?

Answer 3

Considering this thread is the first hit in google I'm going to add all the info I have here just in case someone will be able to use it in the future.


In the .Net framework forum post: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4ce40b19-c442-4412-94b2-1ed24bdb9386

Jesse Houwingprovided a working code that redirects both input  and output.


Considering I don't want to redirect  the output and I want it to remain in the console  application window that solution doesn't help me much but it might help others.


It appears that the problem is reproduced only when you attempt to redirect the input alone.

When you combine the input with the output it all works fine.


If anyone has any idea on how to redirect the input ONLY I would love to hear it.


Answer 4

Hi daat99,

I replied you at here.


Hi All,

I am having an Application build on Win32 Platform. This application enumerates available processes on the local machine. This application works fine on Win32 however it does not work on 64 bit.  It retrieves 32bit process names and fails to get 64bit process names. I read few questions on forums and they say that we cannot access 64bit processes from a 32bit application. However there are few methods such as EnumProcessModulesEx which can access both 32 and 64 processes. This method is available only on Vista 64.
Is there any corresponding API which I can use it on Win2k3 x64 ? or anyother way we can access process names both 32 and 64bit on Win 2k3 x64 computer.
Any help!!!



I've seen many post close to this question but none that actually address the problem I'm having.

I have an IE extension which works perfectly well with several version of IE on several different OS versions.  That is, the 32bit version of the extension works with the 32bit version IE7 and IE8 on the 32bit version of the Windows - (XP, Vista, and 7).  The 64bit version of the extension works with the 64bit version of IE8 on Windows-7 (haven't tested on Vista... but figure it would work the same).

But I have a specific issue with the extension to the 32 bit version of Internet Explorer running under Windows-7 64 bit OS.

If I understand how Wow64 works on the 64 bit OS:

My 32bit extension would go in a folder: \program files (x86)\<Name>

I would then create the following registry entires:

HKLM\Software\Classes\Wow6432Node\CLSID\{My32bitGUID} with subkeys (1) InprocServer32 pointing to my DLL in \progarm files (x86)\<Name> with string ThreadingModel="Apartment" and (2) Implemented Categories with subkey {00021493-0000-0000-C000-000000000046} (for a vertical extension bar)

HKLM\Software\Wow6432Node\Microsoft\Internet Explorer\Extensions\{My32bitButtonGUID} with strings: BandCLSID={My32bitGUID}, CLSID={E0DD6CAB-2D10-11D2-8F1A-0000F87ABD16}, ButtonText, Default Visible, and Icon

Other than the Wow6432Node in the registry keys this is basically the same (but with different GUIDs) as what I use for the 64bit extension in the 64bit Internet Explorer.

When I do this, the custom tool button appears in the 32bit IE8 window as normal - but when I click the button IE8 does not access my extension in anyway that I can tell.  No window is created and as best I can tell none of the window creation routines are called.

It seems I'm missing something trival and simple... but I can't seem to find any reference that points me in the right direction.  I've read everything I could find in the extensions guides.

Any help/input appreciated.


We have a 64 bit service that we are using to do some processing outside of the web app. Its built with the AnyCPU flag, so I am assuming it should always run as a 64 bit process on any 64 bit OS.  It needs to access 64 bit IFilter dll's so we can parse text in a bunch of docx/pptx files.  What I've found though is that it will run as a 32 bit process on some versions of Win7 and also Windows Server 2003.  The other Win7 machine is basically the same laptop, so it should run exactly the same.  When it runs as a 32 bit, its accessing the SysWow64 dll's which don't do what we need it to do.  When I run it on XP x86, its a 32 bit process as expected and works fine.  Any idea's on what might be the cause?
I am trying to access few files from C:\Windows\System32\Winevt on Windows 7 - 64 bit machine through .net application.

When I build my application in 32 bit , I am not able to access this Winevt directory. It complians about directory not found.
But If I build my application in 64 bit mode, I am able to access this directory without any problem.

Do I have to do anything special to access this directory using 32 bit application on 64 bit machine?


Hi Guys,

I'm new here and also new to SQL server although I've had dealings with it in the past.

"Invalid object name tablename. Statement(s) could not be prepared.

My s/w ran with access data sets and I need to get it to operate using SQL Server. So I ran the upgrade wizard and it seemed to successfully upgrade the databases. I can run a query with SQL management studio and see the tables and even the data in the tables, but i get the error abpve when I run my s/w.

The software is built as a 32-bit development and it uses ODBC. The SQL server is 2008 development R2. This runs on an Athlon 64-bit processor. I use ODBC and CRecordset for historical reasons. I first encountered a problem opening the database, so I ran the WOW64 version of ODBC manager to link the driver and database together. I can now open the database, but get the error above when i try to open any table, I'm using Windows NT authentication and the driver I selected is SQL Server Native Client 10.0.

I'm not sure about any other information I would need to supply.

Wondering if there is an issue with 64-bit interfaces, or maybe even Uncode,?

Any suggestions would be appreciated.



Is there any additional setup require if I need to remote access to my 64 bit sql server 2008 express from my 32bit vista sql management studio? Or could it be because 1433 port was blocked by firewall in the server?

I tried to login by "<ip>/sqlexpress" in the server which host the sql server and it was success, but if I remote access through my laptop 32bit management studio with "<ip>/sqlexpress" , network error return said <ip>/sqlexpress could not be find.

I also tried to ping the <ip> through my laptop but failed, but ping from server it works.




Ok - have been round the bit on this one.  First off:  I am aware of the different ODBCAD32.exe files in the different directories and have used both to successfully create and test DSN's.  My issue is once I get inside Access 2010 and try to establish the link.

Step 1 - I use the WOW64 (32 bit version) directory odbcad32.exe to create a pervasive 8.1 DSN to my database.  Tests correctly, works fine - but I can only see user dsn's from both 32 and 64.

Step 2 - go into Access 2010, attempt to connect to the DSN by linking a table to the machine data soruce.  The DSN - ambiguously named THISDNS_32 - when selected yields the error

ODBC --call failed [Microsoft][ODBC Driver Manager] The specified DNS contains an architecture mismatch between the Driver and the Application. 

I hit OK thinking I will just re-set up a new DSN using Access instead.

I go to create the new MACHINE data source and it yields

You are logged on with non-Administrative priveleges.  System dSN's could not be created or modified. 

Questions:  1.) My account is part of the Administrators group; however it is a domain account in the administrators group at the local machine level.  Thoughts on why it would say I am not logged in as an Administrator?

Clicking Ok and attempting to set up a USER DSN does not show the 32 bit Pervasive Client as I believe we are now using the Access-called 64 bit version of ODBCAD32.exe.


Any assistance would be greatly appreciated.


I have an installer executable which is 32-bit that creates and invokes methods within a .NET assembly. This .NET assembly is targetted for 32-bit platform. Also, specifically it has a dependency on the .NET System.Data.dll. The problem is that when the System.Data.dll is loading during the run of my installer executable, the .NET CLR loads the 64-bit version of mscoree.dll, which I believe is a dependency for the System.Data.dll assembly. Obviously this causes a BadImageFormatException in my executable. My question now is that "How do I force the assembly loader in the CLR to load only 32-bit dependencies for the installer executable?"  

Need to enumerate process modules for 64-bit process from 32-bit process context.

But GetModuleBaseName fails for 64-bit process, if called from 32-bit process. Both GetWindowModuleFileName and CreateToolhelp32Snapshot fails in the same condition also.

Don't want to create 64-bit stub to succeed. Process Explorer from Sysinternals performs this task perfectly. Any assistance is welcome.




I have a dump created from the task manager in Vista 64-bit, i am trying to debug it in Windows 7 64-bit. The application that was dumped is a 32-bit .Net process. I cannot repeat the dump process as we cannot reproduce the issue (application hang on shutdown) which we need to debug.

I have tried using both the 32-bit and 64-bit version of WinDbg with little luck. I have also tried following the instructions from http://blogs.msdn.com/b/joaol/archive/2008/09/03/how-to-use-windbg-to-debug-a-dump-of-a-32bit-net-app-running-on-a-x64-machine.aspx.

Here is what has gotten me closest so far:

1. Start WinDbg x86
2. .load C:\Windows\Microsoft.NET\Framework\v4.0.30319\SOS.dll
3. .load wow64exts
4. .sympath srv*c:\symbolspub*http://msdl.microsoft.com/downloads/symbols (the sympath used in the above link)
5. !sw (switch to 32-bit mode)
6. !clrstack

No matter which thread is active i get the following error:

Failed to start stack walk: 80070057

According to this it simply means that the thread isnt running any .net code. Is this true, or could there be other causes of this error? (im getting alot of warnings about symbol timestamps  from alot of Windows dlls and some CLR dlls).

Hope someone can help me out :)





Is there a way to determine whether a PID belongs to a 32-bit or 64-bit process?  I've checked the msdn forums and I have had no luck figuring out how! :( 
I need help on how to fix this problem.  When I try to print I receive, Thunking Spooler APIS from 32 to 64 process has stopped working.  Iv'e tryed a hotpatch, and have search for answers most of the day.  Please Help


I just want to know how smart card works in windows ,

ie I have an application in .Net and it uses winscard.dll to access smart card, now for this ScardSvr.exe needs to be running

My question the smart card drivers are loaded into which process is it in inside ScardSvr.exe? or inside my application process

Why I am asking is If my Application needs to run in both 32 and 64 bit machines(and My application need to run as 32 bit in 64 bit machine inside wow64 ) , if the 64 bit drivers are available (it seems that only 64 bit drivers work in 64 bit machine for the smart card we r using)

and can my application which is 32 bit can use smart card , ie the drivers are not loaded in my application process right?






Hi I am new to 64 bit OS. Till now i Develop everything on 32 bit.
I had not made any program as 32 bit. I just open the VS2008 IDE and there I select new project as Web Service Application .  In webservice application I refer SharePoint Dll.

I write one webmethod called HelloWorld() in which i just write one line code on for SharePoint
SPWeb obj = Site.OpenWeb();

but as soon as i try to run it thorws an exception

Attempted to load a 64-bit assembly on a 32-bit platform. Use ReflectionOnlyLoad() instead if trying to load for reflection purposes

can any one pls help me...




We have an application containing several unmanaged DLLs that has been built in a 32-bit environment. I recently added a .NET remoting module (packaged in a DLL which I cleverly called Remote.dll) to allow our customers to develop applications that can connect to and control our application. As part of our delivery, I created a sample C# .NET application. All of this works fine on 32-bit machines.

Our main application works just fine on Vista 64 and Windows 7. However, I tried to get my sample .NET remoting application to work on Vista 64 and it crashes. So I transferred my sample application code to the 64-bit machine and built it. When running in the debugger, I get

"An unhandled exception of type 'System.BadImageFormatException' occurred in MySampleApp.exe"

"Additional information: Could not load file or assembly 'Remote, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format"

I had been building the sample application with the Platform Target as Any CPU. If I change this to x86, I get the following error when I try to run:

"An unhandled exception of type 'System.IO.FileNotFoundException' occurred in MySampleApp.exe"

"Additional information: The specified module could not be found. (Exception from HRESULT:0x8007007E)"

I have tried moving the main application to the 64-bit machine and building. The main application runs fine, but the sample application still crashes.

I even changed the output location of my sample application to be in the folder where the main application resides, just in case there was a dependency on the main application that I wasn't aware of. Still no go.

Also, in the development environment (VS2008), after adding a reference to my .NET remoting DLL, I can browse it just fine. So this doesn't seem to me to be a build-time problem.

But what do I know? I'm the one who can't get the stupid thing to work!

Thanks for any help!





We are devloping a server application in .Net the production environment is 64 bit. the developers are working in the 32 bit Os versions .

My question is if we compile the solution by targeting any CPU will it be able to access more memory provided by 64 bit environment when it is deployed in a 64 bit environment? since 32 bit os has 4 GB memory limitation for processes , and  even in 64 bit environment the code might be running in a 32 bit simulated envirnment right? or we need to build the code specifically targeting 64 bit environment  so that the process has aceess to more memory , we need a lot of RAM

Cheers ,


In our setup application we make a call to pkgmgr in order to install IIS7.
As our application is 32-bit it will launch the 32-bit version of pkgmgr (Windows 7, 64-bit).
However, when launching the pkgmgr tool a misleading message box error shows up:

"Operation failed with 0x8007000B"
"A attempt was made to load a program with an incorrect format."

The command used: pkgmgr /norestart /iu:IIS-WebServerRole /l:c:\output.txt

If launching the 'native' 64-bit version of pkgmgr with the same command line then the execution succeeds.
In the log file we see that the call is translated into a call to dism.exe:
dism.exe /online /norestart /logpath:"c:\output.txt.txt" /enable-feature /ignorecheck /featurename:"IIS-WebServerRole"

The reason why it failed is now clear:
"You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture."

Shouldn't the 32-bit version of pkgmgr.exe 'redirect' the call to the 64-bit version of pkgmgr/dism, since all Windows packages are native 64-bit?  How can I get around this?
I'm trying to get a COM elevation moniker working and am now stuck on three different paths. On all three paths my goal is to access a COM object from WScript, using something like Set myObj = GetObject("Elevation:Administrator!new:MyApp.MyClass"); I know that my moniker syntax is correct because I can get another object instantiated that I found in the registry using this from my vbs script (which I used just to see if GetObject would work with the moniker.)

1. I started with an in-proc COM server that I set up with LocalizedString, Elevation/Enabled=1, and DllSurrogate for the AppID in the registry. This was a brand-new COM object built with ATL from Visual Studio 2008. I just created an ATL Simple Object with the wizard. I hand-edited the registry to set it up. I could not get this to work. I keep getting 80080017 CO_E_ELEVATION_DISABLED.

2. I tried a LocalServer EXE, again, brand-new in Visual Studio's ATL wizard, with a new ATL Simple Object. I set up the registry by hand, and worked out the bugs until I finally got a COM elevation moniker to work. Only, this is on 32-bit Vista, and when I move the EXE to 64-bit Server 2008, it no longer works. I get 800C000D from GetObject in the vbs script, where on Vista 32-bit the same call works.

3. Even though the vbs script on Vista instantiates the COM object, I can't actually use it, because although it is elevated, I seem to drop the security token. This COM object is in turn creating an instance of a COM object which runs in a Windows service. That COM object checks the thread token of the incoming request to see if it has admin privileges (specifically, if it has SERVICE_CHANGE_CONFIG). The vbs script calls the elevated COM object, which calls the COM object living in the service, and by the time it gets into the service, the thread token no longer has admin privileges, because I do *not* see SERVICE_CHANGE_CONFIG (after impersonate client, open thread token TOKEN_QUERY).

What I am trying to do is get the UAC prompt to come up when I access the service automation interface (for configuration). I cannot, as I understand it, use the COM elevation moniker on the COM class in the Windows service (and I tried, and it didn't work either). So, what I am trying now is either an in-proc (with DllSurrogate) or out-of-proc EXE COM server which I can instantiate with the COM elevation moniker, to get the UAC prompt and the admin security token, which then itself would call the COM interface in the service.

I would rather not just launch my vbscript with RunAs (although this does work directly, in that I can connect directly to the service COM object, which sees SERVICE_CHANGE_CONFIG, without using an intermediary COM object). I would rather have the UAC dialog come up automatically when the user accesses the configuration automation interface.

Can you help with the error code 800C000D on Windows Server 2008 64-bit, and also tell me why I seem to lose the security token on the path into the service COM object?

I don't care to follow-up on the in-proc COM server (DLL) to front the service COM object, unless DllSurrogate has some advantages over an out-of-proc EXE server.

To summarize:

vbscript GetObject(COM elevation moniker: COM-object-A) --> LocalServer COM-object-A elevated --> Windows service COM object wanting to see admin privileges on the incoming thread token.

On Vista, this path is complete, but the Windows service does NOT see admin privileges, despite the acceptance of the UAC prompt during elevation of the moniker.

On Server 2008, the first arrow is broken -- I get HRESULT 800C000D on the GetObject script call.

Jim Flood


I've figured out most of the above, but I am still stuck on Server 2008 64-bit, unable to get the COM elevation moniker to work. I get 80080015 CO_E_MISSING_DISPLAYNAME, despite having LocalizedString in the registry for the CLSID. If I could get help with just this one issue, I would appreciate it greatly.

I am posting my progress on the other problems listed above in a reply below. (I am interested in why my in-proc DLL does not work, but I don't need that solved -- an EXE server is fine. It's not due to lack of _MERGE_PROXYSTUB in the build of the DLL, for what that's worth.)
I have a Windows 32 console appl that makes a system() call to invoke the 'lpr' client as follows:
 system("lpr -S<addr> -P<printer> <file>");
When done on Windows 32 all is good.
When done on Windows 64 the call fails with
    'lpr' is not recognized as an internal or external command.
At a DOS prompt, lpr works ok.
What does it take to get the 'lpr' command to be recognized from a system() call under Windows 64?



aftern installing Office 2010 RTM 64 bit we get from different 16 Bit Applications like acrobat standard

this message

Microsoft Office Outlook
Either there is no default mail client or the current mail client cannot fulfill the messaging request.  Please run Microsoft Outlook and set it as the default mail client.

Outlook is set as default which is also reflected in the corresponding registry keys like HKLM\Software\Clients\Mail and


But both DLLPath entries are pointing to mapi32.dll

It doesn't help to change the entry to olmapi32.dll which comes with Office 2010.

Who can provide help?





<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure