wok rev 21553

syslinux/iso2exe,taziso: add slitaz.pif
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 10 19:27:17 2019 +0200 (4 months ago)
parents 711632e87540
children f56ae17d902e
files syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/taziso syslinux/stuff/iso2exe/win32.c
line diff
     1.1 --- a/syslinux/stuff/iso2exe/init	Wed May 08 15:12:37 2019 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/init	Fri May 10 19:27:17 2019 +0200
     1.3 @@ -342,6 +342,16 @@
     1.4  initrd=/slitaz/boot/$initrd
     1.5  rw root=/dev/null $extraargs autologin
     1.6  EOT
     1.7 +	uudecode - <<EOT | gunzip > /mnt/slitaz/boot/slitaz.pif
     1.8 +begin-base64 644 -
     1.9 +H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
    1.10 +Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
    1.11 +f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
    1.12 +2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
    1.13 +EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
    1.14 +ACxDxwMAAA==
    1.15 +====
    1.16 +EOT
    1.17  	unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
    1.18  		/mnt/slitaz/boot/README
    1.19  	[ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
     2.1 --- a/syslinux/stuff/iso2exe/taziso	Wed May 08 15:12:37 2019 +0100
     2.2 +++ b/syslinux/stuff/iso2exe/taziso	Fri May 10 19:27:17 2019 +0200
     2.3 @@ -255,6 +255,16 @@
     2.4  initrd=/slitaz/boot/$initrd
     2.5  rw root=/dev/null $extraargs autologin
     2.6  EOT
     2.7 +	uudecode - <<EOT | gunzip > $mnt/slitaz/boot/slitaz.pif
     2.8 +begin-base64 644 -
     2.9 +H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
    2.10 +Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
    2.11 +f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
    2.12 +2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
    2.13 +EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
    2.14 +ACxDxwMAAA==
    2.15 +====
    2.16 +EOT
    2.17  	unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
    2.18  		$mnt/slitaz/boot/README
    2.19  	[ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
     3.1 --- a/syslinux/stuff/iso2exe/win32.c	Wed May 08 15:12:37 2019 +0100
     3.2 +++ b/syslinux/stuff/iso2exe/win32.c	Fri May 10 19:27:17 2019 +0200
     3.3 @@ -4,7 +4,6 @@
     3.4  #include <sys/stat.h>
     3.5  #include <fcntl.h>
     3.6  
     3.7 -#define VCPI_LINUX_LOADER The DOS/EXE loader can boot in VM86 using VCPI API
     3.8  #define BOOTSTRAP_SECTOR_COUNT_OFFSET	26
     3.9  
    3.10  static int fullread(int fd, char *p, int n)
    3.11 @@ -29,33 +28,151 @@
    3.12  #define write fullwrite
    3.13  }
    3.14  
    3.15 -#ifdef VCPI_LINUX_LOADER
    3.16 +#pragma pack(push,1)
    3.17 +struct PIF_section_header {
    3.18 +	char name[16];
    3.19 +	short next_header_offset;
    3.20 +	short data_offset;
    3.21 +	short data_length;
    3.22 +};
    3.23 +
    3.24 +struct PIF_basic_section {
    3.25 +	unsigned char unused;
    3.26 +	unsigned char checksum;
    3.27 +	char window_title[30];
    3.28 +	unsigned short max_mem;
    3.29 +	unsigned short min_mem;
    3.30 +	char program_filename[63];
    3.31 +	unsigned short bitmask;
    3.32 +	char working_directory[64];
    3.33 +	char parameters_string[64];
    3.34 +	unsigned char video_mode;
    3.35 +	unsigned char video_pages;
    3.36 +	unsigned char first_interrupt;
    3.37 +	unsigned char last_interrupt;
    3.38 +	unsigned char height_screen;
    3.39 +	unsigned char width_screen;
    3.40 +	unsigned char horizontal_pos;
    3.41 +	unsigned char vertical_pos;
    3.42 +	unsigned short last_text_page;
    3.43 +	char unused2[128];
    3.44 +	unsigned short bitmask2;
    3.45 +};
    3.46 +
    3.47 +struct PIF_section_win_386_3_0 {
    3.48 +	unsigned short max_mem;
    3.49 +	unsigned short min_mem;
    3.50 +	unsigned short active_priority;
    3.51 +	unsigned short background_priority;
    3.52 +	unsigned short max_ems;
    3.53 +	unsigned short required_ems;
    3.54 +	unsigned short max_xms;
    3.55 +	unsigned short required_xms;
    3.56 +	unsigned long bitmask;
    3.57 +	unsigned short bitmask2;
    3.58 +	unsigned short unknown;
    3.59 +	unsigned short shortcut_key_code;
    3.60 +	unsigned short shortcut_key_modifier;
    3.61 +	unsigned short shortcut_key_use;
    3.62 +	unsigned short shortcut_key_scan;
    3.63 +	unsigned short unknown2;
    3.64 +	unsigned short unknown3;
    3.65 +	unsigned long unknown4;
    3.66 +	char parameters_string[64];
    3.67 +};
    3.68 +
    3.69 +struct PIF_section_win_vmm_4_0 {
    3.70 +	char unknown[88];
    3.71 +	char iconfile[80];
    3.72 +	unsigned short icon_number;
    3.73 +	unsigned short bitmask;
    3.74 +	char unknown2[10];
    3.75 +	unsigned short priority;
    3.76 +	unsigned short bitmask2; // video
    3.77 +	char unknown3[8];
    3.78 +	unsigned short text_lines;
    3.79 +	unsigned short bitmask3; // Key modifiers
    3.80 +	unsigned short unknown4;
    3.81 +	unsigned short unknown5;
    3.82 +	unsigned short unknown6;
    3.83 +	unsigned short unknown7;
    3.84 +	unsigned short unknown8;
    3.85 +	unsigned short unknown9;
    3.86 +	unsigned short unknown10;
    3.87 +	unsigned short unknown11;
    3.88 +	unsigned short bitmask4; // Mouse
    3.89 +	char unknown12[6];
    3.90 +	unsigned short bitmask5; // Fonts
    3.91 +	unsigned short unknown13;
    3.92 +	unsigned short rasterfontHsize;
    3.93 +	unsigned short rasterfontVsize;
    3.94 +	unsigned short fontHsize;
    3.95 +	unsigned short fontVsize;
    3.96 +	char raster_name[32];
    3.97 +	char truetype_name[32];
    3.98 +	unsigned short unknown14;
    3.99 +	unsigned short bitmask6;
   3.100 +	unsigned short restore_settings;
   3.101 +	unsigned short Hsize;
   3.102 +	unsigned short Vsize;
   3.103 +	unsigned short HsizePixelsClient;
   3.104 +	unsigned short VsizePixelsClient;
   3.105 +	unsigned short HsizePixels;
   3.106 +	unsigned short VsizePixels;
   3.107 +	unsigned short unknown15;
   3.108 +	unsigned short bitmask7;
   3.109 +	unsigned short maximized;
   3.110 +	char unknown16[4];
   3.111 +	char window_geom[16];
   3.112 +	char bat_file_name[80];
   3.113 +	unsigned short env_size;
   3.114 +	unsigned short dpmi_size;
   3.115 +	unsigned short unknown17;
   3.116 +};
   3.117 +
   3.118 +static struct {
   3.119 +	struct PIF_basic_section s0;
   3.120 +	struct PIF_section_header h0;
   3.121 +	struct PIF_section_header h1;
   3.122 +	struct PIF_section_win_386_3_0 s1;
   3.123 +	struct PIF_section_header h2;
   3.124 +	struct PIF_section_win_vmm_4_0 s2;
   3.125 +} PIF_content = {
   3.126 +	{ 0, 0x78, "MS-DOS Prompt                 ", 640, 0, "" /*slitaz.exe*/,
   3.127 +	  0x10, "", "", 0, 1, 0, 255, 25, 80, 0, 0, 7, "", 0 },
   3.128 +	{ "MICROSOFT PIFEX", sizeof(struct PIF_basic_section)
   3.129 +		+ sizeof(struct PIF_section_header), 0,
   3.130 +		sizeof(struct PIF_basic_section) },
   3.131 +	{ "WINDOWS 386 3.0", sizeof(struct PIF_basic_section)
   3.132 +		+ 2*sizeof(struct PIF_section_header)
   3.133 +		+ sizeof(struct PIF_section_win_386_3_0),
   3.134 +		sizeof(struct PIF_basic_section)
   3.135 +		+ 2*sizeof(struct PIF_section_header),
   3.136 +		sizeof(struct PIF_section_win_386_3_0) },
   3.137 +	{ 640, 0, 100, 50, 65535, 0, 65535, 0, 0x10821002, 31, 0, 0, 0, 0, 0, 0,
   3.138 +	  0, 0, "" },
   3.139 +	{ "WINDOWS VMM 4.0", 65535, sizeof(struct PIF_basic_section)
   3.140 +		+ 3*sizeof(struct PIF_section_header)
   3.141 +		+ sizeof(struct PIF_section_win_386_3_0),
   3.142 +		sizeof(struct PIF_section_win_vmm_4_0) },
   3.143 +	{ "", "PIFMGR.DLL", 0, 2, "", 50, 1, "", 0, 1, 0, 5, 25, 3, 0xC8,
   3.144 +	  0x3E8, 2, 10, 1, "", 28, 0, 0, 0, 7, 12, "Terminal", "Courier New",
   3.145 +	  0, 3, 0, 80, 25, 0x250, 0x140, 0, 0, 22, 0, 0, "", "", "", 0, 0, 1 }
   3.146 +};
   3.147 +#pragma pack(pop)
   3.148 +
   3.149  static void exec16bits(char *isoFileName)
   3.150  {
   3.151 -	int fdiso, fdtmp, i;
   3.152 -	char buffer[512];
   3.153 -	char tmpFileName[MAX_PATH], *p;
   3.154 +	int fd;
   3.155 +	const char pifFileName[] = "slitaz.pif";
   3.156  
   3.157 -	strcpy(tmpFileName, isoFileName);
   3.158 -	p = strrchr(tmpFileName, '\\');
   3.159 -	if (!p++) p = tmpFileName;
   3.160 -	strcpy(p, "tazboot.exe");
   3.161 -	fdiso = open(isoFileName, O_RDONLY|O_BINARY);
   3.162 -	fdtmp = open(tmpFileName, O_WRONLY|O_BINARY|O_CREAT,0555);
   3.163 -	for (i = 0; i < 0x8000; i += sizeof(buffer)) {
   3.164 -		read(fdiso, (char *) buffer, sizeof(buffer));
   3.165 -		if (i == 0) {
   3.166 -			buffer[2] =  buffer[3]  =	// reset last page size
   3.167 -			buffer[18] = buffer[19] = 0;	// reset checksum
   3.168 -			buffer[63]++;			// kill PE header
   3.169 -		}
   3.170 -		write(fdtmp, (char *) buffer, sizeof(buffer));
   3.171 -	}
   3.172 -	close(fdiso);
   3.173 -	close(fdtmp);
   3.174 -	execl(tmpFileName, isoFileName);
   3.175 +	strcpy(PIF_content.s0.program_filename, isoFileName);
   3.176 +	fd = open(pifFileName, O_WRONLY|O_BINARY|O_CREAT,0555);
   3.177 +	write(fd,&PIF_content,sizeof(PIF_content));
   3.178 +	close(fd);
   3.179 +	WinExec(pifFileName, SW_MINIMIZE);
   3.180 +	exit(0);
   3.181  }
   3.182 -#endif
   3.183  
   3.184  static int iswinnt(void)
   3.185  {
   3.186 @@ -194,19 +311,14 @@
   3.187  	
   3.188  	GetModuleFileName(hInstance, isoFileName, MAX_PATH);
   3.189  	if (!iswinnt()) {
   3.190 -#ifdef VCPI_LINUX_LOADER
   3.191  		if (MessageBox(NULL,"This program must be run in DOS mode.\n"
   3.192 -			"I can try to launch it, but it's safer to\n"
   3.193 -			"reboot in DOS mode and run it at DOS prompt.",
   3.194 -			"Launch SliTaz now ?",
   3.195 +			"I can create the file slitaz.pif to launch it, "
   3.196 +			"but you can reboot in DOS mode and\n"
   3.197 +			"run it at DOS prompt.",
   3.198 +			"Create slitaz.pif now ?",
   3.199  			MB_YESNO|MB_ICONQUESTION) == IDYES) {
   3.200  			exec16bits(isoFileName);
   3.201  		}
   3.202 -#else
   3.203 -		MessageBox(NULL,"No support for Win9x yet.\n"
   3.204 -				"Retry in DOS mode without emm386.\n",
   3.205 -			   "Sorry", MB_OK|MB_ICONERROR);
   3.206 -#endif
   3.207  		exit(1);
   3.208  	}
   3.209  	if (!ishybrid(isoFileName)) {