473,503 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 ) ;
}

Jan 25 '07 #1
6 3005
static PTIB GetTIB ( void )
{
return (PTIB)__readfsqword( ??? );
}

Whatever is the PTIB offset in x64...

--PA

"NotCpiP" wrote:
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 ) ;
}
Jan 26 '07 #2
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
br**********************@hotmail.com
Remove only "_nos_pam"
Jan 26 '07 #3
static PTIB GetTIB ( void )
{
PTIB pTib ;
__asm
{
MOV EAX , FS:[18h]
MOV pTib , EAX
}
return ( pTib ) ;
}
Much better to use Windows' built-in function than roll your own. Get the
TEB, which contains a pointer to the TIB.

http://undocumented.ntinternals.net/...urrentTeb.html
Jan 26 '07 #4

Thanks a lot! You guys are great!
Jan 26 '07 #5
"NotCpiP" <No*****@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
>
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.
Jan 26 '07 #6
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
"NotCpiP" <No*****@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
>>
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).
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.

Jan 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2338
by: Marian | last post by:
Hi, I am totaly novice in .NET and I am studying a book about this. There was mentioned "assembly". I did not understand, how function does it has . I would like to know the exact run of code...
3
1659
by: Nick | last post by:
Hi, I am a Windows VC++.net newbie, and do not have much experience on standard C++. Right now, there is a VC++ code which needs to be ported onto Linux for some reason. The code is mainly for...
8
5411
by: | last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems with the 2003 version, hoping this solves the problems, but now I encounter this wierd bug??? If I have the project, and...
1
1424
by: Edward Mitchell | last post by:
How can I get to see the assembly language listing for the C++ code that is displayed in the debugger. I seems like the VS 6.0 had a tool button that would show the assembly language interspersed...
13
4097
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
6
44471
by: Steve | last post by:
I'm playing with late binding and trying a very simple test to load an assembly In my "Host" application I have this code: <code> string modulePath =...
14
2115
by: John | last post by:
My friend told me that his company will migrate the VC++ win32 applications to C++ .NET windows applications. I don't understand why since currently Microsoft only supports .NET on windows...
85
4746
by: fermineutron | last post by:
Some compilers support __asm{ } statement which allows integration of C and raw assembly code. A while back I asked a question about such syntax and was told that __asm is not a part of a C...
5
1285
by: QbProg | last post by:
Hello, I did some experiments with VC++ 2005, and some ILDasm. Please tell me if I have understood the concepts of C++ programming under .NET, since I'm a bit confused! -- There are 4 types of...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.