diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.cpp b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.cpp new file mode 100644 index 00000000..4ccaa231 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.cpp @@ -0,0 +1,31 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// ClassicDLL.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include +#include +#include + +using namespace std; + +int Increment(int numberToIncrement) +{ + return ++numberToIncrement; +} + +const wchar_t * EditText(const wchar_t * s) +{ + return L"Welcome to Build! Please give Andrew some applause! :)"; +} diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.h b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.h new file mode 100644 index 00000000..f36227d0 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.h @@ -0,0 +1,16 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +#pragma once + +extern "C" __declspec(dllexport) int Increment(int numberToIncrement); +extern "C" __declspec(dllexport) const wchar_t * EditText(const wchar_t *); diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj new file mode 100644 index 00000000..2812cb2e --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4} + Win32Proj + ClassicDLL + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + mkdir $(solutiondir)Plugin1\Public +xcopy /y $(outdir)*.dll $(solutiondir)Plugin1\Public\* + + + + + Use + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + mkdir $(solutiondir)Plugin1\Public +xcopy /y $(outdir)*.dll $(solutiondir)Plugin1\Public\* + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + false + + + false + + + false + + + false + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj.filters b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj.filters new file mode 100644 index 00000000..1ddea704 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/ClassicDLL.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {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;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 + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/dllmain.cpp b/Samples/NativePluginSample/DLLExtension/ClassicDLL/dllmain.cpp new file mode 100644 index 00000000..12b809e3 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/dllmain.cpp @@ -0,0 +1,31 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.cpp b/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.cpp new file mode 100644 index 00000000..15c6587f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.cpp @@ -0,0 +1,20 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// stdafx.cpp : source file that includes just the standard includes +// ClassicDLL.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.h b/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.h new file mode 100644 index 00000000..b711c48c --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/stdafx.h @@ -0,0 +1,29 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + + + +// TODO: reference additional headers your program requires here +#include "ClassicDLL.h" diff --git a/Samples/NativePluginSample/DLLExtension/ClassicDLL/targetver.h b/Samples/NativePluginSample/DLLExtension/ClassicDLL/targetver.h new file mode 100644 index 00000000..acd040c7 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/ClassicDLL/targetver.h @@ -0,0 +1,19 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/Samples/NativePluginSample/DLLExtension/DLLExtension.sln b/Samples/NativePluginSample/DLLExtension/DLLExtension.sln new file mode 100644 index 00000000..0100b11f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/DLLExtension.sln @@ -0,0 +1,52 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClassicDLL", "ClassicDLL\ClassicDLL.vcxproj", "{E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin1", "Plugin1\Plugin1.vcxproj", "{407758F0-63B3-4F20-9421-C8589CEE6E7C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|ARM.ActiveCfg = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x64.ActiveCfg = Debug|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x64.Build.0 = Debug|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x86.ActiveCfg = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x86.Build.0 = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|ARM.ActiveCfg = Release|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x64.ActiveCfg = Release|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x64.Build.0 = Release|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x86.ActiveCfg = Release|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x86.Build.0 = Release|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|ARM.ActiveCfg = Debug|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|ARM.Build.0 = Debug|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|ARM.Deploy.0 = Debug|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x64.ActiveCfg = Debug|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x64.Build.0 = Debug|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x64.Deploy.0 = Debug|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x86.ActiveCfg = Debug|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x86.Build.0 = Debug|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Debug|x86.Deploy.0 = Debug|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|ARM.ActiveCfg = Release|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|ARM.Build.0 = Release|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|ARM.Deploy.0 = Release|ARM + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x64.ActiveCfg = Release|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x64.Build.0 = Release|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x64.Deploy.0 = Release|x64 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x86.ActiveCfg = Release|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x86.Build.0 = Release|Win32 + {407758F0-63B3-4F20-9421-C8589CEE6E7C}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml new file mode 100644 index 00000000..a3d8ef7b --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml @@ -0,0 +1,8 @@ + + + diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.cpp b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.cpp new file mode 100644 index 00000000..d025b6d0 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.cpp @@ -0,0 +1,136 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// +// App.xaml.cpp +// Implementation of the App class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace Plugin1; + +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +/// +/// Initializes the singleton application object. This is the first line of authored code +/// executed, and as such is the logical equivalent of main() or WinMain(). +/// +App::App() +{ + InitializeComponent(); + Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); +} + +/// +/// Invoked when the application is launched normally by the end user. Other entry points +/// will be used such as when the application is launched to open a specific file. +/// +/// Details about the launch request and process. +void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) +{ +#if _DEBUG + // Show graphics profiling information while debugging. + if (IsDebuggerPresent()) + { + // Display the current frame rate counters + DebugSettings->EnableFrameRateCounter = true; + } +#endif + auto rootFrame = dynamic_cast(Window::Current->Content); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == nullptr) + { + // Create a Frame to act as the navigation context and associate it with + // a SuspensionManager key + rootFrame = ref new Frame(); + + rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); + + if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) + { + // TODO: Restore the saved session state only when appropriate, scheduling the + // final launch steps after the restore is complete + + } + + if (e->PrelaunchActivated == false) + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); + } + // Place the frame in the current Window + Window::Current->Content = rootFrame; + // Ensure the current window is active + Window::Current->Activate(); + } + } + else + { + if (e->PrelaunchActivated == false) + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); + } + // Ensure the current window is active + Window::Current->Activate(); + } + } +} + +/// +/// Invoked when application execution is being suspended. Application state is saved +/// without knowing whether the application will be terminated or resumed with the contents +/// of memory still intact. +/// +/// The source of the suspend request. +/// Details about the suspend request. +void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) +{ + (void) sender; // Unused parameter + (void) e; // Unused parameter + + //TODO: Save application state and stop any background activity +} + +/// +/// Invoked when Navigation to a certain page fails +/// +/// The Frame which failed navigation +/// Details about the navigation failure +void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e) +{ + throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name); +} \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.h b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.h new file mode 100644 index 00000000..669f3010 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/App.xaml.h @@ -0,0 +1,39 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// +// App.xaml.h +// Declaration of the App class. +// + +#pragma once + +#include "App.g.h" + +namespace Plugin1 +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + ref class App sealed + { + protected: + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; + + internal: + App(); + + private: + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); + void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); + }; +} diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/LockScreenLogo.scale-200.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 00000000..735f57ad Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/LockScreenLogo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/SplashScreen.scale-200.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000..0636b004 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/SplashScreen.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square150x150Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000..5f3e02b8 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square150x150Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..f49edde3 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000..2980c9aa Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/StoreLogo.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/StoreLogo.png new file mode 100644 index 00000000..8c20b10d Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/StoreLogo.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Wide310x150Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..5b197d3e Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Assets/Wide310x150Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml new file mode 100644 index 00000000..569e507a --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.cpp b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.cpp new file mode 100644 index 00000000..2c1a61fe --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.cpp @@ -0,0 +1,38 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// +// MainPage.xaml.cpp +// Implementation of the MainPage class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace Plugin1; + +using namespace Platform; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 + +MainPage::MainPage() +{ + InitializeComponent(); +} diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.h b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.h new file mode 100644 index 00000000..4ad4bf25 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/MainPage.xaml.h @@ -0,0 +1,33 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// +// MainPage.xaml.h +// Declaration of the MainPage class. +// + +#pragma once + +#include "MainPage.g.h" + +namespace Plugin1 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public ref class MainPage sealed + { + public: + MainPage(); + + }; +} diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Package.appxmanifest b/Samples/NativePluginSample/DLLExtension/Plugin1/Package.appxmanifest new file mode 100644 index 00000000..c497a119 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/Package.appxmanifest @@ -0,0 +1,34 @@ + + + + + + Plugin1 + dbenne + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.rc b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.rc new file mode 100644 index 00000000..6d285329 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.rc differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj new file mode 100644 index 00000000..89d4d253 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj @@ -0,0 +1,216 @@ + + + + {407758f0-63b3-4f20-9421-c8589cee6e7c} + Plugin1 + en-US + 14.0 + true + Windows Store + 10.0.14393.0 + 10.0.14393.0 + 10.0 + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + Application + true + v140 + + + Application + true + v140 + + + Application + true + v140 + + + Application + false + true + v140 + true + + + Application + false + true + v140 + true + + + Application + false + true + v140 + true + + + + + + + + + + + + + + + + + + + + + + + + + Plugin1_TemporaryKey.pfx + False + Always + x86 + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + mkdir $(outdir)Public +xcopy /y /s $(solutiondir)$(projectname)\Public\* $(OutDir)Public\* + + + + + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + mkdir $(outdir)Public +xcopy /y /s $(solutiondir)$(projectname)\Public\* $(OutDir)Public\* + + + + + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + + + + + + App.xaml + + + MainPage.xaml + + + + + + Designer + + + Designer + + + + + Designer + + + + true + Document + + + + + + + + + + + + + + App.xaml + + + MainPage.xaml + + + Create + Create + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj.filters b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj.filters new file mode 100644 index 00000000..33063975 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/Plugin1.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + 407758f0-63b3-4f20-9421-c8589cee6e7c + + + 1c3fc413-d8f2-4350-8a83-2560b130d624 + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + {669fbd83-2a88-47ab-9e78-740e6982ccbe} + + + + + + + + + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Public + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/Public/ClassicDLL.dll b/Samples/NativePluginSample/DLLExtension/Plugin1/Public/ClassicDLL.dll new file mode 100644 index 00000000..8834ddf0 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension/Plugin1/Public/ClassicDLL.dll differ diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/pch.cpp b/Samples/NativePluginSample/DLLExtension/Plugin1/pch.cpp new file mode 100644 index 00000000..78ec75a4 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/pch.cpp @@ -0,0 +1,18 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// +// pch.cpp +// Include the standard header and generate the precompiled header. +// + +#include "pch.h" diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/pch.h b/Samples/NativePluginSample/DLLExtension/Plugin1/pch.h new file mode 100644 index 00000000..0323928f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/pch.h @@ -0,0 +1,23 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// +// pch.h +// Header for standard system include files. +// + +#pragma once + +#include +#include + +#include "App.xaml.h" diff --git a/Samples/NativePluginSample/DLLExtension/Plugin1/resource.h b/Samples/NativePluginSample/DLLExtension/Plugin1/resource.h new file mode 100644 index 00000000..79240a1f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension/Plugin1/resource.h @@ -0,0 +1,26 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Plugin1.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.cpp b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.cpp new file mode 100644 index 00000000..377c455f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.cpp @@ -0,0 +1,40 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// ClassicDLL.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include +#include +#include + +using namespace std; + +int Increment(int numberToIncrement) +{ + return ++numberToIncrement; +} + +const wchar_t * EditText(const wchar_t * s) +{ + const wchar_t *text = + L"Check out these great App Model sessions!" + L"\n\nB8004: App Model Evolution" + L"\n\nB8011: Bring your desktop apps to UWP and the Windows Store using the \n Desktop Bridge" + L"\n\nB8025: Cross-device and cross-platform experiences with Project Rome \n and Microsoft Graph" + L"\n\nB8108: App engagement in Windows and Cortana with User Activities and \n Project Rome" + L"\n\nB8012: Tip, tricks, and secrets: Building a great UWP app for PC" + L"\n\nB8002: Introducing Adaptive Cards" + L"\n\nB8093: Nextgen UWP app distribution: Building extensible, stream-able, \n componentized apps"; + return text; +} diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.h b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.h new file mode 100644 index 00000000..43a032be --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.h @@ -0,0 +1,16 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +#pragma once + +extern "C" __declspec(dllexport) int Increment(int); +extern "C" __declspec(dllexport) const wchar_t * EditText(const wchar_t *); diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj new file mode 100644 index 00000000..0a8b328f --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4} + Win32Proj + ClassicDLL + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + mkdir $(solutiondir)Plugin2\Plugin +xcopy /y $(outdir)*.dll $(solutiondir)Plugin2\Plugin\* + + + + + Use + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + mkdir $(solutiondir)Plugin2\Plugin +xcopy /y $(outdir)*.dll $(solutiondir)Plugin2\Plugin\* + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;CLASSICDLL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + false + + + false + + + false + + + false + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj.filters b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj.filters new file mode 100644 index 00000000..1ddea704 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/ClassicDLL.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {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;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 + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/dllmain.cpp b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/dllmain.cpp new file mode 100644 index 00000000..12b809e3 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/dllmain.cpp @@ -0,0 +1,31 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.cpp b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.cpp new file mode 100644 index 00000000..4323339b --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.cpp @@ -0,0 +1,19 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// stdafx.cpp : source file that includes just the standard includes +// ClassicDLL.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.h b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.h new file mode 100644 index 00000000..b711c48c --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/stdafx.h @@ -0,0 +1,29 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + + + +// TODO: reference additional headers your program requires here +#include "ClassicDLL.h" diff --git a/Samples/NativePluginSample/DLLExtension2/ClassicDLL/targetver.h b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/targetver.h new file mode 100644 index 00000000..55c4a003 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/ClassicDLL/targetver.h @@ -0,0 +1,20 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/Samples/NativePluginSample/DLLExtension2/DLLExtension.sln b/Samples/NativePluginSample/DLLExtension2/DLLExtension.sln new file mode 100644 index 00000000..48c429d2 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/DLLExtension.sln @@ -0,0 +1,52 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClassicDLL", "ClassicDLL\ClassicDLL.vcxproj", "{E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin2", "Plugin2\Plugin2.csproj", "{1FE7754B-EADA-4561-9F34-80E5A48EF862}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|ARM.ActiveCfg = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x64.ActiveCfg = Debug|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x64.Build.0 = Debug|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x86.ActiveCfg = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Debug|x86.Build.0 = Debug|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|ARM.ActiveCfg = Release|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x64.ActiveCfg = Release|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x64.Build.0 = Release|x64 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x86.ActiveCfg = Release|Win32 + {E1E52B44-AB2F-483A-8CA7-EE71F2E5D9A4}.Release|x86.Build.0 = Release|Win32 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|ARM.ActiveCfg = Debug|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|ARM.Build.0 = Debug|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|ARM.Deploy.0 = Debug|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x64.ActiveCfg = Debug|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x64.Build.0 = Debug|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x64.Deploy.0 = Debug|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x86.ActiveCfg = Debug|x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x86.Build.0 = Debug|x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Debug|x86.Deploy.0 = Debug|x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|ARM.ActiveCfg = Release|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|ARM.Build.0 = Release|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|ARM.Deploy.0 = Release|ARM + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x64.ActiveCfg = Release|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x64.Build.0 = Release|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x64.Deploy.0 = Release|x64 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x86.ActiveCfg = Release|x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x86.Build.0 = Release|x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml b/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml new file mode 100644 index 00000000..41e9ffc3 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml @@ -0,0 +1,8 @@ + + + diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml.cs b/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml.cs new file mode 100644 index 00000000..534a82ba --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/App.xaml.cs @@ -0,0 +1,118 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace Plugin2 +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { +#if DEBUG + if (System.Diagnostics.Debugger.IsAttached) + { + this.DebugSettings.EnableFrameRateCounter = true; + } +#endif + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (e.PrelaunchActivated == false) + { + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); + } + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/LockScreenLogo.scale-200.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 00000000..735f57ad Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/LockScreenLogo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/SplashScreen.scale-200.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000..0636b004 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/SplashScreen.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square150x150Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000..5f3e02b8 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square150x150Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..f49edde3 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000..2980c9aa Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/StoreLogo.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/StoreLogo.png new file mode 100644 index 00000000..8c20b10d Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/StoreLogo.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Wide310x150Logo.scale-200.png b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..5b197d3e Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Assets/Wide310x150Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml b/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml new file mode 100644 index 00000000..e217ed03 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml.cs b/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml.cs new file mode 100644 index 00000000..e7cd7790 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/MainPage.xaml.cs @@ -0,0 +1,42 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 + +namespace Plugin2 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainPage : Page + { + public MainPage() + { + this.InitializeComponent(); + } + } +} diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Package.appxmanifest b/Samples/NativePluginSample/DLLExtension2/Plugin2/Package.appxmanifest new file mode 100644 index 00000000..33989b64 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/Package.appxmanifest @@ -0,0 +1,34 @@ + + + + + + Plugin2 + dbenne + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin/ClassicDLL.dll b/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin/ClassicDLL.dll new file mode 100644 index 00000000..abcb2ca0 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin/ClassicDLL.dll differ diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin2.csproj b/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin2.csproj new file mode 100644 index 00000000..edb0f298 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/Plugin2.csproj @@ -0,0 +1,147 @@ + + + + + Debug + x86 + {1FE7754B-EADA-4561-9F34-80E5A48EF862} + AppContainerExe + Properties + Plugin2 + Plugin2 + en-US + UAP + 10.0.14393.0 + 10.0.14393.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Plugin2_TemporaryKey.pfx + False + Always + x86 + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + + + + + + App.xaml + + + MainPage.xaml + + + + + + Designer + + + + + + Always + + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + 14.0 + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/AssemblyInfo.cs b/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..40befa06 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Plugin2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Plugin2")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/Default.rd.xml b/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/Default.rd.xml new file mode 100644 index 00000000..80a960ce --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/Properties/Default.rd.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtension2/Plugin2/project.json b/Samples/NativePluginSample/DLLExtension2/Plugin2/project.json new file mode 100644 index 00000000..92d14561 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtension2/Plugin2/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicPluginsInUWP.sln b/Samples/NativePluginSample/DLLExtensionHost/ClassicPluginsInUWP.sln new file mode 100644 index 00000000..4e3a5fd5 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicPluginsInUWP.sln @@ -0,0 +1,66 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassicWin32Host", "ClassicWin32Host\ClassicWin32Host.csproj", "{50D40A2B-85CA-4292-BF34-06E571964856}" +EndProject +Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "UWPPackager", "UWPPackager\UWPPackager.jsproj", "{30025E99-9590-406B-8450-06ED091080A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|ARM.ActiveCfg = Debug|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|ARM.Build.0 = Debug|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|x64.ActiveCfg = Debug|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|x64.Build.0 = Debug|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|x86.ActiveCfg = Debug|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Debug|x86.Build.0 = Debug|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|Any CPU.Build.0 = Release|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|ARM.ActiveCfg = Release|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|ARM.Build.0 = Release|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|x64.ActiveCfg = Release|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|x64.Build.0 = Release|x64 + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|x86.ActiveCfg = Release|Any CPU + {50D40A2B-85CA-4292-BF34-06E571964856}.Release|x86.Build.0 = Release|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|ARM.ActiveCfg = Debug|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Debug|ARM.Build.0 = Debug|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Debug|ARM.Deploy.0 = Debug|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x64.Build.0 = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x64.Deploy.0 = Debug|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x86.ActiveCfg = Debug|x86 + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x86.Build.0 = Debug|x86 + {30025E99-9590-406B-8450-06ED091080A2}.Debug|x86.Deploy.0 = Debug|x86 + {30025E99-9590-406B-8450-06ED091080A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Release|Any CPU.Build.0 = Release|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Release|Any CPU.Deploy.0 = Release|Any CPU + {30025E99-9590-406B-8450-06ED091080A2}.Release|ARM.ActiveCfg = Release|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Release|ARM.Build.0 = Release|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Release|ARM.Deploy.0 = Release|ARM + {30025E99-9590-406B-8450-06ED091080A2}.Release|x64.ActiveCfg = Release|x64 + {30025E99-9590-406B-8450-06ED091080A2}.Release|x64.Build.0 = Release|x64 + {30025E99-9590-406B-8450-06ED091080A2}.Release|x64.Deploy.0 = Release|x64 + {30025E99-9590-406B-8450-06ED091080A2}.Release|x86.ActiveCfg = Release|x86 + {30025E99-9590-406B-8450-06ED091080A2}.Release|x86.Build.0 = Release|x86 + {30025E99-9590-406B-8450-06ED091080A2}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.config b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.config new file mode 100644 index 00000000..8227adb9 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml new file mode 100644 index 00000000..80f259fc --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml.cs new file mode 100644 index 00000000..47528e69 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/App.xaml.cs @@ -0,0 +1,51 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ClassicWin32Host +{ + + + public static class AppData + { + + private static ExtensionManager extensionManager; + internal static ExtensionManager ExtensionManager + { + get + { + return extensionManager; + } + + set + { + extensionManager = value; + } + } + + } + + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ClassicWin32Host.csproj b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ClassicWin32Host.csproj new file mode 100644 index 00000000..b29b7986 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ClassicWin32Host.csproj @@ -0,0 +1,187 @@ + + + + + Debug + AnyCPU + {50D40A2B-85CA-4292-BF34-06E571964856} + WinExe + ClassicWin32Host + ClassicWin32Host + v4.5.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + false + + + 1AFC6CEAD8CC03F0DD2D99E70CA0FE3DD96CD8F7 + + + ClassicWin32Host_1_TemporaryKey.pfx + + + + + + + False + ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll + False + + + False + ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.UI.Xaml.dll + False + + + + + + + + + + 4.0 + + + ..\..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd + + + + + + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + ExtensionsPage.xaml + + + + MainPage.xaml + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + False + Microsoft .NET Framework 4.5.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionManager.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionManager.cs new file mode 100644 index 00000000..57eb3769 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionManager.cs @@ -0,0 +1,504 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Windows.Threading; +using System.Threading.Tasks; +using Windows.ApplicationModel.Core; +using Windows.ApplicationModel; +using Windows.ApplicationModel.AppExtensions; // App Extensions!! +using Windows.ApplicationModel.AppService; +using Windows.Foundation.Collections; +using Windows.Storage; +using Windows.UI.Core; +using Windows.UI.Popups; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media.Imaging; +using Windows.System.Threading; + +namespace ClassicWin32Host +{ + class ExtensionManager + { + private ObservableCollection _extensions; + private string _contract; + private Dispatcher _dispatcher; + private AppExtensionCatalog _catalog; + private StorageFolder _folder; + + public ExtensionManager(string contract, Dispatcher dispatcher) + { + // extensions list + _extensions = new ObservableCollection(); + + // thread which creates the observable collection must be the thread to modify it + _dispatcher = dispatcher; + + // catalog & contract + _contract = contract; + _catalog = AppExtensionCatalog.Open(_contract); + _folder = null; + + // set up extension management events + _catalog.PackageInstalled += Catalog_PackageInstalled; + _catalog.PackageUpdated += Catalog_PackageUpdated; + _catalog.PackageUninstalling += Catalog_PackageUninstalling; + _catalog.PackageUpdating += Catalog_PackageUpdating; + _catalog.PackageStatusChanged += Catalog_PackageStatusChanged; + + // Scan all extensions + FindAllExtensions(); + } + + public ObservableCollection Extensions + { + get { return _extensions; } + } + + public string Contract + { + get { return _contract; } + } + + public StorageFolder Folder + { + get { return _folder; } + } + + public async void FindAllExtensions() + { + // load all the extensions currently installed + IReadOnlyList extensions = await _catalog.FindAllAsync(); + foreach (AppExtension ext in extensions) + { + // load this extension + await LoadExtension(ext); + } + } + + private async void Catalog_PackageInstalled(AppExtensionCatalog sender, AppExtensionPackageInstalledEventArgs args) + { + await _dispatcher.BeginInvoke((Action)(async () => { + foreach (AppExtension ext in args.Extensions) + { + await LoadExtension(ext); + } + }) ,DispatcherPriority.Normal, null); + } + + private async Task LoadAllExtensions(AppExtensionPackageInstalledEventArgs args) + { + foreach (AppExtension ext in args.Extensions) + { + await LoadExtension(ext); + } + return; + } + + // package has been updated, so reload the extensions + private async void Catalog_PackageUpdated(AppExtensionCatalog sender, AppExtensionPackageUpdatedEventArgs args) + { + await _dispatcher.BeginInvoke((Action)(async () => { + foreach (AppExtension ext in args.Extensions) + { + await LoadExtension(ext); + } + }) ,DispatcherPriority.Normal, null); + } + + // package is updating, so just unload the extensions + private async void Catalog_PackageUpdating(AppExtensionCatalog sender, AppExtensionPackageUpdatingEventArgs args) + { + await UnloadExtensions(args.Package); + } + + // package is removed, so unload all the extensions in the package and remove it + private async void Catalog_PackageUninstalling(AppExtensionCatalog sender, AppExtensionPackageUninstallingEventArgs args) + { + await RemoveExtensions(args.Package); + } + + // package status has changed, could be invalid, licensing issue, app was on USB and removed, etc + private async void Catalog_PackageStatusChanged(AppExtensionCatalog sender, AppExtensionPackageStatusChangedEventArgs args) + { + // get package status + if (!(args.Package.Status.VerifyIsOK())) + { + // if it's offline unload only + if (args.Package.Status.PackageOffline) + { + await UnloadExtensions(args.Package); + } + + // package is being serviced or deployed + else if (args.Package.Status.Servicing || args.Package.Status.DeploymentInProgress) + { + // ignore these package status events + } + + // package is tampered or invalid or some other issue + // glyphing the extensions would be a good user experience + else + { + await RemoveExtensions(args.Package); + } + + } + // if package is now OK, attempt to load the extensions + else + { + // try to load any extensions associated with this package + await LoadExtensions(args.Package); + } + } + + + // loads an extension + public async Task LoadExtension(AppExtension ext) + { + + // create plugins folder if it doesn't already exist + if (_folder == null) + { + try + { + // get or create folder for the extension that is unique + _folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Plugins", CreationCollisionOption.OpenIfExists); + } + catch + { + // Bad Things have happened + // But it's OK, becuase it'll be re-created later on. + } + } + + // get unique identifier for this extension + string identifier = ext.AppInfo.AppUserModelId + "!" + ext.Id; + + // load the extension if the package is OK + if (!(ext.Package.Status.VerifyIsOK() + // This is where we'd normally do signature verfication, but for demo purposes it isn't important + // Below is an example of how you'd ensure that you only load store-signed extensions :) + //&& ext.Package.SignatureKind == PackageSignatureKind.Store + )) + { + // if this package doesn't meet our requirements + // ignore it and return + return; + } + + // if its already existing then this is an update + Extension existingExt = _extensions.Where(e => e.UniqueId == identifier).FirstOrDefault(); + + // new extension + if (existingExt == null) + { + // create new extension + Extension nExt = new Extension(ext); + + // Add it to extension list + _extensions.Add(nExt); + + // load it + await nExt.Load(); + } + // update + else + { + // unload the extension + existingExt.Unload(); + + // update the extension + await existingExt.Update(ext); + } + } + + + + // loads all extensions associated with a package - used for when package status comes back + public async Task LoadExtensions(Package package) + { + await _dispatcher.BeginInvoke((Action)(() => { + _extensions.Where(ext => ext.AppExtension.Package.Id.FamilyName == package.Id.FamilyName).ToList().ForEach(async e => { await e.Load(); }); + }), DispatcherPriority.Normal, null); + } + + // unloads all extensions associated with a package - used for updating and when package status goes away + public async Task UnloadExtensions(Package package) + { + await _dispatcher.BeginInvoke((Action)(() => { + _extensions.Where(ext => ext.AppExtension.Package.Id.FamilyName == package.Id.FamilyName).ToList().ForEach(e => { e.Unload(); }); + }), DispatcherPriority.Normal, null); + } + + // removes all extensions associated with a package - used when removing a package or it becomes invalid + public async Task RemoveExtensions(Package package) + { + await _dispatcher.BeginInvoke((Action)(() => { + _extensions.Where(ext => ext.AppExtension.Package.Id.FamilyName == package.Id.FamilyName).ToList().ForEach(e => { e.Unload(); _extensions.Remove(e); }); + }), DispatcherPriority.Normal, null); + } + + + public void RemoveExtension(Extension ext) + { + // Centennial apps cannot use this method. See AppExtensionCatalog documentation for details. + //await _catalog.RequestRemovePackageAsync(ext.AppExtension.Package.Id.FullName); + } + + #region Extra exceptions + // For exceptions using the Extension Manager + public class ExtensionManagerException : Exception + { + public ExtensionManagerException() { } + + public ExtensionManagerException(string message) : base(message) { } + + public ExtensionManagerException(string message, Exception inner) : base(message, inner) { } + } + #endregion + } + + public class Extension : INotifyPropertyChanged + { + #region Member Vars + private AppExtension _extension; + private bool _enabled; + private bool _loaded; + private bool _offline; + private string _uniqueId; + private StorageFolder _folder; + private StorageFile _file; + private Library _lib; + private System.Windows.Visibility _visibility; + + private readonly object _sync = new object(); + + public event PropertyChangedEventHandler PropertyChanged; + #endregion + + public Extension(AppExtension ext) + { + _extension = ext; + _enabled = false; // default enabled/disabled + _loaded = false; + _offline = false; + _folder = null; + _file = null; + _lib = new Library(); + _visibility = System.Windows.Visibility.Collapsed; + + //AUMID + Extension ID is the unique identifier for an extension + _uniqueId = ext.AppInfo.AppUserModelId + "!" + ext.Id; + } + + ~Extension() + { + // unload the DLL + _lib.Free(); + } + + #region Properties + public string UniqueId + { + get { return _uniqueId; } + } + + public bool Enabled + { + get { return _enabled; } + } + + public bool Offline + { + get { return _offline; } + } + + public AppExtension AppExtension + { + get { return _extension; } + } + + public System.Windows.Visibility Visible + { + get { return _visibility; } + } + #endregion + + public Library Lib + { + get { return _lib; } + } + + // Test that the extension works + public void TestExtension() + { + if (_enabled && _lib.Func.FunctionsLoaded) + { + int rnum = (new Random()).Next(1, 50); + string msg = "Extension loaded!" + + "\n" + _extension.DisplayName + + "\n" + _uniqueId + + "\n ++" + rnum.ToString() + " = " + _lib.Func.Increment(rnum).ToString() + + "\n" + _lib.Func.EditText(@"TestStr") + ; + System.Windows.MessageBox.Show(msg); + } + } + + public async Task Update(AppExtension ext) + { + // ensure this is the same uid + string identifier = ext.AppInfo.AppUserModelId + "!" + ext.Id; + if (identifier != this.UniqueId) + { + return; + } + + // update the extension + this._extension = ext; + RaisePropertyChanged("AppExtension"); + + // load it & signal update + await Load(true); + } + + // this controls loading of the extension + public async Task Load(bool isUpdate) + { + #region Error Checking + // if it's not enabled or already loaded, don't load it + if (!_enabled || _loaded) + { + return; + } + + // make sure package is OK to load + if (!_extension.Package.Status.VerifyIsOK()) + { + return; + } + #endregion + + // If we are updating we won't use existing files and will re-copy them instead. + if (isUpdate) + { + _folder = null; + _file = null; + _lib.Free(); + } + + // load the file if we don't already have it. + if (_file == null) + { + // get extension from the other package + StorageFolder folder = await _extension.GetPublicFolderAsync(); + if (folder != null) + { + try + { + StorageFile extensionfile = await folder.GetFileAsync(@"ClassicDLL.dll"); + if (extensionfile != null) + { + // get or create folder for the extension that is unique + _folder = await AppData.ExtensionManager.Folder.CreateFolderAsync(_uniqueId, CreationCollisionOption.OpenIfExists); + + // copy the dll + _file = await extensionfile.CopyAsync(_folder, extensionfile.Name, NameCollisionOption.ReplaceExisting); + } + } + catch (Exception) + { + // something bad happened + return; + } + } + } + + // load the dll + _lib.Load(_file.Path); + + //TestExtension(); + + // all went well, set state + _loaded = true; + _visibility = System.Windows.Visibility.Visible; + RaisePropertyChanged("Visible"); + _offline = false; + } + public Task Load() + { + return this.Load(false); + } + + // This enables the extension + public async Task Enable() + { + // indicate desired state is enabled + _enabled = true; + + // load the extension + await Load(); + } + + // this is different from Disable, example: during updates where we only want to unload -> reload + // Enable is user intention. Load respects enable, but unload doesn't care + public void Unload() + { + // unload it + lock (_sync) + { + if (_loaded) + { + + // unload the DLL + _lib.Free(); + + _loaded = false; + _visibility = System.Windows.Visibility.Collapsed; + RaisePropertyChanged("Visible"); + } + } + } + + // user-facing action to disable the extension + public void Disable() + { + // only disable if it is enabled + if (_enabled) + { + // set desired state to disabled + _enabled = false; + // unload the app + Unload(); + } + } + #region PropertyChanged + + // typical property changed handler + private void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + #endregion + + } +} \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml new file mode 100644 index 00000000..a2a565ba --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plugins + + + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml.cs new file mode 100644 index 00000000..cad327ab --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/ExtensionsPage.xaml.cs @@ -0,0 +1,90 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ClassicWin32Host +{ + /// + /// Interaction logic for ExtensionsPage.xaml + /// + public partial class ExtensionsPage : Page + { + + public ObservableCollection Items = null; + + public ExtensionsPage() + { + this.InitializeComponent(); + + Items = AppData.ExtensionManager.Extensions; + //this.DataContext = Items; + lvExtensions.ItemsSource = Items; + + } + + private async void CheckBox_Checked(object sender, RoutedEventArgs e) + { + CheckBox cb = sender as CheckBox; + Extension ext = cb.DataContext as Extension; + if (!ext.Enabled) + { + await ext.Enable(); + } + } + + private void CheckBox_Unchecked(object sender, RoutedEventArgs e) + { + CheckBox cb = sender as CheckBox; + Extension ext = cb.DataContext as Extension; + if (ext.Enabled) + { + ext.Disable(); + } + } + + private void RemoveButton_Click(object sender, RoutedEventArgs e) + { + // remove the package + Button btn = sender as Button; + Extension ext = btn.DataContext as Extension; + AppData.ExtensionManager.RemoveExtension(ext); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + // get our extensions + AppData.ExtensionManager.FindAllExtensions(); + } + + private void lvExtensions_MouseDown(object sender, MouseButtonEventArgs e) + { + ListViewItem item = sender as ListViewItem; + Extension ext = item.DataContext as Extension; + ext.TestExtension(); + } + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Library.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Library.cs new file mode 100644 index 00000000..23d5969b --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Library.cs @@ -0,0 +1,221 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.ExceptionServices; +using System.Windows; + +namespace ClassicWin32Host +{ + public class Library + { + + public class Functions + { + private bool _functionsLoaded = false; + public bool FunctionsLoaded + { + get + { + return _functionsLoaded; + } + set + { + _functionsLoaded = value; + } + } + + + public dEditText _EditText = null; + [HandleProcessCorruptedStateExceptionsAttribute()] + public string EditText(string s) + { + if (_EditText != null) + { + try + { + IntPtr inPtr = Marshal.StringToHGlobalUni(s); + IntPtr outPtr = _EditText(inPtr); + if (outPtr == IntPtr.Zero) + { + return s; + } + return Marshal.PtrToStringUni(outPtr); + } + catch (Exception) + { + // Strange behavior appending, I suspect GC is wiping the data while it is being consumed. + //MessageBox.Show("Caught corruption exception!"); + return s; + } + } + return s; + } + + public dIncrement _Increment = null; + public int Increment(int num) + { + if (_Increment != null) + { + return _Increment(num); + } + return 0; + } + + public void Unload() + { + _Increment = null; + _EditText = null; + _functionsLoaded = false; + } + + public Functions() + { + + } + } + + private IntPtr _handle = IntPtr.Zero; + private Functions _func = null; + + public Functions Func + { + get + { + return _func; + } + } + + public Library() + { + _func = new Functions(); + _handle = IntPtr.Zero; + } + + #region Library Loading + public void Load(string fullPathFilename) + { + // dll already loaded + if (_handle != IntPtr.Zero) + { + // free it first + FreeLibrary(_handle); + } + try + { + _handle = LoadLibrary(fullPathFilename); + + // display info for failure + if (_handle == IntPtr.Zero) + { + System.IO.FileInfo fi = new System.IO.FileInfo(fullPathFilename); + int err = Marshal.GetLastWin32Error(); + string msg = "Cannot load DLL: " + + "\n Input: " + fullPathFilename + + "\n ERROR: " + err.ToString() + + "\n File Exists: " + fi.Exists.ToString() + ; + if (fi.Exists) + { + msg = msg + + "\n Full Path: " + fi.FullName.ToString() + + "\n Attributes: " + fi.Attributes.ToString() + ; + } + System.Windows.MessageBox.Show(msg); + } + + // file loaded, load the functions + GetFunctions(); + } + catch (Exception ex) + { + System.Windows.MessageBox.Show("Exception thrown while loading code {" + ex.InnerException + "}"); + } + } + + public void Free() + { + FreeLibrary(_handle); + _handle = IntPtr.Zero; + _func.Unload(); + } + + private void GetFunctions() + { + if (_handle == IntPtr.Zero || _func.FunctionsLoaded) + { + return; + } + + IntPtr funcptr = IntPtr.Zero; + + // increment function + funcptr = GetProcAddress(_handle, "Increment"); + if (funcptr != IntPtr.Zero) + { + _func._Increment = (dIncrement)Marshal.GetDelegateForFunctionPointer(funcptr, typeof(dIncrement)); + } + else + { + string msg = "Failed getting function ptr for Increment"; + System.Windows.MessageBox.Show(msg); + return; + } + + // chuck norris function + funcptr = GetProcAddress(_handle, "EditText"); + if (funcptr != IntPtr.Zero) + { + _func._EditText = (dEditText)Marshal.GetDelegateForFunctionPointer(funcptr, typeof(dEditText)); + } + else + { + string msg = "Failed getting function ptr for EditText"; + System.Windows.MessageBox.Show(msg); + return; + } + + _func.FunctionsLoaded = true; + } + #endregion + + #region Native Functions + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int dIncrement(int numberToIncrement); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr dEditText(IntPtr s); + #endregion + + #region Interop + + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + public static extern IntPtr LoadLibrary(string lpFileName); + + [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] + public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern bool FreeLibrary(IntPtr hModule); + + #endregion + + } + +} + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml new file mode 100644 index 00000000..7b0a59fa --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Welcome to the beautiful Emerald City! + + + + + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml.cs new file mode 100644 index 00000000..5f6b294b --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainPage.xaml.cs @@ -0,0 +1,54 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ClassicWin32Host +{ + /// + /// Interaction logic for MainPage.xaml + /// + public partial class MainPage : Page + { + public MainPage() + { + InitializeComponent(); + + DataContext = AppData.ExtensionManager.Extensions; + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + Button btn = sender as Button; + Extension ext = btn.DataContext as Extension; + if (ext.Enabled) + { + string before = mainText.Text; + string after = ext.Lib.Func.EditText(before); + mainText.Text = after; + } + } + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml new file mode 100644 index 00000000..69ebc0af --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml.cs new file mode 100644 index 00000000..9ee3180b --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/MainWindow.xaml.cs @@ -0,0 +1,40 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System; +using System.Runtime.InteropServices; +using Windows.Storage; +using Windows.ApplicationModel; +using System.Windows; + +namespace ClassicWin32Host +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : System.Windows.Window + { + public MainWindow() + { + InitializeComponent(); + + AppData.ExtensionManager = new ExtensionManager("build.classicplugins.demo", this.Dispatcher); + + + // show this is a packaged WPF app! + myText.Text = "I am a packaged WPF app: " + Package.Current.Id.FullName; + + // This is for debug attaching before the program does anything meaningful. + //MessageBox.Show(Package.Current.Id.FullName); + } + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/AssemblyInfo.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..911365c6 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/AssemblyInfo.cs @@ -0,0 +1,67 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClassicWin32Host")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClassicWin32Host")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.Designer.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.Designer.cs new file mode 100644 index 00000000..009db6f2 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ClassicWin32Host.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ClassicWin32Host.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.resx b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.Designer.cs b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.Designer.cs new file mode 100644 index 00000000..72a97880 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ClassicWin32Host.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.settings b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.settings new file mode 100644 index 00000000..033d7a5e --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/ClassicWin32Host/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/UWPPackager.jsproj b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/UWPPackager.jsproj new file mode 100644 index 00000000..7e867ce5 --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/UWPPackager.jsproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + + + Debug + ARM + + + Debug + x64 + + + Debug + x86 + + + Release + AnyCPU + + + Release + ARM + true + + + Release + x64 + true + + + Release + x86 + true + + + + 30025e99-9590-406b-8450-06ed091080a2 + + + + 14.0 + + + + + UAP + 10.0.14393.0 + 10.0.14393.0 + $(VersionNumberMajor).$(VersionNumberMinor) + en-US + UWPPackager_TemporaryKey.pfx + False + Always + neutral + + + + Designer + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/LockScreenLogo.scale-200.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/LockScreenLogo.scale-200.png new file mode 100644 index 00000000..735f57ad Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/LockScreenLogo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/SplashScreen.scale-200.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/SplashScreen.scale-200.png new file mode 100644 index 00000000..0636b004 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/SplashScreen.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.scale-200.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..f49edde3 Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000..2980c9aa Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/StoreLogo.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/StoreLogo.png new file mode 100644 index 00000000..8c20b10d Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/StoreLogo.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Wide310x150Logo.scale-200.png b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..5b197d3e Binary files /dev/null and b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/images/Wide310x150Logo.scale-200.png differ diff --git a/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/package.appxmanifest b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/package.appxmanifest new file mode 100644 index 00000000..1896d81c --- /dev/null +++ b/Samples/NativePluginSample/DLLExtensionHost/UWPPackager/package.appxmanifest @@ -0,0 +1,40 @@ + + + + + + UWPPackager + Dave + images\storelogo.png + + + + + + + + + + + + + + + + + + build.classicplugins.demo + + + + + + + + + + \ No newline at end of file diff --git a/Samples/NativePluginSample/README.md b/Samples/NativePluginSample/README.md new file mode 100644 index 00000000..5da94bad --- /dev/null +++ b/Samples/NativePluginSample/README.md @@ -0,0 +1,8 @@ +This sample contains three apps: +1) A Host App, which has a plugin model (Extensions) that are native dlls. This app is a converted WPF app that utilizes the UWP AppExtension platform to implement the plugin model and allow the plugins to be delivered via UWP packages. +2) First plugin for the host app (packaged in C++ UWP). +3) Second plugin for the host app (packaged in C# UWP). + +The Plugins are two projects. The first project builds the native DLL, the second packages it into a UWP app for distribution. You must build the native DLL first, then build the UWP app. A postbuild step in the native DLL build will place the DLL into the project folder of the UWP packager. The actual UWP packager apps are very basic template apps which just have an AppExtension declaration in the App Manifest. These are normal UWP apps. + +The Plugin host is also two projects with the typical Desktop Bridge packager project and the original WPF C# app. The Plugin host uses AppExtensions to discover the other UWP packages that contain a plugin for it. Te host then copies the DLL from the AppExtension folder to its own local AppData folder. It always loads the DLLs from the local AppData folder. Only Desktop Bridge apps can load DLLs from local AppData. The Plugin host then uses events from the AppExtension API to be alerted of changes to the App Extensions so it knows when to unload the DLL, copy in a new one, and then reload the new updated DLL.