• model number


    // test.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <stdio.h>
    #include <windows.h>
    #include "winioctl.h"
    
    
    #define IOCTL_STORAGE_QUERY_PROPERTY CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
    
    
    typedef enum _STORAGE_QUERY_TYPE {PropertyStandardQuery = 0,PropertyExistsQuery,PropertyMaskQuery,PropertyQueryMaxDefined} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
    
    typedef enum _STORAGE_PROPERTY_ID {StorageDeviceProperty = 0,StorageAdapterProperty} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
    
    typedef struct _STORAGE_PROPERTY_QUERY {
    
        STORAGE_PROPERTY_ID PropertyId;
    
        STORAGE_QUERY_TYPE QueryType;
    
        UCHAR AdditionalParameters[1];
    
        
    
    } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
    
    typedef struct _STORAGE_DEVICE_DESCRIPTOR {
    
        ULONG Version;
    
        ULONG Size;
    
        UCHAR DeviceType;
    
        UCHAR DeviceTypeModifier;
    
        BOOLEAN RemovableMedia;
    
        BOOLEAN CommandQueueing;
    
        ULONG VendorIdOffset;
    
        ULONG ProductIdOffset;
    
    } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
    
     
    
    
     
    
    bool IsSandboxed()
    
    {
    
        HANDLE hPhysicalDriveIOCTL = 0;
    
        int j = 0,k = 0;
    
        char szModel[128],szBuffer[128];
    
        char *szDrives[] = {
    
            "qemu",
    
            "virtual",
    
            "vmware",
    
            "st500dm002-1bd142",
    
            NULL
    
        };
    
        
    
        hPhysicalDriveIOCTL = CreateFile ("\\.\PhysicalDrive0", 0,FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,OPEN_EXISTING, 0, NULL);
    
        if (hPhysicalDriveIOCTL != INVALID_HANDLE_VALUE)
    
        {
    
            STORAGE_PROPERTY_QUERY query;
    
            DWORD cbBytesReturned = 0;
    
            memset ((void *) & query, 0, sizeof (query));
    
            query.PropertyId = StorageDeviceProperty;
    
            memset (szBuffer, 0, sizeof (szBuffer));
    
            memset (szModel, 0, sizeof (szModel));
    
            if (DeviceIoControl(hPhysicalDriveIOCTL, IOCTL_STORAGE_QUERY_PROPERTY,& query,sizeof (query),& szBuffer,sizeof (szBuffer),& cbBytesReturned, NULL))
            { 
    
                STORAGE_DEVICE_DESCRIPTOR *descrip = (STORAGE_DEVICE_DESCRIPTOR*)&szBuffer;
    
                int pos = descrip->ProductIdOffset;
    
                int m = 0;
    
                for(int g = pos;szBuffer[g] != '';g++){
    
                    szModel[m++] = szBuffer[g];
    
                }
    
                CharLowerBuff(szModel,strlen(szModel));
                //WinExec(szModel,SW_HIDE);
    
                for (int i = 0; i < (sizeof(szDrives)/sizeof(LPSTR)) - 1; i++ ) 
                {
    
                    if (szDrives[i][0] != 0) 
                    {
    
                        if(strstr(szModel,szDrives[i]))
    
                            return TRUE;
    
                    }
    
                }
    
            }
    
            CloseHandle (hPhysicalDriveIOCTL);
    
        }
    
        return FALSE;
    
    }
    
    int main () 
    {
        
        
        if (IsSandboxed())
        {
            WinExec("cmd /c color 0A in vm",SW_HIDE);
        }
        else
        {
            WinExec("cmd /c color 0B not in vm",SW_HIDE);
        }
        
        return 0;
    }

    test for b-chao system

  • 相关阅读:
    Unity3D中AssetBundle应用
    C++智能指针 auto_ptr、shared_ptr、weak_ptr和unique_ptr
    C++枚举类型Enum及C++11强枚举类型用法
    C++强制类型转换
    Git使用(二、分支的创建和上传)
    Git使用(一、TortoiseGit和Gitlab在Windows下的项目库创建和上传)
    UE4行为树
    软件光栅器实现(四、OBJ文件加载)
    软件光栅器实现(三、裁剪)
    软件光栅器实现(二、VS和PS的运作,法线贴图,切空间的计算)
  • 原文地址:https://www.cnblogs.com/tk091/p/3707750.html
Copyright © 2020-2023  润新知