├── .gitattributes ├── .gitignore ├── Binaries ├── Beta │ ├── ODNative.pdb │ ├── ODOnDemand.exe │ ├── OneDriveFlyoutPS.dll │ ├── OneDriveFlyoutPS.pdb │ ├── OneDriveLib_OnDemand.zip │ ├── OneDriveLib_OnDemand_1.zip │ ├── Readme.md │ ├── Setup.zip │ ├── StorageApp.exe │ └── StorageApp.pdb ├── CppConsoleApplication.exe ├── ODNative-rvia-surface.dll ├── ODNative-rvia-surface.exp ├── ODNative-rvia-surface.lib ├── ODNative.dll ├── ODNative.dll.lastcodeanalysissucceeded ├── ODNative.exp ├── ODNative.iobj ├── ODNative.ipdb ├── ODNative.lib ├── ODOnDemand.ex1 ├── ODOnDemand.exe ├── ODOnDemand.iobj ├── ODOnDemand.ipdb ├── PowerShell │ ├── OneDriveLib.dll │ └── Readme.md ├── odnative.txt └── x86 │ ├── ODNative.dll │ └── deleteme.txt ├── CodeMap1.dgml ├── DebugAndTraces ├── OneDriveLib.dll └── readme.md ├── ODNative ├── ApiStatus.cpp ├── ApiStatus.h ├── ODNative-rvia-surface.vcxproj ├── ODNative.cpp ├── ODNative.vcxproj ├── ODNative.vcxproj.filters ├── ReadMe.txt ├── dllmain.cpp ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── ODOnDemand ├── EventCallBacks.cpp ├── EventCallBacks.h ├── Helper.cpp ├── ODOnDemand.cpp ├── ODOnDemand.h ├── ODOnDemand.rc ├── ODOnDemand.vcxproj ├── ODOnDemand.vcxproj.filters ├── packages.config └── resource.h ├── ODOnDemandSetup ├── License.rtf ├── ODOnDemandSetup.vdproj ├── license.txt └── readme.rtf ├── OdSyncService - Copy.sln ├── OdSyncService-rvia-surface.sln ├── OdSyncService.VC-rvia-surface.db ├── OdSyncService.sln ├── OneDriveLib ├── GetStatus.cs ├── IOdSyncStatusWS.cs ├── IShellIconOverlayIdentifier.cs ├── OdSyncStatusWS.cs ├── OneDriveLib.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Resources │ ├── ODNative.dll │ └── ODNative32.dll ├── UacHelper.cs └── WriteLog.cs ├── README.md ├── ShellShim ├── AssemblyInfo.cpp ├── ReadMe.txt ├── ShellShim.cpp ├── ShellShim.h ├── ShellShim.vcxproj ├── ShellShim.vcxproj.filters ├── Stdafx.cpp ├── Stdafx.h ├── app.ico ├── app.rc └── resource.h ├── SignDll.ps1 ├── SignExe.ps1 ├── SignInstaller.ps1 └── license.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /Binaries/Beta/ODNative.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/ODNative.pdb -------------------------------------------------------------------------------- /Binaries/Beta/ODOnDemand.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/ODOnDemand.exe -------------------------------------------------------------------------------- /Binaries/Beta/OneDriveFlyoutPS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/OneDriveFlyoutPS.dll -------------------------------------------------------------------------------- /Binaries/Beta/OneDriveFlyoutPS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/OneDriveFlyoutPS.pdb -------------------------------------------------------------------------------- /Binaries/Beta/OneDriveLib_OnDemand.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/OneDriveLib_OnDemand.zip -------------------------------------------------------------------------------- /Binaries/Beta/OneDriveLib_OnDemand_1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/OneDriveLib_OnDemand_1.zip -------------------------------------------------------------------------------- /Binaries/Beta/Readme.md: -------------------------------------------------------------------------------- 1 | ## Beta version of OnDemand monitoring 2 | 3 | ## Disclaimer 4 | Be aware that this software is provided "AS IS". This is a beta and may never see the light of the day. 5 | 6 | ## 1. Getting things ready (choose Option 1 or 2 not both) 7 | 8 | ## 1.1 Option 1. Using installer (easier): ## 9 | 10 | - Download Setup.zip 11 | - Unblock the zip 12 | - Run the installer 13 | 14 | ## 1.2 Option 2. Not using Installer: ## 15 | 16 | - You may need to install C++ Runtime before running the application if you have a previous version 17 | - The standalone BETA version is not digitally signed. 18 | - Download ODOnDemand.exe from this Beta folder. Unblock the file ODOnDemand.exe (beta is not signed). Unblock the file as it was downloaded from the Internet it will most likely be marked as blocked. 19 | - Make sure the application is located on a folder that all users of the machine have access (e.g. c:\tools). 20 | - In order to monitor OneDrive NEEDS to be on the notification area of the taskbar 21 | - If auto monitoring is not enabled the log will onlys starts after the first change in status 22 | - The log file location is *%LOCALAPPDATA%\OneDriveMonitor\Logs* 23 | - The application for now spawns a console window 24 | 25 | 26 | ## 2. Registering the application to monitor OneDrive (auto monitoring) 27 | 28 | - Run cmd as administrator 29 | - run this command: *ODOnDemand.exe -onLaunch* 30 | - If things were correct you will see [Debugger="*path-to-app*\ODOnDemmand.exe -launch] under one of the following keys in regedit. 31 | - For 64-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\OneDrive.exe 32 | - For 32-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\OneDrive.exe 33 | - The monitoring will ONLY take effect next time OneDrive.exe is loaded 34 | 35 | ## 3. Unregistering the monitor 36 | 37 | - Run cmd as administrator 38 | - run this command: *ODOnDemand.exe -clear* 39 | - If the command does not work you need only to delete key Debugger on one of the keys in previous instructions 40 | 41 | ## 4. Running for the first time or running when auto monitoring is not set (-onLaunch) 42 | 43 | - The automatic monitoring will only happens when OneDrive.exe starts (reboot or new sign in) 44 | - You may choose to run only when you need it, but remember that any log entry will happen after a change in status 45 | - If you want to attach to a running OneDrive instance get the PID in Task Manager or using this PowerShell command: *Get-Process -Name OneDrive | Select Id* 46 | - There may be more than one instance of OneDrive (personal and business) and you need to attach to both 47 | - This command will attach to the process: *ODOnDemand.exe -attach PID* where PID is the process id. 48 | 49 | ## 5. Example of PowerShell script to capture the latest status 50 | 51 | ``` 52 | 53 | $content = Get-Content -Path "$($env:LOCALAPPDATA)\OneDriveMonitor\Logs\OneDriveMonitor_$((Get-Date).ToString('yyyy-MM-dd')).log"; 54 | $lastStatus = ''; 55 | for($count=$content.Count-1;$count -gt 0; $count--) 56 | { 57 | if($content[$count].Contains('IconChange')) 58 | { 59 | $lastStatus = $content[$count].Split("`t")[3]; 60 | $lastStatus = $lastStatus.Split("'")[1]; 61 | break; 62 | } 63 | 64 | } 65 | 66 | Write-Host $lastStatus 67 | ``` 68 | 69 | ## 6. Example of PowerShell script to capture latest status when there is more than one OneDrive client installed ## 70 | 71 | ``` 72 | Add-Type -AssemblyName System.DirectoryServices.AccountManagement 73 | $sid = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current.Sid.Value 74 | 75 | 76 | $items = Get-ChildItem -Recurse HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager | Where-Object { $_.Name -imatch $sid } 77 | 78 | $hashName = @{} 79 | $items | ? { $_.GetValue("DisplayNameResource") } | % { $hashName.Add($_.GetValue("DisplayNameResource"), '') } 80 | $path = "$($env:LOCALAPPDATA)\OneDriveMonitor\Logs\OneDriveMonitor_$((Get-Date).ToString('yyyy-MM-dd')).log"; 81 | $content = @(); 82 | if([System.IO.File]::Exists($path)) 83 | { 84 | $content = Get-Content -Path $path; 85 | } else 86 | { 87 | Write-Error "Log file not found at '$path'" -Category OpenError 88 | $hashName.Clear(); 89 | $hashName.Add("_error", "Log file not found at '$path'"); 90 | } 91 | $lastStatus = ''; 92 | for($count=$content.Count-1;$count -gt 0; $count--) 93 | { 94 | if($content[$count].Contains('IconChange')) 95 | { 96 | $lastStatus = $content[$count].Split("`t")[3]; 97 | $lastName = $lastStatus.Split("'")[1]; 98 | if($hashName[$lastName] -ne '') 99 | { 100 | $hashName[$lastName] = $lastStatus; 101 | $count = ($hashName.Values | ? { [string]::IsNullOrEmpty($_) }).Count; 102 | if($count -eq 0) 103 | { 104 | break; 105 | } 106 | 107 | } 108 | } 109 | 110 | } 111 | 112 | 113 | $hashName | ConvertTo-Json 114 | 115 | ``` 116 | -------------------------------------------------------------------------------- /Binaries/Beta/Setup.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/Setup.zip -------------------------------------------------------------------------------- /Binaries/Beta/StorageApp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/StorageApp.exe -------------------------------------------------------------------------------- /Binaries/Beta/StorageApp.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/Beta/StorageApp.pdb -------------------------------------------------------------------------------- /Binaries/CppConsoleApplication.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/CppConsoleApplication.exe -------------------------------------------------------------------------------- /Binaries/ODNative-rvia-surface.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative-rvia-surface.dll -------------------------------------------------------------------------------- /Binaries/ODNative-rvia-surface.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative-rvia-surface.exp -------------------------------------------------------------------------------- /Binaries/ODNative-rvia-surface.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative-rvia-surface.lib -------------------------------------------------------------------------------- /Binaries/ODNative.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.dll -------------------------------------------------------------------------------- /Binaries/ODNative.dll.lastcodeanalysissucceeded: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.dll.lastcodeanalysissucceeded -------------------------------------------------------------------------------- /Binaries/ODNative.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.exp -------------------------------------------------------------------------------- /Binaries/ODNative.iobj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.iobj -------------------------------------------------------------------------------- /Binaries/ODNative.ipdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.ipdb -------------------------------------------------------------------------------- /Binaries/ODNative.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODNative.lib -------------------------------------------------------------------------------- /Binaries/ODOnDemand.ex1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODOnDemand.ex1 -------------------------------------------------------------------------------- /Binaries/ODOnDemand.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODOnDemand.exe -------------------------------------------------------------------------------- /Binaries/ODOnDemand.iobj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODOnDemand.iobj -------------------------------------------------------------------------------- /Binaries/ODOnDemand.ipdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/ODOnDemand.ipdb -------------------------------------------------------------------------------- /Binaries/PowerShell/OneDriveLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/PowerShell/OneDriveLib.dll -------------------------------------------------------------------------------- /Binaries/PowerShell/Readme.md: -------------------------------------------------------------------------------- 1 | **Open PowerShell (it cannot be in elevated mode because of OneDrive design)** 2 | 3 | **Before running the first time, use this to unblock the DLL that you downloaded:** 4 | ``` 5 | PS C:\ODTool> Unblock-File -Path C:\ODTool\OneDriveLib.dll # change path if necessary 6 | ``` 7 | 8 | **Run this:** 9 | ``` 10 | Import-Module OneDriveLib.dll 11 | Get-ODStatus 12 | ``` 13 | 14 | **This is an example of the output:** 15 | ``` 16 | PS C:\ODTool> Import-Module OneDriveLib.dll 17 | PS C:\ODTool> Get-ODStatus 18 | 19 | LocalPath    : E:\MicrosoftOnedrive\OneDrive - My Company 20 | UserSID      : S-1-5-21-124000000-708000000-1543000000-802052 21 | UserName     : CONTOSO\rodneyviana 22 | DisplayName : OneDrive - Contoso 23 | ServiceType  : Business1 24 | StatusString : Looking for changes 25 | 26 | StatusString : UpToDate 27 | LocalPath    : D:\Onedrive 28 | UserSID      : S-1-5-21-124000000-708000000-1543000000-802052 29 | DisplayName : OneDrive - Personal 30 | UserName     : CONTOSO\rodneyviana 31 | ServiceType  : Personal 32 | StatusString : Up To Date 33 | ``` 34 | 35 | **Syntax:** 36 | ``` 37 | Get-ODStatus [-Type ] [-ByPath ] [CLSID ] 38 | [-IncludeLog] [-Verbose] 39 | 40 | Or 41 | Get-ODStatus -OnDemandOnly [-Type ] [-IncludeLog] [-Verbose] 42 | 43 | ``` 44 | **Where:** 45 | ``` 46 | -Type Only returns if Service Type matches 47 | Example: Get-ODStatus -Type Personal 48 | 49 | -ByPath Only checks a particular folder or file status 50 | Example: Get-ODStatus -Path "$env:OneDrive\docs" 51 | 52 | -CLSD Verify only a particular GUID (not used normally) 53 | Example: Get-ODStatus -CLSD A0396A93-DC06-4AEF-BEE9-95FFCCAEF20E 54 | 55 | -IncludeLog If present will save a log file on the temp folder 56 | 57 | -Verbose Show verbose information 58 | 59 | -OnDemandOnly Normally On Demand is only tested as a fallback, when 60 | -OnDemandOnly is present it goes directly to 61 | On Demand status. This may resolve flicker issues 62 | 63 | ``` 64 | 65 | **Important:** 66 | 67 | On Demand Status **ONLY** works if OneDrive icon is visible on the taskbar 68 | -------------------------------------------------------------------------------- /Binaries/odnative.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/odnative.txt -------------------------------------------------------------------------------- /Binaries/x86/ODNative.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/Binaries/x86/ODNative.dll -------------------------------------------------------------------------------- /Binaries/x86/deleteme.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /DebugAndTraces/OneDriveLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/DebugAndTraces/OneDriveLib.dll -------------------------------------------------------------------------------- /DebugAndTraces/readme.md: -------------------------------------------------------------------------------- 1 | This version is for tracing purposes to verify whether the process is running in elevated privileges mode (Is Elevated: True) 2 | 3 | When running, it will create a log file at %temp%\OneDriveLib-yyyy-mm-dd.log 4 | 5 | This log will detail the result of each inquiry. 6 | 7 | In the example below we see that the process is running in elevated privileges, thus it will not work as per OneDrive design requirement. 8 | When it is running in elevated mode, you will also notice that the icon inquiry returns with error 0x80040154 9 | ``` 10 | 2018-02-06T19:59:07 Information Is Interactive: True, Is UAC Enabled: True, Is Elevated: True 11 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconError, Path: C:\Users\rviana\OneDrive - Contoso 12 | 2018-02-06T19:59:07 Information Testing CLSID: {bbacc218-34ea-4666-9d7a-c78f2274a524}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 13 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconUpToDate, Path: C:\Users\rviana\OneDrive - Contoso 14 | 2018-02-06T19:59:07 Information Testing CLSID: {f241c880-6982-4ce5-8cf7-7085ba96da5a}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 15 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconReadOnly, Path: C:\Users\rviana\OneDrive - Contoso 16 | 2018-02-06T19:59:07 Information Testing CLSID: {9aa2f32d-362a-42d9-9328-24a483e2ccc3}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 17 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconShared, Path: C:\Users\rviana\OneDrive - Contoso 18 | 2018-02-06T19:59:07 Information Testing CLSID: {5ab7172c-9c11-405c-8dd5-af20f3606282}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 19 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconSharedSync, Path: C:\Users\rviana\OneDrive - Contoso 20 | 2018-02-06T19:59:07 Information Testing CLSID: {a78ed123-ab77-406b-9962-2a5d9d2f7f30}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 21 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconSync, Path: C:\Users\rviana\OneDrive - Contoso 22 | 2018-02-06T19:59:07 Information Testing CLSID: {a0396a93-dc06-4aef-bee9-95ffccaef20e}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x80040154 23 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveUpToDate, Path: C:\Users\rviana\OneDrive - Contoso 24 | 2018-02-06T19:59:07 Information Testing CLSID: {e768cd3b-bddc-436d-9c13-e1b39ca257b1}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x0 25 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveSync, Path: C:\Users\rviana\OneDrive - Contoso 26 | 2018-02-06T19:59:07 Information Testing CLSID: {cd55129a-b1a1-438e-a425-cebc7dc684ee}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x0 27 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveError, Path: C:\Users\rviana\OneDrive - Contoso 28 | 2018-02-06T19:59:07 Information Testing CLSID: {8ba85c75-763b-4103-94eb-9470f12fe0f7}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x0 29 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconError, Path: C:\Users\rviana\OneDrive 30 | 2018-02-06T19:59:07 Information Testing CLSID: {bbacc218-34ea-4666-9d7a-c78f2274a524}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 31 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconUpToDate, Path: C:\Users\rviana\OneDrive 32 | 2018-02-06T19:59:07 Information Testing CLSID: {f241c880-6982-4ce5-8cf7-7085ba96da5a}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 33 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconReadOnly, Path: C:\Users\rviana\OneDrive 34 | 2018-02-06T19:59:07 Information Testing CLSID: {9aa2f32d-362a-42d9-9328-24a483e2ccc3}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 35 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconShared, Path: C:\Users\rviana\OneDrive 36 | 2018-02-06T19:59:07 Information Testing CLSID: {5ab7172c-9c11-405c-8dd5-af20f3606282}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 37 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconSharedSync, Path: C:\Users\rviana\OneDrive 38 | 2018-02-06T19:59:07 Information Testing CLSID: {a78ed123-ab77-406b-9962-2a5d9d2f7f30}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 39 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconSync, Path: C:\Users\rviana\OneDrive 40 | 2018-02-06T19:59:07 Information Testing CLSID: {a0396a93-dc06-4aef-bee9-95ffccaef20e}, Path: C:\Users\rviana\OneDrive, HR=0x80040154 41 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveUpToDate, Path: C:\Users\rviana\OneDrive 42 | 2018-02-06T19:59:07 Information Testing CLSID: {e768cd3b-bddc-436d-9c13-e1b39ca257b1}, Path: C:\Users\rviana\OneDrive, HR=0x0 43 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveSync, Path: C:\Users\rviana\OneDrive 44 | 2018-02-06T19:59:07 Information Testing CLSID: {cd55129a-b1a1-438e-a425-cebc7dc684ee}, Path: C:\Users\rviana\OneDrive, HR=0x0 45 | 2018-02-06T19:59:07 Information Testing Type: Native.IIconGrooveError, Path: C:\Users\rviana\OneDrive 46 | 2018-02-06T19:59:07 Information Testing CLSID: {8ba85c75-763b-4103-94eb-9470f12fe0f7}, Path: C:\Users\rviana\OneDrive, HR=0x0 47 | ``` 48 | 49 | A working scenario looks like this: 50 | 51 | ``` 52 | 2018-02-06T20:17:22 Information Is Interactive: True, Is UAC Enabled: True, Is Elevated: False 53 | 2018-02-06T20:17:22 Information Testing Type: Native.IIconError, Path: C:\Users\rviana\OneDrive - Contoso 54 | 2018-02-06T20:17:22 Information Testing CLSID: {bbacc218-34ea-4666-9d7a-c78f2274a524}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x0 55 | 2018-02-06T20:17:22 Information Testing Type: Native.IIconUpToDate, Path: C:\Users\rviana\OneDrive - Contoso 56 | 2018-02-06T20:17:23 Information Testing CLSID: {f241c880-6982-4ce5-8cf7-7085ba96da5a}, Path: C:\Users\rviana\OneDrive - Contoso, HR=0x0 57 | 2018-02-06T20:17:23 Information Testing Type: Native.IIconError, Path: C:\Users\rviana\OneDrive 58 | 2018-02-06T20:17:23 Information Testing CLSID: {bbacc218-34ea-4666-9d7a-c78f2274a524}, Path: C:\Users\rviana\OneDrive, HR=0x0 59 | 2018-02-06T20:17:23 Information Testing Type: Native.IIconUpToDate, Path: C:\Users\rviana\OneDrive 60 | 2018-02-06T20:17:23 Information Testing CLSID: {f241c880-6982-4ce5-8cf7-7085ba96da5a}, Path: C:\Users\rviana\OneDrive, HR=0x0 61 | 62 | ``` 63 | -------------------------------------------------------------------------------- /ODNative/ApiStatus.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ApiStatus.h" 3 | 4 | GUID CLSID_FileCoAuth_StorageProviderStatusUISourceFactory = { /* 0827D883-485C-4D62-BA2C-A332DBF3D4B0 */ 0x0827D883, 0x485C, 0x4D62, {0xBA, 0x2C, 0xA3, 0x32, 0xDB, 0xF3, 0xD4, 0xB0} }; 5 | 6 | void safeStringCopy(void* dest, int dest_size, void* source, int source_size) { 7 | int realSize = (min(source_size, dest_size)) * (sizeof TCHAR); 8 | ZeroMemory(dest, dest_size * (sizeof TCHAR)); 9 | if (nullptr != source) 10 | { 11 | std::memcpy(dest, source, realSize); 12 | } 13 | } 14 | 15 | HRESULT printStatusUI(ABI::Windows::Storage::Provider::IStorageProviderStatusUISource* pSource, OneDriveState& currentState) 16 | { 17 | HRESULT getHR = S_OK; 18 | 19 | ABI::Windows::Storage::Provider::IStorageProviderStatusUI* status = nullptr; 20 | HRESULT hr = pSource->GetStatusUI(&status); 21 | 22 | if (SUCCEEDED(hr)) 23 | { 24 | ABI::Windows::Storage::Provider::StorageProviderState state = {}; 25 | getHR = status->get_ProviderState(&state); 26 | //std::cout << "////////// Latest status UI is ////////////" << std::endl; 27 | //std::cout << "Current State is: " << state << " . HRESULT from get_ProviderState is: " << std::hex << getHR << std::endl; 28 | currentState.CurrentState = state; 29 | // Test ProviderStateLabel 30 | HSTRING stateLable = nullptr; 31 | getHR = status->get_ProviderStateLabel(&stateLable); 32 | UINT32 stateLableLength = 0; 33 | auto rawLabel = WindowsGetStringRawBuffer(stateLable, &stateLableLength); 34 | safeStringCopy(&(currentState.Label), MAX_STATE_LABEL, (void*)rawLabel, stateLableLength); 35 | //std::wstring stateLableString = WindowsGetStringRawBuffer(stateLable, &stateLableLength); 36 | //std::wcout << L"Current ProviderStateLabel is: " << stateLableString << " size: " << stateLableLength << " . HRESULT from get_ProviderState is: " << std::hex << getHR << std::endl; 37 | 38 | 39 | // Test ProviderStateIcon 40 | ABI::Windows::Foundation::IUriRuntimeClass* uri = nullptr; 41 | getHR = status->get_ProviderStateIcon(&uri); 42 | 43 | if (SUCCEEDED(getHR)) 44 | { 45 | HSTRING stateIcon = nullptr; 46 | UINT32 stateIconLength = 0; 47 | getHR = uri->get_AbsoluteUri(&stateIcon); 48 | auto rawIcon = WindowsGetStringRawBuffer(stateIcon, &stateIconLength); 49 | safeStringCopy(&(currentState.IconUri), MAX_ICON_URI, (void*)rawIcon, stateIconLength); 50 | //std::wstring stateIconString = WindowsGetStringRawBuffer(stateIcon, &stateIconLength); 51 | //std::wcout << L"Current ProviderStateIcon is: " << stateIconString << " . HRESULT from get_AbsoluteUri is: " << std::hex << getHR << std::endl; 52 | } 53 | else 54 | { 55 | return getHR; 56 | //std::cout << "Error: HRESULT from get_ProviderStateIcon is: " << std::hex << getHR << std::endl; 57 | } 58 | 59 | // Test StorageProviderQuotaUI 60 | ABI::Windows::Storage::Provider::IStorageProviderQuotaUI* quotaUI = nullptr; 61 | getHR = status->get_QuotaUI("aUI); 62 | 63 | if (SUCCEEDED(getHR)) 64 | { 65 | HSTRING quotaUsedLabel = nullptr; 66 | UINT32 labelLength = 0; 67 | HRESULT getQuotaHR = quotaUI->get_QuotaUsedLabel("aUsedLabel); 68 | if (!SUCCEEDED(getQuotaHR)) 69 | { 70 | currentState.isQuotaAvailable = FALSE; 71 | return getHR; // quota may not be available, but it is ok 72 | } 73 | auto rawQuotaUsed = WindowsGetStringRawBuffer(quotaUsedLabel, &labelLength); 74 | safeStringCopy(&(currentState.QuotaLabel), MAX_QUOTA_LABEL, (void*)rawQuotaUsed, labelLength); 75 | //std::wstring quotaUsedLabelString = WindowsGetStringRawBuffer(quotaUsedLabel, &labelLength); 76 | //std::wcout << L"Current QuotaUsedLabel is: " << quotaUsedLabelString << " . HRESULT from get_QuotaUsedLabel is: " << std::hex << getHR << std::endl; 77 | 78 | uint64_t bytesUsed = 0; 79 | uint64_t bytesTotal = 0; 80 | HRESULT getUsedQuota = quotaUI->get_QuotaUsedInBytes(&bytesUsed); 81 | HRESULT getTotalQuota = quotaUI->get_QuotaTotalInBytes(&bytesTotal); 82 | currentState.UsedQuota = bytesUsed; 83 | currentState.TotalQuota = bytesTotal; 84 | //std::cout << "Current total Quota in bytes is: " << std::dec << bytesTotal << " . HRESULT from get_QuotaTotalInBytes is: " << std::hex << getTotalQuota << std::endl; 85 | //std::cout << "Current used Quota in bytes is: " << std::dec << bytesUsed << " . HRESULT from get_QuotaUsedInBytes is: " << std::hex << getUsedQuota << std::endl; 86 | 87 | ABI::Windows::Foundation::IReference* pColorStruct = nullptr; 88 | HRESULT getColorHR = quotaUI->get_QuotaUsedColor(&pColorStruct); 89 | 90 | if (SUCCEEDED(getColorHR)) 91 | { 92 | ABI::Windows::UI::Color quotaColor; 93 | getColorHR = pColorStruct->get_Value("aColor); 94 | currentState.IconColorA = quotaColor.A; 95 | currentState.IconColorB = quotaColor.B; 96 | currentState.IconColorG = quotaColor.G; 97 | currentState.IconColorR = quotaColor.R; 98 | //std::wcout << L"Current used Quota color is: A:" << quotaColor.A << " R:" << quotaColor.R << " G:" << quotaColor.G << " B:" << quotaColor.B << " . HRESULT from quotaUsedColor struct is: " << std::hex << getUsedQuota << std::endl; 99 | } 100 | } 101 | } 102 | else 103 | { 104 | return hr; 105 | } 106 | return getHR; 107 | 108 | } 109 | 110 | HRESULT getInstanceStatus(const std::wstring& syncrootId, OneDriveState& currentState) 111 | { 112 | ABI::Windows::Storage::Provider::IStorageProviderStatusUISourceFactory* pFactory = nullptr; 113 | IUnknown* pUnk = nullptr; 114 | ABI::Windows::Storage::Provider::IStorageProviderStatusUISource* pSource = nullptr; 115 | 116 | HRESULT hr = CoCreateInstance(CLSID_FileCoAuth_StorageProviderStatusUISourceFactory, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IUnknown), (void**)&pUnk); 117 | 118 | //std::cout << "CoCreateInstance: " << std::hex << hr << std::endl; 119 | 120 | if (SUCCEEDED(hr)) 121 | { 122 | GUID guidIID = __uuidof(ABI::Windows::Storage::Provider::IStorageProviderStatusUISourceFactory); 123 | hr = pUnk->QueryInterface(guidIID, (void**)&pFactory); 124 | //std::cout << "QueryInterface: " << std::hex << hr << std::endl; 125 | if (SUCCEEDED(hr)) 126 | { 127 | HSTRING hstrProviderId = nullptr; 128 | WindowsCreateString(syncrootId.c_str(), static_cast(syncrootId.size()), &hstrProviderId); 129 | 130 | hr = pFactory->GetStatusUISource(hstrProviderId, &pSource); 131 | //std::cout << "Result of invoking GetStatusUISource: " << std::hex << hr << std::endl; 132 | } 133 | } 134 | 135 | ABI::Windows::Storage::Provider::IStorageProviderStatusUI* status = nullptr; 136 | 137 | if (SUCCEEDED(hr)) 138 | { 139 | hr = pSource->GetStatusUI(&status); 140 | 141 | //std::cout << "Result from GetStatusUI: " << std::hex << hr << std::endl; 142 | } 143 | 144 | if (SUCCEEDED(hr)) 145 | { 146 | // Print default StatusUI 147 | printStatusUI(pSource, currentState); 148 | } 149 | 150 | return hr; 151 | 152 | } -------------------------------------------------------------------------------- /ODNative/ApiStatus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | const int MAX_STATE_LABEL = 255; 15 | const int MAX_ICON_URI = 1024; 16 | const int MAX_QUOTA_LABEL = 255; 17 | 18 | struct OneDriveState { 19 | int CurrentState; 20 | TCHAR Label[MAX_STATE_LABEL]; 21 | TCHAR IconUri[MAX_ICON_URI]; 22 | BOOL isQuotaAvailable; 23 | uint64_t TotalQuota; 24 | uint64_t UsedQuota; 25 | TCHAR QuotaLabel[MAX_QUOTA_LABEL]; 26 | BYTE IconColorA; 27 | BYTE IconColorR; 28 | BYTE IconColorG; 29 | BYTE IconColorB; 30 | }; 31 | 32 | HRESULT getInstanceStatus(const std::wstring& syncrootId, OneDriveState& currentState); -------------------------------------------------------------------------------- /ODNative/ODNative-rvia-surface.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {4222D206-0E8A-4F68-A171-4AFDB031098E} 23 | Win32Proj 24 | ODNative 25 | 8.1 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v110 38 | true 39 | Unicode 40 | Static 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v110 46 | Unicode 47 | Static 48 | 49 | 50 | DynamicLibrary 51 | false 52 | v110 53 | true 54 | Unicode 55 | Static 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | true 80 | 81 | 82 | false 83 | 84 | 85 | false 86 | 87 | 88 | 89 | Use 90 | Level3 91 | Disabled 92 | WIN32;_DEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 93 | true 94 | 95 | 96 | Windows 97 | true 98 | 99 | 100 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 101 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 102 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 103 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 104 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 105 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 106 | 107 | 108 | 109 | 110 | 111 | Use 112 | Level3 113 | Disabled 114 | _DEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 115 | true 116 | 117 | 118 | Windows 119 | true 120 | 121 | 122 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 123 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 124 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 125 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 126 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 127 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 128 | 129 | 130 | 131 | 132 | 133 | Level3 134 | Use 135 | MaxSpeed 136 | true 137 | true 138 | WIN32;NDEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 139 | true 140 | 141 | 142 | Windows 143 | true 144 | true 145 | true 146 | 147 | 148 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 149 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 150 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 151 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 152 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 153 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 154 | 155 | 156 | 157 | 158 | 159 | Level3 160 | Use 161 | MaxSpeed 162 | true 163 | true 164 | NDEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 165 | true 166 | 167 | 168 | Windows 169 | true 170 | true 171 | true 172 | 173 | 174 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 175 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 176 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 177 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 178 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 179 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | false 193 | 194 | 195 | false 196 | 197 | 198 | false 199 | 200 | 201 | false 202 | 203 | 204 | 205 | 206 | 207 | Create 208 | Create 209 | Create 210 | Create 211 | 212 | 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /ODNative/ODNative.cpp: -------------------------------------------------------------------------------- 1 | // ODNative.cpp : Returns true or false for the Icon related to the action on OneDrive 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "psapi.h" 10 | #include "ApiStatus.h" 11 | 12 | #pragma region TrayArea 13 | 14 | using namespace std; 15 | 16 | wstring GetButtonText(HWND Toolbar, int Order) 17 | { 18 | DWORD processId = 0; 19 | ::GetWindowThreadProcessId(Toolbar, &processId); 20 | if (!processId) 21 | return L"No process id"; 22 | auto hProc = OpenProcess(PROCESS_ALL_ACCESS, false, processId); 23 | if (!hProc) 24 | return L"Unable to open desktop process"; 25 | TBBUTTON* tbButton = (TBBUTTON*)VirtualAllocEx(hProc, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE); 26 | if (!tbButton) 27 | return L"Unable to alocate desktop process memory (1)"; 28 | auto response = ::SendMessage(Toolbar, TB_GETBUTTON, static_cast(Order), (LPARAM)tbButton); 29 | if (!response) 30 | { 31 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 32 | CloseHandle(hProc); 33 | return L"Unable to get OneDrive tooltip text"; 34 | 35 | } 36 | TBBUTTON button = { 0 }; 37 | SIZE_T size; 38 | auto read = ReadProcessMemory(hProc, tbButton, &button, sizeof(TBBUTTON), &size); 39 | if (!read) 40 | { 41 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 42 | CloseHandle(hProc); 43 | return L"Unable to read tooltip information"; 44 | } 45 | size = SendMessage(Toolbar, TB_GETBUTTONTEXT, static_cast(button.idCommand), NULL); 46 | if (size == 0) 47 | { 48 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 49 | CloseHandle(hProc); 50 | return L""; 51 | } 52 | wchar_t* text = (wchar_t*)VirtualAllocEx(hProc, NULL, (size + 1) * sizeof(TCHAR), MEM_COMMIT, PAGE_READWRITE); 53 | if (!text) 54 | { 55 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 56 | CloseHandle(hProc); 57 | return L"Unable to alocate desktop process memory (1)"; 58 | } 59 | size = SendMessage(Toolbar, TB_GETBUTTONTEXT, static_cast(button.idCommand), (LPARAM)text); 60 | if (!size) 61 | { 62 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 63 | VirtualFreeEx(hProc, text, 0, MEM_RELEASE); 64 | CloseHandle(hProc); 65 | return L"Notification message is empty"; 66 | } 67 | wstring strText(size, '\0'); 68 | read = ReadProcessMemory(hProc, text, const_cast(strText.c_str()), (size) * sizeof(TCHAR), &size); 69 | VirtualFreeEx(hProc, tbButton, 0, MEM_RELEASE); 70 | if (read) 71 | VirtualFreeEx(hProc, text, 0, MEM_RELEASE); 72 | CloseHandle(hProc); 73 | if (!read) 74 | { 75 | return L"Unable to alocate desktop process memory (2)"; 76 | } 77 | return strText; 78 | 79 | } 80 | 81 | /// 82 | /// Get Status by Name of All Buttons in Toolbar area 83 | /// 84 | /// Handle of window 85 | /// Display Name of OneDrive instance 86 | /// 87 | wstring GetStatusByName(HWND Handle, wstring OneDriveType) 88 | { 89 | if (!Handle) 90 | return L"Handle not provided"; 91 | auto count = ::SendMessage(Handle, TB_BUTTONCOUNT, NULL, NULL); 92 | if (!count) 93 | return L"No status text found"; 94 | for (int i = 0; i < count; i++) 95 | { 96 | auto strStatus = GetButtonText(Handle, i); 97 | if (strStatus.find(OneDriveType) == 0) 98 | { 99 | return strStatus; 100 | } 101 | } 102 | return L"Status not found for type [" + OneDriveType + L"]"; 103 | 104 | } 105 | 106 | wstring nameToCompare; 107 | wstring currentStatus; 108 | 109 | BOOL CALLBACK enumWindowCallback(HWND hWnd, LPARAM lparam) { 110 | if (currentStatus.size() > nameToCompare.size() && currentStatus.find(nameToCompare) == 0) 111 | return TRUE; 112 | const int maxSize = 2048; 113 | wstring processPath(maxSize, L'\0'); 114 | wstring className(maxSize, L'\0'); 115 | 116 | DWORD processId = NULL; 117 | ::GetWindowThreadProcessId(hWnd, &processId); 118 | 119 | auto procHwnd = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId); 120 | auto length = ::GetProcessImageFileName(procHwnd, const_cast(processPath.c_str()), maxSize); 121 | CloseHandle(procHwnd); 122 | if (length) 123 | processPath.resize(length); 124 | else 125 | processPath = L"<>"; 126 | auto processName = processPath.substr(processPath.find_last_of(L'\\') + 1); 127 | if (processName != L"explorer.exe") 128 | return true; 129 | length = ::GetClassName(hWnd, const_cast(className.c_str()), maxSize); 130 | if (length) 131 | className.resize(length); 132 | else 133 | className = L"<>"; 134 | 135 | // List visible windows with a non-empty title 136 | if (className == L"ToolbarWindow32") { 137 | currentStatus = GetStatusByName(hWnd, nameToCompare); 138 | if (currentStatus.find(L"") != 0) 139 | return TRUE; 140 | } 141 | auto parent = (LPARAM)&hWnd; 142 | ::EnumChildWindows(hWnd, enumWindowCallback, parent); 143 | return TRUE; 144 | } 145 | 146 | /// 147 | /// Get Status of OneDrive by Instance Name 148 | /// 149 | /// Display Name of OneDrive instance (e.g OneDrive - Personal) 150 | /// Status or Error string 151 | wstring GetStatusByName(wstring OneDriveType) 152 | { 153 | nameToCompare = OneDriveType; 154 | currentStatus = L""; 155 | ::EnumChildWindows(GetDesktopWindow(), enumWindowCallback, NULL); 156 | return currentStatus; 157 | } 158 | 159 | 160 | 161 | /// 162 | /// Get Handle of ToolbarWindow32 (Deprecated) 163 | /// 164 | /// One Drive Window Handle in Taskbar 165 | HWND GetHandle() 166 | { 167 | auto hDesktop = GetDesktopWindow(); 168 | auto hTray = FindWindowEx(hDesktop, 0, L"Shell_TrayWnd", NULL); 169 | auto hNotify = FindWindowEx(hTray, 0, L"TrayNotifyWnd", NULL); 170 | auto hSys = FindWindowEx(hNotify, 0, L"SysPager", NULL); 171 | auto hToolbar = FindWindowEx(hSys, 0, L"ToolbarWindow32", NULL); 172 | return hToolbar; 173 | } 174 | 175 | #pragma endregion TrayArea 176 | 177 | __declspec(dllexport) HRESULT GetShellInterfaceFromGuid(BOOL* IsTrue , LPWSTR GuidString, LPWSTR Path) 178 | { 179 | HRESULT hr = 0; 180 | hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); 181 | if (hr != S_OK) 182 | { 183 | CoUninitialize(); 184 | hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); 185 | } 186 | CComPtr spShellIcon; 187 | CLSID CLSID_Interface; 188 | #pragma warning (disable: 6031) 189 | CLSIDFromString(GuidString, &CLSID_Interface); 190 | hr = spShellIcon.CoCreateInstance(CLSID_Interface); 191 | 192 | *IsTrue = 0; 193 | if (hr != S_OK) 194 | return hr; 195 | 196 | *IsTrue = spShellIcon->IsMemberOf(Path, 0) == S_OK; 197 | 198 | ::CoUninitialize(); 199 | 200 | return S_OK; //(HRESULT)fi.hIcon; // S_OK; 201 | 202 | 203 | } 204 | 205 | __declspec(dllexport) HRESULT GetStatusByType(LPWSTR OneDriveType, LPWSTR Status, int Size, PINT ActualSize) 206 | { 207 | const wstring error = L"Buffer size is insufficient"; 208 | auto result = GetStatusByName(OneDriveType); 209 | int bytesSize = static_cast((result.size() + 1) * 2); 210 | *ActualSize = bytesSize; 211 | if (bytesSize > Size) 212 | { 213 | std::memcpy(Status, error.c_str(), (error.size() + 1) * 2); 214 | return E_NOT_SUFFICIENT_BUFFER; 215 | } 216 | std::memcpy(Status, result.c_str(), bytesSize); 217 | 218 | return S_OK; 219 | } 220 | 221 | __declspec(dllexport) HRESULT GetStatusByTypeApi(LPWSTR SyncRootId, OneDriveState* State) 222 | { 223 | OneDriveState stateData = {0}; 224 | HRESULT hr = getInstanceStatus(SyncRootId, stateData); 225 | std::memcpy(State, &stateData, sizeof(OneDriveState)); 226 | return hr; 227 | 228 | } 229 | 230 | -------------------------------------------------------------------------------- /ODNative/ODNative.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {4222D206-0E8A-4F68-A171-4AFDB031098E} 23 | Win32Proj 24 | ODNative 25 | 10.0 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | v142 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v142 38 | true 39 | Unicode 40 | Static 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v142 46 | Unicode 47 | Static 48 | 49 | 50 | DynamicLibrary 51 | false 52 | v142 53 | true 54 | Unicode 55 | Static 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | true 80 | 81 | 82 | false 83 | 84 | 85 | false 86 | 87 | 88 | 89 | Use 90 | Level3 91 | Disabled 92 | WIN32;_DEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 93 | true 94 | 95 | 96 | Windows 97 | true 98 | RuntimeObject.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) 99 | 100 | 101 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 102 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 103 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 104 | echo copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\resources\ODNative32.dll 105 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 106 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 107 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 108 | copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\resources\ODNative32.dll 109 | 110 | 111 | 112 | 113 | Use 114 | Level3 115 | Disabled 116 | _DEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 117 | true 118 | 119 | 120 | Windows 121 | true 122 | RuntimeObject.lib; 123 | 124 | 125 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 126 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 127 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 128 | echo copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\Resources\ODNative.dll 129 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 130 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 131 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 132 | copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\Resources\ODNative.dll 133 | 134 | 135 | 136 | 137 | 138 | Level3 139 | Use 140 | MaxSpeed 141 | true 142 | true 143 | WIN32;NDEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 144 | true 145 | 146 | 147 | Windows 148 | true 149 | true 150 | true 151 | RuntimeObject.lib; 152 | 153 | 154 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 155 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 156 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 157 | echo copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\resources\ODNative32.dll 158 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 159 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 160 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 161 | copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\resources\ODNative32.dll 162 | 163 | 164 | 165 | 166 | Level3 167 | Use 168 | MaxSpeed 169 | true 170 | true 171 | NDEBUG;_WINDOWS;_USRDLL;ODNATIVE_EXPORTS;%(PreprocessorDefinitions) 172 | true 173 | 174 | 175 | Windows 176 | true 177 | true 178 | true 179 | RuntimeObject.lib; 180 | 181 | 182 | echo copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 183 | echo copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 184 | echo copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 185 | echo copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\Resources\ODNative.dll 186 | copy /y $(TargetDir)*.* $(SolutionDir)Binaries\ 187 | copy /y $(TargetDir)*.* $(SolutionDir)TestConsole\bin\$(PlatformTarget)\$(ConfigurationName)\ 188 | copy /y $(TargetDir)*.* $(SolutionDir)OdSyncService\bin\$(PlatformTarget)\$(ConfigurationName)\ 189 | copy /y $(TargetPath) $(SolutionDir)\OneDriveLib\Resources\ODNative.dll 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | false 205 | 206 | 207 | false 208 | 209 | 210 | false 211 | 212 | 213 | false 214 | 215 | 216 | 217 | 218 | 219 | Create 220 | Create 221 | Create 222 | Create 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /ODNative/ODNative.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ODNative/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : ODNative Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this ODNative DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your ODNative application. 9 | 10 | 11 | ODNative.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | ODNative.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | ODNative.cpp 25 | This is the main DLL source file. 26 | 27 | When created, this DLL does not export any symbols. As a result, it 28 | will not produce a .lib file when it is built. If you wish this project 29 | to be a project dependency of some other project, you will either need to 30 | add code to export some symbols from the DLL so that an export library 31 | will be produced, or you can set the Ignore Input Library property to Yes 32 | on the General propert page of the Linker folder in the project's Property 33 | Pages dialog box. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other standard files: 37 | 38 | StdAfx.h, StdAfx.cpp 39 | These files are used to build a precompiled header (PCH) file 40 | named ODNative.pch and a precompiled types file named StdAfx.obj. 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | Other notes: 44 | 45 | AppWizard uses "TODO:" comments to indicate parts of the source code you 46 | should add to or customize. 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /ODNative/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /ODNative/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ODNative.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /ODNative/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 16 | 17 | #include 18 | #include 19 | 20 | // TODO: reference additional headers your program requires here 21 | -------------------------------------------------------------------------------- /ODNative/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /ODOnDemand/EventCallBacks.cpp: -------------------------------------------------------------------------------- 1 | #include "EventCallBacks.h" 2 | 3 | 4 | 5 | std::string formathex(UINT64 Number) 6 | { 7 | char str[30]; 8 | sprintf_s(str, 30, "%I64x", Number); 9 | return str; 10 | } 11 | 12 | std::wstring ReadStringW(ULONG64 Offset) 13 | { 14 | HRESULT hr = S_OK; 15 | 16 | std::wstring str(RESTART_MAX_CMD_LINE, ' '); 17 | ULONG size = str.size(); 18 | hr = g_Data->ReadUnicodeStringVirtualWide(Offset, str.size() * sizeof(TCHAR), const_cast(str.c_str()), size, &size); 19 | if (hr == S_OK && size > 0) 20 | { 21 | str.resize(size - 1); 22 | } 23 | else 24 | { 25 | str = L""; 26 | } 27 | return str; 28 | } 29 | 30 | 31 | 32 | #pragma region BreakPointClass 33 | extern ComPtr g_Client; 34 | extern ComPtr g_Control; 35 | extern ComPtr g_Symbols; 36 | BreakpointClass::BreakpointClass(std::string BPExpression, std::string Tag, BPCallBack Method, ULONG64 BPOffset) 37 | { 38 | this->tag = Tag; 39 | this->method = Method; 40 | hr = g_Control->AddBreakpoint(DEBUG_BREAKPOINT_CODE, DEBUG_ANY_ID, &breakPoint); 41 | if (IsValid()) 42 | { 43 | ULONG flags = 0; 44 | breakPoint->GetFlags(&flags); 45 | if ((flags & DEBUG_BREAKPOINT_DEFERRED) == 0) 46 | { 47 | breakPoint->AddFlags(DEBUG_BREAKPOINT_ADDER_ONLY | DEBUG_BREAKPOINT_ENABLED); 48 | if (BPOffset) 49 | { 50 | hr = breakPoint->SetOffset(BPOffset); 51 | isOffset = true; 52 | } 53 | else 54 | { 55 | isOffset = false; 56 | hr = breakPoint->SetOffsetExpression(BPExpression.c_str()); 57 | } 58 | } 59 | else 60 | { 61 | RemoveBreakPoint(); 62 | hr = E_NOT_SET; 63 | } 64 | } 65 | else 66 | { 67 | hr = E_NOT_SET; 68 | } 69 | } 70 | 71 | 72 | void BreakpointClass::RemoveBreakPoint() 73 | { 74 | if (!IsValid()) 75 | return; 76 | 77 | if (breakPoint) 78 | { 79 | hr = g_Control->RemoveBreakpoint(breakPoint.Get()); 80 | 81 | hr = E_NOT_SET; 82 | } 83 | 84 | } 85 | 86 | HRESULT BreakpointClass::InvokeCallBack() 87 | { 88 | if (NULL == method) 89 | { 90 | //this->RemoveBreakPoint(); 91 | return DEBUG_STATUS_IGNORE_EVENT; 92 | } 93 | return method(this->breakPoint.Get()); 94 | } 95 | 96 | #pragma endregion 97 | 98 | #pragma region EventCallBackClass 99 | 100 | ComPtr EventCallBacks::singleTon; 101 | 102 | EventCallBacks::EventCallBacks() 103 | { 104 | g_Client->SetEventCallbacks(this); 105 | } 106 | 107 | 108 | EventCallBacks::~EventCallBacks() 109 | { 110 | } 111 | 112 | 113 | 114 | 115 | STDMETHODIMP_(ULONG) 116 | EventCallBacks::AddRef( 117 | THIS 118 | ) 119 | { 120 | // This class is designed to be static so 121 | // there's no true refcount. 122 | return 1; 123 | } 124 | 125 | STDMETHODIMP_(ULONG) 126 | EventCallBacks::Release( 127 | THIS 128 | ) 129 | { 130 | // This class is designed to be static so 131 | // there's no true refcount. 132 | return 0; 133 | } 134 | 135 | STDMETHODIMP 136 | EventCallBacks::GetInterestMask( 137 | THIS_ 138 | _Out_ PULONG Mask 139 | ) 140 | { 141 | #if _DEBUG 142 | *Mask = 143 | DEBUG_EVENT_BREAKPOINT | DEBUG_EVENT_LOAD_MODULE | DEBUG_EVENT_SESSION_STATUS | DEBUG_EVENT_EXCEPTION | DEBUG_EVENT_CHANGE_DEBUGGEE_STATE; 144 | #else 145 | * Mask = DEBUG_EVENT_BREAKPOINT | DEBUG_EVENT_LOAD_MODULE | DEBUG_EVENT_SESSION_STATUS; 146 | #endif 147 | /*| 148 | DEBUG_EVENT_EXCEPTION | 149 | DEBUG_EVENT_CREATE_PROCESS | 150 | DEBUG_EVENT_LOAD_MODULE | 151 | DEBUG_EVENT_SESSION_STATUS; */ 152 | return S_OK; 153 | } 154 | 155 | STDMETHODIMP 156 | EventCallBacks::Breakpoint( 157 | THIS_ 158 | _In_ PDEBUG_BREAKPOINT Bp 159 | ) 160 | { 161 | ULONG64 offset = 0; 162 | 163 | std::string Expression(MAX_PATH, ' '); 164 | 165 | ULONG size = 0; 166 | 167 | 168 | 169 | HRESULT hr = Bp->GetOffsetExpression(const_cast(Expression.c_str()), MAX_PATH, &size); 170 | 171 | #if _DEBUG 172 | printf("Expression: %s\n", Expression.c_str()); 173 | #endif 174 | if (hr == S_OK && size > 0) 175 | { 176 | Expression.resize(size - 1); 177 | if (bps.find(Expression) != bps.end()) 178 | { 179 | return bps[Expression].InvokeCallBack(); 180 | } 181 | } 182 | #if _DEBUG 183 | printf("BreakPoint could not be found\n"); 184 | #endif 185 | return DEBUG_STATUS_NO_CHANGE; 186 | } 187 | 188 | STDMETHODIMP 189 | EventCallBacks::Exception( 190 | THIS_ 191 | _In_ PEXCEPTION_RECORD64 Exception, 192 | _In_ ULONG FirstChance 193 | ) 194 | { 195 | #if _DEBUG 196 | printf("Exception: 0x%x\n", Exception->ExceptionCode); 197 | #endif 198 | if (Exception->ExceptionCode == STATUS_BREAKPOINT) 199 | { 200 | return DEBUG_STATUS_BREAK; 201 | } 202 | return DEBUG_STATUS_GO; 203 | 204 | } 205 | 206 | STDMETHODIMP 207 | EventCallBacks::CreateProcess( 208 | THIS_ 209 | _In_ ULONG64 ImageFileHandle, 210 | _In_ ULONG64 Handle, 211 | _In_ ULONG64 BaseOffset, 212 | _In_ ULONG ModuleSize, 213 | _In_ PCSTR ModuleName, 214 | _In_ PCSTR ImageName, 215 | _In_ ULONG CheckSum, 216 | _In_ ULONG TimeDateStamp, 217 | _In_ ULONG64 InitialThreadHandle, 218 | _In_ ULONG64 ThreadDataOffset, 219 | _In_ ULONG64 StartOffset 220 | ) 221 | { 222 | 223 | UNREFERENCED_PARAMETER(ImageFileHandle); 224 | UNREFERENCED_PARAMETER(Handle); 225 | UNREFERENCED_PARAMETER(ModuleSize); 226 | UNREFERENCED_PARAMETER(ModuleName); 227 | UNREFERENCED_PARAMETER(CheckSum); 228 | UNREFERENCED_PARAMETER(TimeDateStamp); 229 | UNREFERENCED_PARAMETER(InitialThreadHandle); 230 | UNREFERENCED_PARAMETER(ThreadDataOffset); 231 | UNREFERENCED_PARAMETER(StartOffset); 232 | 233 | #if _DEBUG 234 | printf("Create Process: %s\n", ModuleName); 235 | #endif 236 | return DEBUG_STATUS_GO; 237 | 238 | } 239 | 240 | STDMETHODIMP 241 | EventCallBacks::LoadModule( 242 | THIS_ 243 | _In_ ULONG64 ImageFileHandle, 244 | _In_ ULONG64 BaseOffset, 245 | _In_ ULONG ModuleSize, 246 | _In_ PCSTR ModuleName, 247 | _In_ PCSTR ImageName, 248 | _In_ ULONG CheckSum, 249 | _In_ ULONG TimeDateStamp 250 | ) 251 | { 252 | 253 | UNREFERENCED_PARAMETER(ImageFileHandle); 254 | UNREFERENCED_PARAMETER(ModuleSize); 255 | UNREFERENCED_PARAMETER(ModuleName); 256 | UNREFERENCED_PARAMETER(CheckSum); 257 | UNREFERENCED_PARAMETER(TimeDateStamp); 258 | 259 | 260 | #if _DEBUG 261 | printf("Loaded: %s\n", ModuleName); 262 | #endif 263 | if (_stricmp(ModuleName, "shell32") == 0) 264 | { 265 | //int i = EventCallBacks::GetInstance()->AddBreakPoint("iisfreb!HandleGlTraceEvent", "", FrebEventCallBack); 266 | #if _DEBUG 267 | //printf("BP Id = %i\n", i); 268 | #endif 269 | return DEBUG_STATUS_BREAK; 270 | } 271 | 272 | return DEBUG_STATUS_GO; 273 | } 274 | 275 | STDMETHODIMP 276 | EventCallBacks::SessionStatus( 277 | THIS_ 278 | _In_ ULONG SessionStatus 279 | ) 280 | { 281 | #if _DEBUG 282 | printf("Session Status: 0x%x\n", SessionStatus); 283 | 284 | #endif 285 | 286 | if (SessionStatus == DEBUG_SESSION_END) 287 | { 288 | #if _DEBUG 289 | printf("Application ended\n"); 290 | #endif 291 | Log(L"Application Ended"); 292 | exit(0); 293 | 294 | //s_isStop = true; 295 | } 296 | 297 | } 298 | #pragma endregion -------------------------------------------------------------------------------- /ODOnDemand/EventCallBacks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ODOnDemand.h" 4 | 5 | 6 | 7 | using namespace std; 8 | using namespace Microsoft::WRL; 9 | 10 | extern ComPtr g_Client; 11 | extern ComPtr g_Data; 12 | 13 | template 14 | HRESULT ReadTargetMemory(ULONG64 Offset, T* Buffer) 15 | { 16 | ULONG bytes = 0; 17 | return g_Data->ReadVirtual(Offset, &Buffer, sizeof(T), &bytes); 18 | }; 19 | 20 | std::wstring ReadStringW(ULONG64 Offset); 21 | 22 | std::string formathex(UINT64 Number); 23 | #pragma region BreakPointClass 24 | 25 | typedef HRESULT(*BPCallBack)(IDebugBreakpoint* BP); 26 | 27 | struct BreakpointClass 28 | { 29 | public: 30 | 31 | BreakpointClass() {}; 32 | BreakpointClass(std::string BPExpression, std::string Tag, BPCallBack Method, ULONG64 BPOffset = 0); 33 | 34 | 35 | HRESULT InvokeCallBack(); 36 | void RemoveBreakPoint(); 37 | bool IsValid() 38 | { 39 | return hr == S_OK; 40 | } 41 | 42 | bool IsOffset() 43 | { 44 | return isOffset; 45 | } 46 | 47 | ComPtr breakPoint; 48 | protected: 49 | bool isOffset = false; 50 | std::string tag; 51 | BPCallBack method; 52 | HRESULT hr = 0; 53 | }; 54 | #pragma endregion 55 | 56 | #pragma region EventCallBacks 57 | 58 | class EventCallBacks : 59 | public DebugBaseEventCallbacks 60 | { 61 | public: 62 | EventCallBacks(); 63 | ~EventCallBacks(); 64 | static EventCallBacks* GetInstance() 65 | { 66 | if (NULL != EventCallBacks::singleTon.Get()) 67 | { 68 | #if _DEBUG 69 | printf("[CREATE] EventCallBack is Not NULL\n"); 70 | #endif 71 | return singleTon.Get(); 72 | } 73 | #if _DEBUG 74 | printf("[CREATE] EventCallBack is NULL\n"); 75 | #endif 76 | 77 | singleTon = ComPtr(new EventCallBacks()); 78 | return singleTon.Get(); 79 | } 80 | 81 | static void DeleteInstance() 82 | { 83 | if (NULL == EventCallBacks::singleTon.Get()) 84 | return; 85 | #if _DEBUG 86 | printf("[DELETE] EventCallBack is Not NULL\n"); 87 | #endif 88 | 89 | if (true /* g_ExtInstancePtr->m_Control4.IsSet() */) 90 | { 91 | for (auto i = GetInstance()->bps.begin(); i != GetInstance()->bps.end(); i++) 92 | { 93 | #if _DEBUG 94 | UINT64 IP = 0; 95 | i->second.breakPoint->GetOffset(&IP); 96 | printf("Deleting BP: %I64x IsValid: %s\n", IP, i->second.IsValid() ? "true" : "false"); 97 | #endif 98 | 99 | i->second.RemoveBreakPoint(); 100 | } 101 | } 102 | GetInstance()->bps.clear(); 103 | PDEBUG_EVENT_CALLBACKS callBack = NULL; 104 | if (true /* g_ExtInstancePtr->m_Client4.IsSet() */) 105 | { 106 | g_Client->GetEventCallbacks(&callBack); 107 | if (NULL != callBack) 108 | { 109 | g_Client->SetEventCallbacks(NULL); 110 | 111 | } 112 | } 113 | singleTon.Reset(); 114 | 115 | } 116 | 117 | int AddBreakPoint(const std::string& BPExpr, std::string Tag, BPCallBack Method) 118 | { 119 | #if _DEBUG 120 | printf("Add BP: %s ", Tag.c_str()); 121 | printf("[%s]\n", BPExpr.c_str()); 122 | #endif 123 | //std::string BPStr = formathex(BPExpr); 124 | const auto bp = bps.find(BPExpr); 125 | if (bp != bps.end()) 126 | { 127 | bp->second.RemoveBreakPoint(); 128 | } 129 | bps.emplace(BPExpr, BreakpointClass(BPExpr, Tag, Method)); 130 | if (bps.find(BPExpr)->second.IsValid()) 131 | return static_cast(bps.size()); 132 | bps.erase(BPExpr); 133 | 134 | #if _DEBUG 135 | printf("*** Adding BP %s failed\n", BPExpr.c_str()); 136 | #endif 137 | return -1; 138 | } 139 | 140 | // IUnknown. 141 | STDMETHOD_(ULONG, AddRef)( 142 | THIS 143 | ); 144 | STDMETHOD_(ULONG, Release)( 145 | THIS 146 | ); 147 | 148 | // IDebugEventCallbacks. 149 | STDMETHOD(GetInterestMask)( 150 | THIS_ 151 | _Out_ PULONG Mask 152 | ); 153 | 154 | STDMETHOD(Breakpoint)( 155 | THIS_ 156 | _In_ PDEBUG_BREAKPOINT Bp 157 | ); 158 | STDMETHOD(Exception)( 159 | THIS_ 160 | _In_ PEXCEPTION_RECORD64 Exception, 161 | _In_ ULONG FirstChance 162 | ); 163 | STDMETHOD(CreateProcess)( 164 | THIS_ 165 | _In_ ULONG64 ImageFileHandle, 166 | _In_ ULONG64 Handle, 167 | _In_ ULONG64 BaseOffset, 168 | _In_ ULONG ModuleSize, 169 | _In_ PCSTR ModuleName, 170 | _In_ PCSTR ImageName, 171 | _In_ ULONG CheckSum, 172 | _In_ ULONG TimeDateStamp, 173 | _In_ ULONG64 InitialThreadHandle, 174 | _In_ ULONG64 ThreadDataOffset, 175 | _In_ ULONG64 StartOffset 176 | ); 177 | STDMETHOD(LoadModule)( 178 | THIS_ 179 | _In_ ULONG64 ImageFileHandle, 180 | _In_ ULONG64 BaseOffset, 181 | _In_ ULONG ModuleSize, 182 | _In_ PCSTR ModuleName, 183 | _In_ PCSTR ImageName, 184 | _In_ ULONG CheckSum, 185 | _In_ ULONG TimeDateStamp 186 | ); 187 | STDMETHOD(SessionStatus)( 188 | THIS_ 189 | _In_ ULONG Status 190 | ); 191 | protected: 192 | std::map bps; 193 | static ComPtr singleTon; 194 | }; 195 | 196 | #pragma endregion 197 | -------------------------------------------------------------------------------- /ODOnDemand/ODOnDemand.cpp: -------------------------------------------------------------------------------- 1 | // ODOnDemand.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include "ODOnDemand.h" 6 | #include "EventCallBacks.h" 7 | 8 | std::string statusStr[] = { 9 | 10 | "DEBUG_STATUS_NO_CHANGE", 11 | "DEBUG_STATUS_GO", 12 | "DEBUG_STATUS_GO_HANDLED", 13 | "DEBUG_STATUS_GO_NOT_HANDLED", 14 | "DEBUG_STATUS_STEP_OVER", 15 | "DEBUG_STATUS_STEP_INTO", 16 | "DEBUG_STATUS_BREAK", 17 | "DEBUG_STATUS_NO_DEBUGGEE", 18 | "DEBUG_STATUS_STEP_BRANCH", 19 | "DEBUG_STATUS_IGNORE_EVENT", 20 | "DEBUG_STATUS_RESTART_REQUESTED", 21 | "DEBUG_STATUS_REVERSE_GO", 22 | "DEBUG_STATUS_REVERSE_STEP_BRANCH", 23 | "DEBUG_STATUS_REVERSE_STEP_OVER", 24 | "DEBUG_STATUS_REVERSE_STEP_INTO", 25 | "DEBUG_STATUS_OUT_OF_SYNC", 26 | "DEBUG_STATUS_WAIT_INPUT", 27 | "DEBUG_STATUS_TIMEOUT" 28 | }; 29 | 30 | int wmain(int argc, wchar_t* argv[]) 31 | { 32 | myApp = L"\""; 33 | myApp.append(argv[0]); 34 | myApp.append(L"\" -launch "); 35 | HRESULT hr{ 0 }; 36 | hr = ::CoInitialize(NULL); 37 | #if _DEBUG 38 | wprintf(L"log: %s\n", GetFileName().c_str()); 39 | wprintf(L"Ansi Time: %s\n", GetTimeAnsi().c_str()); 40 | #endif 41 | Log(L"Initiating App"); 42 | ParseCommand(argc, argv); 43 | if (s_isLaunchMode) 44 | { 45 | Log(L"Setting auto launch key. Use 'ODOnDemand.exe -clear' to remove the monitoring"); 46 | wprintf(L"Setting auto launch key. Use 'ODOnDemand.exe -clear' to remove the monitoring\n"); 47 | hr = SetDebugKey(L"OneDrive.exe"); 48 | if (hr == ERROR_ACCESS_DENIED) 49 | { 50 | Log(L"Access Denied. Please run ODOnDemand.exe in administrative mode"); 51 | wprintf(L"Access Denied. Please run ODOnDemand.exe in administrative mode\n"); 52 | exit(hr); 53 | } 54 | if (hr != ERROR_SUCCESS) 55 | { 56 | Log(format(L"Failed to set auto launch key for the monitoring. Error: %x", hr)); 57 | wprintf(L"Failed to set auto launch key for the monitoring. Error: %x\n", hr); 58 | exit(hr); 59 | } 60 | exit(0); 61 | } 62 | 63 | if (s_isClear) 64 | { 65 | Log(L"Deleting auto launch key. Use 'ODOnDemand.exe -onLaunch' to restart monitoring"); 66 | wprintf(L"Deleting auto launch key. Use 'ODOnDemand.exe -onLaunch' to restart monitoring\n"); 67 | hr = DeleteDebugKey(L"OneDrive.exe"); 68 | if (hr == ERROR_ACCESS_DENIED) 69 | { 70 | Log(L"Access Denied. Please run ODOnDemand.exe in administrative mode"); 71 | wprintf(L"Access Denied. Please run ODOnDemand.exe in administrative mode\n"); 72 | exit(hr); 73 | } 74 | if (hr != ERROR_SUCCESS) 75 | { 76 | Log(format(L"Failed to remove launch key for the monitoring. Error: %x", hr)); 77 | wprintf(L"Failed to remove launch key for the monitoring. Error: %x\n", hr); 78 | exit(hr); 79 | } 80 | exit(0); 81 | } 82 | 83 | if (0 == s_AttachId && cmdLine.size() == 0) 84 | return 0; 85 | CreateInterfaces(); 86 | 87 | if (0 != s_AttachId) 88 | AttachTo(s_AttachId); 89 | else 90 | { 91 | auto hWnd = ::GetConsoleWindow(); 92 | if (NULL != hWnd) 93 | { 94 | ::ShowWindow(hWnd, SW_HIDE); 95 | if (FALSE != ::IsWindowVisible(hWnd)) 96 | { 97 | Log(L"Unable to hide console Window", L"General", sev::Error); 98 | } 99 | 100 | } 101 | else 102 | { 103 | Log(L"Unable to hide console Window", L"General", sev::Error); 104 | } 105 | if (false && cmdLine.find(L"/") == wstring::npos) 106 | { 107 | hr = CreateLocalProcess(); 108 | Log(format(L"Created standalone process not monitored. HR=%d", hr)); 109 | #if _DEBUG 110 | wprintf(L"Created standalone process not monitored. HR=%d\n", hr); 111 | #endif 112 | FreeConsole(); 113 | exit(hr); 114 | } 115 | string cmdLineS = ws2s(cmdLine); 116 | hr = g_Client->CreateProcessW(NULL, const_cast(cmdLineS.c_str()), DEBUG_PROCESS); 117 | 118 | //hr = g_Control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE); 119 | 120 | Log(format(L"Successfully started process (id=%d, cmdLine='%s')", s_AttachId, cmdLine.c_str())); 121 | //hr = CreateDebuggingProcess(); 122 | //AttachTo(s_AttachId); 123 | 124 | } 125 | EventCallBacks* callbacks = EventCallBacks::GetInstance(); 126 | ULONG status{ 0 }; 127 | 128 | s_isStop = false; 129 | bool once = false; 130 | while (true) 131 | { 132 | 133 | 134 | hr = g_Control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE); 135 | 136 | 137 | if (hr != 0) 138 | continue; 139 | #if _DEBUG 140 | printHR("WaitForEvent", hr); 141 | #endif 142 | hr = g_Control->GetExecutionStatus(&status); 143 | #if _DEBUG 144 | printHR("GetStatus", hr); 145 | printf("%s\n", statusStr[status].c_str()); 146 | #endif 147 | int bpId = -1; 148 | switch (status) 149 | { 150 | 151 | case DEBUG_STATUS_BREAK: 152 | bpId = callbacks->AddBreakPoint("SHELL32!Shell_NotifyIconW", "", ODEventCallBack); 153 | if (bpId < 0) 154 | { 155 | Log(L"Unable to add breakpoint", L"General", sev::Error); 156 | #if _DEBUG 157 | printf("BP %i\n", bpId); 158 | #endif 159 | } 160 | hr = g_Control->SetExecutionStatus(DEBUG_STATUS_GO); 161 | #if _DEBUG 162 | printHR("SetExecutionStatus to GO", hr); 163 | #endif 164 | hr = g_System->GetCurrentProcessSystemId(&s_AttachId); 165 | #if _DEBUG 166 | wprintf(L"PID=%d,hr=%d\n", s_AttachId, hr); 167 | #endif 168 | break; 169 | 170 | case DEBUG_STATUS_NO_DEBUGGEE: 171 | printf("Application ended\n"); 172 | Log(L"Application Ended"); 173 | exit(0); 174 | break; 175 | default: 176 | printf("%s\n", statusStr[status].c_str()); 177 | break; 178 | } 179 | 180 | 181 | 182 | } 183 | 184 | 185 | 186 | 187 | g_Control->SetExecutionStatus(DEBUG_STATUS_GO); 188 | hr = g_Control->WaitForEvent(0, INFINITE); 189 | 190 | if (hr != S_OK) 191 | { 192 | printf("Error: 0x%x\n", hr); 193 | return hr; 194 | } 195 | EventCallBacks::DeleteInstance(); 196 | 197 | 198 | 199 | return 0; 200 | 201 | } 202 | 203 | // Run program: Ctrl + F5 or Debug > Start Without Debugging menu 204 | // Debug program: F5 or Debug > Start Debugging menu 205 | 206 | // Tips for Getting Started: 207 | // 1. Use the Solution Explorer window to add/manage files 208 | // 2. Use the Team Explorer window to connect to source control 209 | // 3. Use the Output window to see build output and other messages 210 | // 4. Use the Error List window to view errors 211 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 212 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 213 | -------------------------------------------------------------------------------- /ODOnDemand/ODOnDemand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ONDEMAND_H 3 | #define ONDEMAND_H 4 | 5 | // TODO: add headers that you want to pre-compile here 6 | #include 7 | #include 8 | #pragma comment(lib, "dbgeng.lib") 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | #pragma region Helper 16 | 17 | using namespace Microsoft::WRL; 18 | 19 | extern ComPtr g_Client; 20 | extern ComPtr g_Control; 21 | extern ComPtr g_Symbols; 22 | extern ComPtr g_Data; 23 | extern ComPtr g_System; 24 | 25 | const LPCWSTR DEBUG_REGISTRY_KEY = L"Software\\Microsoft\\Windows NT\\" 26 | L"CurrentVersion\\Image File Execution Options\\"; 27 | #ifdef _M_AMD64 28 | const LPCWSTR DEBUG_REGISTRY_KEY_WOW64 = L"Software\\Wow6432Node\\Microsoft\\Windows NT\\" 29 | L"CurrentVersion\\Image File Execution Options\\"; 30 | #endif 31 | 32 | using namespace std; 33 | 34 | extern wstring s_appPool; 35 | extern bool s_attach; 36 | extern bool s_isLaunchMode; 37 | extern bool s_isClear; 38 | extern bool s_isStop; 39 | extern ULONG s_AttachId; 40 | extern wstring cmdLine; 41 | extern wstring myApp; 42 | 43 | 44 | bool IsInteractive(); 45 | 46 | void CreateInterfaces(); 47 | 48 | void PrintUsage(); 49 | 50 | void PrintUsageAndExit(int Error, wstring Message = L""); 51 | 52 | void PrintErrorAndExit(HRESULT Error, wstring Message = L""); 53 | 54 | void ParseCommand(int argc, wchar_t* argv[]); 55 | 56 | HRESULT SetDebugKey(const wstring& ApplicationName); 57 | 58 | LONG DeleteDebugKey(const wstring& ApplicationName); 59 | 60 | HRESULT ODEventCallBack(IDebugBreakpoint* BP); 61 | 62 | std::string ws2s(const std::wstring& wstr); 63 | 64 | void AttachTo(ULONG PID); 65 | 66 | void printHR(const std::string& Message, const HRESULT& hr); 67 | 68 | wstring GetTimeAnsi(); 69 | wstring GetFileName(); 70 | 71 | ULONG CreateLocalProcess(); 72 | ULONG CreateDebuggingProcess(); 73 | 74 | wstring format(const wchar_t* formatStr, ...); 75 | 76 | enum sev 77 | { 78 | Verbose, 79 | Information, 80 | Warning, 81 | Error 82 | }; 83 | 84 | wstring GetLogFolder(); 85 | 86 | void Log(wstring Message, wstring source = L"General", sev severity = sev::Information); 87 | #pragma endregion // Helper 88 | 89 | #endif //ONDEMAND_H -------------------------------------------------------------------------------- /ODOnDemand/ODOnDemand.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Version 51 | // 52 | 53 | VS_VERSION_INFO VERSIONINFO 54 | FILEVERSION 1,0,1,1 55 | PRODUCTVERSION 1,0,1,1 56 | FILEFLAGSMASK 0x3fL 57 | #ifdef _DEBUG 58 | FILEFLAGS 0x1L 59 | #else 60 | FILEFLAGS 0x0L 61 | #endif 62 | FILEOS 0x40004L 63 | FILETYPE 0x1L 64 | FILESUBTYPE 0x0L 65 | BEGIN 66 | BLOCK "StringFileInfo" 67 | BEGIN 68 | BLOCK "040904b0" 69 | BEGIN 70 | VALUE "CompanyName", "Rodney Viana" 71 | VALUE "FileDescription", "Monitor OneDrive Notification Information" 72 | VALUE "FileVersion", "1.0.1.1" 73 | VALUE "InternalName", "ODOnDemand.exe" 74 | VALUE "LegalCopyright", "Copyright (C) 2019-2021 Rodney Viana" 75 | VALUE "OriginalFilename", "ODOnDemand.exe" 76 | VALUE "ProductName", "OneDrive On Demand Notification Monitor" 77 | VALUE "ProductVersion", "1.0.1.1" 78 | END 79 | END 80 | BLOCK "VarFileInfo" 81 | BEGIN 82 | VALUE "Translation", 0x409, 1200 83 | END 84 | END 85 | 86 | #endif // English (United States) resources 87 | ///////////////////////////////////////////////////////////////////////////// 88 | 89 | 90 | 91 | #ifndef APSTUDIO_INVOKED 92 | ///////////////////////////////////////////////////////////////////////////// 93 | // 94 | // Generated from the TEXTINCLUDE 3 resource. 95 | // 96 | 97 | 98 | ///////////////////////////////////////////////////////////////////////////// 99 | #endif // not APSTUDIO_INVOKED 100 | 101 | -------------------------------------------------------------------------------- /ODOnDemand/ODOnDemand.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {dbfdc140-542d-4c72-8746-7b79070bcf89} 25 | ODOnDemand 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | powershell.exe "$(SolutionDir)SignExe.ps1" 114 | 115 | 116 | 117 | 118 | Level3 119 | true 120 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | 123 | 124 | Console 125 | true 126 | 127 | 128 | 129 | 130 | Level3 131 | true 132 | true 133 | true 134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | Console 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /ODOnDemand/ODOnDemand.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Resource Files 45 | 46 | 47 | -------------------------------------------------------------------------------- /ODOnDemand/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /ODOnDemand/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ODOnDemand.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /ODOnDemandSetup/License.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}} 2 | {\*\generator Riched20 10.0.19041}\viewkind4\uc1 3 | \pard\sl240\slmult1\qc\b\f0\fs22\lang9 MIT License\b0\par 4 | 5 | \pard\sl240\slmult1\par 6 | 7 | \pard\sl240\slmult1\qc Copyright (c) 2017-2020 Rodney Viana\par 8 | 9 | \pard\sl240\slmult1\par 10 | 11 | \pard\sl240\slmult1\qj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\par 12 | \par 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\par 14 | 15 | \pard\sl240\slmult1\par 16 | \b THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\par 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\par 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\par 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\par 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\par 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\par 22 | SOFTWARE.\par 23 | } 24 | -------------------------------------------------------------------------------- /ODOnDemandSetup/license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2020 Rodney Viana 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. -------------------------------------------------------------------------------- /ODOnDemandSetup/readme.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Courier New;}{\f2\fnil\fcharset2 Symbol;}} 2 | {\*\generator Riched20 10.0.19041}\viewkind4\uc1 3 | \pard\sl240\slmult1\qc\b\f0\fs32\lang9 OnDemand monitoring\b0\fs22\par 4 | 5 | \pard\sl240\slmult1\par 6 | \b Disclaimer\par 7 | \b0 Be aware that this software is provided "AS IS". This is a release candidate and may never see the light of the day.\par 8 | \par 9 | \b Getting things ready\b0\par 10 | 11 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li720\sl240\slmult1 In order to monitor OneDrive NEEDS to be on the notification area of the taskbar\par 12 | {\pntext\f2\'B7\tab}If auto monitoring is not enabled the log will onlys starts after the first change in status\par 13 | {\pntext\f2\'B7\tab}The log file location is %LOCALAPPDATA%\\OneDriveMonitor\\Logs\par 14 | {\pntext\f2\'B7\tab}Registering the application to monitor OneDrive (auto monitoring) if option was not chosen during installation (the option is selected by default):\par 15 | 16 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li1080\sl240\slmult1 Run cmd as administrator\par 17 | {\pntext\f2\'B7\tab}run this command: ODOnDemand.exe -onLaunch\par 18 | 19 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li720\sl240\slmult1 If things were correct you will see [Debugger="path-to-app\\ODOnDemmand.exe" -launch] under one of the following keys in regedit.\par 20 | 21 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li1080\sl240\slmult1 For 64-bit OS: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\OneDrive.exe\par 22 | {\pntext\f2\'B7\tab}For 32-bit OS: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\OneDrive.exe\par 23 | 24 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li720\sl240\slmult1 The monitoring will ONLY take effect next time OneDrive.exe is loaded\par 25 | 26 | \pard\sl240\slmult1\par 27 | \b Unregistering the monitor\par 28 | 29 | \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-360\li720\sl240\slmult1\b0 Run cmd as administrator\par 30 | {\pntext\f2\'B7\tab}run this command: ODOnDemand.exe -clear\par 31 | {\pntext\f2\'B7\tab}If the command does not work you need only to delete key Debugger on one of the keys in previous instructions\par 32 | {\pntext\f2\'B7\tab}Running for the first time or running when auto monitoring is not set (-onLaunch)\par 33 | {\pntext\f2\'B7\tab}The automatic monitoring will only happens when OneDrive.exe starts (reboot or new sign in)\par 34 | {\pntext\f2\'B7\tab}You may choose to run only when you need it, but remember that any log entry will happen after a change in status\par 35 | {\pntext\f2\'B7\tab}If you want to attach to a running OneDrive instance get the PID in Task Manager or using this PowerShell command: Get-Process -Name OneDrive | Select Id\par 36 | {\pntext\f2\'B7\tab}There may be more than one instance of OneDrive (personal and business) and you need to attach to both\par 37 | {\pntext\f2\'B7\tab}This command will attach to the process: ODOnDemand.exe -attach PID where PID is the process id.\par 38 | 39 | \pard\sl240\slmult1\par 40 | \b Example of PowerShell script to capture the latest status\par 41 | \b0\par 42 | \f1\fs16 $content = Get-Content -Path "$($env:LOCALAPPDATA)\\OneDriveMonitor\\Logs\\OneDriveMonitor_$((Get-Date).ToString('yyyy-MM-dd')).log";\par 43 | $lastStatus = '';\par 44 | for($count=$content.Count-1;$count -gt 0; $count--)\par 45 | \{\par 46 | if($content[$count].Contains('IconChange'))\par 47 | \{\par 48 | $lastStatus = $content[$count].Split("`t")[3];\par 49 | $lastStatus = $lastStatus.Split("'")[1];\par 50 | break;\par 51 | \}\par 52 | \par 53 | \}\par 54 | \par 55 | Write-Host $lastStatus\par 56 | } 57 | -------------------------------------------------------------------------------- /OdSyncService - Copy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OdSyncService", "OdSyncService\OdSyncService.csproj", "{F55BC23A-4CB5-461E-BAB5-114B2D95440F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OdSyncServiceTests", "OdSyncServiceTests\OdSyncServiceTests.csproj", "{85F06619-6831-4B21-B48D-DC3EB179A4BE}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsole", "TestConsole\TestConsole.csproj", "{4D234C53-B2D1-4522-AC74-2A6649CEB192}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ODNative", "ODNative\ODNative.vcxproj", "{4222D206-0E8A-4F68-A171-4AFDB031098E}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Debug|ARM = Debug|ARM 18 | Debug|x64 = Debug|x64 19 | Debug|x86 = Debug|x86 20 | Release|Any CPU = Release|Any CPU 21 | Release|ARM = Release|ARM 22 | Release|x64 = Release|x64 23 | Release|x86 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|ARM.ActiveCfg = Debug|Any CPU 29 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|ARM.Build.0 = Debug|Any CPU 30 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|x64.ActiveCfg = Debug|x64 31 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|x64.Build.0 = Debug|x64 32 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|x86.ActiveCfg = Debug|x86 33 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Debug|x86.Build.0 = Debug|x86 34 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|ARM.ActiveCfg = Release|Any CPU 37 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|ARM.Build.0 = Release|Any CPU 38 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|x64.ActiveCfg = Release|x64 39 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|x64.Build.0 = Release|x64 40 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|x86.ActiveCfg = Release|x86 41 | {F55BC23A-4CB5-461E-BAB5-114B2D95440F}.Release|x86.Build.0 = Release|x86 42 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|ARM.ActiveCfg = Debug|Any CPU 45 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|ARM.Build.0 = Debug|Any CPU 46 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|x64.ActiveCfg = Debug|x64 47 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|x64.Build.0 = Debug|x64 48 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|x86.ActiveCfg = Debug|x86 49 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Debug|x86.Build.0 = Debug|x86 50 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|ARM.ActiveCfg = Release|Any CPU 53 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|ARM.Build.0 = Release|Any CPU 54 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|x64.ActiveCfg = Release|x64 55 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|x64.Build.0 = Release|x64 56 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|x86.ActiveCfg = Release|x86 57 | {85F06619-6831-4B21-B48D-DC3EB179A4BE}.Release|x86.Build.0 = Release|x86 58 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|ARM.ActiveCfg = Debug|Any CPU 61 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|ARM.Build.0 = Debug|Any CPU 62 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|x64.ActiveCfg = Debug|x64 63 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|x64.Build.0 = Debug|x64 64 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|x86.ActiveCfg = Debug|x86 65 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Debug|x86.Build.0 = Debug|x86 66 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|Any CPU.Build.0 = Release|Any CPU 68 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|ARM.ActiveCfg = Release|Any CPU 69 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|ARM.Build.0 = Release|Any CPU 70 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|x64.ActiveCfg = Release|x64 71 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|x64.Build.0 = Release|x64 72 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|x86.ActiveCfg = Release|x86 73 | {4D234C53-B2D1-4522-AC74-2A6649CEB192}.Release|x86.Build.0 = Release|x86 74 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|Any CPU.ActiveCfg = Debug|Win32 75 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|ARM.ActiveCfg = Debug|Win32 76 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x64.ActiveCfg = Debug|x64 77 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x64.Build.0 = Debug|x64 78 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x86.ActiveCfg = Debug|Win32 79 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x86.Build.0 = Debug|Win32 80 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|Any CPU.ActiveCfg = Release|Win32 81 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|ARM.ActiveCfg = Release|Win32 82 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x64.ActiveCfg = Release|x64 83 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x64.Build.0 = Release|x64 84 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x86.ActiveCfg = Release|Win32 85 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x86.Build.0 = Release|Win32 86 | EndGlobalSection 87 | GlobalSection(SolutionProperties) = preSolution 88 | HideSolutionNode = FALSE 89 | EndGlobalSection 90 | EndGlobal 91 | -------------------------------------------------------------------------------- /OdSyncService.VC-rvia-surface.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/OdSyncService.VC-rvia-surface.db -------------------------------------------------------------------------------- /OdSyncService.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.156 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ODNative", "ODNative\ODNative.vcxproj", "{4222D206-0E8A-4F68-A171-4AFDB031098E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneDriveLib", "OneDriveLib\OneDriveLib.csproj", "{0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ODOnDemand", "ODOnDemand\ODOnDemand.vcxproj", "{DBFDC140-542D-4C72-8746-7B79070BCF89}" 11 | EndProject 12 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "ODOnDemandSetup", "ODOnDemandSetup\ODOnDemandSetup.vdproj", "{88D40A7E-6C63-4A11-9461-D59350611C8D}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | CD_ROM|Any CPU = CD_ROM|Any CPU 17 | CD_ROM|ARM = CD_ROM|ARM 18 | CD_ROM|Mixed Platforms = CD_ROM|Mixed Platforms 19 | CD_ROM|x64 = CD_ROM|x64 20 | CD_ROM|x86 = CD_ROM|x86 21 | Debug|Any CPU = Debug|Any CPU 22 | Debug|ARM = Debug|ARM 23 | Debug|Mixed Platforms = Debug|Mixed Platforms 24 | Debug|x64 = Debug|x64 25 | Debug|x86 = Debug|x86 26 | DVD-5|Any CPU = DVD-5|Any CPU 27 | DVD-5|ARM = DVD-5|ARM 28 | DVD-5|Mixed Platforms = DVD-5|Mixed Platforms 29 | DVD-5|x64 = DVD-5|x64 30 | DVD-5|x86 = DVD-5|x86 31 | Release|Any CPU = Release|Any CPU 32 | Release|ARM = Release|ARM 33 | Release|Mixed Platforms = Release|Mixed Platforms 34 | Release|x64 = Release|x64 35 | Release|x86 = Release|x86 36 | SingleImage|Any CPU = SingleImage|Any CPU 37 | SingleImage|ARM = SingleImage|ARM 38 | SingleImage|Mixed Platforms = SingleImage|Mixed Platforms 39 | SingleImage|x64 = SingleImage|x64 40 | SingleImage|x86 = SingleImage|x86 41 | EndGlobalSection 42 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 43 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|Any CPU.ActiveCfg = Release|Win32 44 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|ARM.ActiveCfg = Release|Win32 45 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|Mixed Platforms.ActiveCfg = Release|Win32 46 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|Mixed Platforms.Build.0 = Release|Win32 47 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|x64.ActiveCfg = Release|x64 48 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|x64.Build.0 = Release|x64 49 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|x86.ActiveCfg = Release|Win32 50 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.CD_ROM|x86.Build.0 = Release|Win32 51 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|Any CPU.ActiveCfg = Debug|Win32 52 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|ARM.ActiveCfg = Debug|Win32 53 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 54 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|Mixed Platforms.Build.0 = Debug|Win32 55 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x64.ActiveCfg = Debug|x64 56 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x64.Build.0 = Debug|x64 57 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x86.ActiveCfg = Debug|Win32 58 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Debug|x86.Build.0 = Debug|Win32 59 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|Any CPU.ActiveCfg = Debug|Win32 60 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|ARM.ActiveCfg = Debug|Win32 61 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|Mixed Platforms.ActiveCfg = Debug|Win32 62 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|Mixed Platforms.Build.0 = Debug|Win32 63 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|x64.ActiveCfg = Debug|x64 64 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|x64.Build.0 = Debug|x64 65 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|x86.ActiveCfg = Debug|Win32 66 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.DVD-5|x86.Build.0 = Debug|Win32 67 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|Any CPU.ActiveCfg = Release|Win32 68 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|ARM.ActiveCfg = Release|Win32 69 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|Mixed Platforms.ActiveCfg = Release|Win32 70 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|Mixed Platforms.Build.0 = Release|Win32 71 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x64.ActiveCfg = Release|x64 72 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x64.Build.0 = Release|x64 73 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x86.ActiveCfg = Release|Win32 74 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.Release|x86.Build.0 = Release|Win32 75 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|Any CPU.ActiveCfg = Release|Win32 76 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|ARM.ActiveCfg = Release|Win32 77 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|Mixed Platforms.ActiveCfg = Release|Win32 78 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|Mixed Platforms.Build.0 = Release|Win32 79 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|x64.ActiveCfg = Release|x64 80 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|x64.Build.0 = Release|x64 81 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|x86.ActiveCfg = Release|Win32 82 | {4222D206-0E8A-4F68-A171-4AFDB031098E}.SingleImage|x86.Build.0 = Release|Win32 83 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 84 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 85 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|ARM.ActiveCfg = Release|Any CPU 86 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|ARM.Build.0 = Release|Any CPU 87 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|Mixed Platforms.ActiveCfg = Release|Any CPU 88 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|Mixed Platforms.Build.0 = Release|Any CPU 89 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|x64.ActiveCfg = Release|Any CPU 90 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|x64.Build.0 = Release|Any CPU 91 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|x86.ActiveCfg = Release|Any CPU 92 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.CD_ROM|x86.Build.0 = Release|Any CPU 93 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 94 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|Any CPU.Build.0 = Debug|Any CPU 95 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|ARM.ActiveCfg = Debug|Any CPU 96 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|ARM.Build.0 = Debug|Any CPU 97 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 98 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 99 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|x64.ActiveCfg = Debug|Any CPU 100 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|x64.Build.0 = Debug|Any CPU 101 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|x86.ActiveCfg = Debug|Any CPU 102 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Debug|x86.Build.0 = Debug|Any CPU 103 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 104 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 105 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|ARM.ActiveCfg = Debug|Any CPU 106 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|ARM.Build.0 = Debug|Any CPU 107 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|Mixed Platforms.ActiveCfg = Debug|Any CPU 108 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|Mixed Platforms.Build.0 = Debug|Any CPU 109 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|x64.ActiveCfg = Debug|Any CPU 110 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|x64.Build.0 = Debug|Any CPU 111 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|x86.ActiveCfg = Debug|Any CPU 112 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.DVD-5|x86.Build.0 = Debug|Any CPU 113 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|Any CPU.ActiveCfg = Release|Any CPU 114 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|Any CPU.Build.0 = Release|Any CPU 115 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|ARM.ActiveCfg = Release|Any CPU 116 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|ARM.Build.0 = Release|Any CPU 117 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 118 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|Mixed Platforms.Build.0 = Release|Any CPU 119 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|x64.ActiveCfg = Release|Any CPU 120 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|x64.Build.0 = Release|Any CPU 121 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|x86.ActiveCfg = Release|Any CPU 122 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.Release|x86.Build.0 = Release|Any CPU 123 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 124 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|Any CPU.Build.0 = Release|Any CPU 125 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|ARM.ActiveCfg = Release|Any CPU 126 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|ARM.Build.0 = Release|Any CPU 127 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|Mixed Platforms.ActiveCfg = Release|Any CPU 128 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|Mixed Platforms.Build.0 = Release|Any CPU 129 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|x64.ActiveCfg = Release|Any CPU 130 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|x64.Build.0 = Release|Any CPU 131 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|x86.ActiveCfg = Release|Any CPU 132 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3}.SingleImage|x86.Build.0 = Release|Any CPU 133 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|Any CPU.ActiveCfg = Debug|Win32 134 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|Any CPU.Build.0 = Debug|Win32 135 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|ARM.ActiveCfg = Debug|Win32 136 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|ARM.Build.0 = Debug|Win32 137 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|Mixed Platforms.ActiveCfg = Debug|Win32 138 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|Mixed Platforms.Build.0 = Debug|Win32 139 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|x64.ActiveCfg = Debug|x64 140 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|x64.Build.0 = Debug|x64 141 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|x86.ActiveCfg = Debug|Win32 142 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.CD_ROM|x86.Build.0 = Debug|Win32 143 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|Any CPU.ActiveCfg = Debug|Win32 144 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|ARM.ActiveCfg = Debug|Win32 145 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 146 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|Mixed Platforms.Build.0 = Debug|Win32 147 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|x64.ActiveCfg = Debug|x64 148 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|x64.Build.0 = Debug|x64 149 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|x86.ActiveCfg = Debug|Win32 150 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Debug|x86.Build.0 = Debug|Win32 151 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|Any CPU.ActiveCfg = Debug|Win32 152 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|Any CPU.Build.0 = Debug|Win32 153 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|ARM.ActiveCfg = Debug|Win32 154 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|ARM.Build.0 = Debug|Win32 155 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|Mixed Platforms.ActiveCfg = Debug|Win32 156 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|Mixed Platforms.Build.0 = Debug|Win32 157 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|x64.ActiveCfg = Debug|x64 158 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|x64.Build.0 = Debug|x64 159 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|x86.ActiveCfg = Debug|Win32 160 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.DVD-5|x86.Build.0 = Debug|Win32 161 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|Any CPU.ActiveCfg = Release|Win32 162 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|ARM.ActiveCfg = Release|Win32 163 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|Mixed Platforms.ActiveCfg = Release|Win32 164 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|Mixed Platforms.Build.0 = Release|Win32 165 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|x64.ActiveCfg = Release|x64 166 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|x64.Build.0 = Release|x64 167 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|x86.ActiveCfg = Release|Win32 168 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.Release|x86.Build.0 = Release|Win32 169 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|Any CPU.ActiveCfg = Debug|Win32 170 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|Any CPU.Build.0 = Debug|Win32 171 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|ARM.ActiveCfg = Debug|Win32 172 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|ARM.Build.0 = Debug|Win32 173 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|Mixed Platforms.ActiveCfg = Debug|Win32 174 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|Mixed Platforms.Build.0 = Debug|Win32 175 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|x64.ActiveCfg = Debug|x64 176 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|x64.Build.0 = Debug|x64 177 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|x86.ActiveCfg = Debug|Win32 178 | {DBFDC140-542D-4C72-8746-7B79070BCF89}.SingleImage|x86.Build.0 = Debug|Win32 179 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.CD_ROM|Any CPU.ActiveCfg = Debug 180 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.CD_ROM|ARM.ActiveCfg = Debug 181 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.CD_ROM|Mixed Platforms.ActiveCfg = Debug 182 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.CD_ROM|x64.ActiveCfg = Debug 183 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.CD_ROM|x86.ActiveCfg = Debug 184 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Debug|Any CPU.ActiveCfg = Debug 185 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Debug|ARM.ActiveCfg = Debug 186 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Debug|Mixed Platforms.ActiveCfg = Debug 187 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Debug|x64.ActiveCfg = Debug 188 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Debug|x86.ActiveCfg = Debug 189 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.DVD-5|Any CPU.ActiveCfg = Debug 190 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.DVD-5|ARM.ActiveCfg = Debug 191 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.DVD-5|Mixed Platforms.ActiveCfg = Debug 192 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.DVD-5|x64.ActiveCfg = Debug 193 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.DVD-5|x86.ActiveCfg = Debug 194 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Release|Any CPU.ActiveCfg = Release 195 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Release|ARM.ActiveCfg = Release 196 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Release|Mixed Platforms.ActiveCfg = Release 197 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Release|x64.ActiveCfg = Release 198 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.Release|x86.ActiveCfg = Release 199 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.SingleImage|Any CPU.ActiveCfg = Debug 200 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.SingleImage|ARM.ActiveCfg = Debug 201 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.SingleImage|Mixed Platforms.ActiveCfg = Debug 202 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.SingleImage|x64.ActiveCfg = Debug 203 | {88D40A7E-6C63-4A11-9461-D59350611C8D}.SingleImage|x86.ActiveCfg = Debug 204 | EndGlobalSection 205 | GlobalSection(SolutionProperties) = preSolution 206 | HideSolutionNode = FALSE 207 | EndGlobalSection 208 | GlobalSection(ExtensibilityGlobals) = postSolution 209 | SolutionGuid = {223C73A1-27AF-434C-945C-66800EEC3D49} 210 | EndGlobalSection 211 | EndGlobal 212 | -------------------------------------------------------------------------------- /OneDriveLib/GetStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using OdSyncService; 6 | using System.Management.Automation; 7 | using System.IO; 8 | using System.Runtime.InteropServices; 9 | 10 | namespace OneDriveLib 11 | { 12 | [Cmdlet(VerbsCommon.Get, "ODStatus", DefaultParameterSetName = "Regular")] 13 | public class GetStatus: PSCmdlet 14 | { 15 | [Parameter(HelpMessage = "Type of service (e.g.: Business1 or Personal")] 16 | public string Type 17 | { 18 | get; set; 19 | } 20 | 21 | [Parameter(HelpMessage = "To test the status of a specific path",ParameterSetName = "Regular")] 22 | public string ByPath 23 | { 24 | get; set; 25 | } 26 | 27 | [Parameter(HelpMessage = "To test a specific Icon overlay (for other services like Dropbox)", ParameterSetName = "Regular")] 28 | public Guid CLSID 29 | { 30 | get; set; 31 | } 32 | 33 | private bool includeLog = false; 34 | [Parameter(HelpMessage = "Create a log file")] 35 | public SwitchParameter IncludeLog 36 | { 37 | get { return includeLog; } 38 | set { includeLog = value; } 39 | } 40 | 41 | private bool onDemandOnly = false; 42 | [Parameter(HelpMessage = "Skip check for non-OnDemand and only gets the OnDemand status", ParameterSetName = OnDemandString)] 43 | public SwitchParameter OnDemandOnly 44 | { 45 | get { return onDemandOnly; } 46 | set { onDemandOnly = value; } 47 | } 48 | 49 | private bool showDllPath = false; 50 | [Parameter(HelpMessage = "Show the temporary native DLL path. You may want to delete it after unloading the process", ParameterSetName = OnDemandString)] 51 | public SwitchParameter ShowDllPath 52 | { 53 | get { return showDllPath; } 54 | set { showDllPath = value; } 55 | } 56 | internal const string dllName = "ODNative.dll"; 57 | private const string OnDemandString = "OnDemand"; 58 | static string dllPath = null; 59 | static string originalPath = null; 60 | // private bool disposedValue; 61 | 62 | protected override void ProcessRecord() 63 | { 64 | base.ProcessRecord(); 65 | if (!Environment.UserInteractive && ParameterSetName != OnDemandString) 66 | throw new InvalidOperationException("Non-Interactive mode detected. OneDrive Status can only be checked interactively unless -OnDemandOnly is specified"); 67 | if (UacHelper.IsProcessElevated && ParameterSetName != OnDemandString) 68 | throw new InvalidOperationException("PowerShell is running in Administrator mode. OneDrive status cannot be checked in elevated privileges"); 69 | OdSyncStatusWS.OnDemandOnly = onDemandOnly; 70 | WriteLog.ShouldLog = includeLog; 71 | if (includeLog) 72 | WriteVerbose("Log file is being saved @ "+WriteLog.FileName); 73 | if (onDemandOnly) 74 | { 75 | WriteVerbose("On Demand Only check"); 76 | WriteLog.WriteInformationEvent("On Demand Only option selected"); 77 | } 78 | if (showDllPath) 79 | WriteVerbose("Show DLL folder is enabled"); 80 | if (dllPath == null) 81 | { 82 | CopyDLL(); 83 | } 84 | 85 | if(showDllPath) 86 | Host.UI.WriteLine($"The temporary DLL path is '{Path.Combine(dllPath, dllName)}'"); 87 | OdSyncStatusWS os = new OdSyncStatusWS(); 88 | List statuses = new List(); 89 | 90 | // Just Get the Path 91 | if(!String.IsNullOrEmpty(ByPath)) 92 | { 93 | WriteLog.WriteInformationEvent($"Path being tested is '{ByPath}'"); 94 | if(CLSID == Guid.Empty) 95 | WriteObject(os.GetStatus(ByPath).ToString()); 96 | else 97 | { 98 | 99 | WriteObject(Native.API.IsCertainType(ByPath, CLSID)); 100 | } 101 | return; 102 | 103 | } 104 | var statusCol = os.GetStatus(); 105 | foreach(var status in statusCol) 106 | { 107 | if (String.IsNullOrEmpty(Type) || status.ServiceType.ToLower().Contains(Type.ToLower().Replace("*", ""))) 108 | { 109 | WriteLog.WriteInformationEvent($"Guid Type being tested is '{CLSID}'"); 110 | if (CLSID != Guid.Empty) 111 | { 112 | status.StatusString = Native.API.IsCertainType(status.LocalPath, CLSID) ? "GuidFound "+CLSID.ToString("B") : "GuidNotFound " + CLSID.ToString("B"); 113 | } 114 | statuses.Add(status); 115 | 116 | } 117 | 118 | } 119 | WriteObject(statuses.ToArray()); 120 | 121 | } 122 | 123 | private static void CopyDLL() 124 | { 125 | dllPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); 126 | try 127 | { 128 | Directory.CreateDirectory(dllPath); 129 | } 130 | catch (Exception ex) 131 | { 132 | throw new Exception(String.Format("Unable to generate folder for support files at {0}\n{1}", dllPath, ex.ToString())); 133 | 134 | } 135 | byte[] streamBytes = null; 136 | if (Marshal.SizeOf(new IntPtr()) == 8) // 64 bits 137 | { 138 | streamBytes = Properties.Resources.ODNative64; 139 | } 140 | else 141 | { 142 | streamBytes = Properties.Resources.ODNative32; 143 | } 144 | try 145 | { 146 | using (Stream fileStream = File.OpenWrite(Path.Combine(dllPath, dllName))) 147 | { 148 | fileStream.Write(streamBytes, 0, streamBytes.Length); 149 | } 150 | } 151 | catch (Exception ex) 152 | { 153 | string tmpStr = dllPath; 154 | dllPath = null; 155 | throw new Exception(String.Format("Unable to generate support files at {0}\n{1}", dllPath, ex.ToString())); 156 | } 157 | // Set up search path DLL 158 | string path = Environment.GetEnvironmentVariable("PATH") ?? string.Empty; 159 | if (originalPath == null) 160 | originalPath = path; 161 | path += ";" + dllPath; 162 | Environment.SetEnvironmentVariable("PATH", path); 163 | } 164 | 165 | /* 166 | protected virtual void Dispose(bool disposing) 167 | { 168 | if (!disposedValue) 169 | { 170 | if (disposing) 171 | { 172 | // TODO: dispose managed state (managed objects) 173 | } 174 | 175 | if (dllPath != null && File.Exists(Path.Combine(dllPath, dllName))) 176 | { 177 | bool removed = false; 178 | try 179 | { 180 | removed = Native.API.UnloadModule(); 181 | //if (removed) 182 | // WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' removed from memory"); 183 | //else 184 | // WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' NOT removed from memory"); 185 | 186 | File.Delete(Path.Combine(dllPath, dllName)); 187 | DirectoryInfo di = new DirectoryInfo(dllPath); 188 | 189 | //WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' removed successfully"); 190 | //Environment.SetEnvironmentVariable("PATH", originalPath); 191 | dllPath = null; 192 | try 193 | { 194 | di.Delete(true); 195 | //WriteVerbose($"Folder '{dllPath}' removed successfully"); 196 | } 197 | catch (Exception ex) 198 | { 199 | //WriteWarning($"Folder '{dllPath}' could not be removed. Error {ex.ToString()}"); 200 | //WriteLog.WriteWarningEvent($"Folder '{dllPath}' could not be removed. Error {ex.ToString()}"); 201 | } 202 | } 203 | catch (Exception ex) 204 | { 205 | //WriteLog.WriteWarningEvent($"DLL '{Path.Combine(dllPath, dllName)}' could not be removed. Error: {ex.ToString()}"); 206 | //WriteWarning($"DLL '{Path.Combine(dllPath, dllName)}' could not be removed. Error: {ex.ToString()}"); 207 | } 208 | } 209 | 210 | disposedValue = true; 211 | } 212 | } 213 | */ 214 | 215 | /* 216 | ~GetStatus() 217 | { 218 | // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method 219 | //Dispose(disposing: false); 220 | if (dllPath != null && File.Exists(Path.Combine(dllPath, dllName))) 221 | { 222 | bool removed = false; 223 | try 224 | { 225 | removed = Native.API.UnloadModule(); 226 | //if (removed) 227 | // WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' removed from memory"); 228 | //else 229 | // WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' NOT removed from memory"); 230 | 231 | File.Delete(Path.Combine(dllPath, dllName)); 232 | DirectoryInfo di = new DirectoryInfo(dllPath); 233 | 234 | //WriteVerbose($"DLL '{Path.Combine(dllPath, dllName)}' removed successfully"); 235 | //Environment.SetEnvironmentVariable("PATH", originalPath); 236 | dllPath = null; 237 | try 238 | { 239 | di.Delete(true); 240 | //WriteVerbose($"Folder '{dllPath}' removed successfully"); 241 | } 242 | catch (Exception ex) 243 | { 244 | //WriteWarning($"Folder '{dllPath}' could not be removed. Error {ex.ToString()}"); 245 | //WriteLog.WriteWarningEvent($"Folder '{dllPath}' could not be removed. Error {ex.ToString()}"); 246 | } 247 | } 248 | catch (Exception ex) 249 | { 250 | //WriteLog.WriteWarningEvent($"DLL '{Path.Combine(dllPath, dllName)}' could not be removed. Error: {ex.ToString()}"); 251 | //WriteWarning($"DLL '{Path.Combine(dllPath, dllName)}' could not be removed. Error: {ex.ToString()}"); 252 | } 253 | } 254 | } 255 | */ 256 | 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /OneDriveLib/IOdSyncStatusWS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.Serialization; 6 | using System.ServiceModel; 7 | using System.Text; 8 | using System.Threading; 9 | 10 | namespace OdSyncService 11 | { 12 | // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IOdSyncStatusWS" in both code and config file together. 13 | [ServiceContract] 14 | public interface IOdSyncStatusWS 15 | { 16 | [OperationContract] 17 | StatusDetailCollection GetStatus(); 18 | 19 | } 20 | 21 | [DataContract] 22 | public enum ServiceStatus 23 | { 24 | Error, 25 | Shared, 26 | SharedSync, 27 | UpToDate, 28 | Syncing, 29 | ReadOnly, 30 | OnDemandOrUnknown 31 | } 32 | 33 | public struct QuotaColor 34 | { 35 | public byte A; 36 | public byte R; 37 | public byte G; 38 | public byte B; 39 | public QuotaColor(byte A, byte R, byte G, byte B) 40 | { 41 | this.A = A; 42 | this.R = R; 43 | this.G = G; 44 | this.B = B; 45 | } 46 | 47 | public override string ToString() 48 | { 49 | return $"A: {A}, R: {R}, G: {G}, B: {B}"; 50 | } 51 | }; 52 | 53 | public class PathStatus 54 | { 55 | internal PathStatus(string FilePath, ServiceStatus FileStatus) 56 | { 57 | Path = FilePath; 58 | Status = FileStatus.ToString(); 59 | } 60 | 61 | public string Path 62 | { 63 | protected set; 64 | get; 65 | } 66 | 67 | public string Status 68 | { 69 | protected set; 70 | get; 71 | } 72 | } 73 | 74 | [DataContract] 75 | public class StatusDetail 76 | { 77 | [DataMember] 78 | public string SyncRootId; 79 | 80 | [DataMember] 81 | public string LocalPath; 82 | 83 | [DataMember] 84 | public string UserSID; 85 | 86 | [DataMember] 87 | public string UserName; 88 | 89 | internal ServiceStatus Status; 90 | 91 | [DataMember] 92 | public int NewApiStatus = -1; 93 | 94 | [DataMember] 95 | public string DisplayName; 96 | 97 | [DataMember] 98 | public string ServiceType; 99 | 100 | [DataMember] 101 | public string StatusString; 102 | 103 | [DataMember] 104 | public string IconPath; 105 | 106 | [DataMember] 107 | public string QuotaLabel; 108 | 109 | [DataMember] 110 | public ulong QuotaTotalBytes = 0; 111 | 112 | [DataMember] 113 | public ulong QuotaUsedBytes = 0; 114 | 115 | [DataMember] 116 | public QuotaColor QuotaColor = new QuotaColor(0, 0, 0, 0); 117 | 118 | [DataMember] 119 | public bool IsNewApi = false; 120 | 121 | public List GetUnsynchedFiles(bool StopAtFirst = true) 122 | { 123 | string[] files = Directory.GetFiles(LocalPath, "*.*", SearchOption.AllDirectories); 124 | OdSyncStatusWS os = new OdSyncStatusWS(); 125 | List synched = new List(); 126 | int i = 0; 127 | foreach (var file in files) 128 | { 129 | var status = os.GetStatus(file); 130 | 131 | if(status != ServiceStatus.OnDemandOrUnknown && status != ServiceStatus.UpToDate && status != ServiceStatus.SharedSync) 132 | { 133 | synched.Add(new PathStatus(file, status)); 134 | if(StopAtFirst) 135 | { 136 | return synched; 137 | } 138 | if (i++ == 100) 139 | { 140 | i = 0; 141 | Thread.Sleep(0); // let the cpu process other threads 142 | } 143 | } 144 | } 145 | return synched; 146 | } 147 | } 148 | 149 | [CollectionDataContract] 150 | public class StatusDetailCollection : List 151 | { 152 | public StatusDetailCollection() 153 | : base() 154 | { 155 | } 156 | 157 | public StatusDetailCollection(List items) 158 | : base() 159 | { 160 | foreach (var item in items) 161 | { 162 | Add(item); 163 | } 164 | } 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /OneDriveLib/IShellIconOverlayIdentifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using OneDriveLib; 8 | 9 | namespace Native 10 | { 11 | 12 | 13 | [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] 14 | public struct OneDriveState 15 | { 16 | public int CurrentState; 17 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = API.MAX_STATE_LABEL)] 18 | public string Label; 19 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = API.MAX_ICON_URI)] 20 | public string IconUri; 21 | [MarshalAs(UnmanagedType.Bool)] 22 | public bool isQuotaAvailable; 23 | public ulong TotalQuota; 24 | public ulong UsedQuota; 25 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = API.MAX_QUOTA_LABEL)] 26 | public string QuotaLabel; 27 | public byte IconColorA; 28 | public byte IconColorR; 29 | public byte IconColorG; 30 | public byte IconColorB; 31 | }; 32 | 33 | 34 | public class API 35 | { 36 | public const int MAX_STATE_LABEL = 255; 37 | public const int MAX_ICON_URI = 1024; 38 | public const int MAX_QUOTA_LABEL = 255; 39 | [DllImport(GetStatus.dllName, EntryPoint = "?GetStatusByTypeApi@@YAJPEA_WPEAUOneDriveState@@@Z", CallingConvention = CallingConvention.Cdecl)] 40 | public static extern uint GetStatusByTypeApi( 41 | [In, MarshalAs(UnmanagedType.LPWStr)] string SyncRootId, 42 | ref OneDriveState State 43 | ); 44 | 45 | [DllImport(GetStatus.dllName, EntryPoint = "?GetStatusByTypeApi@@YAJPA_WPAUOneDriveState@@@Z", CallingConvention = CallingConvention.Cdecl)] 46 | public static extern uint GetStatusByTypeApi32( 47 | [In, MarshalAs(UnmanagedType.LPWStr)] string SyncRootId, 48 | ref OneDriveState State 49 | ); 50 | 51 | [DllImport(GetStatus.dllName, EntryPoint = "?GetShellInterfaceFromGuid@@YAJPEAHPEA_W1@Z", CallingConvention = CallingConvention.Cdecl)] 52 | public static extern uint GetShellInterfaceFromGuid( 53 | [Out,MarshalAs(UnmanagedType.Bool)] out bool IsTrue, 54 | [In, MarshalAs(UnmanagedType.LPWStr)] string GuidString, 55 | [In,MarshalAs(UnmanagedType.LPWStr)] string Path); 56 | 57 | [DllImport(GetStatus.dllName, EntryPoint = "?GetShellInterfaceFromGuid@@YAJPAHPA_W1@Z", CallingConvention = CallingConvention.Cdecl)] 58 | public static extern uint GetShellInterfaceFromGuid32( 59 | [Out, MarshalAs(UnmanagedType.Bool)] out bool IsTrue, 60 | [In, MarshalAs(UnmanagedType.LPWStr)] string GuidString, 61 | [In, MarshalAs(UnmanagedType.LPWStr)] string Path); 62 | 63 | [DllImport(GetStatus.dllName, EntryPoint = "?GetStatusByType@@YAJPEA_W0HPEAH@Z", CallingConvention = CallingConvention.Cdecl)] 64 | public static extern uint GetStatusByType( 65 | [In, MarshalAs(UnmanagedType.LPWStr)] string OneDriveType, 66 | [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder Status, 67 | [In, MarshalAs(UnmanagedType.I4)] int Size, 68 | [In, Out, MarshalAs(UnmanagedType.I4)] ref int ActualSize); 69 | 70 | [DllImport(GetStatus.dllName, EntryPoint = "?GetStatusByType@@YAJPA_W0HPAH@Z", CallingConvention = CallingConvention.Cdecl)] 71 | public static extern uint GetStatusByType32( 72 | [In, MarshalAs(UnmanagedType.LPWStr)] string OneDriveType, 73 | [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder Status, 74 | [In, MarshalAs(UnmanagedType.I4)] int Size, 75 | [In, Out, MarshalAs(UnmanagedType.I4)] ref int ActualSize); 76 | 77 | [DllImport("kernel32", SetLastError = true)] 78 | static extern bool FreeLibrary(IntPtr hModule); 79 | 80 | [DllImport("kernel32", SetLastError = true)] 81 | static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPWStr)] string lpFileName); 82 | 83 | public static bool UnloadModule() 84 | { 85 | foreach (ProcessModule mod in Process.GetCurrentProcess().Modules) 86 | { 87 | if (mod.ModuleName.ToLower() == GetStatus.dllName.ToLower()) 88 | { 89 | FreeLibrary(mod.BaseAddress); 90 | return true; 91 | } 92 | } 93 | return false; 94 | } 95 | 96 | public static bool LoadModuleIfNot() 97 | { 98 | bool loaded = false; 99 | foreach (ProcessModule mod in Process.GetCurrentProcess().Modules) 100 | { 101 | if (mod.ModuleName.ToLower() == GetStatus.dllName.ToLower()) 102 | { 103 | loaded = true; 104 | 105 | } 106 | } 107 | if(!loaded) 108 | { 109 | var result = LoadLibrary(GetStatus.dllName); 110 | return (result != IntPtr.Zero); 111 | } 112 | return true; 113 | 114 | 115 | } 116 | 117 | const uint CLSCTX_INPROC = 3; 118 | static public bool IsTrue(string Path) 119 | { 120 | 121 | Guid CLSID = typeof(T).GUID; 122 | 123 | var isType = IsCertainType(Path, CLSID); 124 | OneDriveLib.WriteLog.WriteToFile = true; 125 | OneDriveLib.WriteLog.WriteInformationEvent(String.Format("Testing Type: {0} [{1}], Path: {2}: {3}", typeof(T).ToString(), CLSID, Path, isType)); 126 | 127 | return IsCertainType(Path, CLSID); 128 | } 129 | 130 | static public uint GetStateBySyncRootId(string SyncRootId, out OneDriveState State) 131 | { 132 | State = new OneDriveState(); 133 | uint hr = 0; 134 | if (Marshal.SizeOf(IntPtr.Zero) == 8) 135 | hr = GetStatusByTypeApi(SyncRootId, ref State); 136 | else 137 | hr = GetStatusByTypeApi32(SyncRootId, ref State); 138 | return hr; 139 | } 140 | 141 | static public string GetStatusByDisplayName(string DisplayName) 142 | { 143 | 144 | int size = 2000; 145 | StringBuilder status = new StringBuilder(size); 146 | if (Marshal.SizeOf(IntPtr.Zero) == 8) 147 | _ = GetStatusByType(DisplayName, status, size, ref size); 148 | else 149 | _ = GetStatusByType32(DisplayName, status, size, ref size); 150 | string retStatus = status.ToString(); 151 | var start = Math.Max(0, retStatus.IndexOf("\n")); 152 | return retStatus.Replace("\n","").Substring(start); 153 | } 154 | static public bool IsCertainType(string Path, Guid CLSID) 155 | { 156 | bool isTrue = false; 157 | uint hr = 1; 158 | if (Marshal.SizeOf(IntPtr.Zero) == 8) 159 | hr = GetShellInterfaceFromGuid(out isTrue, CLSID.ToString("B"), Path + "\\"); 160 | else 161 | hr = GetShellInterfaceFromGuid32(out isTrue, CLSID.ToString("B"), Path + "\\"); 162 | 163 | #if DEBUG 164 | OneDriveLib.WriteLog.WriteToFile = true; 165 | //Console.Write("{0}:{1}({2}) ", typeof(T).ToString(), CLSID.ToString("B"), isTrue); 166 | #endif 167 | OneDriveLib.WriteLog.WriteInformationEvent(String.Format("Testing CLSID: {0}, Path: {1}, HR=0x{2:X}", CLSID.ToString("B"), Path, hr)); 168 | 169 | if (hr == 0) 170 | return isTrue; 171 | else 172 | return false; 173 | 174 | } 175 | } 176 | 177 | 178 | 179 | [ComVisible(false)] 180 | [ComImport] 181 | [Guid("0C6C4200-C589-11D0-999A-00C04FD655E1")] 182 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 183 | 184 | public interface IShellIconOverlayIdentifier 185 | { 186 | 187 | [PreserveSig] 188 | int IsMemberOf([MarshalAs(UnmanagedType.LPWStr)] string path, 189 | uint attributes); 190 | 191 | [PreserveSig] 192 | int GetOverlayInfo( 193 | IntPtr iconFileBuffer, 194 | int iconFileBufferSize, 195 | out int iconIndex, 196 | out uint flags); 197 | 198 | [PreserveSig] 199 | int GetPriority(out int priority); 200 | 201 | } 202 | 203 | [ComVisible(false)] 204 | [ComImport] 205 | [Guid("F241C880-6982-4CE5-8CF7-7085BA96DA5A")] 206 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 207 | public interface IIconUpToDate : IShellIconOverlayIdentifier 208 | { } 209 | 210 | [ComVisible(false)] 211 | [ComImport] 212 | [Guid("BBACC218-34EA-4666-9D7A-C78F2274A524")] 213 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 214 | public interface IIconError : IShellIconOverlayIdentifier 215 | { } 216 | 217 | [ComVisible(false)] 218 | [ComImport] 219 | [Guid("5AB7172C-9C11-405C-8DD5-AF20F3606282")] 220 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 221 | public interface IIconShared : IShellIconOverlayIdentifier 222 | { } 223 | 224 | [ComVisible(false)] 225 | [ComImport] 226 | [Guid("A78ED123-AB77-406B-9962-2A5D9D2F7F30")] 227 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 228 | public interface IIconSharedSync : IShellIconOverlayIdentifier 229 | { } 230 | 231 | [ComVisible(false)] 232 | [ComImport] 233 | [Guid("A0396A93-DC06-4AEF-BEE9-95FFCCAEF20E")] 234 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 235 | public interface IIconSync : IShellIconOverlayIdentifier 236 | { } 237 | 238 | [ComVisible(false)] 239 | [ComImport] 240 | [Guid("9AA2F32D-362A-42D9-9328-24A483E2CCC3")] 241 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 242 | public interface IIconReadOnly : IShellIconOverlayIdentifier 243 | { } 244 | 245 | 246 | [ComVisible(false)] 247 | [ComImport] 248 | [Guid("8BA85C75-763B-4103-94EB-9470F12FE0F7")] 249 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 250 | public interface IIconProErrorConflict : IShellIconOverlayIdentifier 251 | { } 252 | 253 | [ComVisible(false)] 254 | [ComImport] 255 | [Guid("CD55129A-B1A1-438E-A425-CEBC7DC684EE")] 256 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 257 | public interface IIconProSyncInProgress : IShellIconOverlayIdentifier 258 | { } 259 | 260 | [ComVisible(false)] 261 | [ComImport] 262 | [Guid("E768CD3B-BDDC-436D-9C13-E1B39CA257B1")] 263 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 264 | public interface IIconProInSync : IShellIconOverlayIdentifier 265 | { } 266 | 267 | 268 | [ComVisible(false)] 269 | [ComImport] 270 | [Guid("8BA85C75-763B-4103-94EB-9470F12FE0F7")] 271 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 272 | public interface IIconGrooveError : IShellIconOverlayIdentifier 273 | { } 274 | 275 | [ComVisible(false)] 276 | [ComImport] 277 | [Guid("CD55129A-B1A1-438E-A425-CEBC7DC684EE")] 278 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 279 | public interface IIconGrooveSync : IShellIconOverlayIdentifier 280 | { } 281 | 282 | [ComVisible(false)] 283 | [ComImport] 284 | [Guid("E768CD3B-BDDC-436D-9C13-E1B39CA257B1")] 285 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 286 | public interface IIconGrooveUpToDate : IShellIconOverlayIdentifier 287 | { } 288 | 289 | 290 | [ComVisible(false)] 291 | [ComImport] 292 | [Guid("0C6C4200-C589-11D0-999A-00C04FD655E1")] 293 | public class ShellIconOverlayIdentifier 294 | { 295 | 296 | } 297 | /* 298 | --RegistryStringValue(L"", L"{BBACC218-34EA-4666-9D7A-C78F2274A524}"), // " OneDrive1", Error Icon Overlay 299 | --RegistryStringValue(L"", L"{5AB7172C-9C11-405C-8DD5-AF20F3606282}"), // " OneDrive2", Shared Icon Overlay 300 | --RegistryStringValue(L"", L"{A78ED123-AB77-406B-9962-2A5D9D2F7F30}"), // " OneDrive3", Shared Syncing Icon Overlay 301 | --RegistryStringValue(L"", L"{F241C880-6982-4CE5-8CF7-7085BA96DA5A}"), // " OneDrive4", Up-to-Date Icon Overlay 302 | --RegistryStringValue(L"", L"{A0396A93-DC06-4AEF-BEE9-95FFCCAEF20E}"), // " OneDrive5", Syncing Icon Overlay 303 | --RegistryStringValue(L"", L"{9AA2F32D-362A-42D9-9328-24A483E2CCC3}"), // " OneDrive6", Read Only Up to Date Overlay 304 | 305 | */ 306 | 307 | } 308 | -------------------------------------------------------------------------------- /OneDriveLib/OdSyncStatusWS.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Runtime.Serialization; 7 | using System.Security.Principal; 8 | using System.ServiceModel; 9 | using System.Text; 10 | using Native; 11 | using System.DirectoryServices.AccountManagement; 12 | //using FileSyncLibrary; 13 | 14 | namespace OdSyncService 15 | { 16 | // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "OdSyncStatusWS" in both code and config file together. 17 | public class OdSyncStatusWS : IOdSyncStatusWS 18 | { 19 | private static string userSID = null; 20 | 21 | internal static bool OnDemandOnly { get; set; } = false; 22 | 23 | private static string UserSID 24 | { 25 | get 26 | { 27 | if (userSID == null) 28 | { 29 | var userIdentity = WindowsIdentity.GetCurrent(); 30 | userSID = userIdentity.User.ToString(); 31 | } 32 | return userSID; 33 | } 34 | } 35 | 36 | public ServiceStatus GetStatus(string Path) 37 | { 38 | 39 | if (!OnDemandOnly) 40 | { 41 | if (Native.API.IsTrue(Path)) 42 | return ServiceStatus.Error; 43 | if (Native.API.IsTrue(Path)) 44 | return ServiceStatus.UpToDate; 45 | if (Native.API.IsTrue(Path)) 46 | return ServiceStatus.ReadOnly; 47 | if (Native.API.IsTrue(Path)) 48 | return ServiceStatus.Shared; 49 | if (Native.API.IsTrue(Path)) 50 | return ServiceStatus.SharedSync; 51 | if (Native.API.IsTrue(Path)) 52 | return ServiceStatus.Syncing; 53 | if (Native.API.IsTrue(Path)) 54 | return ServiceStatus.UpToDate; 55 | if (Native.API.IsTrue(Path)) 56 | return ServiceStatus.Syncing; 57 | if (Native.API.IsTrue(Path)) 58 | return ServiceStatus.Error; 59 | } 60 | 61 | return ServiceStatus.OnDemandOrUnknown; 62 | } 63 | 64 | 65 | public IEnumerable GetStatusInternal() 66 | { 67 | //const string hklm = "HKEY_LOCAL_MACHINE"; 68 | const string subkeyString = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\"; // SkyDrive\UserSyncRoots\"; 69 | 70 | using (var key = Registry.LocalMachine.OpenSubKey(subkeyString)) 71 | { 72 | if (key == null) 73 | { 74 | yield return new StatusDetail() { Status = ServiceStatus.OnDemandOrUnknown }; 75 | } 76 | else 77 | { 78 | if (key.SubKeyCount == 0) 79 | { 80 | yield return new StatusDetail() { Status = ServiceStatus.OnDemandOrUnknown, ServiceType="OneDrive" }; 81 | } 82 | foreach (var subkey in key.GetSubKeyNames()) 83 | { 84 | var displayKey = key.OpenSubKey(subkey); 85 | var displayName = displayKey?.GetValue("DisplayNameResource") as string; 86 | using (var userKey = key.OpenSubKey(String.Format("{0}{1}", subkey, @"\UserSyncRoots"))) 87 | { 88 | if (userKey != null && userKey.Name.Contains(UserSID)) 89 | { 90 | 91 | 92 | foreach (var valueName in userKey.GetValueNames()) 93 | { 94 | var detail = new StatusDetail(); 95 | try 96 | { 97 | var id = new SecurityIdentifier(valueName); 98 | string userName = id.Translate(typeof(NTAccount)).Value; 99 | detail.UserName = userName; 100 | detail.UserSID = valueName; 101 | detail.DisplayName = displayName; 102 | detail.SyncRootId = subkey; 103 | 104 | string[] parts = userKey.Name.Split('!'); 105 | 106 | if (parts.Length > 1) 107 | { 108 | detail.ServiceType = parts[Math.Min(2, parts.Length - 1)].Split('|')[0]; 109 | } else 110 | { 111 | detail.ServiceType = "INVALID"; 112 | } 113 | } 114 | catch (Exception ex) 115 | { 116 | detail.UserName = String.Format("{0}: {1}", ex.GetType().ToString(), 117 | ex.Message); 118 | OneDriveLib.WriteLog.WriteErrorEvent("OneDrive " + detail.UserName); 119 | } 120 | detail.LocalPath = userKey.GetValue(valueName) as string; 121 | detail.StatusString = GetStatus(detail.LocalPath).ToString(); 122 | yield return detail; 123 | } 124 | } 125 | } 126 | } 127 | } 128 | } 129 | 130 | 131 | 132 | } 133 | 134 | public IEnumerable GetStatusInternalGroove() 135 | { 136 | //const string hklm = "HKEY_LOCAL_MACHINE"; 137 | const string subkeyString = @"Software\Microsoft\Office"; // SkyDrive\UserSyncRoots\"; 138 | 139 | using (var key = Registry.CurrentUser.OpenSubKey(subkeyString)) 140 | { 141 | if (key == null) 142 | { 143 | yield return new StatusDetail() { Status = ServiceStatus.OnDemandOrUnknown, ServiceType="Groove" }; 144 | } 145 | else 146 | { 147 | if (key.SubKeyCount == 0) 148 | { 149 | yield return new StatusDetail() { Status = ServiceStatus.OnDemandOrUnknown }; 150 | } 151 | foreach (var subkey in key.GetSubKeyNames()) 152 | { 153 | using (var userKey = key.OpenSubKey(String.Format("{0}{1}", subkey, @"\Common\Internet"))) 154 | { 155 | if (userKey != null && userKey.GetValue("LocalSyncClientDiskLocation") as String[] != null) 156 | { 157 | string[] folders = userKey.GetValue("LocalSyncClientDiskLocation") as String[]; 158 | foreach (var folder in folders) 159 | { 160 | var detail = new StatusDetail(); 161 | try 162 | { 163 | 164 | detail.UserName = WindowsIdentity.GetCurrent().Name; 165 | detail.UserSID = UserPrincipal.Current.Sid.ToString(); 166 | 167 | 168 | string[] parts = subkey.Split('!'); 169 | 170 | detail.ServiceType = String.Format("Groove{0}", parts[parts.Length - 1]); 171 | 172 | } 173 | catch (Exception ex) 174 | { 175 | detail.UserName = String.Format("Groove - {0}: {1}", ex.GetType().ToString(), 176 | ex.Message); 177 | OneDriveLib.WriteLog.WriteErrorEvent(detail.UserName); 178 | } 179 | detail.LocalPath = folder; 180 | detail.StatusString = GetStatus(detail.LocalPath).ToString(); 181 | yield return detail; 182 | } 183 | } 184 | } 185 | 186 | } 187 | } 188 | } 189 | 190 | 191 | 192 | } 193 | public StatusDetailCollection GetStatus() 194 | { 195 | 196 | OneDriveLib.WriteLog.WriteToFile = true; 197 | OneDriveLib.WriteLog.WriteInformationEvent(String.Format("Is Interactive: {0}, Is UAC Enabled: {1}, Is Elevated: {2}", Environment.UserInteractive, OneDriveLib.UacHelper.IsUacEnabled, 198 | OneDriveLib.UacHelper.IsProcessElevated)); 199 | 200 | StatusDetailCollection statuses = new StatusDetailCollection(); 201 | 202 | foreach (var status in GetStatusInternal()) 203 | { 204 | OneDriveState state = new OneDriveState(); 205 | var hr = API.GetStateBySyncRootId(status.SyncRootId, out state); 206 | if(hr == 0) 207 | { 208 | status.QuotaUsedBytes = state.UsedQuota; 209 | status.QuotaTotalBytes = state.TotalQuota; 210 | status.NewApiStatus = state.CurrentState; 211 | status.StatusString = state.CurrentState == 0 ? "Synced" : state.Label; 212 | status.QuotaLabel = state.QuotaLabel; 213 | status.QuotaColor = new QuotaColor(state.IconColorA, state.IconColorR, state.IconColorG, state.IconColorB); 214 | status.IconPath = state.IconUri; 215 | status.IsNewApi = true; 216 | statuses.Add(status); 217 | } 218 | if (hr != 0 && status.Status != ServiceStatus.OnDemandOrUnknown) 219 | { 220 | if (status.Status == ServiceStatus.Error) 221 | { 222 | status.StatusString = API.GetStatusByDisplayName(status.DisplayName); 223 | } 224 | statuses.Add(status); 225 | } 226 | } 227 | foreach (var status in GetStatusInternalGroove()) 228 | { 229 | if (status.Status != ServiceStatus.OnDemandOrUnknown) 230 | { 231 | if (status.Status == ServiceStatus.Error) 232 | { 233 | status.StatusString = API.GetStatusByDisplayName(status.DisplayName); 234 | } 235 | statuses.Add(status); 236 | } 237 | } 238 | return statuses; 239 | } 240 | 241 | 242 | 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /OneDriveLib/OneDriveLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {0BA56256-CB30-4DEB-A442-6ACBB7F6B2B3} 8 | Library 9 | Properties 10 | OneDriveLib 11 | OneDriveLib 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | 38 | 39 | 40 | False 41 | ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | True 58 | True 59 | Resources.resx 60 | 61 | 62 | 63 | 64 | 65 | 66 | ResXFileCodeGenerator 67 | Resources.Designer.cs 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | copy /y $(TargetPath) $(SolutionDir)\Binaries\PowerShell\ 79 | copy /y $(TargetDir)$(TargetName).pdb $(SolutionDir)\Binaries\PowerShell\ 80 | 81 | 88 | -------------------------------------------------------------------------------- /OneDriveLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OneDriveLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Open Source - Rodney Viana")] 12 | [assembly: AssemblyProduct("OneDriveLib")] 13 | [assembly: AssemblyCopyright("Copyright © 2017-2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0ba56256-cb30-4deb-a442-6acbb7f6b2b3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.*")] 36 | //[assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /OneDriveLib/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 OneDriveLib.Properties { 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", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 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 Resources() { 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 | internal 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("OneDriveLib.Properties.Resources", typeof(Resources).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 | internal 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.Byte[]. 65 | /// 66 | internal static byte[] ODNative32 { 67 | get { 68 | object obj = ResourceManager.GetObject("ODNative32", resourceCulture); 69 | return ((byte[])(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Byte[]. 75 | /// 76 | internal static byte[] ODNative64 { 77 | get { 78 | object obj = ResourceManager.GetObject("ODNative64", resourceCulture); 79 | return ((byte[])(obj)); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /OneDriveLib/Properties/Resources.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 | ..\resources\odnative32.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 123 | 124 | 125 | ..\resources\odnative.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 126 | 127 | -------------------------------------------------------------------------------- /OneDriveLib/Resources/ODNative.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/OneDriveLib/Resources/ODNative.dll -------------------------------------------------------------------------------- /OneDriveLib/Resources/ODNative32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/OneDriveLib/Resources/ODNative32.dll -------------------------------------------------------------------------------- /OneDriveLib/UacHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Runtime.InteropServices; 5 | using System.Security.Principal; 6 | 7 | namespace OneDriveLib 8 | { 9 | /// 10 | /// Utility Class to get UAC info 11 | /// From: https://stackoverflow.com/questions/1220213/detect-if-running-as-administrator-with-or-without-elevated-privileges 12 | /// 13 | public static class UacHelper 14 | { 15 | private const string uacRegistryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; 16 | private const string uacRegistryValue = "EnableLUA"; 17 | 18 | private static uint STANDARD_RIGHTS_READ = 0x00020000; 19 | private static uint TOKEN_QUERY = 0x0008; 20 | private static uint TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY); 21 | 22 | [DllImport("advapi32.dll", SetLastError = true)] 23 | [return: MarshalAs(UnmanagedType.Bool)] 24 | static extern bool OpenProcessToken(IntPtr ProcessHandle, UInt32 DesiredAccess, out IntPtr TokenHandle); 25 | 26 | [DllImport("advapi32.dll", SetLastError = true)] 27 | public static extern bool GetTokenInformation(IntPtr TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, IntPtr TokenInformation, uint TokenInformationLength, out uint ReturnLength); 28 | 29 | public enum TOKEN_INFORMATION_CLASS 30 | { 31 | TokenUser = 1, 32 | TokenGroups, 33 | TokenPrivileges, 34 | TokenOwner, 35 | TokenPrimaryGroup, 36 | TokenDefaultDacl, 37 | TokenSource, 38 | TokenType, 39 | TokenImpersonationLevel, 40 | TokenStatistics, 41 | TokenRestrictedSids, 42 | TokenSessionId, 43 | TokenGroupsAndPrivileges, 44 | TokenSessionReference, 45 | TokenSandBoxInert, 46 | TokenAuditPolicy, 47 | TokenOrigin, 48 | TokenElevationType, 49 | TokenLinkedToken, 50 | TokenElevation, 51 | TokenHasRestrictions, 52 | TokenAccessInformation, 53 | TokenVirtualizationAllowed, 54 | TokenVirtualizationEnabled, 55 | TokenIntegrityLevel, 56 | TokenUIAccess, 57 | TokenMandatoryPolicy, 58 | TokenLogonSid, 59 | MaxTokenInfoClass 60 | } 61 | 62 | public enum TOKEN_ELEVATION_TYPE 63 | { 64 | TokenElevationTypeDefault = 1, 65 | TokenElevationTypeFull, 66 | TokenElevationTypeLimited 67 | } 68 | 69 | public static bool IsUacEnabled 70 | { 71 | get 72 | { 73 | RegistryKey uacKey = Registry.LocalMachine.OpenSubKey(uacRegistryKey, false); 74 | bool result = (uacKey?.GetValue(uacRegistryValue) ?? 1).Equals(1); 75 | return result; 76 | } 77 | } 78 | 79 | public static bool IsProcessElevated 80 | { 81 | get 82 | { 83 | if (IsUacEnabled) 84 | { 85 | IntPtr tokenHandle; 86 | if (!OpenProcessToken(Process.GetCurrentProcess().Handle, TOKEN_READ, out tokenHandle)) 87 | { 88 | throw new ApplicationException("Could not get process token. Win32 Error Code: " + Marshal.GetLastWin32Error()); 89 | } 90 | 91 | TOKEN_ELEVATION_TYPE elevationResult = TOKEN_ELEVATION_TYPE.TokenElevationTypeDefault; 92 | 93 | int elevationResultSize = Marshal.SizeOf((int)elevationResult); 94 | uint returnedSize = 0; 95 | IntPtr elevationTypePtr = Marshal.AllocHGlobal(elevationResultSize); 96 | 97 | bool success = GetTokenInformation(tokenHandle, TOKEN_INFORMATION_CLASS.TokenElevationType, elevationTypePtr, (uint)elevationResultSize, out returnedSize); 98 | if (success) 99 | { 100 | elevationResult = (TOKEN_ELEVATION_TYPE)Marshal.ReadInt32(elevationTypePtr); 101 | bool isProcessAdmin = elevationResult == TOKEN_ELEVATION_TYPE.TokenElevationTypeFull; 102 | return isProcessAdmin; 103 | } 104 | else 105 | { 106 | throw new ApplicationException("Unable to determine the current elevation."); 107 | } 108 | } 109 | else 110 | { 111 | WindowsIdentity identity = WindowsIdentity.GetCurrent(); 112 | WindowsPrincipal principal = new WindowsPrincipal(identity); 113 | bool result = principal.IsInRole(WindowsBuiltInRole.Administrator); 114 | return result; 115 | } 116 | } 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /OneDriveLib/WriteLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Diagnostics; 6 | using System.IO; 7 | 8 | namespace OneDriveLib 9 | { 10 | public static class WriteLog 11 | { 12 | 13 | private static object writeLock = new object(); 14 | // One file name per day 15 | 16 | private static DateTime failedCreate = DateTime.MinValue; 17 | public static string FileName 18 | { 19 | get 20 | { 21 | return String.Format("{0}OneDriveLib-{1}.log", Path.GetTempPath(), DateTime.Now.ToString("yyyy-MM-dd")); 22 | } 23 | } 24 | 25 | public static bool ShouldLog 26 | { 27 | get; 28 | set; 29 | } = false; 30 | 31 | public static void AppendToFile(EventLogEntryType Severity, string Message) 32 | { 33 | AppendToFile(String.Format("{0}\t{1}\t{2}", 34 | DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss"), 35 | Severity, 36 | Message)); 37 | } 38 | 39 | public static void AppendToFile(string Text) 40 | { 41 | byte[] strArray = Encoding.UTF8.GetBytes(Text); 42 | AppendToFile(strArray); 43 | 44 | } 45 | 46 | public static void AppendToFile(byte[] RawBytes) 47 | { 48 | bool myLock = System.Threading.Monitor.TryEnter(writeLock, 100); 49 | 50 | 51 | if (myLock) 52 | { 53 | try 54 | { 55 | 56 | using (FileStream stream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) 57 | { 58 | stream.Position = stream.Length; 59 | stream.Write(RawBytes, 0, RawBytes.Length); 60 | stream.WriteByte(13); 61 | stream.WriteByte(10); 62 | 63 | } 64 | 65 | } 66 | catch (Exception ex) 67 | { 68 | string str = string.Format("Unable to create log. Type: {0} Message: {1}\nStack:{2}", ex, ex.Message, ex.StackTrace); 69 | System.Diagnostics.Debug.WriteLine(str); 70 | System.Diagnostics.Debug.Flush(); 71 | 72 | 73 | } 74 | finally 75 | { 76 | System.Threading.Monitor.Exit(writeLock); 77 | 78 | 79 | } 80 | } 81 | 82 | 83 | } 84 | 85 | public static string Source 86 | { 87 | get 88 | { 89 | return "OneDriveLib"; 90 | } 91 | } 92 | 93 | public static string Log 94 | { 95 | get 96 | { 97 | return "Application"; 98 | } 99 | } 100 | 101 | public static bool CreateSource() 102 | { 103 | return CreateSource(Source); 104 | } 105 | 106 | internal static bool CreateSource(string Source) 107 | { 108 | try 109 | { 110 | EventLog.CreateEventSource(Source, Log); 111 | return true; 112 | } 113 | catch (Exception ex) 114 | { 115 | 116 | if (DateTime.Now.Subtract(failedCreate) > TimeSpan.FromHours(1)) 117 | { 118 | AppendToFile(EventLogEntryType.Error, String.Format("Unable to create Event Log Source '{0}' - {1}:{2}", 119 | Source, ex.GetType(), ex.Message)); 120 | } 121 | failedCreate = DateTime.Now; 122 | 123 | } 124 | 125 | 126 | return false; 127 | } 128 | 129 | public static bool WriteToFile 130 | { 131 | get; 132 | set; 133 | } 134 | 135 | internal static bool WriteToLog(EventLogEntryType Severity, string Message) 136 | { 137 | 138 | if (!ShouldLog) 139 | return false; 140 | if (WriteToFile) 141 | { 142 | AppendToFile(Severity, Message); 143 | return true; 144 | } 145 | bool sourceCreated = false; 146 | try 147 | { 148 | sourceCreated = EventLog.SourceExists(Source); 149 | } 150 | catch 151 | { 152 | sourceCreated = false; 153 | } 154 | if (!sourceCreated) 155 | sourceCreated = CreateSource(); 156 | if (sourceCreated) 157 | { 158 | EventLog.WriteEntry(Source, Message, Severity); 159 | return true; 160 | } 161 | else 162 | { 163 | AppendToFile(Severity, Message); 164 | } 165 | 166 | return false; 167 | } 168 | 169 | public static bool WriteInformationEvent(string Message) 170 | { 171 | return WriteToLog(EventLogEntryType.Information, Message); 172 | } 173 | 174 | public static bool WriteErrorEvent(string Message) 175 | { 176 | return WriteToLog(EventLogEntryType.Error, Message); 177 | } 178 | 179 | public static bool WriteWarningEvent(string Message) 180 | { 181 | return WriteToLog(EventLogEntryType.Warning, Message); 182 | } 183 | 184 | 185 | } 186 | 187 | 188 | 189 | } 190 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This version is not compatible with Windows 11 2 | Use this version instead (should also work with Windows 10): 3 | https://github.com/rodneyviana/ODSyncUtil/ 4 | 5 | 6 | # Now including support for On Demand! 7 | 8 | **Watch this video to get started** 9 | 10 | [![OneDriveLib Introduction](https://img.youtube.com/vi/2AqB-7Uq9lc/0.jpg)](https://www.youtube.com/watch?v=2AqB-7Uq9lc) 11 | 12 | **Open PowerShell (it cannot be in elevated mode because of OneDrive design)** 13 | 14 | [Download here](https://github.com/rodneyviana/ODSyncService/releases) 15 | 16 | **Before running the first time, use this to unblock the DLL that you downloaded:** 17 | ``` 18 | PS C:\ODTool> Unblock-File -Path C:\ODTool\OneDriveLib.dll # change path if necessary 19 | ``` 20 | 21 | **Run this:** 22 | ``` 23 | Import-Module OneDriveLib.dll 24 | Get-ODStatus 25 | ``` 26 | 27 | **This is an example of the output:** 28 | ``` 29 | PS C:\ODTool> Import-Module OneDriveLib.dll 30 | PS C:\ODTool> Get-ODStatus 31 | 32 | LocalPath    : E:\MicrosoftOnedrive\OneDrive - My Company 33 | UserSID      : S-1-5-21-124000000-708000000-1543000000-802052 34 | UserName     : CONTOSO\rodneyviana 35 | DisplayName : OneDrive - Contoso 36 | ServiceType  : Business1 37 | StatusString : Looking for changes 38 | 39 | StatusString : UpToDate 40 | LocalPath    : D:\Onedrive 41 | UserSID      : S-1-5-21-124000000-708000000-1543000000-802052 42 | DisplayName : OneDrive - Personal 43 | UserName     : CONTOSO\rodneyviana 44 | ServiceType  : Personal 45 | StatusString : Up To Date 46 | ``` 47 | 48 | **Syntax:** 49 | ``` 50 | Get-ODStatus [-Type ] [-ByPath ] [CLSID ] 51 | [-IncludeLog] [-Verbose] 52 | 53 | Or 54 | Get-ODStatus -OnDemandOnly [-Type ] [-IncludeLog] [-Verbose] 55 | 56 | ``` 57 | **Where:** 58 | ``` 59 | -Type Only returns if Service Type matches 60 | Example: Get-ODStatus -Type Personal 61 | 62 | -ByPath Only checks a particular folder or file status 63 | Example: Get-ODStatus -Path "$env:OneDrive\docs" 64 | 65 | -CLSD Verify only a particular GUID (not used normally) 66 | Example: Get-ODStatus -CLSD A0396A93-DC06-4AEF-BEE9-95FFCCAEF20E 67 | 68 | -IncludeLog If present will save a log file on the temp folder 69 | 70 | -Verbose Show verbose information 71 | 72 | -OnDemandOnly Normally On Demand is only tested as a fallback, when 73 | -OnDemandOnly is present it goes directly to 74 | On Demand status. This may resolve flicker issues 75 | 76 | ``` 77 | 78 | **Important:** 79 | 80 | On Demand Status **ONLY** works if OneDrive icon is visible on the taskbar 81 | 82 | Examples: 83 | 84 | List status of all OneDrive instances: 85 | 86 | Get-ODStatus 87 | 88 | Check if a particular file of folder is synchronized 89 | 90 | Get-ODStatus -ByPath "$($env:OneDrive)\DalyReports\" 91 | 92 | Save and list the log file: 93 | 94 | Get-ODStatus -IncludeLog 95 | 96 | Get-Item -Path "$($env:Temp)\OneDriveLib*" 97 | 98 | For On Demand installations: 99 | 100 | Get-ODStatus -OnDemandOnly 101 | ``` 102 | -------------------------------------------------------------------------------- /ShellShim/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | using namespace System; 4 | using namespace System::Reflection; 5 | using namespace System::Runtime::CompilerServices; 6 | using namespace System::Runtime::InteropServices; 7 | using namespace System::Security::Permissions; 8 | 9 | // 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | // 14 | [assembly:AssemblyTitleAttribute(L"ShellShim")]; 15 | [assembly:AssemblyDescriptionAttribute(L"")]; 16 | [assembly:AssemblyConfigurationAttribute(L"")]; 17 | [assembly:AssemblyCompanyAttribute(L"")]; 18 | [assembly:AssemblyProductAttribute(L"ShellShim")]; 19 | [assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2017")]; 20 | [assembly:AssemblyTrademarkAttribute(L"")]; 21 | [assembly:AssemblyCultureAttribute(L"")]; 22 | 23 | // 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the value or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | 34 | [assembly:AssemblyVersionAttribute("1.0.*")]; 35 | 36 | [assembly:ComVisible(false)]; 37 | 38 | [assembly:CLSCompliantAttribute(true)]; -------------------------------------------------------------------------------- /ShellShim/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : ShellShim Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this ShellShim DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your ShellShim application. 9 | 10 | ShellShim.vcxproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | ShellShim.vcxproj.filters 17 | This is the filters file for VC++ projects generated using an Application Wizard. 18 | It contains information about the association between the files in your project 19 | and the filters. This association is used in the IDE to show grouping of files with 20 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 21 | "Source Files" filter). 22 | 23 | ShellShim.cpp 24 | This is the main DLL source file. 25 | 26 | ShellShim.h 27 | This file contains a class declaration. 28 | 29 | AssemblyInfo.cpp 30 | Contains custom attributes for modifying assembly metadata. 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | Other notes: 34 | 35 | AppWizard uses "TODO:" to indicate parts of the source code you 36 | should add to or customize. 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | -------------------------------------------------------------------------------- /ShellShim/ShellShim.cpp: -------------------------------------------------------------------------------- 1 | // This is the main DLL file. 2 | 3 | #include "stdafx.h" 4 | 5 | #include "ShellShim.h" 6 | 7 | -------------------------------------------------------------------------------- /ShellShim/ShellShim.h: -------------------------------------------------------------------------------- 1 | // ShellShim.h 2 | 3 | #pragma once 4 | #include 5 | #include 6 | 7 | using namespace System; 8 | 9 | namespace ShellShim { 10 | const MIDL_INTERFACE("F241C880-6982-4CE5-8CF7-7085BA96DA5A") IguidUptoDate; 11 | 12 | const MIDL_INTERFACE("8BA85C75-763B-4103-94EB-9470F12FE0F7") ISkydriverPro; 13 | CLSID CLSID_UoToDate; 14 | public ref class Class1 15 | { 16 | ::CLSIDFromString(L"F241C880-6982-4CE5-8CF7-7085BA96DA5A", &CLSID_UoToDate); 17 | // TODO: Add your methods for this class here. 18 | }; 19 | 20 | #pragma unmanaged 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /ShellShim/ShellShim.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {401D37BD-2A3B-4F4B-AA01-7D72673B7267} 23 | v3.5 24 | ManagedCProj 25 | ShellShim 26 | 8.1 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v140 33 | true 34 | Unicode 35 | 36 | 37 | DynamicLibrary 38 | false 39 | v140 40 | true 41 | Unicode 42 | 43 | 44 | DynamicLibrary 45 | true 46 | v140 47 | true 48 | Unicode 49 | 50 | 51 | DynamicLibrary 52 | false 53 | v140 54 | true 55 | Unicode 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | true 80 | 81 | 82 | false 83 | 84 | 85 | false 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | WIN32;_DEBUG;%(PreprocessorDefinitions) 92 | Use 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | _DEBUG;%(PreprocessorDefinitions) 103 | Use 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Level3 112 | WIN32;NDEBUG;%(PreprocessorDefinitions) 113 | Use 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | Level3 122 | NDEBUG;%(PreprocessorDefinitions) 123 | Use 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | Create 144 | Create 145 | Create 146 | Create 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /ShellShim/ShellShim.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Resource Files 45 | 46 | 47 | 48 | 49 | Resource Files 50 | 51 | 52 | -------------------------------------------------------------------------------- /ShellShim/Stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ShellShim.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /ShellShim/Stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, 3 | // but are changed infrequently 4 | 5 | #pragma once 6 | 7 | 8 | -------------------------------------------------------------------------------- /ShellShim/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/ShellShim/app.ico -------------------------------------------------------------------------------- /ShellShim/app.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodneyviana/ODSyncService/ff48221e5edada83050bae64dd06ca601977dd41/ShellShim/app.rc -------------------------------------------------------------------------------- /ShellShim/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Rodney Viana 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. 22 | --------------------------------------------------------------------------------