Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a more user friendly message when plugin program file does not e… #2730

Merged
merged 3 commits into from
Dec 21, 2019

Conversation

celeron533
Copy link
Contributor

@celeron533 celeron533 commented Dec 14, 2019

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly

  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])

  • Use Preview tab to see how your pull request will actually look like

  • Searched for similar pull requests

  • Compiled the code with Visual Studio

  • Require translation update

  • Require document update (readme.md, wikipage, etc)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New feature

Description of your pull request and other information

At least gives a hint to user to check whether the plugin program file exists on file system.

catch (System.ComponentModel.Win32Exception ex)
{
// do not use File.Exists(...), it can not handle the scenarios when the plugin file is in system environment path.
if ((uint)ex.ErrorCode == 0x80004005) // file not found
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: #2729

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it is uncommon to see "The specified executable is not a valid application for this OS platform." error. Only when run 64 bit program on 32 bit platform. or just have the bad image.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's uncommon, but there is😥. Just check if it is FileNotFound, if not, throw error with (or without) native error code so we won't misleading user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally prefer to use current implementation to keep everything simple.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy paste from here
https://docs.microsoft.com/zh-cn/windows/win32/seccrypto/common-hresult-values?redirectedfrom=MSDN

Name Description Value
S_OK Operation successful 0x00000000
E_ABORT Operation aborted 0x80004004
E_ACCESSDENIED General access denied error 0x80070005
E_FAIL Unspecified failure 0x80004005
...... ...... .......

Seems we should use native error code...

@celeron533 celeron533 merged commit 39ad6fc into shadowsocks:master Dec 21, 2019
@celeron533 celeron533 deleted the plugin_not_found branch May 10, 2020 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant