1 | /*␊ |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | *␊ |
6 | * Portions Copyright (c) 2003 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 2.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 | #ifndef __LIBSAIO_XML_H␊ |
26 | #define __LIBSAIO_XML_H␊ |
27 | ␊ |
28 | enum xmltype {␊ |
29 | ␉kTagTypeNone = 0,␊ |
30 | ␉kTagTypeDict,␊ |
31 | ␉kTagTypeKey,␊ |
32 | ␉kTagTypeString,␊ |
33 | ␉kTagTypeInteger,␊ |
34 | ␉kTagTypeData,␊ |
35 | ␉kTagTypeDate,␊ |
36 | ␉kTagTypeFalse,␊ |
37 | ␉kTagTypeTrue,␊ |
38 | ␉kTagTypeArray␊ |
39 | };␊ |
40 | ␊ |
41 | struct string_ref␊ |
42 | {␊ |
43 | ␉char *string;␊ |
44 | ␉int id;␊ |
45 | ␉struct string_ref *next;␊ |
46 | };␊ |
47 | typedef struct string_ref string_ref;␊ |
48 | ␊ |
49 | extern string_ref *ref_strings;␊ |
50 | ␊ |
51 | #define kXMLTagPList "plist "␊ |
52 | #define kXMLTagDict "dict"␊ |
53 | #define kXMLTagKey "key"␊ |
54 | #define kXMLTagString "string"␊ |
55 | #define kXMLTagInteger "integer"␊ |
56 | #define kXMLTagData "data"␊ |
57 | #define kXMLTagDate "date"␊ |
58 | #define kXMLTagFalse "false/"␊ |
59 | #define kXMLTagTrue "true/"␊ |
60 | #define kXMLTagArray "array"␊ |
61 | // for back-references used by libkern serializer␊ |
62 | #define kXMLTagReference "reference"␊ |
63 | #define kXMLStringID "ID="␊ |
64 | #define kXMLStringIDRef "IDREF="␊ |
65 | #define kXMLStringIDRefs "IDREFS="␊ |
66 | #define kXMLTagSIZE "size="␊ |
67 | ␊ |
68 | #define kPropCFBundleIdentifier␉␉("CFBundleIdentifier")␊ |
69 | #define kPropCFBundleExecutable␉␉("CFBundleExecutable")␊ |
70 | #define kPropOSBundleRequired␉␉("OSBundleRequired")␊ |
71 | #define kPropOSBundleLibraries␉␉("OSBundleLibraries")␊ |
72 | #define kPropIOKitPersonalities␉␉("IOKitPersonalities")␊ |
73 | #define kPropIONameMatch␉␉("IONameMatch")␊ |
74 | ␊ |
75 | // Micky1979␊ |
76 | // kXMLv1 require one argument␊ |
77 | ␊ |
78 | #define kXMLv1 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\␊ |
79 | <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n\␊ |
80 | <plist version=\"1.0\">\n\␊ |
81 | <dict>\n%s\n\␊ |
82 | </dict>\n\␊ |
83 | </plist>"␊ |
84 | ␊ |
85 | // Micky1979␊ |
86 | // kFakeInjectorKext require 4 arguments (a generic name (used twice) + IOKitPersonalities + OSBundleRequired ("" if not needed)):␊ |
87 | // name, name, IOKitPersonalities, OSBundleRequired␊ |
88 | #define kFakeInjectorKext "<\?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\␊ |
89 | <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n\␊ |
90 | <plist version=\"1.0\">\n\␊ |
91 | <dict>\n\␊ |
92 | ␉<key>CFBundleDevelopmentRegion</key>\n\␊ |
93 | ␉<string>English</string>\n\␊ |
94 | ␉<key>CFBundleIdentifier</key>\n\␊ |
95 | ␉<string>com.Enoch.plist.%s</string>\n\␊ |
96 | ␉<key>CFBundleInfoDictionaryVersion</key>\n\␊ |
97 | ␉<string>6.0</string>\n\␊ |
98 | ␉<key>CFBundleName</key>\n\␊ |
99 | ␉<string>%s</string>\n\␊ |
100 | ␉<key>CFBundlePackageType</key>\n\␊ |
101 | ␉<string>KEXT</string>\n\␊ |
102 | ␉<key>CFBundleSignature</key>\n\␊ |
103 | ␉<string>\?\?\?\?</string>\n\␊ |
104 | ␉<key>CFBundleVersion</key>\n\␊ |
105 | ␉<string>1.0.0</string>\n\␊ |
106 | ␉<key>IOKitPersonalities</key>\n\␊ |
107 | ␉<dict>\n%s\␊ |
108 | ␉</dict>\n%s\␊ |
109 | </dict>\n\␊ |
110 | </plist>\n"␊ |
111 | ␊ |
112 | // Micky1979 following 3 funtions are to convert a TagPtr to a property list v1 and to create kexts injector␊ |
113 | char *XMLConvertTagPtrToXMLString(TagPtr aDict, long parentType, int indent);␊ |
114 | char *XMLConvertTagPtrToPropertyList_v1(TagPtr aDict);␊ |
115 | char *XMLGenerateKextInjectorFromTag(TagPtr aDict, char *personalityName, char *OSBundleRequired);␊ |
116 | ␊ |
117 | extern long gImageFirstBootXAddr;␊ |
118 | extern long gImageLastKernelAddr;␊ |
119 | ␊ |
120 | TagPtr XMLGetProperty( TagPtr dict, const char *key );␊ |
121 | TagPtr XMLGetElement( TagPtr dict, int id );␊ |
122 | TagPtr XMLGetKey( TagPtr dict, int id );␊ |
123 | TagPtr XMLGetValueForKey(TagPtr key);␊ |
124 | ␊ |
125 | int XMLTagCount( TagPtr dict );␊ |
126 | ␊ |
127 | bool XMLIsType(TagPtr dict, enum xmltype type);␊ |
128 | ␊ |
129 | bool XMLCastBoolean( TagPtr dict );␊ |
130 | char *XMLCastString( TagPtr dict );␊ |
131 | long XMLCastStringOffset(TagPtr dict);␊ |
132 | int XMLCastInteger ( TagPtr dict );␊ |
133 | TagPtr XMLCastDict ( TagPtr dict );␊ |
134 | TagPtr XMLCastArray( TagPtr dict );␊ |
135 | char *XMLCastData( TagPtr dict, int *length );␊ |
136 | ␊ |
137 | bool XMLIsBoolean(TagPtr entry);␊ |
138 | bool XMLIsString (TagPtr entry);␊ |
139 | bool XMLIsInteger(TagPtr entry);␊ |
140 | bool XMLIsDict (TagPtr entry);␊ |
141 | bool XMLIsArray (TagPtr entry);␊ |
142 | bool XMLIsData (TagPtr entry);␊ |
143 | ␊ |
144 | ␊ |
145 | bool XMLAddTagToDictionary(TagPtr dict, char *key, TagPtr value);␊ |
146 | ␊ |
147 | long XMLParseNextTag(char *buffer, TagPtr *tag);␊ |
148 | void XMLFreeTag(TagPtr tag);␊ |
149 | char *XMLDecode(const char *in);␊ |
150 | //==========================================================================␊ |
151 | // XMLParseFile␊ |
152 | // Expects to see one dictionary in the XML file.␊ |
153 | // Puts the first dictionary it finds in the␊ |
154 | // tag pointer and returns 0, or returns -1 if not found.␊ |
155 | //␊ |
156 | long XMLParseFile( char *buffer, TagPtr *dict );␊ |
157 | ␊ |
158 | //==========================================================================␊ |
159 | // ParseTag*␊ |
160 | long ParseTagBoolean( char *buffer, TagPtr *tag, long type );␊ |
161 | ␊ |
162 | #endif /* __LIBSAIO_XML_H */␊ |
163 | |