From 25006dfe3020228c6bf3af12075fd52519135498 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 20 Apr 2013 18:54:27 +0000 Subject: [PATCH] [SAMSRV] - Add string resources for SAM object names and comments. - Use the string resources in the setup code. svn path=/trunk/; revision=58792 --- reactos/dll/win32/samsrv/lang/de-DE.rc | 24 +++++ reactos/dll/win32/samsrv/lang/en-US.rc | 24 +++++ reactos/dll/win32/samsrv/samsrv.h | 3 + reactos/dll/win32/samsrv/samsrv.rc | 23 +++++ reactos/dll/win32/samsrv/setup.c | 119 +++++++++++++++++++++---- 5 files changed, 177 insertions(+), 16 deletions(-) create mode 100644 reactos/dll/win32/samsrv/lang/de-DE.rc create mode 100644 reactos/dll/win32/samsrv/lang/en-US.rc diff --git a/reactos/dll/win32/samsrv/lang/de-DE.rc b/reactos/dll/win32/samsrv/lang/de-DE.rc new file mode 100644 index 00000000000..f88c273a930 --- /dev/null +++ b/reactos/dll/win32/samsrv/lang/de-DE.rc @@ -0,0 +1,24 @@ +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_DOMAIN_BUILTIN_NAME "Builtin" + + IDS_ALIAS_ADMINISTRATORS_NAME "Administratoren" + IDS_ALIAS_ADMINISTRATORS_COMMENT "Administratoren haben unbeschränkten Zugriff auf den Computer oder die Domäne." + + IDS_ALIAS_GUESTS_NAME "Gäste" + IDS_ALIAS_GUESTS_COMMENT "Gäste besitzen standadmäßig die selben Rechte wie die Mitglieder der Benutzer-Gruppe." + + IDS_ALIAS_POWER_USERS_NAME "Hauptbenutzer" + IDS_ALIAS_POWER_USERS_COMMENT "Hauptbenutzer besitzen die meisten Rechte mit einigen Einschränkungen." + + IDS_ALIAS_USERS_NAME "Benutzer" + IDS_ALIAS_USERS_COMMENT "Benutzer können keine Änderungen am System vornehmen." + + IDS_USER_ADMINISTRATOR_NAME "Administrator" + IDS_USER_ADMINISTRATOR_COMMENT "Vordefiniertes Konto für die Verwaltung des Comuters oder der Domäne." + + IDS_USER_GUEST_NAME "Gast" + IDS_USER_GUEST_COMMENT "Vordefiniertes Konto für Gastzugriff auf den Computer oder die Domäne." +END diff --git a/reactos/dll/win32/samsrv/lang/en-US.rc b/reactos/dll/win32/samsrv/lang/en-US.rc new file mode 100644 index 00000000000..8728978a63b --- /dev/null +++ b/reactos/dll/win32/samsrv/lang/en-US.rc @@ -0,0 +1,24 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE +BEGIN + IDS_DOMAIN_BUILTIN_NAME "Builtin" + + IDS_ALIAS_ADMINISTRATORS_NAME "Administrators" + IDS_ALIAS_ADMINISTRATORS_COMMENT "Administrators have unrestricted access to the computer or domain." + + IDS_ALIAS_GUESTS_NAME "Guests" + IDS_ALIAS_GUESTS_COMMENT "Guests have the same rights a members of the Users group by default." + + IDS_ALIAS_POWER_USERS_NAME "Power Users" + IDS_ALIAS_POWER_USERS_COMMENT "Power Users have most administrative rights with some restrictions." + + IDS_ALIAS_USERS_NAME "Users" + IDS_ALIAS_USERS_COMMENT "Users are prevented from making system-wide changes." + + IDS_USER_ADMINISTRATOR_NAME "Administrator" + IDS_USER_ADMINISTRATOR_COMMENT "Built-in account used to administate the computer or domain." + + IDS_USER_GUEST_NAME "Guest" + IDS_USER_GUEST_COMMENT "Built-in account for guest access to the computer or domain." +END diff --git a/reactos/dll/win32/samsrv/samsrv.h b/reactos/dll/win32/samsrv/samsrv.h index 8a5255859bb..f774440c561 100644 --- a/reactos/dll/win32/samsrv/samsrv.h +++ b/reactos/dll/win32/samsrv/samsrv.h @@ -15,6 +15,7 @@ #include #include #include +#include #define NTOS_MODE_USER #include #include @@ -30,6 +31,8 @@ #include +#include "resources.h" + typedef enum _SAM_DB_OBJECT_TYPE { SamDbIgnoreObject, diff --git a/reactos/dll/win32/samsrv/samsrv.rc b/reactos/dll/win32/samsrv/samsrv.rc index eba129e3fea..c7bdda53bb6 100644 --- a/reactos/dll/win32/samsrv/samsrv.rc +++ b/reactos/dll/win32/samsrv/samsrv.rc @@ -1,5 +1,28 @@ +#include +#include "resources.h" + #define REACTOS_VERSION_DLL #define REACTOS_STR_FILE_DESCRIPTION "SAM server DLL\0" #define REACTOS_STR_INTERNAL_NAME "samsrv\0" #define REACTOS_STR_ORIGINAL_FILENAME "samsrv.dll\0" +#define REACTOS_FILEVERSION 5,1,2600,0 +#define REACTOS_STR_FILE_VERSION "5.1.2600\0" #include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +/* + * Everything specific to any language goes in one of the specific + * files. Note that you can and may override resources which also have + * a neutral version. This is to get localized bitmaps for example. + */ + +/* UTF-8 */ +#pragma code_page(65001) +#ifdef LANGUAGE_DE_DE + #include "lang/de-DE.rc" +#endif +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif + diff --git a/reactos/dll/win32/samsrv/setup.c b/reactos/dll/win32/samsrv/setup.c index 61eb078fd6c..cec4aead8f5 100644 --- a/reactos/dll/win32/samsrv/setup.c +++ b/reactos/dll/win32/samsrv/setup.c @@ -23,6 +23,53 @@ SID_IDENTIFIER_AUTHORITY SecurityNtAuthority = {SECURITY_NT_AUTHORITY}; /* FUNCTIONS ***************************************************************/ +static INT +SampLoadString(HINSTANCE hInstance, + UINT uId, + LPWSTR lpBuffer, + INT nBufferMax) +{ + HGLOBAL hmem; + HRSRC hrsrc; + WCHAR *p; + int string_num; + int i; + + /* Use loword (incremented by 1) as resourceid */ + hrsrc = FindResourceW(hInstance, + MAKEINTRESOURCEW((LOWORD(uId) >> 4) + 1), + (LPWSTR)RT_STRING); + if (!hrsrc) + return 0; + + hmem = LoadResource(hInstance, hrsrc); + if (!hmem) + return 0; + + p = LockResource(hmem); + string_num = uId & 0x000f; + for (i = 0; i < string_num; i++) + p += *p + 1; + + i = min(nBufferMax - 1, *p); + if (i > 0) + { + memcpy(lpBuffer, p + 1, i * sizeof(WCHAR)); + lpBuffer[i] = 0; + } + else + { + if (nBufferMax > 1) + { + lpBuffer[0] = 0; + return 0; + } + } + + return i; +} + + BOOL SampIsSetupRunning(VOID) { @@ -222,9 +269,22 @@ SampCreateAliasAccount(HKEY hDomainKey, } +#if 0 +static BOOL +SampCreateGroupAccount(HKEY hDomainKey, + LPCWSTR lpAccountName, + ULONG ulRelativeId) +{ + + return FALSE; +} +#endif + + static BOOL SampCreateUserAccount(HKEY hDomainKey, LPCWSTR lpAccountName, + LPCWSTR lpComment, ULONG ulRelativeId, ULONG UserAccountControl) { @@ -320,8 +380,8 @@ SampCreateUserAccount(HKEY hDomainKey, L"AdminComment", 0, REG_SZ, - (LPVOID)lpEmptyString, - sizeof(WCHAR)); + (LPVOID)lpComment, + (wcslen(lpComment) + 1) * sizeof(WCHAR)); RegSetValueEx(hAccountKey, L"UserComment", @@ -344,7 +404,7 @@ SampCreateUserAccount(HKEY hDomainKey, (LPVOID)lpEmptyString, sizeof(WCHAR)); - /* Set LogonHours attribute */ + /* Set LogonHours attribute*/ *((PUSHORT)LogonHours) = 168; memset(&(LogonHours[2]), 0xff, 21); @@ -630,10 +690,15 @@ SampInitializeSAM(VOID) PSID pBuiltinSid = NULL; BOOL bResult = TRUE; PSID pSid; + HINSTANCE hInstance; + WCHAR szComment[256]; + WCHAR szName[80]; NTSTATUS Status; TRACE("SampInitializeSAM() called\n"); + hInstance = GetModuleHandleW(L"samsrv.dll"); + if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SAM\\SAM", 0, @@ -687,31 +752,45 @@ SampInitializeSAM(VOID) goto done; } + SampLoadString(hInstance, IDS_DOMAIN_BUILTIN_NAME, szName, 80); + /* Create the Builtin domain */ if (SampCreateDomain(hDomainsKey, L"Builtin", - L"Builtin", + szName, //L"Builtin", // SampGetResourceString(hInstance, IDS_DOMAIN_BUILTIN_NAME), pBuiltinSid, &hDomainKey)) { + SampLoadString(hInstance, IDS_ALIAS_ADMINISTRATORS_NAME, szName, 80); + SampLoadString(hInstance, IDS_ALIAS_ADMINISTRATORS_COMMENT, szComment, 256); + SampCreateAliasAccount(hDomainKey, - L"Administrators", - L"Testabc1234567890", + szName, + szComment, DOMAIN_ALIAS_RID_ADMINS); + SampLoadString(hInstance, IDS_ALIAS_USERS_NAME, szName, 80); + SampLoadString(hInstance, IDS_ALIAS_USERS_COMMENT, szComment, 256); + SampCreateAliasAccount(hDomainKey, - L"Users", - L"Users Group", + szName, + szComment, DOMAIN_ALIAS_RID_USERS); - SampCreateAliasAccount(hDomainKey, - L"Guests", - L"Guests Group", - DOMAIN_ALIAS_RID_GUESTS); + SampLoadString(hInstance, IDS_ALIAS_GUESTS_NAME, szName, 80); + SampLoadString(hInstance, IDS_ALIAS_GUESTS_COMMENT, szComment, 256); SampCreateAliasAccount(hDomainKey, - L"Power Users", - L"Power Users Group", + szName, + szComment, + DOMAIN_ALIAS_RID_GUESTS); + + SampLoadString(hInstance, IDS_ALIAS_POWER_USERS_NAME, szName, 80); + SampLoadString(hInstance, IDS_ALIAS_POWER_USERS_COMMENT, szComment, 256); + + SampCreateAliasAccount(hDomainKey, + szName, + szComment, DOMAIN_ALIAS_RID_POWER_USERS); @@ -737,13 +816,21 @@ SampInitializeSAM(VOID) AccountDomainInfo->DomainSid, &hDomainKey)) { + SampLoadString(hInstance, IDS_USER_ADMINISTRATOR_NAME, szName, 80); + SampLoadString(hInstance, IDS_USER_ADMINISTRATOR_COMMENT, szComment, 256); + SampCreateUserAccount(hDomainKey, - L"Administrator", + szName, + szComment, DOMAIN_USER_RID_ADMIN, USER_DONT_EXPIRE_PASSWORD | USER_NORMAL_ACCOUNT); + SampLoadString(hInstance, IDS_USER_GUEST_NAME, szName, 80); + SampLoadString(hInstance, IDS_USER_GUEST_COMMENT, szComment, 256); + SampCreateUserAccount(hDomainKey, - L"Guest", + szName, + szComment, DOMAIN_USER_RID_GUEST, USER_ACCOUNT_DISABLED | USER_DONT_EXPIRE_PASSWORD | USER_NORMAL_ACCOUNT);