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

No interpretation for error messages in SynCrtSock.SysErrorMessagePerModule on my machines #411

Closed
FeelAirSlow opened this issue Oct 28, 2021 · 2 comments

Comments

@FeelAirSlow
Copy link

Hello,

My system is in french language and when a winhttp.dll error is raised in SynCrtSock, I only have the error code but no textual explanation.

May I suggest a slight modification in SynCrtSock ?
The function SysErrorMessagePerModule, could be modified to fall back to the default behaviour (cf. https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage) if english langage is not available.
Moreover, it may also be useful to use the FORMAT_MESSAGE_IGNORE_INSERTS flag (cf. https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353).

  tmpLen := FormatMessage(
    FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_IGNORE_INSERTS,
    pointer(GetModuleHandle(ModuleName)),Code,ENGLISH_LANGID,@err,0,nil);
  // if string is empty, it may be because english is not found
  if (tmpLen = 0) then
     tmpLen := FormatMessage(
       FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_IGNORE_INSERTS,
       pointer(GetModuleHandle(ModuleName)),Code,0,@err,0,nil);

Thank you !

synopse pushed a commit that referenced this issue Oct 28, 2021
@synopse
Copy link
Owner

synopse commented Oct 28, 2021

Should be fixed now.

Note that mORMot 2 already included this fallback in mormot.core.os.windows.inc.

@FeelAirSlow
Copy link
Author

I tested your modifications of SynCrtSock.pas : that's perfect, thank you !

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

No branches or pull requests

2 participants