📄 main.c
字号:
ret = GlobalStructure(stclass);
else
if (stclass == PUBLIC)
return(0);
else
ret = declglb(CINT, stclass);
}
if (!ret)
ns();
return(1);
}
/*
* dump the literal pool
*/
void dumplits(void) {
int j, k;
if (litptr == 0)
return;
ol("; start of global pool");
printlabel(litlab);
col();
k = 0;
while (k < litptr) {
defbyte();
j = 8;
while (j--) {
onum(litq[k++] & 127);
if ((j == 0) | (k >= litptr)) {
nl();
break;
}
outbyte(',');
}
}
}
static void DumpGlobalConstants() {
int i, j, n;
byte *pb;
char myline[300], sto[10];
int *pi;
i = 1;
while (i <= gcptr) {
j = 0;
outstr(globcon[i].name);
if (strlen(globcon[i].name) > 7)
nl();
if (globcon[i].type == GLOBBYTE) {
pb = (byte*)globcon[i].pp + 1;
ot("db\t");
n = (int)globcon[i].pp[0];
while (n--) {
outundec(*pb++);
if (++j > 20) {
nl();
ot("db\t");
j = 0;
}
else
if (n > 0)
outstr(",");
}
nl();
}
else
if (globcon[i].type == GLOBCHAR) {
strcpy(myline, "db\t\"");
strcat(myline, globcon[i].pp);
strcat(myline, "\"");
ot(myline);
nl();
}
else
if (globcon[i].type == GLOBINT || globcon[i].type == GLOBLONG) {
pi = (int*)globcon[i].pp;
pi++;
strcpy(sto, "dw\t");
if (globcon[i].type == GLOBLONG)
strcpy(sto, "dd\t");
ot(sto);
n = (int)globcon[i].pp[0];
while (n--) {
outundec(*pi++);
if (++j > 15) {
nl();
ot(sto);
j = 0;
}
else
if (n > 0)
outstr(",");
}
nl();
}
free(globcon[i].pp);
i++;
}
}
/*
* dump all static variables
*/
void dumpglbs(void) {
int j;
char text[50];
if (!glbflag)
return;
// ol("; dump globals");
cptr = rglbptr;
while (cptr < glbptr) {
if (symtab[cptr].label) {
cptr++;
continue;
}
if (symtab[cptr].ident == FUNCDEF) {
symtab[cptr].ident = FUNCTION; // undefined function
symtab[cptr].storage = EXTERN;
}
if (symtab[cptr].ident != FUNCTION && symtab[cptr].type != STRUCTDEF) {
ppubext(cptr);
if (symtab[cptr].storage != EXTERN) {
InsertPrefix(text);
strcat(text, symtab[cptr].name);
outstr(text);
col();
defstorage();
j = glint(cptr);
if ((symtab[cptr].type == CINT) ||
(symtab[cptr].type == UCINT) ||
(symtab[cptr].type == VOID) ||
(symtab[cptr].ident == POINTER)) // note "ident" here, not "type"
j = j * intsize();
else
if (symtab[cptr].type == CLONG)
j = j * 4;
onum(j);
nl();
}
}
else {
if (symtab[cptr].used)
fpubext(cptr);
}
cptr++;
}
if (nflag) {
ot("public\tHARDSTK,SOFTSTK");
nl();
outstr("HARDSTK\tequ\t");
onum(hardstk);
nl();
outstr("SOFTSTK\tequ\t");
onum(softstk);
nl();
}
}
// report errors
void errorsummary(void) {
if (ncmp)
error("missing closing bracket");
nl();
comment();
outdec(errcnt);
if (errcnt)
errfile = YES;
outstr(" error(s) in compilation");
nl();
comment();
ot("literal pool:");
outdec(litptr);
nl();
comment();
ot("global pool:");
outdec(glbptr-rglbptr);
nl();
comment();
ot("Macro pool:");
outdec(macptr);
nl();
regsummary();
pl(errcnt ? "Error(s)" : "No errors");
}
char xtypeof(char *s) {
s += strlen(s) - 2;
if (*s == '.')
return(*(s+1));
return(' ');
}
// Determine if the provided sn agrees with
// requirement. Checks length, that it is numeric,
// and then whether the even bytes match one of
// the samples.
static int CheckAsciiSN(char *sn, char *num) {
int i, j, a, b, flag;
byte *p;
// Check length
if (strlen(sn) != 16) // must be 12 chars
return 0;
// Check is numeric
p = (byte*)sn;
for (i=0; i<8; i++) { // all odd must be numeric
num[i] = *p++;
if (num[i] < '0' || num[i] > '9')
return 0;
p++;
}
num[8] = '\0';
// Check is valid
srand(27);
for (i=0; i<21; i++) {
flag = 1;
p = (byte*)sn;
for (j=0; j<16; j++) {
a = rand() % 234;
if (j%2) {
b = (int)sss[i][j];
if (b < 0)
b = 256 + b;
a = b - a + 48;
if (flag && *p != a)
flag = 0;
}
p++;
}
if (flag)
return 1;
}
return 0;
}
static int Inverse(char *f, char *num) {
char *p, *q, buff[128], local[200];
int fd, i, bytes;
long fpos;
p = NULL;
fd = _open(f, O_RDWR);
fpos = 0L;
do {
lseek(fd, fpos, SEEK_SET);
bytes = _read(fd, buff, 128);
if (p = CheckInStr(buff, sn2))
break;
fpos += 64L;
} while (bytes > 0);
if (p) {
fpos += p - buff + 2;
// fpos is now pointing to the start of the *p[]
// data structure above. The compiler will have
// reversed the order, so the lowest string in
// memory will be the last string in the array.
lseek(fd, fpos, SEEK_SET);
_read(fd, buff, 128); // read entire array
if (num) {
srand(7); // definite start
p = num;
q = buff;
for (i=0; i<8; i++) { // insert the new sn
*p += mine(); // obfuscation
buff[i*14 + 3*i] = buff[i*7]; // red herring
buff[i*14 + 2*i] = *p++;
}
lseek(fd, fpos, SEEK_SET);
i = _write(fd, buff, 128); // overwrite
_close(fd);
}
else {
p = local;
bytes = 1;
srand(7);
for (i=0; i<8; i++) {
*p = buff[i*14 + 2*i];
if (i == 0 && *p == 'K') {
_close(fd);
return (999999999);
}
*p++ -= mine(); // de-obfuscation
}
*p = '\0';
_close(fd);
return atoi(local);
}
}
}
static int mine() {
return rand() % 37;
}
// Check if a SN line already exists in the ini. If no
// file exists or a SN line does not exist, returns zero.
// If a sn does exist it returns with the number if it
// is valid or -1 if not.
static int CheckINI(char *me) {
char local[200], *p;
FILE *fp;
int i, n;
strcpy(local, me);
p = local + strlen(local)-3;
*p++ = 'i';
*p++ = 'n';
*p++ = 'i';
if (fp = fopen(local, "r")) {
while (fgets(local, 128, fp)) {
if (strstr(local, "SN") || strstr(local, "sn")) {
// extract the number
p = local;
while (*p && *p++ != '=')
;
while (*p && *p == ' ')
p++;
n = 0;
for (i=0; i<8; i++) {
local[i] = *p;
if (*p < '0' || *p > '9') {
fclose(fp);
return -1;
}
p += 2;
}
local[i] = '\0';
fclose(fp);
return atoi(local);
}
}
}
return 0;
}
static int AddINI(char *me, char *sn) {
char local[200], *p;
FILE *fp;
strcpy(local, me);
p = local + strlen(local)-3;
*p++ = 'i';
*p++ = 'n';
*p++ = 'i';
if (fp = fopen(local, "r+")) {
while (fgets(local, 128, fp))
;
}
else
if ((fp = fopen(local, "w")) == NULL) {
printf("Cannot create INI file: %s\n", local);
exit(1);
}
strcpy(local, "SN=");
strcat(local, sn);
strcat(local, "\n");
fputs(local, fp);
fclose(fp);
}
static char *CheckInStr(char *p, char *s) {
char *ss, *qq;
int i, n, flag;
ss = s;
n = strlen(s);
i = flag = 0;
qq = NULL;
while (i++ < 128) {
if (*p == *ss) {
flag++;
if (flag == n){
qq = p;
break;
}
ss++;
}
else {
flag = 0;
ss = s;
}
p++;
}
return qq;
}
static void ClearTable() {
int i;
char nm[NAMESIZE];
strcpy(nm, " ");
for (i=2; i<NAMESIZE; i++)
strcat(nm, " ");
nm[NAMESIZE-1] = '\0';
for (i=0; i<SYMTBSZ; i++)
strcpy(symtab[i].name, nm);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -