Exemplo n.º 1
0
/*-----------------------------------------------------------------------------
PrintError(HRESULT hr)
    Print out the error message that corresponds to the error code

Parameters
    hr - Error code

Return Value
    None
-----------------------------------------------------------------------------*/
void PrintError(HRESULT hr)
{
    LPVOID lpMsgBuf;
    
    // Format the error message
    if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
                  FORMAT_MESSAGE_FROM_SYSTEM     |
                  FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL,
                  hr,
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Defaut lang
                  (LPWSTR) &lpMsgBuf,
                  0,
                  NULL ))
    {
        wprintf(L"Unknown error occured\n");
        return;
    }

    // Display the string
    wprintf(L"\n%s", (LPCWSTR)lpMsgBuf);

    // Free the buffer
    LocalFree( lpMsgBuf );

    WaitForKeyPress();
}
Exemplo n.º 2
0
/*-----------------------------------------------------------------------------
GetUserQuotaInfo(IDiskQuotaControl* lpDiskQuotaControl)
    Get quota information for a specific user

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL GetUserQuotaInfo(IDiskQuotaControl* lpDiskQuotaControl)
{
    WCHAR    szUser[MAX_PATH] = {0};
    IDiskQuotaUser* lpDiskQuotaUser;
    DWORD    dwCharsRead;
    HANDLE   hStdIn  = GetStdHandle(STD_INPUT_HANDLE);
    HRESULT  hr;

    wprintf(L"\n\nEnter the logon name of the user");
    wprintf(L"(ie. DOMAIN\\USERNAME): ");

    // Get the user for which to get quota information 
    ReadConsole(hStdIn, szUser, MAX_PATH, &dwCharsRead, NULL);
    szUser[MAX_PATH-1] = L'\0'; // make sure szUser is NULL terminated
    LfcrToNull(szUser);

    // Check if the name is valid
    hr = lpDiskQuotaControl->FindUserName((LPCWSTR)szUser, &lpDiskQuotaUser);
    if (SUCCEEDED(hr))
    {
        WCHAR    szQuotaUsedText[MAX_PATH] = {0};
        WCHAR    szQuotaLimitText[MAX_PATH] = {0};
        WCHAR    szQuotaThresholdText[MAX_PATH] = {0};

        if (SUCCEEDED(hr = lpDiskQuotaUser->GetQuotaThresholdText(
                                    szQuotaThresholdText, MAX_PATH))         &&
            SUCCEEDED(hr = lpDiskQuotaUser->GetQuotaLimitText(
                                    szQuotaLimitText, MAX_PATH))             &&
            SUCCEEDED(hr = lpDiskQuotaUser->GetQuotaUsedText(
                                    szQuotaUsedText, MAX_PATH)))
        {
            szQuotaUsedText[MAX_PATH-1] = L'\0'; // make sure szQuotaUsedText is NULL terminated
            szQuotaLimitText[MAX_PATH-1] = L'\0'; // make sure szQuotaLimitText is NULL terminated
            szQuotaThresholdText[MAX_PATH-1] = L'\0'; // make sure szQuotaThresholdText is NULL terminated

            wprintf(L"Amount Used        Limit    Threshold\n");
            wprintf(L"-----------        -----    ---------\n");
            wprintf(L"   %10s", szQuotaUsedText);
            wprintf(L"   %10s", szQuotaLimitText);
            wprintf(L"   %10s", szQuotaThresholdText);
            wprintf(L"\n");
        }
        else
        {
            wprintf(L"\nCould not get the quota information for %s", szUser);
        }

        lpDiskQuotaUser->Release();
    }
    else
    {
        wprintf(L"\nCould not find quota data for %s\n", szUser);
    }

    WaitForKeyPress();

    return SUCCEEDED(hr);
}
Exemplo n.º 3
0
/*-----------------------------------------------------------------------------
GetDefaultQuota(IDiskQuotaControl* lpDiskQuotaControl)
    Gets the state of quota tracking on the current volume

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL GetDefaultQuota(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT hr;
    DWORD   dwState;

    // Get the default quota state
    hr = lpDiskQuotaControl->GetQuotaState(&dwState);

    if (FAILED(hr))
    {
        PrintError(hr);
        return FALSE;
    }

    wprintf(L"\n\nDefault Disk Quota State:\n");

    // Switch on the state of disk quota tracking
    switch(dwState & DISKQUOTA_STATE_MASK)
    {
    case DISKQUOTA_STATE_DISABLED:
        wprintf(L"Quota's are not enabled on the volume.\n");
        break;
    case DISKQUOTA_STATE_TRACK:
        wprintf(L"Quotas are enabled but the limit value is not being ");
        wprintf(L"enforced.\nUsers may exceed their quota limit.\n");
        break;
    case DISKQUOTA_STATE_ENFORCE:
        wprintf(L"Quotas are enabled and the limit value is enforced.");
        wprintf(L"\nUsers cannot exceed their quota limit.\n");
        break;
    default:
        wprintf(L"Unknown.\n");
        break;
    }

    wprintf(L"\nDefault Disk Quota File State:\n");

    switch(dwState & DISKQUOTA_FILESTATE_MASK)
    {
    case DISKQUOTA_FILESTATE_INCOMPLETE:
        wprintf(L"The volume's quota information is out of date.\n");
        wprintf(L"Quotas are probably disabled.\n");
        break;
    case DISKQUOTA_FILESTATE_REBUILDING:
        wprintf(L"The volume is rebuilding its quota information.\n");
        break;
    default:
        wprintf(L"Unknown.\n");
        break;
    }

    WaitForKeyPress();

    return TRUE;
}
Exemplo n.º 4
0
Arquivo: Main.c Projeto: Zoxc/nano64
void Intrepret()
{
    Branching = false;
    GeneralPurpose[0] = 0;

    if(Debugging)
    {
        while(true)
        {
            uint32_t Instruction = *ProgamCounter;

            ClearScreen();
            printf("nano64 0.0.1 - A very incomplete Nintendo 64 emulator\n\n");

            DumpRegisters();

            printf("\n\nCurrent instruction [%.8X] ", Instruction);

            CPUJumpTable[Instruction >> 26]();

            printf("\nPress a key to step forward...");

            WaitForKeyPress();

            ProgamCounter++;
        }

        ClearScreen();
        printf("nano64 0.0.1 - A very incomplete Nintendo 64 emulator\n\n");

        DumpRegisters();

        printf("\n\nEmulation done. Press a key to quit.");

        WaitForKeyPress();
    }
    else
    {
        while(true)
Exemplo n.º 5
0
/*-----------------------------------------------------------------------------
GetQuotaLogFlags(IDiskQuotaControl* lpDiskQuotaControl)
    Gets the state of the quota log flags

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL GetQuotaLogFlags(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT hr;
    DWORD   dwQuotaLogFlags;

    // Get the state log the quota log flags
    hr = lpDiskQuotaControl->GetQuotaLogFlags(&dwQuotaLogFlags);

    if (FAILED(hr))
    {
        PrintError(hr);
        return FALSE;
    }

    wprintf(L"\n\nDisk Quota Log State:\n");

    // Check if the system creates a log entry when a threshold limit
    // is exceeded
    if (DISKQUOTA_IS_LOGGED_USER_THRESHOLD(dwQuotaLogFlags))
    {
        wprintf(L"\nAn event log entry will be created when the user");
        wprintf(L"\nexceeds his assigned warning threshold.\n");
    }
    else
    {
        wprintf(L"\nAn event log entry will NOT be created when the");
        wprintf(L"\nuser exceeds his assigned warning threshold.\n");
    }

    // Check if the system creates a log entry when a hard limit
    // is exceeded
    if (DISKQUOTA_IS_LOGGED_USER_LIMIT(dwQuotaLogFlags))
    {
        wprintf(L"\nAn event log entry will be created when the user");
        wprintf(L"\nexceeds his assigned hard quota limit.\n");
    }
    else
    {
        wprintf(L"\nAn event log entry will NOT be created when the");
        wprintf(L"\nuser exceeds his assigned hard quota limit.\n");
    }
    WaitForKeyPress();

    return TRUE;
}
Exemplo n.º 6
0
/*-----------------------------------------------------------------------------
EnumerateUsers(IDiskQuotaControl* lpDiskQuotaControl)
    Enumerate through all of the disk quota users

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL EnumerateUsers(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT              hr;
    IEnumDiskQuotaUsers* lpEnumDiskQuotaUsers;
    IDiskQuotaUser*      lpDiskQuotaUser;
    DWORD                dwUsersFetched;

    // Create an enumerator object to enumerate quota users on the volume. 
    hr = lpDiskQuotaControl->CreateEnumUsers(NULL, 0,
                                             DISKQUOTA_USERNAME_RESOLVE_SYNC,
                                             &lpEnumDiskQuotaUsers);
    if (SUCCEEDED(hr))
    {
        WCHAR szLogonName[MAX_PATH];

        wprintf(L"\n\nLogon name\n");
        wprintf(L"----------\n");

        // Enumerate through all of the quota users
        while(SUCCEEDED(hr) &&
              S_OK == lpEnumDiskQuotaUsers->
                      Next(1, &lpDiskQuotaUser, &dwUsersFetched))
        {
            // Retrieve the name strings associated with this disk quota user.
            if (SUCCEEDED(hr = lpDiskQuotaUser->GetName(NULL, 0, szLogonName,
                                                        MAX_PATH, NULL, 0)))
            { 
                szLogonName[MAX_PATH-1] = L'\0'; // make sure szLogonName is NULL terminated
                wprintf(L"%s\n", szLogonName);
                lpDiskQuotaUser->Release();
            }
        }
        lpEnumDiskQuotaUsers->Release();
    }

    if (FAILED(hr)) PrintError(hr);
    WaitForKeyPress();

    return SUCCEEDED(hr);
}
Exemplo n.º 7
0
/*-----------------------------------------------------------------------------
GetDefaultThreshold(IDiskQuotaControl* lpDiskQuotaControl)
    Get the default threshold of the volume.

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL GetDefaultThreshold(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT hr;
    WCHAR   szDefaultThresholdText[MAX_PATH];

    // Get the default threshold
    hr = lpDiskQuotaControl->
        GetDefaultQuotaThresholdText(szDefaultThresholdText, MAX_PATH);

    if (FAILED(hr))
    {
        PrintError(hr);
        return FALSE;
    }

    szDefaultThresholdText[MAX_PATH - 1] = L'\0'; // Make sure szDefaultThresholdText is NULL terminated

    wprintf(L"\n\nDefault Quota Threshold: %s\n", szDefaultThresholdText);

    WaitForKeyPress();
    
    return TRUE;
}
Exemplo n.º 8
0
/*-----------------------------------------------------------------------------
GetDefaultHardLimit(IDiskQuotaControl* lpDiskQuotaControl)
    Get the default hard limit of the volume.

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL GetDefaultHardLimit(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT hr;
    WCHAR   szDefaultHardLimitText[MAX_PATH];

    // Get the default hard quota limit in text format
    hr = lpDiskQuotaControl->
        GetDefaultQuotaLimitText(szDefaultHardLimitText, MAX_PATH);

    if (FAILED(hr))
    {
        PrintError(hr);
        return FALSE;
    }

    szDefaultHardLimitText[MAX_PATH - 1] = L'\0'; // Make sure szDefaultHardLimitText is NULL terminated

    wprintf(L"\n\nDefault Quota Hard Limit: %s\n", szDefaultHardLimitText);

    WaitForKeyPress();

    return TRUE;
}
Exemplo n.º 9
0
void ConfigHandleClick( Config *conf )
{
	int i;
	char buf[32];
	
	for( i = 0; i < conf->init_entries; i++ )
	{
		if( conf->entry[i].active )
		{
			switch( conf->entry[i].type )
			{
				case CONF_NUM_RANGE:
				{
					if( ++*conf->entry[i].num_range->active_num > conf->entry[i].num_range->range_max )
					{
						*conf->entry[i].num_range->active_num = conf->entry[i].num_range->range_min;
					}
					sprintf(conf->entry[i].num_range->numstring, "%d", *conf->entry[i].num_range->active_num);
					sprintf(conf->entry[i].text,
					        "%s: %s",
					         conf->entry[i].num_range->name,
					         conf->entry[i].num_range->numstring);
					
					break;
				}
				case CONF_KEY:
				{
					// draw message box
					SDL_Rect dest;
					SDL_Surface *newkey;
					
					dest.x = 250;
					dest.y = 300;
					
					newkey = LoadImage( "gfx/newkey.png" );
					SDL_BlitSurface( newkey, NULL, screen, &dest );
					SDL_Flip( screen );
					
					// wait for key press
					*conf->entry[i].key->key_id = WaitForKeyPress();
					
					strcpy( conf->entry[i].key->keyname, SDL_GetKeyName(*conf->entry[i].key->key_id));
					sprintf( conf->entry[i].text,
					         "%s: %s",
						 conf->entry[i].key->name,
						 conf->entry[i].key->keyname);
					break;
				}
				case CONF_TOGGLE:
				{
					if( *conf->entry[i].toggle->status != 0 )
					{
						*conf->entry[i].toggle->status = 0;
					}
					else
					{
						*conf->entry[i].toggle->status = 1;
					}
					
					strcpy(conf->entry[i].toggle->strstatus,
						*conf->entry[i].toggle->status ? "on" : "off");
					sprintf( conf->entry[i].text,
						"%s: %s",
						conf->entry[i].toggle->name,
						conf->entry[i].toggle->strstatus );
					
					break;
				}
			}
		}
	}
	
	return;
}
Exemplo n.º 10
0
/*-----------------------------------------------------------------------------
EnumerateUserQuotas(IDiskQuotaControl* lpDiskQuotaControl)
    Enumerate through all user's and their quota's

Parameters
    lpDiskQuotaControl - Pointer to an object that implements the
                         IDiskQuotaControl interface

Return Value
    TRUE - Success
    FALSE - Failure
-----------------------------------------------------------------------------*/
BOOL EnumerateUserQuotas(IDiskQuotaControl* lpDiskQuotaControl)
{
    HRESULT              hr;
    IEnumDiskQuotaUsers* lpEnumDiskQuotaUsers;

    // Create an enumerator object to enumerate quota users on the volume. 
    hr = lpDiskQuotaControl->CreateEnumUsers(NULL, 0,
                                             DISKQUOTA_USERNAME_RESOLVE_SYNC,
                                             &lpEnumDiskQuotaUsers);
    if (SUCCEEDED(hr))
    {
        IDiskQuotaUser*      lpDiskQuotaUser;
        DWORD                dwUsersFetched;
        WCHAR                szLogonName[MAX_PATH];
        WCHAR                szQuotaUsedText[MAX_PATH];
        WCHAR                szQuotaLimitText[MAX_PATH];
        WCHAR                szQuotaThresholdText[MAX_PATH];
        DISKQUOTA_USER_INFORMATION dqUserInfo;

        wprintf(L"\n\nStatus               Logon Name  ");
        wprintf(L"Amount Used        Limit    Threshold\n");
        wprintf(L"------               ----------  ");
        wprintf(L"-----------        -----    ---------\n");

        // Enumerate through all of the quota users
        while(SUCCEEDED(hr) &&
              S_OK == lpEnumDiskQuotaUsers->
                        Next(1, &lpDiskQuotaUser, &dwUsersFetched))
        {
            if (SUCCEEDED(hr = lpDiskQuotaUser->
                    GetName(NULL, 0, szLogonName, MAX_PATH, NULL, 0))      &&
                SUCCEEDED(hr = lpDiskQuotaUser->
                    GetQuotaThresholdText(szQuotaThresholdText, MAX_PATH)) &&
                SUCCEEDED(hr = lpDiskQuotaUser->
                    GetQuotaLimitText(szQuotaLimitText, MAX_PATH))         &&
                SUCCEEDED(hr = lpDiskQuotaUser->
                    GetQuotaUsedText(szQuotaUsedText, MAX_PATH))           &&
                SUCCEEDED(hr = lpDiskQuotaUser->
                    GetQuotaInformation((LPVOID)&dqUserInfo,
                        sizeof(DISKQUOTA_USER_INFORMATION))))
            {
                szLogonName[MAX_PATH - 1] = L'\0'; // Make sure szLogonName is NULL terminated
                szQuotaUsedText[MAX_PATH - 1] = L'\0'; // Make sure szQuotaUsedText is NULL terminated
                szQuotaLimitText[MAX_PATH - 1] = L'\0'; // Make sure szQuotaLimitText is NULL terminated
                szQuotaThresholdText[MAX_PATH - 1] = L'\0'; // Make sure szQuotaThresholdText is NULL terminated

                // Check if the user is exceeding their threshold
                if ((dqUserInfo.QuotaUsed > dqUserInfo.QuotaThreshold) &&
                    (dqUserInfo.QuotaThreshold >= 0))
                {
                    wprintf(L"Warning ");
                }
                else
                {
                    wprintf(L"OK      ");
                }

                wprintf(L"%23s", szLogonName);
                wprintf(L"   %10s", szQuotaUsedText);
                wprintf(L"   %10s", szQuotaLimitText);
                wprintf(L"   %10s", szQuotaThresholdText);
                wprintf(L"\n");
            }
            else
            {
                szLogonName[MAX_PATH - 1] = L'\0'; // Make sure szLogonName is NULL terminated

                wprintf(L"Could not retrieve %s's quota information\n",
                         szLogonName);
            }
            lpDiskQuotaUser->Release();
        }
        lpEnumDiskQuotaUsers->Release();
    }
    else
    {
        PrintError(hr);
    }

    WaitForKeyPress();

    return SUCCEEDED(hr);
}
Exemplo n.º 11
0
int main()
{
	// Initialize timing
	SharedUtility::TimeInit();

	// Create the library instance
	g_pServerLibrary = new CLibrary();

	// Get the server core path
	String strPath("%s" SERVER_CORE_NAME DEBUG_SUFFIX LIBRARY_EXTENSION, SharedUtility::GetAppPath());

	// Load the server library
	if(!g_pServerLibrary->Load(strPath.C_String()))
	{
		printf("Failed to load server core!\n");
		WaitForKeyPress();
		return 1;
	}

	// Get the server core exports
	typedef CServerInterface * (* GetServerInterface_t)();
	typedef void (* DestroyServerInterface_t)(CServerInterface * pServer);
	GetServerInterface_t pfnGetServerInterface = 
		(GetServerInterface_t)g_pServerLibrary->GetProcedureAddress("GetServerInterface");
	DestroyServerInterface_t pfnDestroyServerInterface = 
		(DestroyServerInterface_t)g_pServerLibrary->GetProcedureAddress("DestroyServerInterface");

	// Create the server core instance
	g_pServer = pfnGetServerInterface();

	// Is the server core instance invalid?
	if(!g_pServer)
	{
		// Server instance invalid, exit
		printf("Server instance is invalid!\n");
		WaitForKeyPress();
		return 1;
	}

	// Call the server core OnLoad event
	if(!g_pServer->OnLoad())
	{
		// Server load failed, exit
		WaitForKeyPress();
		return 1;
	}

	// Register the close event handler
#ifdef WIN32
	SetConsoleCtrlHandler(CtrlHandler, TRUE);
#else
	void (* prev_fn)(int);
	prev_fn = signal(SIGINT, SignalHandler);
	if(prev_fn == SIG_IGN) signal(SIGINT, SIG_IGN);
	prev_fn = signal(SIGTERM, SignalHandler);
	if(prev_fn == SIG_IGN) signal(SIGTERM, SIG_IGN);
#endif

	// Start the input thread
	CThread inputThread;
	inputThread.SetUserData<bool>(true);
	inputThread.Start(InputThread);

	// Loop until the server IsActive returns false
	while(g_pServer->IsActive())
	{
		// Call the server core Process event
		g_pServer->Process();

		// Wait
		Sleep(TIMING_VALUE);
	}

	// Stop the input thread
	inputThread.SetUserData<bool>(false);
	inputThread.Stop(false);

	// Call the server core OnUnload event
	g_pServer->OnUnload();

	// Destroy the server instance
	pfnDestroyServerInterface(g_pServer);

	// Shutdown timing
	SharedUtility::TimeShutdown();
	return 0;
}