Should I use windbg_x86 for debugging 32bit applications in 64bit windows? - debugging

I use windows 7 x64 with intel cpu. which windbg works fine and should I use for debugging x86 apps ?
and another similar question, I install windows XP x86 as vmware guest for kernel debugging.My host is x64 windows 7.which windbg should I use?, windbg x86 or x64 for kernel debugging ?

I don't want to say RTFM, but in this case that's where the answer is.
This is an extract from WinDbg help:
Host computer running a 32-bit version of Windows
If your host computer is running a 32-bit version of Windows, use the 32-bit debugging tools. (This situation applies to both x86-based and x64-based targets.)
x64-based host computer running a 64-bit version of Windows
If your host computer uses an x64-based processor and is running a 64-bit version of Windows, the following rules apply:
If you are analyzing a dump file, you can use either the 32-bit debugging tools or the 64-bit debugging tools. (It is not important whether the dump file is a user-mode dump file or a kernel-mode dump file, and it is not important whether the dump file was made on an x86-based or an x64-based platform.)
If you are performing live kernel-mode debugging, you can use either the 32-bit debugging tools or the x64 debugging tools. (This situation applies to both x86-based and x64-based targets.)
If you are debugging live user-mode code that is running on the same computer as the debugger, use the 64-bit tools for debugging 64-bit code and 32-bit code running on WOW64. To set the debugger for 32-bit or 64-bit mode, use the .effmach command.
If you are debugging live 32-bit user-mode code that is running on a separate target computer, use the 32-bit debugging tools.

It is usually best to match the debugger to the architecture of the application being debugged (sometimes even required). For debugging 32-bit applications, even on a 64-bit windows OS I would suggest the x86 version of WinDbg. I would use the x64 version of WinDbg only if I wanted to debug part of the WOW64 part of the 32-bit application, which shouldn't happen often.

Related

Detect OS x86 or x64, when compiled as x86

I developed bootstrap software to start my game. I did this with Go. It was especially important for me to be cross-platform. Also, I didn't want to divide the download links into two as x86 / x64. I wanted to handle everything in one output. That's why I had to compile to x86. When I do this, I cannot properly detect that the operating system is x86 or x64.
In a software compiled as x86, how can i properly detect operating system x86 or x64 (in Go).
This code is not correct when compiled as x86.
const is64Bit = uint64(^uintptr(0)) == ^uint64(0)
On Windows you can call IsWow64Process to determine whether you are a 32-bit process running on a 64-bit OS. Note that it returns false if you are a 64-bit process running on a 64-bit OS, but if you have a 64-bit process running, then you know the OS is 64-bit or it wouldn't run.
Also note that 32-bit Windows is considered obsolete. Microsoft is already phasing out support for 32-bit Windows - they no longer want it to be installed on new computers.
On Linux you can call uname and look at the machine field. Here's a list of possible values. Note that most of them won't be compatible with your program, only i386, i686 and x86_64.

How to run a 32-bit vb.net program in a 64-bit Windows 7?

I have Visual Studio 2010 in a 32-bit Windows 7. I need to compile my created vb.net program (lets call it myprogram.exe) to be able to run in a 64-bit Windows 7 environment.
I have set my VS2010 project to "Any CPU" and even so myprogram.exe doesn't run on a 64-bit Windows 7. However, it does on a 32-bit Windows 7.
Could be possible it's because I'm using System.Data.OracleClient for database connection?
Error message in 64-bit Windows 7:
"The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher"
The 64-bit Windows 7 has Framework v2 installed. I attach some picture to show that.
Supposedly, WOW64 should run automatically but will not work on all applications.
In this case, should I install on my 64-bit Windows 7 some "Windows virtual PC"?
EDIT:
My VS2010 Premium is in a 32-bit Windows7 environment, and only see "Any CPU" option available. I don't see any other one else.
Should I install in the 64-bit Windows7 PC some "32-bit virtual Windows7 "? Which one would you recommend?
If you compile your program with the target platform set to AnyCPU then, when you run you executable on a 64bit OS the JIT compiler emits code for 64bit systems and, on 32bit OS, code for 32bit systems.
From your error it is clear that something between your references is a 32bit only library and thus cannot be called from 64bit code.
You could switch back to 32bit setting the x86 target platform in your Build Configuration or try to identify the library responsible and check if a 64bit version exists.
However, if you don't have specific reasons to use AnyCPU then you could still use x86 because in some cases the performances are better than 64bit code
You could read about the PROS and CONS of AnyCPU in this a little old, but still valuable, article
Try instead setting it from "Any CPU" to "x86" to force it to run on the 32-bit architecture. The problem might be that your program is relying on DLLs that aren't supported on the 64-bit architecture.

