rodneyviana / ODSyncService

OneDrive service/DLL for Sync State
MIT License
93 stars 26 forks source link

Why prevent running in elevated mode? #18

Closed eduardomb08 closed 4 years ago

eduardomb08 commented 4 years ago

Hi @rodneyviana,

This is meant to be a question/idea discussion. It would be great if we could chat about this topic.

While investigating issue #13 I notice the verification IsProcessedElevated throwing an InvalidOperationException with the message "PowerShell is running in Administrator mode. OneDrive status cannot be checked in elevated privileges".

I tested locally running the module with this verification commented out and was able to run it without any problems. So, I was wondering about the context in which you added this check. Maybe it's something related to a specific scenario. Or maybe it's old logic that could not make sense anymore.

In case of the latter, I could create a PR to remove that verification. Now if it's the former, would you be ok with introducing a switch to ignore that check?

Thanks in advance!

Best Regards, Eduardo Monteiro de Barros

eduardomb08 commented 4 years ago

After further tests I realize bypassing the elevation tests only leads to a different exception when running in an elevated process. The new exception is REGDB_E_CLASSNOTREG and happens in the calls to the Native library (method GetShellInterfaceFromGuid). Inside the Native library, when trying to create the instance of the interface a HRESULT of 0x80040154 (Class not registered) will be returned.

When running from a non-elevated process, the instance is created as expected.