473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to convert inline assembler to .asm file

Hi all,

I'm having a problem converting an inline assembler function to .asm file. I need seperate inline assembler code because in x64 architecture doesn't have support for inline assembly. Here is the code(and attached as a txt file IsVM.txt at the bottom),

#include <windows.h>
#include <string>
#include <iostream>
#include <tlhelp32.h>

using namespace std;


int filter(int code)
{
if (code == EXCEPTION_PRIV_INSTRUCTION)
{
return EXCEPTION_EXECUTE_HANDLER;
}
else
{
return EXCEPTION_CONTINUE_SEARCH;
}
}

bool IsInsideVMWare(void)
{
bool rc = true;

__try
{
__asm
{
push edx
push ecx
push ebx

mov eax, 'VMXh'
mov ebx, 0 // any value but not the MAGIC VALUE
mov ecx, 10 // get VMWare version
mov edx, 'VX' // port number

in eax, dx // read port
// on return EAX returns the VERSION
cmp ebx, 'VMXh' // is it a reply from VMWare?
setz [rc] // set return value

pop ebx
pop ecx
pop edx
}
}
__except(filter(GetExceptionCode()))
{
rc = false;
}

return rc;
}

int main()
{
if(IsInsideVMWare())
cout << "You are in a VMware.." << endl;
else
cout << "You are in a native system.."<< endl;
system("PAUSE");
return 0;
}
Any idea how to convert and link to my cpp file? Thanks from now.

T H K
Attached Files
File Type: txt IsVM.txt (649 Bytes, 405 views)
Jul 30 '10 #1
1 3529
weaknessforcats
9,208 Expert Mod 8TB
Can you not have IsInsideVMWare() in its own file an link to it by using a function prototype in the C++ file?

You just need the asm as a file in the project or you could pre-compile into a library that you add as a project linker dependency. You would still use the function prototype in the C++ code.
Jul 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: gnv | last post by:
Hi all, I am writing a cross-browser(i.e. 6 and netscape 7.1) javascript program to save an XML file to local file system. I have an xml string like below: var xmlStr = "<?xml version="1.0"...
1
by: joe | last post by:
Hello, I have some code written in C that I want to transfer over to JScript so I can run within my project to "burn" my DSP code into EEPROM(Non-volatile RAM). I want to generate an .ldr file (a...
10
by: Padmaja | last post by:
Hello I want to convert a huge delimited text file (of appr 85MB) directly into XML. I dont want to loop through the text file and write as xml, as it is very large file and taking much time. ...
1
by: cmonsta | last post by:
Is there any way in vs.net to convert the million or so inline styles to an external stylesheet? I know to use flow vs. grid control before coding my pages but I'm wondering about converting older...
0
by: futurefrontiers | last post by:
I have about 300 .mak files that I would like to convert to VC7 .vcproj files. I know I can do this inside Visual Studio IDE. But I'd like to avoid the painstaking process of opening each file in...
12
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page,...
7
by: jamihuq | last post by:
Hello, I would like to convert the following inline function to a macro. Can someone help? Thx Jami inline char * fromDESC(const char * &aDesC)
1
by: Johanna Pfalz | last post by:
Is there a module/method in python to convert a file from .DBF format to ..CSV format? Johanna Pfalz
1
by: derik | last post by:
can any1 help me in converting a log file into XML file in vb.net.. a log file has 1000 numbers of lines which sld be converted into a xml file ..this convertion is done to feed the file in to...
0
by: bsurineni | last post by:
Hey All, I am stuck up in converting a flat file with | as a delimiter, to a table in MySQL! I am kinda newbie to MySQL, could anyone please help me out? Thanks, Bob S
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.