Subversion Repositories SvarDOS

Rev

Rev 351 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 351 Rev 358
Line 120... Line 120...
120
 
120
 
121
 
121
 
122
/* scan memory for rmod, returns its segment if found, 0xffff otherwise */
122
/* scan memory for rmod, returns its segment if found, 0xffff otherwise */
123
unsigned short rmod_find(void) {
123
unsigned short rmod_find(void) {
124
  unsigned short i;
124
  unsigned short i;
125
  unsigned short far *pattern;
125
  unsigned short far *ptrword;
-
 
126
  unsigned char far *ptrbyte;
126
 
127
 
127
  /* iterate over all paragraphs, looking for my signature */
128
  /* iterate over all paragraphs, looking for my signature */
128
  for (i = 0; i != 65535; i++) {
129
  for (i = 1; i != 65535; i++) {
129
    pattern = MK_FP(i, 0);
130
    ptrword = MK_FP(i, 0);
130
    if (pattern[0] != 0x1983) continue;
131
    if (ptrword[0] != 0x1983) continue;
131
    if (pattern[1] != 0x1985) continue;
132
    if (ptrword[1] != 0x1985) continue;
132
    if (pattern[2] != 0x2017) continue;
133
    if (ptrword[2] != 0x2017) continue;
133
    if (pattern[3] != 0x2019) continue;
134
    if (ptrword[3] != 0x2019) continue;
-
 
135
    /* extra check: make sure the paragraph before is an MCB block and that it
-
 
136
     * belongs to itself. otherwise I could find the rmod code embedded inside
-
 
137
     * the command.com binary... */
-
 
138
    ptrbyte = MK_FP(i - 1, 0);
-
 
139
    if ((*ptrbyte != 'M') && (*ptrbyte != 'Z')) continue; /* not an MCB */
-
 
140
    ptrword = MK_FP(i - 1, 1);
-
 
141
    if (*ptrword != i) continue; /* not belonging to self */
134
    return(i);
142
    return(i);
135
  }
143
  }
136
  return(0xffff);
144
  return(0xffff);
137
}
145
}