ReactOS 0.4.17-dev-304-g69474b3
DllMain.c File Reference
#include <windows.h>
Include dependency graph for DllMain.c:

Go to the source code of this file.

Functions

void init_locale (HMODULE module)
 
static void InitSystemDir (void)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

char system_dir [MAX_PATH]
 

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 16 of file DllMain.c.

17{
18 switch (fdwReason)
19 {
22 //init_locale(hinstDLL);
23 break;
24
26 break;
27
29 break;
30
32 break;
33 }
34
35 return TRUE;
36}
static DWORD const fdwReason
#define TRUE
Definition: types.h:120
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define DLL_THREAD_ATTACH
Definition: compat.h:132
static void InitSystemDir(void)
Definition: DllMain.c:11

◆ init_locale()

void init_locale ( HMODULE  module)

Definition at line 1913 of file locale.c.

1914{
1915 USHORT utf8[2] = { 0, CP_UTF8 };
1916 USHORT *ansi_ptr, *oem_ptr;
1919 const WCHAR *user_locale_name;
1920 DWORD count;
1921 SIZE_T size;
1922 HKEY hkey;
1923
1927
1930
1932 if (!(user_locale = NlsValidateLocale( &user_lcid, 0 )))
1933 {
1934 if (GetEnvironmentVariableW( L"WINEUSERLOCALE", bufferW, ARRAY_SIZE(bufferW) ))
1937 }
1938 user_lcid = user_locale->ilanguage;
1940
1941 if (GetEnvironmentVariableW( L"WINEUNIXCP", bufferW, ARRAY_SIZE(bufferW) ))
1942 unix_cp = wcstoul( bufferW, NULL, 10 );
1943
1945
1946 ansi_ptr = NtCurrentTeb()->Peb->AnsiCodePageData ? NtCurrentTeb()->Peb->AnsiCodePageData : utf8;
1947 oem_ptr = NtCurrentTeb()->Peb->OemCodePageData ? NtCurrentTeb()->Peb->OemCodePageData : utf8;
1948 RtlInitCodePageTable( ansi_ptr, &ansi_cpinfo );
1949 RtlInitCodePageTable( oem_ptr, &oem_cpinfo );
1950
1951 RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Nls",
1953 RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1955 RegCreateKeyExW( HKEY_CURRENT_USER, L"Control Panel\\International",
1957
1959
1961 !RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\TimeZoneInformation",
1963 {
1964 RegSetValueExW( hkey, L"StandardName", 0, REG_SZ, (BYTE *)timezone.StandardName,
1965 (lstrlenW(timezone.StandardName) + 1) * sizeof(WCHAR) );
1966 RegSetValueExW( hkey, L"TimeZoneKeyName", 0, REG_SZ, (BYTE *)timezone.TimeZoneKeyName,
1967 (lstrlenW(timezone.TimeZoneKeyName) + 1) * sizeof(WCHAR) );
1968 RegCloseKey( hkey );
1969 }
1970
1971 /* Update registry contents if the user locale has changed.
1972 * This simulates the action of the Windows control panel. */
1973
1974 user_locale_name = locale_strings + user_locale->sname + 1;
1975 count = sizeof(bufferW);
1976 if (!RegQueryValueExW( intl_key, L"LocaleName", NULL, NULL, (BYTE *)bufferW, &count ))
1977 {
1978 if (!wcscmp( bufferW, user_locale_name )) return; /* unchanged */
1979 TRACE( "updating registry, locale changed %s -> %s\n",
1980 debugstr_w(bufferW), debugstr_w(user_locale_name) );
1981 }
1982 else TRACE( "updating registry, locale changed none -> %s\n", debugstr_w(user_locale_name) );
1983
1985
1986 if (!RegCreateKeyExW( nls_key, L"Codepage",
1988 {
1989 count = swprintf( bufferW, ARRAY_SIZE(bufferW), L"%03d", GetACP() );
1990 RegSetValueExW( hkey, L"ACP", 0, REG_SZ, (BYTE *)bufferW, (count + 1) * sizeof(WCHAR) );
1991 count = swprintf( bufferW, ARRAY_SIZE(bufferW), L"%03d", GetOEMCP() );
1992 RegSetValueExW( hkey, L"OEMCP", 0, REG_SZ, (BYTE *)bufferW, (count + 1) * sizeof(WCHAR) );
1993 count = swprintf( bufferW, ARRAY_SIZE(bufferW), L"%03d", system_locale->idefaultmaccodepage );
1994 RegSetValueExW( hkey, L"MACCP", 0, REG_SZ, (BYTE *)bufferW, (count + 1) * sizeof(WCHAR) );
1995 RegCloseKey( hkey );
1996 }
1997}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define lstrlenW
Definition: compat.h:750
#define LOCALE_NAME_USER_DEFAULT
Definition: locale.c:43
static HKEY tz_key
Definition: locale.c:312
static LCID system_lcid
Definition: locale.c:308
static void load_locale_nls(void)
Definition: locale.c:439
static HMODULE kernelbase_handle
Definition: locale.c:47
UINT WINAPI GetACP(void)
Definition: locale.c:5550
static CPTABLEINFO ansi_cpinfo
Definition: locale.c:305
static HKEY intl_key
Definition: locale.c:310
DWORD WINAPI DECLSPEC_HOTPATCH GetDynamicTimeZoneInformation(DYNAMIC_TIME_ZONE_INFORMATION *info)
Definition: locale.c:5669
static void load_sortdefault_nls(void)
Definition: locale.c:481
static const struct sortguid * get_language_sort(const WCHAR *name)
Definition: locale.c:664
const NLS_LOCALE_DATA *WINAPI NlsValidateLocale(LCID *lcid, ULONG flags)
Definition: locale.c:725
static const NLS_LOCALE_DATA * get_locale_by_name(const WCHAR *name, LCID *lcid)
Definition: locale.c:644
static const struct sortguid * current_locale_sort
Definition: locale.c:410
static HKEY nls_key
Definition: locale.c:311
static UINT unix_cp
Definition: locale.c:307
static const WCHAR * locale_strings
Definition: locale.c:316
static void update_locale_registry(void)
Definition: locale.c:1855
static const NLS_LOCALE_DATA * system_locale
Definition: locale.c:317
static CPTABLEINFO oem_cpinfo
Definition: locale.c:306
UINT WINAPI GetOEMCP(void)
Definition: locale.c:6157
static struct norm_table * norm_info
Definition: locale.c:323
static LCID user_lcid
Definition: locale.c:309
static const NLS_LOCALE_DATA * user_locale
Definition: locale.c:318
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define NtCurrentTeb
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define LOCALE_NAME_MAX_LENGTH
#define LOCALE_CUSTOM_UNSPECIFIED
#define LOCALE_CUSTOM_DEFAULT
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
Definition: locale.c:392
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define CP_UTF8
Definition: nls.h:20
#define TRACE(s)
Definition: solgame.cpp:4
Definition: fake.h:14
#define TIME_ZONE_ID_INVALID
Definition: timezoneapi.h:21
ULONG_PTR SIZE_T
Definition: typedefs.h:80
NTSYSAPI void WINAPI RtlInitCodePageTable(USHORT *, CPTABLEINFO *)
NTSYSAPI NTSTATUS WINAPI NtGetNlsSectionPtr(ULONG, ULONG, void *, void **, SIZE_T *)
@ NormalizationC
Definition: winnls.h:737
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DllMain().

◆ InitSystemDir()

static void InitSystemDir ( void  )
static

Definition at line 11 of file DllMain.c.

12{
14}
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2202
char system_dir[MAX_PATH]
Definition: DllMain.c:7

Referenced by DllMain().

Variable Documentation

◆ system_dir