ReactOS  0.4.15-dev-2947-g59e1b78
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];
18  HANDLE hFile;
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 CloseHandle
Definition: compat.h:598
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
DWORD dwFileSize
Definition: more.c:40
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE hKernel32
Definition: locale.c:13
#define OPEN_EXISTING
Definition: compat.h:634
STRSAFEAPI StringCbPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:547
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1697
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:612
#define malloc
Definition: debug_ros.c:4

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 }
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
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)

Variable Documentation

◆ hKernel32