Index: reactos/base/setup/CMakeLists.txt =================================================================== --- reactos/base/setup/CMakeLists.txt (revision 74184) +++ reactos/base/setup/CMakeLists.txt (working copy) @@ -3,3 +3,4 @@ add_subdirectory(setup) add_subdirectory(usetup) add_subdirectory(welcome) +add_subdirectory(firstapp) Index: setup/firstapp/CMakeLists.txt =================================================================== --- reactos/base/setup/firstapp/CMakeLists.txt (nonexistent) +++ reactos/base/setup/firstapp/CMakeLists.txt (working copy) @@ -0,0 +1,4 @@ +add_executable(isvpc isvpc.c) +set_module_type(isvpc win32gui UNICODE) +add_importlibs(isvpc gdi32 user32 shell32 msvcrt kernel32 ntdll) +add_cd_file(TARGET isvpc DESTINATION reactos NO_CAB FOR bootcd) Index: setup/firstapp/isvpc.c =================================================================== --- reactos/base/setup/firstapp/isvpc.c (nonexistent) +++ reactos/base/setup/firstapp/isvpc.c (working copy) @@ -0,0 +1,81 @@ +/* +Basic demonstration of Win32 structured exception handling (SEH) code is +based on "Code for this article: Exception.exe" (MYSEH.CPP) from this article: + + https://www.microsoft.com/msj/0197/exception/exception.aspx + +Originally written by Matt Pietrek for the January 1997 Microsoft Systems Journal. +Modified in 2016 by David E. Grayson to work with gcc. + +Detecting Virtual PC from CodeProject: + + https://www.codeproject.com/kb/system/vmdetect.aspx + +Combined and modified 17-Mar-2017 by Doug Lyons to use in VPC detection routine for ReactOS. + +License: GPL V3.0 + +*/ + +#include +#include "excpt.h" + +int vpc = 1; + +EXCEPTION_DISPOSITION __cdecl +_except_handler( + struct _EXCEPTION_RECORD * ExceptionRecord, + void * EstablisherFrame, + struct _CONTEXT * ContextRecord, + void * DispatcherContext) +{ + // Not running VPC + ContextRecord->Eip += 4; // skip past the "call VPC" opcodes + + __asm__( // decrement vpc from 1 to 0 + "sub $1, %0" + : "=r" (vpc) + : "r" (vpc) + ); + + // Tell the OS to restart after the faulting instruction. + return ExceptionContinueExecution; +} + + +BOOL IsVPC() +{ + __asm__( // Build EXCEPTION_REGISTRATION record: + "push %0\n" // Bytes 4 to 7: Address of handler function + "push %%fs:0\n" // Bytes 0 to 3: Address of previous handler + "movl %%esp, %%fs:0\n" // Install new EXECPTION_REGISTRATION + : + : "r" ((DWORD_PTR)_except_handler) + ); + + + // call VPC + __asm__ __volatile__ (".byte 0x0F"); + __asm__ __volatile__ (".byte 0x3F"); + __asm__ __volatile__ (".byte 0x07"); + __asm__ __volatile__ (".byte 0x0B"); + __asm__ __volatile__ (".byte 0x90"); + + + __asm__( // Remove our EXCEPTION_REGISTRATION record + "movl (%esp), %eax\n" // Get pointer to previous record + "movl %eax, %fs:0\n" // Install previous record + "addl $8, %esp\n" // Clean our EXCEPTION_REGISTRATION off stack + ); + + return vpc; +} + +int wmain() +{ + if (IsVPC()) + MessageBox(0, TEXT("Is VPC"),TEXT("Press OK..."), MB_OK); + else + MessageBox(0, TEXT("Not VPC"),TEXT("Press OK..."), MB_OK); + return 0; +} \ No newline at end of file