Changeset 193 for trunk/nom/src/nomgc.c
- Timestamp:
- Jan 16, 2007, 8:31:25 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/nom/src/nomgc.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/nom/src/nomgc.c
r160 r193 54 54 #include <gc.h> 55 55 56 gboolean bUseGC=FALSE; /* M Ark if we use the garbage collector */56 gboolean bUseGC=FALSE; /* Mark if we use the garbage collector */ 57 57 58 58 static gpointer gcMalloc(gulong ulBytes) … … 94 94 95 95 g_mem_set_vtable(&vtbl); 96 fprintf(stderr, " GC memory functions set for GLIB. (%s: %d)\n", __FILE__, __LINE__);96 /* fprintf(stderr, " GC memory functions set for GLIB. (%s: %d)\n", __FILE__, __LINE__); */ 97 97 98 98 bUseGC=TRUE; … … 104 104 } 105 105 106 static void qsAddDLLToList(HREGDLL hReg, qsLrec_t* rec) 107 { 108 if(NULLHANDLE==g_slist_find(hReg->dllList, rec)) 109 hReg->dllList=g_slist_append(hReg->dllList, rec); 110 } 111 112 #if 0 113 static void qsPrintDLLList(HREGDLL hReg) 114 { 115 GSList* lTemp; 116 int a=0; 117 118 lTemp=hReg->dllList; 119 while(lTemp) 120 { 121 qsLrec_t* rec; 122 rec=(qsLrec_t*)lTemp->data; 123 a++; 124 g_message(" %d: %s", a, rec->pName); 125 lTemp=g_slist_next(lTemp); 126 } 127 } 128 #endif 106 129 107 130 /* 108 131 Find a library record in the buffer filled by DosQuerySysState(). 109 132 */ 110 static qsLrec_t* qsFindModuleRec(const HREGDLLhRegisterDLL, USHORT hMod){133 static qsLrec_t* qsFindModuleRec(const qsPtrRec_t * hRegisterDLL, USHORT hMod){ 111 134 qsLrec_t * pModRec; 112 135 int a=0; … … 116 139 { 117 140 a++; 118 / / printf("%d Checking: %x -> %04X (%s)\n", a, pModRec, pModRec->hmte, pModRec->pName);141 /* printf("%d Checking: %x -> %04X (%s)\n", a, pModRec, pModRec->hmte, pModRec->pName); */ 119 142 120 143 if (NULLHANDLE==pModRec->pObjInfo && pModRec->ctObj > 0) … … 133 156 pModRec=(qsLrec_t *)pModRec->pNextRec; 134 157 } 158 135 159 return pModRec; 136 160 } 137 161 138 162 #define BUFSIZE 1024*1024 163 NOMEXTERN HREGDLL NOMLINK nomBeginRegisterDLLWithGC(void) 164 { 165 ULONG rc; 166 HREGDLL hReg=NULLHANDLE; 167 PTIB ptib; 168 PPIB ppib; 169 char * buf; 170 HREGDLL pRegDLL=NULLHANDLE; 171 172 rc = DosGetInfoBlocks(&ptib, &ppib); 173 if (rc!=NO_ERROR) 174 return NULLHANDLE; 175 176 buf = malloc(BUFSIZE); 177 if(!buf) 178 return NULLHANDLE; 179 180 pRegDLL =(HREGDLL) malloc(sizeof(REGDLL)); 181 if(!pRegDLL){ 182 free(buf); 183 return NULLHANDLE; 184 } 185 pRegDLL->dllList=NULLHANDLE; 186 187 memset(buf,0,BUFSIZE); 188 189 rc = DosQuerySysState(QS_PROCESS | QS_SEMAPHORE | QS_MTE | QS_FILESYS | QS_SHMEMORY , 190 QS_MTE, /*0x96*/ ppib->pib_ulpid , 1UL, (PCHAR)buf, BUFSIZE); 191 if (rc==NO_ERROR) { 192 qsPrec_t * p; 193 GSList* lTemp; 194 195 pRegDLL->pMainAnchor=(qsPtrRec_t*) buf; 196 197 p=pRegDLL->pMainAnchor->pProcRec; 198 199 while(p && p->RecType == 1) 200 { 201 202 if (p->cLib) { 203 int i; 204 205 for (i=0; i<p->cLib; i++){ 206 qsLrec_t * pModRec; 207 208 pModRec=qsFindModuleRec(pRegDLL->pMainAnchor, p->pLibRec[i]); 209 210 if(pModRec){ 211 //if(pModRec->pName) 212 //g_message("%s", pModRec->pName); 213 qsAddDLLToList(pRegDLL, pModRec); 214 } 215 }/* for() */ 216 }/* if(p->clib) */ 217 break; 218 };/* while() */ 219 220 /* Ok, got directly imported DLLs. Now go over these and check them for additional imports. 221 Every import is added to the end of the list (except duplicates). So while going over 222 the list we touch every DLL and check every import. Import cycles are no problem, because 223 later duplicates are ignored. */ 224 lTemp=pRegDLL->dllList; 225 while(lTemp) 226 { 227 qsLrec_t* rec; 228 229 rec=(qsLrec_t*)lTemp->data; 230 231 /* Check the imports of this DLL if any */ 232 if(rec->ctImpMod >0) 233 { 234 int iImps; 235 PUSHORT pImpHmte; 236 237 pImpHmte=(PUSHORT)((void*)rec + sizeof(qsLrec_t)); 238 for(iImps=0; iImps < rec->ctImpMod; iImps++) 239 { 240 qsLrec_t * pModImp; 241 242 pModImp=qsFindModuleRec(pRegDLL->pMainAnchor, pImpHmte[iImps]); 243 if(pModImp) 244 qsAddDLLToList(pRegDLL, pModImp); 245 }/* for()*/ 246 }/* if() */ 247 lTemp=g_slist_next(lTemp); 248 };/* while() */ 249 //qsPrintDLLList(); 250 hReg=pRegDLL; 251 } 252 else{ 253 free(pRegDLL); 254 free(buf); 255 } 256 return hReg; 257 } 258 259 NOMEXTERN void NOMLINK nomEndRegisterDLLWithGC(const HREGDLL hRegisterDLL ) 260 { 261 g_slist_free(hRegisterDLL->dllList); 262 free((char*)hRegisterDLL->pMainAnchor); 263 free((char*)hRegisterDLL); 264 } 265 266 #define OBJREAD 0x0001L 267 #define OBJWRITE 0x0002L 268 #define OBJINVALID 0x0080L 269 NOMEXTERN BOOL NOMLINK nomRegisterDLLByName(const HREGDLL hRegisterDLL, const char* chrDLLName) 270 { 271 GSList* lTemp; 272 273 //printf("Trying to register DLL %s\n", chrDLLName); 274 lTemp=hRegisterDLL->dllList; 275 while(lTemp) 276 { 277 qsLrec_t* pModRec; 278 279 pModRec=(qsLrec_t*)lTemp->data; 280 if(pModRec){ 281 // printf("DLL name: %s\n", pModRec->pName); 282 if(pModRec->pName && (NULLHANDLE!=strstr( pModRec->pName, chrDLLName))) 283 { 284 qsLObjrec_t *pObjInfo; 285 //g_message(" --> Found DLL %s", pModRec->pName); 286 pObjInfo=pModRec->pObjInfo; 287 if(NULLHANDLE!=pObjInfo) 288 { 289 int iObj; 290 for(iObj=0; iObj<pModRec->ctObj ;iObj++) 291 { 292 if (!(pObjInfo[iObj].oflags & OBJWRITE)) continue; 293 if (!(pObjInfo[iObj].oflags & OBJREAD)) continue; 294 if ((pObjInfo[iObj].oflags & OBJINVALID)) continue; 295 //g_message(" #%d: %04lX, size: %04lX %04lX", 296 // iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags); 297 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 298 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); 299 } 300 } 301 return TRUE; 302 } 303 } 304 lTemp=g_slist_next(lTemp); 305 };/* while() */ 306 return FALSE; 307 } 308 309 #if 0 139 310 #define BUFSIZE 1024*1024 140 311 NOMEXTERN HREGDLL NOMLINK nomBeginRegisterDLLWithGC(void) … … 166 337 return hReg; 167 338 } 168 169 NOMEXTERN void NOMLINK nomEndRegisterDLLWithGC(const HREGDLL hRegisterDLL )170 {171 free((char*)hRegisterDLL);172 }173 174 175 339 /* 176 340 FIXME: … … 194 358 int a=0; 195 359 196 printf("Trying to register DLL %s\n", chrDLLName);360 //printf("Trying to register DLL %s\n", chrDLLName); 197 361 198 362 p=hRegisterDLL->pProcRec; … … 214 378 { 215 379 qsLObjrec_t *pObjInfo; 216 printf(" --> Found DLL %s\n", pModRec->pName);380 //printf(" --> Found DLL %s\n", pModRec->pName); 217 381 pObjInfo=pModRec->pObjInfo; 218 382 if(NULLHANDLE!=pObjInfo) … … 224 388 if (!(pObjInfo[iObj].oflags & OBJREAD)) continue; 225 389 if ((pObjInfo[iObj].oflags & OBJINVALID)) continue; 226 printf(" #%d: %04lX, size: %04lX %04lX \n",390 printf(" #%d: %04lX, size: %04lX %04lX", 227 391 iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags); 228 392 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 229 393 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); 230 231 394 } 232 395 } … … 251 414 { 252 415 qsLObjrec_t *pObjInfo; 253 printf(" --> Found DLL %s\n", pModImp->pName);416 //printf(" --> Found DLL %s\n", pModImp->pName); 254 417 pObjInfo=pModImp->pObjInfo; 255 418 if(NULLHANDLE!=pObjInfo) … … 262 425 if ((pObjInfo[iObj].oflags & OBJINVALID)) continue; 263 426 264 printf(" #%d: %04lX, size: %04lX %04lX\n",265 iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags);427 //printf(" #%d: %04lX, size: %04lX %04lX\n", 428 // iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags); 266 429 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 267 430 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); … … 280 443 return FALSE; 281 444 } 445 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
