diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e9abf7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,329 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/CreateDesktop.sln b/CreateDesktop.sln new file mode 100644 index 0000000..488f745 --- /dev/null +++ b/CreateDesktop.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateDesktop", "CreateDesktop\CreateDesktop.vcxproj", "{FBE87476-45CE-4B8F-88FB-1D66142480C8}" +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 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Debug|x64.ActiveCfg = Debug|x64 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Debug|x64.Build.0 = Debug|x64 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Debug|x86.ActiveCfg = Debug|Win32 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Debug|x86.Build.0 = Debug|Win32 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Release|x64.ActiveCfg = Release|x64 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Release|x64.Build.0 = Release|x64 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Release|x86.ActiveCfg = Release|Win32 + {FBE87476-45CE-4B8F-88FB-1D66142480C8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B72935A8-E3BE-4177-926E-9C21595C2CD2} + EndGlobalSection +EndGlobal diff --git a/CreateDesktop/.gitignore b/CreateDesktop/.gitignore new file mode 100644 index 0000000..259148f --- /dev/null +++ b/CreateDesktop/.gitignore @@ -0,0 +1,32 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/CreateDesktop/CreateDesktop.vcxproj b/CreateDesktop/CreateDesktop.vcxproj new file mode 100644 index 0000000..b0f8c18 --- /dev/null +++ b/CreateDesktop/CreateDesktop.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {FBE87476-45CE-4B8F-88FB-1D66142480C8} + Win32Proj + CreateDesktop + 10.0.17134.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/CreateDesktop/CreateDesktop.vcxproj.filters b/CreateDesktop/CreateDesktop.vcxproj.filters new file mode 100644 index 0000000..89d2ea5 --- /dev/null +++ b/CreateDesktop/CreateDesktop.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/CreateDesktop/main.cpp b/CreateDesktop/main.cpp new file mode 100644 index 0000000..e14317e Binary files /dev/null and b/CreateDesktop/main.cpp differ diff --git a/CreateDesktop/stdafx.cpp b/CreateDesktop/stdafx.cpp new file mode 100644 index 0000000..5d99289 Binary files /dev/null and b/CreateDesktop/stdafx.cpp differ diff --git a/CreateDesktop/stdafx.h b/CreateDesktop/stdafx.h new file mode 100644 index 0000000..4eecf54 Binary files /dev/null and b/CreateDesktop/stdafx.h differ diff --git a/CreateDesktop/targetver.h b/CreateDesktop/targetver.h new file mode 100644 index 0000000..d5949e8 Binary files /dev/null and b/CreateDesktop/targetver.h differ diff --git a/Main.cpp b/Main.cpp deleted file mode 100644 index e1dc379..0000000 --- a/Main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include - -//Create a new desktop or open an existing one -HDESK CreateHiddenDesktop(CHAR *desktop_name) -{ - CHAR explorer_path[MAX_PATH]; - HDESK hidden_desktop = NULL, original_desktop; - STARTUPINFOA startup_info = {0}; - PROCESS_INFORMATION process_info = {0}; - - ExpandEnvironmentStringsA("%windir%\\explorer.exe", explorer_path, MAX_PATH-1); - - hidden_desktop = OpenDesktopA(desktop_name, NULL, FALSE, GENERIC_ALL); - if(!hidden_desktop) - { - hidden_desktop = CreateDesktopA(desktop_name, NULL, NULL, 0, GENERIC_ALL, NULL); - if(hidden_desktop) - { - original_desktop = GetThreadDesktop(GetCurrentThreadId()); - - if(SetThreadDesktop(hidden_desktop)) - { - startup_info.cb = sizeof(startup_info); - startup_info.lpDesktop = desktop_name; - - //We need to create an explorer.exe in the context of the new desktop for start menu, etc - CreateProcessA(explorer_path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startup_info, &process_info); - - SetThreadDesktop(original_desktop); - } - } - } - return hidden_desktop; -} - -void main() -{ - HDESK original_desktop, hidden_desktop; - - hidden_desktop = CreateHiddenDesktop("MalwareTech_Hidden"); - original_desktop = GetThreadDesktop(GetCurrentThreadId()); - - printf("Entering hidden desktop\n"); - - //Need to switch thread into context of new desktop to register hotkeys - SetThreadDesktop(hidden_desktop); - SwitchDesktop(hidden_desktop); - - if(RegisterHotKey(NULL, 1, MOD_CONTROL | MOD_ALT | MOD_NOREPEAT, 0x45)) - { - MSG msg = {0}; - while(GetMessage(&msg, NULL, 0, 0) != 0) - { - if(msg.message == WM_HOTKEY) - { - printf("Exiting hidden desktop\n"); - SwitchDesktop(original_desktop); - break; - } - } - } - - CloseHandle(hidden_desktop); - getchar(); -} \ No newline at end of file diff --git a/README.md b/README.md index 5582f67..286a1d2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,30 @@ # CreateDesktop -**Example application for creating multiple desktops on Windows** -Creates a new desktop named "MalwareTech_Hidden" and switches into it (You can witch back to the original dekstop with the hotkey CTRL + ALT + E) +Creates a hidden Windows 10 virtual desktop. +## Details + +Visual Studio 2017 32/64-bit native console application written in C++. When run creates a hidden virtual Windows 10 desktop and toggles to it. To toggle back, press Ctrl+Alt+E. The virtual desktop remains active but invisible even after the command has terminated. Run the command again to get back to it. + +### Using + +Run CreateDesktop.exe from File Explorer or a shell. + +Press Ctrl+Alt+E to toggle back to the source desktop. + +Any key then exists (the prompt will be taken away in a future version). + +Run CreateDesktop.exe to return to the hidden virtual desktop to find it as you left it. + +### Known Issues + +Start Menu and other Windows-specific icons on the taskbar don't respond on the virtual desktop. + +## Built With + +* [Visual Studio Community 2017](https://www.visualstudio.com/) - The IDE used + +## Authors + +* **MalwareTech** - *Initial work* - [MalwareTech](https://github.com/MalwareTech) +* **Andreas Toth** - *VS 2017 Project, UNICODE, and clean-ups* - [MrAndreasToth](https://github.com/mrandreastoth) \ No newline at end of file