Exemplo n.º 1
0
/*
 * Called when the program starts, to save whatever credential information
 * we'll need later, and to do whatever other specialized platform-dependent
 * initialization we want.
 */
void
init_process_policies(void)
{
	HMODULE kernel32Handle;
	typedef BOOL (WINAPI *SetProcessDEPPolicyHandler)(DWORD);
	SetProcessDEPPolicyHandler PSetProcessDEPPolicy;

#ifndef PROCESS_DEP_ENABLE
#define PROCESS_DEP_ENABLE 1
#endif

	/*
	 * If we have SetProcessDEPPolicy(), turn "data execution
	 * prevention" on - i.e., if the MMU lets you set execute
	 * permission on a per-page basis, turn execute permission
	 * off on most data pages.  PSetProcessDEPPolicy() fails on
	 * 64-bit Windows (it's *always* on there), but if it fails,
	 * we don't care (we did our best), so we don't check for
	 * errors.
	 *
	 * XXX - if the GetModuleHandle() call fails, should we report
	 * an error?  That "shouldn't happen" - it's the equivalent
	 * of libc.{so,sl,a} or libSystem.dylib being missing on UN*X.
	 */
	kernel32Handle = GetModuleHandle(_T("kernel32.dll"));
	if (kernel32Handle != NULL) {
		PSetProcessDEPPolicy = (SetProcessDEPPolicyHandler) GetProcAddress(kernel32Handle, "SetProcessDEPPolicy");
		if (PSetProcessDEPPolicy) {
			PSetProcessDEPPolicy(PROCESS_DEP_ENABLE);
		}
	}

	npf_sys_is_running();
}
Exemplo n.º 2
0
/*  Check if there's something important to tell the user during startup.
 *  We want to do this *after* showing the main window so that any windows
 *  we pop up will be above the main window.
 */
static void
check_and_warn_user_startup(const QString &cf_name)
{
#ifndef _WIN32
    Q_UNUSED(cf_name)
#endif
    gchar               *cur_user, *cur_group;

    /* Tell the user not to run as root. */
    if (running_with_special_privs() && recent.privs_warn_if_elevated) {
        cur_user = get_cur_username();
        cur_group = get_cur_groupname();
        simple_message_box(ESD_TYPE_WARN, &recent.privs_warn_if_elevated,
        "Running as user \"%s\" and group \"%s\".\n"
        "This could be dangerous.\n\n"
        "If you're running Wireshark this way in order to perform live capture, "
        "you may want to be aware that there is a better way documented at\n"
        "https://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
        g_free(cur_user);
        g_free(cur_group);
    }

#ifdef _WIN32
    /* Warn the user if npf.sys isn't loaded. */
    if (!get_stdin_capture() && cf_name.isEmpty() && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_windows_major_version() >= 6) {
        simple_message_box(ESD_TYPE_WARN, &recent.privs_warn_if_no_npf, "%s",
        "The NPF driver isn't running. You may have trouble\n"
        "capturing or listing interfaces.");
    }
#endif

}