- Timestamp:
- 06/16/11 20:13:33 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfi.h
r253 r258 889 889 * @param fd A file descriptor of an already open file. Must be seekable. 890 890 * 891 * @return A reference to a newly allocated REGFI_FILE structure, if successful;892 * NULL on error. Use regfi_free to free the returned REGFI_FILE.893 *894 * @ingroup regfiBase895 */896 _EXPORT()897 REGFI_FILE* regfi_alloc(int fd, REGFI_ENCODING output_encoding);898 899 900 /** Parses file headers returned by supplied callback functions.901 *902 * This interface is useful if you have a registry hive in memory903 * or have some other reason to emulate a real file.904 *905 * @param file_cb A structure defining the callback functions needed to access the file.906 *907 * @return A reference to a newly allocated REGFI_FILE structure, if successful;908 * NULL on error. Use regfi_free to free the returned REGFI_FILE.909 *910 * @ingroup regfiBase911 */912 _EXPORT()913 REGFI_FILE* regfi_alloc_cb(REGFI_RAW_FILE* file_cb,914 REGFI_ENCODING output_encoding);915 916 917 /** Frees a hive's data structures without closing the underlying file.918 *919 * @param file The registry structure to free.920 *921 * @ingroup regfiBase922 */923 _EXPORT()924 void regfi_free(REGFI_FILE* file);925 926 927 /** Get errors, warnings, and/or verbose information relating to processing of928 * the given registry file.929 *930 * @return A newly allocated char* which must be free()d by the caller.931 *932 * @ingroup regfiBase933 */934 _EXPORT()935 char* regfi_log_get_str();936 937 938 /** Set the verbosity level of messages generated by the library for the939 * current thread.940 *941 * @param mask An integer representing the types of messages desired.942 * Acceptable values are created through bitwise ORs of943 * REGFI_LOG_* values. For instance, if only errors and944 * informational messages were desired (but not warnings),945 * then one would specify: REGFI_LOG_ERROR|REGFI_LOG_INFO946 * By default the message mask is: REGFI_LOG_ERROR|REGFI_LOG_WARN.947 *948 * @return true on success and false on failure. Failure occurs if949 * underlying pthread functions fail. errno is set in this case.950 *951 * Message masks are set in a thread-specific way. If one were to set a message952 * mask in one thread and then spawn a new thread, then the new thread will have953 * it's message mask reset to the default. This function may be called at any954 * time and will take effect immediately for the current thread.955 *956 * @note When a non-zero message mask is set, messages will957 * accumulate in memory without limit if they are not fetched using958 * @ref regfi_get_log_str and subsequently freed by the caller. It is959 * recommended that messsages be fetched after each regfi API call in960 * order to provide the most context.961 *962 * @ingroup regfiBase963 */964 _EXPORT()965 bool regfi_log_set_mask(uint16_t mask);966 967 968 /** Fetches a hive's root key.969 *970 * @return Returns the root key or NULL on failure. Key must be freed using971 * @ref regfi_free_record.972 *973 * @ingroup regfiBase974 */975 _EXPORT()976 const REGFI_NK* regfi_get_rootkey(REGFI_FILE* file);977 978 979 /** Frees a record previously returned by one of the API functions.980 *981 * @param file The file from which the record originated.982 * (This is needed for memory management reasons.)983 *984 * @param record Any of the following record types: REGFI_NK, REGFI_VK,985 * REGFI_SK, REGFI_DATA, and REGFI_CLASSNAME records.986 *987 * @note The "const" in the record data type is a bit misleading and is there just for988 * convenience. Since records returned previously must not be modified by users989 * of the API due to internal caching, these are returned as const, so this990 * function is const to make passing those records back easy.991 *992 * @ingroup regfiBase993 */994 _EXPORT()995 void regfi_free_record(REGFI_FILE* file, const void* record);996 997 998 /** Increments reference count on record999 *1000 * Adds an extra internal reference to specified record, making it necessary to1001 * call regfi_free_record on it an additional time before it is freed. This is1002 * useful in cases where multiple threads/structures need access to a shared record,1003 * without requiring them to be in sync with when it is freed.1004 *1005 * @param file The file from which the record originated.1006 * (This is needed for memory management reasons.)1007 *1008 * @param record Any of the following record types: REGFI_NK, REGFI_VK,1009 * REGFI_SK, REGFI_DATA, and REGFI_CLASSNAME records.1010 *1011 * @return Updated record pointer on success, NULL otherwise1012 *1013 * @note Be sure to use the returned record for further access to the structure1014 * instead of the previous version of the pointer. E.g.:1015 * @code1016 * myKey = (const REGFI_NK*)regfi_reference_record(myFile, myKey);1017 * @endcode1018 *1019 * @ingroup regfiBase1020 */1021 _EXPORT()1022 const void* regfi_reference_record(REGFI_FILE* file, const void* record);1023 1024 1025 /** Retrieves number of subkeys referenced by this key.1026 *1027 * Number of subkeyss in key structure and subkey list structure could differ,1028 * so this provides a standard/sane way of determining the number.1029 *1030 * @param key the key whose number of subkeys is desired1031 *1032 * @return Returns the number of subkeys referenced by this key.1033 *1034 * @ingroup regfiBase1035 */1036 _EXPORT()1037 uint32_t regfi_fetch_num_subkeys(const REGFI_NK* key);1038 1039 1040 /** Retrieves number of values referenced by this key.1041 *1042 * Number of values in key structure and value list structure could differ,1043 * so this provides a standard/sane way of determining the number.1044 *1045 * @param key the key whose number of values is desired1046 *1047 * @return Returns the number of values referenced by this key.1048 *1049 * @ingroup regfiBase1050 */1051 _EXPORT()1052 uint32_t regfi_fetch_num_values(const REGFI_NK* key);1053 1054 1055 /** Retrieves classname for a given key.1056 *1057 * @param file the file from which key is derived1058 * @param key the key whose classname is desired1059 *1060 * @return Returns a newly allocated classname structure, or NULL on failure.1061 * Classname structures must be freed with @ref regfi_free_record.1062 *1063 * @ingroup regfiBase1064 */1065 _EXPORT()1066 const REGFI_CLASSNAME* regfi_fetch_classname(REGFI_FILE* file,1067 const REGFI_NK* key);1068 1069 1070 /** Returns the SK (security) record referenced by the supplied key.1071 *1072 * @param file the file from which key is derived1073 * @param key the key whose SK record is desired1074 *1075 * @return A read-only SK structure, or NULL on failure.1076 *1077 * @ingroup regfiBase1078 */1079 _EXPORT()1080 const REGFI_SK* regfi_fetch_sk(REGFI_FILE* file, const REGFI_NK* key);1081 1082 1083 /** Returns the next SK (security) record referenced by the supplied SK record1084 *1085 * @param file the file from which sk is derived1086 * @param sk the SK record whose next sibling SK record is desired1087 *1088 * @return A read-only SK structure, or NULL on failure.1089 *1090 * @note1091 * SK records are included in a circular, doubly-linked list.1092 * To iterate over all SK records, be sure to check for the repetition of1093 * the SK record you started with to determine when all have been traversed.1094 *1095 * @ingroup regfiBase1096 */1097 _EXPORT()1098 const REGFI_SK* regfi_next_sk(REGFI_FILE* file, const REGFI_SK* sk);1099 1100 1101 /** Returns the previous SK (security) record referenced by the supplied SK record1102 *1103 * @param file the file from which sk is derived1104 * @param sk the SK record whose previous sibling SK record is desired1105 *1106 * @return A read-only SK structure, or NULL on failure.1107 *1108 * @note1109 * SK records are included in a circular, doubly-linked list.1110 * To iterate over all SK records, be sure to check for the repetition of1111 * the SK record you started with to determine when all have been traversed.1112 *1113 * @ingroup regfiBase1114 */1115 _EXPORT()1116 const REGFI_SK* regfi_prev_sk(REGFI_FILE* file, const REGFI_SK* sk);1117 1118 1119 /** Retrieves data for a given value.1120 *1121 * @param file the file from which value is derived1122 * @param value the value whose data is desired1123 *1124 * @return Returns a newly allocated data structure, or NULL on failure.1125 * Data structures must be freed with @ref regfi_free_record.1126 *1127 * @ingroup regfiBase1128 */1129 _EXPORT()1130 const REGFI_DATA* regfi_fetch_data(REGFI_FILE* file,1131 const REGFI_VK* value);1132 1133 1134 /** Locates a specific subkey of a given key.1135 *1136 * @param file the file from which key is derived1137 * @param key the key whose subkey is desired1138 * @param name name of the desired subkey1139 * @param index a return value: the index of the desired subkey.1140 * undefined on error1141 *1142 * @return true if the subkey is found, false if an error occurred or if the1143 * specified name could not be found. If an error occurs, messages1144 * will be written explaining the issue. (See regfi_log_get_str.)1145 *1146 * @ingroup regfiBase1147 */1148 _EXPORT()1149 bool regfi_find_subkey(REGFI_FILE* file, const REGFI_NK* key,1150 const char* name, uint32_t* index);1151 1152 1153 /** Locates a specific value of a given key.1154 *1155 * @param file the file from which key is derived1156 * @param key the key whose value is desired1157 * @param name name of the desired value1158 * @param index a return value: the index of the desired value.1159 * undefined on error1160 *1161 * @return true if the value is found, false if an error occurred or if the1162 * specified name could not be found. If an error occurs, messages1163 * will be written explaining the issue. (See regfi_log_get_str.)1164 *1165 * @ingroup regfiBase1166 */1167 _EXPORT()1168 bool regfi_find_value(REGFI_FILE* file, const REGFI_NK* key,1169 const char* name, uint32_t* index);1170 1171 1172 /** Retrieves a specific subkey of a given key.1173 *1174 * @param file the file from which key is derived1175 * @param key the key whose subkey is desired1176 * @param index the index of the desired subkey1177 *1178 * @return the requested subkey or NULL on error.1179 *1180 * @ingroup regfiBase1181 */1182 _EXPORT()1183 const REGFI_NK* regfi_get_subkey(REGFI_FILE* file, const REGFI_NK* key,1184 uint32_t index);1185 1186 1187 /** Retrieves a specific value of a given key.1188 *1189 * @param file the file from which key is derived1190 * @param key the key whose value is desired1191 * @param index the index of the desired value1192 *1193 * @return the requested value or NULL on error.1194 *1195 * @ingroup regfiBase1196 */1197 _EXPORT()1198 const REGFI_VK* regfi_get_value(REGFI_FILE* file, const REGFI_NK* key,1199 uint32_t index);1200 1201 1202 1203 /** Uses a key's parent_off reference to retrieve it's parent.1204 *1205 * @param file the file from which key is derived1206 * @param key the key whose parent is desired1207 *1208 * @return the requested subkey or NULL on error.1209 *1210 * @ingroup regfiBase1211 */1212 _EXPORT()1213 const REGFI_NK* regfi_get_parentkey(REGFI_FILE* file, const REGFI_NK* key);1214 1215 1216 /******************************************************************************/1217 /**1218 * @defgroup regfiIteratorLayer Iterator Layer: Primary regfi Library Interface1219 *1220 * This top layer of API functions provides an iterator interface which makes1221 * traversing registry data structures easy in both single-threaded and1222 * multi-threaded scenarios.1223 */1224 /******************************************************************************/1225 1226 /** Creates a new iterator for the provided registry file.1227 *1228 * @param file The opened registry file the iterator should be created for.1229 *1230 891 * @param output_encoding Character encoding that strings should be returned in. 1231 892 * Only supply the REGFI_ENCODING_* constants, as others … … 1236 897 * REGFI_ENCODING_UTF8 1237 898 * 899 * @return A reference to a newly allocated REGFI_FILE structure, if successful; 900 * NULL on error. Use regfi_free to free the returned REGFI_FILE. 901 * 902 * @ingroup regfiBase 903 */ 904 _EXPORT() 905 REGFI_FILE* regfi_alloc(int fd, REGFI_ENCODING output_encoding); 906 907 908 /** Parses file headers returned by supplied callback functions. 909 * 910 * This interface is useful if you have a registry hive in memory 911 * or have some other reason to emulate a real file. 912 * 913 * @param file_cb A structure defining the callback functions needed to access the file. 914 * 915 * @param output_encoding Character encoding that strings should be returned in. 916 * Only supply the REGFI_ENCODING_* constants, as others 917 * will be rejected. 918 * The following values are currently accepted: 919 * REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII) 920 * REGFI_ENCODING_ASCII 921 * REGFI_ENCODING_UTF8 922 * 923 * @return A reference to a newly allocated REGFI_FILE structure, if successful; 924 * NULL on error. Use regfi_free to free the returned REGFI_FILE. 925 * 926 * @ingroup regfiBase 927 */ 928 _EXPORT() 929 REGFI_FILE* regfi_alloc_cb(REGFI_RAW_FILE* file_cb, 930 REGFI_ENCODING output_encoding); 931 932 933 /** Frees a hive's data structures without closing the underlying file. 934 * 935 * @param file The registry structure to free. 936 * 937 * @ingroup regfiBase 938 */ 939 _EXPORT() 940 void regfi_free(REGFI_FILE* file); 941 942 943 /** Get errors, warnings, and/or verbose information relating to processing of 944 * the given registry file. 945 * 946 * @return A newly allocated char* which must be free()d by the caller. 947 * 948 * @ingroup regfiBase 949 */ 950 _EXPORT() 951 char* regfi_log_get_str(); 952 953 954 /** Set the verbosity level of messages generated by the library for the 955 * current thread. 956 * 957 * @param mask An integer representing the types of messages desired. 958 * Acceptable values are created through bitwise ORs of 959 * REGFI_LOG_* values. For instance, if only errors and 960 * informational messages were desired (but not warnings), 961 * then one would specify: REGFI_LOG_ERROR|REGFI_LOG_INFO 962 * By default the message mask is: REGFI_LOG_ERROR|REGFI_LOG_WARN. 963 * 964 * @return true on success and false on failure. Failure occurs if 965 * underlying pthread functions fail. errno is set in this case. 966 * 967 * Message masks are set in a thread-specific way. If one were to set a message 968 * mask in one thread and then spawn a new thread, then the new thread will have 969 * it's message mask reset to the default. This function may be called at any 970 * time and will take effect immediately for the current thread. 971 * 972 * @note When a non-zero message mask is set, messages will 973 * accumulate in memory without limit if they are not fetched using 974 * @ref regfi_log_get_str and subsequently freed by the caller. It is 975 * recommended that messsages be fetched after each regfi API call in 976 * order to provide the most context. 977 * 978 * @ingroup regfiBase 979 */ 980 _EXPORT() 981 bool regfi_log_set_mask(uint16_t mask); 982 983 984 /** Fetches a hive's root key. 985 * 986 * @return Returns the root key or NULL on failure. Key must be freed using 987 * @ref regfi_free_record. 988 * 989 * @ingroup regfiBase 990 */ 991 _EXPORT() 992 const REGFI_NK* regfi_get_rootkey(REGFI_FILE* file); 993 994 995 /** Frees a record previously returned by one of the API functions. 996 * 997 * @param file The file from which the record originated. 998 * (This is needed for memory management reasons.) 999 * 1000 * @param record Any of the following record types: REGFI_NK, REGFI_VK, 1001 * REGFI_SK, REGFI_DATA, and REGFI_CLASSNAME records. 1002 * 1003 * @note The "const" in the record data type is a bit misleading and is there just for 1004 * convenience. Since records returned previously must not be modified by users 1005 * of the API due to internal caching, these are returned as const, so this 1006 * function is const to make passing those records back easy. 1007 * 1008 * @ingroup regfiBase 1009 */ 1010 _EXPORT() 1011 void regfi_free_record(REGFI_FILE* file, const void* record); 1012 1013 1014 /** Increments reference count on record 1015 * 1016 * Adds an extra internal reference to specified record, making it necessary to 1017 * call regfi_free_record on it an additional time before it is freed. This is 1018 * useful in cases where multiple threads/structures need access to a shared record, 1019 * without requiring them to be in sync with when it is freed. 1020 * 1021 * @param file The file from which the record originated. 1022 * (This is needed for memory management reasons.) 1023 * 1024 * @param record Any of the following record types: REGFI_NK, REGFI_VK, 1025 * REGFI_SK, REGFI_DATA, and REGFI_CLASSNAME records. 1026 * 1027 * @return Updated record pointer on success, NULL otherwise 1028 * 1029 * @note Be sure to use the returned record for further access to the structure 1030 * instead of the previous version of the pointer. E.g.: 1031 * @code 1032 * myKey = (const REGFI_NK*)regfi_reference_record(myFile, myKey); 1033 * @endcode 1034 * 1035 * @ingroup regfiBase 1036 */ 1037 _EXPORT() 1038 const void* regfi_reference_record(REGFI_FILE* file, const void* record); 1039 1040 1041 /** Retrieves number of subkeys referenced by this key. 1042 * 1043 * Number of subkeyss in key structure and subkey list structure could differ, 1044 * so this provides a standard/sane way of determining the number. 1045 * 1046 * @param key the key whose number of subkeys is desired 1047 * 1048 * @return Returns the number of subkeys referenced by this key. 1049 * 1050 * @ingroup regfiBase 1051 */ 1052 _EXPORT() 1053 uint32_t regfi_fetch_num_subkeys(const REGFI_NK* key); 1054 1055 1056 /** Retrieves number of values referenced by this key. 1057 * 1058 * Number of values in key structure and value list structure could differ, 1059 * so this provides a standard/sane way of determining the number. 1060 * 1061 * @param key the key whose number of values is desired 1062 * 1063 * @return Returns the number of values referenced by this key. 1064 * 1065 * @ingroup regfiBase 1066 */ 1067 _EXPORT() 1068 uint32_t regfi_fetch_num_values(const REGFI_NK* key); 1069 1070 1071 /** Retrieves classname for a given key. 1072 * 1073 * @param file the file from which key is derived 1074 * @param key the key whose classname is desired 1075 * 1076 * @return Returns a newly allocated classname structure, or NULL on failure. 1077 * Classname structures must be freed with @ref regfi_free_record. 1078 * 1079 * @ingroup regfiBase 1080 */ 1081 _EXPORT() 1082 const REGFI_CLASSNAME* regfi_fetch_classname(REGFI_FILE* file, 1083 const REGFI_NK* key); 1084 1085 1086 /** Returns the SK (security) record referenced by the supplied key. 1087 * 1088 * @param file the file from which key is derived 1089 * @param key the key whose SK record is desired 1090 * 1091 * @return A read-only SK structure, or NULL on failure. 1092 * 1093 * @ingroup regfiBase 1094 */ 1095 _EXPORT() 1096 const REGFI_SK* regfi_fetch_sk(REGFI_FILE* file, const REGFI_NK* key); 1097 1098 1099 /** Returns the next SK (security) record referenced by the supplied SK record 1100 * 1101 * @param file the file from which sk is derived 1102 * @param sk the SK record whose next sibling SK record is desired 1103 * 1104 * @return A read-only SK structure, or NULL on failure. 1105 * 1106 * @note 1107 * SK records are included in a circular, doubly-linked list. 1108 * To iterate over all SK records, be sure to check for the repetition of 1109 * the SK record you started with to determine when all have been traversed. 1110 * 1111 * @ingroup regfiBase 1112 */ 1113 _EXPORT() 1114 const REGFI_SK* regfi_next_sk(REGFI_FILE* file, const REGFI_SK* sk); 1115 1116 1117 /** Returns the previous SK (security) record referenced by the supplied SK record 1118 * 1119 * @param file the file from which sk is derived 1120 * @param sk the SK record whose previous sibling SK record is desired 1121 * 1122 * @return A read-only SK structure, or NULL on failure. 1123 * 1124 * @note 1125 * SK records are included in a circular, doubly-linked list. 1126 * To iterate over all SK records, be sure to check for the repetition of 1127 * the SK record you started with to determine when all have been traversed. 1128 * 1129 * @ingroup regfiBase 1130 */ 1131 _EXPORT() 1132 const REGFI_SK* regfi_prev_sk(REGFI_FILE* file, const REGFI_SK* sk); 1133 1134 1135 /** Retrieves data for a given value. 1136 * 1137 * @param file the file from which value is derived 1138 * @param value the value whose data is desired 1139 * 1140 * @return Returns a newly allocated data structure, or NULL on failure. 1141 * Data structures must be freed with @ref regfi_free_record. 1142 * 1143 * @ingroup regfiBase 1144 */ 1145 _EXPORT() 1146 const REGFI_DATA* regfi_fetch_data(REGFI_FILE* file, 1147 const REGFI_VK* value); 1148 1149 1150 /** Locates a specific subkey of a given key. 1151 * 1152 * @param file the file from which key is derived 1153 * @param key the key whose subkey is desired 1154 * @param name name of the desired subkey 1155 * @param index a return value: the index of the desired subkey. 1156 * undefined on error 1157 * 1158 * @return true if the subkey is found, false if an error occurred or if the 1159 * specified name could not be found. If an error occurs, messages 1160 * will be written explaining the issue. (See regfi_log_get_str.) 1161 * 1162 * @ingroup regfiBase 1163 */ 1164 _EXPORT() 1165 bool regfi_find_subkey(REGFI_FILE* file, const REGFI_NK* key, 1166 const char* name, uint32_t* index); 1167 1168 1169 /** Locates a specific value of a given key. 1170 * 1171 * @param file the file from which key is derived 1172 * @param key the key whose value is desired 1173 * @param name name of the desired value 1174 * @param index a return value: the index of the desired value. 1175 * undefined on error 1176 * 1177 * @return true if the value is found, false if an error occurred or if the 1178 * specified name could not be found. If an error occurs, messages 1179 * will be written explaining the issue. (See regfi_log_get_str.) 1180 * 1181 * @ingroup regfiBase 1182 */ 1183 _EXPORT() 1184 bool regfi_find_value(REGFI_FILE* file, const REGFI_NK* key, 1185 const char* name, uint32_t* index); 1186 1187 1188 /** Retrieves a specific subkey of a given key. 1189 * 1190 * @param file the file from which key is derived 1191 * @param key the key whose subkey is desired 1192 * @param index the index of the desired subkey 1193 * 1194 * @return the requested subkey or NULL on error. 1195 * 1196 * @ingroup regfiBase 1197 */ 1198 _EXPORT() 1199 const REGFI_NK* regfi_get_subkey(REGFI_FILE* file, const REGFI_NK* key, 1200 uint32_t index); 1201 1202 1203 /** Retrieves a specific value of a given key. 1204 * 1205 * @param file the file from which key is derived 1206 * @param key the key whose value is desired 1207 * @param index the index of the desired value 1208 * 1209 * @return the requested value or NULL on error. 1210 * 1211 * @ingroup regfiBase 1212 */ 1213 _EXPORT() 1214 const REGFI_VK* regfi_get_value(REGFI_FILE* file, const REGFI_NK* key, 1215 uint32_t index); 1216 1217 1218 1219 /** Uses a key's parent_off reference to retrieve it's parent. 1220 * 1221 * @param file the file from which key is derived 1222 * @param key the key whose parent is desired 1223 * 1224 * @return the requested subkey or NULL on error. 1225 * 1226 * @ingroup regfiBase 1227 */ 1228 _EXPORT() 1229 const REGFI_NK* regfi_get_parentkey(REGFI_FILE* file, const REGFI_NK* key); 1230 1231 1232 /******************************************************************************/ 1233 /** 1234 * @defgroup regfiIteratorLayer Iterator Layer: Primary regfi Library Interface 1235 * 1236 * This top layer of API functions provides an iterator interface which makes 1237 * traversing registry data structures easy in both single-threaded and 1238 * multi-threaded scenarios. 1239 */ 1240 /******************************************************************************/ 1241 1242 /** Creates a new iterator for the provided registry file. 1243 * 1244 * @param file The opened registry file the iterator should be created for. 1245 * 1238 1246 * @return A newly allocated REGFI_ITERATOR. 1239 1247 * Must be free()d with regfi_iterator_free. … … 1487 1495 _EXPORT() 1488 1496 REGFI_VK* regfi_load_value(REGFI_FILE* file, uint32_t offset, 1489 1490 1497 REGFI_ENCODING output_encoding, 1498 bool strict); 1491 1499 1492 1500
Note: See TracChangeset
for help on using the changeset viewer.