static void usage(void) { WINE_MESSAGE( "Usage: ping [-n count] [-w timeout] target_name\n\n" ); WINE_MESSAGE( "Options:\n" ); WINE_MESSAGE( " -n Number of echo requests to send.\n" ); WINE_MESSAGE( " -w Timeout in milliseconds to wait for each reply.\n" ); }
static void usage(void) { WINE_MESSAGE( "Usage: eject [-u] [-a] [-h] [x:]...\n" ); WINE_MESSAGE( " -a Eject all the CD drives we find\n" ); WINE_MESSAGE( " -h Display this help message\n" ); WINE_MESSAGE( " -u Unmount only, don't eject the CD\n" ); WINE_MESSAGE( " x: Eject drive x:\n" ); exit(1); }
/*********************************************************************** * start_dosbox */ static void start_dosbox( const char *appname, const char *args ) { static const WCHAR cfgW[] = {'c','f','g',0}; const char *config_dir = wine_get_config_dir(); WCHAR path[MAX_PATH], config[MAX_PATH]; HANDLE file; char *p, *buffer; int i; int ret = 1; DWORD written, drives = GetLogicalDrives(); char *dosbox = find_dosbox(); if (!dosbox) return; if (tolower(appname[0]) == 'z') { WINE_MESSAGE( "winevdm: Cannot start DOS application %s\n", appname ); WINE_MESSAGE( " because DOSBox doesn't support running from the Z: drive.\n" ); ExitProcess(1); } if (!GetTempPathW( MAX_PATH, path )) return; if (!GetTempFileNameW( path, cfgW, 0, config )) return; if (!GetCurrentDirectoryW( MAX_PATH, path )) return; file = CreateFileW( config, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 ); if (file == INVALID_HANDLE_VALUE) return; buffer = HeapAlloc( GetProcessHeap(), 0, sizeof("[autoexec]") + 25 * (strlen(config_dir) + sizeof("mount c /dosdevices/c:")) + 4 * strlenW( path ) + 6 + strlen( appname ) + strlen( args ) + 20 ); p = buffer; p += sprintf( p, "[autoexec]\n" ); for (i = 0; i < 25; i++) if (drives & (1 << i)) p += sprintf( p, "mount %c %s/dosdevices/%c:\n", 'a' + i, config_dir, 'a' + i ); p += sprintf( p, "%c:\ncd ", path[0] ); p += WideCharToMultiByte( CP_UNIXCP, 0, path + 2, -1, p, 4 * strlenW(path), NULL, NULL ) - 1; p += sprintf( p, "\n%s %s\n", appname, args ); p += sprintf( p, "exit\n" ); if (WriteFile( file, buffer, strlen(buffer), &written, NULL ) && written == strlen(buffer)) { const char *args[4]; char *config_file = wine_get_unix_file_name( config ); args[0] = dosbox; args[1] = "-conf"; args[2] = config_file; args[3] = NULL; ret = spawnvp( _P_WAIT, args[0], args ); } CloseHandle( file ); DeleteFileW( config ); HeapFree( GetProcessHeap(), 0, buffer ); ExitProcess( ret ); }
static void usage(void) { WINE_MESSAGE( "Usage: wineboot [options]\n" ); WINE_MESSAGE( "Options;\n" ); WINE_MESSAGE( " -h,--help Display this help message\n" ); WINE_MESSAGE( " -e,--end-session End the current session cleanly\n" ); WINE_MESSAGE( " -f,--force Force exit for processes that don't exit cleanly\n" ); WINE_MESSAGE( " -i,--init Perform initialization for first Wine instance\n" ); WINE_MESSAGE( " -k,--kill Kill running processes without any cleanup\n" ); WINE_MESSAGE( " -r,--restart Restart only, don't do normal startup operations\n" ); WINE_MESSAGE( " -s,--shutdown Shutdown only, don't reboot\n" ); WINE_MESSAGE( " -u,--update Update the wineprefix directory\n" ); }
/* execute rundll32 on the wine.inf file if necessary */ static void update_wineprefix( int force ) { const char *config_dir = wine_get_config_dir(); char *inf_path = get_wine_inf_path(); int fd; struct stat st; if (!inf_path) { WINE_MESSAGE( "wine: failed to update %s, wine.inf not found\n", config_dir ); return; } if ((fd = open( inf_path, O_RDONLY )) == -1) { WINE_MESSAGE( "wine: failed to update %s with %s: %s\n", config_dir, inf_path, strerror(errno) ); goto done; } fstat( fd, &st ); close( fd ); if (update_timestamp( config_dir, st.st_mtime ) || force) { HANDLE process; DWORD count = 0; if ((process = start_rundll32( inf_path, FALSE ))) { HWND hwnd = show_wait_window(); for (;;) { MSG msg; DWORD res = MsgWaitForMultipleObjects( 1, &process, FALSE, INFINITE, QS_ALLINPUT ); if (res == WAIT_OBJECT_0) { CloseHandle( process ); if (count++ || !(process = start_rundll32( inf_path, TRUE ))) break; } else while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); } DestroyWindow( hwnd ); } WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", config_dir ); } done: HeapFree( GetProcessHeap(), 0, inf_path ); }
static void parse_options( int *argc, char *argv[] ) { int i; char *opt; for (i = 1; i < *argc; i++) { if (argv[i][0] != '-') { /* check for valid drive argument */ if (strlen(argv[i]) != 2 || argv[i][1] != ':') usage(); continue; } for (opt = argv[i] + 1; *opt; opt++) switch(*opt) { case 'a': eject_all = 1; break; case 'u': unmount_only = 1; break; case 'h': usage(); break; default: WINE_MESSAGE( "Unknown option -%c\n", *opt ); usage(); } memmove( argv + i, argv + i + 1, (*argc - i) * sizeof(*argv) ); (*argc)--; i--; } }
int main( int argc, char *argv[] ) { parse_options( &argc, argv ); if (eject_all) { WCHAR drive; for (drive = 'c'; drive <= 'z'; drive++) { if (get_drive_type( drive ) != DRIVE_CDROM) continue; if (!eject_cd( drive )) exit(1); } } else if (argc > 1) { int i; for (i = 1; i < argc; i++) if (!eject_cd( argv[i][0] )) exit(1); } else { WCHAR drive = find_cd_drive(); if (!drive) { WINE_MESSAGE( "No CD drive found\n" ); exit(1); } if (!eject_cd( drive )) exit(1); } exit(0); }
static BOOL add_file_or_directory( HFCI fci, WCHAR *name ) { DWORD attr = GetFileAttributesW( name ); if (attr == INVALID_FILE_ATTRIBUTES) { WINE_MESSAGE( "cannot open %s\n", wine_dbgstr_w(name) ); return FALSE; } if (attr & FILE_ATTRIBUTE_DIRECTORY) { if (opt_recurse) return add_directory( fci, name ); WINE_MESSAGE( "cabarc: Cannot add %s, it's a directory (use -r for recursive add)\n", wine_dbgstr_w(name) ); return FALSE; } return add_file( fci, name ); }
static BOOL eject_cd( WCHAR drive ) { static const WCHAR deviceW[] = {'\\','\\','.','\\','a',':',0}; PREVENT_MEDIA_REMOVAL removal; WCHAR buffer[16]; HANDLE handle; DWORD result; if (get_drive_type( drive ) != DRIVE_CDROM) { WINE_MESSAGE( "Drive %c: is not a CD or is not mounted\n", (char)drive ); return FALSE; } memcpy( buffer, deviceW, sizeof(deviceW) ); buffer[4] = drive; handle = CreateFileW( buffer, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); if (handle == INVALID_HANDLE_VALUE) { WINE_MESSAGE( "Cannot open device for drive %c:\n", (char)drive ); return FALSE; } WINE_TRACE( "ejecting %c:\n", (char)drive ); if (!DeviceIoControl( handle, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &result, NULL )) WINE_WARN( "FSCTL_DISMOUNT_VOLUME failed with err %d\n", GetLastError() ); removal.PreventMediaRemoval = FALSE; if (!DeviceIoControl( handle, IOCTL_STORAGE_MEDIA_REMOVAL, &removal, sizeof(removal), NULL, 0, &result, NULL )) WINE_WARN( "IOCTL_STORAGE_MEDIA_REMOVAL failed with err %d\n", GetLastError() ); if (!unmount_only) { if (!DeviceIoControl( handle, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &result, NULL )) WINE_WARN( "IOCTL_STORAGE_EJECT_MEDIA failed with err %d\n", GetLastError() ); } CloseHandle( handle ); return TRUE; }
static DWORD register_iexplore(BOOL doregister) { HRESULT hres; if (check_native_ie()) { WINE_MESSAGE("Native IE detected, not doing registration\n"); return 0; } hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL); return FAILED(hres); }
/*********************************************************************** * start_dos_exe */ static void start_dos_exe( LPCSTR filename, LPCSTR cmdline ) { MEMORY_BASIC_INFORMATION mem_info; const char *reason; start_dosbox( filename, cmdline ); if (VirtualQuery( NULL, &mem_info, sizeof(mem_info) ) && mem_info.State != MEM_FREE) { __wine_load_dos_exe( filename, cmdline ); if (GetLastError() == ERROR_NOT_SUPPORTED) reason = "because vm86 mode is not supported on this platform"; else reason = wine_dbg_sprintf( "It failed with error code %u", GetLastError() ); } else reason = "because the DOS memory range is unavailable"; WINE_MESSAGE( "winevdm: Cannot start DOS application %s\n", filename ); WINE_MESSAGE( " %s.\n", reason ); WINE_MESSAGE( " You should install DOSBox.\n" ); ExitProcess(1); }
/* find the CD drive, and die if we find more than one */ static WCHAR find_cd_drive(void) { WCHAR ret = 0, drive; for (drive = 'c'; drive <= 'z'; drive++) { if (get_drive_type( drive ) != DRIVE_CDROM) continue; if (ret) { WINE_MESSAGE( "Multiple CD drives found (%c: and %c:), you need to specify the one you want.\n", (char)ret, (char)drive ); exit(1); } ret = drive; } return ret; }
static void usage( void ) { WINE_MESSAGE( "Usage: cabarc [options] command file.cab [files...] [dest_dir\\]\n" "\nCommands:\n" " L List the contents of the cabinet\n" " N Create a new cabinet\n" " X Extract files from the cabinet into dest_dir\n" "\nOptions:\n" " -d size Set maximum disk size\n" " -h Display this help\n" " -i id Set cabinet id\n" " -m type Set compression type (mszip|none)\n" " -p Preserve directory names\n" " -r Recurse into directories\n" " -s size Reserve space in the cabinet header\n" " -v More verbose output\n" ); }
static int new_cabinet( char *cab_dir ) { static const WCHAR plusW[] = {'+',0}; WCHAR **file; ERF erf; BOOL ret = FALSE; HFCI fci; CCAB cab; cab.cb = opt_cabinet_size; cab.cbFolderThresh = CB_MAX_DISK; cab.cbReserveCFHeader = opt_reserve_space; cab.cbReserveCFFolder = 0; cab.cbReserveCFData = 0; cab.iCab = 0; cab.iDisk = 0; cab.setID = opt_cabinet_id; cab.szDisk[0] = 0; strcpy( cab.szCabPath, cab_dir ); strcat( cab.szCabPath, "\\" ); format_cab_name( cab.szCab, 1, opt_cab_file ); fci = FCICreate( &erf, fci_file_placed, cab_alloc, cab_free,fci_open, fci_read, fci_write, fci_close, fci_lseek, fci_delete, fci_get_temp, &cab, NULL ); for (file = opt_files; *file; file++) { if (!strcmpW( *file, plusW )) FCIFlushFolder( fci, fci_get_next_cab, fci_status ); else if (!(ret = add_file_or_directory( fci, *file ))) break; } if (ret) { if (!(ret = FCIFlushCabinet( fci, FALSE, fci_get_next_cab, fci_status ))) WINE_MESSAGE( "cabarc: Failed to create cabinet %s\n", wine_dbgstr_a(opt_cab_file) ); } FCIDestroy( fci ); return !ret; }
/* format a cabinet name by replacing the '*' wildcard by the cabinet id */ static BOOL format_cab_name( char *dest, int id, const char *name ) { const char *num = strchr( name, '*' ); int len; if (!num) { if (id == 1) { strcpy( dest, name ); return TRUE; } WINE_MESSAGE( "cabarc: Cabinet name must contain a '*' character\n" ); return FALSE; } len = num - name; memcpy( dest, name, len ); len += sprintf( dest + len, "%u", id ); lstrcpynA( dest + len, num + 1, CB_MAX_CABINET_NAME - len ); return TRUE; }
/*********************************************************************** * main */ int main( int argc, char *argv[] ) { DWORD count; HINSTANCE16 instance; LOADPARAMS16 params; WORD showCmd[2]; char buffer[MAX_PATH]; STARTUPINFOA info; char *cmdline, *appname, **first_arg; char *p; if (!argv[1]) usage(); if (!strcmp( argv[1], "--app-name" )) { if (!(appname = argv[2])) usage(); first_arg = argv + 3; } else { if (!SearchPathA( NULL, argv[1], ".exe", sizeof(buffer), buffer, NULL )) { WINE_MESSAGE( "winevdm: unable to exec '%s': file not found\n", argv[1] ); ExitProcess(1); } appname = buffer; first_arg = argv + 1; } if (*first_arg) first_arg++; /* skip program name */ cmdline = build_command_line( first_arg ); if (WINE_TRACE_ON(winevdm)) { int i; WINE_TRACE( "GetCommandLine = '%s'\n", GetCommandLineA() ); WINE_TRACE( "appname = '%s'\n", appname ); WINE_TRACE( "cmdline = '%.*s'\n", cmdline[0], cmdline+1 ); for (i = 0; argv[i]; i++) WINE_TRACE( "argv[%d]: '%s'\n", i, argv[i] ); } GetStartupInfoA( &info ); showCmd[0] = 2; showCmd[1] = (info.dwFlags & STARTF_USESHOWWINDOW) ? info.wShowWindow : SW_SHOWNORMAL; params.hEnvironment = 0; params.cmdLine = MapLS( cmdline ); params.showCmd = MapLS( showCmd ); params.reserved = 0; RestoreThunkLock(1); /* grab the Win16 lock */ /* some programs assume mmsystem is always present */ LoadLibrary16( "gdi.exe" ); LoadLibrary16( "user.exe" ); LoadLibrary16( "mmsystem.dll" ); if ((instance = LoadModule16( appname, ¶ms )) < 32) { if (instance == 11) { /* first see if it is a .pif file */ if( ( p = strrchr( appname, '.' )) && !strcasecmp( p, ".pif")) pif_cmd( appname, cmdline + 1); else { /* try DOS format */ /* loader expects arguments to be regular C strings */ start_dos_exe( appname, cmdline + 1 ); } /* if we get back here it failed */ instance = GetLastError(); } WINE_MESSAGE( "winevdm: can't exec '%s': ", appname ); switch (instance) { case 2: WINE_MESSAGE("file not found\n" ); break; case 11: WINE_MESSAGE("invalid program file\n" ); break; default: WINE_MESSAGE("error=%d\n", instance ); break; } ExitProcess(instance); } /* wait forever; the process will be killed when the last task exits */ ReleaseThunkLock( &count ); Sleep( INFINITE ); return 0; }
/*********************************************************************** * usage */ static void usage(void) { WINE_MESSAGE( "Usage: winevdm.exe [--app-name app.exe] command line\n\n" ); ExitProcess(1); }
/******************************************************************************* * PSDRV_GetTrueTypeMetrics * * Reads font metrics from TrueType font files in directories listed in the * [TrueType Font Directories] section of the Wine configuration file. * * If this function fails (returns FALSE), the driver will fail to initialize * and the driver heap will be destroyed, so it's not necessary to HeapFree * everything in that event. * */ BOOL PSDRV_GetTrueTypeMetrics(void) { static const WCHAR pathW[] = {'P','a','t','h',0}; FT_Error error; FT_Library library; HKEY hkey; DWORD len; LPWSTR valueW; LPSTR valueA, ptr; /* @@ Wine registry key: HKCU\Software\Wine\Fonts */ if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts", &hkey) != ERROR_SUCCESS) return TRUE; ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0); if(!ft_handle) { WINE_MESSAGE( "Wine cannot find the FreeType font library. To enable Wine to\n" "use TrueType fonts please install a version of FreeType greater than\n" "or equal to 2.0.5.\n" "http://www.freetype.org\n"); RegCloseKey(hkey); return TRUE; } #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL) goto sym_not_found; LOAD_FUNCPTR(FT_Done_Face) LOAD_FUNCPTR(FT_Done_FreeType) LOAD_FUNCPTR(FT_Get_Char_Index) LOAD_FUNCPTR(FT_Get_Glyph_Name) LOAD_FUNCPTR(FT_Get_Sfnt_Name) LOAD_FUNCPTR(FT_Get_Sfnt_Name_Count) LOAD_FUNCPTR(FT_Get_Sfnt_Table) LOAD_FUNCPTR(FT_Init_FreeType) LOAD_FUNCPTR(FT_Load_Glyph) LOAD_FUNCPTR(FT_New_Face) LOAD_FUNCPTR(FT_Set_Charmap) #undef LOAD_FUNCPTR error = pFT_Init_FreeType(&library); if (error != FT_Err_Ok) { ERR("%s returned %i\n", "FT_Init_FreeType", error); wine_dlclose(ft_handle, NULL, 0); RegCloseKey(hkey); return FALSE; } if (RegQueryValueExW( hkey, pathW, NULL, NULL, NULL, &len ) == ERROR_SUCCESS) { len += sizeof(WCHAR); valueW = HeapAlloc( GetProcessHeap(), 0, len ); if (RegQueryValueExW( hkey, pathW, NULL, NULL, (LPBYTE)valueW, &len ) == ERROR_SUCCESS) { len = WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, NULL, 0, NULL, NULL ); valueA = HeapAlloc( GetProcessHeap(), 0, len ); WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, len, NULL, NULL ); TRACE( "got font path %s\n", debugstr_a(valueA) ); ptr = valueA; while (ptr) { LPSTR next = strchr( ptr, ':' ); if (next) *next++ = 0; ReadTrueTypeDir( library, ptr ); ptr = next; } HeapFree( GetProcessHeap(), 0, valueA ); } HeapFree( GetProcessHeap(), 0, valueW ); } RegCloseKey(hkey); pFT_Done_FreeType(library); wine_dlclose(ft_handle, NULL, 0); ft_handle = NULL; return TRUE; sym_not_found: WINE_MESSAGE( "Wine cannot find certain functions that it needs inside the FreeType\n" "font library. To enable Wine to use TrueType fonts please upgrade\n" "FreeType to at least version 2.0.5.\n" "http://www.freetype.org\n"); RegCloseKey(hkey); wine_dlclose(ft_handle, NULL, 0); ft_handle = NULL; return TRUE; }
int wmain( int argc, WCHAR *argv[] ) { static const WCHAR noneW[] = {'n','o','n','e',0}; static const WCHAR mszipW[] = {'m','s','z','i','p',0}; WCHAR *p, *command; char buffer[MAX_PATH]; char filename[MAX_PATH]; char *cab_file, *file_part; int i; while (argv[1] && argv[1][0] == '-') { switch (argv[1][1]) { case 'd': argv++; argc--; opt_cabinet_size = atoiW( argv[1] ); if (opt_cabinet_size < 50000) { WINE_MESSAGE( "cabarc: Cabinet size must be at least 50000\n" ); return 1; } break; case 'h': usage(); return 0; case 'i': argv++; argc--; opt_cabinet_id = atoiW( argv[1] ); break; case 'm': argv++; argc--; if (!strcmpiW( argv[1], noneW )) opt_compression = tcompTYPE_NONE; else if (!strcmpiW( argv[1], mszipW )) opt_compression = tcompTYPE_MSZIP; else { WINE_MESSAGE( "cabarc: Unknown compression type '%s'\n", optarg ); return 1; } break; case 'p': opt_preserve_paths = 1; break; case 'r': opt_recurse = 1; break; case 's': argv++; argc--; opt_reserve_space = atoiW( argv[1] ); break; case 'v': opt_verbose++; break; default: usage(); return 1; } argv++; argc--; } command = argv[1]; if (argc < 3 || !command[0] || command[1]) { usage(); return 1; } cab_file = strdupWtoA( CP_ACP, argv[2] ); argv += 2; argc -= 2; if (!GetFullPathNameA( cab_file, MAX_PATH, buffer, &file_part ) || !file_part) { WINE_ERR( "cannot get full name for %s\n", wine_dbgstr_a( cab_file )); return 1; } strcpy(filename, file_part); file_part[0] = 0; /* map slash to backslash in all file arguments */ for (i = 1; i < argc; i++) for (p = argv[i]; *p; p++) if (*p == '/') *p = '\\'; opt_files = argv + 1; opt_cab_file = filename; switch (*command) { case 'l': case 'L': return list_cabinet( buffer ); case 'n': case 'N': return new_cabinet( buffer ); case 'x': case 'X': if (argc > 1) /* check for destination dir as last argument */ { WCHAR *last = argv[argc - 1]; if (last[0] && last[strlenW(last) - 1] == '\\') { opt_dest_dir = last; argv[--argc] = NULL; } } WINE_TRACE("Extracting file(s) from cabinet %s\n", wine_dbgstr_a(cab_file)); return extract_cabinet( buffer ); default: usage(); return 1; } }
/*********************************************************************** * start_dos_exe */ static void start_dos_exe( LPCSTR filename, LPCSTR cmdline ) { start_dosbox( filename, cmdline ); WINE_MESSAGE( "winevdm: %s is a DOS application, you need to install DOSBox.\n", filename ); ExitProcess(1); }