Beispiel #1
0
BOOL GetDriverSpecs( struct display_t *pEntry, char *szSubKey )
{
	HKEY hKey, hKey2;
	char *p;
	char szTemp[ MAX_PATH + 1 ] = "", szTemp2[ MAX_PATH + 1 ] = "";

	hKey = MyRegOpenKey( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\Class" );
	if( hKey )
		hKey2 = MyRegOpenKey( hKey, szSubKey );
	else
		return FALSE;

	RegCloseKey( hKey );
	if( !hKey2 )
		return FALSE;

	if( !(p = MyRegQueryValueMalloc( hKey2, "DriverDesc", NULL, NULL ) ) )
		return FALSE;
	strcpy( pEntry->szName, p );
	free( p );

	hKey = MyRegOpenKey( hKey2, "DEFAULT" );
	if( !hKey )
		return FALSE;

	if( !(p = MyRegQueryValueMalloc( hKey, "drv", NULL, NULL ) ) )
		return FALSE;
	strcpy( pEntry->szDriver, p );

	// if no drive is specified in the driver filename, assume a path relative to the windows
	// system directory
	if( !strchr( p, ':' ) )
	{
		GetSystemDirectory( szTemp, MAX_PATH );
		strcat( szTemp, "\\" );
		strcat( szTemp, p );
	}
	else
		strcpy( szTemp, p );

	free( p );

	if( !GetMyFileVersionInfo( szTemp, pEntry ) )
		return FALSE;

	if( strlen( szTemp ) )
		SetCurrentDirectory( szTemp );

	RegCloseKey( hKey );
	RegCloseKey( hKey2 );

	return TRUE;
}
Beispiel #2
0
char *MyRegQuickQueryMalloc( HKEY hKey, LPCSTR szSubKey, LPCSTR szValueName, LPDWORD pType, LPDWORD pSize )
{
	HKEY hNew;
	char *pData;

	if( !(hNew = MyRegOpenKey( hKey, szSubKey)) )
		return NULL;

	pData = MyRegQueryValueMalloc( hNew, szValueName, pType, pSize );

	RegCloseKey( hNew );
	return pData;
}
Beispiel #3
0
DWORD WINAPI GetDisplayProfileData( struct display_t *pDispEntry, DWORD nMaxInt )
{
	HKEY hKey;
	DWORD nFound = 0, i;

	for( i = 0; i < nMaxInt; i++ )
		ClearEntry( pDispEntry + i );

	hKey = MyRegOpenKey( HKEY_LOCAL_MACHINE, "Enum" );
	nFound = SearchAllSubkeysForDisplays( hKey, pDispEntry, nMaxInt, 0 );
	if( hKey )
		RegCloseKey( hKey );

	return nFound;
}
Beispiel #4
0
DWORD SearchAllSubkeysForDisplays( HKEY hKey, struct display_t *pDispEntry, DWORD nMaxInt, DWORD nFound )
{
	DWORD index = 0;
	HKEY hSubKey;
	char *name = NULL;
	char *data = NULL;

	if( !hKey )
		return nFound;

	if( !(nFound < nMaxInt) )
		return nFound;

	while( name = MyRegEnumKeyMalloc( hKey, index ) )
	{
		nFound = SearchAllSubkeysForDisplays( hSubKey = MyRegOpenKey( hKey, name ), pDispEntry, nMaxInt, nFound );
		if( hSubKey )
			data = MyRegQueryValueMalloc( hSubKey, "Class", NULL, NULL );
		if( data )
		{
			if( strnicmp( data, "Display", 8 ) == 0 )
			{
				free( data );
				data = MyRegQueryValueMalloc( hSubKey, "Driver", NULL, NULL );
				if( data )
				{
					if( nFound < nMaxInt )
					{
						if( GetDriverSpecs( (pDispEntry + nFound), data ) )
							nFound++;
						else
							ClearEntry( pDispEntry + nFound );
					}
					free( data );
				}
			}
		}
		if( hSubKey )
			RegCloseKey( hSubKey );
		free( name );
		index++;
	}

	return nFound;
}
Beispiel #5
0
VOID
LinkGetRegistryValues(
    LPWSTR ConsoleTitle,
    LPLNKPROPNTCONSOLE lpCon
    )

/*++

Routine Description:

    This routine reads in values from the registry and places them
    in the supplied structure.

Arguments:

    pStateInfo - optional pointer to structure to receive information

Return Value:

    current page number

--*/

{
    HKEY hCurrentUserKey;
    HKEY hConsoleKey;
    HKEY hTitleKey;
    NTSTATUS Status;
    LPWSTR TranslatedTitle;
    DWORD dwValue;
    DWORD i;
    WCHAR awchFaceName[LF_FACESIZE];
    WCHAR awchBuffer[ 16 ];

    //
    // Impersonate the client process
    //

    if (!CsrImpersonateClient(NULL)) {
        KdPrint(("CONSRV: GetRegistryValues Impersonate failed\n"));
        return;
    }

    //
    // Open the current user registry key
    //

    Status = RtlOpenCurrentUser(MAXIMUM_ALLOWED, &hCurrentUserKey);
    if (!NT_SUCCESS(Status)) {
        CsrRevertToSelf();
        return;
    }

    //
    // Open the console registry key
    //

    Status = MyRegOpenKey(hCurrentUserKey,
                          CONSOLE_REGISTRY_STRING,
                          &hConsoleKey);
    if (!NT_SUCCESS(Status)) {
        NtClose(hCurrentUserKey);
        CsrRevertToSelf();
        return;
    }

    //
    // If there is no structure to fill out, just bail out
    //

    if (!lpCon)
        goto CloseKeys;

    //
    // Open the console title subkey, if there is one
    //

    if (ConsoleTitle && (*ConsoleTitle != L'\0'))
    {
        TranslatedTitle = TranslateConsoleTitle(ConsoleTitle);
        if (TranslatedTitle == NULL)
            goto GetDefaultConsole;
        Status = MyRegOpenKey( hConsoleKey,
                               TranslatedTitle,
                               &hTitleKey);
        HeapFree(pConHeap,0,TranslatedTitle);
        if (!NT_SUCCESS(Status))
            goto GetDefaultConsole;
    } else {

GetDefaultConsole:

        hTitleKey = hConsoleKey;
    }

    //
    // Initial screen fill
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FILLATTR,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->wFillAttribute = (WORD)dwValue;
    }

    //
    // Initial popup fill
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_POPUPATTR,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->wPopupFillAttribute = (WORD)dwValue;
    }

    //
    // Initial insert mode
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_INSERTMODE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->bInsertMode = !!dwValue;
    }

    //
    // Initial quick edit mode
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_QUICKEDIT,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->bQuickEdit = !!dwValue;
    }

