判断程序的执行环境是VM

How to Install and Configure GitLab on Ubuntu 18.04 LTS GitLab is an open source GIT repository manager based on Rails and developed by GitLab Inc. It is a web-based GIT repository manager that allows your team to work on code, perform feature requests, track bugs, and test and implement applications. GitLab pr 阅读详情
来段老V的代码  很古老的
抗VM分析
  mov    ecx, 0Ah        ; CX=function# (0Ah=get_version)
      mov    eax, 'VMXh'  ; EAX=magic
      mov    dx, 'VX'          ; DX=magic
      in      eax, dx              ; specially processed io cmd
    ; output: EAX/EBX/ECX = data
      cmp    ebx, 'VMXh'  ; also eax/ecx modified (maybe vmw/os ver?)
      je      under_VMware

 

===

bool IsInsideVMWare()
{
  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(EXCEPTION_EXECUTE_HANDLER)
  {
    rc = false;
  }

  return rc;
}


bool IsInsideVPC()
{
  bool rc = false;

  __try
  {
    _asm push ebx
    _asm mov  ebx, 0 // Flag
    _asm mov  eax, 1 // VPC function number

    // call VPC
    _asm __emit 0Fh
    _asm __emit 3Fh
    _asm __emit 07h
    _asm __emit 0Bh

    _asm test ebx, ebx
    _asm setz [rc]
    _asm pop ebx
  }
  // The except block shouldn't get triggered if VPC is running!!
  __except(IsInsideVPC_exceptionFilter(GetExceptionInformation()))
  {
  }

  return rc;
}

==============

给个通用判断的方法,不管VMWare或VirtuaPC都有效

int  DCVM ()
{
  unsigned char m[2+4], rpill[] = "/x0f/x01/x0d/x00/x00/x00/x00/xc3";
  *((unsigned*)&rpill[3]) = (unsigned)m;
  ((void(*)())&rpill)();

  printf ("idt base: %#x/n", *((unsigned*)&m[2]));
  if (m[5]>0xd0) printf ("虚拟机/r/n", m[5]);
  else printf ("真实机器/r/n");
  return 0;
}

#include <stdio.h>

int  LdtCheck()
{
    unsigned char m[2];
    __asm sldt m;  //L,not i
    printf("LDTR: %2.2x %2.2x/n", m[0], m[1]);
    return (m[0] != 0x00 && m[1] != 0x00) ? 1 : 0;
}

int main(int argc, char * argv[])
{

    if (LdtCheck())
        printf("Virtual Machine detected./n");
    else
        printf("Native machine detected./n");
   
    return 0;
}

#include <stdio.h>

inline int idtCheck ()
{
    unsigned char m[2];
    __asm sidt m;
    printf("IDTR: %2.2x %2.2x/n", m[0], m[1]);
    return (m[1]>0xd0) ? 1 : 0;
}

int gdtCheck()
{
    unsigned char m[2];
    __asm sgdt m;
    printf("GDTR: %2.2x %2.2x/n", m[0], m[1]);
    return (m[1]>0xd0) ? 1 : 0;
}

int ldtCheck()
{
    unsigned char m[2];
    __asm sldt m;
    printf("LDTR: %2.2x %2.2x/n", m[0], m[1]);
    return (m[0] != 0x00 && m[1] != 0x00) ? 1 : 0;
}

int main(int argc, char * argv[])
{
    idtCheck();
    gdtCheck();
   
    if (ldtCheck())
        printf("Virtual Machine detected./n");
    else
        printf("Native machine detected./n");
   
    return 0;
}
是能够测出来,但是编译时有下列警告信息,让人不爽。

C:/WINDDK/3790>cl test.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

test.c
test.c(7) : warning C4409: illegal instruction size
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:test.exe
test.obj

*************************************************
' 检测程序是否运行于 VPC 虚拟机中
'
' 返回: 真表示运行在虚拟机中
' ------------------------------------------------
'   以下代码仅仅适用于在非标准模块中
'   这些代码根据BBS中bigwahaha提供的代码实现,本人未
'   进行测试检验, 有环境测试OK的用户请及时反馈
'*************************************************
Private Function IsInsideVPC() As Boolean
'_asm{overall}
'_asm{
'   push    ebp
'   mov     ebp,esp  ;esp,retAdr,this,retVal

