Help: Can I migrate assembly language code to x64 via VC++.NET 200

G

Guest

Hi,
Can anyone tell me if it is possible to make the following function work
under VC++.NET 2005 – x64 platform? How? Originally it works under VC++6.
Thanks a lot!

static PTIB GetTIB ( void )
{
PTIB pTib ;
__asm
{
MOV EAX , FS:[18h]
MOV pTib , EAX
}
return ( pTib ) ;
}
 
G

Guest

static PTIB GetTIB ( void )
{
return (PTIB)__readfsqword( ??? );
}

Whatever is the PTIB offset in x64...

--PA
 
B

Bruno van Dooren [MVP VC++]

Can anyone tell me if it is possible to make the following function work
under VC++.NET 2005 - x64 platform? How? Originally it works under VC++6.
Thanks a lot!

static PTIB GetTIB ( void )
{
PTIB pTib ;
__asm
{
MOV EAX , FS:[18h]
MOV pTib , EAX
}
return ( pTib ) ;
}

To add to Pavel's answer, it is always a good idea to post asm questions in
the masm group.
The people who hang out there are assembly language experts.
Some C++ people know assembly as well of course.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
W

Willy Denoyette [MVP]

NotCpiP said:
Thanks a lot! You guys are great!


Well, the answer of Ben won't help you, this "GetCurrentTeb" function no longer exists on
X64, after all it's an undocumented function, so IMO not better than roll your own.
Another point is that inline asm is not available in VC++ 64 bit mode, you need to implement
such functions in standalone asm.
Not sure why you need to get at the TEB, but if you need to access the TLS, you'll have to
call TlsGetValue (see winintrl.h).

Willy.
 
W

Willy Denoyette [MVP]

Willy Denoyette said:
Well, the answer of Ben won't help you, this "GetCurrentTeb" function no longer exists on
X64, after all it's an undocumented function, so IMO not better than roll your own.
Another point is that inline asm is not available in VC++ 64 bit mode, you need to
implement such functions in standalone asm.
Not sure why you need to get at the TEB, but if you need to access the TLS, you'll have to
call TlsGetValue (see winintrl.h).

Correction, I just noticed that NtCurrentTeb is currently declared in winnt.h for both 32
and 64 bit (both AMD and IA64).
For AMD and Win64, this function boils down to a call to __readgsqword.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top