CrendKing / avisynth_filter

DirectShow filters that put AviSynth and VapourSynth into video playing
MIT License
107 stars 8 forks source link

Source folder name cause player to crash #22

Closed Litfal closed 3 years ago

Litfal commented 3 years ago

Environment

Describe the bug

Some folder name causes crashing. I guess the folder name includes one or more chars are NOT in system Charset. But file name is fine.

And When I enable avisynth filter log. REG ADD HKCU\SOFTWARE\AviSynthFilter /v "LogFile" /t REG_SZ /d "%temp%\AviSynthFilter.log" /f EVERYTHING WILL BE FINE. It's fun. I just want debug.

To Reproduce

  1. Create a folder "挥" anywhere. (If your system charset is not GB)
  2. Put any video file in.
  3. Play it.
CrendKing commented 3 years ago

This is caused by AviSynthPlus not compiling with UTF-16 on Windows. When the video player plays a file, it first changes its current directory to the video directory. Then it loads avsf, which loads AviSynth.dll. The latter tries to get absolute path of the plugin directory by calculating $PWD/USER_PLUS_PLUGINS/. Since $PWD has invalid character, it throws error code 1113 (No mapping for the Unicode character exists in the target multi-byte code page).

    KernelBase.dll!00007ff9e6fe3e49()
    vcruntime140d.dll!00007ff9cbe3b1f0()
    AviSynth.dll!std::filesystem::_Throw_system_error_from_std_win_error(const __std_win_error _Errno) Line 51
    AviSynth.dll!std::filesystem::_Check_convert_result(const __std_fs_convert_result _Result) Line 58
    AviSynth.dll!std::filesystem::_Convert_wide_to_narrow<std::char_traits<char>,std::allocator<char>>(const __std_code_page _Code_page, const std::basic_string_view<wchar_t,std::char_traits<wchar_t>> _Input, const std::allocator<char> & _Al) Line 91
    AviSynth.dll!std::filesystem::_Convert_wide_to<std::char_traits<char>,std::allocator<char>,char>(const std::basic_string_view<wchar_t,std::char_traits<wchar_t>> _Input, const std::allocator<char> & _Al) Line 170
    AviSynth.dll!std::filesystem::path::generic_string<char,std::char_traits<char>,std::allocator<char>,0>(const std::allocator<char> & _Al) Line 1006
    AviSynth.dll!std::filesystem::path::generic_string() Line 1011
    AviSynth.dll!GetFullPathNameWrap(const std::string & f) Line 116
    AviSynth.dll!PluginManager::AddAutoloadDir(const std::string & dirPath, bool toFront) Line 618
    AviSynth.dll!ScriptEnvironment::ScriptEnvironment() Line 2266
    AviSynth.dll!CreateScriptEnvironment2(int version) Line 5069
    AviSynth.dll!CreateScriptEnvironment(int version) Line 5042
    avisynth_filter_64.ax!AvsFilter::AvsHandler::CreateEnv() Line 252
    avisynth_filter_64.ax!AvsFilter::AvsHandler::AvsHandler() Line 28
    avisynth_filter_64.ax!AvsFilter::CreateInstance<AvsFilter::CAviSynthFilter>(IUnknown * pUnk, HRESULT * phr) Line 59
    avisynth_filter_64.ax!CFactoryTemplate::CreateInstance(IUnknown * pUnk, HRESULT * phr) Line 277
    avisynth_filter_64.ax!CClassFactory::CreateInstance(IUnknown * pUnkOuter, const _GUID & riid, void * * pv) Line 134
    mpc-be64.exe!LoadExternalObject(const wchar_t * path, const _GUID & clsid, const _GUID & iid, void * * ppv) Line 1434
    mpc-be64.exe!CFGManager::Connect(IPin * pPinOut, IPin * pPinIn, bool bContinueRender) Line 1034
    mpc-be64.exe!CFGManager::ConnectFilter(IBaseFilter * pBF, IPin * pPinIn) Line 1569
    mpc-be64.exe!CFGManager::Connect(IPin * pPinOut, IPin * pPinIn, bool bContinueRender) Line 1073
    mpc-be64.exe!CFGManager::ConnectFilter(IBaseFilter * pBF, IPin * pPinIn) Line 1569
    mpc-be64.exe!CFGManager::RenderFile(const wchar_t * lpcwstrFileName, const wchar_t * lpcwstrPlayList) Line 1207
    mpc-be64.exe!CMainFrame::OpenFile(OpenFileData * pOFD) Line 12206
    mpc-be64.exe!CMainFrame::OpenMediaPrivate(ATL::CAutoPtr<OpenMediaData> pOMD) Line 14014
    mpc-be64.exe!CGraphThread::OnOpen(unsigned __int64 wParam, __int64 lParam) Line 20382
    mpc-be64.exe!CWinThread::DispatchThreadMessageEx(tagMSG * pMsg) Line 771
    mpc-be64.exe!AfxInternalPreTranslateMessage(tagMSG * pMsg) Line 227
    mpc-be64.exe!AfxInternalPumpMessage() Line 178
    mpc-be64.exe!CWinThread::Run() Line 629
    mpc-be64.exe!_AfxThreadEntry(void * pParam) Line 126
    mpc-be64.exe!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97
    kernel32.dll!00007ff9e7487034()
    ntdll.dll!00007ff9e945cec1()

There is fix from avsf side because AviSynthPlus does not provide wchar_t version of API. One way you can workaround yourself is by turning on UTF-8 support in Windows. I didn't notice this because I use this option all the time.

UTF-8