aboutsummaryrefslogtreecommitdiff
path: root/lib/substitute.h
diff options
context:
space:
mode:
authorcomex2015-01-10 16:04:32 -0500
committercomex2015-01-10 16:04:32 -0500
commit19a538132d5f5d1a13b51bb7e909f525da791220 (patch)
tree8523033f1366c0a9754593bc0505360a7bf22c18 /lib/substitute.h
parentsimplify (diff)
downloadsubstitute-19a538132d5f5d1a13b51bb7e909f525da791220.tar.gz
private syms starting to look good
Diffstat (limited to 'lib/substitute.h')
-rw-r--r--lib/substitute.h44
1 files changed, 38 insertions, 6 deletions
diff --git a/lib/substitute.h b/lib/substitute.h
index d4287fb..20dc020 100644
--- a/lib/substitute.h
+++ b/lib/substitute.h
@@ -6,12 +6,11 @@
#pragma once
#include <stdlib.h>
+#include <stdint.h>
// TODO add numbers
enum {
SUBSTITUTE_OK = 0,
-
- SUBSTITUTE_ERR_MODULE_NOT_FOUND,
};
int substitute_hook_function(void *function, void *replacement, int options, void *result);
@@ -29,18 +28,51 @@ typedef struct nlist substitute_sym;
#error No definition for substitute_sym!
#endif
-/* Look up private symbols in an image currently loaded into the process.
+struct substitute_image {
+#ifdef __APPLE__
+ intptr_t slide;
+ void *dlhandle;
+ const void *image_header;
+#endif
+ /* possibly private fields... */
+};
+
+/* Look up an image currently loaded into the process.
*
* @filename the executable/library path (c.f. dyld(3) on Darwin)
+ * @return a handle, or NULL if the image wasn't found
+ */
+
+struct substitute_image *substitute_open_image(const char *filename);
+
+/* Release a handle opened with substitute_open_image.
+ *
+ * @handle a banana
+ */
+void substitute_close_image(struct substitute_image *handle);
+
+/* Look up private symbols in an image currently loaded into the process.
+ *
+ * @handle handle opened with substitute_open_image
* @names an array of symbol names to search for
* @nlist an array of substitute_sym *, one per name; on return, each entry
* will be a pointer into the symbol table for that image, or NULL if the
* symbol wasn't found
* @count number of names
*
- * @return SUBSTITUTE_OK or SUBSTITUTE_ERR_MODULE_NOT_FOUND
+ * @return SUBSTITUTE_OK (maybe errors in the future)
+ */
+int substitute_find_private_syms(struct substitute_image *handle,
+ const char **names,
+ substitute_sym **syms,
+ size_t count);
+
+/* Get a pointer corresponding to a loaded symbol table entry.
+ * @handle handle containing the symbol
+ * @sym symbol
+ * @return the pointer - on ARM, this can be | 1 for Thumb, like everything
+ * else
*/
-int substitute_find_syms(const char *filename, const char **names,
- substitute_sym **syms, size_t count);
+void *substitute_sym_to_ptr(struct substitute_image *handle, substitute_sym *sym);
#endif /* 1 */