Es ist ziemlich einfach, die XrmParseCommand
Funktion zu "kapabeln" und die Optionen aufzulisten, bevor die ursprüngliche Funktion ausgeführt wird.
/* G. Allen Morris III <gam3@gam3.net> */
#define _GNU_SOURCE
#include <X11/Xresource.h>
#include <stdio.h>
#include <dlfcn.h>
static char *types[] = {
"XrmoptionNoArg",
"XrmoptionIsArg",
"XrmoptionStickyArg",
"XrmoptionSepArg",
"XrmoptionResArg",
"XrmoptionSkipArg",
"XrmoptionSkipLine",
"XrmoptionSkipNArgs"
};
void XrmParseCommand(XrmDatabase * database,
XrmOptionDescList table,
int table_count,
_Xconst char *name, int *argc_in_out, char **argv_in_out)
{
void (*original_XrmParseCommand) (XrmDatabase * database,
XrmOptionDescList table,
int table_count,
_Xconst char *name, int *argc_in_out,
char **argv_in_out);
int argc = *argc_in_out;
printf("'XrmParseCommand's %s\n", name);
for (int i = 0; i < table_count; i++) {
switch (table[i].argKind) {
case XrmoptionNoArg:
case XrmoptionIsArg:
case XrmoptionStickyArg:
case XrmoptionResArg:
case XrmoptionSkipArg:
case XrmoptionSkipLine:
case XrmoptionSkipNArgs:
case XrmoptionSepArg:
printf("%20s %30s %s \n", types[table[i].argKind], table[i].option,
table[i].specifier);
break;
default:
printf("%20s %30s %s \n", "UNKNOWN", table[i].option,
table[i].specifier);
}
}
original_XrmParseCommand = dlsym(RTLD_NEXT, "XrmParseCommand");
(*original_XrmParseCommand) (database,
table,
table_count, name, argc_in_out, argv_in_out);
}
/* eof */
Makefile
myXrmParseCommand.so : myXrmParseCommand.c
gcc -Wall -fPIC -shared -o $@ $< -ldl
Um es auszuführen
#/bin/sh
make && LD_PRELOAD=./myXrmParseCommand.so xterm -e :;
Es gibt eine snippit auf Git Labor hier .