Skip to content

Commit bb5bab6

Browse files
committed
Add debug info
1 parent 4c7fee0 commit bb5bab6

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

plthook_elf.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@
187187
#endif
188188
#endif /* __LP64__ */
189189

190+
/* TODO: Add debug info for library listing */
191+
#ifdef PLTHOOK_DEBUG
192+
#define DEBUG_MSG(...) fprintf(stderr, __VA_ARGS__)
193+
#else
194+
#define DEBUG_MSG(...)
195+
#endif
196+
190197
typedef struct mem_prot {
191198
size_t start;
192199
size_t end;

plthook_osx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747
#include <mach-o/fixup-chains.h>
4848
#include "plthook.h"
4949

50-
// #define PLTHOOK_DEBUG_CMD 1
51-
// #define PLTHOOK_DEBUG_BIND 1
52-
// #define PLTHOOK_DEBUG_FIXUPS 1
53-
// #define PLTHOOK_DEBUG_ADDR 1
50+
#ifdef PLTHOOK_DEBUG
51+
#define PLTHOOK_DEBUG_CMD 1
52+
#define PLTHOOK_DEBUG_BIND 1
53+
#define PLTHOOK_DEBUG_FIXUPS 1
54+
#define PLTHOOK_DEBUG_ADDR 1
55+
#endif
5456

5557
#ifdef PLTHOOK_DEBUG_CMD
5658
#define DEBUG_CMD(...) fprintf(stderr, __VA_ARGS__)

plthook_win32.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
#define stricmp strcasecmp
6464
#endif
6565

66+
#ifdef PLTHOOK_DEBUG
67+
#define DEBUG_MSG(...) fprintf(stderr, __VA_ARGS__)
68+
#else
69+
#define DEBUG_MSG(...)
70+
#endif
71+
6672
typedef struct {
6773
const char *mod_name;
6874
const char *name;
@@ -214,6 +220,8 @@ static int plthook_open_real(plthook_t **plthook_out, HMODULE hMod)
214220
const char *module_name = (char *)hMod + desc->Name;
215221
int is_winsock2_dll = (stricmp(module_name, "WS2_32.DLL") == 0);
216222

223+
DEBUG_MSG("Imported Library: '%s'\n", module_name);
224+
217225
while (addr_thunk->u1.Function != 0) {
218226
const char *name = NULL;
219227

@@ -249,6 +257,8 @@ static int plthook_open_real(plthook_t **plthook_out, HMODULE hMod)
249257
continue;
250258
}
251259

260+
DEBUG_MSG("Imported Delayed Library: '%s'\n", module_name);
261+
252262
while (name_thunk->u1.AddressOfData) {
253263
const char *name = NULL;
254264

0 commit comments

Comments
 (0)