├── .gitignore ├── ExtensionsForOneDrive.sln ├── External ├── Microsoft.Live.dll └── Microsoft.Live.pdb ├── Install.bat ├── LICENSE ├── Package-Debug.bat ├── Package-Release.bat ├── README.md ├── Service ├── App.config ├── App.xaml ├── App.xaml.cs ├── Assets.Designer.cs ├── Assets.resx ├── Graphics │ └── Add.ico ├── LoginWindow.xaml ├── LoginWindow.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Messages.cs ├── Models │ ├── ClipboardService.cs │ ├── LiveService.cs │ ├── NotificationService.cs │ ├── RefreshTokenHandler.cs │ └── RegistryConfigurationService.cs ├── Properties │ └── AssemblyInfo.cs ├── Service.csproj ├── Service.sln ├── Utilities │ ├── Extensions.cs │ └── WebBrowserUtility.cs ├── ViewModels │ ├── LoginWindowViewModel.cs │ └── MainWindowViewModel.cs └── packages.config ├── Shell Extension ├── ContextMenuHandler.cpp ├── ContextMenuHandler.h ├── ContextMenuHandler.rgs ├── ExtensionBase.h ├── OverlayHandler.cpp ├── OverlayHandler.h ├── OverlayHandler.rgs ├── ShellExtension.aps ├── ShellExtension.sln ├── ShellExtension.vcxproj ├── ShellExtensionPS.vcxproj ├── ShellExtensionps.def ├── dlldata.c ├── dllmain.cpp ├── dllmain.h ├── icon1.ico ├── resource.h ├── shellext.aps ├── shellext.cpp ├── shellext.def ├── shellext.idl ├── shellext.rc ├── shellext.rgs ├── shellext_p.c ├── stdafx.cpp ├── stdafx.h └── targetver.h └── Uninstall.bat /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /ExtensionsForOneDrive.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shell Extension", "Shell Extension\ShellExtension.vcxproj", "{52269F85-9E85-4209-A1EE-CD6E9891B29C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service.csproj", "{5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{10DC4827-8EB7-4321-9F28-4DE2C508021C}" 11 | ProjectSection(SolutionItems) = preProject 12 | .nuget\NuGet.Config = .nuget\NuGet.Config 13 | .nuget\NuGet.exe = .nuget\NuGet.exe 14 | .nuget\NuGet.targets = .nuget\NuGet.targets 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Win32 = Debug|Win32 20 | Debug|x64 = Debug|x64 21 | Release|Win32 = Release|Win32 22 | Release|x64 = Release|x64 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|Win32.ActiveCfg = Debug|Win32 26 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|Win32.Build.0 = Debug|Win32 27 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|x64.ActiveCfg = Debug|x64 28 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|x64.Build.0 = Debug|x64 29 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|Win32.ActiveCfg = Release|Win32 30 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|Win32.Build.0 = Release|Win32 31 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|x64.ActiveCfg = Release|x64 32 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|x64.Build.0 = Release|x64 33 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|Win32.ActiveCfg = Debug|Any CPU 34 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|Win32.Build.0 = Debug|Any CPU 35 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|x64.ActiveCfg = Debug|Any CPU 36 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|x64.Build.0 = Debug|Any CPU 37 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|Win32.ActiveCfg = Release|Any CPU 38 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|Win32.Build.0 = Release|Any CPU 39 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|x64.ActiveCfg = Release|Any CPU 40 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|x64.Build.0 = Release|Any CPU 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /External/Microsoft.Live.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/External/Microsoft.Live.dll -------------------------------------------------------------------------------- /External/Microsoft.Live.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/External/Microsoft.Live.pdb -------------------------------------------------------------------------------- /Install.bat: -------------------------------------------------------------------------------- 1 | REM This is temporary. 2 | CLS 3 | 4 | SET PATH=%PATH%;%SystemRoot%\Microsoft.NET\Framework\v4.0.30319 5 | 6 | regsvr32 /s "%~dp0\ExtensionsForOneDrive.Shell.dll" 7 | ngen install "%~dp0\ExtensionsForOneDrive.Service.exe" /silent 8 | ngen install "%~dp0\GalaSoft.MvvmLight.Extras.WPF45.dll" /silent 9 | ngen install "%~dp0\GalaSoft.MvvmLight.WPF45.dll" /silent 10 | ngen install "%~dp0\Microsoft.Live.dll" /silent 11 | ngen install "%~dp0\Microsoft.Practices.ServiceLocation.dll" /silent 12 | ngen install "%~dp0\System.Windows.Interactivity.dll" /silent 13 | 14 | pause -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rafael Rivera 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Package-Debug.bat: -------------------------------------------------------------------------------- 1 | REM This is temporary. 2 | CLS 3 | 4 | cd build\debug\ 5 | rmdir /q /s package 6 | mkdir package 7 | copy *.dll package\ 8 | copy *.exe package\ 9 | copy ..\..\Install.bat package\ 10 | copy ..\..\Uninstall.bat package\ 11 | pause -------------------------------------------------------------------------------- /Package-Release.bat: -------------------------------------------------------------------------------- 1 | REM This is temporary. 2 | CLS 3 | 4 | cd build\release\ 5 | rmdir /q /s package 6 | mkdir package 7 | copy *.dll package\ 8 | copy *.exe package\ 9 | copy ..\..\Install.bat package\ 10 | copy ..\..\Uninstall.bat package\ 11 | pause -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Extensions for OneDrive 2 | 3 | ## About 4 | Extensions for OneDrive currently adds: 5 | 6 | * A "Copy OneDrive public link" context menu item 7 | * A shell icon overlay to indicate state of cloud->local sync 8 | 9 | ## Download 10 | 11 | See [Releases](https://github.com/riverar/ExtensionsForOneDrive/releases) for downloadable bits. 12 | 13 | ## Installation 14 | 15 | Place all bits into a permanent folder (e.g. `C:\Program Files\Extensions for OneDrive`) and execute `Install.bat` (as a user with administrative privileges). 16 | 17 | This will register the shell extension and [ngen](http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx) managed binaries for faster start up performance. 18 | 19 | Restart Windows (or the shell) for changes to take effect. 20 | 21 | ## Uninstallation 22 | 23 | Execute `Uninstall.bat` (again, as a user with administrative privileges). 24 | 25 | This will unregister the shell extension and remove any previously ngen'ed binaries. 26 | 27 | Restart Windows to ensure you can delete all bits from their permanent location. 28 | (You may instead resort to terminating and restarting all processes hosting the extension.) 29 | 30 | ## Looking to contribute? 31 | 32 | I welcome everyone to peruse the code and suggest changes where needed. 33 | 34 | In the short term, I'd like to: 35 | 36 | * Improve (un)installation workflow 37 | * Implement Clipboard-to-OneDrive to enable raw image data sharing scenarios 38 | * Add another overlay handler to indicate "in the cloud" state 39 | * Ideally by not eating another shell icon overlay slot 40 | * Clean up the service 41 | 42 | ## Support 43 | 44 | Please use the issue tracker to submit any problems you run into. More general questions and comments can be directed to me, [@WithinRafael](http://twitter.com/WithinRafael), on Twitter. 45 | 46 | ## Additional credits 47 | 48 | Icon: "Cloud" by Pieter J. Smits from The Noun Project 49 | http://thenounproject.com/term/cloud/6853/ 50 | -------------------------------------------------------------------------------- /Service/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Service/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Service/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Windows; 3 | using System.Threading.Tasks; 4 | 5 | using GalaSoft.MvvmLight.Ioc; 6 | using GalaSoft.MvvmLight.Messaging; 7 | 8 | using Microsoft.Live; 9 | using Microsoft.Live.Public; 10 | using Microsoft.Practices.ServiceLocation; 11 | 12 | using ExtensionsForOneDrive.Models; 13 | using ExtensionsForOneDrive.ViewModel; 14 | using ExtensionsForOneDrive.Service.Models; 15 | 16 | namespace ExtensionsForOneDrive 17 | { 18 | public partial class App : Application 19 | { 20 | private LoginWindow _loginWindow; 21 | private static Mutex _mutex; 22 | 23 | protected override void OnStartup(StartupEventArgs e) 24 | { 25 | base.OnStartup(e); 26 | 27 | RegisterProviders(); 28 | RegisterMutex(); 29 | 30 | ShowLoginWindowIfNeeded(); 31 | } 32 | 33 | private void ShowLoginWindowIfNeeded() 34 | { 35 | Messenger.Default.Register(this, (msg) => 36 | { 37 | _loginWindow.Close(); 38 | _loginWindow = null; 39 | 40 | if(msg.ContinueProcessing) 41 | { 42 | var clipboardService = ServiceLocator.Current.GetInstance(); 43 | clipboardService.GetPublicLinkAndStore(); 44 | } 45 | }); 46 | 47 | var configurationService = ServiceLocator.Current.GetInstance(); 48 | if(configurationService.GetValue("IsConfigured") == 0) 49 | { 50 | _loginWindow = new LoginWindow(); 51 | _loginWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; 52 | _loginWindow.ShowDialog(); 53 | } 54 | } 55 | 56 | private void RegisterMutex() 57 | { 58 | Task.Factory.StartNew(() => 59 | { 60 | _mutex = new Mutex(true, @"ExtensionsForOneDrive_Mutex"); 61 | _mutex.WaitOne(); 62 | }); 63 | } 64 | 65 | private void UnregisterMutex() 66 | { 67 | _mutex.Dispose(); 68 | } 69 | 70 | private void RegisterProviders() 71 | { 72 | SimpleIoc.Default.Register(); 73 | SimpleIoc.Default.Register(); 74 | SimpleIoc.Default.Register(); 75 | 76 | SimpleIoc.Default.Register(() => 77 | { 78 | return new LiveAuthClient("000000004011678D", SimpleIoc.Default.GetInstance()); 79 | }); 80 | 81 | SimpleIoc.Default.Register(() => 82 | { 83 | return SimpleIoc.Default.GetInstance(); 84 | }); 85 | 86 | SimpleIoc.Default.Register(true); 87 | SimpleIoc.Default.Register(true); 88 | SimpleIoc.Default.Register(true); 89 | 90 | ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); 91 | } 92 | 93 | protected override void OnExit(ExitEventArgs e) 94 | { 95 | base.OnExit(e); 96 | 97 | UnregisterMutex(); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Service/Assets.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ExtensionsForOneDrive.Service { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Assets { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Assets() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExtensionsForOneDrive.Service.Assets", typeof(Assets).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 65 | /// 66 | public static System.Drawing.Icon Cloud { 67 | get { 68 | object obj = ResourceManager.GetObject("Cloud", resourceCulture); 69 | return ((System.Drawing.Icon)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Service/Assets.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | Graphics\add.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Service/Graphics/Add.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Service/Graphics/Add.ico -------------------------------------------------------------------------------- /Service/LoginWindow.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Service/LoginWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | using GalaSoft.MvvmLight.Messaging; 4 | using ExtensionsForOneDrive.ViewModel; 5 | using Microsoft.Practices.ServiceLocation; 6 | 7 | namespace ExtensionsForOneDrive 8 | { 9 | public partial class LoginWindow : Window 10 | { 11 | public LoginWindow() 12 | { 13 | InitializeComponent(); 14 | 15 | this.DataContext = ServiceLocator.Current.GetInstance(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Service/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 14 | Next token refresh: 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Service/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using ExtensionsForOneDrive.Service; 2 | using Microsoft.Practices.ServiceLocation; 3 | using ExtensionsForOneDrive.ViewModel; 4 | using System.Windows; 5 | 6 | using ExtensionsForOneDrive.Service.Utilities; 7 | 8 | namespace ExtensionsForOneDrive 9 | { 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | 16 | this.DataContext = ServiceLocator.Current.GetInstance(); 17 | this.Icon = Assets.Cloud.ToImageSource(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Service/Messages.cs: -------------------------------------------------------------------------------- 1 | namespace ExtensionsForOneDrive 2 | { 3 | public class CloseLoginWindow 4 | { 5 | public CloseLoginWindow(bool continueProcessing) 6 | { 7 | this.ContinueProcessing = continueProcessing; 8 | } 9 | 10 | public bool ContinueProcessing { get; private set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Service/Models/ClipboardService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Threading; 4 | using System.Security.Principal; 5 | using System.Security.AccessControl; 6 | using System.Threading.Tasks; 7 | 8 | using ExtensionsForOneDrive.Service.Models; 9 | 10 | namespace ExtensionsForOneDrive.Models 11 | { 12 | // TODO: This entire class feels icky. 13 | 14 | public interface IClipboardService 15 | { 16 | void GetPublicLinkAndStore(); 17 | } 18 | 19 | public class ClipboardService : IClipboardService 20 | { 21 | private readonly IConfigurationService _configurationService; 22 | private readonly ILiveService _liveService; 23 | private readonly INotificationService _notificationService; 24 | 25 | private Task _changeListenerTask; 26 | 27 | public ClipboardService(IConfigurationService configurationService, ILiveService liveService, INotificationService notificationService) 28 | { 29 | _configurationService = configurationService; 30 | _liveService = liveService; 31 | _notificationService = notificationService; 32 | 33 | ConfigureDropListener(); 34 | } 35 | 36 | public void GetPublicLinkAndStore() 37 | { 38 | var link = _liveService.GetSharedReadLink(_configurationService.GetValue("Drop")); 39 | 40 | var clipboardThread = new Thread(() => { 41 | Clipboard.SetText(link); 42 | }); 43 | 44 | clipboardThread.SetApartmentState(ApartmentState.STA); 45 | clipboardThread.Start(); 46 | 47 | _notificationService.Notify(string.Format("Public link saved to clipboard:\n{0}", link)); 48 | } 49 | 50 | private void ConfigureDropListener() 51 | { 52 | var sid = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null); 53 | var accessRule = new EventWaitHandleAccessRule(sid, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, AccessControlType.Allow); 54 | 55 | var security = new EventWaitHandleSecurity(); 56 | security.AddAccessRule(accessRule); 57 | 58 | bool newlyCreated = false; 59 | var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "ExtensionsForOneDrive_DataAvailableEvent", out newlyCreated, security); 60 | 61 | if (!newlyCreated) 62 | { 63 | throw new InvalidOperationException("Configuration Changed event already exists."); 64 | } 65 | 66 | _changeListenerTask = Task.Factory.StartNew(() => 67 | { 68 | while (waitHandle.WaitOne()) 69 | { 70 | GetPublicLinkAndStore(); 71 | } 72 | }); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Service/Models/LiveService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Timers; 4 | using System.Collections.Generic; 5 | 6 | using Microsoft.Live; 7 | using Microsoft.Live.Public; 8 | 9 | namespace ExtensionsForOneDrive.Models 10 | { 11 | public interface ILiveService 12 | { 13 | bool IsAuthenticated { get; set; } 14 | 15 | string GetLoginUrl(); 16 | 17 | void GetTokens(string authorizationCode); 18 | 19 | string GetSharedReadLink(string fileID); 20 | } 21 | 22 | public class LiveService : ILiveService 23 | { 24 | private readonly ILiveAuthClient _authClient; 25 | private readonly IRefreshTokenHandler _refreshTokenHandler; 26 | private readonly IConfigurationService _configurationService; 27 | private readonly IEnumerable _scopes = new List { 28 | "wl.signin", "wl.offline_access", "wl.skydrive", "wl.skydrive_update" 29 | }; 30 | 31 | private LiveConnectSession _session; 32 | private Timer _refreshTimer; 33 | 34 | public LiveService(IRefreshTokenHandler refreshTokenHandler, ILiveAuthClient authClient, IConfigurationService configurationService) 35 | { 36 | _refreshTokenHandler = refreshTokenHandler; 37 | _configurationService = configurationService; 38 | _authClient = authClient; 39 | 40 | _refreshTimer = new Timer(); 41 | ConfigureRefreshTimer(); 42 | 43 | _configurationService.PropertyChanged += (_, args) => 44 | { 45 | if (args.PropertyName == "TokenExpiration") 46 | { 47 | ConfigureRefreshTimer(); 48 | } 49 | }; 50 | } 51 | 52 | private void ConfigureRefreshTimer() 53 | { 54 | _refreshTimer.Stop(); 55 | _refreshTimer.AutoReset = false; 56 | _refreshTimer.Elapsed += RefreshTimerElapsed; 57 | 58 | if(_configurationService.GetValue("Configured") > 0) 59 | { 60 | var expiration = DateTime.Parse(_configurationService.GetValue("TokenExpiration")); 61 | 62 | if (DateTime.Now < expiration) 63 | { 64 | var span = expiration - DateTime.Now; 65 | _refreshTimer.Interval = span.TotalMilliseconds; 66 | } 67 | else 68 | { 69 | _refreshTimer.Interval = TimeSpan.FromSeconds(3).TotalMilliseconds; 70 | } 71 | 72 | _refreshTimer.Start(); 73 | } 74 | } 75 | 76 | public bool IsAuthenticated { get; set; } 77 | 78 | public string GetLoginUrl() 79 | { 80 | return _authClient.GetLoginUrl(_scopes); 81 | } 82 | 83 | public void GetTokens(string authorizationCode) 84 | { 85 | var task = _authClient.ExchangeAuthCodeAsync(authorizationCode); 86 | task.Wait(); 87 | 88 | // TODO: Failure case 89 | 90 | _session = task.Result; 91 | 92 | SaveTokens(); 93 | 94 | this.IsAuthenticated = true; 95 | } 96 | 97 | private void RefreshTokens() 98 | { 99 | var task = _authClient.IntializeAsync(_scopes); 100 | task.Wait(); 101 | 102 | // TODO: Failure case 103 | 104 | // TODO: Lock session 105 | 106 | _session = task.Result.Session; 107 | 108 | SaveTokens(); 109 | 110 | this.IsAuthenticated = true; 111 | } 112 | 113 | private void SaveTokens() 114 | { 115 | _configurationService.SetValue("AccessToken", _session.AccessToken); 116 | _configurationService.SetValue("RefreshToken", _session.RefreshToken); 117 | _configurationService.SetValue("TokenExpiration", DateTime.Now.AddMinutes(45).ToString()); 118 | _configurationService.SetValue("IsConfigured", 1); 119 | } 120 | 121 | private void RefreshTimerElapsed(object sender, ElapsedEventArgs args) 122 | { 123 | this.RefreshTokens(); 124 | } 125 | 126 | public string GetSharedReadLink(string fileID) 127 | { 128 | if (string.IsNullOrWhiteSpace(fileID)) 129 | throw new ArgumentNullException("id"); 130 | 131 | var filePrefix = fileID.Split('!').First(); 132 | 133 | if (_session == null) 134 | { 135 | this.RefreshTokens(); 136 | } 137 | 138 | var connectClient = new LiveConnectClient(_session); 139 | var task = connectClient.GetAsync(string.Format("file.{0}.{1}/shared_read_link", filePrefix, fileID)); 140 | task.Wait(); 141 | 142 | // TODO: Error condition 143 | 144 | // HACK 145 | var result = task.Result.Result; 146 | return result["link"] as string; 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Service/Models/NotificationService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace ExtensionsForOneDrive.Service.Models 5 | { 6 | public interface INotificationService 7 | { 8 | void Notify(string message); 9 | } 10 | 11 | public class NotificationService : INotificationService 12 | { 13 | private readonly NotifyIcon _icon; 14 | 15 | public NotificationService() 16 | { 17 | _icon = new NotifyIcon(); 18 | _icon.Icon = Assets.Cloud; 19 | } 20 | 21 | public void Notify(string message) 22 | { 23 | _icon.Visible = true; 24 | 25 | _icon.ShowBalloonTip(3000, "Extensions for OneDrive", message, ToolTipIcon.Info); 26 | _icon.BalloonTipShown += (_, __) => 27 | { 28 | _icon.Visible = false; 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Service/Models/RefreshTokenHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.Live; 3 | using ExtensionsForOneDrive.Models; 4 | 5 | namespace ExtensionsForOneDrive 6 | { 7 | public class RegistryRefreshTokenHandler : IRefreshTokenHandler 8 | { 9 | private readonly IConfigurationService _configurationService; 10 | 11 | public RegistryRefreshTokenHandler(IConfigurationService configurationService) 12 | { 13 | _configurationService = configurationService; 14 | } 15 | 16 | public Task RetrieveRefreshTokenAsync() 17 | { 18 | return Task.Factory.StartNew(() => 19 | { 20 | var token = _configurationService.GetValue("RefreshToken"); 21 | 22 | if (!string.IsNullOrWhiteSpace(token)) 23 | { 24 | return new RefreshTokenInfo(token); 25 | } 26 | else 27 | { 28 | return null; 29 | } 30 | 31 | }); 32 | } 33 | 34 | public Task SaveRefreshTokenAsync(RefreshTokenInfo tokenInfo) 35 | { 36 | return Task.Factory.StartNew(() => 37 | { 38 | _configurationService.SetValue("RefreshToken", tokenInfo.RefreshToken); 39 | }); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Service/Models/RegistryConfigurationService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System.ComponentModel; 3 | 4 | namespace ExtensionsForOneDrive.Models 5 | { 6 | public interface IConfigurationService 7 | { 8 | T GetValue(string name); 9 | 10 | void SetValue(string name, object value); 11 | 12 | event PropertyChangedEventHandler PropertyChanged; 13 | } 14 | 15 | public class RegistryConfigurationService : IConfigurationService, INotifyPropertyChanged 16 | { 17 | private readonly string _registryRoot = @"Software\Rafael\ExtensionsForOneDrive"; 18 | 19 | public T GetValue(string name) 20 | { 21 | using (var root = Registry.CurrentUser.CreateSubKey(_registryRoot)) 22 | { 23 | var value = root.GetValue(name); 24 | 25 | if (value == null) 26 | return default(T); 27 | else 28 | return (T)value; 29 | } 30 | } 31 | 32 | public void SetValue(string name, object value) 33 | { 34 | using (var root = Registry.CurrentUser.CreateSubKey(_registryRoot)) 35 | { 36 | RegistryValueKind kind; 37 | 38 | if (value is short || value is int || value is long) 39 | kind = RegistryValueKind.DWord; 40 | else 41 | kind = RegistryValueKind.String; 42 | 43 | root.SetValue(name, value, kind); 44 | 45 | RaisePropertyChanged(name); 46 | } 47 | } 48 | 49 | public event PropertyChangedEventHandler PropertyChanged; 50 | 51 | protected void RaisePropertyChanged(string name) 52 | { 53 | PropertyChangedEventHandler handler = PropertyChanged; 54 | if (handler != null) 55 | { 56 | handler(this, new PropertyChangedEventArgs(name)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Service/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Windows; 3 | 4 | [assembly: AssemblyTitle("Extensions For OneDrive Service")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("")] 9 | [assembly: AssemblyCopyright("Copyright ©")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 13 | 14 | [assembly: AssemblyVersion("0.4.0.0")] 15 | [assembly: AssemblyFileVersion("0.4.0.0")] 16 | -------------------------------------------------------------------------------- /Service/Service.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC} 8 | WinExe 9 | Properties 10 | ExtensionsForOneDrive.Service 11 | ExtensionsForOneDrive.Service 12 | v4.5.1 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | publish\ 18 | true 19 | Disk 20 | false 21 | Foreground 22 | 7 23 | Days 24 | false 25 | false 26 | true 27 | 0 28 | 1.0.0.%2a 29 | false 30 | false 31 | true 32 | .pdb 33 | ..\ 34 | true 35 | 36 | 37 | AnyCPU 38 | true 39 | full 40 | false 41 | ..\Build\Debug\ 42 | DEBUG;TRACE 43 | prompt 44 | 4 45 | 46 | 47 | AnyCPU 48 | pdbonly 49 | true 50 | ..\Build\Release\ 51 | TRACE 52 | prompt 53 | 4 54 | 55 | 56 | 57 | ..\packages\MvvmLightLibs.4.2.30.0\lib\net45\GalaSoft.MvvmLight.Extras.WPF45.dll 58 | 59 | 60 | ..\packages\MvvmLightLibs.4.2.30.0\lib\net45\GalaSoft.MvvmLight.WPF45.dll 61 | 62 | 63 | ..\External\Microsoft.Live.dll 64 | 65 | 66 | ..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | ..\packages\MvvmLightLibs.4.2.30.0\lib\net45\System.Windows.Interactivity.dll 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 4.0 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | MSBuild:Compile 91 | Designer 92 | 93 | 94 | LoginWindow.xaml 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | True 104 | True 105 | Assets.resx 106 | 107 | 108 | 109 | 110 | 111 | Designer 112 | MSBuild:Compile 113 | 114 | 115 | App.xaml 116 | Code 117 | 118 | 119 | 120 | 121 | Code 122 | 123 | 124 | PublicResXFileCodeGenerator 125 | Assets.Designer.cs 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | False 136 | Microsoft .NET Framework 4.5.1 %28x86 and x64%29 137 | true 138 | 139 | 140 | False 141 | .NET Framework 3.5 SP1 Client Profile 142 | false 143 | 144 | 145 | False 146 | .NET Framework 3.5 SP1 147 | false 148 | 149 | 150 | 151 | 152 | 153 | 154 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 155 | 156 | 157 | 158 | 165 | -------------------------------------------------------------------------------- /Service/Service.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service.csproj", "{5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {5531EF6A-3B01-4191-A1D2-71BB07F8C5FC}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Service/Utilities/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Windows; 3 | using System.Windows.Interop; 4 | using System.Windows.Media; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace ExtensionsForOneDrive.Service.Utilities 8 | { 9 | public static class Extensions 10 | { 11 | public static ImageSource ToImageSource(this Icon icon) 12 | { 13 | return Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Service/Utilities/WebBrowserUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace ExtensionsForOneDrive.Utilities 6 | { 7 | public static class WebBrowserUtility 8 | { 9 | public static readonly DependencyProperty BindableSourceProperty = 10 | DependencyProperty.RegisterAttached("BindableSource", typeof(string), typeof(WebBrowserUtility), new UIPropertyMetadata(null, BindableSourcePropertyChanged)); 11 | 12 | public static string GetBindableSource(DependencyObject obj) 13 | { 14 | return (string)obj.GetValue(BindableSourceProperty); 15 | } 16 | 17 | public static void SetBindableSource(DependencyObject obj, string value) 18 | { 19 | obj.SetValue(BindableSourceProperty, value); 20 | } 21 | 22 | public static void BindableSourcePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) 23 | { 24 | var browser = o as WebBrowser; 25 | if (browser != null) 26 | { 27 | string uri = e.NewValue as string; 28 | browser.Source = string.IsNullOrEmpty(uri) ? null : new Uri(uri); 29 | } 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Service/ViewModels/LoginWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Windows.Navigation; 4 | 5 | using GalaSoft.MvvmLight; 6 | using GalaSoft.MvvmLight.Command; 7 | using GalaSoft.MvvmLight.Messaging; 8 | 9 | using ExtensionsForOneDrive.Models; 10 | 11 | namespace ExtensionsForOneDrive.ViewModel 12 | { 13 | public class LoginWindowViewModel : ViewModelBase 14 | { 15 | private readonly ILiveService _liveAuthService; 16 | private readonly IConfigurationService _configurationService; 17 | 18 | public LoginWindowViewModel(ILiveService liveAuthService, IConfigurationService configurationService) 19 | { 20 | if (liveAuthService == null) 21 | throw new ArgumentNullException("liveAuthService"); 22 | 23 | if (configurationService == null) 24 | throw new ArgumentNullException("configurationService"); 25 | 26 | _liveAuthService = liveAuthService; 27 | _configurationService = configurationService; 28 | 29 | Loaded = new RelayCommand(() => 30 | { 31 | var loginUrl = _liveAuthService.GetLoginUrl(); 32 | this.CurrentPage = new Uri(loginUrl, UriKind.Absolute); 33 | }); 34 | 35 | Navigated = new RelayCommand((args) => 36 | { 37 | if (args.Uri.AbsoluteUri.StartsWith("https://login.live.com/oauth20_desktop.srf")) 38 | { 39 | var continueProcessing = false; 40 | var parsedQueryParameters = HttpUtility.ParseQueryString(args.Uri.Query); 41 | var authorizationCode = parsedQueryParameters["code"]; 42 | 43 | if (authorizationCode != null) 44 | { 45 | _liveAuthService.GetTokens(authorizationCode); 46 | continueProcessing = true; 47 | } 48 | 49 | Messenger.Default.Send(new CloseLoginWindow(continueProcessing)); 50 | } 51 | }); 52 | } 53 | 54 | private Uri _currentPage; 55 | public Uri CurrentPage 56 | { 57 | get 58 | { 59 | return _currentPage; 60 | } 61 | 62 | set 63 | { 64 | _currentPage = value; 65 | RaisePropertyChanged("CurrentPage"); 66 | } 67 | } 68 | 69 | public RelayCommand Loaded { get; set; } 70 | 71 | public RelayCommand Navigated { get; set; } 72 | } 73 | } -------------------------------------------------------------------------------- /Service/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using GalaSoft.MvvmLight.Command; 3 | using GalaSoft.MvvmLight.Messaging; 4 | 5 | using ExtensionsForOneDrive.Models; 6 | 7 | namespace ExtensionsForOneDrive.ViewModel 8 | { 9 | public class MainWindowViewModel : ViewModelBase 10 | { 11 | private readonly IConfigurationService _configurationService; 12 | 13 | public MainWindowViewModel(IConfigurationService configurationService) 14 | { 15 | _configurationService = configurationService; 16 | 17 | OneDriveLoginCommand = new RelayCommand(() => 18 | { 19 | Messenger.Default.Send(new OpenLoginWindow()); 20 | }, 21 | () => 22 | { 23 | return _configurationService.GetValue("IsConfigured") == 0; 24 | }); 25 | 26 | SetNextRefresh(); 27 | 28 | _configurationService.PropertyChanged += (_, args) => 29 | { 30 | if (args.PropertyName == "TokenExpiration") 31 | { 32 | SetNextRefresh(); 33 | } 34 | }; 35 | } 36 | 37 | public RelayCommand OneDriveLoginCommand { get; set; } 38 | 39 | private string _nextRefresh; 40 | public string NextRefresh 41 | { 42 | get { return _nextRefresh; } 43 | set 44 | { 45 | _nextRefresh = value; 46 | RaisePropertyChanged("NextRefresh"); 47 | } 48 | } 49 | 50 | private void SetNextRefresh() 51 | { 52 | if (_configurationService.GetValue("IsConfigured") == 0) 53 | { 54 | this.NextRefresh = "(not configured)"; 55 | } 56 | else 57 | { 58 | this.NextRefresh = _configurationService.GetValue("TokenExpiration"); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Service/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Shell Extension/ContextMenuHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ContextMenuHandler.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | #define IS_FLAG_SET(val, flag) ((val & flag) == (flag)) 11 | #define IS_FLAG_CLEAR(val, flag) ((val & flag) == 0) 12 | 13 | CContextMenuHandler::CContextMenuHandler() : _fShowMenuItem(false) 14 | { 15 | } 16 | 17 | CContextMenuHandler::~CContextMenuHandler() 18 | { 19 | } 20 | 21 | IFACEMETHODIMP CContextMenuHandler::Initialize(PCIDLIST_ABSOLUTE /*pidlFolder*/, IDataObject *pdtobj, HKEY /*hkeyProgID*/) 22 | { 23 | this->_fShowMenuItem = false; 24 | 25 | HRESULT hr = EnsureOneDriveFolderCached(); 26 | if (SUCCEEDED(hr)) 27 | { 28 | CComPtr spShellItemArray; 29 | hr = SHCreateShellItemArrayFromDataObject(pdtobj, IID_PPV_ARGS(&spShellItemArray)); 30 | if (SUCCEEDED(hr)) 31 | { 32 | DWORD dwNumItems; 33 | hr = spShellItemArray->GetCount(&dwNumItems); 34 | if (SUCCEEDED(hr) && dwNumItems == 1) 35 | { 36 | CComPtr spShellItem; 37 | hr = spShellItemArray->GetItemAt(0, &spShellItem); 38 | if (SUCCEEDED(hr)) 39 | { 40 | CComHeapPtr spszDisplayName; 41 | hr = spShellItem->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &spszDisplayName); 42 | if (SUCCEEDED(hr)) 43 | { 44 | SFGAOF sfgaoAttributes; 45 | hr = spShellItem->GetAttributes(SFGAO_STREAM | SFGAO_FOLDER, &sfgaoAttributes); 46 | 47 | // Some dastardly shell items, like .zips, may have SFGAO_FOLDER set. 48 | // We use the SFGAO_STREAM to sniff those out. 49 | if (SUCCEEDED(hr) && 50 | (!IS_FLAG_SET(sfgaoAttributes, SFGAO_FOLDER) || 51 | (IS_FLAG_SET(sfgaoAttributes, SFGAO_FOLDER) && IS_FLAG_SET(sfgaoAttributes, SFGAO_STREAM)))) 52 | { 53 | size_t cchOneDriveFolderLength = wcslen(this->_spszCachedOneDriveFolder); 54 | size_t lengthOfTargetName = wcslen(spszDisplayName); 55 | 56 | if (lengthOfTargetName > cchOneDriveFolderLength && CompareStringOrdinal( 57 | this->_spszCachedOneDriveFolder, cchOneDriveFolderLength, spszDisplayName, cchOneDriveFolderLength, TRUE) == CSTR_EQUAL) 58 | { 59 | this->_spszTargetPath = spszDisplayName; 60 | this->_fShowMenuItem = true; 61 | } 62 | else 63 | { 64 | hr = S_FALSE; 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | return hr; 74 | } 75 | 76 | IFACEMETHODIMP CContextMenuHandler::GetCommandString(UINT_PTR /*idCmd*/, UINT /*uFlags*/, UINT * /*pwReserved*/, LPSTR /*pszName*/, UINT /*cchMax*/) 77 | { 78 | return E_NOTIMPL; 79 | } 80 | 81 | IFACEMETHODIMP CContextMenuHandler::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags) 82 | { 83 | HRESULT hr = S_OK; 84 | 85 | if (IS_FLAG_CLEAR(uFlags, CMF_DEFAULTONLY) && this->_fShowMenuItem) 86 | { 87 | UINT uFlags = MF_STRING | MF_BYPOSITION; 88 | 89 | if (InsertMenu(hMenu, indexMenu, uFlags, idCmdFirst, L"Copy public OneDrive &link")) 90 | { 91 | // Quirky return semantics 92 | // http://msdn.microsoft.com/en-us/library/windows/desktop/bb776097.aspx 93 | hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1); 94 | } 95 | else 96 | { 97 | hr = HRESULT_FROM_WIN32(GetLastError()); 98 | } 99 | } 100 | 101 | return hr; 102 | } 103 | 104 | IFACEMETHODIMP CContextMenuHandler::InvokeCommand(LPCMINVOKECOMMANDINFO pici) 105 | { 106 | HRESULT hr = E_FAIL; 107 | 108 | if (IS_INTRESOURCE(pici->lpVerb) && LOWORD(pici->lpVerb) == 0) 109 | { 110 | if (OpenClipboard(nullptr) && EmptyClipboard() && CloseClipboard()) 111 | { 112 | CComPtr spShellItem; 113 | hr = SHCreateItemFromParsingName(this->_spszTargetPath, NULL, IID_PPV_ARGS(&spShellItem)); 114 | if (SUCCEEDED(hr)) 115 | { 116 | CComPtr spPropertyStore; 117 | hr = spShellItem->GetPropertyStore(GPS_EXTRINSICPROPERTIES, IID_PPV_ARGS(&spPropertyStore)); 118 | if (SUCCEEDED(hr)) 119 | { 120 | PROPVARIANT pvFileIdentifier; 121 | PropVariantInit(&pvFileIdentifier); 122 | hr = spPropertyStore->GetValue(PKEY_StorageProviderFileIdentifier, &pvFileIdentifier); 123 | if (SUCCEEDED(hr)) 124 | { 125 | hr = HandoffToService(pvFileIdentifier.pwszVal); 126 | PropVariantClear(&pvFileIdentifier); 127 | } 128 | } 129 | } 130 | } 131 | } 132 | else 133 | { 134 | hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); 135 | } 136 | 137 | return hr; 138 | } 139 | 140 | bool CContextMenuHandler::IsServiceRunning() 141 | { 142 | bool fRunning = false; 143 | 144 | HANDLE hMutex = OpenMutex(SYNCHRONIZE, FALSE, L"ExtensionsForOneDrive_Mutex"); 145 | if (hMutex != nullptr) 146 | { 147 | fRunning = true; 148 | CloseHandle(hMutex); 149 | } 150 | 151 | return fRunning; 152 | } 153 | 154 | HRESULT CContextMenuHandler::HandoffToService(LPCWSTR pwszFileIdentifier) 155 | { 156 | size_t cbFileIdentifier; 157 | HRESULT hr = StringCbLength(pwszFileIdentifier, sizeof(wchar_t) * MAX_PATH, &cbFileIdentifier); 158 | if (SUCCEEDED(hr)) 159 | { 160 | hr = HRESULT_FROM_WIN32(RegSetKeyValue(HKEY_CURRENT_USER, L"Software\\Rafael\\ExtensionsForOneDrive", L"Drop", REG_SZ, pwszFileIdentifier, cbFileIdentifier)); 161 | if (SUCCEEDED(hr)) 162 | { 163 | if (!CContextMenuHandler::IsServiceRunning()) 164 | { 165 | LPTHREAD_START_ROUTINE lpThreadStart = [](LPVOID) -> DWORD 166 | { 167 | HRESULT hr = CContextMenuHandler::StartHelperService(); 168 | if (SUCCEEDED(hr)) 169 | { 170 | hr = HRESULT_FROM_WIN32(ERROR_TIMEOUT); 171 | for (int i = 0; i < 10; i++) 172 | { 173 | if (CContextMenuHandler::IsServiceRunning()) 174 | { 175 | hr = SignalDataAvailable(); 176 | break; 177 | } 178 | Sleep(1000); 179 | } 180 | } 181 | return 0; 182 | }; 183 | 184 | if (SHCreateThread(lpThreadStart, nullptr, 0, nullptr)) 185 | { 186 | hr = S_OK; 187 | } 188 | else 189 | { 190 | hr = HRESULT_FROM_WIN32(GetLastError()); 191 | } 192 | } 193 | else 194 | { 195 | hr = SignalDataAvailable(); 196 | } 197 | } 198 | } 199 | 200 | return hr; 201 | } 202 | 203 | HRESULT CContextMenuHandler::StartHelperService() 204 | { 205 | HRESULT hr = S_OK; 206 | 207 | if (!IsServiceRunning()) 208 | { 209 | CComHeapPtr spszServicePath; 210 | hr = GetServiceExecutablePath(&spszServicePath); 211 | if (SUCCEEDED(hr)) 212 | { 213 | HINSTANCE hInstance = ShellExecuteW(nullptr, L"open", spszServicePath, nullptr, nullptr, SW_SHOWDEFAULT); 214 | if (reinterpret_cast(hInstance) <= 32) 215 | { 216 | hr = E_FAIL; 217 | } 218 | } 219 | } 220 | 221 | return hr; 222 | } 223 | 224 | HRESULT CContextMenuHandler::SignalDataAvailable() 225 | { 226 | HRESULT hr = E_FAIL; 227 | 228 | HANDLE hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, L"ExtensionsForOneDrive_DataAvailableEvent"); 229 | if (hEvent != NULL) 230 | { 231 | if (SetEvent(hEvent) == TRUE) 232 | { 233 | hr = S_OK; 234 | } 235 | 236 | CloseHandle(hEvent); 237 | } 238 | else 239 | { 240 | hr = HRESULT_FROM_WIN32(GetLastError()); 241 | } 242 | 243 | return hr; 244 | } 245 | 246 | HRESULT CContextMenuHandler::GetServiceExecutablePath(LPWSTR* ppszServiceExecutablePath) 247 | { 248 | *ppszServiceExecutablePath = nullptr; 249 | 250 | HKEY hkInproc; 251 | 252 | HRESULT hr = HRESULT_FROM_WIN32(RegOpenKey(HKEY_CLASSES_ROOT, L"CLSID\\{98BEF305-AD58-410A-9864-93ED872F8549}\\InprocServer32", &hkInproc)); 253 | if (SUCCEEDED(hr)) 254 | { 255 | wchar_t szLibPath[MAX_PATH]; 256 | long cchLibPath = ARRAYSIZE(szLibPath); 257 | long cbLibPath = sizeof(szLibPath[0]) * cchLibPath; 258 | 259 | hr = HRESULT_FROM_WIN32(RegQueryValueW(hkInproc, nullptr, szLibPath, &cbLibPath)); 260 | if (SUCCEEDED(hr)) 261 | { 262 | hr = PathCchRemoveFileSpec(szLibPath, cchLibPath); 263 | if (SUCCEEDED(hr)) 264 | { 265 | hr = PathCchAppend(szLibPath, ARRAYSIZE(szLibPath), L"ExtensionsForOneDrive.Service.exe"); 266 | if (SUCCEEDED(hr)) 267 | { 268 | hr = SHStrDup(szLibPath, ppszServiceExecutablePath); 269 | } 270 | } 271 | } 272 | } 273 | 274 | return hr; 275 | } -------------------------------------------------------------------------------- /Shell Extension/ContextMenuHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | #include "shellext_i.h" 7 | #include "ExtensionBase.h" 8 | 9 | using namespace std; 10 | using namespace ATL; 11 | 12 | class ATL_NO_VTABLE CContextMenuHandler : 13 | public CExtensionBase, 14 | public CComObjectRootEx, 15 | public CComCoClass, 16 | public IShellExtInit, 17 | public IContextMenu 18 | { 19 | public: 20 | CContextMenuHandler(); 21 | ~CContextMenuHandler(); 22 | 23 | DECLARE_REGISTRY_RESOURCEID(IDR_CONTEXTMENUHANDLER) 24 | 25 | DECLARE_NOT_AGGREGATABLE(CContextMenuHandler) 26 | 27 | BEGIN_COM_MAP(CContextMenuHandler) 28 | COM_INTERFACE_ENTRY(IShellExtInit) 29 | COM_INTERFACE_ENTRY(IContextMenu) 30 | END_COM_MAP() 31 | 32 | DECLARE_PROTECT_FINAL_CONSTRUCT() 33 | 34 | // IShellExtInit 35 | IFACEMETHODIMP Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID); 36 | 37 | // IContextMenu 38 | IFACEMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); 39 | IFACEMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); 40 | IFACEMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO pici); 41 | 42 | private: 43 | HRESULT HandoffToService(LPCWSTR pwszIdentifier); 44 | 45 | static HRESULT GetServiceExecutablePath(LPWSTR* ppszServiceExecutablePath); 46 | static bool IsServiceRunning(); 47 | static HRESULT StartHelperService(); 48 | static HRESULT SignalDataAvailable(); 49 | 50 | bool _fShowMenuItem; 51 | CComHeapPtr _spszTargetPath; 52 | }; 53 | 54 | OBJECT_ENTRY_AUTO(__uuidof(ContextMenuHandler), CContextMenuHandler) 55 | -------------------------------------------------------------------------------- /Shell Extension/ContextMenuHandler.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | NoRemove CLSID 4 | { 5 | ForceRemove {98BEF305-AD58-410A-9864-93ED872F8549} = s 'Extensions for OneDrive Context Menu Handler' 6 | { 7 | val ContextMenuOptIn = s 'http://twitter.com/WithinRafael' 8 | InprocServer32 = s '%MODULE%' 9 | { 10 | val ThreadingModel = s 'Apartment' 11 | } 12 | TypeLib = s '{89676DD9-9BB1-40B6-8764-D3665A0494C3}' 13 | Version = s '1.0' 14 | } 15 | } 16 | } 17 | 18 | HKCR 19 | { 20 | NoRemove AllFilesystemObjects 21 | { 22 | NoRemove ShellEx 23 | { 24 | NoRemove ContextMenuHandlers 25 | { 26 | ForceRemove ExtensionsForOneDrive = s '{98BEF305-AD58-410A-9864-93ED872F8549}' 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Shell Extension/ExtensionBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using namespace ATL; 4 | 5 | class CExtensionBase 6 | { 7 | public: 8 | CExtensionBase() 9 | { 10 | InitializeCriticalSection(&this->_cs); 11 | } 12 | 13 | ~CExtensionBase() 14 | { 15 | DeleteCriticalSection(&this->_cs); 16 | } 17 | 18 | HRESULT EnsureOneDriveFolderCached() 19 | { 20 | HRESULT hr = S_OK; 21 | 22 | if (this->_spszCachedOneDriveFolder == nullptr) 23 | { 24 | CComHeapPtr spszLocatedOneDriveFolder; 25 | 26 | hr = SHGetKnownFolderPath(FOLDERID_SkyDrive, KF_FLAG_DONT_VERIFY | KF_FLAG_NO_ALIAS, nullptr, &spszLocatedOneDriveFolder); 27 | if (SUCCEEDED(hr)) 28 | { 29 | EnterCriticalSection(&this->_cs); 30 | 31 | if (this->_spszCachedOneDriveFolder == nullptr) 32 | { 33 | this->_spszCachedOneDriveFolder = spszLocatedOneDriveFolder; 34 | } 35 | 36 | LeaveCriticalSection(&this->_cs); 37 | } 38 | } 39 | 40 | return hr; 41 | } 42 | 43 | CComHeapPtr _spszCachedOneDriveFolder; 44 | CRITICAL_SECTION _cs; 45 | }; -------------------------------------------------------------------------------- /Shell Extension/OverlayHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "OverlayHandler.h" 8 | 9 | using namespace std; 10 | 11 | COverlayHandler::COverlayHandler() 12 | { 13 | } 14 | 15 | HRESULT COverlayHandler::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int* /*pIndex*/, DWORD* pdwFlags) 16 | { 17 | *pdwFlags = ISIOI_ICONFILE; 18 | HRESULT hr = S_OK; 19 | 20 | int cbCopied = GetModuleFileName(_AtlBaseModule.GetModuleInstance(), pwszIconFile, cchMax); 21 | if (cbCopied <= 0) 22 | { 23 | hr = HRESULT_FROM_WIN32(GetLastError()); 24 | } 25 | 26 | return hr; 27 | } 28 | 29 | HRESULT COverlayHandler::GetPriority(int* pPriority) 30 | { 31 | *pPriority = 0; 32 | 33 | return S_OK; 34 | } 35 | 36 | HRESULT COverlayHandler::IsMemberOf(PCWSTR pwszPath, DWORD /*dwAttrib*/) 37 | { 38 | HRESULT hr = EnsureOneDriveFolderCached(); 39 | if (SUCCEEDED(hr)) 40 | { 41 | hr = S_FALSE; 42 | 43 | wstring spszPath(pwszPath); 44 | if (spszPath.length() > 0 && 45 | spszPath.find(this->_spszCachedOneDriveFolder) != string::npos && 46 | CompareStringOrdinal(pwszPath, -1, this->_spszCachedOneDriveFolder, -1, TRUE) != CSTR_EQUAL) 47 | { 48 | CComPtr spShellItem; 49 | hr = SHCreateItemFromParsingName(pwszPath, nullptr, IID_PPV_ARGS(&spShellItem)); 50 | if (SUCCEEDED(hr)) 51 | { 52 | ULONG ulStatus = 0; 53 | hr = spShellItem->GetUInt32(PKEY_FilePlaceholderStatus, &ulStatus); 54 | if (SUCCEEDED(hr)) 55 | { 56 | if (ulStatus == 7) 57 | { 58 | hr = S_OK; 59 | } 60 | else 61 | { 62 | hr = S_FALSE; 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | if (FAILED(hr)) 70 | { 71 | hr = E_FAIL; 72 | } 73 | 74 | // S_OK The icon overlay should be displayed. 75 | // S_FALSE The icon overlay should not be displayed. 76 | // E_FAIL The operation failed. 77 | 78 | return hr; 79 | } -------------------------------------------------------------------------------- /Shell Extension/OverlayHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | 5 | #include 6 | #include 7 | 8 | #include "shellext_i.h" 9 | #include "ExtensionBase.h" 10 | 11 | using namespace std; 12 | using namespace ATL; 13 | 14 | class ATL_NO_VTABLE COverlayHandler : 15 | public CExtensionBase, 16 | public CComObjectRootEx, 17 | public CComCoClass, 18 | public IShellIconOverlayIdentifier 19 | { 20 | public: 21 | COverlayHandler(); 22 | 23 | DECLARE_REGISTRY_RESOURCEID(IDR_OVERLAYHANDLER) 24 | 25 | DECLARE_NOT_AGGREGATABLE(COverlayHandler) 26 | 27 | BEGIN_COM_MAP(COverlayHandler) 28 | COM_INTERFACE_ENTRY(IShellIconOverlayIdentifier) 29 | END_COM_MAP() 30 | 31 | DECLARE_PROTECT_FINAL_CONSTRUCT() 32 | 33 | // IShellIconOverlayIdentifier 34 | IFACEMETHODIMP GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int* pIndex, DWORD* pdwFlags); 35 | IFACEMETHODIMP GetPriority(int* pPriority); 36 | IFACEMETHODIMP IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib); 37 | }; 38 | 39 | OBJECT_ENTRY_AUTO(__uuidof(OverlayHandler), COverlayHandler) -------------------------------------------------------------------------------- /Shell Extension/OverlayHandler.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | NoRemove CLSID 4 | { 5 | ForceRemove {47B595FA-1976-44A5-9D10-2F2BD069BA4A} = s 'Extensions for OneDrive Overlay Handler' 6 | { 7 | InprocServer32 = s '%MODULE%' 8 | { 9 | val ThreadingModel = s 'Apartment' 10 | } 11 | TypeLib = s '{89676DD9-9BB1-40B6-8764-D3665A0494C3}' 12 | Version = s '1.0' 13 | } 14 | } 15 | } 16 | 17 | HKLM 18 | { 19 | NoRemove SOFTWARE 20 | { 21 | NoRemove Microsoft 22 | { 23 | NoRemove Windows 24 | { 25 | NoRemove CurrentVersion 26 | { 27 | NoRemove Explorer 28 | { 29 | NoRemove ShellIconOverlayIdentifiers 30 | { 31 | ForceRemove 000_ExtensionsForOneDrive = s '{47B595FA-1976-44A5-9D10-2F2BD069BA4A}' 32 | { 33 | 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Shell Extension/ShellExtension.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Shell Extension/ShellExtension.aps -------------------------------------------------------------------------------- /Shell Extension/ShellExtension.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLProject3", "ShellExtension.vcxproj", "{52269F85-9E85-4209-A1EE-CD6E9891B29C}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLProject3PS", "ShellExtensionPS.vcxproj", "{DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {52269F85-9E85-4209-A1EE-CD6E9891B29C} = {52269F85-9E85-4209-A1EE-CD6E9891B29C} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|Win32.Build.0 = Debug|Win32 23 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|x64.ActiveCfg = Debug|x64 24 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Debug|x64.Build.0 = Debug|x64 25 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|Win32.ActiveCfg = Release|Win32 26 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|Win32.Build.0 = Release|Win32 27 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|x64.ActiveCfg = Release|x64 28 | {52269F85-9E85-4209-A1EE-CD6E9891B29C}.Release|x64.Build.0 = Release|x64 29 | {DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE}.Debug|x64.ActiveCfg = Debug|x64 31 | {DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE}.Release|Win32.ActiveCfg = Release|Win32 32 | {DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE}.Release|x64.ActiveCfg = Release|x64 33 | EndGlobalSection 34 | GlobalSection(SolutionProperties) = preSolution 35 | HideSolutionNode = FALSE 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Shell Extension/ShellExtension.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {52269F85-9E85-4209-A1EE-CD6E9891B29C} 23 | AtlProj 24 | Shell Extension 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | Unicode 44 | 45 | 46 | DynamicLibrary 47 | false 48 | v120 49 | Unicode 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | true 70 | $(SolutionDir)Build\$(Configuration)\ 71 | $(SolutionDir)Build\$(Configuration)\int\ 72 | ExtensionsForOneDrive.Shell 73 | 74 | 75 | true 76 | true 77 | $(SolutionDir)Build\$(Configuration)\ 78 | $(SolutionDir)Build\$(Configuration)\int\ 79 | ExtensionsForOneDrive.Shell 80 | 81 | 82 | true 83 | false 84 | $(SolutionDir)Build\$(Configuration)\ 85 | $(SolutionDir)Build\$(Configuration)\int\ 86 | ExtensionsForOneDrive.Shell 87 | 88 | 89 | true 90 | false 91 | $(SolutionDir)Build\$(Configuration)\ 92 | $(SolutionDir)Build\$(Configuration)\int\ 93 | ExtensionsForOneDrive.Shell 94 | 95 | 96 | 97 | NotUsing 98 | Level4 99 | Disabled 100 | WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) 101 | true 102 | 103 | 104 | 105 | 106 | false 107 | Win32 108 | _DEBUG;%(PreprocessorDefinitions) 109 | shellext_i.h 110 | shellext_i.c 111 | shellext_p.c 112 | true 113 | $(IntDir)shellext.tlb 114 | 115 | true 116 | 117 | 118 | 0x0409 119 | $(IntDir);%(AdditionalIncludeDirectories) 120 | _DEBUG;%(PreprocessorDefinitions) 121 | 122 | 123 | Windows 124 | .\shellext.def 125 | true 126 | false 127 | $(OutDir)$(TargetName)$(TargetExt) 128 | Pathcch.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 129 | 130 | 131 | 132 | 133 | NotUsing 134 | Level4 135 | Disabled 136 | WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) 137 | true 138 | 139 | 140 | 141 | 142 | false 143 | _DEBUG;%(PreprocessorDefinitions) 144 | shellext_i.h 145 | shellext_i.c 146 | shellext_p.c 147 | true 148 | $(IntDir)shellext.tlb 149 | 150 | 151 | 152 | 153 | 0x0409 154 | $(IntDir);%(AdditionalIncludeDirectories) 155 | _DEBUG;%(PreprocessorDefinitions) 156 | 157 | 158 | Windows 159 | .\shellext.def 160 | true 161 | false 162 | $(OutDir)$(TargetName)$(TargetExt) 163 | Pathcch.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level4 170 | MaxSpeed 171 | WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) 172 | true 173 | 174 | 175 | 176 | 177 | false 178 | Win32 179 | NDEBUG;%(PreprocessorDefinitions) 180 | shellext_i.h 181 | shellext_i.c 182 | shellext_p.c 183 | true 184 | $(IntDir)shellext.tlb 185 | 186 | true 187 | 188 | 189 | 0x0409 190 | $(IntDir);%(AdditionalIncludeDirectories) 191 | NDEBUG;%(PreprocessorDefinitions) 192 | 193 | 194 | Windows 195 | .\shellext.def 196 | true 197 | true 198 | true 199 | false 200 | $(OutDir)$(TargetName)$(TargetExt) 201 | Pathcch.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 202 | 203 | 204 | 205 | 206 | NotUsing 207 | Level4 208 | MaxSpeed 209 | WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) 210 | true 211 | 212 | 213 | 214 | 215 | false 216 | NDEBUG;%(PreprocessorDefinitions) 217 | shellext_i.h 218 | shellext_i.c 219 | shellext_p.c 220 | true 221 | $(IntDir)shellext.tlb 222 | 223 | 224 | 225 | 226 | 0x0409 227 | $(IntDir);%(AdditionalIncludeDirectories) 228 | NDEBUG;%(PreprocessorDefinitions) 229 | 230 | 231 | Windows 232 | .\shellext.def 233 | true 234 | true 235 | true 236 | false 237 | $(OutDir)$(TargetName)$(TargetExt) 238 | Pathcch.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 239 | 240 | 241 | 242 | 243 | 244 | 245 | false 246 | false 247 | 248 | 249 | 250 | 251 | false 252 | false 253 | 254 | 255 | 256 | 257 | 258 | 259 | false 260 | false 261 | 262 | 263 | 264 | 265 | false 266 | false 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | Create 275 | Create 276 | Create 277 | Create 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | -------------------------------------------------------------------------------- /Shell Extension/ShellExtensionPS.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {DEDBC126-A8E1-4CED-8D00-E3AD5128F4EE} 23 | AtlPSProj 24 | 25 | 26 | 27 | DynamicLibrary 28 | true 29 | v120 30 | Unicode 31 | 32 | 33 | DynamicLibrary 34 | true 35 | v120 36 | Unicode 37 | 38 | 39 | DynamicLibrary 40 | false 41 | v120 42 | Unicode 43 | 44 | 45 | DynamicLibrary 46 | false 47 | v120 48 | Unicode 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | $(Configuration)PS\ 68 | 69 | 70 | 71 | $(Configuration)PS\ 72 | 73 | 74 | 75 | 76 | WIN32;REGISTER_PROXY_DLL;_DEBUG;%(PreprocessorDefinitions) 77 | 78 | 79 | kernel32.lib;rpcns4.lib;rpcrt4.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) 80 | ATLProject3PS.def 81 | true 82 | 83 | 84 | if exist dlldata.c goto :END 85 | echo Error: MIDL will not generate DLLDATA.C unless you have at least 1 interface in the main project. 86 | Exit 1 87 | :END 88 | 89 | Checking for required files 90 | 91 | 92 | 93 | 94 | WIN32;REGISTER_PROXY_DLL;_DEBUG;%(PreprocessorDefinitions) 95 | 96 | 97 | kernel32.lib;rpcns4.lib;rpcrt4.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) 98 | ATLProject3PS.def 99 | true 100 | 101 | 102 | if exist dlldata.c goto :END 103 | echo Error: MIDL will not generate DLLDATA.C unless you have at least 1 interface in the main project. 104 | Exit 1 105 | :END 106 | 107 | Checking for required files 108 | 109 | 110 | 111 | 112 | MaxSpeed 113 | WIN32;REGISTER_PROXY_DLL;NDEBUG;%(PreprocessorDefinitions) 114 | 115 | 116 | kernel32.lib;rpcns4.lib;rpcrt4.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) 117 | ATLProject3PS.def 118 | true 119 | true 120 | true 121 | 122 | 123 | if exist dlldata.c goto :END 124 | echo Error: MIDL will not generate DLLDATA.C unless you have at least 1 interface in the main project. 125 | Exit 1 126 | :END 127 | 128 | Checking for required files 129 | 130 | 131 | 132 | 133 | MaxSpeed 134 | WIN32;REGISTER_PROXY_DLL;NDEBUG;%(PreprocessorDefinitions) 135 | 136 | 137 | kernel32.lib;rpcns4.lib;rpcrt4.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) 138 | ATLProject3PS.def 139 | true 140 | true 141 | true 142 | 143 | 144 | if exist dlldata.c goto :END 145 | echo Error: MIDL will not generate DLLDATA.C unless you have at least 1 interface in the main project. 146 | Exit 1 147 | :END 148 | 149 | Checking for required files 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /Shell Extension/ShellExtensionps.def: -------------------------------------------------------------------------------- 1 | 2 | LIBRARY 3 | 4 | EXPORTS 5 | DllGetClassObject PRIVATE 6 | DllCanUnloadNow PRIVATE 7 | DllRegisterServer PRIVATE 8 | DllUnregisterServer PRIVATE 9 | -------------------------------------------------------------------------------- /Shell Extension/dlldata.c: -------------------------------------------------------------------------------- 1 | /********************************************************* 2 | DllData file -- generated by MIDL compiler 3 | 4 | DO NOT ALTER THIS FILE 5 | 6 | This file is regenerated by MIDL on every IDL file compile. 7 | 8 | To completely reconstruct this file, delete it and rerun MIDL 9 | on all the IDL files in this DLL, specifying this file for the 10 | /dlldata command line option 11 | 12 | *********************************************************/ 13 | 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | EXTERN_PROXY_FILE( ATLProject3 ) 22 | EXTERN_PROXY_FILE( shellext ) 23 | 24 | 25 | PROXYFILE_LIST_START 26 | /* Start of list */ 27 | REFERENCE_PROXY_FILE( ATLProject3 ), 28 | REFERENCE_PROXY_FILE( shellext ), 29 | /* End of list */ 30 | PROXYFILE_LIST_END 31 | 32 | 33 | DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID ) 34 | 35 | #ifdef __cplusplus 36 | } /*extern "C" */ 37 | #endif 38 | 39 | /* end of generated dlldata file */ 40 | -------------------------------------------------------------------------------- /Shell Extension/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "resource.h" 3 | #include "shellext_i.h" 4 | #include "dllmain.h" 5 | 6 | CShellExtModule _AtlModule; 7 | 8 | extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID lpReserved) 9 | { 10 | return _AtlModule.DllMain(dwReason, lpReserved); 11 | } -------------------------------------------------------------------------------- /Shell Extension/dllmain.h: -------------------------------------------------------------------------------- 1 | class CShellExtModule : public ATL::CAtlDllModuleT 2 | { 3 | public : 4 | DECLARE_LIBID(LIBID_shellextLib) 5 | }; 6 | 7 | extern class CShellExtModule _AtlModule; -------------------------------------------------------------------------------- /Shell Extension/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Shell Extension/icon1.ico -------------------------------------------------------------------------------- /Shell Extension/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Shell Extension/resource.h -------------------------------------------------------------------------------- /Shell Extension/shellext.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Shell Extension/shellext.aps -------------------------------------------------------------------------------- /Shell Extension/shellext.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "resource.h" 3 | #include "shellext_i.h" 4 | #include "dllmain.h" 5 | 6 | using namespace ATL; 7 | 8 | STDAPI DllCanUnloadNow(void) 9 | { 10 | return _AtlModule.DllCanUnloadNow(); 11 | } 12 | 13 | STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) 14 | { 15 | return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 16 | } 17 | 18 | STDAPI DllRegisterServer(void) 19 | { 20 | return _AtlModule.DllRegisterServer(); 21 | } 22 | 23 | STDAPI DllUnregisterServer(void) 24 | { 25 | return _AtlModule.DllUnregisterServer(); 26 | } 27 | 28 | STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine) 29 | { 30 | HRESULT hr = E_FAIL; 31 | static const wchar_t szUserSwitch[] = L"user"; 32 | 33 | if (pszCmdLine != NULL) 34 | { 35 | if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) 36 | { 37 | ATL::AtlSetPerUserRegistration(true); 38 | } 39 | } 40 | 41 | if (bInstall) 42 | { 43 | hr = DllRegisterServer(); 44 | if (FAILED(hr)) 45 | { 46 | DllUnregisterServer(); 47 | } 48 | } 49 | else 50 | { 51 | hr = DllUnregisterServer(); 52 | } 53 | 54 | return hr; 55 | } -------------------------------------------------------------------------------- /Shell Extension/shellext.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | 3 | EXPORTS 4 | DllCanUnloadNow PRIVATE 5 | DllGetClassObject PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | DllInstall PRIVATE 9 | -------------------------------------------------------------------------------- /Shell Extension/shellext.idl: -------------------------------------------------------------------------------- 1 | import "oaidl.idl"; 2 | import "ocidl.idl"; 3 | import "shobjidl.idl"; 4 | 5 | [version(1.0), uuid(89676DD9-9BB1-40B6-8764-D3665A0494C3)] 6 | library shellextLib 7 | { 8 | importlib("stdole2.tlb"); 9 | 10 | [uuid(47B595FA-1976-44A5-9D10-2F2BD069BA4A)] 11 | coclass OverlayHandler 12 | { 13 | [default] interface IUnknown; 14 | }; 15 | 16 | [uuid(98BEF305-AD58-410A-9864-93ED872F8549)] 17 | coclass ContextMenuHandler 18 | { 19 | [default] interface IContextMenu; 20 | }; 21 | }; -------------------------------------------------------------------------------- /Shell Extension/shellext.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riverar/ExtensionsForOneDrive/74edde0c80b8cc9e030f451f99dbb7e3fb1b55d5/Shell Extension/shellext.rc -------------------------------------------------------------------------------- /Shell Extension/shellext.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /Shell Extension/shellext_p.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* this ALWAYS GENERATED file contains the proxy stub code */ 4 | 5 | 6 | /* File created by MIDL compiler version 8.00.0603 */ 7 | /* at Wed Mar 26 00:30:35 2014 8 | */ 9 | /* Compiler settings for shellext.idl: 10 | Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603 11 | protocol : dce , ms_ext, c_ext, robust 12 | error checks: allocation ref bounds_check enum stub_data 13 | VC __declspec() decoration level: 14 | __declspec(uuid()), __declspec(selectany), __declspec(novtable) 15 | DECLSPEC_UUID(), MIDL_INTERFACE() 16 | */ 17 | /* @@MIDL_FILE_HEADING( ) */ 18 | 19 | #if defined(_M_AMD64) 20 | 21 | 22 | #pragma warning( disable: 4049 ) /* more than 64k source lines */ 23 | #if _MSC_VER >= 1200 24 | #pragma warning(push) 25 | #endif 26 | 27 | #pragma warning( disable: 4211 ) /* redefine extern to static */ 28 | #pragma warning( disable: 4232 ) /* dllimport identity*/ 29 | #pragma warning( disable: 4024 ) /* array to pointer mapping*/ 30 | #pragma warning( disable: 4152 ) /* function/data pointer conversion in expression */ 31 | 32 | #define USE_STUBLESS_PROXY 33 | 34 | 35 | /* verify that the version is high enough to compile this file*/ 36 | #ifndef __REDQ_RPCPROXY_H_VERSION__ 37 | #define __REQUIRED_RPCPROXY_H_VERSION__ 475 38 | #endif 39 | 40 | 41 | #include "rpcproxy.h" 42 | #ifndef __RPCPROXY_H_VERSION__ 43 | #error this stub requires an updated version of 44 | #endif /* __RPCPROXY_H_VERSION__ */ 45 | 46 | 47 | #include "shellext_i.h" 48 | 49 | #define TYPE_FORMAT_STRING_SIZE 3 50 | #define PROC_FORMAT_STRING_SIZE 1 51 | #define EXPR_FORMAT_STRING_SIZE 1 52 | #define TRANSMIT_AS_TABLE_SIZE 0 53 | #define WIRE_MARSHAL_TABLE_SIZE 0 54 | 55 | typedef struct _shellext_MIDL_TYPE_FORMAT_STRING 56 | { 57 | short Pad; 58 | unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; 59 | } shellext_MIDL_TYPE_FORMAT_STRING; 60 | 61 | typedef struct _shellext_MIDL_PROC_FORMAT_STRING 62 | { 63 | short Pad; 64 | unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; 65 | } shellext_MIDL_PROC_FORMAT_STRING; 66 | 67 | typedef struct _shellext_MIDL_EXPR_FORMAT_STRING 68 | { 69 | long Pad; 70 | unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; 71 | } shellext_MIDL_EXPR_FORMAT_STRING; 72 | 73 | 74 | static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = 75 | {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; 76 | 77 | 78 | extern const shellext_MIDL_TYPE_FORMAT_STRING shellext__MIDL_TypeFormatString; 79 | extern const shellext_MIDL_PROC_FORMAT_STRING shellext__MIDL_ProcFormatString; 80 | extern const shellext_MIDL_EXPR_FORMAT_STRING shellext__MIDL_ExprFormatString; 81 | 82 | 83 | extern const MIDL_STUB_DESC Object_StubDesc; 84 | 85 | 86 | extern const MIDL_SERVER_INFO IOverlayHandler_ServerInfo; 87 | extern const MIDL_STUBLESS_PROXY_INFO IOverlayHandler_ProxyInfo; 88 | 89 | 90 | extern const MIDL_STUB_DESC Object_StubDesc; 91 | 92 | 93 | extern const MIDL_SERVER_INFO IContextMenuHandler_ServerInfo; 94 | extern const MIDL_STUBLESS_PROXY_INFO IContextMenuHandler_ProxyInfo; 95 | 96 | 97 | 98 | #if !defined(__RPC_WIN64__) 99 | #error Invalid build platform for this stub. 100 | #endif 101 | 102 | static const shellext_MIDL_PROC_FORMAT_STRING shellext__MIDL_ProcFormatString = 103 | { 104 | 0, 105 | { 106 | 107 | 0x0 108 | } 109 | }; 110 | 111 | static const shellext_MIDL_TYPE_FORMAT_STRING shellext__MIDL_TypeFormatString = 112 | { 113 | 0, 114 | { 115 | NdrFcShort( 0x0 ), /* 0 */ 116 | 117 | 0x0 118 | } 119 | }; 120 | 121 | 122 | /* Object interface: IUnknown, ver. 0.0, 123 | GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ 124 | 125 | 126 | /* Object interface: IOverlayHandler, ver. 0.0, 127 | GUID={0xE9BF8D5F,0x8F02,0x479E,{0x94,0xC5,0x75,0xD2,0x6A,0x20,0x4F,0xFC}} */ 128 | 129 | #pragma code_seg(".orpc") 130 | static const unsigned short IOverlayHandler_FormatStringOffsetTable[] = 131 | { 132 | 0 133 | }; 134 | 135 | static const MIDL_STUBLESS_PROXY_INFO IOverlayHandler_ProxyInfo = 136 | { 137 | &Object_StubDesc, 138 | shellext__MIDL_ProcFormatString.Format, 139 | &IOverlayHandler_FormatStringOffsetTable[-3], 140 | 0, 141 | 0, 142 | 0 143 | }; 144 | 145 | 146 | static const MIDL_SERVER_INFO IOverlayHandler_ServerInfo = 147 | { 148 | &Object_StubDesc, 149 | 0, 150 | shellext__MIDL_ProcFormatString.Format, 151 | &IOverlayHandler_FormatStringOffsetTable[-3], 152 | 0, 153 | 0, 154 | 0, 155 | 0}; 156 | CINTERFACE_PROXY_VTABLE(3) _IOverlayHandlerProxyVtbl = 157 | { 158 | 0, 159 | &IID_IOverlayHandler, 160 | IUnknown_QueryInterface_Proxy, 161 | IUnknown_AddRef_Proxy, 162 | IUnknown_Release_Proxy 163 | }; 164 | 165 | const CInterfaceStubVtbl _IOverlayHandlerStubVtbl = 166 | { 167 | &IID_IOverlayHandler, 168 | &IOverlayHandler_ServerInfo, 169 | 3, 170 | 0, /* pure interpreted */ 171 | CStdStubBuffer_METHODS 172 | }; 173 | 174 | 175 | /* Object interface: IContextMenuHandler, ver. 0.0, 176 | GUID={0xE58341FD,0x11BA,0x4150,{0x92,0xAB,0xF8,0x02,0x03,0xBF,0x58,0xFC}} */ 177 | 178 | #pragma code_seg(".orpc") 179 | static const unsigned short IContextMenuHandler_FormatStringOffsetTable[] = 180 | { 181 | 0 182 | }; 183 | 184 | static const MIDL_STUBLESS_PROXY_INFO IContextMenuHandler_ProxyInfo = 185 | { 186 | &Object_StubDesc, 187 | shellext__MIDL_ProcFormatString.Format, 188 | &IContextMenuHandler_FormatStringOffsetTable[-3], 189 | 0, 190 | 0, 191 | 0 192 | }; 193 | 194 | 195 | static const MIDL_SERVER_INFO IContextMenuHandler_ServerInfo = 196 | { 197 | &Object_StubDesc, 198 | 0, 199 | shellext__MIDL_ProcFormatString.Format, 200 | &IContextMenuHandler_FormatStringOffsetTable[-3], 201 | 0, 202 | 0, 203 | 0, 204 | 0}; 205 | CINTERFACE_PROXY_VTABLE(3) _IContextMenuHandlerProxyVtbl = 206 | { 207 | 0, 208 | &IID_IContextMenuHandler, 209 | IUnknown_QueryInterface_Proxy, 210 | IUnknown_AddRef_Proxy, 211 | IUnknown_Release_Proxy 212 | }; 213 | 214 | const CInterfaceStubVtbl _IContextMenuHandlerStubVtbl = 215 | { 216 | &IID_IContextMenuHandler, 217 | &IContextMenuHandler_ServerInfo, 218 | 3, 219 | 0, /* pure interpreted */ 220 | CStdStubBuffer_METHODS 221 | }; 222 | 223 | static const MIDL_STUB_DESC Object_StubDesc = 224 | { 225 | 0, 226 | NdrOleAllocate, 227 | NdrOleFree, 228 | 0, 229 | 0, 230 | 0, 231 | 0, 232 | 0, 233 | shellext__MIDL_TypeFormatString.Format, 234 | 1, /* -error bounds_check flag */ 235 | 0x50002, /* Ndr library version */ 236 | 0, 237 | 0x800025b, /* MIDL Version 8.0.603 */ 238 | 0, 239 | 0, 240 | 0, /* notify & notify_flag routine table */ 241 | 0x1, /* MIDL flag */ 242 | 0, /* cs routines */ 243 | 0, /* proxy/server info */ 244 | 0 245 | }; 246 | 247 | const CInterfaceProxyVtbl * const _shellext_ProxyVtblList[] = 248 | { 249 | ( CInterfaceProxyVtbl *) &_IOverlayHandlerProxyVtbl, 250 | ( CInterfaceProxyVtbl *) &_IContextMenuHandlerProxyVtbl, 251 | 0 252 | }; 253 | 254 | const CInterfaceStubVtbl * const _shellext_StubVtblList[] = 255 | { 256 | ( CInterfaceStubVtbl *) &_IOverlayHandlerStubVtbl, 257 | ( CInterfaceStubVtbl *) &_IContextMenuHandlerStubVtbl, 258 | 0 259 | }; 260 | 261 | PCInterfaceName const _shellext_InterfaceNamesList[] = 262 | { 263 | "IOverlayHandler", 264 | "IContextMenuHandler", 265 | 0 266 | }; 267 | 268 | 269 | #define _shellext_CHECK_IID(n) IID_GENERIC_CHECK_IID( _shellext, pIID, n) 270 | 271 | int __stdcall _shellext_IID_Lookup( const IID * pIID, int * pIndex ) 272 | { 273 | IID_BS_LOOKUP_SETUP 274 | 275 | IID_BS_LOOKUP_INITIAL_TEST( _shellext, 2, 1 ) 276 | IID_BS_LOOKUP_RETURN_RESULT( _shellext, 2, *pIndex ) 277 | 278 | } 279 | 280 | const ExtendedProxyFileInfo shellext_ProxyFileInfo = 281 | { 282 | (PCInterfaceProxyVtblList *) & _shellext_ProxyVtblList, 283 | (PCInterfaceStubVtblList *) & _shellext_StubVtblList, 284 | (const PCInterfaceName * ) & _shellext_InterfaceNamesList, 285 | 0, /* no delegation */ 286 | & _shellext_IID_Lookup, 287 | 2, 288 | 2, 289 | 0, /* table of [async_uuid] interfaces */ 290 | 0, /* Filler1 */ 291 | 0, /* Filler2 */ 292 | 0 /* Filler3 */ 293 | }; 294 | #if _MSC_VER >= 1200 295 | #pragma warning(pop) 296 | #endif 297 | 298 | 299 | #endif /* defined(_M_AMD64)*/ 300 | 301 | -------------------------------------------------------------------------------- /Shell Extension/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" -------------------------------------------------------------------------------- /Shell Extension/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef STRICT 4 | #define STRICT 5 | #endif 6 | 7 | #include "targetver.h" 8 | 9 | #define _ATL_APARTMENT_THREADED 10 | #define _ATL_NO_AUTOMATIC_NAMESPACE 11 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS 12 | #define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW 13 | 14 | #include "resource.h" 15 | #include 16 | #include 17 | #include -------------------------------------------------------------------------------- /Shell Extension/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /Uninstall.bat: -------------------------------------------------------------------------------- 1 | REM This is temporary. 2 | CLS 3 | 4 | SET PATH=%PATH%;%SystemRoot%\Microsoft.NET\Framework\v4.0.30319 5 | 6 | regsvr32 /u /s "%~dp0\ExtensionsForOneDrive.Shell.dll" 7 | reg delete HKCU\Software\Rafael\ExtensionsForOneDrive /f 8 | 9 | ngen uninstall "%~dp0\ExtensionsForOneDrive.Service.exe" /silent 10 | ngen uninstall "%~dp0\GalaSoft.MvvmLight.Extras.WPF45.dll" /silent 11 | ngen uninstall "%~dp0\GalaSoft.MvvmLight.WPF45.dll" /silent 12 | ngen uninstall "%~dp0\Microsoft.Live.dll" /silent 13 | ngen uninstall "%~dp0\Microsoft.Practices.ServiceLocation.dll" /silent 14 | 15 | pause --------------------------------------------------------------------------------