Commit 0a66633c authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

kernel32: Simplify and optimize create_(system,env)_registry_keys().

parent 24eb38bd
......@@ -132,7 +132,7 @@ static void create_system_registry_keys( const SYSTEM_INFO *info )
if (NtCreateKey( &system_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) return;
RtlInitUnicodeString( &valueW, IdentifierW );
NtSetValueKey( system_key, &valueW, 0, REG_SZ, SysidW, (strlenW(SysidW)+1) * sizeof(WCHAR) );
NtSetValueKey( system_key, &valueW, 0, REG_SZ, SysidW, sizeof(SysidW) );
attr.RootDirectory = system_key;
RtlInitUnicodeString( &nameW, fpuW );
......@@ -151,6 +151,7 @@ static void create_system_registry_keys( const SYSTEM_INFO *info )
if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ))
{
WCHAR idW[60];
DWORD sizeW;
DWORD cpuMHz = cpuHz / 1000000;
/*TODO: report 64bit processors properly*/
......@@ -158,12 +159,12 @@ static void create_system_registry_keys( const SYSTEM_INFO *info )
sprintf( id, "x86 Family %d Model %d Stepping %d",
info->wProcessorLevel, HIBYTE(info->wProcessorRevision), LOBYTE(info->wProcessorRevision) );
RtlMultiByteToUnicodeN( idW, sizeof(idW), NULL, id, strlen(id)+1 );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, idW, (strlenW(idW)+1)*sizeof(WCHAR) );
RtlMultiByteToUnicodeN( idW, sizeof(idW), &sizeW, id, strlen(id)+1 );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, idW, sizeW );
/*TODO; report amd's properly*/
RtlInitUnicodeString( &valueW, VendorIdentifierW );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, VenidIntelW, (strlenW(VenidIntelW)+1) * sizeof(WCHAR) );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, VenidIntelW, sizeof(VenidIntelW) );
RtlInitUnicodeString( &valueW, mhzKeyW );
NtSetValueKey( hkey, &valueW, 0, REG_DWORD, &cpuMHz, sizeof(DWORD) );
......@@ -194,6 +195,7 @@ static void create_env_registry_keys( const SYSTEM_INFO *info )
HANDLE env_key;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW, valueW;
DWORD sizeW;
char nProc[10],id[60],procLevel[10],rev[10];
WCHAR nProcW[10],idW[60],procLevelW[10],revW[10];
......@@ -214,31 +216,31 @@ static void create_env_registry_keys( const SYSTEM_INFO *info )
if (NtCreateKey( &env_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) return;
sprintf( nProc, "%d", info->dwNumberOfProcessors );
RtlMultiByteToUnicodeN( nProcW, sizeof(nProcW), NULL, nProc, strlen(nProc)+1 );
RtlMultiByteToUnicodeN( nProcW, sizeof(nProcW), &sizeW, nProc, strlen(nProc)+1 );
RtlInitUnicodeString( &valueW, NumProcW );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, nProcW, (strlenW(nProcW)+1)*sizeof(WCHAR) );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, nProcW, sizeW );
/* TODO: currently hardcoded x86, add different processors */
RtlInitUnicodeString( &valueW, ProcArchW );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, x86W, (strlenW(x86W)+1) * sizeof(WCHAR) );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, x86W, sizeof(x86W) );
/* TODO: currently hardcoded Intel, add different processors */
sprintf( id, "x86 Family %d Model %d Stepping %d, GenuineIntel",
info->wProcessorLevel, HIBYTE(info->wProcessorRevision), LOBYTE(info->wProcessorRevision) );
RtlMultiByteToUnicodeN( idW, sizeof(idW), NULL, id, strlen(id)+1 );
RtlMultiByteToUnicodeN( idW, sizeof(idW), &sizeW, id, strlen(id)+1 );
RtlInitUnicodeString( &valueW, ProcIdW );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, idW, (strlenW(idW)+1)*sizeof(WCHAR) );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, idW, sizeW );
sprintf( procLevel, "%d", info->wProcessorLevel );
RtlMultiByteToUnicodeN( procLevelW, sizeof(procLevelW), NULL, procLevel, strlen(procLevel)+1 );
RtlMultiByteToUnicodeN( procLevelW, sizeof(procLevelW), &sizeW, procLevel, strlen(procLevel)+1 );
RtlInitUnicodeString( &valueW, ProcLvlW );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, procLevelW, (strlenW(procLevelW)+1)*sizeof(WCHAR) );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, procLevelW, sizeW );
/* Properly report model/stepping */
sprintf( rev, "%04x", info->wProcessorRevision);
RtlMultiByteToUnicodeN( revW, sizeof(revW), NULL, rev, strlen(rev)+1 );
RtlMultiByteToUnicodeN( revW, sizeof(revW), &sizeW, rev, strlen(rev)+1 );
RtlInitUnicodeString( &valueW, ProcRevW );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, revW, (strlenW(revW)+1)*sizeof(WCHAR) );
NtSetValueKey( env_key, &valueW, 0, REG_SZ, revW, sizeW );
NtClose( env_key );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment