ReactOS 0.4.16-dev-197-g92996da
locale.c File Reference
#include "precomp.h"
Include dependency graph for locale.c:

Go to the source code of this file.

Functions

static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(PVOID *)
 
static PVOID LoadCodePageData (_In_ ULONG Code)
 
void SetupLocale (_In_ ULONG AnsiCode, _In_ ULONG OemCode, _In_ ULONG Unicode)
 

Variables

HANDLE hKernel32
 

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pWow64DisableWow64FsRedirection)
static

◆ LoadCodePageData()

static PVOID LoadCodePageData ( _In_ ULONG  Code)
static

Definition at line 15 of file locale.c.

16{
17 char filename[MAX_PATH], sysdir[MAX_PATH];
19 PVOID Data = NULL;
20 PVOID FsRedir;
21
22 if (!hKernel32)
23 {
24 hKernel32 = GetModuleHandleA("kernel32.dll");
25
26 pWow64DisableWow64FsRedirection = (void*)GetProcAddress(hKernel32, "Wow64DisableWow64FsRedirection");
27 pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hKernel32, "Wow64RevertWow64FsRedirection");
28 }
29
30 if (pWow64DisableWow64FsRedirection)
31 pWow64DisableWow64FsRedirection(&FsRedir);
32
34
35 if (Code != -1)
36 StringCbPrintfA(filename, sizeof(filename), "%s\\c_%lu.nls", sysdir, Code);
37 else
38 StringCbPrintfA(filename, sizeof(filename), "%s\\l_intl.nls", sysdir);
39
41 ok(hFile != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", filename, (UINT)GetLastError());
43 {
44 DWORD dwRead;
47 ReadFile(hFile, Data, dwFileSize, &dwRead, NULL);
49 }
50
51 if (pWow64RevertWow64FsRedirection)
52 pWow64RevertWow64FsRedirection(FsRedir);
53
54 return Data;
55}
#define ok(value,...)
Definition: atltest.h:57
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
unsigned long DWORD
Definition: ntddk_ex.h:95
const char * filename
Definition: ioapi.h:137
HANDLE hKernel32
Definition: locale.c:13
DWORD dwFileSize
Definition: more.c:40
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
STRSAFEAPI StringCbPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:547
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1701
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFile
Definition: winbase.h:3773

Referenced by SetupLocale().

◆ SetupLocale()

void SetupLocale ( _In_ ULONG  AnsiCode,
_In_ ULONG  OemCode,
_In_ ULONG  Unicode 
)

Definition at line 58 of file locale.c.

62{
63 NLSTABLEINFO NlsTable;
64 PVOID AnsiCodePageData;
65 PVOID OemCodePageData;
66 PVOID UnicodeCaseTableData;
67
68 AnsiCodePageData = LoadCodePageData(AnsiCode);
69 OemCodePageData = LoadCodePageData(OemCode);
70 UnicodeCaseTableData = LoadCodePageData(Unicode);
71
72 RtlInitNlsTables(AnsiCodePageData, OemCodePageData, UnicodeCaseTableData, &NlsTable);
73 RtlResetRtlTranslations(&NlsTable);
74 /*
75 * Do NOT free the buffers here, they are directly used!
76 * Yes, we leak the old buffers, but this is a test anyway...
77 */
78}
static PVOID LoadCodePageData(_In_ ULONG Code)
Definition: locale.c:15
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)

Variable Documentation

◆ hKernel32