Skip to content

Commit 6c62136

Browse files
committed
engine: client: avi: convert filename to wide characters before passing it into VFW API
1 parent f34b35b commit 6c62136

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

engine/client/avi/avi_win.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int (_stdcall *pAVIStreamTimeToSample)( PAVISTREAM pavi, LONG lTime );
6464
static void* (_stdcall *pAVIStreamGetFrame)( PGETFRAME pg, LONG lPos );
6565
static int (_stdcall *pAVIStreamGetFrameClose)( PGETFRAME pg );
6666
static dword (_stdcall *pAVIStreamRelease)( PAVISTREAM pavi );
67-
static int (_stdcall *pAVIFileOpen)( PAVIFILE *ppfile, LPCSTR szFile, UINT uMode, LPCLSID lpHandler );
67+
static int (_stdcall *pAVIFileOpenW)( PAVIFILE *ppfile, LPCWSTR szFile, UINT uMode, LPCLSID lpHandler );
6868
static int (_stdcall *pAVIFileGetStream)( PAVIFILE pfile, PAVISTREAM *ppavi, DWORD fccType, LONG lParam );
6969
static int (_stdcall *pAVIStreamReadFormat)( PAVISTREAM pavi, LONG lPos,LPVOID lpFormat, LONG *lpcbFormat );
7070
static int (_stdcall *pAVIStreamStart)( PAVISTREAM pavi );
@@ -77,7 +77,7 @@ static dllfunc_t avifile_funcs[] =
7777
{ "AVIFileExit", (void **) &pAVIFileExit },
7878
{ "AVIFileGetStream", (void **) &pAVIFileGetStream },
7979
{ "AVIFileInit", (void **) &pAVIFileInit },
80-
{ "AVIFileOpenA", (void **) &pAVIFileOpen },
80+
{ "AVIFileOpenW", (void **) &pAVIFileOpenW },
8181
{ "AVIFileRelease", (void **) &pAVIFileRelease },
8282
{ "AVIStreamGetFrame", (void **) &pAVIStreamGetFrame },
8383
{ "AVIStreamGetFrameClose", (void **) &pAVIStreamGetFrameClose },
@@ -494,6 +494,7 @@ void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audi
494494
AVISTREAMINFO stream_info;
495495
int opened_streams = 0;
496496
LONG hr;
497+
wchar_t pathBuffer[MAX_PATH];
497498

498499
// default state: non-working.
499500
Avi->active = false;
@@ -502,8 +503,15 @@ void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audi
502503
// can't load Video For Windows :-(
503504
if( !avi_initialized ) return;
504505

506+
// convert to wide char
507+
if( MultiByteToWideChar( CP_UTF8, 0, filename, -1, pathBuffer, ARRAYSIZE( pathBuffer )) <= 0 )
508+
{
509+
Con_DPrintf( S_ERROR "filename buffer limit exceeded\n" );
510+
return;
511+
}
512+
505513
// load the AVI
506-
hr = pAVIFileOpen( &Avi->pfile, filename, OF_SHARE_DENY_WRITE, 0L );
514+
hr = pAVIFileOpenW( &Avi->pfile, pathBuffer, OF_SHARE_DENY_WRITE, 0L );
507515

508516
if( hr != 0 ) // error opening AVI:
509517
{

0 commit comments

Comments
 (0)