static BOOL WINAPI DirectXOpenDDrawCallback(GUID *guid, LPTSTR desc, LPTSTR drivername, VOID *context, HMONITOR hmon) { vout_display_t *vd = context; vout_display_sys_t *sys = vd->sys; /* This callback function is called by DirectDraw once for each * available DirectDraw device. * * Returning TRUE keeps enumerating. */ if (!hmon) return TRUE; char *psz_drivername = FromT(drivername); char *psz_desc = FromT(desc); msg_Dbg(vd, "DirectXEnumCallback: %s, %s", psz_desc, psz_drivername); char *device = var_GetString(vd, "directx-device"); /* Check for forced device */ if (device && *device && !strcmp(psz_drivername, device)) { MONITORINFO monitor_info; monitor_info.cbSize = sizeof(MONITORINFO); if (GetMonitorInfoA(hmon, &monitor_info)) { RECT rect; /* Move window to the right screen */ GetWindowRect(sys->hwnd, &rect); if (!IntersectRect(&rect, &rect, &monitor_info.rcWork)) { rect.left = monitor_info.rcWork.left; rect.top = monitor_info.rcWork.top; msg_Dbg(vd, "DirectXEnumCallback: setting window " "position to %ld,%ld", rect.left, rect.top); SetWindowPos(sys->hwnd, NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } } sys->hmonitor = hmon; } free(device); if (hmon == sys->hmonitor) { msg_Dbg(vd, "selecting %s, %s", psz_desc, psz_drivername); free(sys->display_driver); sys->display_driver = malloc(sizeof(*guid)); if (sys->display_driver) *sys->display_driver = *guid; } free(psz_drivername); free(psz_desc); return TRUE; }
static int GetFileFontByName( LPCTSTR font_name, char **psz_filename ) { HKEY hKey; TCHAR vbuffer[MAX_PATH]; TCHAR dbuffer[256]; if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey) != ERROR_SUCCESS ) return 1; char *font_name_temp = FromT( font_name ); size_t fontname_len = strlen( font_name_temp ); for( int index = 0;; index++ ) { DWORD vbuflen = MAX_PATH - 1; DWORD dbuflen = 255; LONG i_result = RegEnumValue( hKey, index, vbuffer, &vbuflen, NULL, NULL, (LPBYTE)dbuffer, &dbuflen); if( i_result != ERROR_SUCCESS ) { RegCloseKey( hKey ); return i_result; } char *psz_value = FromT( vbuffer ); char *s = strchr( psz_value,'(' ); if( s != NULL && s != psz_value ) s[-1] = '\0'; /* Manage concatenated font names */ if( strchr( psz_value, '&') ) { if( strcasestr( psz_value, font_name_temp ) != NULL ) { free( psz_value ); break; } } else { if( strncasecmp( psz_value, font_name_temp, fontname_len ) == 0 ) { free( psz_value ); break; } } free( psz_value ); } *psz_filename = FromT( dbuffer ); free( font_name_temp ); RegCloseKey( hKey ); return 0; }
static char *config_GetAppDir (void) { #if !VLC_WINSTORE_APP /* if portable directory exists, use it */ TCHAR path[MAX_PATH]; if (GetModuleFileName (NULL, path, MAX_PATH)) { TCHAR *lastDir = _tcsrchr (path, '\\'); if (lastDir) { _tcscpy (lastDir + 1, TEXT("portable")); DWORD attrib = GetFileAttributes (path); if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)) return FromT (path); } } #endif char *psz_dir; char *psz_parent = config_GetShellDir (CSIDL_APPDATA); if (psz_parent == NULL || asprintf (&psz_dir, "%s\\vlc", psz_parent) == -1) psz_dir = NULL; free (psz_parent); return psz_dir; }
static int GetFileFontByName( LPCTSTR font_name, char **psz_filename, int *i_index ) { HKEY hKey; TCHAR vbuffer[MAX_PATH]; TCHAR dbuffer[256]; if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey) != ERROR_SUCCESS ) return 1; char *font_name_temp = FromT( font_name ); for( int index = 0;; index++ ) { DWORD vbuflen = MAX_PATH - 1; DWORD dbuflen = 255; LONG i_result = RegEnumValue( hKey, index, vbuffer, &vbuflen, NULL, NULL, (LPBYTE)dbuffer, &dbuflen); if( i_result != ERROR_SUCCESS ) { free( font_name_temp ); RegCloseKey( hKey ); return i_result; } char *psz_value = FromT( vbuffer ); char *s = strchr( psz_value,'(' ); if( s != NULL && s != psz_value ) s[-1] = '\0'; int i_concat_idx = 0; if( ( i_concat_idx = ConcatenatedIndex( psz_value, font_name_temp ) ) != -1 ) { *i_index = i_concat_idx; *psz_filename = FromT( dbuffer ); free( psz_value ); break; } free( psz_value ); } free( font_name_temp ); RegCloseKey( hKey ); return 0; }
/***************************************************************************** * config variable callback *****************************************************************************/ static BOOL WINAPI DirectXEnumCallback2(GUID *guid, LPTSTR desc, LPTSTR drivername, VOID *data, HMONITOR hmon) { enum_context_t *ctx = data; VLC_UNUSED(guid); VLC_UNUSED(desc); VLC_UNUSED(hmon); char *psz_drivername = FromT(drivername); ctx->values = xrealloc(ctx->values, (ctx->count + 1) * sizeof(char *)); ctx->descs = xrealloc(ctx->descs, (ctx->count + 1) * sizeof(char *)); ctx->values[ctx->count] = psz_drivername; ctx->descs[ctx->count] = psz_drivername; ctx->count++; free(psz_drivername); return TRUE; /* Keep enumerating */ }
/***************************************************************************** * config variable callback *****************************************************************************/ static BOOL WINAPI DirectXEnumCallback2(GUID *guid, LPTSTR desc, LPTSTR drivername, VOID *data, HMONITOR hmon) { enum_context_t *ctx = (enum_context_t *)data; // sunqueen modify VLC_UNUSED(guid); VLC_UNUSED(desc); VLC_UNUSED(hmon); char *psz_drivername = FromT(drivername); ctx->values = (char **)xrealloc(ctx->values, (ctx->count + 1) * sizeof(char *)); // sunqueen modify ctx->descs = (char **)xrealloc(ctx->descs, (ctx->count + 1) * sizeof(char *)); // sunqueen modify ctx->values[ctx->count] = strdup(drivername); //psz_drivername; // sunqueen modify ctx->descs[ctx->count] = psz_drivername; ctx->count++; //free(psz_drivername); // sunqueen delete return TRUE; /* Keep enumerating */ }
/* * This is a hack used by Chrome and WebKit to expose the fallback font used * by Uniscribe for some given text for use with custom shapers / font engines. */ static char *UniscribeFallback( const char *psz_family, uni_char_t codepoint ) { HDC hdc = NULL; HDC meta_file_dc = NULL; HENHMETAFILE meta_file = NULL; LPTSTR psz_fbuffer = NULL; char *psz_result = NULL; hdc = CreateCompatibleDC( NULL ); if( !hdc ) return NULL; meta_file_dc = CreateEnhMetaFile( hdc, NULL, NULL, NULL ); if( !meta_file_dc ) goto error; LOGFONT lf; memset( &lf, 0, sizeof( lf ) ); psz_fbuffer = ToT( psz_family ); if( !psz_fbuffer ) goto error; _tcsncpy( ( LPTSTR ) &lf.lfFaceName, psz_fbuffer, LF_FACESIZE ); free( psz_fbuffer ); lf.lfCharSet = DEFAULT_CHARSET; HFONT hFont = CreateFontIndirect( &lf ); if( !hFont ) goto error; HFONT hOriginalFont = SelectObject( meta_file_dc, hFont ); TCHAR text = codepoint; SCRIPT_STRING_ANALYSIS script_analysis; HRESULT hresult = ScriptStringAnalyse( meta_file_dc, &text, 1, 0, -1, SSA_METAFILE | SSA_FALLBACK | SSA_GLYPHS | SSA_LINK, 0, NULL, NULL, NULL, NULL, NULL, &script_analysis ); if( SUCCEEDED( hresult ) ) { hresult = ScriptStringOut( script_analysis, 0, 0, 0, NULL, 0, 0, FALSE ); ScriptStringFree( &script_analysis ); } SelectObject( meta_file_dc, hOriginalFont ); DeleteObject( hFont ); meta_file = CloseEnhMetaFile( meta_file_dc ); if( SUCCEEDED( hresult ) ) { LOGFONT log_font; log_font.lfFaceName[ 0 ] = 0; EnumEnhMetaFile( 0, meta_file, MetaFileEnumProc, &log_font, NULL ); if( log_font.lfFaceName[ 0 ] ) psz_result = FromT( log_font.lfFaceName ); } DeleteEnhMetaFile(meta_file); DeleteDC( hdc ); return psz_result; error: if( meta_file_dc ) DeleteEnhMetaFile( CloseEnhMetaFile( meta_file_dc ) ); if( hdc ) DeleteDC( hdc ); return NULL; }
/***************************************************************************** * NT Service utility functions *****************************************************************************/ static int NTServiceInstall( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; char psz_path[10*MAX_PATH], *psz_extra; TCHAR psz_pathtmp[MAX_PATH]; SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS ); if( handle == NULL ) { msg_Err( p_intf, "could not connect to Services Control Manager database" ); return VLC_EGENERIC; } /* Find out the filename of ourselves so we can install it to the * service control manager */ GetModuleFileName( NULL, psz_pathtmp, MAX_PATH ); sprintf( psz_path, "\"%s\" -I "MODULE_STRING, FromT(psz_pathtmp) ); psz_extra = var_InheritString( p_intf, "ntservice-extraintf" ); if( psz_extra ) { strcat( psz_path, " --ntservice-extraintf " ); strcat( psz_path, psz_extra ); free( psz_extra ); } psz_extra = var_InheritString( p_intf, "ntservice-options" ); if( psz_extra && *psz_extra ) { strcat( psz_path, " " ); strcat( psz_path, psz_extra ); free( psz_extra ); } SC_HANDLE service = CreateServiceA( handle, p_sys->psz_service, p_sys->psz_service, GENERIC_READ | GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, psz_path, NULL, NULL, NULL, NULL, NULL ); if( service == NULL ) { if( GetLastError() != ERROR_SERVICE_EXISTS ) { msg_Err( p_intf, "could not create new service: \"%s\" (%s)", p_sys->psz_service ,psz_path ); CloseServiceHandle( handle ); return VLC_EGENERIC; } else { msg_Warn( p_intf, "service \"%s\" already exists", p_sys->psz_service ); } } else { msg_Warn( p_intf, "service successfuly created" ); } if( service ) CloseServiceHandle( service ); CloseServiceHandle( handle ); return VLC_SUCCESS; }