-include(../../../settings.cmake)
-
-add_definitions(-DUNICODE)
-add_definitions(-D_UNICODE)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmain")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
-
-include_directories("${CLI_CMAKE_RESOURCE_DIR}/uwpshim")
-link_directories(${UWPHOST_LIB_PATH})
-set (PLATFORM STORE)
-
-add_executable(UWPShim
- uwpshim.cpp
- native.rc
-)
-
-target_link_libraries(UWPShim
- UWPHost
- vcruntime
-)
-
-install(TARGETS UWPShim DESTINATION .)
+add_subdirectory(Console)
+add_subdirectory(Windows)
\ No newline at end of file
--- /dev/null
+include(../../../../settings.cmake)
+
+add_definitions(-DUNICODE)
+add_definitions(-D_UNICODE)
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmain")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+
+include_directories("${CLI_CMAKE_RESOURCE_DIR}/uwpshim")
+link_directories(${UWPHOST_LIB_PATH})
+set (PLATFORM STORE)
+
+add_executable(ConsoleUWPShim
+ ../uwpshim.cpp
+ ../native.rc
+)
+
+target_link_libraries(ConsoleUWPShim
+ UWPHost
+ vcruntime
+)
+
+install(TARGETS ConsoleUWPShim DESTINATION .)
DWORD exitCode = -1;
int argc;
LPCWSTR* wszArglist = const_cast<LPCWSTR*>(SegmentCommandLine(GetCommandLineW(), &argc));
-
- if (argc < 2)
- {
- // Invalid number of arguments
- return exitCode;
- }
-
+
// This module is merely a shim to figure out what the actual EntryPoint assembly is and call the Host with
// that information. The EntryPoint would be found based on the following assumptions
//
// 1) Current module lives under the "CoreRuntime" subfolder of the AppX package installation folder.
// 2) It has the same name as the EntryPoint assembly that will reside in the parent folder (i.e. the AppX package installation folder).
- const wchar_t* pActivationModulePath = wszArglist[0];
+ wchar_t pActivationModulePath[MAX_PATH];
+ if (!GetModuleFileName(nullptr, pActivationModulePath, MAX_PATH))
+ {
+ return GetLastError();
+ }
const wchar_t *pLastSlash = wcsrchr(pActivationModulePath, L'\\');
if (pLastSlash == NULL)
{
- return exitCode;
+ TerminateProcess(GetCurrentProcess(), exitCode);
}
wchar_t entryPointAssemblyFileName[MAX_PATH];
auto success = ExecuteAssembly(entryPointAssemblyFileName, argc-1, &(wszArglist[1]), &exitCode);
- return exitCode;
+ TerminateProcess(GetCurrentProcess(), exitCode);
}
--- /dev/null
+include(../../../../settings.cmake)
+
+add_definitions(-DUNICODE)
+add_definitions(-D_UNICODE)
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmain")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+
+include_directories("${CLI_CMAKE_RESOURCE_DIR}/uwpshim")
+link_directories(${UWPHOST_LIB_PATH})
+set (PLATFORM STORE)
+
+add_executable(UWPShim
+ ../uwpshim.cpp
+ ../native.rc
+)
+
+target_link_libraries(UWPShim
+ UWPHost
+ vcruntime
+)
+
+install(TARGETS UWPShim DESTINATION .)
<ItemGroup>
<CMakeOutput Include="$(IntermediateOutputRootPath)uwphost\host\uwphost\$(ConfigurationGroup)\uwphost.dll" />
- <CMakeOutput Include="$(IntermediateOutputRootPath)uwpshim\$(ConfigurationGroup)\uwpshim.exe" />
+ <CMakeOutput Include="$(IntermediateOutputRootPath)uwpshim\Windows\$(ConfigurationGroup)\uwpshim.exe" />
+ <CMakeOutput Include="$(IntermediateOutputRootPath)uwpshim\Console\$(ConfigurationGroup)\consoleuwpshim.exe" />
<CMakeOutput Include="$(IntermediateOutputRootPath)uwphost\copywin32resources\$(ConfigurationGroup)\copywin32resources.exe" />
</ItemGroup>