352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/* $Id$ */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/** @file
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * VBoxCredProvUtils - Misc. utility functions for VBoxCredProv.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/*
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * Copyright (C) 2012 Oracle Corporation
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync *
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * available from http://www.virtualbox.org. This file is free software;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * General Public License (GPL) as published by the Free Software
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/*******************************************************************************
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync* Header Files *
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync*******************************************************************************/
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync#include <Windows.h>
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync#include <iprt/string.h>
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync#include <VBox/log.h>
677d56e09bab8713dc546b66c93f8bb92a7881c3vboxsync#include <VBox/VBoxGuestLib.h>
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/*******************************************************************************
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync* Global Variables *
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync*******************************************************************************/
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/** Verbosity flag for guest logging. */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsyncDWORD g_dwVerbosity = 0;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/**
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * Displays a verbose message.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync *
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * @param iLevel Minimum log level required to display this message.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * @param pszFormat The message text.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * @param ... Format arguments.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsyncvoid VBoxCredProvVerbose(DWORD dwLevel, const char *pszFormat, ...)
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync{
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync if (dwLevel <= g_dwVerbosity)
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync {
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync va_list args;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync va_start(args, pszFormat);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync char *psz = NULL;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync RTStrAPrintfV(&psz, pszFormat, args);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync va_end(args);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync AssertPtr(psz);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync LogRel(("%s", psz));
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync RTStrFree(psz);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync }
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync}
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync/**
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * Reports VBoxGINA's status to the host (treated as a guest facility).
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync *
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * @return IPRT status code.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync * @param enmStatus Status to report to the host.
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync */
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsyncint VBoxCredProvReportStatus(VBoxGuestFacilityStatus enmStatus)
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync{
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync VBoxCredProvVerbose(0, "VBoxCredProv: reporting status %d\n", enmStatus);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync int rc = VbglR3AutoLogonReportStatus(enmStatus);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync if (RT_FAILURE(rc))
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync VBoxCredProvVerbose(0, "VBoxCredProv: failed to report status %d, rc=%Rrc\n", enmStatus, rc);
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync return rc;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync}
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync