-
Notifications
You must be signed in to change notification settings - Fork 9
/
get_offsets.c
70 lines (56 loc) · 2.12 KB
/
get_offsets.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <dlfcn.h>
#include <stdlib.h>
// Camera
#include <cam_intf.h>
#define CAM_LIB_MCT "libmmcamera2_mct.so"
#define CAM_LIB_OEM "liboemcamera.so"
#define PRINT(PARAM_ID, table_ptr) \
blob_pointer = (char*)(get_pointer_of(PARAM_ID, table_ptr)) - (char*)(table_ptr); \
oss_pointer = (char*)(POINTER_OF_META(PARAM_ID, table_ptr)) - (char*)(table_ptr); \
blob_size = get_size_of(PARAM_ID); \
oss_size = SIZE_OF_PARAM(PARAM_ID, table_ptr); \
if ((blob_pointer != oss_pointer) || (blob_size != oss_size)) printf("FIXME!!!\n"); \
printf("BLOB: %s index=%d pointer=%d size=%d\n", #PARAM_ID, PARAM_ID, blob_pointer, blob_size); \
printf("OSS : %s index=%d pointer=%d size=%d\n", #PARAM_ID, PARAM_ID, oss_pointer, oss_size);
typedef void* (*get_pointer_of_t)(cam_intf_parm_type_t, metadata_buffer_t*);
typedef uint32_t (*get_size_of_t)(cam_intf_parm_type_t);
void* find_library_handle() {
void* handle;
handle = dlopen(CAM_LIB_MCT, RTLD_LAZY);
if (handle) {
return handle;
}
handle = dlopen(CAM_LIB_OEM, RTLD_LAZY);
if (handle) {
return handle;
}
return NULL;
}
int main() {
void* handle;
get_pointer_of_t get_pointer_of;
get_size_of_t get_size_of;
metadata_buffer_t* pMetadata = malloc(sizeof(metadata_buffer_t));
handle = find_library_handle();
if (!handle) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
get_pointer_of = (get_pointer_of_t)dlsym(handle, "get_pointer_of");
if (!get_pointer_of) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
get_size_of = (get_size_of_t)dlsym(handle, "get_size_of");
if (!get_size_of) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
int blob_pointer = 0;
int oss_pointer = 0;
int blob_size = 0;
int oss_size = 0;
/* INCLUDE() macros from metadata_data_t go after this */
dlclose(handle);
return 0;
}