diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dcfb190
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+build_*
+*.swp
+*.swo
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6072521
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(elevate)
+
+file(GLOB elevate_headers src/*.h)
+file(GLOB elevate_sources src/*.c src/*.rc)
+
+add_executable(elevate ${elevate_headers} ${elevate_sources})
+add_definitions(-D_UNICODE -DUNICODE)
diff --git a/Elevate.sdf b/Elevate.sdf
deleted file mode 100644
index aabbfbb..0000000
Binary files a/Elevate.sdf and /dev/null differ
diff --git a/Elevate.sln b/Elevate.sln
deleted file mode 100644
index 4c1fe93..0000000
--- a/Elevate.sln
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Elevate", "Elevate\Elevate.vcxproj", "{D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Debug|x64.ActiveCfg = Debug|x64
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Debug|x64.Build.0 = Debug|x64
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Debug|x86.ActiveCfg = Debug|Win32
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Debug|x86.Build.0 = Debug|Win32
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Release|x64.ActiveCfg = Release|x64
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Release|x64.Build.0 = Release|x64
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Release|x86.ActiveCfg = Release|Win32
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Elevate.suo b/Elevate.suo
deleted file mode 100644
index 78f1d94..0000000
Binary files a/Elevate.suo and /dev/null differ
diff --git a/Elevate/Elevate.aps b/Elevate/Elevate.aps
deleted file mode 100644
index 4834492..0000000
Binary files a/Elevate/Elevate.aps and /dev/null differ
diff --git a/Elevate/Elevate.vcproj b/Elevate/Elevate.vcproj
deleted file mode 100644
index 02ed813..0000000
--- a/Elevate/Elevate.vcproj
+++ /dev/null
@@ -1,376 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Elevate/Elevate.vcxproj b/Elevate/Elevate.vcxproj
deleted file mode 100644
index f9521d2..0000000
--- a/Elevate/Elevate.vcxproj
+++ /dev/null
@@ -1,181 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {D44F41E2-0CEE-4B9B-825D-1AEBF6DCAB1C}
- Elevate
- Win32Proj
-
-
-
- Application
- Unicode
- true
-
-
- Application
- Unicode
-
-
- Application
- Unicode
- true
-
-
- Application
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.40219.1
- $(SolutionDir)bin\x86\$(Configuration)\
- $(SolutionDir)bin\x86\$(Configuration)\
- true
- $(SolutionDir)bin\$(Platform)\$(Configuration)\
- $(SolutionDir)bin\$(Platform)\$(Configuration)\
- true
- $(SolutionDir)bin\x86\$(Configuration)\
- $(SolutionDir)bin\x86\$(Configuration)\
- false
- $(SolutionDir)bin\$(Platform)\$(Configuration)\
- $(SolutionDir)bin\$(Platform)\$(Configuration)\
- false
-
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- EnableFastChecks
- MultiThreadedDebug
-
-
- Level4
- EditAndContinue
- StdCall
- CompileAsC
-
-
- true
- Console
- MachineX86
-
-
-
-
- X64
-
-
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- EnableFastChecks
- MultiThreadedDebug
-
-
- Level4
- ProgramDatabase
- StdCall
- CompileAsC
-
-
- true
- Console
- MachineX64
-
-
-
-
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- MultiThreaded
-
-
- Level4
- ProgramDatabase
- StdCall
- CompileAsC
-
-
- true
- Console
- true
- true
- MachineX86
-
-
-
-
- X64
-
-
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
-
-
- MultiThreaded
-
-
- Level4
- ProgramDatabase
- StdCall
- CompileAsC
-
-
- true
- Console
- true
- true
- MachineX64
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Elevate/Elevate.vcxproj.filters b/Elevate/Elevate.vcxproj.filters
deleted file mode 100644
index b13b449..0000000
--- a/Elevate/Elevate.vcxproj.filters
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
-
-
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Resource Files
-
-
-
\ No newline at end of file
diff --git a/Elevate/Elevate.vcxproj.user b/Elevate/Elevate.vcxproj.user
deleted file mode 100644
index ace9a86..0000000
--- a/Elevate/Elevate.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/cmake_vs2017.bat b/cmake_vs2017.bat
new file mode 100644
index 0000000..38b5ea8
--- /dev/null
+++ b/cmake_vs2017.bat
@@ -0,0 +1,4 @@
+mkdir build_vs2017
+pushd build_vs2017
+cmake --debug-trycompile -G "Visual Studio 15 2017 Win64" ..
+popd
diff --git a/Elevate/Elevate.rc b/src/elevate.rc
similarity index 96%
rename from Elevate/Elevate.rc
rename to src/elevate.rc
index 130223f..440e2d1 100644
--- a/Elevate/Elevate.rc
+++ b/src/elevate.rc
@@ -7,7 +7,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include "afxres.h"
+#include "windows.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@@ -75,7 +75,7 @@ BEGIN
VALUE "FileVersion", "1, 0, 0, 2894"
VALUE "InternalName", "Elevate"
VALUE "LegalCopyright", "Copyright (C) 2007"
- VALUE "OriginalFilename", "Elevate.exe"
+ VALUE "OriginalFilename", "elevate.exe"
VALUE "ProductName", "Elevate Application"
VALUE "ProductVersion", "1, 0, 0, 2894"
END
diff --git a/Elevate/main.c b/src/main.c
similarity index 90%
rename from Elevate/main.c
rename to src/main.c
index 15445a8..2156738 100644
--- a/Elevate/main.c
+++ b/src/main.c
@@ -86,7 +86,7 @@ INT DispatchCommand(
L"Usage: Elevate [-?|-wait|-k] prog [args]\n"
L"-? - Shows this help\n"
L"-wait - Waits until prog terminates\n"
- L"-k - Starts the the %%COMSPEC%% environment variable value and\n"
+ L"-k - Starts the %%COMSPEC%% environment variable value and\n"
L" executes prog in it (CMD.EXE, 4NT.EXE, etc.)\n"
L"prog - The program to execute\n"
L"args - Optional command line arguments to prog\n" );
@@ -130,23 +130,32 @@ int __cdecl wmain(
__in WCHAR* Argv[]
)
{
- OSVERSIONINFO OsVer;
+ OSVERSIONINFOEX OsVer;
COMMAND_LINE_ARGS Args;
+ DWORD VerifyVersionFlags;
+ DWORDLONG VersionConditionMask;
+
INT Index;
BOOL FlagsRead = FALSE;
WCHAR CommandLineBuffer[ 260 ] = { 0 };
- ZeroMemory( &OsVer, sizeof( OSVERSIONINFO ) );
- OsVer.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-
+ ZeroMemory( &OsVer, sizeof( OSVERSIONINFOEX ) );
+ OsVer.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX );
+ VersionConditionMask = 0;
ZeroMemory( &Args, sizeof( COMMAND_LINE_ARGS ) );
Args.CommandLine = CommandLineBuffer;
+ //
+ // Set the version verification settings
+ //
+ OsVer.dwMajorVersion = 6;
+ VerifyVersionFlags = VER_MAJORVERSION;
+ VersionConditionMask = VerSetConditionMask(VersionConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+
//
// Check OS version
//
- if ( GetVersionEx( &OsVer ) &&
- OsVer.dwMajorVersion < 6 )
+ if ( FALSE == VerifyVersionInfo( &OsVer, VerifyVersionFlags, VersionConditionMask ) )
{
fwprintf( stderr, L"This tool is for Windows Vista and above only.\n" );
return EXIT_FAILURE;
diff --git a/Elevate/resource.h b/src/resource.h
similarity index 100%
rename from Elevate/resource.h
rename to src/resource.h
diff --git a/Elevate/stdafx.h b/src/stdafx.h
similarity index 100%
rename from Elevate/stdafx.h
rename to src/stdafx.h