'   assume  fs:nothing
'   
push    offset @F
'   
push    fs:[0]
'   
mov     fs:[0],esp

'   push    ebx
'   xor       ebx,ebx
'   dec      ebx         ; 初始 EBX = TRUE (VB)
'   mov     eax, 1      ; VPC function number
'   db      0Fh,3Fh,07h,0Bh
'
'   
;设定返回值
'   mov     eax,[ebp+3*4]
'   
mov     [eax],ebx
'
'   
pop     ebx
'   pop     fs:[0]
'   
add     esp,4
'   
leave
'   xor     eax,eax     ;返回 S_OK
'   ret     2*4
'
'   @@:
'   
mov     edx,dword ptr [esp+0CH]
'   
add     dword ptr ds:[edx+0B8h],4       ; regEip
'   xor      eax,eax
'   mov     dword ptr ds:[edx+0A4h],eax     ; regEbx,eax
'   mov     dword ptr ds:[edx],10007h       ; ContextFlags,CONTEXT_FULL
'   ret     4 * 4
'}
End Function

'*************************************************
' 检测程序是否运行于 VMWare 虚拟机中
'
' 返回: 真表示运行在虚拟机中
' ------------------------------------------------
'   以下代码仅仅适用于在非标准模块中
'   这些代码根据BBS中bigwahaha提供的代码实现,本人未
'   进行测试检验, 有环境测试OK的用户请及时反馈
'*************************************************

Private Function IsInsideVMWare() As Boolean
'_asm{overall}
'_asm{
'   
push    ebp
'   mov     ebp,esp  ;esp,retAdr,this,retVal
'
'   assume  
fs:nothing
'   
push    offset @IsInsideVMWare_error
'   
push    fs:[0]
'   
mov     fs:[0],esp
'
'   
push    ebx
'   mov     eax, 'VMXh'
'   
xor       ebx,ebx  ; any value but not the MAGIC VALUE
'   mov     ecx, 10  ; get VMWare version
'   mov     dx, 'VX' ; port number
'
'   
in        eax, dx  ; read port
'                    ; on return EAX returns the VERSION
'   xor     edx,edx
'   cmp   ebx, 'VMXh' ; is it a reply from VMWare?
'   jnz     @F
'   
dec     edx
'   @@:
'   
;设定返回值
'   mov     eax,[ebp+3*4]
'   
mov     [eax],edx
'
'   
pop     ebx
'   pop     fs:[0]
'   
add     esp,4
'   
leave
'   xor     eax,eax     ;返回 S_OK
'   ret     2*4
'
'   @IsInsideVMWare_error:
'   
mov     edx,dword ptr [esp+0CH]
'   
inc       dword ptr ds:[edx+0B8h]         ; regEip
'   xor       eax,eax
'   mov     dword ptr ds:[edx],10007h       ; ContextFlags,CONTEXT_FULL
'   ret     4 * 4
'}
End Function

 


 

ENVI5.6 批量处理GF-2/GF-6/GF-7:从安装到融合的完整自动化流程 本文详细介绍了ENVI5.6环境下批量处理GF-2/GF-6/GF-7卫星数据的完整自动化流程,包括环境配置、工具安装、正射校正、图像融合等关键步骤。通过实战案例和优化技巧,帮助用户高效完成高分卫星影像处理,提升工作效率。特别针对GF-6和GF-7的特殊处理要点进行了深入解析。 阅读详情

相关推荐

深入解析STM32定时器中央对齐模式3的双中断机制

本文深入解析了STM32定时器中央对齐模式3的双中断机制。该模式在一个PWM周期内,会在计数器到达ARR(上溢)和0(下溢)时各触发一次更新中断,实现更精细的实时控制。文章详细阐述了其工作原理、配置方法,并指导如何在中断服务函数中通过DIR位区分中断来源,同时探讨了其在电机控制、数字电源等场景下的应用优势与CPU负载挑战。

weixin_29164185的博客 503

test

#include stdio.h>__inline int idtCheck ()...{unsigned char m[6];__asm sidt m;printf("IDTR: %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x ", m[0], m[1], m[2], m[3], m[4], m[5]);return (m[5]>0xd0) ? 1 : 0;}int 

shnxl的专栏 334

