|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.0 (the 'License'). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License."
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: #import <objc/Storage.h>
26: #import <objc/List.h>
27: #import <objc/HashTable.h>
28: #import <objc/objc-runtime.h>
29:
30:
31: #import <sys/file.h>
32: #import <string.h>
33: #import <sys/loader.h>
34: #import <sys/table.h>
35: #import <sys/types.h>
36: #import <sys/stat.h>
37: #import <ldsyms.h>
38: #import <mach.h>
39: #import <stdlib.h>
40:
41: #import "RegionManager.h"
42: #import "ObjcProcess.h"
43: #import "ObjcImage.h"
44: #import <sys/loader.h>
45:
46: struct section *getsectbynamefromheader(struct mach_header *, char *, char *);
47: int table(int, int, void *, int, int);
48: int open(const char *, int, ...);
49: int close(int);
50: kern_return_t map_fd(int, vm_offset_t, vm_offset_t *, boolean_t, vm_size_t);
51:
52: @implementation ObjcProcess
53:
54:
55: + newFromTask:(vm_task_t)task
56: {
57: struct mach_headers **machhdrs;
58:
59: self = [super new];
60: regionManager = [RegionManager newTask:task];
61: imageList = [List new];
62:
63: machhdrs = [regionManager getMachHeaders];
64: while (*machhdrs) {
65: id image = [ObjcImage newFromHeader:*machhdrs];
66: [[image regionManager:regionManager] getModules];
67: [imageList addObject:image];
68: machhdrs++;
69: }
70: return self;
71: }
72:
73:
74: #if 0
75:
76: -(List *)getClasses
77: {
78: struct objc_symtab *memSymtab;
79: struct objc_module *memModules, *memModule, *endOfModules;
80: struct mach_header *memHeader;
81: int numClass, headerIndex;
82: Class memClass, memMetaClass;
83: List *orphans;
84: int memSize;
85: orphans = [List new];
86: for (headerIndex = 0; headerIndex < machhdrs[headerIndex]; headerIndex++) {
87:
88: memHeader = machhdrs[headerIndex];
89:
90: memModules = [regionManager
91: getSectData: SEG_OBJC
92: section: SECT_OBJC_MODULES
93: size: &memSize
94: forHeader: memHeader];
95:
96: endOfModules = (struct objc_module *)((char *)memModules + memSize);
97: for ( memModule = memModules;
98: memModule < endOfModules;
99: memModule = (struct objc_module *)((STR)memModule + memModule->size)) {
100: if (memSymtab = WARP(memModule->symtab)) {
101: for (numClass = 0; numClass < memSymtab->cls_def_cnt; numClass++) {
102: if (memClass = WARP(memSymtab->defs[numClass])) {
103: [self adopt: orphans with: memClass];
104: }
105: }
106: }
107: }
108: }
109: return orphans;
110: }
111:
112: #endif
113:
114:
115: @end
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.