summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/perk/perk.h112
1 files changed, 99 insertions, 13 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index eb0a546..ca51be4 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -22,19 +22,33 @@ extern "C" {
#endif
#endif
-/* exec flags */
-#define PERK_HELP 0x01
-
-/* errors */
-#define PERK_OK 0x00
-#define PERK_BAD_OPT 0xA1
-#define PERK_BAD_OPT_VAL 0xA2
-#define PERK_IO_ERROR 0xA3
-#define PERK_MAP_ERROR 0xA4
-#define PERK_BAD_DOS_HEADER 0xA5
-#define PERK_BAD_COFF_HEADER 0xA6
-#define PERK_BAD_IMAGE_TYPE 0xA7
-#define PERK_MALFORMED_IMAGE 0xA8
+/* status codes */
+#define PERK_OK 0x00
+#define PERK_USAGE 0x01
+#define PERK_BAD_OPT 0x02
+#define PERK_BAD_OPT_VAL 0x03
+#define PERK_IO_ERROR 0xA0
+#define PERK_MAP_ERROR 0xA1
+#define PERK_BAD_DOS_HEADER 0xA2
+#define PERK_BAD_COFF_HEADER 0xA3
+#define PERK_BAD_IMAGE_TYPE 0xA4
+#define PERK_MALFORMED_IMAGE 0xA5
+
+/* driver flags */
+#define PERK_DRIVER_VERBOSITY_NONE 0x0000
+#define PERK_DRIVER_VERBOSITY_ERRORS 0x0001
+#define PERK_DRIVER_VERBOSITY_STATUS 0x0002
+#define PERK_DRIVER_VERBOSITY_USAGE 0x0004
+#define PERK_DRIVER_CLONE_VECTOR 0x0008
+
+#define PERK_DRIVER_FLAG_VERSION 0x0010
+#define PERK_DRIVER_FLAG_DRY_RUN 0x0020
+
+/* unit action flags */
+#define PERK_ACTION_FLAG_MAP_READWRITE 0x0001
+
+/* unit (text) output & format flags */
+#define PERK_OUTPUT_FLAG_EXPORT_SYMS 0x0001
struct pe_raw_image {
void * addr;
@@ -70,6 +84,78 @@ struct pe_image_meta {
struct pe_meta_sec_hdr * hidata;
};
+struct pe_symbol_ctx {
+ uint32_t size;
+ uint32_t version;
+ const char ** append;
+ const char ** exclude;
+};
+
+struct pe_output_ctx {
+ uint32_t size;
+ uint32_t version;
+ const char * header;
+ const char * footer;
+};
+
+struct pe_linker_ctx {
+ uint32_t size;
+ uint32_t version;
+};
+
+struct pe_server_ctx {
+ uint32_t size;
+ uint32_t version;
+};
+
+struct pe_common_ctx {
+ uint32_t size;
+ uint32_t version;
+ int fdin;
+ int fdout;
+ int fderr;
+ int fdlog;
+ int fdsrc;
+ int fddst;
+ int fdtmp;
+ int prot;
+ int mode;
+ int status;
+ uint64_t drvflags;
+ uint64_t actflags;
+ uint64_t fmtflags;
+ uint64_t lnkflags;
+ const char * output;
+ const char * srcdir;
+ const char * dstdir;
+ const char * tmpdir;
+ struct pe_symbol_ctx * symctx;
+ struct pe_output_ctx * outctx;
+ struct pe_linker_ctx * lnkctx;
+ struct pe_server_ctx * srvctx;
+};
+
+struct pe_driver_ctx {
+ const char ** units;
+ const char * program;
+ const char * module;
+ struct pe_common_ctx cctx;
+};
+
+struct pe_unit_ctx {
+ const char * path;
+ struct pe_raw_image map;
+ struct pe_image_meta * meta;
+ struct pe_common_ctx cctx;
+};
+
+/* driver api */
+perk_api int pe_get_driver_ctx (const char ** argv, const char ** envp, uint32_t flags, struct pe_driver_ctx **);
+perk_api int pe_free_driver_ctx (struct pe_driver_ctx *);
+
+perk_api int pe_get_unit_ctx (struct pe_driver_ctx *, const char * name, struct pe_unit_ctx **);
+perk_api int pe_free_unit_ctx (struct pe_unit_ctx *);
+
/* utility api */
perk_api int pe_output_export_symbols (const struct pe_image_meta *, uint32_t flags, FILE *);