STM32F103+AX58100 EtherCAT从站SPI移植实战:CubeMX配置避坑指南

本文详细介绍了STM32F103与AX58100 EtherCAT从站控制器的SPI接口移植实战,重点解析CubeMX配置中的关键参数与常见陷阱。内容涵盖硬件连接规范、SPI模式设置、中断优先级规划及协议栈对接技巧,帮助开发者高效实现工业自动化领域的实时通信方案。特别强调CPOL/CPHA配置与AX58100的匹配要求,避免数据错位问题。

weixin_29230865的博客 343

在不同环境下,该如何判断服务器是虚拟机还是物理机呢?

判断系统是否为虚拟机的方法有很多,通过查看硬件信息、检查系统日志、使用特定命令、观察性能表现等方法,可以比较准确地做出判断。在实际操作中,可以结合多种方法进行验证,以确保判断的准确性。此外,使用研发项目管理系统PingCode和通用项目协作软件Worktile,可以提升团队的协作效率,更好地管理虚拟机和物理机。

星河梦瑾的博客 4838

基于CNN的表情识别(FER)pytorch实现

Report for FER Jian Tang Abstract 我们使用卷积神经网络(CNN)实现了baby的面部表情识别(FER)。 数据上,我们获取了开源FER数据集FER2013[1],besides我们使用爬虫获取了baby相关的人脸图片,进行了手工分类标注以形成一个全新的baby FER数据集。 模型上,我们首先复现了Luan[2]的工作,即参考Kuo[3]在CVPR 2018上的工作并实现一个轻量的CNN网络,在FER2013上进行训练并得到了XXXX%的平均分类准确率(avg a

qq_20241587的博客 3689

保姆级教程:用北醒TFmini-i-CAN雷达给PixHawk飞控加装‘眼睛’,实现自动避障与定高

经过多次测试,前向雷达的最佳安装位置是机架前部下方5-10cm处,倾斜角度20-30度。电源方面,建议为CAN设备单独供电,避免电机启动时的电压骤降导致数据异常。北醒TFmini-i-CAN雷达与PixHawk飞控的组合,为DIY爱好者打开了低成本实现智能避障的大门。实际部署时,需确保整个CAN网络的波特率一致(TFmini-i默认为250kbps),每个设备具有唯一ID。雷达的安装角度也直接影响检测效果,建议通过3D打印支架将雷达向前下方倾斜15-30度。当使用多个雷达时,需为每个设备创建独立的参数组。

weixin_30892889的博客 339

VMWare Virtual PC 虚拟机 检测

Detect if your program is running inside a Virtual MachineBy lallous | 5 Apr 2005 An article showing how you can programmatically check if your code is running inside a virtual machine (such as VPC or VMWare).Download source and demo project - 6

lionzl的专栏 1820

智能车竞赛卡丁快跑组:自动驾驶与人车交互技术实战解析

本文深入解析了智能车竞赛卡丁快跑组的技术核心,重点探讨了自动驾驶与人车交互两大模块的实战方案。文章详细拆解了从环境感知、路径规划到语音识别、命令执行的完整流程,并分享了基于单片机平台的调试心法与赛场经验,为参赛者提供了一套从零开始、分步攻坚的系统性备赛指南。

f0g1h2的博客 1188

检测当前环境是否是虚拟机

虚拟机检测技术--检测当前环境是否是虚拟机

sunjiaoya的博客 6648

Wireshark时间分析实战:精准调试网络延迟与时间同步问题

本文深入探讨了Wireshark在网络延迟与时间同步问题分析中的核心应用。通过实战案例,详细讲解了如何设置时间显示格式、利用时间参考点量化关键路径延迟,以及运用时间平移功能校正错位时间轴。掌握这些时间分析技巧,能帮助网络工程师精准定位隐藏于数据包时序中的性能瓶颈与故障根源。

weixin_29290963的博客 267

SAP系统中客户库存B库存简介

在 SAP 系统中,特殊库存 B (Special Stock B) 指的是 “客户库存” (Customer Stock)。这是一个非常独特的库存概念,其核心定义是:物理上存放在你的仓库中,但法律上的所有权属于你的客户。1. 核心概念所有权 (Ownership): 属于客户。你的公司不拥有该物料的所有权。管理维度: 库存不仅由“物料+工厂+库位”管理,还必须指定 “客户编号” (Customer Number)。例子。

我小时候很黑的博客 553

检测程序是否在虚拟机运行的两种方法

最近在项目中遇到一个虚拟机检测的问题,需要检测当前程序是否在虚拟机中运行。 关于虚拟机的检测方法有很多,网上也能搜索到很多相关的 相信很多程序狗很可能也会遇到相同的问题

hnlwt的专栏 1万+

高可用架构设计——多节点OpenClaw集群部署与负载均衡(2026企业级)

本文介绍了企业级OpenClaw高可用集群架构设计,重点阐述了多节点部署与负载均衡方案。架构采用分层设计,包括表现层、应用层、数据层和基础设施层,确保99.99%的可用性目标。详细配置了主节点、工作节点和存储节点规格,提供Kubernetes集群部署脚本示例,实现自动化的容器编排管理。通过硬件冗余、故障隔离和弹性扩展等可靠性原则,构建能够应对各种故障场景的稳定AI助手系统。

博客 428

how to install git on ubuntu

What the Red Means The lines that the user needs to enter or customize will be in red in this tutorial! The rest should mostly be copy-and-pastable. About Git Git is a distributed version control ...

Move Fast! 196

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

how to install git server on ubuntu

# How to install git server on ubuntu ## install git   sudo apt-get install git ## add git user    sudo useradd git       sudo passwd git    ## install postgres   sudo apt-get install postgresql...

qq_32641185的博客 288

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

How To Install Git on Ubuntu 14.04

Introduction An indispensable tool in modern software development is some kind of version control system. Version control systems allow you to keep track of your software at the source level. You c

嵌入式技术在路上 563

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

How to Install Git on Ubuntu 12.04

FROM: https://www.digitalocean.com/community/articles/how-to-install-git-on-ubuntu-12-04 How to Install Git on Ubuntu 12.04 About Git Git is a distributed version control system released to t

tangwing的专栏 2695

How to download and install git on Ubuntu/Linux

1) For the latest stable version for your release of Linux/Ubuntusudo apt-get install git2) For Ubuntu, this PPA provides the latest stable upstream Git versionsudo add-apt-repository ppa:git-core/ppa...

