// redpill.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <tchar.h>

void inside_vmware()
{
    printf("Inside VMWare.");
    fopen("C:\\inside_vmware.txt", "w");
}

void outside_vmware()
{
    printf("Outside VMWare.");
    fopen("C:\\outside_vmware.txt", "w");
}

int _tmain(int argc, _TCHAR* argv[])
{
	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) 
         inside_vmware();
	 else 
         outside_vmware();

	return 0;
}