-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBOOTIT.ENG
191 lines (177 loc) · 4.39 KB
/
BOOTIT.ENG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
int level=1;
int last;
int i;
int numarg;
char config[255];
char config_to_write[255];
char sublevel[]="\0";
char *datfile="C:\\AUTOCONF.DAT";
int drive='C';
char zero_string[41];
char temp[255];
int in;
unsigned count;
void bootme(int want_warm) /* arg 0 = cold boot, 1 = warm */ {
union REGS reg;
void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
unsigned far* boottype = (unsigned far*)0x00400072UL;
char far* shiftstate = (char far*)0x00400017UL;
unsigned ticks;
int time_to_waste;
/* Simulate reception of Ctrl-Alt-Del: */
printf("\nOverloading cache...");
asm{
mov ax,4A10h
mov bx,0001h
int 2Fh
}
printf("\nFixing CTRL & ALT... (CTRL-ALT-DEL if fails)");
for (;;) {
*shiftstate |= 0x0C; /* turn on Ctrl & Alt */
reg.x.ax = 0x4F53; /* 0x53 = Del's scan code */
reg.x.cflag = 1; /* sentinel for ignoring key */
int86(0x15, ®, ®);
/* If carry flag is still set, we've finished. */
if (reg.x.cflag)
break;
/* Else waste some time before trying again: */
printf("\nPlease wait to retry...");
reg.h.ah = 0;
int86(0x1A, ®, ®);/* system time into CX:DX */
ticks = reg.x.dx;
for (time_to_waste = 3; time_to_waste > 0; ) {
reg.h.ah = 0;
int86(0x1A, ®, ®);
if (ticks != reg.x.dx)
ticks = reg.x.dx , --time_to_waste;
}
}
/* Issue a DOS disk reset request: */
printf("\nIssuing disk reset request...");
reg.h.ah = 0x0D;
int86(0x21, ®, ®);
/* Set boot type and boot: */
*boottype = (want_warm ? 0x1234 : 0);
(*boot)( );
}
void helpex(void)
{
printf("\nBOOTIT 1.5 for AUTOCONF (2.80 and above)");
printf("\nsyntax:\n\n");
printf("BOOTIT [-drive] configuration ");
printf("\n\nwhere:\n");
printf( "\t[drive]: the boot drive of your PC");
printf("\n\tconfiguration : configuration to boot, ex: F1, A or F0 (for F10)\n\n");
printf("example: BOOTIT F2 -F\n\n");
printf("\nTo specify a sub-configuration, just write as follows: A_F2_L.");
printf("\nTo obtain the list of configuration after reboot: BOOTIT LIST(E)\n");
printf("Note: the order of options as well as the use of capitalized or small\n");
printf(" letters are not important at all.\n");
exit(1);
}
void main (int argc,char **argv)
{
if (argc>3) helpex();
if (argc==1) helpex();
printf("\nBOOTIT 1.5 - AUTOCONF (2.80 & +)");
for (numarg=1;numarg<argc;numarg++)
{
if ((stricmp(argv[numarg],"LIST")==0)||(stricmp(argv[numarg],"LISTE")==0))
{
strcpy(config," ");
break;
}
strcpy(temp,strupr(argv[numarg]));
if (temp[0]=='-') drive=temp[1];
else strcpy(config,temp);}
datfile[0]=drive;
if (config[strlen(config)-1]>='0')
if (config[strlen(config)-1]<='9')
if (config[strlen(config)-2]=='F')
{
config_to_write[1]=config[strlen(config)-1];
config_to_write[0]='œ';
last=strlen(config)-4;
goto okay;
}
last=strlen(config)-3;
config_to_write[1]=config[strlen(config)-1];
config_to_write[0]='$';
config_to_write[2]='\0';
okay:
sublevel[0]=sublevel[0]+1;
for(i=0;i<=last;i++)
{
if (config[i]!='_')
{
sublevel[0]=sublevel[0]+1;
if (config[i]=='F')
{
if (config[i+1]<='9')
{
if (config[i+1]>='0')
{
zero_string[level+20]=1;
zero_string[level]=config[i+1];
i++;
}
}
else
{
zero_string[level+20]=0;
zero_string[level]=config[i];
}
}
else
{
zero_string[level+20]=0;
zero_string[level]=config[i];
}
level++;
}
}
if (_dos_creat(datfile, _A_HIDDEN, &in) != 0)
{
printf("\nError opening %s.\n",datfile);
helpex();
}
_dos_write(in, zero_string, 40, &count);
_dos_write(in, sublevel, 1, &count);
_dos_write(in, config_to_write, strlen(config_to_write), &count);
_dos_close(in);
flushall();
fcloseall();
printf("...preparation finished.");
asm{
push es
push di
mov ax,1600h
int 2Fh // Enhanced Windows install check
test al,7Fh
jnz yes_windows // ; Jump if zero
mov ax,4680h
int 2Fh //; Windows 3.0 running status, ax
or ax,ax //; Zero ?
jz yes_windows //; Jump if zero
}
goto no_windows;
yes_windows:
asm{
pop es
pop di
}
printf("\nYou computer has been prepared for restart...");
printf("\nPlease exit Windows and press CTRL ALT DELETE.");
exit(1);
no_windows:
asm{
pop es
pop di
}
bootme(1);
}