MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / ctor

Function ctor

Bcore/src/main/cpp/Dobby/example/darwin_common_api.cc:52–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51#if 1
52__attribute__((constructor)) static void ctor() {
53 void *func = NULL;
54 log_set_level(1);
55
56 func_map = new std::map<void *, const char *>();
57
58 for (int i = 0; i < sizeof(func_array) / sizeof(char *); ++i) {
59 func = DobbySymbolResolver(NULL, func_array[i]);
60 if (func == NULL) {
61 LOG(1, "func %s not resolve", func_array[i]);
62 continue;
63 }
64 func_map->insert(std::pair<void *, const char *>(func, func_array[i]));
65 }
66
67 for (auto i = func_map->begin(), e = func_map->end(); i != e; i++) {
68 DobbyInstrument(i->first, common_handler);
69 }
70
71 DobbyGlobalOffsetTableReplace(NULL, "_pthread_create", (void *)fake_pthread_create, (void **)&orig_pthread_create);
72
73 pthread_t socket_server;
74 uint64_t socket_demo_server(void *ctx);
75 pthread_create(&socket_server, NULL, (void *(*)(void *))socket_demo_server, NULL);
76
77 usleep(1000);
78 pthread_t socket_client;
79 uint64_t socket_demo_client(void *ctx);
80 pthread_create(&socket_client, NULL, (void *(*)(void *))socket_demo_client, NULL);
81
82 pthread_join(socket_client, 0);
83 pthread_join(socket_server, 0);
84}
85
86#include <sys/socket.h>
87#include <netinet/in.h>

Callers

nothing calls this directly

Calls 7

log_set_levelFunction · 0.85
DobbyInstrumentFunction · 0.85
DobbySymbolResolverFunction · 0.50
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected