Author: dchapyshev
Date: Mon Nov 3 05:27:17 2008
New Revision: 37164
URL:
http://svn.reactos.org/svn/reactos?rev=37164&view=rev
Log:
- Implement GetCPInfoExA/W (not fully)
- Move CODEPAGE_ENTRY struct to header file
- Small fix HeapWalk
Modified:
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/dll/win32/kernel32/mem/heap.c
trunk/reactos/dll/win32/kernel32/misc/lang.c
trunk/reactos/dll/win32/kernel32/misc/nls.c
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Mon Nov 3 05:27:17
2008
@@ -37,6 +37,15 @@
#define SetLastErrorByStatus(__S__) \
((void)SetLastError(RtlNtStatusToDosError(__S__)))
+
+typedef struct _CODEPAGE_ENTRY
+{
+ LIST_ENTRY Entry;
+ UINT CodePage;
+ HANDLE SectionHandle;
+ PBYTE SectionMapping;
+ CPTABLEINFO CodePageTable;
+} CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
typedef
DWORD
@@ -171,5 +180,8 @@
OUT PHANDLE hSection,
IN PUNICODE_STRING ApplicationName);
+PCODEPAGE_ENTRY FASTCALL
+IntGetCodePageEntry(UINT CodePage);
+
#endif /* ndef _KERNEL32_INCLUDE_KERNEL32_H */
Modified: trunk/reactos/dll/win32/kernel32/mem/heap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/hea…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/heap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/mem/heap.c [iso-8859-1] Mon Nov 3 05:27:17 2008
@@ -262,10 +262,13 @@
Status = RtlWalkHeap(hHeap, lpEntry);
- if (Status)
+ if (!NT_SUCCESS(Status))
+ {
SetLastError(RtlNtStatusToDosError(Status));
-
- return !Status;
+ return FALSE;
+ }
+
+ return TRUE;
}
/* EOF */
Modified: trunk/reactos/dll/win32/kernel32/misc/lang.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/la…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] Mon Nov 3 05:27:17 2008
@@ -1267,32 +1267,89 @@
/*
- * @unimplemented
+ * @implemented
*/
BOOL
STDCALL
-GetCPInfoExW(
- UINT CodePage,
- DWORD dwFlags,
- LPCPINFOEXW lpCPInfoEx)
-{
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented
+GetCPInfoExW(UINT CodePage,
+ DWORD dwFlags,
+ LPCPINFOEXW lpCPInfoEx)
+{
+ if (!GetCPInfo(CodePage, (LPCPINFO) lpCPInfoEx))
+ return FALSE;
+
+ switch(CodePage)
+ {
+ case CP_UTF7:
+ {
+ static const WCHAR utf7[] = L"Unicode (UTF-7)\0";
+
+ lpCPInfoEx->CodePage = CP_UTF7;
+ lpCPInfoEx->UnicodeDefaultChar = 0x3f;
+ wcscpy(lpCPInfoEx->CodePageName, utf7);
+ }
+ break;
+
+ case CP_UTF8:
+ {
+ static const WCHAR utf8[] = L"Unicode (UTF-8)\0";
+
+ lpCPInfoEx->CodePage = CP_UTF8;
+ lpCPInfoEx->UnicodeDefaultChar = 0x3f;
+ wcscpy(lpCPInfoEx->CodePageName, utf8);
+ }
+
+ default:
+ {
+ PCODEPAGE_ENTRY CodePageEntry;
+
+ CodePageEntry = IntGetCodePageEntry(CodePage);
+ if (CodePageEntry == NULL)
+ {
+ DPRINT1("Could not get CodePage Entry! CodePageEntry = 0\n");
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ lpCPInfoEx->CodePage = CodePageEntry->CodePageTable.CodePage;
+ lpCPInfoEx->UnicodeDefaultChar =
CodePageEntry->CodePageTable.UniDefaultChar;
+ /* FIXME: We need to get a codepage name */
+ DPRINT1("FIXME: We need to get a codepage name!\n");
+ wcscpy(lpCPInfoEx->CodePageName, L"Unknown\0");
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * @implemented
*/
BOOL
STDCALL
-GetCPInfoExA(
- UINT CodePage,
- DWORD dwFlags,
- LPCPINFOEXA lpCPInfoEx)
-{
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
+GetCPInfoExA(UINT CodePage,
+ DWORD dwFlags,
+ LPCPINFOEXA lpCPInfoEx)
+{
+ CPINFOEXW CPInfo;
+
+ if (!GetCPInfoExW(CodePage, dwFlags, &CPInfo))
+ return FALSE;
+
+ /* the layout is the same except for CodePageName */
+ memcpy(lpCPInfoEx, &CPInfo, sizeof(CPINFOEXA));
+
+ WideCharToMultiByte(CP_ACP,
+ 0,
+ CPInfo.CodePageName,
+ -1,
+ lpCPInfoEx->CodePageName,
+ sizeof(lpCPInfoEx->CodePageName),
+ NULL,
+ NULL);
+ return TRUE;
}
static int
Modified: trunk/reactos/dll/win32/kernel32/misc/nls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/nl…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/nls.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/nls.c [iso-8859-1] Mon Nov 3 05:27:17 2008
@@ -20,15 +20,6 @@
/* GLOBAL VARIABLES ***********************************************************/
-typedef struct _CODEPAGE_ENTRY
-{
- LIST_ENTRY Entry;
- UINT CodePage;
- HANDLE SectionHandle;
- PBYTE SectionMapping;
- CPTABLEINFO CodePageTable;
-} CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
-
/* Sequence length based on the first character. */
static const char UTF8Length[128] =
{
@@ -185,7 +176,7 @@
* @return Code page entry.
*/
-static PCODEPAGE_ENTRY FASTCALL
+PCODEPAGE_ENTRY FASTCALL
IntGetCodePageEntry(UINT CodePage)
{
CHAR SectionName[40];