Compilation on 64-bit system for 32 bit system - compatibility

i have a 64-bit machine with 64-bit OS...
how can i compile programs with Visual Studio 2010 so that they work on 32-bit system
if i install 32-bit OS on my 64-bit machine than i thinks it won't be a problem
If you are talking about .NET applications simply verify that you are targeting x86 in the properties of your project (this is the default setting) or Any CPU:
This is a nice property of just-in-time compiled code. It runs just as well on a 32-bit machine (using the x86 jitter) as a 64-bit machine (x64 jitter). The only time you get in trouble is when you need to use legacy unmanaged code that's only available as 32-bit machine code. Not uncommon with old dbase providers (like Jet) and COM servers. You've got the right kind of machine to detect these problems early.
Emphasizing: you don't have a problem if the target machine is 32-bit, only if it is a 64-bit machine.

Why do some programs compiled for x86 do not run under x64, while some do

I have seen that some programs which were written by me and assembled for x86 using ml.exe run fine on my Win 7 x64. I believe this is because of Wow technology.
However, there are some programs (not written by me) which don't run. They give the error that:
The version of this file is not compatible with the version of Windows you're running. Check you computer system infromation to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher
Is there any way I can modify the EXE of these programs to make it run on Win 7 x64. What is the fundamental difference in these programs which make it different from other programs which run transparently.
They're actually 8- or 16-bit programs. Windows x64 runs in Long Mode, which does not support Virtual 8086 Mode, required for such programs. There is no way to make them work short of recompiling them from source or running them in a virtual machine.
One reason can be combination of .NET and native libraries. .NET libraries are compiled in runtime as x64 (if you don't specify explicitly x86) and native libraries run in x86 mode. it cannot run togehther.
Another reason is access to registry. Depending on used API, x86app in wow64 mode can be forwarded to another part of registry. If the registry access API is inconsistent, it can make a problem.

Windows Server 2008 Hyper-V on x86 processor

I notice there are two version of Windows Server 2008 w/ Hyper-V available for download on the MSDN Subscription License site:
Windows Server 2008 Datacenter, Enterprise and Standard (x64)
Windows Server 2008 Datacenter, Enterprise and Standard (x86)
I want to set up a development server for testing/developing using the Hyper-V software. According to the pre-requisites, you can only run Hyper-V on x64 based processor. Can a run Hyper-V on a x86 based processer? If not, why do Microsoft offer a x86 and x64 download?
This is a follow up to this question
Update:
The MSDN subscription site also offers a download for Windows Server 2008 Datacenter, Enterprise and Standard without Hyper-V (x64 and x86). Why don't they just offer one download for x86 version on Windows Server 2008, it is just confusing trying to determine the correct installion ISO....
Hyper-V only is supported for x64 CPU. In addition to it 64 bit CPU should support Intel or AMD virtualization hardware. Guest OS can be 32 or 64 bit. There is simple application SecurAble http://www.grc.com/securable.htm that you can use to test you hardware without actually installing Windows 2008/Hyper-V. In many cases you should enable hardware virtualization in BIOS.
There are several problems with Hyper-V. One of the most annoying is luck of USB support in guest OS.
Other than that it’s a very good tool.
x86 Does Not require 64-bit hardware. It exists to allow installation of Windows Server 2008 on legacy x86 hardware.
Legacy x86 hardware in my experiences has often times not had Hardware Virtualization support, and these flavors of Windows work great in this case.
You should only install the 32-bit version if you have applications that absolutely will not run in 64-bit and you cannot host those applications in a Hyper-V 32-bit guest OS or you have hardware that you must run that does not provide a 64-bit driver. For all other cases, you get substantial advantages running the 64-bit version of the os. (Both versions require 64-bit hardware, but the x86 version of the OS is still 32-bit -- like running any other 32-bit app. on a 64-bit machine, except this app. happens to be your OS).

Resources