Beispiel #1
0
static HANDLE init_module(const char* library)
{
	HANDLE			h;
	char*			f;
	char			buf[PATH_MAX];

	static const char	sys[] = "C:\\Windows\\System32";

	f = "GetModuleHandle";
	sfsprintf(buf, sizeof(buf), "%s\\%s.dll", sys, library);
	if (h = GetModuleHandle(buf))
		goto found;
	f = "LoadLibrary";
	sfsprintf(buf, sizeof(buf), "%s.dll", library);
	if (h = LoadLibrary(buf))
		goto found;
	sfsprintf(buf, sizeof(buf), "%s\\%s.dll", sys, library);
	if (h = LoadLibrary(buf))
		goto found;
	logmsg(LOGLEVEL(index), "library %s not found", library);
	return 0;
 found:
	logmsg(LOGLEVEL(index), "library %s bound to %s by %s", library, buf, f);
	return h;
}
Beispiel #2
0
static FARPROC getsymbol(int index, const char* symbol)
{
	FARPROC			sym;

	static HANDLE		handle;

	static const char	library[] = "msi";

	if (!handle && !(handle = init_module(library)))
	{
		logmsg(LOGLEVEL(index), "library %s not found", library);
		return 0;
	}
	if (!(sym = GetProcAddress(handle, symbol)))
		logmsg(LOGLEVEL(index), "symbol %s not found in library %s", symbol, library);
	return sym;
}
Beispiel #3
0
void debug(struct opts *opts, const char *format, ...) {
    if (!LOGLEVEL(opts, LOG_DEBUG))
        return;

    va_list ap;
    va_start(ap, format);
    if (format[0] == LOG_NP[0]) {
        format += 1;
    } else {
        fprintf(stderr, "DEBUG: ");
    }
    vfprintf(stderr, format, ap);
    va_end(ap);
}
Beispiel #4
0
void debug_printopts(struct opts *opts) {
    if (!LOGLEVEL(opts, LOG_DEBUG))
        return;

    int arg;
    debug(opts, "o_loglevel: %d\n", opts->o_loglevel);
    debug(opts, "o_datadir: %s\n", opts->o_datadir);
    debug(opts, "o_logdir: %s\n", opts->o_logdir);
    debug(opts, "o_argc: %d\n", opts->o_argc);
    debug(opts, "o_argv:");
    for (arg = 0; arg < opts->o_argc; arg += 1)
        debug(opts, LOG_NP " %s", opts->o_argv[arg]);
    debug(opts, LOG_NP "\n");
    debug(opts, "o_realpath: %s\n", opts->o_realpath);
    debug(opts, "o_execname: %s\n", opts->o_execname);
    debug(opts, "o_session_log: %s\n", opts->o_session_log);
    debug(opts, "o_session_log_file: %p\n", opts->o_session_log_file);
}