00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _CINVOKE_H
00029 #define _CINVOKE_H
00030
00031 #include "cinvoke-arch.h"
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036
00114 typedef struct _CInvLibrary {
00115 ArchLibrary arch;
00116 } CInvLibrary;
00117
00118 typedef struct _CInvFunction {
00119 cinv_callconv_t callconv;
00120 int hasreturn;
00121 cinv_type_t rettype;
00122 int numparms;
00123 int *parmstacksizes;
00124 int *parmalignments;
00125 int *parmmemsizes;
00126 cinv_type_t *parmtypes;
00127 short stacksize;
00128 } CInvFunction;
00129
00139 typedef void (*cinv_cbfunc_t)(CInvFunction *f, void *parameters[],
00140 void *returnout, void *userdata);
00141
00142 struct _CInvStructure;
00143 struct hashtable;
00144
00145 typedef struct _CInvStructMember {
00146 struct _CInvStructure *structtype;
00147 cinv_type_t type;
00148 int offset;
00149 int alignment;
00150 } CInvStructMember;
00151
00152 typedef struct _CInvStructure {
00153 struct hashtable *members;
00154 CInvStructMember *firstmember;
00155 int nextoffset;
00156 int finished;
00157 } CInvStructure;
00158
00159 typedef struct _CInvCallback {
00160 CInvFunction *prototype;
00161 void *userdata;
00162 cinv_cbfunc_t cbfunc;
00163 char *stub;
00164 } CInvCallback;
00165
00167
00169
00172 CInvContext *cinv_context_create();
00178 const char *cinv_context_geterrormsg(CInvContext *context);
00185 cinv_int32_t cinv_context_geterrorcode(CInvContext *context);
00190 cinv_status_t cinv_context_delete(CInvContext *context);
00191
00199 CInvLibrary *cinv_library_create(CInvContext *context, const char *path);
00206 void *cinv_library_load_entrypoint(CInvContext *context,
00207 CInvLibrary *library, const char *name);
00213 cinv_status_t cinv_library_delete(CInvContext *context, CInvLibrary *library);
00214
00252 CInvFunction *cinv_function_create(CInvContext *context,
00253 cinv_callconv_t callingconvention, const char *returnformat,
00254 const char *parameterformat);
00273 cinv_status_t cinv_function_invoke(CInvContext *context,
00274 CInvFunction *function, void *entrypoint, void *returnvalout,
00275 void *parameters[]);
00281 cinv_status_t cinv_function_delete(CInvContext *context,
00282 CInvFunction *function);
00283
00288 CInvStructure *cinv_structure_create(CInvContext *context);
00296 cinv_status_t cinv_structure_addmember_value(CInvContext *context,
00297 CInvStructure *structure, const char *name, cinv_type_t type);
00308 cinv_status_t cinv_structure_addmember_struct(CInvContext *context,
00309 CInvStructure *structure, const char *name, CInvStructure *type);
00316 cinv_status_t cinv_structure_finish(CInvContext *context,
00317 CInvStructure *structure);
00325 cinv_status_t cinv_structure_getsize(CInvContext *context,
00326 CInvStructure *structure, int *size_out);
00332 void *cinv_structure_create_instance(CInvContext *context,
00333 CInvStructure *structure);
00348 cinv_status_t cinv_structure_instance_setvalue(CInvContext *context,
00349 CInvStructure *structure, void *instance, const char *name,
00350 void *value_ptr);
00365 void *cinv_structure_instance_getvalue(CInvContext *context,
00366 CInvStructure *structure, void *instance, const char *name);
00372 cinv_status_t cinv_structure_delete_instance(CInvContext *context,
00373 void *instance);
00380 cinv_status_t cinv_structure_delete(CInvContext *context,
00381 CInvStructure *structure);
00382
00392 CInvCallback *cinv_callback_create(CInvContext *context,
00393 CInvFunction *prototype, void *userdata, cinv_cbfunc_t cbfunc);
00400 void *cinv_callback_getentrypoint(CInvContext *context,
00401 CInvCallback *callback);
00407 cinv_status_t cinv_callback_delete(CInvContext *context,
00408 CInvCallback *callback);
00411 #ifdef __cplusplus
00412 }
00413 #endif
00414
00415 #endif