程序员备忘录 362

git linux apt get,How to install GIT on Linux (Ubuntu & CentOS)

Installation on CentOS 7We can install git using 2 methods i.e. either using yum or installing from source. We will start by using yum for git installation,YUM methodJust like any other software, we c...

weixin_31794609的博客 218

How to install GIT on Linux (Ubuntu & CentOS)

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34194317的博客 284

How to Install HTTP Git Server With Nginx on Ubuntu 16.04

转自: https://www.howtoforge.com/tutorial/install-http-git-server-with-nginx-on-ubuntu-1604/ Git is a free and open-source version control system that can be used to track changes of code. Git

yuliying的专栏 1389

How to install Git on Ubuntu Lucid (10.04)

I'm sure there are tons of blogs out there on the same subject. This is just like a reference for me and others out there who might stumble upon this post. Note that what I have documented here is wha

anderberte 496

TWEET SHARE SHARE SHARE How To Install Git on Ubuntu 12.04

https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-12-04 纸上得来终觉浅,觉知此事要躬行。

zhiqicheng的专栏 203

How To Install Gitea Git Server On Ubuntu 16.04 / 18.04 / 18.10 With MariaDB

转载-适合菜鸟,网上的一些文章没有给出具体细节,这篇算是一个补充,细化了数据库(适用MYSQL)的操作过程。 Gitea is an open source version control platform similar to Gitbub… It’s probably the easiest, fastest, and most painless way of setting up a se...

mih2010的博客 454

install git lfs on ubuntu

sudo apt-get install software-properties-common sudo curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh > script.sh sudo bash script.sh sudo apt-get install git-lfs git lfs install 参考网页

qcxyliyong的博客 579

How to install paramiko/pexpect

sudo add-apt-repository universe sudo add-apt-repository multiverse sudo apt-get update sudo apt-get install python-pippip install pexpect # use dir(pexpect) to check sudo apt-get install p...

weixin_30745641的博客 77
上一篇: 内核钩子实例(稳定)
下一篇: how to detect VMM using (almost) one CPU instruction
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值