From: Scott on
I have broken this down to a very simple 3 line program. When I compile in 32
bit mode it compiles, switching to 64 bit I get the above error.

I am running on a Vista 64/Ultimate using VS2008. For this example I created
a console application:

#include <stdafx.h>

int _tmain(int argc, _TCHAR* argv[])
{
CONTEXT ctx;

DWORD dwEip = ctx.Eip;
return 0;
}
The stdafx looks like:
#pragma once
//#define _AMD64_
//#define _IA64_
#include <stdio.h>
#include <tchar.h>
#include <windows.h>

#include "targetver.h"

I have tried defining either _AMD64_ or _IA64_ with varying results.

If I use _AMD64_, which is appropriate for the computer I am on, I get the
above error.

Defining _IA64_ I get

error C3861: '__readgsqword': identifier not found

This is probably reasonable since I am on multiCore DELL box using an Intel
chip set.

Shouldn't the project just switch when I change my project type from Win32
to X64? What needs to be defined to get this to work correctly?

Looking at WinNT.h it seems that defining _AMD64_ should bring in the
correct version of _CONTEXT but it doesn't.

So how is this supposed to work? I have other programs that I have
converted from WIN32 to X64 without (major) issue.


--
Scott Norberg
From: Scott on
Since I put this out here myself I can call it a stupid question. :-(

So just in case if someone reads this that doesn't know the hardware
architecture is different between win32 and x64 so the names of the registers
are different to accomodate the 64 bit width, I suppose they could have used
the same names, but who knows.

Several good articles on this

http://msdn.microsoft.com/en-us/magazine/cc300794.aspx

Just to get you going.

--
Scott Norberg


"Scott" wrote:

> I have broken this down to a very simple 3 line program. When I compile in 32
> bit mode it compiles, switching to 64 bit I get the above error.
>
> I am running on a Vista 64/Ultimate using VS2008. For this example I created
> a console application:
>
> #include <stdafx.h>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> CONTEXT ctx;
>
> DWORD dwEip = ctx.Eip;
> return 0;
> }
> The stdafx looks like:
> #pragma once
> //#define _AMD64_
> //#define _IA64_
> #include <stdio.h>
> #include <tchar.h>
> #include <windows.h>
>
> #include "targetver.h"
>
> I have tried defining either _AMD64_ or _IA64_ with varying results.
>
> If I use _AMD64_, which is appropriate for the computer I am on, I get the
> above error.
>
> Defining _IA64_ I get
>
> error C3861: '__readgsqword': identifier not found
>
> This is probably reasonable since I am on multiCore DELL box using an Intel
> chip set.
>
> Shouldn't the project just switch when I change my project type from Win32
> to X64? What needs to be defined to get this to work correctly?
>
> Looking at WinNT.h it seems that defining _AMD64_ should bring in the
> correct version of _CONTEXT but it doesn't.
>
> So how is this supposed to work? I have other programs that I have
> converted from WIN32 to X64 without (major) issue.
>
>
> --
> Scott Norberg
From: Tim Roberts on
Scott <snorberg(a)newsgroups.nospam> wrote:
>
>So just in case if someone reads this that doesn't know the hardware
>architecture is different between win32 and x64 so the names of the registers
>are different to accomodate the 64 bit width, I suppose they could have used
>the same names, but who knows.

No, eax, ebx, and the like are still valid register names in x64. They
just happen to refer to the lower 32 bits of the native registers rax, rbx,
etc. It's just like ax being part of eax when we went from 16 to 32.

The CONTEXT structure contains the full registers, hence it uses the full
register names.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.