#ifdef _X86_
    //
    // Initial full screen mode
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FULLSCR,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->bFullScreen = !!dwValue;
    }
#endif

    //
    // Initial screen buffer size
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_BUFFERSIZE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->dwScreenBufferSize.X = LOWORD(dwValue);
        lpCon->dwScreenBufferSize.Y = HIWORD(dwValue);
    }

    //
    // Initial window size
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_WINDOWSIZE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->dwWindowSize.X = LOWORD(dwValue);
        lpCon->dwWindowSize.Y = HIWORD(dwValue);
    }

    //
    // Initial window position
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_WINDOWPOS,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->dwWindowOrigin.X = (SHORT)LOWORD(dwValue);
        lpCon->dwWindowOrigin.Y = (SHORT)HIWORD(dwValue);
        lpCon->bAutoPosition = FALSE;
    }

    //
    // Initial font size
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FONTSIZE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->dwFontSize.X = LOWORD(dwValue);
        lpCon->dwFontSize.Y = HIWORD(dwValue);
    }

    //
    // Initial font family
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FONTFAMILY,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->uFontFamily = dwValue;
    }

    //
    // Initial font weight
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FONTWEIGHT,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->uFontWeight = dwValue;
    }

    //
    // Initial font face name
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_FACENAME,
                       sizeof(awchFaceName), (PBYTE)awchFaceName))) {
        RtlCopyMemory(lpCon->FaceName, awchFaceName, sizeof(awchFaceName));
    }

    //
    // Initial cursor size
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_CURSORSIZE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->uCursorSize = dwValue;
    }

    //
    // Initial history buffer size
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_HISTORYSIZE,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->uHistoryBufferSize = dwValue;
    }

    //
    // Initial number of history buffers
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_HISTORYBUFS,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->uNumberOfHistoryBuffers = dwValue;
    }

    //
    // Initial history duplication mode
    //

    if (NT_SUCCESS(MyRegQueryValue(hTitleKey,
                       CONSOLE_REGISTRY_HISTORYNODUP,
                       sizeof(dwValue), (PBYTE)&dwValue))) {
        lpCon->bHistoryNoDup = dwValue;
    }

    //
    // Initial color table
    //

    for (i=0; i<16; i++) {
        wsprintf(awchBuffer, CONSOLE_REGISTRY_COLORTABLE, i);
        if (NT_SUCCESS(MyRegQueryValue(hTitleKey, awchBuffer,
                           sizeof(dwValue), (PBYTE)&dwValue))) {
            lpCon->ColorTable[i] = dwValue;
        }
    }

    //
    // Close the registry keys
    //

    if (hTitleKey != hConsoleKey) {
        NtClose(hTitleKey);
    }

CloseKeys:
    NtClose(hConsoleKey);
    NtClose(hCurrentUserKey);
    CsrRevertToSelf();

}