Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/emu/x64printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5839,6 +5839,8 @@ void x64Print(x64emu_t* emu, char* buff, size_t buffsz, const char* func, int ti
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIu64 ", %" PRIu64 ", %" PRIu32 ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8));
} else if (w == iFEppipppp) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIp ", %" PRIi32 ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8));
} else if (w == iFEpppiipi) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIp ", %" PRIp ", %" PRIi32 ", %" PRIi32 ", %" PRIp ", %" PRIi32 ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8));
} else if (w == iFEpppLppp) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIp ", %" PRIp ", %" PRIu64 ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8));
} else if (w == iFEppppipp) {
Expand Down
6 changes: 6 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3168,6 +3168,7 @@
#() iFEpuuLppp
#() iFEpUUuppp
#() iFEppipppp
#() iFEpppiipi
#() iFEpppLppp
#() iFEppppipp
#() iFEppppLpp
Expand Down Expand Up @@ -5824,8 +5825,13 @@ wrappedlibresolv:
- __dn_expand
- dn_expand
- iFppiipi:
- __res_nquery
- __res_querydomain
- res_nquery
- res_querydomain
- iFpppiipi:
- __res_nquerydomain
- res_nquerydomain
- iFipiipippi:
- __res_mkquery
- res_mkquery
Expand Down
5 changes: 5 additions & 0 deletions src/wrapped/generated/wrappedlibresolvtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
typedef int32_t (*iFpiipi_t)(void*, int32_t, int32_t, void*, int32_t);
typedef int32_t (*iFppppi_t)(void*, void*, void*, void*, int32_t);
typedef int32_t (*iFppiipi_t)(void*, void*, int32_t, int32_t, void*, int32_t);
typedef int32_t (*iFpppiipi_t)(void*, void*, void*, int32_t, int32_t, void*, int32_t);
typedef int32_t (*iFipiipippi_t)(int32_t, void*, int32_t, int32_t, void*, int32_t, void*, void*, int32_t);

#define SUPER() ADDED_FUNCTIONS() \
Expand All @@ -23,8 +24,12 @@ typedef int32_t (*iFipiipippi_t)(int32_t, void*, int32_t, int32_t, void*, int32_
GO(res_search, iFpiipi_t) \
GO(__dn_expand, iFppppi_t) \
GO(dn_expand, iFppppi_t) \
GO(__res_nquery, iFppiipi_t) \
GO(__res_querydomain, iFppiipi_t) \
GO(res_nquery, iFppiipi_t) \
GO(res_querydomain, iFppiipi_t) \
GO(__res_nquerydomain, iFpppiipi_t) \
GO(res_nquerydomain, iFpppiipi_t) \
GO(__res_mkquery, iFipiipippi_t) \
GO(res_mkquery, iFipiipippi_t)

Expand Down
2 changes: 2 additions & 0 deletions src/wrapped/generated/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,7 @@ typedef int32_t (*iFEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*,
typedef int32_t (*iFEpuuLppp_t)(x64emu_t*, void*, uint32_t, uint32_t, uintptr_t, void*, void*, void*);
typedef int32_t (*iFEpUUuppp_t)(x64emu_t*, void*, uint64_t, uint64_t, uint32_t, void*, void*, void*);
typedef int32_t (*iFEppipppp_t)(x64emu_t*, void*, void*, int32_t, void*, void*, void*, void*);
typedef int32_t (*iFEpppiipi_t)(x64emu_t*, void*, void*, void*, int32_t, int32_t, void*, int32_t);
typedef int32_t (*iFEpppLppp_t)(x64emu_t*, void*, void*, void*, uintptr_t, void*, void*, void*);
typedef int32_t (*iFEppppipp_t)(x64emu_t*, void*, void*, void*, void*, int32_t, void*, void*);
typedef int32_t (*iFEppppLpp_t)(x64emu_t*, void*, void*, void*, void*, uintptr_t, void*, void*);
Expand Down Expand Up @@ -7094,6 +7095,7 @@ void iFEpippppp(x64emu_t *emu, uintptr_t fcn) { iFEpippppp_t fn = (iFEpippppp_t)
void iFEpuuLppp(x64emu_t *emu, uintptr_t fcn) { iFEpuuLppp_t fn = (iFEpuuLppp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFEpUUuppp(x64emu_t *emu, uintptr_t fcn) { iFEpUUuppp_t fn = (iFEpUUuppp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFEppipppp(x64emu_t *emu, uintptr_t fcn) { iFEppipppp_t fn = (iFEppipppp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFEpppiipi(x64emu_t *emu, uintptr_t fcn) { iFEpppiipi_t fn = (iFEpppiipi_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8)); }
void iFEpppLppp(x64emu_t *emu, uintptr_t fcn) { iFEpppLppp_t fn = (iFEpppLppp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFEppppipp(x64emu_t *emu, uintptr_t fcn) { iFEppppipp_t fn = (iFEppppipp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFEppppLpp(x64emu_t *emu, uintptr_t fcn) { iFEppppLpp_t fn = (iFEppppLpp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (uintptr_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
Expand Down
1 change: 1 addition & 0 deletions src/wrapped/generated/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3205,6 +3205,7 @@ void iFEpippppp(x64emu_t *emu, uintptr_t fnc);
void iFEpuuLppp(x64emu_t *emu, uintptr_t fnc);
void iFEpUUuppp(x64emu_t *emu, uintptr_t fnc);
void iFEppipppp(x64emu_t *emu, uintptr_t fnc);
void iFEpppiipi(x64emu_t *emu, uintptr_t fnc);
void iFEpppLppp(x64emu_t *emu, uintptr_t fnc);
void iFEppppipp(x64emu_t *emu, uintptr_t fnc);
void iFEppppLpp(x64emu_t *emu, uintptr_t fnc);
Expand Down
122 changes: 51 additions & 71 deletions src/wrapped/wrappedlibresolv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,119 +23,99 @@ const char* libresolvName = "libresolv.so.2";
#include "generated/wrappedlibresolvtypes.h"
#include "wrappercallback.h"

static int real_res_search_wrapper(const char *dname, int class, int type, unsigned char *answer, int anslen)
{
if(my->res_search) {
return my->res_search((void*)dname, class, type, answer, anslen);
}
if(my->__res_search) {
return my->__res_search((void*)dname, class, type, answer, anslen);
#define FIND_REAL_DNS_FUNC(name) \
void* my_func_##name = NULL; \
if (my->name) \
my_func_##name = my->name; \
else if (my->__##name) \
my_func_##name = my->__##name; \
else { \
my_func_##name = NULL; \
printf_log(LOG_NONE, "Error: " #name " or __" #name " symbol not found in libresolv!\n"); \
}

printf_log(LOG_NONE, "Error: res_search or __res_search symbol not found in libresolv!\n");
return -1;
}

static int real_dn_expand_wrapper(const void *msg, const void *eomorig, const void *comp_dn, void *exp_dn, int length)
EXPORT int my_res_search(x64emu_t* emu, void* dname, int class, int type, void* answer, int anslen)
{
if(my->__dn_expand) {
return my->__dn_expand((void*)msg, (void*)eomorig, (void*)comp_dn, exp_dn, length);
}
if(my->dn_expand) {
return my->dn_expand((void*)msg, (void*)eomorig, (void*)comp_dn, exp_dn, length);
}

printf_log(LOG_NONE, "Error: dn_expand or __dn_expand symbol not found in libresolv!\n");
return -1;
FIND_REAL_DNS_FUNC(res_search);
return ((iFpiipi_t)my_func_res_search)(dname, class, type, answer, anslen);
}

static int real_res_mkquery_wrapper(int op, const char *dname, int class, int type, const unsigned char *data, int datalen, const unsigned char *newrr, unsigned char *buf, int buflen)
EXPORT int my___res_search(x64emu_t* emu, void* dname, int class, int type, void* answer, int anslen)
{
if(my->__res_mkquery) {
return my->__res_mkquery(op, (void*)dname, class, type, (void*)data, datalen, (void*)newrr, buf, buflen);
}
if(my->res_mkquery) {
return my->res_mkquery(op, (void*)dname, class, type, (void*)data, datalen, (void*)newrr, buf, buflen);
}

printf_log(LOG_NONE, "Error: res_mkquery or __res_mkquery symbol not found in libresolv!\n");
return -1;
FIND_REAL_DNS_FUNC(res_search);
return ((iFpiipi_t)my_func_res_search)(dname, class, type, answer, anslen);
}

static int real_res_query_wrapper(const char *dname, int class, int type, unsigned char *answer, int anslen)
EXPORT int my___dn_expand(x64emu_t* emu, void* msg, void* eomorig, void* comp_dn, void* exp_dn, int length)
{
if(my->__res_query) {
return my->__res_query((void*)dname, class, type, answer, anslen);
}
if(my->res_query) {
return my->res_query((void*)dname, class, type, answer, anslen);
}

printf_log(LOG_NONE, "Error: res_query or __res_query symbol not found in libresolv!\n");
return -1;
FIND_REAL_DNS_FUNC(dn_expand);
return ((iFppppi_t)my_func_dn_expand)(msg, eomorig, comp_dn, exp_dn, length);
}

static int real_res_querydomain_wrapper(const char *name, const char *domain, int class, int type, unsigned char *answer, int anslen)
EXPORT int my_dn_expand(x64emu_t* emu, void* msg, void* eomorig, void* comp_dn, void* exp_dn, int length)
{
if(my->__res_querydomain) {
return my->__res_querydomain((void*)name, (void*)domain, class, type, answer, anslen);
}
if(my->res_querydomain) {
return my->res_querydomain((void*)name, (void*)domain, class, type, answer, anslen);
}

printf_log(LOG_NONE, "Error: res_querydomain or __res_querydomain symbol not found in libresolv!\n");
return -1;
FIND_REAL_DNS_FUNC(dn_expand);
return ((iFppppi_t)my_func_dn_expand)(msg, eomorig, comp_dn, exp_dn, length);
}

EXPORT int my_res_search(x64emu_t* emu, const char* dname, int class, int type, unsigned char* answer, int anslen)
EXPORT int my___res_nquery(x64emu_t* emu, void* statep, void* dname, int class, int type, void* answer, int anslen)
{
return real_res_search_wrapper(dname, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_nquery);
return ((iFppiipi_t)my_func_res_nquery)(statep, dname, class, type, answer, anslen);
}

EXPORT int my___res_search(x64emu_t* emu, const char* dname, int class, int type, unsigned char* answer, int anslen)
EXPORT int my_res_nquery(x64emu_t* emu, void* statep, void* dname, int class, int type, void* answer, int anslen)
{
return real_res_search_wrapper(dname, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_nquery);
return ((iFppiipi_t)my_func_res_nquery)(statep, dname, class, type, answer, anslen);
}

EXPORT int my___dn_expand(x64emu_t* emu, const void* msg, const void* eomorig, const void* comp_dn, void* exp_dn, int length)
EXPORT int my___res_nquerydomain(x64emu_t* emu, void* statep, void* dname, void* domain, int class, int type, void* answer, int anslen)
{
return real_dn_expand_wrapper(msg, eomorig, comp_dn, exp_dn, length);
FIND_REAL_DNS_FUNC(res_nquerydomain);
return ((iFpppiipi_t)my_func_res_nquerydomain)(statep, dname, domain, class, type, answer, anslen);
}

EXPORT int my_dn_expand(x64emu_t* emu, const void* msg, const void* eomorig, const void* comp_dn, void* exp_dn, int length)
EXPORT int my_res_nquerydomain(x64emu_t* emu, void* statep, void* dname, void* domain, int class, int type, void* answer, int anslen)
{
return real_dn_expand_wrapper(msg, eomorig, comp_dn, exp_dn, length);
FIND_REAL_DNS_FUNC(res_nquerydomain);
return ((iFpppiipi_t)my_func_res_nquerydomain)(statep, dname, domain, class, type, answer, anslen);
}

EXPORT int my___res_query(x64emu_t* emu, const char* dname, int class, int type, unsigned char* answer, int anslen)
EXPORT int my___res_query(x64emu_t* emu, void* dname, int class, int type, void* answer, int anslen)
{
return real_res_query_wrapper(dname, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_query);
return ((iFpiipi_t)my_func_res_query)(dname, class, type, answer, anslen);
}

EXPORT int my_res_query(x64emu_t* emu, const char* dname, int class, int type, unsigned char* answer, int anslen)
EXPORT int my_res_query(x64emu_t* emu, void* dname, int class, int type, void* answer, int anslen)
{
return real_res_query_wrapper(dname, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_query);
return ((iFpiipi_t)my_func_res_query)(dname, class, type, answer, anslen);
}

EXPORT int my___res_querydomain(x64emu_t* emu, const char* name, const char* domain, int class, int type, unsigned char* answer, int anslen)
EXPORT int my___res_querydomain(x64emu_t* emu, void* name, void* domain, int class, int type, void* answer, int anslen)
{
return real_res_querydomain_wrapper(name, domain, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_querydomain);
return ((iFppiipi_t)my_func_res_querydomain)(name, domain, class, type, answer, anslen);
}

EXPORT int my_res_querydomain(x64emu_t* emu, const char* name, const char* domain, int class, int type, unsigned char* answer, int anslen)
EXPORT int my_res_querydomain(x64emu_t* emu, void* name, void* domain, int class, int type, void* answer, int anslen)
{
return real_res_querydomain_wrapper(name, domain, class, type, answer, anslen);
FIND_REAL_DNS_FUNC(res_querydomain);
return ((iFppiipi_t)my_func_res_querydomain)(name, domain, class, type, answer, anslen);
}

EXPORT int my___res_mkquery(x64emu_t* emu, int op, const char* dname, int class, int type, const unsigned char* data, int datalen, const unsigned char* newrr, unsigned char* buf, int buflen)
EXPORT int my___res_mkquery(x64emu_t* emu, int op, void* dname, int class, int type, void* data, int datalen, void* newrr, void* buf, int buflen)
{
return real_res_mkquery_wrapper(op, dname, class, type, data, datalen, newrr, buf, buflen);
FIND_REAL_DNS_FUNC(res_mkquery);
return ((iFipiipippi_t)my_func_res_mkquery)(op, dname, class, type, data, datalen, newrr, buf, buflen);
}

EXPORT int my_res_mkquery(x64emu_t* emu, int op, const char* dname, int class, int type, const unsigned char* data, int datalen, const unsigned char* newrr, unsigned char* buf, int buflen)
EXPORT int my_res_mkquery(x64emu_t* emu, int op, void* dname, int class, int type, void* data, int datalen, void* newrr, void* buf, int buflen)
{
return real_res_mkquery_wrapper(op, dname, class, type, data, datalen, newrr, buf, buflen);
FIND_REAL_DNS_FUNC(res_mkquery);
return ((iFipiipippi_t)my_func_res_mkquery)(op, dname, class, type, data, datalen, newrr, buf, buflen);
}

#ifdef STATICBUILD
Expand Down
6 changes: 4 additions & 2 deletions src/wrapped/wrappedlibresolv_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ GO(__res_nameinquery, iFpiipp)
GO(__res_nmkquery, iFpipiipippi)
#endif
GO(res_nmkquery, iFpipiipippi)
GO(__res_nquery, iFppiipi)
//GO(__res_nquerydomain,
GOM(__res_nquery, iFEppiipi)
GOM(res_nquery, iFEppiipi)
GOM(__res_nquerydomain, iFEpppiipi)
GOM(res_nquerydomain, iFEpppiipi)
GO(__res_nsearch, iFppiipi)
#ifdef STATICBUILD
//GO(__res_nsend,
Expand Down
Loading