Author: aandrejevic
Date: Sat Jun 6 02:22:36 2015
New Revision: 68029
URL: http://svn.reactos.org/svn/reactos?rev=68029&view=rev
Log:
[NTVDM]
Programs don't expect the XMS function AH = 07h to access the keyboard
controller, since the specification says it's done in a hardware-independent
way. So, reimplement this function by calling EmulatorGetA20() instead.
Also, for the sake of simplicity, use EmulatorSetA20 instead of PCAT_A20Control
to change the A20 state.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] Sat Jun 6 02:22:36 2015
@@ -76,47 +76,13 @@
/* HELPERS FOR A20 LINE *******************************************************/
-static BOOLEAN PCAT_A20Control(BYTE Control, PBOOLEAN A20Status)
-{
- BYTE ControllerOutput;
-
- /* Retrieve PS/2 controller output byte */
- IOWriteB(PS2_CONTROL_PORT, 0xD0);
- ControllerOutput = IOReadB(PS2_DATA_PORT);
-
- switch (Control)
- {
- case 0: /* Disable A20 line */
- ControllerOutput &= ~0x02;
- IOWriteB(PS2_CONTROL_PORT, 0xD1);
- IOWriteB(PS2_DATA_PORT, ControllerOutput);
- break;
-
- case 1: /* Enable A20 line */
- ControllerOutput |= 0x02;
- IOWriteB(PS2_CONTROL_PORT, 0xD1);
- IOWriteB(PS2_DATA_PORT, ControllerOutput);
- break;
-
- default: /* Get A20 status */
- break;
- }
-
- if (A20Status)
- *A20Status = (ControllerOutput & 0x02) != 0;
-
- /* Return success */
- return TRUE;
-}
-
static VOID XmsLocalEnableA20(VOID)
{
/* Enable A20 only if we can do so, otherwise make the caller believe we enabled it */
if (!CanChangeA20) goto Quit;
/* The count is zero so enable A20 */
- if (A20EnableCount == 0 && !PCAT_A20Control(1, NULL))
- goto Fail;
+ if (A20EnableCount == 0) EmulatorSetA20(TRUE);
++A20EnableCount;
@@ -124,55 +90,30 @@
setAX(0x0001); /* Line successfully enabled */
setBL(XMS_STATUS_SUCCESS);
return;
+}
+
+static VOID XmsLocalDisableA20(VOID)
+{
+ /* Disable A20 only if we can do so, otherwise make the caller believe we disabled it */
+ if (!CanChangeA20) goto Quit;
+
+ /* If the count is already zero, fail */
+ if (A20EnableCount == 0) goto Fail;
+
+ --A20EnableCount;
+
+ /* The count is zero so disable A20 */
+ if (A20EnableCount == 0) EmulatorSetA20(FALSE);
+
+Quit:
+ setAX(0x0001); /* Line successfully disabled */
+ setBL(XMS_STATUS_SUCCESS);
+ return;
Fail:
setAX(0x0000); /* Line failed to be enabled */
setBL(XMS_STATUS_A20_ERROR);
return;
-}
-
-static VOID XmsLocalDisableA20(VOID)
-{
- /* Disable A20 only if we can do so, otherwise make the caller believe we disabled it */
- if (!CanChangeA20) goto Quit;
-
- /* If the count is already zero, fail */
- if (A20EnableCount == 0) goto Fail;
-
- --A20EnableCount;
-
- /* The count is zero so disable A20 */
- if (A20EnableCount == 0 && !PCAT_A20Control(0, NULL))
- goto Fail;
-
-Quit:
- setAX(0x0001); /* Line successfully disabled */
- setBL(XMS_STATUS_SUCCESS);
- return;
-
-Fail:
- setAX(0x0000); /* Line failed to be enabled */
- setBL(XMS_STATUS_A20_ERROR);
- return;
-}
-
-static VOID XmsGetA20State(VOID)
-{
- BOOLEAN A20Status = FALSE;
-
- /*
- * NOTE: The XMS specification explicitely says that this check is done
- * in a hardware-independent manner, by checking whether high memory wraps.
- * For our purposes we just call the emulator API.
- */
-
- /* Get A20 status */
- if (PCAT_A20Control(2, &A20Status))
- setBL(XMS_STATUS_SUCCESS);
- else
- setBL(XMS_STATUS_A20_ERROR);
-
- setAX(A20Status);
}
/* PRIVATE FUNCTIONS **********************************************************/
@@ -395,8 +336,8 @@
/* Query A20 State */
case 0x07:
{
- /* This call sets AX and BL to their correct values */
- XmsGetA20State();
+ setAX(EmulatorGetA20());
+ setBL(XMS_STATUS_SUCCESS);
break;
}
Author: cfinck
Date: Fri Jun 5 15:52:39 2015
New Revision: 68023
URL: http://svn.reactos.org/svn/reactos?rev=68023&view=rev
Log:
[SPOOLSS]
In an attempt to simplify the code for further functions that return information structures, implement and document the undocumented PackStrings function.
Hints were taken from an XP DDK sample and own testing.
[SPOOLSS_APITEST]
Add some tests for PackStrings that succeed under Windows Server 2003.
Added:
branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/tools.c (with props)
branches/colins-printing-for-freedom/rostests/apitests/spoolss/ (with props)
branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt (with props)
branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c (with props)
branches/colins-printing-for-freedom/rostests/apitests/spoolss/testlist.c (with props)
Modified:
branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/CMakeLists.txt
branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/spoolss.spec
branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
--- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/CMakeLists.txt [iso-8859-1] (original)
+++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/CMakeLists.txt [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -4,7 +4,8 @@
list(APPEND SOURCE
context.c
main.c
- precomp.h)
+ precomp.h
+ tools.c)
add_library(spoolss SHARED
${SOURCE}
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/spoolss.spec
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
--- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/spoolss.spec [iso-8859-1] (original)
+++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/spoolss.spec [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -106,7 +106,7 @@
@ stub OpenPrinterExW
@ stub OpenPrinterPortW
@ stdcall OpenPrinterW(wstr ptr ptr)
-@ stub PackStrings
+@ stdcall PackStrings(ptr ptr ptr ptr)
@ stub PartialReplyPrinterChangeNotification
@ stub PlayGdiScriptOnPrinterIC
@ stub PrinterHandleRundown
Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/tools.c
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
--- branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/tools.c (added)
+++ branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/tools.c [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -0,0 +1,70 @@
+/*
+ * PROJECT: ReactOS Spooler Router
+ * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
+ * PURPOSE: Miscellaneous tool functions
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#include "precomp.h"
+
+
+/**
+ * @name PackStrings
+ *
+ * Takes an array of Unicode strings and fills an output buffer with these strings at the end and pointers to each string at specific offsets.
+ * Useful helper for functions that copy an information structure including strings into a given buffer (like PRINTER_INFO_1).
+ *
+ * @param pSource
+ * The array of Unicode strings to copy. Needs to have at least as many elements as the DestOffsets array.
+ *
+ * @param pDest
+ * Pointer to the beginning of the output buffer.
+ * The caller is responsible for verifying that this buffer is large enough to hold all strings and pointers.
+ *
+ * @param DestOffsets
+ * Array of byte offsets in the output buffer. For each element of DestOffsets, the function will copy the address of the corresponding copied
+ * string of pSource to this location in the output buffer. If a string in pSource is NULL, the function will set the pointer address to NULL
+ * in the output buffer.
+ * Use macros like FIELD_OFFSET to calculate the offsets for this array.
+ * The last element of the array must have the value MAXDWORD to let the function detect the end of the array.
+ *
+ * @param pEnd
+ * Pointer to the end of the output buffer. That means the first element outside of the buffer given in pDest.
+ *
+ * @return
+ * Returns a pointer to the beginning of the strings in pDest.
+ * The strings are copied in reverse order, so this pointer will point to the last copied string of pSource.
+ */
+PBYTE WINAPI
+PackStrings(PCWSTR* pSource, PBYTE pDest, PDWORD DestOffsets, PBYTE pEnd)
+{
+ DWORD cbString;
+ ULONG_PTR StringAddress;
+
+ // Loop until we reach an element with offset set to MAXDWORD.
+ while (*DestOffsets != MAXDWORD)
+ {
+ StringAddress = 0;
+
+ if (*pSource)
+ {
+ // Determine the length of the source string.
+ cbString = (wcslen(*pSource) + 1) * sizeof(WCHAR);
+
+ // Copy it before the last string.
+ pEnd -= cbString;
+ StringAddress = (ULONG_PTR)pEnd;
+ CopyMemory(pEnd, *pSource, cbString);
+ }
+
+ // Copy the address of the copied string to the location given by the offset.
+ CopyMemory(&pDest[*DestOffsets], &StringAddress, sizeof(ULONG_PTR));
+
+ // Advance to the next source string and destination offset.
+ pSource++;
+ DestOffsets++;
+ }
+
+ // pEnd is now at the last string we copied. Return this value as a pointer to the beginning of all strings in the output buffer.
+ return pEnd;
+}
Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/base/spoolss/tools.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt [iso-8859-1] (original)
+++ branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -17,6 +17,7 @@
add_subdirectory(setupapi)
add_subdirectory(shell32)
add_subdirectory(psapi)
+add_subdirectory(spoolss)
add_subdirectory(user32)
if(NOT ARCH STREQUAL "amd64")
add_subdirectory(w32kdll)
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Fri Jun 5 15:52:39 2015
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/
------------------------------------------------------------------------------
bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt (added)
+++ branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -0,0 +1,10 @@
+
+list(APPEND SOURCE
+ PackStrings.c
+ testlist.c)
+
+add_executable(spoolss_apitest ${SOURCE})
+target_link_libraries(spoolss_apitest wine ${PSEH_LIB})
+set_module_type(spoolss_apitest win32cui)
+add_importlibs(spoolss_apitest spoolss msvcrt kernel32 ntdll)
+add_cd_file(TARGET spoolss_apitest DESTINATION reactos/bin FOR all)
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c (added)
+++ branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -0,0 +1,48 @@
+/*
+ * PROJECT: ReactOS Spooler Router API Tests
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE: Tests for PackStrings
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+
+PBYTE WINAPI PackStrings(PCWSTR*, PBYTE, PDWORD, PBYTE);
+
+typedef struct _EXAMPLE_STRUCT
+{
+ PWSTR String1;
+ PWSTR String2;
+}
+EXAMPLE_STRUCT, *PEXAMPLE_STRUCT;
+
+START_TEST(PackStrings)
+{
+ PCWSTR Source1[] = { L"Test", L"String" };
+ PCWSTR Source2[] = { L"Test", NULL };
+
+ BYTE Buffer[50];
+ PBYTE pEnd;
+ PEXAMPLE_STRUCT pStruct = (PEXAMPLE_STRUCT)Buffer;
+ DWORD Offsets[] = {
+ FIELD_OFFSET(EXAMPLE_STRUCT, String1),
+ FIELD_OFFSET(EXAMPLE_STRUCT, String2),
+ MAXDWORD
+ };
+
+ // Try a usual case with two strings. Verify that they are copied in reverse order.
+ pEnd = PackStrings(Source1, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
+ ok(wcscmp(pStruct->String1, Source1[0]) == 0, "String1 and Source1[0] don't match!\n");
+ ok(wcscmp(pStruct->String2, Source1[1]) == 0, "String2 and Source1[1] don't match!\n");
+ ok(wcscmp((PWSTR)pEnd, Source1[1]) == 0, "pEnd and Source1[1] don't match!\n");
+
+ // Now verify that the corresponding pointer is set to NULL if a string is NULL.
+ pEnd = PackStrings(Source2, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
+ ok(wcscmp(pStruct->String1, Source2[0]) == 0, "String1 and Source2[0] don't match!\n");
+ ok(!pStruct->String2, "String2 is %p!\n", pStruct->String2);
+ ok(wcscmp((PWSTR)pEnd, Source2[0]) == 0, "pEnd and Source2[0] don't match!\n");
+}
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/colins-printing-for-freedom/rostests/apitests/spoolss/testlist.c
URL: http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/spoolss/testlist.c (added)
+++ branches/colins-printing-for-freedom/rostests/apitests/spoolss/testlist.c [iso-8859-1] Fri Jun 5 15:52:39 2015
@@ -0,0 +1,20 @@
+/*
+ * PROJECT: ReactOS Print Spooler Router API Tests
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE: Test list
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#define __ROS_LONG64__
+
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_PackStrings(void);
+
+const struct test winetest_testlist[] =
+{
+ { "PackStrings", func_PackStrings },
+
+ { 0, 0 }
+};
Propchange: branches/colins-printing-for-freedom/rostests/apitests/spoolss/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native