From c5166c1a2d134a033ad096aec8ba5325e1a99962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 24 Nov 2012 18:22:26 +0000 Subject: [PATCH 01/24] [CPORTLIB] Code formatting only. svn path=/trunk/; revision=57759 --- .../include/reactos/drivers/serial/ns16550.h | 4 +- .../include/reactos/libs/cportlib/cportlib.h | 62 +++---- reactos/lib/cportlib/cport.c | 166 +++++++++--------- 3 files changed, 120 insertions(+), 112 deletions(-) diff --git a/reactos/include/reactos/drivers/serial/ns16550.h b/reactos/include/reactos/drivers/serial/ns16550.h index 4a69824da73..027dd105020 100644 --- a/reactos/include/reactos/drivers/serial/ns16550.h +++ b/reactos/include/reactos/drivers/serial/ns16550.h @@ -11,8 +11,8 @@ #pragma once /* Note: These definitions are the internal definitions used by Microsoft serial - driver (see src/kernel/serial/serial.h in WDK source code). Linux uses its own, as - do most other OS. + driver (see src/kernel/serial/serial.h in WDK source code). Linux uses its own, + as do most other OS. */ #if !defined(SERIAL_REGISTER_STRIDE) diff --git a/reactos/include/reactos/libs/cportlib/cportlib.h b/reactos/include/reactos/libs/cportlib/cportlib.h index be64007a42c..31b76158bc6 100644 --- a/reactos/include/reactos/libs/cportlib/cportlib.h +++ b/reactos/include/reactos/libs/cportlib/cportlib.h @@ -14,61 +14,63 @@ #define CP_GET_NODATA 1 #define CP_GET_ERROR 2 -#define CPPORT_FLAG_MODEM_CONTROL 0x02 +#define CPPORT_FLAG_MODEM_CONTROL 0x02 typedef struct _CPPORT { - PUCHAR Address; - ULONG Baud; - USHORT Flags; + PUCHAR Address; + ULONG Baud; + USHORT Flags; } CPPORT, *PCPPORT; - + VOID NTAPI CpInitialize( - IN PCPPORT Port, - IN PUCHAR Address, - IN ULONG Rate - ); + IN PCPPORT Port, + IN PUCHAR Address, + IN ULONG Rate +); VOID NTAPI CpEnableFifo( - IN PUCHAR Address, - IN BOOLEAN Enable - ); + IN PUCHAR Address, + IN BOOLEAN Enable +); BOOLEAN NTAPI CpDoesPortExist( - IN PUCHAR Address - ); - + IN PUCHAR Address +); + UCHAR NTAPI CpReadLsr( - IN PCPPORT Port, - IN UCHAR ExpectedValue - ); + IN PCPPORT Port, + IN UCHAR ExpectedValue +); VOID NTAPI CpSetBaud( - IN PCPPORT Port, - IN ULONG Rate - ); + IN PCPPORT Port, + IN ULONG Rate +); USHORT NTAPI CpGetByte( - IN PCPPORT Port, - IN PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll - ); - + IN PCPPORT Port, + IN PUCHAR Byte, + IN BOOLEAN Wait, + IN BOOLEAN Poll +); + VOID NTAPI CpPutByte( - IN PCPPORT Port, - IN UCHAR Byte - ); + IN PCPPORT Port, + IN UCHAR Byte +); + +/* EOF */ diff --git a/reactos/lib/cportlib/cport.c b/reactos/lib/cportlib/cport.c index 28d7738fec5..97d281f71ce 100644 --- a/reactos/lib/cportlib/cport.c +++ b/reactos/lib/cportlib/cport.c @@ -20,8 +20,8 @@ /* NOTE: The original code supports Modem Control. We currently do not */ /* FIXMEs: - - Make this serial-port specific (NS16550 vs other serial port types) - - Get x64 KDCOM, KDBG, FREELDR, and other current code to use this + - Make this serial-port specific (NS16550 vs other serial port types) + - Get x64 KDCOM, KDBG, FREELDR, and other current code to use this */ /* INCLUDES *******************************************************************/ @@ -41,19 +41,19 @@ UCHAR RingIndicator; VOID NTAPI CpInitialize(IN PCPPORT Port, - IN PUCHAR Address, - IN ULONG Rate) + IN PUCHAR Address, + IN ULONG Rate) { - /* Reset port data */ + /* Reset port data */ Port->Address = Address; Port->Baud = 0; - /* Set the baud rate */ + /* Set the baud rate */ CpSetBaud(Port, Rate); /* Enable on DTR and RTS */ WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, - SERIAL_MCR_DTR | SERIAL_MCR_RTS); + SERIAL_MCR_DTR | SERIAL_MCR_RTS); /* Disable interrupts */ WRITE_PORT_UCHAR(Address + INTERRUPT_ENABLE_REGISTER, 0); @@ -61,10 +61,10 @@ CpInitialize(IN PCPPORT Port, VOID NTAPI -CpEnableFifo(IN PUCHAR Address, - IN BOOLEAN Enable) +CpEnableFifo(IN PUCHAR Address, + IN BOOLEAN Enable) { - /* Set FIFO */ + /* Set FIFO */ WRITE_PORT_UCHAR(Address + FIFO_CONTROL_REGISTER, Enable ? SERIAL_FCR_ENABLE : 0); } @@ -72,58 +72,62 @@ BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address) { - UCHAR Old; - /* - * See "Building Hardware and Firmware to Complement Microsoft Windows Headless Operation" - * Out-of-Band Management Port Device Requirements: - * The device must act as a 16550 or 16450 UART. - * Windows Server 2003 will test this device using the following process. - * 1. Save off the current modem status register. - * 2. Place the UART into diagnostic mode (The UART is placed into loopback mode - * by writing SERIAL_MCR_LOOP to the modem control register). - * 3. The modem status register is read and the high bits are checked. This means - * SERIAL_MSR_CTS, SERIAL_MSR_DSR, SERIAL_MSR_RI and SERIAL_MSR_DCD should - * all be clear. - * 4. Place the UART in diagnostic mode and turn on OUTPUT (Loopback Mode and - * OUTPUT are both turned on by writing (SERIAL_MCR_LOOP | SERIAL_MCR_OUT1) - * to the modem control register). - * 5. The modem status register is read and the ring indicator is checked. - * This means SERIAL_MSR_RI should be set. - * 6. Restore original modem status register. - */ - Old = READ_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER); + /* + * See "Building Hardware and Firmware to Complement Microsoft Windows Headless Operation" + * Out-of-Band Management Port Device Requirements: + * The device must act as a 16550 or 16450 UART. + * Windows Server 2003 will test this device using the following process: + * 1. Save off the current modem status register. + * 2. Place the UART into diagnostic mode (The UART is placed into loopback mode + * by writing SERIAL_MCR_LOOP to the modem control register). + * 3. The modem status register is read and the high bits are checked. This means + * SERIAL_MSR_CTS, SERIAL_MSR_DSR, SERIAL_MSR_RI and SERIAL_MSR_DCD should + * all be clear. + * 4. Place the UART in diagnostic mode and turn on OUTPUT (Loopback Mode and + * OUTPUT are both turned on by writing (SERIAL_MCR_LOOP | SERIAL_MCR_OUT1) + * to the modem control register). + * 5. The modem status register is read and the ring indicator is checked. + * This means SERIAL_MSR_RI should be set. + * 6. Restore original modem status register. + */ + + UCHAR Old = READ_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER); + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP); WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP); + if (!(READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & - (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD))) - { - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, - (SERIAL_MCR_OUT1 | SERIAL_MCR_LOOP)); - if (READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & SERIAL_MSR_RI) - { - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old); - return TRUE; - } - } + (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD))) + { + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, + (SERIAL_MCR_OUT1 | SERIAL_MCR_LOOP)); + if (READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & SERIAL_MSR_RI) + { + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old); + return TRUE; + } + } + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old); + return FALSE; } UCHAR NTAPI CpReadLsr(IN PCPPORT Port, - IN UCHAR ExpectedValue) + IN UCHAR ExpectedValue) { - UCHAR Lsr, Msr; + UCHAR Lsr, Msr; - /* Read the LSR and check if the expected value is present */ + /* Read the LSR and check if the expected value is present */ Lsr = READ_PORT_UCHAR(Port->Address + LINE_STATUS_REGISTER); if (!(Lsr & ExpectedValue)) - { - /* Check the MSR for ring indicator toggle */ + { + /* Check the MSR for ring indicator toggle */ Msr = READ_PORT_UCHAR(Port->Address + MODEM_STATUS_REGISTER); - /* If the indicator reaches 3, we've seen this on/off twice */ + /* If the indicator reaches 3, we've seen this on/off twice */ RingIndicator |= (Msr & SERIAL_MSR_RI) ? 1 : 2; if (RingIndicator == 3) Port->Flags |= CPPORT_FLAG_MODEM_CONTROL; } @@ -134,13 +138,13 @@ CpReadLsr(IN PCPPORT Port, VOID NTAPI CpSetBaud(IN PCPPORT Port, - IN ULONG Rate) + IN ULONG Rate) { - UCHAR Lcr; - USHORT Mode; + UCHAR Lcr; + USHORT Mode; /* Add DLAB */ - Lcr = READ_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER); + Lcr = READ_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER); WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, Lcr | SERIAL_LCR_DLAB); /* Set baud rate */ @@ -150,59 +154,59 @@ CpSetBaud(IN PCPPORT Port, /* Reset DLAB and set 8 data bits, 1 stop bit, no parity, no break */ WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, - SERIAL_8_DATA | SERIAL_1_STOP | SERIAL_NONE_PARITY); + SERIAL_8_DATA | SERIAL_1_STOP | SERIAL_NONE_PARITY); - /* Save baud rate in port */ + /* Save baud rate in port */ Port->Baud = Rate; } USHORT NTAPI CpGetByte(IN PCPPORT Port, - IN PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll) + IN PUCHAR Byte, + IN BOOLEAN Wait, + IN BOOLEAN Poll) { - UCHAR Lsr; - ULONG i; + UCHAR Lsr; + ULONG i; - /* Handle early read-before-init */ - if (!Port->Address) return CP_GET_NODATA; + /* Handle early read-before-init */ + if (!Port->Address) return CP_GET_NODATA; - /* If "wait" mode enabled, spin many times, otherwise attempt just once */ - i = Wait ? 204800 : 1; + /* If "wait" mode enabled, spin many times, otherwise attempt just once */ + i = Wait ? 204800 : 1; while (i--) - { - /* Read LSR for data ready */ + { + /* Read LSR for data ready */ Lsr = CpReadLsr(Port, SERIAL_LSR_DR); if ((Lsr & SERIAL_LSR_DR) == SERIAL_LSR_DR) - { - /* If an error happened, clear the byte and fail */ + { + /* If an error happened, clear the byte and fail */ if (Lsr & (SERIAL_LSR_FE | SERIAL_LSR_PE)) - { + { *Byte = 0; return CP_GET_ERROR; } - /* If only polling was requested by caller, return now */ + /* If only polling was requested by caller, return now */ if (Poll) return CP_GET_SUCCESS; - /* Otherwise read the byte and return it */ + /* Otherwise read the byte and return it */ *Byte = READ_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER); - /* Handle CD if port is in modem control mode */ + /* Handle CD if port is in modem control mode */ if (Port->Flags & CPPORT_FLAG_MODEM_CONTROL) - { - /* Not implemented yet */ - DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n"); + { + /* Not implemented yet */ + DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n"); } - /* Byte was read */ + /* Byte was read */ return CP_GET_SUCCESS; } } - /* Reset LSR, no data was found */ + /* Reset LSR, no data was found */ CpReadLsr(Port, 0); return CP_GET_NODATA; } @@ -210,18 +214,20 @@ CpGetByte(IN PCPPORT Port, VOID NTAPI CpPutByte(IN PCPPORT Port, - IN UCHAR Byte) + IN UCHAR Byte) { - /* Check if port is in modem control to handle CD */ + /* Check if port is in modem control to handle CD */ while (Port->Flags & CPPORT_FLAG_MODEM_CONTROL) - { - /* Not implemented yet */ - DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n"); + { + /* Not implemented yet */ + DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n"); } - /* Wait for LSR to say we can go ahead */ + /* Wait for LSR to say we can go ahead */ while (!(CpReadLsr(Port, SERIAL_LSR_THRE) & SERIAL_LSR_THRE)); /* Send the byte */ WRITE_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER, Byte); } + +/* EOF */ From 1656ff4b7123626344d9c3b02770c85ea763be4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 24 Nov 2012 19:36:07 +0000 Subject: [PATCH 02/24] [KD64] Use \t instead of hardcoding the tab character. svn path=/trunk/; revision=57761 --- reactos/ntoskrnl/kd64/kdinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/kd64/kdinit.c b/reactos/ntoskrnl/kd64/kdinit.c index 914be3c283b..fd43defd016 100644 --- a/reactos/ntoskrnl/kd64/kdinit.c +++ b/reactos/ntoskrnl/kd64/kdinit.c @@ -193,7 +193,7 @@ KdInitSystem(IN ULONG BootPhase, /* Check if this is a comma, a space or a tab */ if ((*DebugOptionEnd == ',') || (*DebugOptionEnd == ' ') || - (*DebugOptionEnd == ' ')) + (*DebugOptionEnd == '\t')) { /* * We reached the end of the option or From afd01007a5e8c9ea06c932b21988947061fb3938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 24 Nov 2012 19:38:05 +0000 Subject: [PATCH 03/24] [NTOSKRNL] Code formatting only svn path=/trunk/; revision=57762 --- reactos/ntoskrnl/kd/wrappers/gdbstub_powerpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/kd/wrappers/gdbstub_powerpc.c b/reactos/ntoskrnl/kd/wrappers/gdbstub_powerpc.c index 4a9a236e7ec..83ce48aca05 100644 --- a/reactos/ntoskrnl/kd/wrappers/gdbstub_powerpc.c +++ b/reactos/ntoskrnl/kd/wrappers/gdbstub_powerpc.c @@ -105,7 +105,9 @@ static PETHREAD GspEnumThread; static FAST_MUTEX GspLock; extern LIST_ENTRY PsActiveProcessHead; -KD_PORT_INFORMATION GdbPortInfo = { 2, 115200, 0 }; /* FIXME hardcoded for COM2, 115200 baud */ + +/* FIXME hardcoded for COM2, 115200 baud */ +KD_PORT_INFORMATION GdbPortInfo = { 2, 115200, 0 }; /* Number of Registers. */ #define NUMREGS 16 From fad4fbd259fb669aa7ab11aff5b2cba0c3aee2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 24 Nov 2012 19:50:31 +0000 Subject: [PATCH 04/24] [NTOSKRNL] Code formatting only svn path=/trunk/; revision=57763 --- reactos/ntoskrnl/inbv/inbvport.c | 140 +++++++++++++++---------------- 1 file changed, 68 insertions(+), 72 deletions(-) diff --git a/reactos/ntoskrnl/inbv/inbvport.c b/reactos/ntoskrnl/inbv/inbvport.c index 839d6fe9779..5f58cff96df 100644 --- a/reactos/ntoskrnl/inbv/inbvport.c +++ b/reactos/ntoskrnl/inbv/inbvport.c @@ -15,107 +15,103 @@ CPPORT Port[4] = { - {NULL, 0, TRUE}, - {NULL, 0, TRUE}, - {NULL, 0, TRUE}, - {NULL, 0, TRUE} + {NULL, 0, TRUE}, + {NULL, 0, TRUE}, + {NULL, 0, TRUE}, + {NULL, 0, TRUE} }; /* FUNCTIONS *****************************************************************/ VOID NTAPI -InbvPortEnableFifo( - IN ULONG PortId, - IN BOOLEAN Enable - ) +InbvPortEnableFifo(IN ULONG PortId, + IN BOOLEAN Enable) { - /* Set FIFO as requested */ - CpEnableFifo(Port[PortId].Address, Enable); + /* Set FIFO as requested */ + CpEnableFifo(Port[PortId].Address, Enable); } VOID NTAPI -InbvPortPutByte( - IN ULONG PortId, - IN BOOLEAN Output - ) +InbvPortPutByte(IN ULONG PortId, + IN BOOLEAN Output) { - /* Send the byte */ - CpPutByte(&Port[PortId], Output); + /* Send the byte */ + CpPutByte(&Port[PortId], Output); } VOID NTAPI -InbvPortTerminate( - IN ULONG PortId - ) +InbvPortTerminate(IN ULONG PortId) { - /* The port is now available */ - Port[PortId].Address = NULL; + /* The port is now available */ + Port[PortId].Address = NULL; } BOOLEAN NTAPI -InbvPortInitialize( - IN ULONG BaudRate, - IN ULONG PortNumber, - IN PUCHAR PortAddress, - OUT PULONG PortId, - IN BOOLEAN IsMMIODevice - ) +InbvPortInitialize(IN ULONG BaudRate, + IN ULONG PortNumber, + IN PUCHAR PortAddress, + OUT PULONG PortId, + IN BOOLEAN IsMMIODevice) { - /* Not yet supported */ - ASSERT(IsMMIODevice == FALSE); + /* Not yet supported */ + ASSERT(IsMMIODevice == FALSE); - /* Set default baud rate */ + /* Set default baud rate */ if (BaudRate == 0) BaudRate = 19200; - /* Check if port or address given */ - if (PortNumber) - { - /* Pick correct address for port */ - if (!PortAddress) - { + /* Check if port or address given */ + if (PortNumber) + { + /* Pick correct address for port */ + if (!PortAddress) + { switch (PortNumber) - { - case 1: - PortAddress = (PUCHAR)0x3F8; - break; + { + case 1: + PortAddress = (PUCHAR)0x3F8; + break; - case 2: - PortAddress = (PUCHAR)0x2F8; - break; + case 2: + PortAddress = (PUCHAR)0x2F8; + break; - case 3: - PortAddress = (PUCHAR)0x3E8; - break; + case 3: + PortAddress = (PUCHAR)0x3E8; + break; - default: - PortNumber = 4; - PortAddress = (PUCHAR)0x2E8; - } - } - } - else - { - /* Pick correct port for address */ - PortAddress = (PUCHAR)0x2F8; - if (CpDoesPortExist(PortAddress)) - { - PortNumber = 2; + default: + PortNumber = 4; + PortAddress = (PUCHAR)0x2E8; + } } - else - { - PortAddress = (PUCHAR)0x3F8; - if (!CpDoesPortExist(PortAddress)) return FALSE; - PortNumber = 1; - } - } + } + else + { + /* Pick correct port for address */ + PortAddress = (PUCHAR)0x2F8; + if (CpDoesPortExist(PortAddress)) + { + PortNumber = 2; + } + else + { + PortAddress = (PUCHAR)0x3F8; + if (!CpDoesPortExist(PortAddress)) return FALSE; + PortNumber = 1; + } + } - /* Initialize the port unless it's already up, and then return it */ - if (Port[PortNumber - 1].Address) return FALSE; - CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate); - *PortId = PortNumber - 1; - return TRUE; + /* Initialize the port unless it's already up, and then return it */ + if (Port[PortNumber - 1].Address) return FALSE; + + CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate); + *PortId = PortNumber - 1; + + return TRUE; } + +/* EOF */ From 4864e1b55309116c7d70e51a23a9c7538f9e486a Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 24 Nov 2012 23:19:40 +0000 Subject: [PATCH 05/24] [LSASRV] - Add new registry API. - Implement LsarEnumerateAccounts. svn path=/trunk/; revision=57764 --- reactos/dll/win32/lsasrv/CMakeLists.txt | 1 + reactos/dll/win32/lsasrv/lsarpc.c | 199 +++++++++++- reactos/dll/win32/lsasrv/lsasrv.h | 58 ++++ reactos/dll/win32/lsasrv/registry.c | 411 ++++++++++++++++++++++++ 4 files changed, 667 insertions(+), 2 deletions(-) create mode 100644 reactos/dll/win32/lsasrv/registry.c diff --git a/reactos/dll/win32/lsasrv/CMakeLists.txt b/reactos/dll/win32/lsasrv/CMakeLists.txt index 71b4d0a0265..a68f0ec1f49 100644 --- a/reactos/dll/win32/lsasrv/CMakeLists.txt +++ b/reactos/dll/win32/lsasrv/CMakeLists.txt @@ -18,6 +18,7 @@ list(APPEND SOURCE lsasrv.c policy.c privileges.c + registry.c security.c lsasrv.rc ${CMAKE_CURRENT_BINARY_DIR}/lsasrv_stubs.c diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index 4bb17cedbd9..322660c22a4 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -642,8 +642,203 @@ NTSTATUS WINAPI LsarEnumerateAccounts( PLSAPR_ACCOUNT_ENUM_BUFFER EnumerationBuffer, DWORD PreferedMaximumLength) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + LSAPR_ACCOUNT_ENUM_BUFFER EnumBuffer = {0, NULL}; + PLSA_DB_OBJECT PolicyObject = NULL; + WCHAR AccountKeyName[64]; + HANDLE AccountsKeyHandle = NULL; + HANDLE AccountKeyHandle; + HANDLE SidKeyHandle; + ULONG EnumIndex; + ULONG EnumCount; + ULONG RequiredLength; + ULONG DataLength; + ULONG i; + NTSTATUS Status = STATUS_SUCCESS; + + TRACE("(%p %p %p %lu)\n", PolicyHandle, EnumerationContext, + EnumerationBuffer, PreferedMaximumLength); + + if (EnumerationContext == NULL || + EnumerationBuffer == NULL) + return STATUS_INVALID_PARAMETER; + + EnumerationBuffer->EntriesRead = 0; + EnumerationBuffer->Information = NULL; + + /* Validate the PolicyHandle */ + Status = LsapValidateDbObject(PolicyHandle, + LsaDbPolicyObject, + POLICY_VIEW_LOCAL_INFORMATION, + &PolicyObject); + if (!NT_SUCCESS(Status)) + { + ERR("LsapValidateDbObject returned 0x%08lx\n", Status); + return Status; + } + + Status = LsapRegOpenKey(PolicyObject->KeyHandle, + L"Accounts", + KEY_READ, + &AccountsKeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + + EnumIndex = *EnumerationContext; + EnumCount = 0; + RequiredLength = 0; + + while (TRUE) + { + Status = LsapRegEnumerateSubKey(AccountsKeyHandle, + EnumIndex, + 64 * sizeof(WCHAR), + AccountKeyName); + if (!NT_SUCCESS(Status)) + break; + + TRACE("EnumIndex: %lu\n", EnumIndex); + TRACE("Account key name: %S\n", AccountKeyName); + + Status = LsapRegOpenKey(AccountsKeyHandle, + AccountKeyName, + KEY_READ, + &AccountKeyHandle); + TRACE("LsapRegOpenKey returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + Status = LsapRegOpenKey(AccountKeyHandle, + L"Sid", + KEY_READ, + &SidKeyHandle); + TRACE("LsapRegOpenKey returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + DataLength = 0; + Status = LsapRegQueryValue(SidKeyHandle, + NULL, + NULL, + NULL, + &DataLength); + TRACE("LsapRegQueryValue returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + TRACE("Data length: %lu\n", DataLength); + + if ((RequiredLength + DataLength + sizeof(LSAPR_ACCOUNT_INFORMATION)) > PreferedMaximumLength) + break; + + RequiredLength += (DataLength + sizeof(LSAPR_ACCOUNT_INFORMATION)); + EnumCount++; + } + + LsapRegCloseKey(SidKeyHandle); + } + + LsapRegCloseKey(AccountKeyHandle); + } + + EnumIndex++; + } + + TRACE("EnumCount: %lu\n", EnumCount); + TRACE("RequiredLength: %lu\n", RequiredLength); + + EnumBuffer.EntriesRead = EnumCount; + EnumBuffer.Information = midl_user_allocate(EnumCount * sizeof(LSAPR_ACCOUNT_INFORMATION)); + if (EnumBuffer.Information == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + EnumIndex = *EnumerationContext; + for (i = 0; i < EnumCount; i++, EnumIndex++) + { + Status = LsapRegEnumerateSubKey(AccountsKeyHandle, + EnumIndex, + 64 * sizeof(WCHAR), + AccountKeyName); + if (!NT_SUCCESS(Status)) + break; + + TRACE("EnumIndex: %lu\n", EnumIndex); + TRACE("Account key name: %S\n", AccountKeyName); + + Status = LsapRegOpenKey(AccountsKeyHandle, + AccountKeyName, + KEY_READ, + &AccountKeyHandle); + TRACE("LsapRegOpenKey returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + Status = LsapRegOpenKey(AccountKeyHandle, + L"Sid", + KEY_READ, + &SidKeyHandle); + TRACE("LsapRegOpenKey returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + DataLength = 0; + Status = LsapRegQueryValue(SidKeyHandle, + NULL, + NULL, + NULL, + &DataLength); + TRACE("LsapRegQueryValue returned %08lX\n", Status); + if (NT_SUCCESS(Status)) + { + EnumBuffer.Information[i].Sid = midl_user_allocate(DataLength); + if (EnumBuffer.Information[i].Sid == NULL) + { + LsapRegCloseKey(AccountKeyHandle); + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = LsapRegQueryValue(SidKeyHandle, + NULL, + NULL, + EnumBuffer.Information[i].Sid, + &DataLength); + TRACE("SampRegQueryValue returned %08lX\n", Status); + } + + LsapRegCloseKey(SidKeyHandle); + } + + LsapRegCloseKey(AccountKeyHandle); + + if (!NT_SUCCESS(Status)) + goto done; + } + } + + if (NT_SUCCESS(Status)) + { + *EnumerationContext += EnumCount; + EnumerationBuffer->EntriesRead = EnumBuffer.EntriesRead; + EnumerationBuffer->Information = EnumBuffer.Information; + } + +done: + if (!NT_SUCCESS(Status)) + { + if (EnumBuffer.Information) + { + for (i = 0; i < EnumBuffer.EntriesRead; i++) + { + if (EnumBuffer.Information[i].Sid != NULL) + midl_user_free(EnumBuffer.Information[i].Sid); + } + + midl_user_free(EnumBuffer.Information); + } + } + + if (AccountsKeyHandle != NULL) + LsapRegCloseKey(AccountsKeyHandle); + + return Status; } diff --git a/reactos/dll/win32/lsasrv/lsasrv.h b/reactos/dll/win32/lsasrv/lsasrv.h index 8849448f3f4..f4eba9fd9bb 100644 --- a/reactos/dll/win32/lsasrv/lsasrv.h +++ b/reactos/dll/win32/lsasrv/lsasrv.h @@ -263,6 +263,64 @@ LsarpEnumeratePrivileges(DWORD *EnumerationContext, PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer, DWORD PreferedMaximumLength); +/* registry.h */ +NTSTATUS +LsapRegCloseKey(IN HANDLE KeyHandle); + +NTSTATUS +LsapRegCreateKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName, + IN ACCESS_MASK DesiredAccess, + OUT HANDLE KeyHandle); + +NTSTATUS +LsapRegDeleteKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName); + +NTSTATUS +LsapRegEnumerateSubKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN ULONG Length, + OUT LPWSTR Buffer); + +NTSTATUS +LsapRegOpenKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName, + IN ACCESS_MASK DesiredAccess, + OUT HANDLE KeyHandle); + +NTSTATUS +LsapRegQueryKeyInfo(IN HANDLE KeyHandle, + OUT PULONG SubKeyCount, + OUT PULONG ValueCount); + +NTSTATUS +LsapRegDeleteValue(IN HANDLE KeyHandle, + IN LPWSTR ValueName); + +NTSTATUS +LsapRegEnumerateValue(IN HANDLE KeyHandle, + IN ULONG Index, + OUT LPWSTR Name, + IN OUT PULONG NameLength, + OUT PULONG Type OPTIONAL, + OUT PVOID Data OPTIONAL, + IN OUT PULONG DataLength OPTIONAL); + +NTSTATUS +LsapRegQueryValue(IN HANDLE KeyHandle, + IN LPWSTR ValueName, + OUT PULONG Type OPTIONAL, + OUT LPVOID Data OPTIONAL, + IN OUT PULONG DataLength OPTIONAL); + +NTSTATUS +LsapRegSetValue(IN HANDLE KeyHandle, + IN LPWSTR ValueName, + IN ULONG Type, + IN LPVOID Data, + IN ULONG DataLength); + /* security.c */ NTSTATUS LsapCreatePolicySd(PSECURITY_DESCRIPTOR *PolicySd, diff --git a/reactos/dll/win32/lsasrv/registry.c b/reactos/dll/win32/lsasrv/registry.c new file mode 100644 index 00000000000..80c083eb57a --- /dev/null +++ b/reactos/dll/win32/lsasrv/registry.c @@ -0,0 +1,411 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: Security Account Manager (SAM) Server + * FILE: reactos/dll/win32/samsrv/registry.c + * PURPOSE: Registry helper functions + * + * PROGRAMMERS: Eric Kohl + */ + +/* INCLUDES ****************************************************************/ + +#include "lsasrv.h" + +WINE_DEFAULT_DEBUG_CHANNEL(lsasrv); + +/* FUNCTIONS ***************************************************************/ + +static +BOOLEAN +IsStringType(ULONG Type) +{ + return (Type == REG_SZ) || (Type == REG_EXPAND_SZ) || (Type == REG_MULTI_SZ); +} + + +NTSTATUS +LsapRegCloseKey(IN HANDLE KeyHandle) +{ + return NtClose(KeyHandle); +} + + +NTSTATUS +LsapRegCreateKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName, + IN ACCESS_MASK DesiredAccess, + OUT HANDLE KeyHandle) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING Name; + ULONG Disposition; + + RtlInitUnicodeString(&Name, KeyName); + + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + ParentKeyHandle, + NULL); + + /* Create the key */ + return ZwCreateKey(KeyHandle, + DesiredAccess, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); +} + + +NTSTATUS +LsapRegDeleteKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING SubKeyName; + HANDLE TargetKey; + NTSTATUS Status; + + RtlInitUnicodeString(&SubKeyName, + (LPWSTR)KeyName); + InitializeObjectAttributes(&ObjectAttributes, + &SubKeyName, + OBJ_CASE_INSENSITIVE, + ParentKeyHandle, + NULL); + Status = NtOpenKey(&TargetKey, + DELETE, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + return Status; + + Status = NtDeleteKey(TargetKey); + + NtClose(TargetKey); + + return Status; +} + + +NTSTATUS +LsapRegEnumerateSubKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN ULONG Length, + OUT LPWSTR Buffer) +{ + PKEY_BASIC_INFORMATION KeyInfo = NULL; + ULONG BufferLength = 0; + ULONG ReturnedLength; + NTSTATUS Status; + + /* Check if we have a name */ + if (Length) + { + /* Allocate a buffer for it */ + BufferLength = sizeof(KEY_BASIC_INFORMATION) + Length * sizeof(WCHAR); + + KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); + if (KeyInfo == NULL) + return STATUS_NO_MEMORY; + } + + /* Enumerate the key */ + Status = ZwEnumerateKey(KeyHandle, + Index, + KeyBasicInformation, + KeyInfo, + BufferLength, + &ReturnedLength); + if (NT_SUCCESS(Status)) + { + /* Check if the name fits */ + if (KeyInfo->NameLength < (Length * sizeof(WCHAR))) + { + /* Copy it */ + RtlMoveMemory(Buffer, + KeyInfo->Name, + KeyInfo->NameLength); + + /* Terminate the string */ + Buffer[KeyInfo->NameLength / sizeof(WCHAR)] = 0; + } + else + { + /* Otherwise, we ran out of buffer space */ + Status = STATUS_BUFFER_OVERFLOW; + } + } + + /* Free the buffer and return status */ + if (KeyInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo); + + return Status; +} + + +NTSTATUS +LsapRegOpenKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName, + IN ACCESS_MASK DesiredAccess, + OUT HANDLE KeyHandle) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING Name; + + RtlInitUnicodeString(&Name, KeyName); + + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_CASE_INSENSITIVE, + ParentKeyHandle, + NULL); + + return NtOpenKey(KeyHandle, + DesiredAccess, + &ObjectAttributes); +} + + +NTSTATUS +LsapRegQueryKeyInfo(IN HANDLE KeyHandle, + OUT PULONG SubKeyCount, + OUT PULONG ValueCount) +{ + KEY_FULL_INFORMATION FullInfoBuffer; + ULONG Length; + NTSTATUS Status; + + FullInfoBuffer.ClassLength = 0; + FullInfoBuffer.ClassOffset = FIELD_OFFSET(KEY_FULL_INFORMATION, Class); + + Status = NtQueryKey(KeyHandle, + KeyFullInformation, + &FullInfoBuffer, + sizeof(KEY_FULL_INFORMATION), + &Length); + TRACE("NtQueryKey() returned status 0x%08lX\n", Status); + if (!NT_SUCCESS(Status)) + return Status; + + if (SubKeyCount != NULL) + *SubKeyCount = FullInfoBuffer.SubKeys; + + if (ValueCount != NULL) + *ValueCount = FullInfoBuffer.Values; + + return Status; +} + + +NTSTATUS +LsapRegDeleteValue(IN HANDLE KeyHandle, + IN LPWSTR ValueName) +{ + UNICODE_STRING Name; + + RtlInitUnicodeString(&Name, + ValueName); + + return NtDeleteValueKey(KeyHandle, + &Name); +} + + +NTSTATUS +LsapRegEnumerateValue(IN HANDLE KeyHandle, + IN ULONG Index, + OUT LPWSTR Name, + IN OUT PULONG NameLength, + OUT PULONG Type OPTIONAL, + OUT PVOID Data OPTIONAL, + IN OUT PULONG DataLength OPTIONAL) +{ + PKEY_VALUE_FULL_INFORMATION ValueInfo = NULL; + ULONG BufferLength = 0; + ULONG ReturnedLength; + NTSTATUS Status; + + TRACE("Index: %lu\n", Index); + + /* Calculate the required buffer length */ + BufferLength = FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name); + BufferLength += (MAX_PATH + 1) * sizeof(WCHAR); + if (Data != NULL) + BufferLength += *DataLength; + + /* Allocate the value buffer */ + ValueInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); + if (ValueInfo == NULL) + return STATUS_NO_MEMORY; + + /* Enumerate the value*/ + Status = ZwEnumerateValueKey(KeyHandle, + Index, + KeyValueFullInformation, + ValueInfo, + BufferLength, + &ReturnedLength); + if (NT_SUCCESS(Status)) + { + if (Name != NULL) + { + /* Check if the name fits */ + if (ValueInfo->NameLength < (*NameLength * sizeof(WCHAR))) + { + /* Copy it */ + RtlMoveMemory(Name, + ValueInfo->Name, + ValueInfo->NameLength); + + /* Terminate the string */ + Name[ValueInfo->NameLength / sizeof(WCHAR)] = 0; + } + else + { + /* Otherwise, we ran out of buffer space */ + Status = STATUS_BUFFER_OVERFLOW; + goto done; + } + } + + if (Data != NULL) + { + /* Check if the data fits */ + if (ValueInfo->DataLength <= *DataLength) + { + /* Copy it */ + RtlMoveMemory(Data, + (PVOID)((ULONG_PTR)ValueInfo + ValueInfo->DataOffset), + ValueInfo->DataLength); + + /* if the type is REG_SZ and data is not 0-terminated + * and there is enough space in the buffer NT appends a \0 */ + if (IsStringType(ValueInfo->Type) && + ValueInfo->DataLength <= *DataLength - sizeof(WCHAR)) + { + WCHAR *ptr = (WCHAR *)((ULONG_PTR)Data + ValueInfo->DataLength); + if ((ptr > (WCHAR *)Data) && ptr[-1]) + *ptr = 0; + } + } + else + { + Status = STATUS_BUFFER_OVERFLOW; + goto done; + } + } + } + +done: + if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW)) + { + if (Type != NULL) + *Type = ValueInfo->Type; + + if (NameLength != NULL) + *NameLength = ValueInfo->NameLength; + + if (DataLength != NULL) + *DataLength = ValueInfo->DataLength; + } + + /* Free the buffer and return status */ + if (ValueInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, ValueInfo); + + return Status; +} + + +NTSTATUS +LsapRegQueryValue(IN HANDLE KeyHandle, + IN LPWSTR ValueName, + OUT PULONG Type OPTIONAL, + OUT PVOID Data OPTIONAL, + IN OUT PULONG DataLength OPTIONAL) +{ + PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; + UNICODE_STRING Name; + ULONG BufferLength = 0; + NTSTATUS Status; + + RtlInitUnicodeString(&Name, + ValueName); + + if (DataLength != NULL) + BufferLength = *DataLength; + + BufferLength += FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data); + + /* Allocate memory for the value */ + ValueInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); + if (ValueInfo == NULL) + return STATUS_NO_MEMORY; + + /* Query the value */ + Status = ZwQueryValueKey(KeyHandle, + &Name, + KeyValuePartialInformation, + ValueInfo, + BufferLength, + &BufferLength); + if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW)) + { + if (Type != NULL) + *Type = ValueInfo->Type; + + if (DataLength != NULL) + *DataLength = ValueInfo->DataLength; + } + + /* Check if the caller wanted data back, and we got it */ + if ((NT_SUCCESS(Status)) && (Data != NULL)) + { + /* Copy it */ + RtlMoveMemory(Data, + ValueInfo->Data, + ValueInfo->DataLength); + + /* if the type is REG_SZ and data is not 0-terminated + * and there is enough space in the buffer NT appends a \0 */ + if (IsStringType(ValueInfo->Type) && + ValueInfo->DataLength <= *DataLength - sizeof(WCHAR)) + { + WCHAR *ptr = (WCHAR *)((ULONG_PTR)Data + ValueInfo->DataLength); + if ((ptr > (WCHAR *)Data) && ptr[-1]) + *ptr = 0; + } + } + + /* Free the memory and return status */ + RtlFreeHeap(RtlGetProcessHeap(), 0, ValueInfo); + + if ((Data == NULL) && (Status == STATUS_BUFFER_OVERFLOW)) + Status = STATUS_SUCCESS; + + return Status; +} + + +NTSTATUS +LsapRegSetValue(HANDLE KeyHandle, + LPWSTR ValueName, + ULONG Type, + LPVOID Data, + ULONG DataLength) +{ + UNICODE_STRING Name; + + RtlInitUnicodeString(&Name, + ValueName); + + return ZwSetValueKey(KeyHandle, + &Name, + 0, + Type, + Data, + DataLength); +} From e223b5389a2bfcd89f56998c1406771934678d55 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 25 Nov 2012 02:53:09 +0000 Subject: [PATCH 06/24] [WineTests] - Sync to 1.5.18 svn path=/trunk/; revision=57765 --- rostests/winetests/user32/msg.c | 53 +++++- rostests/winetests/user32/resource.c | 4 +- rostests/winetests/user32/win.c | 272 ++++++++++++++++++++++++++- 3 files changed, 317 insertions(+), 12 deletions(-) diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index 434c76e87ff..3eb943a5ba5 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -6795,6 +6795,7 @@ static void test_interthread_messages(void) wnd_event.hwnd = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, 0, NULL); ok (wnd_event.hwnd != 0, "Failed to create parent window\n"); + flush_events(); flush_sequence(); log_all_parent_messages++; wnd_event.start_event = CreateEventA( NULL, TRUE, FALSE, NULL ); @@ -11031,11 +11032,6 @@ static void test_ShowWindow(void) } else { - if (wp.ptMinPosition.x != sw[i].wp_min.x || wp.ptMinPosition.y != sw[i].wp_min.y) - todo_wine - ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y, - "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y); - else ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y, "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y); } @@ -11268,8 +11264,7 @@ static void test_EndDialog(void) ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n"); cls.lpszClassName = "MyDialogClass"; cls.hInstance = GetModuleHandle(0); - /* need a cast since a dlgproc is used as a wndproc */ - cls.lpfnWndProc = (WNDPROC)test_dlg_proc; + cls.lpfnWndProc = test_dlg_proc; if (!RegisterClass(&cls)) assert(0); flush_sequence(); @@ -13792,6 +13787,27 @@ static const struct message WmSetLayeredStyle2[] = { { 0 } }; +struct layered_window_info +{ + HWND hwnd; + HDC hdc; + SIZE size; + HANDLE event; + BOOL ret; +}; + +static DWORD CALLBACK update_layered_proc( void *param ) +{ + struct layered_window_info *info = param; + POINT src = { 0, 0 }; + + info->ret = pUpdateLayeredWindow( info->hwnd, 0, NULL, &info->size, + info->hdc, &src, 0, NULL, ULW_OPAQUE ); + ok( info->ret, "failed\n"); + SetEvent( info->event ); + return 0; +} + static void test_layered_window(void) { HWND hwnd; @@ -13801,6 +13817,9 @@ static void test_layered_window(void) SIZE size; POINT pos, src; RECT rect, client; + HANDLE thread; + DWORD tid; + struct layered_window_info info; if (!pUpdateLayeredWindow) { @@ -13894,6 +13913,26 @@ static void test_layered_window(void) broken(rect.right == client.right - 100 && rect.bottom == client.bottom - 50), "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); + SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); + info.hwnd = hwnd; + info.hdc = hdc; + info.size.cx = 250; + info.size.cy = 300; + info.event = CreateEventA( NULL, TRUE, FALSE, NULL ); + info.ret = FALSE; + thread = CreateThread( NULL, 0, update_layered_proc, &info, 0, &tid ); + ok( WaitForSingleObject( info.event, 1000 ) == 0, "wait failed\n" ); + ok( info.ret, "UpdateLayeredWindow failed in other thread\n" ); + WaitForSingleObject( thread, 1000 ); + CloseHandle( thread ); + GetWindowRect( hwnd, &rect ); + ok( rect.left == 200 && rect.top == 200 && rect.right == 450 && rect.bottom == 500, + "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); + GetClientRect( hwnd, &rect ); + ok( (rect.right == 250 && rect.bottom == 300) || + broken(rect.right == client.right - 50 && rect.bottom == client.bottom), + "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); + DestroyWindow( hwnd ); DeleteDC( hdc ); DeleteObject( bmp ); diff --git a/rostests/winetests/user32/resource.c b/rostests/winetests/user32/resource.c index dd4342de7df..346cc2a8944 100755 --- a/rostests/winetests/user32/resource.c +++ b/rostests/winetests/user32/resource.c @@ -170,11 +170,11 @@ static void test_accel1(void) ac[n].cmd = 0xfff0; ac[n].key = 0xffff; - ac[n++].fVirt = (SHORT) 0x0000; + ac[n++].fVirt = 0x0000; ac[n].cmd = 0xfff0; ac[n].key = 0xffff; - ac[n++].fVirt = (SHORT) 0x0001; + ac[n++].fVirt = 0x0001; hAccel = CreateAcceleratorTable( &ac[0], n ); ok( hAccel != NULL, "create accelerator table\n"); diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index f6a576f2bd6..a25960d43bb 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -50,6 +50,7 @@ static UINT (WINAPI *pGetWindowModuleFileNameA)(HWND,LPSTR,UINT); static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*); static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD); +static BOOL (WINAPI *pUpdateLayeredWindowIndirect)(HWND,const UPDATELAYEREDWINDOWINFO*); static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD); static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT); @@ -2636,7 +2637,7 @@ static void test_SetActiveWindow(HWND hwnd) SetActiveWindow(0); check_wnd_state(0, 0, 0, 0); - /*trace("testing SetActiveWindow %p\n", hwnd);*/ + trace("testing SetActiveWindow %p\n", hwnd); ShowWindow(hwnd, SW_SHOW); check_wnd_state(hwnd, hwnd, hwnd, 0); @@ -2656,11 +2657,11 @@ static void test_SetActiveWindow(HWND hwnd) SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_SHOWWINDOW); check_wnd_state(hwnd, hwnd, hwnd, 0); - + trace("testing ShowWindow SW_HIDE window %p\n", hwnd); ShowWindow(hwnd, SW_HIDE); check_wnd_state(0, 0, 0, 0); - /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/ + trace("testing SetActiveWindow on an invisible window %p\n", hwnd); SetActiveWindow(hwnd); check_wnd_state(hwnd, hwnd, hwnd, 0); @@ -6074,6 +6075,47 @@ static void test_layered_window(void) ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" ); ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE ); ok( ret, "UpdateLayeredWindow should succeed on layered window\n" ); + ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE | ULW_EX_NORESIZE ); + ok( !ret, "UpdateLayeredWindow should fail with ex flag\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + if (pUpdateLayeredWindowIndirect) + { + UPDATELAYEREDWINDOWINFO info; + info.cbSize = sizeof(info); + info.hdcDst = 0; + info.pptDst = NULL; + info.psize = &sz; + info.hdcSrc = hdc; + info.pptSrc = &pt; + info.crKey = 0; + info.pblend = NULL; + info.dwFlags = ULW_OPAQUE | ULW_EX_NORESIZE; + info.prcDirty = NULL; + ret = pUpdateLayeredWindowIndirect( hwnd, &info ); + ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" ); + sz.cx--; + ret = pUpdateLayeredWindowIndirect( hwnd, &info ); + ok( !ret, "UpdateLayeredWindowIndirect should fail\n" ); + ok( GetLastError() == ERROR_INCORRECT_SIZE || broken(GetLastError() == ERROR_MR_MID_NOT_FOUND), + "wrong error %u\n", GetLastError() ); + info.dwFlags = ULW_OPAQUE; + ret = pUpdateLayeredWindowIndirect( hwnd, &info ); + ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" ); + sz.cx++; + info.dwFlags = ULW_OPAQUE | 0xf00; + ret = pUpdateLayeredWindowIndirect( hwnd, &info ); + ok( !ret, "UpdateLayeredWindowIndirect should fail\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + info.cbSize--; + info.dwFlags = ULW_OPAQUE; + ret = pUpdateLayeredWindowIndirect( hwnd, &info ); + ok( !ret, "UpdateLayeredWindowIndirect should fail\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + ret = pUpdateLayeredWindowIndirect( hwnd, NULL ); + ok( !ret, "UpdateLayeredWindowIndirect should fail\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + } + ret = pSetLayeredWindowAttributes( hwnd, 0x654321, 22, LWA_COLORKEY | LWA_ALPHA ); ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" ); ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags ); @@ -7062,6 +7104,228 @@ todo_wine ok(ret, "UnregisterClass(my_window) failed\n"); } +static void test_map_points(void) +{ + BOOL ret; + POINT p; + HWND wnd, wnd0, dwnd; + INT n; + DWORD err; + POINT pos = { 100, 200 }; + int width = 150; + int height = 150; + RECT window_rect; + RECT client_rect; + + /* Create test windows */ + wnd = CreateWindow("static", "test1", WS_POPUP, pos.x, pos.y, width, height, NULL, NULL, NULL, NULL); + ok(wnd != NULL, "Failed %p\n", wnd); + wnd0 = CreateWindow("static", "test2", WS_POPUP, 0, 0, width, height, NULL, NULL, NULL, NULL); + ok(wnd0 != NULL, "Failed %p\n", wnd); + dwnd = CreateWindow("static", "test3", 0, 200, 300, 150, 150, NULL, NULL, NULL, NULL); + DestroyWindow(dwnd); + ok(dwnd != NULL, "Failed %p\n", dwnd); + + /* Verify window rect and client rect (they should have the same width and height) */ + GetWindowRect(wnd, &window_rect); + ok(window_rect.left == pos.x, "left is %d instead of %d\n", window_rect.left, pos.x); + ok(window_rect.top == pos.y, "top is %d instead of %d\n", window_rect.top, pos.y); + ok(window_rect.right == pos.x + width, "right is %d instead of %d\n", window_rect.right, pos.x + width); + ok(window_rect.bottom == pos.y + height, "bottom is %d instead of %d\n", window_rect.bottom, pos.y + height); + GetClientRect(wnd, &client_rect); + ok(client_rect.left == 0, "left is %d instead of 0\n", client_rect.left); + ok(client_rect.top == 0, "top is %d instead of 0\n", client_rect.top); + ok(client_rect.right == width, "right is %d instead of %d\n", client_rect.right, width); + ok(client_rect.bottom == height, "bottom is %d instead of %d\n", client_rect.bottom, height); + + /* Test MapWindowPoints */ + + /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */ + + SetLastError(0xdeadbeef); + n = MapWindowPoints(NULL, NULL, NULL, 0); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + SetLastError(0xdeadbeef); + n = MapWindowPoints(wnd, wnd, NULL, 0); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + n = MapWindowPoints(wnd, NULL, NULL, 0); + ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %x\n", + n, MAKELONG(window_rect.left, window_rect.top)); + + n = MapWindowPoints(NULL, wnd, NULL, 0); + ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %x\n", + n, MAKELONG(-window_rect.left, -window_rect.top)); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(dwnd, NULL, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(dwnd, wnd, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(NULL, dwnd, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(wnd, dwnd, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(dwnd, dwnd, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(NULL, NULL, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + n = MapWindowPoints(wnd, wnd, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %d, expected %d\n", n, 0); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + p.x = p.y = 100; + n = MapWindowPoints(wnd, NULL, &p, 1); + ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %x\n", + n, MAKELONG(window_rect.left, window_rect.top)); + ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n", + p.x, p.y, window_rect.left + 100, window_rect.top + 100); + + p.x = p.y = 100; + n = MapWindowPoints(NULL, wnd, &p, 1); + ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %x\n", + n, MAKELONG(-window_rect.left, -window_rect.top)); + ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n", + p.x, p.y, -window_rect.left + 100, -window_rect.top + 100); + + SetLastError(0xdeadbeef); + p.x = p.y = 0; + n = MapWindowPoints(wnd0, NULL, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %x, expected 0\n", n); + ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + SetLastError(0xdeadbeef); + p.x = p.y = 0; + n = MapWindowPoints(NULL, wnd0, &p, 1); + err = GetLastError(); + ok(n == 0, "Got %x, expected 0\n", n); + ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y); + ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef); + + /* Test ClientToScreen */ + + /* ClientToScreen(wnd, NULL); crashes on Windows */ + + SetLastError(0xdeadbeef); + ret = ClientToScreen(NULL, NULL); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + ret = ClientToScreen(NULL, &p); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + ret = ClientToScreen(dwnd, &p); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + p.x = p.y = 100; + ret = ClientToScreen(wnd, &p); + ok(ret, "Failed with error %u\n", GetLastError()); + ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n", + p.x, p.y, window_rect.left + 100, window_rect.top + 100); + + p.x = p.y = 0; + ret = ClientToScreen(wnd0, &p); + ok(ret, "Failed with error %u\n", GetLastError()); + ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y); + + /* Test ScreenToClient */ + + /* ScreenToClient(wnd, NULL); crashes on Windows */ + + SetLastError(0xdeadbeef); + ret = ScreenToClient(NULL, NULL); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + ret = ScreenToClient(NULL, &p); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + SetLastError(0xdeadbeef); + p.x = p.y = 100; + ret = ScreenToClient(dwnd, &p); + err = GetLastError(); + ok(!ret, "Should fail\n"); + ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100); + ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE); + + p.x = p.y = 100; + ret = ScreenToClient(wnd, &p); + ok(ret, "Failed with error %u\n", GetLastError()); + ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got(%d, %d), expected (%d, %d)\n", + p.x, p.y, -window_rect.left + 100, -window_rect.top + 100); + + p.x = p.y = 0; + ret = ScreenToClient(wnd0, &p); + ok(ret, "Failed with error %u\n", GetLastError()); + ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y); + + DestroyWindow(wnd); + DestroyWindow(wnd0); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -7072,6 +7336,7 @@ START_TEST(win) pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" ); pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" ); pUpdateLayeredWindow = (void *)GetProcAddress( user32, "UpdateLayeredWindow" ); + pUpdateLayeredWindowIndirect = (void *)GetProcAddress( user32, "UpdateLayeredWindowIndirect" ); pGetMonitorInfoA = (void *)GetProcAddress( user32, "GetMonitorInfoA" ); pMonitorFromPoint = (void *)GetProcAddress( user32, "MonitorFromPoint" ); pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" ); @@ -7172,6 +7437,7 @@ START_TEST(win) test_shell_window(); test_handles( hwndMain ); test_winregion(); + test_map_points(); /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook); From 3c766118e3853b7c6d7fdd8ad08e099d9ab2929b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 25 Nov 2012 10:35:57 +0000 Subject: [PATCH 07/24] [LSASRV] Implement LsarGetQuotasForAccount and LsarSetQuotasForAccount. svn path=/trunk/; revision=57766 --- reactos/dll/win32/lsasrv/lsarpc.c | 84 +++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index 322660c22a4..e82fda02b2a 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -1383,8 +1383,30 @@ NTSTATUS WINAPI LsarGetQuotasForAccount( LSAPR_HANDLE AccountHandle, PQUOTA_LIMITS QuotaLimits) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PLSA_DB_OBJECT AccountObject; + ULONG Size; + NTSTATUS Status; + + TRACE("(%p %p)\n", AccountHandle, QuotaLimits); + + /* Validate the account handle */ + Status = LsapValidateDbObject(AccountHandle, + LsaDbAccountObject, + ACCOUNT_VIEW, + &AccountObject); + if (!NT_SUCCESS(Status)) + { + ERR("Invalid handle (Status %lx)\n", Status); + return Status; + } + + /* Get the quota attribute */ + Status = LsapGetObjectAttribute(AccountObject, + L"DefQuota", + QuotaLimits, + &Size); + + return Status; } @@ -1393,8 +1415,59 @@ NTSTATUS WINAPI LsarSetQuotasForAccount( LSAPR_HANDLE AccountHandle, PQUOTA_LIMITS QuotaLimits) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PLSA_DB_OBJECT AccountObject; + QUOTA_LIMITS InternalQuotaLimits; + ULONG Size; + NTSTATUS Status; + + TRACE("(%p %p)\n", AccountHandle, QuotaLimits); + + /* Validate the account handle */ + Status = LsapValidateDbObject(AccountHandle, + LsaDbAccountObject, + ACCOUNT_ADJUST_QUOTAS, + &AccountObject); + if (!NT_SUCCESS(Status)) + { + ERR("Invalid handle (Status %lx)\n", Status); + return Status; + } + + /* Get the quota limits attribute */ + Size = sizeof(QUOTA_LIMITS); + Status = LsapGetObjectAttribute(AccountObject, + L"DefQuota", + &InternalQuotaLimits, + &Size); + if (!NT_SUCCESS(Status)) + { + TRACE("LsapGetObjectAttribute() failed (Status 0x%08lx)\n", Status); + return Status; + } + + /* Update the quota limits */ + if (QuotaLimits->PagedPoolLimit != 0) + InternalQuotaLimits.PagedPoolLimit = QuotaLimits->PagedPoolLimit; + + if (QuotaLimits->NonPagedPoolLimit != 0) + InternalQuotaLimits.NonPagedPoolLimit = QuotaLimits->NonPagedPoolLimit; + + if (QuotaLimits->MinimumWorkingSetSize != 0) + InternalQuotaLimits.MinimumWorkingSetSize = QuotaLimits->MinimumWorkingSetSize; + + if (QuotaLimits->MaximumWorkingSetSize != 0) + InternalQuotaLimits.MaximumWorkingSetSize = QuotaLimits->MaximumWorkingSetSize; + + if (QuotaLimits->PagefileLimit != 0) + InternalQuotaLimits.PagefileLimit = QuotaLimits->PagefileLimit; + + /* Set the quota limits attribute */ + Status = LsapSetObjectAttribute(AccountObject, + L"DefQuota", + &InternalQuotaLimits, + sizeof(QUOTA_LIMITS)); + + return Status; } @@ -1870,7 +1943,8 @@ NTSTATUS WINAPI LsarLookupPrivilegeName( return Status; } - Status = LsarpLookupPrivilegeName(Value, (PUNICODE_STRING*)Name); + Status = LsarpLookupPrivilegeName(Value, + (PUNICODE_STRING*)Name); return Status; } From 7595ef1c18c26d10c14f298fa2aeb4025bf50809 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 25 Nov 2012 13:47:07 +0000 Subject: [PATCH 08/24] [LSASRV] - Add enumeration of user rights to LsarEnumerateAccountRights. - Use RPC_UNICODE_STRING instead of UNICODE_STRING in the privilege lookup code. svn path=/trunk/; revision=57767 --- reactos/dll/win32/lsasrv/lsarpc.c | 55 +++++++++++++++------ reactos/dll/win32/lsasrv/lsasrv.h | 8 +++- reactos/dll/win32/lsasrv/privileges.c | 69 +++++++++++++++++++++++++-- 3 files changed, 111 insertions(+), 21 deletions(-) diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index e82fda02b2a..0d91ee090a6 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -1915,7 +1915,7 @@ NTSTATUS WINAPI LsarLookupPrivilegeValue( TRACE("Privilege: %wZ\n", Name); - Status = LsarpLookupPrivilegeValue((PUNICODE_STRING)Name, + Status = LsarpLookupPrivilegeValue(Name, Value); return Status; @@ -1944,7 +1944,7 @@ NTSTATUS WINAPI LsarLookupPrivilegeName( } Status = LsarpLookupPrivilegeName(Value, - (PUNICODE_STRING*)Name); + Name); return Status; } @@ -1994,9 +1994,10 @@ NTSTATUS WINAPI LsarEnumerateAccountRights( PLSAPR_PRIVILEGE_SET PrivilegeSet = NULL; PRPC_UNICODE_STRING RightsBuffer = NULL; PRPC_UNICODE_STRING PrivilegeString; + ACCESS_MASK SystemAccess; ULONG RightsCount; ULONG RightsIndex; - ULONG PrivIndex; + ULONG i; NTSTATUS Status; TRACE("LsarEnumerateAccountRights(%p %p %p)\n", @@ -2022,13 +2023,23 @@ NTSTATUS WINAPI LsarEnumerateAccountRights( goto done; } - /* FIXME: Get account rights */ - + /* Get account rights */ + Status = LsarGetSystemAccessAccount(AccountHandle, + &SystemAccess); + if (!NT_SUCCESS(Status)) + { + ERR("LsarGetSystemAccessAccount returned 0x%08lx\n", Status); + goto done; + } RightsCount = PrivilegeSet->PrivilegeCount; - /* FIXME: Count account rights */ - + /* Count account rights */ + for (i = 0; i < sizeof(ACCESS_MASK) * 8; i++) + { + if (SystemAccess & (1 << i)) + RightsCount++; + } /* We are done if there are no rights to be enumerated */ if (RightsCount == 0) @@ -2049,25 +2060,41 @@ NTSTATUS WINAPI LsarEnumerateAccountRights( /* Copy the privileges into the buffer */ RightsIndex = 0; - for (PrivIndex = 0; PrivIndex < PrivilegeSet->PrivilegeCount; PrivIndex++) + for (i = 0; i < PrivilegeSet->PrivilegeCount; i++) { PrivilegeString = NULL; Status = LsarLookupPrivilegeName(PolicyHandle, - (PLUID)&PrivilegeSet->Privilege[PrivIndex].Luid, - (PRPC_UNICODE_STRING *)&PrivilegeString); + (PLUID)&PrivilegeSet->Privilege[i].Luid, + &PrivilegeString); if (!NT_SUCCESS(Status)) goto done; - RightsBuffer[RightsIndex].Length = PrivilegeString->Length; - RightsBuffer[RightsIndex].MaximumLength = PrivilegeString->MaximumLength; - RightsBuffer[RightsIndex].Buffer = PrivilegeString->Buffer; + RightsBuffer[i].Length = PrivilegeString->Length; + RightsBuffer[i].MaximumLength = PrivilegeString->MaximumLength; + RightsBuffer[i].Buffer = PrivilegeString->Buffer; MIDL_user_free(PrivilegeString); RightsIndex++; } - /* FIXME: Copy account rights into the buffer */ + /* Copy account rights into the buffer */ + for (i = 0; i < sizeof(ACCESS_MASK) * 8; i++) + { + if (SystemAccess & (1 << i)) + { + Status = LsapLookupAccountRightName(1 << i, + &PrivilegeString); + if (!NT_SUCCESS(Status)) + goto done; + RightsBuffer[i].Length = PrivilegeString->Length; + RightsBuffer[i].MaximumLength = PrivilegeString->MaximumLength; + RightsBuffer[i].Buffer = PrivilegeString->Buffer; + + MIDL_user_free(PrivilegeString); + RightsIndex++; + } + } UserRights->Entries = RightsCount; UserRights->UserRights = (PRPC_UNICODE_STRING)RightsBuffer; diff --git a/reactos/dll/win32/lsasrv/lsasrv.h b/reactos/dll/win32/lsasrv/lsasrv.h index f4eba9fd9bb..e8182441c9e 100644 --- a/reactos/dll/win32/lsasrv/lsasrv.h +++ b/reactos/dll/win32/lsasrv/lsasrv.h @@ -252,10 +252,10 @@ LsarSetLocalAccountDomain(PLSA_DB_OBJECT PolicyObject, /* privileges.c */ NTSTATUS LsarpLookupPrivilegeName(PLUID Value, - PUNICODE_STRING *Name); + PRPC_UNICODE_STRING *Name); NTSTATUS -LsarpLookupPrivilegeValue(PUNICODE_STRING Name, +LsarpLookupPrivilegeValue(PRPC_UNICODE_STRING Name, PLUID Value); NTSTATUS @@ -263,6 +263,10 @@ LsarpEnumeratePrivileges(DWORD *EnumerationContext, PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer, DWORD PreferedMaximumLength); +NTSTATUS +LsapLookupAccountRightName(ULONG RightValue, + PRPC_UNICODE_STRING *Name); + /* registry.h */ NTSTATUS LsapRegCloseKey(IN HANDLE KeyHandle); diff --git a/reactos/dll/win32/lsasrv/privileges.c b/reactos/dll/win32/lsasrv/privileges.c index d2d21e7c98e..6b9cff9c504 100644 --- a/reactos/dll/win32/lsasrv/privileges.c +++ b/reactos/dll/win32/lsasrv/privileges.c @@ -18,6 +18,12 @@ typedef struct LPCWSTR Name; } PRIVILEGE_DATA; +typedef struct +{ + ULONG Flag; + LPCWSTR Name; +} RIGHT_DATA; + /* GLOBALS *****************************************************************/ @@ -54,14 +60,28 @@ static const PRIVILEGE_DATA WellKnownPrivileges[] = {{SE_CREATE_GLOBAL_PRIVILEGE, 0}, SE_CREATE_GLOBAL_NAME} }; +static const RIGHT_DATA WellKnownRights[] = +{ + {SECURITY_ACCESS_INTERACTIVE_LOGON, SE_INTERACTIVE_LOGON_NAME}, + {SECURITY_ACCESS_NETWORK_LOGON, SE_NETWORK_LOGON_NAME}, + {SECURITY_ACCESS_BATCH_LOGON, SE_BATCH_LOGON_NAME}, + {SECURITY_ACCESS_SERVICE_LOGON, SE_SERVICE_LOGON_NAME}, + {SECURITY_ACCESS_DENY_INTERACTIVE_LOGON, SE_DENY_INTERACTIVE_LOGON_NAME}, + {SECURITY_ACCESS_DENY_NETWORK_LOGON, SE_DENY_NETWORK_LOGON_NAME}, + {SECURITY_ACCESS_DENY_BATCH_LOGON, SE_DENY_BATCH_LOGON_NAME}, + {SECURITY_ACCESS_DENY_SERVICE_LOGON, SE_DENY_SERVICE_LOGON_NAME}, + {SECURITY_ACCESS_REMOTE_INTERACTIVE_LOGON, SE_REMOTE_INTERACTIVE_LOGON_NAME}, + {SECURITY_ACCESS_DENY_REMOTE_INTERACTIVE_LOGON, SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME} +}; + /* FUNCTIONS ***************************************************************/ NTSTATUS LsarpLookupPrivilegeName(PLUID Value, - PUNICODE_STRING *Name) + PRPC_UNICODE_STRING *Name) { - PUNICODE_STRING NameBuffer; + PRPC_UNICODE_STRING NameBuffer; ULONG Priv; if (Value->HighPart != 0 || @@ -76,7 +96,7 @@ LsarpLookupPrivilegeName(PLUID Value, if (Value->LowPart == WellKnownPrivileges[Priv].Luid.LowPart && Value->HighPart == WellKnownPrivileges[Priv].Luid.HighPart) { - NameBuffer = MIDL_user_allocate(sizeof(UNICODE_STRING)); + NameBuffer = MIDL_user_allocate(sizeof(RPC_UNICODE_STRING)); if (NameBuffer == NULL) return STATUS_NO_MEMORY; @@ -103,7 +123,7 @@ LsarpLookupPrivilegeName(PLUID Value, NTSTATUS -LsarpLookupPrivilegeValue(PUNICODE_STRING Name, +LsarpLookupPrivilegeValue(PRPC_UNICODE_STRING Name, PLUID Value) { ULONG Priv; @@ -218,4 +238,43 @@ done: Status = STATUS_MORE_ENTRIES; return Status; -} \ No newline at end of file +} + + +NTSTATUS +LsapLookupAccountRightName(ULONG RightValue, + PRPC_UNICODE_STRING *Name) +{ + PRPC_UNICODE_STRING NameBuffer; + ULONG i; + + for (i = 0; i < sizeof(WellKnownRights) / sizeof(WellKnownRights[0]); i++) + { + if (WellKnownRights[i].Flag == RightValue) + { + NameBuffer = MIDL_user_allocate(sizeof(RPC_UNICODE_STRING)); + if (NameBuffer == NULL) + return STATUS_NO_MEMORY; + + NameBuffer->Length = wcslen(WellKnownRights[i].Name) * sizeof(WCHAR); + NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR); + + NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength); + if (NameBuffer == NULL) + { + MIDL_user_free(NameBuffer); + return STATUS_INSUFFICIENT_RESOURCES; + } + + wcscpy(NameBuffer->Buffer, WellKnownRights[i].Name); + + *Name = NameBuffer; + + return STATUS_SUCCESS; + } + } + + return STATUS_NO_SUCH_PRIVILEGE; +} + +/* EOF */ From bff31ec33b9fcb76d9f2e44dd96a0991a75aad72 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 25 Nov 2012 19:35:56 +0000 Subject: [PATCH 09/24] CORE-6650 #resolve #comment Add missing files on bootcd. Patch By Lee Schroeder. svn path=/trunk/; revision=57768 --- reactos/boot/bootdata/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reactos/boot/bootdata/CMakeLists.txt b/reactos/boot/bootdata/CMakeLists.txt index 2f608e555de..afdb2b72590 100644 --- a/reactos/boot/bootdata/CMakeLists.txt +++ b/reactos/boot/bootdata/CMakeLists.txt @@ -1,6 +1,7 @@ add_subdirectory(packages) +#common hives add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/txtsetup.sif DESTINATION reactos NO_CAB FOR bootcd regtest) add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hivecls_${ARCH}.inf DESTINATION reactos NO_CAB NAME_ON_CD hivecls.inf FOR bootcd regtest) add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hivedef_${ARCH}.inf DESTINATION reactos NO_CAB NAME_ON_CD hivedef.inf FOR bootcd regtest) @@ -45,6 +46,15 @@ add_cd_file( #regtest add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcdregtest/regtest.cmd DESTINATION reactos/bin FOR all) +#autorun.inf +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/autorun.inf DESTINATION root NO_CAB FOR all) + +#icon.ico +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/icon.ico DESTINATION root NO_CAB FOR all) + +#readme.txt +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/readme.txt DESTINATION root NO_CAB FOR all) + #freeldr.ini add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcd.ini DESTINATION root NO_CAB NAME_ON_CD freeldr.ini FOR bootcd regtest) add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/livecd.ini DESTINATION root NAME_ON_CD freeldr.ini FOR livecd) From 3ba8c1dc0b0ca0ad8167e44ec69d96f2d71b38ae Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 25 Nov 2012 19:47:54 +0000 Subject: [PATCH 10/24] [LSASRV] - Implement LsarDeleteObject. - Store the object name in the database object in order to be able to delete the objects key later. svn path=/trunk/; revision=57769 --- reactos/dll/win32/lsasrv/database.c | 66 ++++++++++++++++++++++++++++- reactos/dll/win32/lsasrv/lsarpc.c | 37 +++++++++++++++- reactos/dll/win32/lsasrv/lsasrv.h | 4 ++ 3 files changed, 104 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/lsasrv/database.c b/reactos/dll/win32/lsasrv/database.c index 9303636a3f4..ba278288ea8 100644 --- a/reactos/dll/win32/lsasrv/database.c +++ b/reactos/dll/win32/lsasrv/database.c @@ -796,7 +796,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject = RtlAllocateHeap(RtlGetProcessHeap(), 0, - sizeof(LSA_DB_OBJECT)); + sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR)); if (NewObject == NULL) { NtClose(ObjectKeyHandle); @@ -809,6 +809,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject->Access = DesiredAccess; NewObject->KeyHandle = ObjectKeyHandle; NewObject->ParentObject = ParentObject; + wcscpy(NewObject->Name, ObjectName); if (ParentObject != NULL) ParentObject->RefCount++; @@ -895,6 +896,69 @@ LsapCloseDbObject(PLSA_DB_OBJECT DbObject) } +NTSTATUS +LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) +{ + PLSA_DB_OBJECT ParentObject = NULL; + WCHAR KeyName[64]; + ULONG EnumIndex; + + NTSTATUS Status = STATUS_SUCCESS; + + DbObject->RefCount--; + + if (DbObject->RefCount > 0) + return STATUS_SUCCESS; + + if (DbObject->KeyHandle != NULL) + { + EnumIndex = 0; + + while (TRUE) + { + Status = LsapRegEnumerateSubKey(DbObject->KeyHandle, + EnumIndex, + 64 * sizeof(WCHAR), + KeyName); + if (!NT_SUCCESS(Status)) + break; + + TRACE("EnumIndex: %lu\n", EnumIndex); + TRACE("Key name: %S\n", KeyName); + + Status = LsapRegDeleteKey(DbObject->KeyHandle, + KeyName); + if (!NT_SUCCESS(Status)) + break; + +// EnumIndex++; + } + + NtClose(DbObject->KeyHandle); + } + + if (DbObject->ParentObject != NULL) + { + ParentObject = DbObject->ParentObject; + + LsapRegDeleteKey(ParentObject->KeyHandle, + DbObject->Name); + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject); + + if (ParentObject != NULL) + { + ParentObject->RefCount--; + + if (ParentObject->RefCount == 0) + Status = LsapCloseDbObject(ParentObject); + } + + return Status; +} + + NTSTATUS LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject, LPWSTR AttributeName, diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index 0d91ee090a6..67375f0156b 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -1968,8 +1968,41 @@ NTSTATUS WINAPI LsarLookupPrivilegeDisplayName( NTSTATUS WINAPI LsarDeleteObject( LSAPR_HANDLE *ObjectHandle) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PLSA_DB_OBJECT DbObject; + NTSTATUS Status; + + TRACE("(%p)\n", ObjectHandle); + + if (ObjectHandle == NULL) + return STATUS_INVALID_PARAMETER; + + /* Validate the ObjectHandle */ + Status = LsapValidateDbObject(*ObjectHandle, + LsaDbIgnoreObject, + DELETE, + &DbObject); + if (!NT_SUCCESS(Status)) + { + ERR("LsapValidateDbObject returned 0x%08lx\n", Status); + return Status; + } + + /* You cannot delete the policy object */ + if (DbObject->ObjectType == LsaDbPolicyObject) + return STATUS_INVALID_PARAMETER; + + /* Delete the database object */ + Status = LsapDeleteDbObject(DbObject); + if (!NT_SUCCESS(Status)) + { + ERR("LsapDeleteDbObject returned 0x%08lx\n", Status); + return Status; + } + + /* Invalidate the object handle */ + *ObjectHandle = NULL; + + return STATUS_SUCCESS; } diff --git a/reactos/dll/win32/lsasrv/lsasrv.h b/reactos/dll/win32/lsasrv/lsasrv.h index e8182441c9e..33af276382f 100644 --- a/reactos/dll/win32/lsasrv/lsasrv.h +++ b/reactos/dll/win32/lsasrv/lsasrv.h @@ -48,6 +48,7 @@ typedef struct _LSA_DB_OBJECT ACCESS_MASK Access; HANDLE KeyHandle; struct _LSA_DB_OBJECT *ParentObject; + WCHAR Name[0]; } LSA_DB_OBJECT, *PLSA_DB_OBJECT; #define LSAP_DB_SIGNATURE 0x12345678 @@ -106,6 +107,9 @@ LsapValidateDbObject(IN LSAPR_HANDLE Handle, NTSTATUS LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject); +NTSTATUS +LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject); + NTSTATUS LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject, LPWSTR AttributeName, From 7e62b6e39ebe3622a84986ae80e317458d432660 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 26 Nov 2012 05:50:15 +0000 Subject: [PATCH 11/24] [WineTests] - Sync to 1.5.18 svn path=/trunk/; revision=57770 --- rostests/winetests/user32/sysparams.c | 137 +++++++++++++++++++++----- 1 file changed, 114 insertions(+), 23 deletions(-) diff --git a/rostests/winetests/user32/sysparams.c b/rostests/winetests/user32/sysparams.c index f3e98b61db8..3a77134e7c4 100755 --- a/rostests/winetests/user32/sysparams.c +++ b/rostests/winetests/user32/sysparams.c @@ -126,6 +126,9 @@ static HDC hdc; #define SPI_SETSCREENREADER_VALNAME_LEGACY "Blind Access" #define SPI_SETFONTSMOOTHING_REGKEY "Control Panel\\Desktop" #define SPI_SETFONTSMOOTHING_VALNAME "FontSmoothing" +#define SPI_SETFONTSMOOTHINGTYPE_VALNAME "FontSmoothingType" +#define SPI_SETFONTSMOOTHINGCONTRAST_VALNAME "FontSmoothingGamma" +#define SPI_SETFONTSMOOTHINGORIENTATION_VALNAME "FontSmoothingOrientation" #define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop" #define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive" #define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop" @@ -270,13 +273,9 @@ static BOOL test_error_msg ( int rc, const char *name ) /* * Tests the HKEY_CURRENT_USER subkey value. * The value should contain string value. - * - * Params: - * lpsSubKey - subkey name - * lpsRegName - registry entry name - * lpsTestValue - value to test */ -static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCSTR valName2, LPCSTR testValue, BOOL optional ) +static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCSTR valName2, + const void *exp_value, DWORD exp_type, BOOL optional ) { CHAR value[MAX_PATH]; DWORD valueLen; @@ -292,9 +291,20 @@ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCS RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { - ok( !strcmp( testValue, value ), - "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n", - subKey1, valName1, testValue, value ); + ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); + switch (exp_type) + { + case REG_DWORD: + ok( *(DWORD *)value == *(DWORD *)exp_value, + "Wrong value in registry: %s %s %08x/%08x\n", + subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); + break; + case REG_SZ: + ok( !strcmp( exp_value, value ), + "Wrong value in registry: %s %s '%s' instead of '%s'\n", + subKey1, valName1, value, (const char *)exp_value ); + break; + } found++; } else if (strict) @@ -311,9 +321,20 @@ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCS RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { - ok( !strcmp( testValue, value ), - "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n", - subKey1, valName2, testValue, value ); + ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); + switch (exp_type) + { + case REG_DWORD: + ok( *(DWORD *)value == *(DWORD *)exp_value, + "Wrong value in registry: %s %s %08x/%08x\n", + subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); + break; + case REG_SZ: + ok( !strcmp( exp_value, value ), + "Wrong value in registry: %s %s '%s' instead of '%s'\n", + subKey1, valName1, value, (const char *)exp_value ); + break; + } found++; } else if (strict) @@ -331,9 +352,20 @@ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCS RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { - ok( !strcmp( testValue, value ), - "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n", - subKey2, valName1, testValue, value ); + ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); + switch (exp_type) + { + case REG_DWORD: + ok( *(DWORD *)value == *(DWORD *)exp_value, + "Wrong value in registry: %s %s %08x/%08x\n", + subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); + break; + case REG_SZ: + ok( !strcmp( exp_value, value ), + "Wrong value in registry: %s %s '%s' instead of '%s'\n", + subKey1, valName1, value, (const char *)exp_value ); + break; + } found++; } else if (strict) @@ -350,9 +382,20 @@ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCS RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { - ok( !strcmp( testValue, value ), - "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n", - subKey2, valName2, testValue, value ); + ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); + switch (exp_type) + { + case REG_DWORD: + ok( *(DWORD *)value == *(DWORD *)exp_value, + "Wrong value in registry: %s %s %08x/%08x\n", + subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); + break; + case REG_SZ: + ok( !strcmp( exp_value, value ), + "Wrong value in registry: %s %s '%s' instead of '%s'\n", + subKey1, valName1, value, (const char *)exp_value ); + break; + } found++; } else if (strict) @@ -368,15 +411,17 @@ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCS } #define test_reg_key( subKey, valName, testValue ) \ - _test_reg_key( subKey, NULL, valName, NULL, testValue, FALSE ) + _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, FALSE ) #define test_reg_key_optional( subKey, valName, testValue ) \ - _test_reg_key( subKey, NULL, valName, NULL, testValue, TRUE ) + _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, TRUE ) #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \ - _test_reg_key( subKey1, subKey2, valName, NULL, testValue, FALSE ) + _test_reg_key( subKey1, subKey2, valName, NULL, testValue, REG_SZ, FALSE ) #define test_reg_key_ex2( subKey1, subKey2, valName1, valName2, testValue ) \ - _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, FALSE ) + _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, FALSE ) #define test_reg_key_ex2_optional( subKey1, subKey2, valName1, valName2, testValue ) \ - _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, TRUE ) + _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, TRUE ) +#define test_reg_key_dword( subKey, valName, testValue ) \ + _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_DWORD, FALSE ) /* get a metric from the registry. If the value is negative * it is assumed to be in twips and converted to pixels */ @@ -1942,6 +1987,7 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */ { BOOL rc; BOOL old_b; + DWORD old_type, old_contrast, old_orient; const UINT vals[]={0xffffffff,0,1,2}; unsigned int i; @@ -1951,6 +1997,9 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */ rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &old_b, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}FONTSMOOTHING")) return; + SystemParametersInfoA( SPI_GETFONTSMOOTHINGTYPE, 0, &old_type, 0 ); + SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 ); + SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 ); for (i=0;i Date: Mon, 26 Nov 2012 21:55:09 +0000 Subject: [PATCH 12/24] [LSASRV] Do not store a key name in an LSA object. Fixes CORE-6792. svn path=/trunk/; revision=57771 --- reactos/dll/win32/lsasrv/database.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/lsasrv/database.c b/reactos/dll/win32/lsasrv/database.c index ba278288ea8..3ca4363d449 100644 --- a/reactos/dll/win32/lsasrv/database.c +++ b/reactos/dll/win32/lsasrv/database.c @@ -796,7 +796,8 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject = RtlAllocateHeap(RtlGetProcessHeap(), 0, - sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR)); +// sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR)); + sizeof(LSA_DB_OBJECT)); if (NewObject == NULL) { NtClose(ObjectKeyHandle); @@ -809,7 +810,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject->Access = DesiredAccess; NewObject->KeyHandle = ObjectKeyHandle; NewObject->ParentObject = ParentObject; - wcscpy(NewObject->Name, ObjectName); +// wcscpy(NewObject->Name, ObjectName); if (ParentObject != NULL) ParentObject->RefCount++; @@ -900,9 +901,10 @@ NTSTATUS LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) { PLSA_DB_OBJECT ParentObject = NULL; +#if 0 WCHAR KeyName[64]; ULONG EnumIndex; - +#endif NTSTATUS Status = STATUS_SUCCESS; DbObject->RefCount--; @@ -912,6 +914,7 @@ LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) if (DbObject->KeyHandle != NULL) { +#if 0 EnumIndex = 0; while (TRUE) @@ -933,16 +936,17 @@ LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) // EnumIndex++; } - +#endif NtClose(DbObject->KeyHandle); } if (DbObject->ParentObject != NULL) { ParentObject = DbObject->ParentObject; - +#if 0 LsapRegDeleteKey(ParentObject->KeyHandle, DbObject->Name); +#endif } RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject); From 5c4631ef0b59812283cc75a74c73183539a4debe Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Wed, 28 Nov 2012 11:17:24 +0000 Subject: [PATCH 13/24] [REGEDIT] - Add a line break to import prompt for improved readability. Suggested by Lee Schroeder. CORE-6766 svn path=/trunk/; revision=57772 --- reactos/base/applications/regedit/lang/bg-BG.rc | 2 +- reactos/base/applications/regedit/lang/cs-CZ.rc | 2 +- reactos/base/applications/regedit/lang/de-DE.rc | 2 +- reactos/base/applications/regedit/lang/el-GR.rc | 2 +- reactos/base/applications/regedit/lang/en-US.rc | 2 +- reactos/base/applications/regedit/lang/es-ES.rc | 2 +- reactos/base/applications/regedit/lang/fr-FR.rc | 2 +- reactos/base/applications/regedit/lang/hu-HU.rc | 2 +- reactos/base/applications/regedit/lang/id-ID.rc | 2 +- reactos/base/applications/regedit/lang/it-IT.rc | 2 +- reactos/base/applications/regedit/lang/ja-JP.rc | 2 +- reactos/base/applications/regedit/lang/ko-KR.rc | 2 +- reactos/base/applications/regedit/lang/nl-NL.rc | 2 +- reactos/base/applications/regedit/lang/no-NO.rc | 2 +- reactos/base/applications/regedit/lang/pl-PL.rc | 2 +- reactos/base/applications/regedit/lang/pt-BR.rc | 2 +- reactos/base/applications/regedit/lang/pt-PT.rc | 2 +- reactos/base/applications/regedit/lang/ro-RO.rc | 2 +- reactos/base/applications/regedit/lang/ru-RU.rc | 2 +- reactos/base/applications/regedit/lang/sk-SK.rc | 2 +- reactos/base/applications/regedit/lang/sl-SI.rc | 2 +- reactos/base/applications/regedit/lang/sv-SE.rc | 2 +- reactos/base/applications/regedit/lang/th-TH.rc | 2 +- reactos/base/applications/regedit/lang/uk-UA.rc | 2 +- reactos/base/applications/regedit/lang/zh-CN.rc | 2 +- reactos/base/applications/regedit/lang/zh-TW.rc | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/reactos/base/applications/regedit/lang/bg-BG.rc b/reactos/base/applications/regedit/lang/bg-BG.rc index d893726afa1..9a89e74cd93 100644 --- a/reactos/base/applications/regedit/lang/bg-BG.rc +++ b/reactos/base/applications/regedit/lang/bg-BG.rc @@ -449,7 +449,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/cs-CZ.rc b/reactos/base/applications/regedit/lang/cs-CZ.rc index 3fe8dab3c2a..859a87f00df 100644 --- a/reactos/base/applications/regedit/lang/cs-CZ.rc +++ b/reactos/base/applications/regedit/lang/cs-CZ.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/de-DE.rc b/reactos/base/applications/regedit/lang/de-DE.rc index c718cf750e3..6087fdc3a3d 100644 --- a/reactos/base/applications/regedit/lang/de-DE.rc +++ b/reactos/base/applications/regedit/lang/de-DE.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/el-GR.rc b/reactos/base/applications/regedit/lang/el-GR.rc index 2a3b458dfd7..5ef7ffacb5e 100644 --- a/reactos/base/applications/regedit/lang/el-GR.rc +++ b/reactos/base/applications/regedit/lang/el-GR.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/en-US.rc b/reactos/base/applications/regedit/lang/en-US.rc index 14fef6bdb8c..db5e0f4a1f1 100644 --- a/reactos/base/applications/regedit/lang/en-US.rc +++ b/reactos/base/applications/regedit/lang/en-US.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/es-ES.rc b/reactos/base/applications/regedit/lang/es-ES.rc index f6028047e4d..781b47c204d 100644 --- a/reactos/base/applications/regedit/lang/es-ES.rc +++ b/reactos/base/applications/regedit/lang/es-ES.rc @@ -437,7 +437,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/fr-FR.rc b/reactos/base/applications/regedit/lang/fr-FR.rc index 1e35d35d9dd..a17cbce4b27 100644 --- a/reactos/base/applications/regedit/lang/fr-FR.rc +++ b/reactos/base/applications/regedit/lang/fr-FR.rc @@ -430,7 +430,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "L'ajout d'informations peut involontairement modifier ou supprimer des valeurs et endommager le fonctionnement de composants. Si vous n'êtes pas sûr de la source de ces informations dans '%1', ne les ajoutez pas au Registre.\n\nÊtes-vous sûr de vouloir continuer ?" + IDS_IMPORT_PROMPT "L'ajout d'informations peut involontairement modifier ou supprimer des valeurs et endommager le fonctionnement de composants.\nSi vous n'êtes pas sûr de la source de ces informations dans '%1', ne les ajoutez pas au Registre.\n\nÊtes-vous sûr de vouloir continuer ?" IDS_IMPORT_OK "Les clés et valeurs contenues dans '%1' ont été correctement ajoutées au Registre." IDS_IMPORT_ERROR "Impossible d'importer '%1' à la suite d'une erreur lors de la lecture de ce fichier. Il s'agit d'une erreur disque, ou le fichier est endommagé." IDS_EXPORT_ERROR "Impossible d'exporter dans le fichier '%1' à la suite d'une erreur lors de sa création ou d'une tentative d'écriture, pouvant être due à une erreur de disque ou de système de fichiers." diff --git a/reactos/base/applications/regedit/lang/hu-HU.rc b/reactos/base/applications/regedit/lang/hu-HU.rc index 29392b8c7d8..e17cee0e98a 100644 --- a/reactos/base/applications/regedit/lang/hu-HU.rc +++ b/reactos/base/applications/regedit/lang/hu-HU.rc @@ -435,7 +435,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/id-ID.rc b/reactos/base/applications/regedit/lang/id-ID.rc index 0ef5808c5f5..c10b1044197 100644 --- a/reactos/base/applications/regedit/lang/id-ID.rc +++ b/reactos/base/applications/regedit/lang/id-ID.rc @@ -433,7 +433,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/it-IT.rc b/reactos/base/applications/regedit/lang/it-IT.rc index 8306942784f..dbe3168b69b 100644 --- a/reactos/base/applications/regedit/lang/it-IT.rc +++ b/reactos/base/applications/regedit/lang/it-IT.rc @@ -436,7 +436,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/ja-JP.rc b/reactos/base/applications/regedit/lang/ja-JP.rc index 62ab90d610d..7cb11142b46 100644 --- a/reactos/base/applications/regedit/lang/ja-JP.rc +++ b/reactos/base/applications/regedit/lang/ja-JP.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/ko-KR.rc b/reactos/base/applications/regedit/lang/ko-KR.rc index 5d7b4315401..e56320ae3e4 100644 --- a/reactos/base/applications/regedit/lang/ko-KR.rc +++ b/reactos/base/applications/regedit/lang/ko-KR.rc @@ -419,7 +419,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/nl-NL.rc b/reactos/base/applications/regedit/lang/nl-NL.rc index 9e5ff8830f8..fe77fb233bb 100644 --- a/reactos/base/applications/regedit/lang/nl-NL.rc +++ b/reactos/base/applications/regedit/lang/nl-NL.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/no-NO.rc b/reactos/base/applications/regedit/lang/no-NO.rc index 2fbd6912f8e..85e3715c82d 100644 --- a/reactos/base/applications/regedit/lang/no-NO.rc +++ b/reactos/base/applications/regedit/lang/no-NO.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/pl-PL.rc b/reactos/base/applications/regedit/lang/pl-PL.rc index 7f9f0a7d78c..e19ba7cb92b 100644 --- a/reactos/base/applications/regedit/lang/pl-PL.rc +++ b/reactos/base/applications/regedit/lang/pl-PL.rc @@ -441,7 +441,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/pt-BR.rc b/reactos/base/applications/regedit/lang/pt-BR.rc index b463f465ddc..08b57f0bce2 100644 --- a/reactos/base/applications/regedit/lang/pt-BR.rc +++ b/reactos/base/applications/regedit/lang/pt-BR.rc @@ -435,7 +435,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/pt-PT.rc b/reactos/base/applications/regedit/lang/pt-PT.rc index 116e7fc84d2..95335f123da 100644 --- a/reactos/base/applications/regedit/lang/pt-PT.rc +++ b/reactos/base/applications/regedit/lang/pt-PT.rc @@ -436,7 +436,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/ro-RO.rc b/reactos/base/applications/regedit/lang/ro-RO.rc index ece2edc80c6..d071b61b125 100644 --- a/reactos/base/applications/regedit/lang/ro-RO.rc +++ b/reactos/base/applications/regedit/lang/ro-RO.rc @@ -432,7 +432,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/ru-RU.rc b/reactos/base/applications/regedit/lang/ru-RU.rc index 9bf863e6b5f..459214b18b1 100644 --- a/reactos/base/applications/regedit/lang/ru-RU.rc +++ b/reactos/base/applications/regedit/lang/ru-RU.rc @@ -431,7 +431,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/sk-SK.rc b/reactos/base/applications/regedit/lang/sk-SK.rc index 1696945f582..88a3967fdc4 100644 --- a/reactos/base/applications/regedit/lang/sk-SK.rc +++ b/reactos/base/applications/regedit/lang/sk-SK.rc @@ -419,7 +419,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/sl-SI.rc b/reactos/base/applications/regedit/lang/sl-SI.rc index 8971413b47f..04bdec5b2db 100644 --- a/reactos/base/applications/regedit/lang/sl-SI.rc +++ b/reactos/base/applications/regedit/lang/sl-SI.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/sv-SE.rc b/reactos/base/applications/regedit/lang/sv-SE.rc index c7a25154a1f..b682c0e0f2e 100644 --- a/reactos/base/applications/regedit/lang/sv-SE.rc +++ b/reactos/base/applications/regedit/lang/sv-SE.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/th-TH.rc b/reactos/base/applications/regedit/lang/th-TH.rc index 98318350136..792748fb745 100644 --- a/reactos/base/applications/regedit/lang/th-TH.rc +++ b/reactos/base/applications/regedit/lang/th-TH.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/uk-UA.rc b/reactos/base/applications/regedit/lang/uk-UA.rc index a19c3170378..03efe7afe0a 100644 --- a/reactos/base/applications/regedit/lang/uk-UA.rc +++ b/reactos/base/applications/regedit/lang/uk-UA.rc @@ -435,7 +435,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/zh-CN.rc b/reactos/base/applications/regedit/lang/zh-CN.rc index 6f98991630d..15b65f4bf4e 100644 --- a/reactos/base/applications/regedit/lang/zh-CN.rc +++ b/reactos/base/applications/regedit/lang/zh-CN.rc @@ -434,7 +434,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." diff --git a/reactos/base/applications/regedit/lang/zh-TW.rc b/reactos/base/applications/regedit/lang/zh-TW.rc index d2edd7a9528..23f3c943a5e 100644 --- a/reactos/base/applications/regedit/lang/zh-TW.rc +++ b/reactos/base/applications/regedit/lang/zh-TW.rc @@ -435,7 +435,7 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly. If you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" + IDS_IMPORT_PROMPT "Adding information can unintentionally change or delete values and cause components to stop working correctly.\nIf you do not trust the source of this information in '%1', do not add it to registry.\n\nAre you sure you want to continue?" IDS_IMPORT_OK "The keys and values contained in '%1' have been successfully added to the registry." IDS_IMPORT_ERROR "Cannot import '%1': Error opening the file. There may be a disk, file system error or file may not exist." IDS_EXPORT_ERROR "Cannot export '%1': Error creating or writing to the file. There may be a disk or file system error." From f8de4142cd6b35e6bfbc53d8c1cf3a7bee35f81d Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Wed, 28 Nov 2012 11:20:13 +0000 Subject: [PATCH 14/24] [REGEDIT] - Allow canceling import operations. Patch by Lee Schroeder. CORE-6766 #resolve svn path=/trunk/; revision=57773 --- reactos/base/applications/regedit/main.c | 2 +- reactos/base/applications/regedit/regedit.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/reactos/base/applications/regedit/main.c b/reactos/base/applications/regedit/main.c index acb8a7b8a0b..ea37f8ab3ae 100644 --- a/reactos/base/applications/regedit/main.c +++ b/reactos/base/applications/regedit/main.c @@ -213,7 +213,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, /* Perform application initialization */ if (!InitInstance(hInstance, nCmdShow)) { - return FALSE; + return 0; } hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(ID_ACCEL)); diff --git a/reactos/base/applications/regedit/regedit.c b/reactos/base/applications/regedit/regedit.c index 8d9ee80dee2..af456d8b7fd 100644 --- a/reactos/base/applications/regedit/regedit.c +++ b/reactos/base/applications/regedit/regedit.c @@ -158,10 +158,25 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent) /* Request import confirmation */ if (!silent) { + int choice; + LoadStringW(hInst, IDS_IMPORT_PROMPT, szText, COUNT_OF(szText)); - if (InfoMessageBox(NULL, MB_YESNO | MB_ICONWARNING, szTitle, szText, filename) != IDYES) - goto cont; + choice = InfoMessageBox(NULL, MB_YESNOCANCEL | MB_ICONWARNING, szTitle, szText, filename); + + switch (choice) + { + case IDNO: + goto cont; + case IDCANCEL: + /* The cancel case is useful if the user is importing more than one registry file + at a time, and wants to back out anytime during the import process. This way, the + user doesn't have to resort to ending the regedit process abruptly just to cancel + the operation. */ + return TRUE; + default: + break; + } } /* Open the file */ From dfa74be23eba84f10d925c2b7845fbe4573e055a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 21:57:31 +0000 Subject: [PATCH 15/24] [SERIAL] The SER_...(x) macros return UCHAR pointers, i.e. PUCHAR. svn path=/trunk/; revision=57774 --- reactos/drivers/serial/serial/serial.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/reactos/drivers/serial/serial/serial.h b/reactos/drivers/serial/serial/serial.h index b6ed661226c..98da08b4881 100644 --- a/reactos/drivers/serial/serial/serial.h +++ b/reactos/drivers/serial/serial/serial.h @@ -106,25 +106,25 @@ typedef struct _WORKITEM_DATA #define CLOCKS_PER_BIT 16 /* UART registers and bits */ -#define SER_RBR(x) ((x)+0) /* Receive Register */ -#define SER_THR(x) ((x)+0) /* Transmit Register */ -#define SER_DLL(x) ((x)+0) /* Baud Rate Divisor LSB */ -#define SER_IER(x) ((x)+1) /* Interrupt Enable Register */ +#define SER_RBR(x) ((PUCHAR)(x)+0) /* Receive Register */ +#define SER_THR(x) ((PUCHAR)(x)+0) /* Transmit Register */ +#define SER_DLL(x) ((PUCHAR)(x)+0) /* Baud Rate Divisor LSB */ +#define SER_IER(x) ((PUCHAR)(x)+1) /* Interrupt Enable Register */ #define SR_IER_DATA_RECEIVED 0x01 #define SR_IER_THR_EMPTY 0x02 #define SR_IER_LSR_CHANGE 0x04 #define SR_IER_MSR_CHANGE 0x08 #define SR_IER_SLEEP_MODE 0x10 /* Uart >= 16750 */ #define SR_IER_LOW_POWER 0x20 /* Uart >= 16750 */ -#define SER_DLM(x) ((x)+1) /* Baud Rate Divisor MSB */ -#define SER_IIR(x) ((x)+2) /* Interrupt Identification Register */ +#define SER_DLM(x) ((PUCHAR)(x)+1) /* Baud Rate Divisor MSB */ +#define SER_IIR(x) ((PUCHAR)(x)+2) /* Interrupt Identification Register */ #define SR_IIR_SELF 0x00 #define SR_IIR_ID_MASK 0x07 #define SR_IIR_MSR_CHANGE SR_IIR_SELF #define SR_IIR_THR_EMPTY (SR_IIR_SELF | 2) #define SR_IIR_DATA_RECEIVED (SR_IIR_SELF | 4) #define SR_IIR_ERROR (SR_IIR_SELF | 6) -#define SER_FCR(x) ((x)+2) /* FIFO Control Register (Uart >= 16550A) */ +#define SER_FCR(x) ((PUCHAR)(x)+2) /* FIFO Control Register (Uart >= 16550A) */ #define SR_FCR_ENABLE_FIFO 0x01 #define SR_FCR_CLEAR_RCVR (0x02 | SR_FCR_ENABLE_FIFO) #define SR_FCR_CLEAR_XMIT (0x04 | SR_FCR_ENABLE_FIFO) @@ -132,7 +132,7 @@ typedef struct _WORKITEM_DATA #define SR_FCR_4_BYTES (0x40 | SR_FCR_ENABLE_FIFO) #define SR_FCR_8_BYTES (0x80 | SR_FCR_ENABLE_FIFO) #define SR_FCR_14_BYTES (0xC0 | SR_FCR_ENABLE_FIFO) -#define SER_LCR(x) ((x)+3) /* Line Control Register */ +#define SER_LCR(x) ((PUCHAR)(x)+3) /* Line Control Register */ #define SR_LCR_CS5 0x00 #define SR_LCR_CS6 0x01 #define SR_LCR_CS7 0x02 @@ -146,10 +146,10 @@ typedef struct _WORKITEM_DATA #define SR_LCR_PSP 0x38 #define SR_LCR_BRK 0x40 #define SR_LCR_DLAB 0x80 -#define SER_MCR(x) ((x)+4) /* Modem Control Register */ +#define SER_MCR(x) ((PUCHAR)(x)+4) /* Modem Control Register */ #define SR_MCR_DTR SERIAL_DTR_STATE #define SR_MCR_RTS SERIAL_RTS_STATE -#define SER_LSR(x) ((x)+5) /* Line Status Register */ +#define SER_LSR(x) ((PUCHAR)(x)+5) /* Line Status Register */ #define SR_LSR_DATA_RECEIVED 0x01 #define SR_LSR_OVERRUN_ERROR 0x02 #define SR_LSR_PARITY_ERROR 0x04 @@ -158,7 +158,7 @@ typedef struct _WORKITEM_DATA #define SR_LSR_THR_EMPTY 0x20 #define SR_LSR_TSR_EMPTY 0x40 #define SR_LSR_ERROR_IN_FIFO 0x80 /* Uart >= 16550A */ -#define SER_MSR(x) ((x)+6) /* Modem Status Register */ +#define SER_MSR(x) ((PUCHAR)(x)+6) /* Modem Status Register */ #define SR_MSR_CTS_CHANGED 0x01 #define SR_MSR_DSR_CHANGED 0x02 #define SR_MSR_RI_CHANGED 0x04 @@ -167,7 +167,7 @@ typedef struct _WORKITEM_DATA #define SR_MSR_DSR SERIAL_DSR_STATE /* Data Set Ready */ #define SI_MSR_RI SERIAL_RI_STATE /* Ring Indicator */ #define SR_MSR_DCD SERIAL_DCD_STATE /* Data Carrier Detect */ -#define SER_SCR(x) ((x)+7) /* Scratch Pad Register, Uart >= Uart16450 */ +#define SER_SCR(x) ((PUCHAR)(x)+7) /* Scratch Pad Register, Uart >= Uart16450 */ /************************************ circularbuffer.c */ From 39f19b3ed5e5d33e12f2d787a23ff4043da70a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 22:03:07 +0000 Subject: [PATCH 16/24] [SERIAL] Comment the different defines. svn path=/trunk/; revision=57775 --- .../include/reactos/drivers/serial/ns16550.h | 158 +++++++++++------- 1 file changed, 101 insertions(+), 57 deletions(-) diff --git a/reactos/include/reactos/drivers/serial/ns16550.h b/reactos/include/reactos/drivers/serial/ns16550.h index 027dd105020..1ee89668de4 100644 --- a/reactos/include/reactos/drivers/serial/ns16550.h +++ b/reactos/include/reactos/drivers/serial/ns16550.h @@ -10,60 +10,93 @@ #pragma once -/* Note: These definitions are the internal definitions used by Microsoft serial - driver (see src/kernel/serial/serial.h in WDK source code). Linux uses its own, - as do most other OS. +/* Note: These definitions are the internal definitions used by Microsoft + Serial Driver (see src/serial/serial/serial.h in WDK source code). + Linux uses its own, as do most other OS. */ +/* Baud master clock */ +// #define BAUD_CLOCK 1843200 +// #define CLOCKS_PER_BIT 16 +#define CLOCK_RATE 115200 // UART clock rate == BAUD_CLOCK / CLOCKS_PER_BIT + +// Define the spacing between registers. #if !defined(SERIAL_REGISTER_STRIDE) #define SERIAL_REGISTER_STRIDE 1 #endif -#define RECEIVE_BUFFER_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) -#define TRANSMIT_HOLDING_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) -#define INTERRUPT_ENABLE_REGISTER ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE)) -#define INTERRUPT_IDENT_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE)) -#define FIFO_CONTROL_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE)) -#define LINE_CONTROL_REGISTER ((ULONG)((0x03)*SERIAL_REGISTER_STRIDE)) -#define MODEM_CONTROL_REGISTER ((ULONG)((0x04)*SERIAL_REGISTER_STRIDE)) -#define LINE_STATUS_REGISTER ((ULONG)((0x05)*SERIAL_REGISTER_STRIDE)) -#define MODEM_STATUS_REGISTER ((ULONG)((0x06)*SERIAL_REGISTER_STRIDE)) -#define DIVISOR_LATCH_LSB ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) -#define DIVISOR_LATCH_MSB ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE)) -#define SERIAL_REGISTER_SPAN ((ULONG)(7*SERIAL_REGISTER_STRIDE)) -#define SERIAL_STATUS_LENGTH ((ULONG)(1*SERIAL_REGISTER_STRIDE)) +/* + * Offsets of the various registers, from the base register address. + */ +#define RECEIVE_BUFFER_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) +#define TRANSMIT_HOLDING_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) +#define INTERRUPT_ENABLE_REGISTER ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE)) +#define INTERRUPT_IDENT_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE)) +#define FIFO_CONTROL_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE)) +#define LINE_CONTROL_REGISTER ((ULONG)((0x03)*SERIAL_REGISTER_STRIDE)) +#define MODEM_CONTROL_REGISTER ((ULONG)((0x04)*SERIAL_REGISTER_STRIDE)) +#define LINE_STATUS_REGISTER ((ULONG)((0x05)*SERIAL_REGISTER_STRIDE)) +#define MODEM_STATUS_REGISTER ((ULONG)((0x06)*SERIAL_REGISTER_STRIDE)) +#define SCRATCH_REGISTER ((ULONG)((0x07)*SERIAL_REGISTER_STRIDE)) -#define SERIAL_DATA_LENGTH_5 0x00 -#define SERIAL_DATA_LENGTH_6 0x01 -#define SERIAL_DATA_LENGTH_7 0x02 -#define SERIAL_DATA_LENGTH_8 0x03 +#define DIVISOR_LATCH_LSB ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE)) +#define DIVISOR_LATCH_MSB ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE)) +#define SERIAL_REGISTER_LENGTH ((ULONG)(7*SERIAL_REGISTER_STRIDE)) -#define SERIAL_IER_RDA 0x01 -#define SERIAL_IER_THR 0x02 -#define SERIAL_IER_RLS 0x04 -#define SERIAL_IER_MS 0x08 +// Length of the interrupt status register. +#define SERIAL_STATUS_LENGTH ((ULONG)(1*SERIAL_REGISTER_STRIDE)) +/* + * Start, Data, Parity, Stop number of data bits + * transmitted in the Serial Data Unit. + */ +#define SERIAL_DATA_LENGTH_5 0x00 +#define SERIAL_DATA_LENGTH_6 0x01 +#define SERIAL_DATA_LENGTH_7 0x02 +#define SERIAL_DATA_LENGTH_8 0x03 + +/* + * Masks defining the interrupts that can be enabled or disabled. + */ +#define SERIAL_IER_RDA 0x01 // New incoming data available. +#define SERIAL_IER_THR 0x02 // Space available for another octet in the transmitter. +#define SERIAL_IER_RLS 0x04 // Error occurred with incoming data. +#define SERIAL_IER_MS 0x08 // Change occurred in the modem control line. + +/* + * Interrupt Identification Register masks. + */ #define SERIAL_IIR_RLS 0x06 #define SERIAL_IIR_RDA 0x04 #define SERIAL_IIR_CTI 0x0c #define SERIAL_IIR_THR 0x02 #define SERIAL_IIR_MS 0x00 -#define SERIAL_IIR_FIFOS_ENABLED 0xc0 +#define SERIAL_IIR_FIFOS_ENABLED 0xc0 #define SERIAL_IIR_NO_INTERRUPT_PENDING 0x01 -#define SERIAL_IIR_MUST_BE_ZERO 0x30 +#define SERIAL_IIR_MUST_BE_ZERO 0x30 -#define SERIAL_FCR_ENABLE ((UCHAR)0x01) -#define SERIAL_FCR_RCVR_RESET ((UCHAR)0x02) -#define SERIAL_FCR_TXMT_RESET ((UCHAR)0x04) +/* + * Fifo Control Register accessing masks. + */ +#define SERIAL_FCR_DISABLE ((UCHAR)0x00) +#define SERIAL_FCR_ENABLE ((UCHAR)0x01) +#define SERIAL_FCR_RCVR_RESET ((UCHAR)0x02) +#define SERIAL_FCR_TXMT_RESET ((UCHAR)0x04) -#define SERIAL_1_BYTE_HIGH_WATER ((UCHAR)0x00) -#define SERIAL_4_BYTE_HIGH_WATER ((UCHAR)0x40) -#define SERIAL_8_BYTE_HIGH_WATER ((UCHAR)0x80) -#define SERIAL_14_BYTE_HIGH_WATER ((UCHAR)0xc0) +#define SERIAL_1_BYTE_HIGH_WATER ((UCHAR)0x00) +#define SERIAL_4_BYTE_HIGH_WATER ((UCHAR)0x40) +#define SERIAL_8_BYTE_HIGH_WATER ((UCHAR)0x80) +#define SERIAL_14_BYTE_HIGH_WATER ((UCHAR)0xc0) -#define SERIAL_LCR_DLAB 0x80 -#define SERIAL_LCR_BREAK 0x40 +/* + * Line Control Register accessing masks. + */ +#define SERIAL_LCR_DLAB 0x80 // Divisor Latch Access Bit +#define SERIAL_LCR_BREAK 0x40 // Send a break +/* + * Line Control Register setting bits. + */ #define SERIAL_5_DATA ((UCHAR)0x00) #define SERIAL_6_DATA ((UCHAR)0x01) #define SERIAL_7_DATA ((UCHAR)0x02) @@ -82,27 +115,38 @@ #define SERIAL_SPACE_PARITY ((UCHAR)0x38) #define SERIAL_PARITY_MASK ((UCHAR)0x38) -#define SERIAL_MCR_DTR 0x01 -#define SERIAL_MCR_RTS 0x02 -#define SERIAL_MCR_OUT1 0x04 -#define SERIAL_MCR_OUT2 0x08 -#define SERIAL_MCR_LOOP 0x10 -#define SERIAL_MCR_TL16C550CAFE 0x20 +/* + * Modem Control Register accessing masks. + */ +#define SERIAL_MCR_DTR 0x01 // Controls the Data Terminal Ready line +#define SERIAL_MCR_RTS 0x02 // Controls the Ready To Send line +#define SERIAL_MCR_OUT1 0x04 // General purpose output +#define SERIAL_MCR_OUT2 0x08 // General purpose output +#define SERIAL_MCR_LOOP 0x10 // Controls the loopback testing mode +#define SERIAL_MCR_TL16C550CAFE 0x20 // Enables Auto Flow Control on a TI TL16C550C -#define SERIAL_LSR_DR 0x01 -#define SERIAL_LSR_OE 0x02 -#define SERIAL_LSR_PE 0x04 -#define SERIAL_LSR_FE 0x08 -#define SERIAL_LSR_BI 0x10 -#define SERIAL_LSR_THRE 0x20 -#define SERIAL_LSR_TEMT 0x40 -#define SERIAL_LSR_FIFOERR 0x80 +/* + * Line Status Register accessing masks. + */ +#define SERIAL_LSR_DR 0x01 // Data Ready indicator +#define SERIAL_LSR_OE 0x02 // Overrun indicator +#define SERIAL_LSR_PE 0x04 // Parity Error indicator +#define SERIAL_LSR_FE 0x08 // Framing Error indicator +#define SERIAL_LSR_BI 0x10 // Break Interrupt indicator +#define SERIAL_LSR_THRE 0x20 // Transmit Holding Register Empty indicator +#define SERIAL_LSR_TEMT 0x40 // Transmitter Empty indicator +#define SERIAL_LSR_FIFOERR 0x80 // Fifo Error indicator -#define SERIAL_MSR_DCTS 0x01 -#define SERIAL_MSR_DDSR 0x02 -#define SERIAL_MSR_TERI 0x04 -#define SERIAL_MSR_DDCD 0x08 -#define SERIAL_MSR_CTS 0x10 -#define SERIAL_MSR_DSR 0x20 -#define SERIAL_MSR_RI 0x40 -#define SERIAL_MSR_DCD 0x80 +/* + * Modem Status Register accessing masks. + */ +#define SERIAL_MSR_DCTS 0x01 // Delta Clear To Send +#define SERIAL_MSR_DDSR 0x02 // Delta Data Set Ready +#define SERIAL_MSR_TERI 0x04 // Trailing Edge Ring Indicator +#define SERIAL_MSR_DDCD 0x08 // Delta Data Carrier Detect +#define SERIAL_MSR_CTS 0x10 // Clear To Send +#define SERIAL_MSR_DSR 0x20 // Data Set Ready +#define SERIAL_MSR_RI 0x40 // Ring Indicator +#define SERIAL_MSR_DCD 0x80 // Data Carrier Detect + +/* EOF */ From da43d9219e63efea1db7e1b60040dc323059a616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 22:12:29 +0000 Subject: [PATCH 17/24] [CPORTLIB] - Do a synthesis of all the code I've found concerning initializing COM ports (in kdcom / kddll / kdbg in the kernel and in freeldr). The "// Windows" comments concern the original code for testing the existence of COM ports, inside cportlib, whereas "// ReactOS" comments concern the equivalent existing in our kdcom/kddll/kdbg etc... - CORRECT THE VIRTUAL PC COM PORT INITIALIZATION !! The problem was, that the current COM port existence test fails on VPC whereas it works well in all other virtual machines. Therefore : * I keep the existing testing code in a function called ComPortTest1, this works everywhere but on VPC ; * I add a very basic COM port existence test function called ComPortTest2, which basically looks for the scratch register, this works everywhere including on VPC. * The COM port existence test consists in the two tests above. svn path=/trunk/; revision=57776 --- .../include/reactos/libs/cportlib/cportlib.h | 47 ++-- reactos/lib/cportlib/cport.c | 233 ++++++++++++------ 2 files changed, 189 insertions(+), 91 deletions(-) diff --git a/reactos/include/reactos/libs/cportlib/cportlib.h b/reactos/include/reactos/libs/cportlib/cportlib.h index 31b76158bc6..b7681f7d337 100644 --- a/reactos/include/reactos/libs/cportlib/cportlib.h +++ b/reactos/include/reactos/libs/cportlib/cportlib.h @@ -10,26 +10,25 @@ #include +// +// Return error codes. +// #define CP_GET_SUCCESS 0 #define CP_GET_NODATA 1 #define CP_GET_ERROR 2 +// +// COM port flags. +// #define CPPORT_FLAG_MODEM_CONTROL 0x02 + typedef struct _CPPORT { PUCHAR Address; - ULONG Baud; + ULONG BaudRate; USHORT Flags; } CPPORT, *PCPPORT; -VOID -NTAPI -CpInitialize( - IN PCPPORT Port, - IN PUCHAR Address, - IN ULONG Rate -); - VOID NTAPI CpEnableFifo( @@ -37,6 +36,21 @@ CpEnableFifo( IN BOOLEAN Enable ); +VOID +NTAPI +CpSetBaud( + IN PCPPORT Port, + IN ULONG BaudRate +); + +NTSTATUS +NTAPI +CpInitialize( + IN PCPPORT Port, + IN PUCHAR Address, + IN ULONG BaudRate +); + BOOLEAN NTAPI CpDoesPortExist( @@ -50,20 +64,13 @@ CpReadLsr( IN UCHAR ExpectedValue ); -VOID -NTAPI -CpSetBaud( - IN PCPPORT Port, - IN ULONG Rate -); - USHORT NTAPI CpGetByte( - IN PCPPORT Port, - IN PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll + IN PCPPORT Port, + OUT PUCHAR Byte, + IN BOOLEAN Wait, + IN BOOLEAN Poll ); VOID diff --git a/reactos/lib/cportlib/cport.c b/reactos/lib/cportlib/cport.c index 97d281f71ce..7279b69893b 100644 --- a/reactos/lib/cportlib/cport.c +++ b/reactos/lib/cportlib/cport.c @@ -11,6 +11,10 @@ * documented their serial algorithms, we use the same ones to stay "compliant". * Do not change this code to "improve" it. It's done this way on purpose, at least on x86. * -- sir_richard + * + * REPLY: I reworked the COM-port testing code because the original one + * (i.e. the Microsoft's documented one) doesn't work on Virtual PC 2007. + * -- hbelusca */ /* NOTE: This code is used by Headless Support (Ntoskrnl.exe and Osloader.exe) and @@ -30,47 +34,100 @@ #include #include #include +#include + +#define NDEBUG #include /* GLOBALS ********************************************************************/ +// Wait timeout value +#define TIMEOUT_COUNT 1024 * 200 + UCHAR RingIndicator; + /* FUNCTIONS ******************************************************************/ -VOID -NTAPI -CpInitialize(IN PCPPORT Port, - IN PUCHAR Address, - IN ULONG Rate) -{ - /* Reset port data */ - Port->Address = Address; - Port->Baud = 0; - - /* Set the baud rate */ - CpSetBaud(Port, Rate); - - /* Enable on DTR and RTS */ - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, - SERIAL_MCR_DTR | SERIAL_MCR_RTS); - - /* Disable interrupts */ - WRITE_PORT_UCHAR(Address + INTERRUPT_ENABLE_REGISTER, 0); -} - VOID NTAPI CpEnableFifo(IN PUCHAR Address, IN BOOLEAN Enable) { - /* Set FIFO */ - WRITE_PORT_UCHAR(Address + FIFO_CONTROL_REGISTER, Enable ? SERIAL_FCR_ENABLE : 0); + /* Set FIFO and clear the receive/transmit buffers */ + WRITE_PORT_UCHAR(Address + FIFO_CONTROL_REGISTER, + Enable ? SERIAL_FCR_ENABLE | SERIAL_FCR_RCVR_RESET | SERIAL_FCR_TXMT_RESET + : SERIAL_FCR_DISABLE); } -BOOLEAN +VOID NTAPI -CpDoesPortExist(IN PUCHAR Address) +CpSetBaud(IN PCPPORT Port, + IN ULONG BaudRate) +{ + UCHAR Lcr; + ULONG Mode = CLOCK_RATE / BaudRate; + + /* Set the DLAB on */ + Lcr = READ_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER); + WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, Lcr | SERIAL_LCR_DLAB); + + /* Set the baud rate */ + WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_LSB, (UCHAR)(Mode & 0xFF)); + WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_MSB, (UCHAR)((Mode >> 8) & 0xFF)); + + /* Reset DLAB */ + WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, Lcr); + + /* Save baud rate in port */ + Port->BaudRate = BaudRate; +} + +NTSTATUS +NTAPI +CpInitialize(IN PCPPORT Port, + IN PUCHAR Address, + IN ULONG BaudRate) +{ + /* Validity checks */ + if (Port == NULL || Address == NULL || BaudRate == 0) + return STATUS_INVALID_PARAMETER; + + if (!CpDoesPortExist(Address)) + return STATUS_NOT_FOUND; + + /* Initialize port data */ + Port->Address = Address; + Port->BaudRate = 0; + Port->Flags = 0; + + /* Disable the interrupts */ + WRITE_PORT_UCHAR(Address + LINE_CONTROL_REGISTER, 0); + WRITE_PORT_UCHAR(Address + INTERRUPT_ENABLE_REGISTER, 0); + + /* Turn on DTR, RTS and OUT2 */ + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, + SERIAL_MCR_DTR | SERIAL_MCR_RTS | SERIAL_MCR_OUT2); + + /* Set the baud rate */ + CpSetBaud(Port, BaudRate); + + /* Set 8 data bits, 1 stop bit, no parity, no break */ + WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, + SERIAL_8_DATA | SERIAL_1_STOP | SERIAL_NONE_PARITY); + + /* Turn on FIFO */ + // TODO: Check whether FIFO exists and turn it on in that case. + CpEnableFifo(Address, TRUE); // for 16550 + + /* Read junk out of the RBR */ + (VOID)READ_PORT_UCHAR(Address + RECEIVE_BUFFER_REGISTER); + + return STATUS_SUCCESS; +} + +static BOOLEAN +ComPortTest1(IN PUCHAR Address) { /* * See "Building Hardware and Firmware to Complement Microsoft Windows Headless Operation" @@ -89,28 +146,87 @@ CpDoesPortExist(IN PUCHAR Address) * 5. The modem status register is read and the ring indicator is checked. * This means SERIAL_MSR_RI should be set. * 6. Restore original modem status register. + * + * REMARK: Strangely enough, the Virtual PC 2007 virtual machine + * doesn't pass this test. */ - UCHAR Old = READ_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER); + BOOLEAN RetVal = FALSE; + UCHAR Mcr, Msr; - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP); + /* Save the Modem Control Register */ + Mcr = READ_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER); + + /* Enable loop (diagnostic) mode (set Bit 4 of the MCR) */ WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP); - if (!(READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & - (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD))) + /* Clear all modem output bits */ + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP); + + /* Read the Modem Status Register */ + Msr = READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER); + + /* + * The upper nibble of the MSR (modem output bits) must be + * equal to the lower nibble of the MCR (modem input bits). + */ + if ((Msr & (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD)) == 0x00) { + /* Set all modem output bits */ WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, - (SERIAL_MCR_OUT1 | SERIAL_MCR_LOOP)); - if (READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & SERIAL_MSR_RI) + SERIAL_MCR_OUT1 | SERIAL_MCR_LOOP); // Windows +/* ReactOS + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, + SERIAL_MCR_DTR | SERIAL_MCR_RTS | SERIAL_MCR_OUT1 | SERIAL_MCR_OUT2 | SERIAL_MCR_LOOP); +*/ + + /* Read the Modem Status Register */ + Msr = READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER); + + /* + * The upper nibble of the MSR (modem output bits) must be + * equal to the lower nibble of the MCR (modem input bits). + */ + if (Msr & SERIAL_MSR_RI) // Windows + // if (Msr & (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD) == 0xF0) // ReactOS { - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old); - return TRUE; + RetVal = TRUE; } } - WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old); + /* Restore the MCR */ + WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Mcr); - return FALSE; + return RetVal; +} + +static BOOLEAN +ComPortTest2(IN PUCHAR Address) +{ + /* + * This test checks whether the 16450/16550 scratch register is available. + * If not, the serial port is considered as unexisting. + */ + + UCHAR Byte = 0; + + do + { + WRITE_PORT_UCHAR(Address + SCRATCH_REGISTER, Byte); + + if (READ_PORT_UCHAR(Address + SCRATCH_REGISTER) != Byte) + return FALSE; + + } while (++Byte != 0); + + return TRUE; +} + +BOOLEAN +NTAPI +CpDoesPortExist(IN PUCHAR Address) +{ + return ( ComPortTest1(Address) || ComPortTest2(Address) ); } UCHAR @@ -135,54 +251,28 @@ CpReadLsr(IN PCPPORT Port, return Lsr; } -VOID -NTAPI -CpSetBaud(IN PCPPORT Port, - IN ULONG Rate) -{ - UCHAR Lcr; - USHORT Mode; - - /* Add DLAB */ - Lcr = READ_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER); - WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, Lcr | SERIAL_LCR_DLAB); - - /* Set baud rate */ - Mode = (USHORT)(115200 / Rate); - WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_MSB, (UCHAR)((Mode >> 8) & 0xff)); - WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_LSB, (UCHAR)(Mode & 0xff)); - - /* Reset DLAB and set 8 data bits, 1 stop bit, no parity, no break */ - WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, - SERIAL_8_DATA | SERIAL_1_STOP | SERIAL_NONE_PARITY); - - /* Save baud rate in port */ - Port->Baud = Rate; -} - USHORT NTAPI -CpGetByte(IN PCPPORT Port, - IN PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll) +CpGetByte(IN PCPPORT Port, + OUT PUCHAR Byte, + IN BOOLEAN Wait, + IN BOOLEAN Poll) { UCHAR Lsr; - ULONG i; + ULONG LimitCount = Wait ? TIMEOUT_COUNT : 1; /* Handle early read-before-init */ if (!Port->Address) return CP_GET_NODATA; /* If "wait" mode enabled, spin many times, otherwise attempt just once */ - i = Wait ? 204800 : 1; - while (i--) + while (LimitCount--) { /* Read LSR for data ready */ Lsr = CpReadLsr(Port, SERIAL_LSR_DR); if ((Lsr & SERIAL_LSR_DR) == SERIAL_LSR_DR) { /* If an error happened, clear the byte and fail */ - if (Lsr & (SERIAL_LSR_FE | SERIAL_LSR_PE)) + if (Lsr & (SERIAL_LSR_FE | SERIAL_LSR_PE | SERIAL_LSR_OE)) { *Byte = 0; return CP_GET_ERROR; @@ -217,17 +307,18 @@ CpPutByte(IN PCPPORT Port, IN UCHAR Byte) { /* Check if port is in modem control to handle CD */ - while (Port->Flags & CPPORT_FLAG_MODEM_CONTROL) + // while (Port->Flags & CPPORT_FLAG_MODEM_CONTROL) // Commented for the moment. + if (Port->Flags & CPPORT_FLAG_MODEM_CONTROL) // To be removed when this becomes implemented. { /* Not implemented yet */ DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n"); } /* Wait for LSR to say we can go ahead */ - while (!(CpReadLsr(Port, SERIAL_LSR_THRE) & SERIAL_LSR_THRE)); + while ((CpReadLsr(Port, SERIAL_LSR_THRE) & SERIAL_LSR_THRE) == 0x00); /* Send the byte */ - WRITE_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER, Byte); + WRITE_PORT_UCHAR(Port->Address + TRANSMIT_HOLDING_REGISTER, Byte); } /* EOF */ From 2c0b925b1fecfc2e8564d8e785378e9af3b8d22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 22:16:15 +0000 Subject: [PATCH 18/24] [FREELDR] - Make use of the previously committed cportlib code. This works great on VPC 2007 :) - Comment the unused Rs232PortPollByte function. - In hardware.c, add useful comments and two macros holding the maximum number of COM and LPT ports. svn path=/trunk/; revision=57777 --- .../boot/freeldr/freeldr/arch/i386/hardware.c | 33 ++- reactos/boot/freeldr/freeldr/comm/rs232.c | 251 +++++------------- reactos/boot/freeldr/freeldr/include/comm.h | 4 +- 3 files changed, 91 insertions(+), 197 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c index 279f1a49f39..fe547ec0803 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c @@ -20,6 +20,7 @@ */ #include +#include #define NDEBUG #include @@ -32,6 +33,10 @@ #define LATCH (CLOCK_TICK_RATE / HZ) +/* Maximum number of COM and LPT ports */ +#define MAX_COM_PORTS 4 +#define MAX_LPT_PORTS 3 + /* No Mouse */ #define MOUSE_TYPE_NONE 0 /* Microsoft Mouse with 2 buttons */ @@ -1042,7 +1047,7 @@ DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey) PCM_PARTIAL_RESOURCE_LIST PartialResourceList; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; PCM_SERIAL_DEVICE_DATA SerialDeviceData; - ULONG Irq[4] = {4, 3, 4, 3}; + ULONG Irq[MAX_COM_PORTS] = {4, 3, 4, 3}; ULONG Base; CHAR Buffer[80]; PUSHORT BasePtr; @@ -1053,12 +1058,17 @@ DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey) TRACE("DetectSerialPorts()\n"); - ControllerNumber = 0; + /* + * The BIOS data area 0x400 holds the address of the first valid COM port. + * Each COM port address is stored in a 2-byte field. + * Infos at: http://www.bioscentral.com/misc/bda.htm + */ BasePtr = (PUSHORT)0x400; - for (i = 0; i < 2; i++, BasePtr++) + + for (i = 0; i < MAX_COM_PORTS; i++, BasePtr++) { Base = (ULONG)*BasePtr; - if (Base == 0) + if (Base == 0 || !CpDoesPortExist((PUCHAR)Base)) continue; TRACE("Found COM%u port at 0x%x\n", i + 1, Base); @@ -1126,7 +1136,7 @@ DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey) MmHeapFree(PartialResourceList); - if (!Rs232PortInUse(Base)) + if (!Rs232PortInUse(UlongToPtr(Base))) { /* Detect serial mouse */ DetectSerialPointerPeripheral(ControllerKey, UlongToPtr(Base)); @@ -1142,20 +1152,25 @@ DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey) { PCM_PARTIAL_RESOURCE_LIST PartialResourceList; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; - ULONG Irq[3] = {7, 5, (ULONG)-1}; + ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG)-1}; CHAR Buffer[80]; PCONFIGURATION_COMPONENT_DATA ControllerKey; PUSHORT BasePtr; ULONG Base; - ULONG ControllerNumber; + ULONG ControllerNumber = 0; ULONG i; ULONG Size; TRACE("DetectParallelPorts() called\n"); - ControllerNumber = 0; + /* + * The BIOS data area 0x408 holds the address of the first valid LPT port. + * Each LPT port address is stored in a 2-byte field. + * Infos at: http://www.bioscentral.com/misc/bda.htm + */ BasePtr = (PUSHORT)0x408; - for (i = 0; i < 3; i++, BasePtr++) + + for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++) { Base = (ULONG)*BasePtr; if (Base == 0) diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/comm/rs232.c index 0ef92cef2cd..ee46345feb7 100644 --- a/reactos/boot/freeldr/freeldr/comm/rs232.c +++ b/reactos/boot/freeldr/freeldr/comm/rs232.c @@ -22,6 +22,7 @@ #ifndef _M_ARM #include +#include /* MACROS *******************************************************************/ @@ -62,227 +63,105 @@ /* STATIC VARIABLES *********************************************************/ -static ULONG Rs232ComPort = 0; -static ULONG Rs232BaudRate = 0; -static PUCHAR Rs232PortBase = (PUCHAR)0; +static ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; -/* The com port must only be initialized once! */ +/* The COM port must only be initialized once! */ +static CPPORT Rs232ComPort; static BOOLEAN PortInitialized = FALSE; -/* STATIC FUNCTIONS *********************************************************/ - -static BOOLEAN Rs232DoesComPortExist(PUCHAR BaseAddress) -{ - BOOLEAN found; - UCHAR mcr; - UCHAR msr; - - found = FALSE; - - /* save Modem Control Register (MCR) */ - mcr = READ_PORT_UCHAR (SER_MCR(BaseAddress)); - - /* enable loop mode (set Bit 4 of the MCR) */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10); - - /* clear all modem output bits */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR (SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0x00) - { - /* set all modem output bits */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x1F); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR (SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0xF0) - found = TRUE; - } - - /* restore MCR */ - WRITE_PORT_UCHAR (SER_MCR(BaseAddress), mcr); - - return (found); -} /* FUNCTIONS *********************************************************/ -BOOLEAN Rs232PortInitialize(ULONG ComPort, ULONG BaudRate) +BOOLEAN Rs232PortInitialize(IN ULONG ComPort, + IN ULONG BaudRate) { - ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; - //char buffer[80]; - ULONG divisor; - UCHAR lcr; + NTSTATUS Status; + PUCHAR Address; - if (PortInitialized == FALSE) + if (PortInitialized == FALSE) + { + if (BaudRate == 0) { - if (BaudRate != 0) - { - Rs232BaudRate = BaudRate; - } - else - { - Rs232BaudRate = DEFAULT_BAUD_RATE; - } - - if (ComPort == 0) - { - if (Rs232DoesComPortExist ((PUCHAR)(ULONG_PTR)BaseArray[2])) - { - Rs232PortBase = (PUCHAR)(ULONG_PTR)BaseArray[2]; - Rs232ComPort = 2; -/*#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif*/ /* NDEBUG */ - } - else if (Rs232DoesComPortExist ((PUCHAR)(ULONG_PTR)BaseArray[1])) - { - Rs232PortBase = (PUCHAR)(ULONG_PTR)BaseArray[1]; - Rs232ComPort = 1; -/*#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif*/ /* NDEBUG */ - } - else - { - /*sprintf (buffer, - "\nKernel Debugger: No COM port found!!!\n\n"); - HalDisplayString (buffer);*/ - return FALSE; - } - } - else - { - if (Rs232DoesComPortExist ((PUCHAR)(ULONG_PTR)BaseArray[ComPort])) - { - Rs232PortBase = (PUCHAR)(ULONG_PTR)BaseArray[ComPort]; - Rs232ComPort = ComPort; -/*#ifndef NDEBUG - sprintf (buffer, - "\nSerial port COM%ld found at 0x%lx\n", - ComPort, - (ULONG)PortBase); - HalDisplayString (buffer); -#endif*/ /* NDEBUG */ - } - else - { - /*sprintf (buffer, - "\nKernel Debugger: No serial port found!!!\n\n"); - HalDisplayString (buffer);*/ - return FALSE; - } - } - - PortInitialized = TRUE; + BaudRate = DEFAULT_BAUD_RATE; } - /* - * set baud rate and data format (8N1) - */ + if (ComPort == 0) + { + if (CpDoesPortExist(UlongToPtr(BaseArray[2]))) + { + Address = UlongToPtr(BaseArray[2]); + } + else if (CpDoesPortExist(UlongToPtr(BaseArray[1]))) + { + Address = UlongToPtr(BaseArray[1]); + } + else + { + return FALSE; + } + } + else if (ComPort <= 4) // 4 == MAX_COM_PORTS + { + if (CpDoesPortExist(UlongToPtr(BaseArray[ComPort]))) + { + Address = UlongToPtr(BaseArray[ComPort]); + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } - /* turn on DTR and RTS */ - WRITE_PORT_UCHAR (SER_MCR(Rs232PortBase), SR_MCR_DTR | SR_MCR_RTS); + Status = CpInitialize(&Rs232ComPort, Address, BaudRate); + if (!NT_SUCCESS(Status)) return FALSE; - /* set DLAB */ - lcr = READ_PORT_UCHAR (SER_LCR(Rs232PortBase)) | SR_LCR_DLAB; - WRITE_PORT_UCHAR (SER_LCR(Rs232PortBase), lcr); + PortInitialized = TRUE; + } - /* set baud rate */ - divisor = 115200 / BaudRate; - WRITE_PORT_UCHAR (SER_DLL(Rs232PortBase), divisor & 0xff); - WRITE_PORT_UCHAR (SER_DLM(Rs232PortBase), (divisor >> 8) & 0xff); - - /* reset DLAB and set 8N1 format */ - WRITE_PORT_UCHAR (SER_LCR(Rs232PortBase), - SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO); - - /* read junk out of the RBR */ - lcr = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); - - /* - * set global info - */ - //KdComPortInUse = (ULONG)PortBase; - - /* - * print message to blue screen - */ - /*sprintf (buffer, - "\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n", - ComPort, - (ULONG)PortBase, - BaudRate); - - HalDisplayString (buffer);*/ - - return TRUE; + return TRUE; } -BOOLEAN Rs232PortGetByte(PUCHAR ByteRecieved) +BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived) { - if (PortInitialized == FALSE) - return FALSE; + if (PortInitialized == FALSE) + return FALSE; - if ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_DR)) - { - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); - return TRUE; - } - - return FALSE; + return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS); } -BOOLEAN Rs232PortPollByte(PUCHAR ByteRecieved) +/* +BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived) { - if (PortInitialized == FALSE) - return FALSE; + if (PortInitialized == FALSE) + return FALSE; - while ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_DR) == 0) - ; + while ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_DR) == 0) + ; - *ByteRecieved = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); + *ByteReceived = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); - return TRUE; + return TRUE; } +*/ VOID Rs232PortPutByte(UCHAR ByteToSend) { - if (PortInitialized == FALSE) - return; + if (PortInitialized == FALSE) + return; - while ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_TBE) == 0) - ; - - WRITE_PORT_UCHAR (SER_THR(Rs232PortBase), ByteToSend); + CpPutByte(&Rs232ComPort, ByteToSend); } #endif /* DBG */ -BOOLEAN Rs232PortInUse(ULONG Base) +BOOLEAN Rs232PortInUse(PUCHAR Base) { #if DBG - return PortInitialized && Rs232PortBase == (PUCHAR)(ULONG_PTR)Base ? TRUE : FALSE; + return ( (PortInitialized && (Rs232ComPort.Address == Base)) ? TRUE : FALSE ); #else return FALSE; #endif diff --git a/reactos/boot/freeldr/freeldr/include/comm.h b/reactos/boot/freeldr/freeldr/include/comm.h index 511b705de50..49d0943eb77 100644 --- a/reactos/boot/freeldr/freeldr/include/comm.h +++ b/reactos/boot/freeldr/freeldr/include/comm.h @@ -23,6 +23,6 @@ BOOLEAN Rs232PortInitialize(ULONG ComPort, ULONG BaudRate); BOOLEAN Rs232PortGetByte(PUCHAR ByteRecieved); -BOOLEAN Rs232PortPollByte(PUCHAR ByteRecieved); +// BOOLEAN Rs232PortPollByte(PUCHAR ByteRecieved); VOID Rs232PortPutByte(UCHAR ByteToSend); -BOOLEAN Rs232PortInUse(ULONG Base); +BOOLEAN Rs232PortInUse(PUCHAR Base); From 7450523726e973868ea5fdaceeb7a1ebcc61cadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 22:25:07 +0000 Subject: [PATCH 19/24] [FREELDR] Remove unuseful defines, now. svn path=/trunk/; revision=57778 --- reactos/boot/freeldr/freeldr/comm/rs232.c | 32 +---------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/comm/rs232.c index ee46345feb7..6755884a3e5 100644 --- a/reactos/boot/freeldr/freeldr/comm/rs232.c +++ b/reactos/boot/freeldr/freeldr/comm/rs232.c @@ -28,38 +28,8 @@ #if DBG -#define DEFAULT_BAUD_RATE 19200 +#define DEFAULT_BAUD_RATE 19200 -#define SER_RBR(x) ((x)+0) -#define SER_THR(x) ((x)+0) -#define SER_DLL(x) ((x)+0) -#define SER_IER(x) ((x)+1) -#define SER_DLM(x) ((x)+1) -#define SER_IIR(x) ((x)+2) -#define SER_LCR(x) ((x)+3) -#define SR_LCR_CS5 0x00 -#define SR_LCR_CS6 0x01 -#define SR_LCR_CS7 0x02 -#define SR_LCR_CS8 0x03 -#define SR_LCR_ST1 0x00 -#define SR_LCR_ST2 0x04 -#define SR_LCR_PNO 0x00 -#define SR_LCR_POD 0x08 -#define SR_LCR_PEV 0x18 -#define SR_LCR_PMK 0x28 -#define SR_LCR_PSP 0x38 -#define SR_LCR_BRK 0x40 -#define SR_LCR_DLAB 0x80 -#define SER_MCR(x) ((x)+4) -#define SR_MCR_DTR 0x01 -#define SR_MCR_RTS 0x02 -#define SER_LSR(x) ((x)+5) -#define SR_LSR_DR 0x01 -#define SR_LSR_TBE 0x20 -#define SER_MSR(x) ((x)+6) -#define SR_MSR_CTS 0x10 -#define SR_MSR_DSR 0x20 -#define SER_SCR(x) ((x)+7) /* STATIC VARIABLES *********************************************************/ From edf7b69357dd0c6346725353527a61f23a28d073 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 28 Nov 2012 23:05:57 +0000 Subject: [PATCH 20/24] [Win32k] - Fix crash when the exception is thrown. svn path=/trunk/; revision=57779 --- reactos/win32ss/user/ntuser/painting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/win32ss/user/ntuser/painting.c b/reactos/win32ss/user/ntuser/painting.c index f85adff9b7c..5779fff20d2 100644 --- a/reactos/win32ss/user/ntuser/painting.c +++ b/reactos/win32ss/user/ntuser/painting.c @@ -1088,6 +1088,8 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* pUnsafePs) RETURN(FALSE); } + UserRefObjectCo(Window, &Ref); // Here for the exception. + _SEH2_TRY { ProbeForRead(pUnsafePs, sizeof(*pUnsafePs), 1); @@ -1103,8 +1105,6 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* pUnsafePs) RETURN(FALSE); } - UserRefObjectCo(Window, &Ref); - RETURN(IntEndPaint(Window, &Ps)); CLEANUP: From cd57963daf600559af8d2d54c414dccc25dc28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 23:16:01 +0000 Subject: [PATCH 21/24] [CPORTLIB/FREELDR] GetByte --> Wait for data (with timeout) and get it if available. PollByte --> Check for data, get it if available, and return immediately. svn path=/trunk/; revision=57780 --- reactos/boot/freeldr/freeldr/comm/rs232.c | 9 ++------- reactos/boot/freeldr/freeldr/windows/headless.c | 4 ++-- reactos/include/reactos/libs/cportlib/cportlib.h | 3 +-- reactos/lib/cportlib/cport.c | 6 +----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/comm/rs232.c index 6755884a3e5..347ca0986e6 100644 --- a/reactos/boot/freeldr/freeldr/comm/rs232.c +++ b/reactos/boot/freeldr/freeldr/comm/rs232.c @@ -100,7 +100,7 @@ BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived) if (PortInitialized == FALSE) return FALSE; - return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS); + return (CpGetByte(&Rs232ComPort, ByteReceived, TRUE) == CP_GET_SUCCESS); } /* @@ -109,12 +109,7 @@ BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived) if (PortInitialized == FALSE) return FALSE; - while ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_DR) == 0) - ; - - *ByteReceived = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); - - return TRUE; + return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE) == CP_GET_SUCCESS); } */ diff --git a/reactos/boot/freeldr/freeldr/windows/headless.c b/reactos/boot/freeldr/freeldr/windows/headless.c index bcc0f6434b0..aa701ea2ab5 100644 --- a/reactos/boot/freeldr/freeldr/windows/headless.c +++ b/reactos/boot/freeldr/freeldr/windows/headless.c @@ -143,7 +143,7 @@ BOOLEAN WinLdrPortGetByte(IN ULONG PortId, OUT PUCHAR Data) { - return CpGetByte(&Port[PortId], Data, TRUE, FALSE) == CP_GET_SUCCESS; + return CpGetByte(&Port[PortId], Data, TRUE) == CP_GET_SUCCESS; } BOOLEAN @@ -151,7 +151,7 @@ WinLdrPortPollOnly(IN ULONG PortId) { UCHAR Dummy; - return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS; + return CpGetByte(&Port[PortId], &Dummy, FALSE) == CP_GET_SUCCESS; } VOID diff --git a/reactos/include/reactos/libs/cportlib/cportlib.h b/reactos/include/reactos/libs/cportlib/cportlib.h index b7681f7d337..d145f8261f3 100644 --- a/reactos/include/reactos/libs/cportlib/cportlib.h +++ b/reactos/include/reactos/libs/cportlib/cportlib.h @@ -69,8 +69,7 @@ NTAPI CpGetByte( IN PCPPORT Port, OUT PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll + IN BOOLEAN Wait ); VOID diff --git a/reactos/lib/cportlib/cport.c b/reactos/lib/cportlib/cport.c index 7279b69893b..8e493dd268a 100644 --- a/reactos/lib/cportlib/cport.c +++ b/reactos/lib/cportlib/cport.c @@ -255,8 +255,7 @@ USHORT NTAPI CpGetByte(IN PCPPORT Port, OUT PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll) + IN BOOLEAN Wait) { UCHAR Lsr; ULONG LimitCount = Wait ? TIMEOUT_COUNT : 1; @@ -278,9 +277,6 @@ CpGetByte(IN PCPPORT Port, return CP_GET_ERROR; } - /* If only polling was requested by caller, return now */ - if (Poll) return CP_GET_SUCCESS; - /* Otherwise read the byte and return it */ *Byte = READ_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER); From 6f570605556661e77f9a0b8622c29125b2f70898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 23:23:54 +0000 Subject: [PATCH 22/24] [KDDLL] - Use cportlib for COM port facilities. Fixes COM port debugging output with Virtual PC 2007. - Remove now unneeded header file. CORE-4247 #comment Fixed in r57776, r57777, r57780 and r57781. #resolve svn path=/trunk/; revision=57781 --- reactos/drivers/base/kddll/CMakeLists.txt | 2 + reactos/drivers/base/kddll/kdcom.c | 141 +++++++--------------- reactos/drivers/base/kddll/kdcom.h | 54 --------- reactos/drivers/base/kddll/kddll.h | 5 +- 4 files changed, 48 insertions(+), 154 deletions(-) delete mode 100644 reactos/drivers/base/kddll/kdcom.h diff --git a/reactos/drivers/base/kddll/CMakeLists.txt b/reactos/drivers/base/kddll/CMakeLists.txt index 4d3473b98d7..f7477fc63fb 100644 --- a/reactos/drivers/base/kddll/CMakeLists.txt +++ b/reactos/drivers/base/kddll/CMakeLists.txt @@ -10,7 +10,9 @@ add_library(kdcom SHARED set_entrypoint(kdcom 0) set_subsystem(kdcom native) set_image_base(kdcom 0x00010000) + add_importlibs(kdcom ntoskrnl hal) +target_link_libraries(kdcom cportlib) add_dependencies(kdcom psdk bugcodes) add_cd_file(TARGET kdcom DESTINATION reactos/system32 NO_CAB FOR all) diff --git a/reactos/drivers/base/kddll/kdcom.c b/reactos/drivers/base/kddll/kdcom.c index 11474d5bfdc..ea017d8b0f1 100644 --- a/reactos/drivers/base/kddll/kdcom.c +++ b/reactos/drivers/base/kddll/kdcom.c @@ -7,9 +7,9 @@ */ #include "kddll.h" -#include "kdcom.h" +#include -/* serial debug connection */ +/* Serial debug connection */ #define DEFAULT_DEBUG_PORT 2 /* COM2 */ #define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */ #define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */ @@ -19,91 +19,46 @@ #if defined(_M_IX86) || defined(_M_AMD64) -const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; +const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; #elif defined(_M_PPC) -const ULONG BaseArray[2] = {0, 0x800003f8}; +const ULONG BaseArray[] = {0, 0x800003F8}; #elif defined(_M_MIPS) -const ULONG BaseArray[3] = {0, 0x80006000, 0x80007000}; +const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; #elif defined(_M_ARM) -const ULONG BaseArray[2] = {0, 0xF1012000}; +const ULONG BaseArray[] = {0, 0xF1012000}; #else #error Unknown architecture #endif /* GLOBALS ********************************************************************/ -PUCHAR ComPortBase; -ULONG ComPortNumber = DEFAULT_DEBUG_PORT; -ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE; -ULONG ComPortIrq = 0; +CPPORT KdDebugComPort; +ULONG KdDebugComPortIrq = 0; // Not used at the moment. +/* FUNCTIONS ******************************************************************/ + NTSTATUS NTAPI -KdpPortInitialize() +KdpPortInitialize(IN ULONG ComPortNumber, + IN ULONG ComPortBaudRate) { - ULONG Mode; + NTSTATUS Status; KDDBGPRINT("KdpPortInitialize, Port = COM%ld\n", ComPortNumber); - /* Enable loop mode (set Bit 4 of the MCR) */ - WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_LOOP); - - /* Clear all modem output bits */ - WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_LOOP); - - /* The upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) */ - if ((READ_PORT_UCHAR(ComPortBase + COM_MSR) & 0xF0) != 0x00) + Status = CpInitialize(&KdDebugComPort, + UlongToPtr(BaseArray[ComPortNumber]), + ComPortBaudRate); + if (!NT_SUCCESS(Status)) { return STATUS_INVALID_PARAMETER; } - - /* Set all modem output bits */ - WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_ALL); - - /* The upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) */ - if ((READ_PORT_UCHAR(ComPortBase + COM_MSR) & 0xF0) != 0xF0) + else { - return STATUS_INVALID_PARAMETER; + KdComPortInUse = KdDebugComPort.Address; + return STATUS_SUCCESS; } - - /* Enable FIFO */ - WRITE_PORT_UCHAR(ComPortBase + COM_FCR, - FCR_ENABLE_FIFO | FCR_CLEAR_RCVR | FCR_CLEAR_XMIT); - - /* Disable interrupts */ - WRITE_PORT_UCHAR(ComPortBase + COM_LCR, 0); - WRITE_PORT_UCHAR(ComPortBase + COM_IEN, 0); - - /* Enable on DTR and RTS */ - WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_DTR | MCR_RTS); - - /* Set DLAB */ - WRITE_PORT_UCHAR(ComPortBase + COM_LCR, LCR_DLAB); - - /* Set baud rate */ - Mode = 115200 / ComPortBaudRate; - WRITE_PORT_UCHAR(ComPortBase + COM_DLL, (UCHAR)(Mode & 0xff)); - WRITE_PORT_UCHAR(ComPortBase + COM_DLM, (UCHAR)((Mode >> 8) & 0xff)); - - /* Reset DLAB and set 8 data bits, 1 stop bit, no parity, no break */ - WRITE_PORT_UCHAR(ComPortBase + COM_LCR, LCR_CS8 | LCR_ST1 | LCR_PNO); - - /* Check for 16450/16550 scratch register */ - WRITE_PORT_UCHAR(ComPortBase + COM_SCR, 0xff); - if (READ_PORT_UCHAR(ComPortBase + COM_SCR) != 0xff) - { - return STATUS_INVALID_PARAMETER; - } - WRITE_PORT_UCHAR(ComPortBase + COM_SCR, 0x00); - if (READ_PORT_UCHAR(ComPortBase + COM_SCR) != 0x00) - { - return STATUS_INVALID_PARAMETER; - } - - return STATUS_SUCCESS; } /****************************************************************************** @@ -114,9 +69,11 @@ KdpPortInitialize() */ NTSTATUS NTAPI -KdDebuggerInitialize0( - IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) +KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { + ULONG ComPortNumber = DEFAULT_DEBUG_PORT; + ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE; + PCHAR CommandLine, PortString, BaudString, IrqString; ULONG Value; @@ -136,7 +93,7 @@ KdDebuggerInitialize0( /* Get the port and baud rate */ PortString = strstr(CommandLine, "DEBUGPORT"); BaudString = strstr(CommandLine, "BAUDRATE"); - IrqString = strstr(CommandLine, "IRQ"); + IrqString = strstr(CommandLine, "IRQ"); /* Check if we got the /DEBUGPORT parameter */ if (PortString) @@ -154,10 +111,10 @@ KdDebuggerInitialize0( return STATUS_INVALID_PARAMETER; } - /* Gheck for a valid Serial Port */ + /* Check for a valid Serial Port */ PortString += 3; Value = atol(PortString); - if (Value > 4) + if (Value >= sizeof(BaseArray) / sizeof(BaseArray[0])) { return STATUS_INVALID_PARAMETER; } @@ -198,57 +155,46 @@ KdDebuggerInitialize0( { /* Read and set it */ Value = atol(IrqString + 1); - if (Value) ComPortIrq = Value; + if (Value) KdDebugComPortIrq = Value; } } } - /* Get base address */ - ComPortBase = UlongToPtr(BaseArray[ComPortNumber]); - KdComPortInUse = ComPortBase; - /* Initialize the port */ - return KdpPortInitialize(); + return KdpPortInitialize(ComPortNumber, ComPortBaudRate); } VOID NTAPI KdpSendByte(IN BYTE Byte) { - /* Wait for the port to be ready */ - while ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_TBE) == 0); - - /* This is needed due to subtle timing issues */ - READ_PORT_UCHAR(ComPortBase + COM_MSR); - while ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_TBE) == 0); - READ_PORT_UCHAR(ComPortBase + COM_MSR); - /* Send the byte */ - WRITE_PORT_UCHAR(ComPortBase + COM_DAT, Byte); + CpPutByte(&KdDebugComPort, Byte); } KDP_STATUS NTAPI KdpPollByte(OUT PBYTE OutByte) { - READ_PORT_UCHAR(ComPortBase + COM_MSR); // Timing - - /* Check if data is available */ - if ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_DR)) + /* Get the byte */ + if (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS) { /* Yes, return the byte */ - *OutByte = READ_PORT_UCHAR(ComPortBase + COM_DAT); return KDP_PACKET_RECEIVED; } - - /* Timed out */ - return KDP_PACKET_TIMEOUT; + else + { + /* Timed out */ + return KDP_PACKET_TIMEOUT; + } } KDP_STATUS NTAPI KdpReceiveByte(OUT PBYTE OutByte) { + // TODO: Use CpGetByte(&KdDebugComPort, OutByte, TRUE); + ULONG Repeats = KdpStallScaleFactor * 100; while (Repeats--) @@ -267,7 +213,7 @@ KdpReceiveByte(OUT PBYTE OutByte) KDP_STATUS NTAPI -KdpPollBreakIn() +KdpPollBreakIn(VOID) { UCHAR Byte; if (KdpPollByte(&Byte) == KDP_PACKET_RECEIVED) @@ -282,8 +228,7 @@ KdpPollBreakIn() NTSTATUS NTAPI -KdSave( - IN BOOLEAN SleepTransition) +KdSave(IN BOOLEAN SleepTransition) { /* Nothing to do on COM ports */ return STATUS_SUCCESS; @@ -291,10 +236,10 @@ KdSave( NTSTATUS NTAPI -KdRestore( - IN BOOLEAN SleepTransition) +KdRestore(IN BOOLEAN SleepTransition) { /* Nothing to do on COM ports */ return STATUS_SUCCESS; } +/* EOF */ diff --git a/reactos/drivers/base/kddll/kdcom.h b/reactos/drivers/base/kddll/kdcom.h deleted file mode 100644 index d6b6430e889..00000000000 --- a/reactos/drivers/base/kddll/kdcom.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * COPYRIGHT: GPL, see COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: drivers/base/kddll/kdcom.h - * PURPOSE: COM port definitions for the kernel debugger. - * PROGRAMMER: Timo Kreuzer (timo.kreuzer@ewactos.org) - */ - -#pragma once - -#define COM_DAT 0x00 -#define COM_IEN 0x01 /* interrupt enable register */ -#define COM_FCR 0x02 /* FIFO Control Register */ -#define COM_LCR 0x03 /* line control registers */ -#define COM_MCR 0x04 /* modem control reg */ -#define COM_LSR 0x05 /* line status register */ -#define COM_MSR 0x06 /* modem status register */ -#define COM_SCR 0x07 /* scratch register */ -#define COM_DLL 0x00 /* divisor latch least sig */ -#define COM_DLM 0x01 /* divisor latch most sig */ - -#define IEN_ERDA 0x01 -#define IEN_ETHRE 0x02 -#define IEN_ERLSI 0x04 -#define IEN_EMS 0x08 -#define IEN_ALL 0x0F -#define FCR_ENABLE_FIFO 0x01 -#define FCR_CLEAR_RCVR 0x02 -#define FCR_CLEAR_XMIT 0x04 -#define LCR_CS5 0x00 -#define LCR_CS6 0x01 -#define LCR_CS7 0x02 -#define LCR_CS8 0x03 -#define LCR_ST1 0x00 -#define LCR_ST2 0x04 -#define LCR_PNO 0x00 -#define LCR_POD 0x08 -#define LCR_PEV 0x18 -#define LCR_PMK 0x28 -#define LCR_PSP 0x38 -#define LCR_BRK 0x40 -#define LCR_DLAB 0x80 -#define MCR_DTR 0x01 -#define MCR_RTS 0x02 -#define MCR_OUT1 0x04 /* general purpose output */ -#define MCR_OUT2 0x08 -#define MCR_LOOP 0x10 /* loopback testing mode */ -#define MCR_ALL (MCR_DTR | MCR_RTS | MCR_OUT1 | MCR_OUT2 | MCR_LOOP) -#define LSR_DR 0x01 -#define LSR_TBE 0x20 -#define MSR_CTS 0x10 /* (complemented) state of clear to send (CTS). */ -#define MSR_DSR 0x20 /* (complemented) state of data set ready (DSR). */ -#define MSR_RI 0x40 /* (complemented) state of ring indicator (RI). */ -#define MSR_DCD 0x80 /* (complemented) state of data carrier detect (DCD). */ diff --git a/reactos/drivers/base/kddll/kddll.h b/reactos/drivers/base/kddll/kddll.h index 036f8b045ef..6e461fe0500 100644 --- a/reactos/drivers/base/kddll/kddll.h +++ b/reactos/drivers/base/kddll/kddll.h @@ -12,15 +12,16 @@ #define NOEXTAPI #include -#define NDEBUG #include -#include #include "arc/arc.h" #include "windbgkd.h" #include #include /* port intrinsics */ +#define NDEBUG +#include + long atol(const char *str); typedef UCHAR BYTE, *PBYTE; From 24abb046763be6dfe7c6d3a93e6e439d66d3f62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 29 Nov 2012 10:26:00 +0000 Subject: [PATCH 23/24] [KDCOM] Fixes COM port debugging output with Virtual PC 2007. See r57781 for more details. CORE-4247 #comment Fixed also in r57782. svn path=/trunk/; revision=57782 --- reactos/drivers/base/kdcom/CMakeLists.txt | 10 +-- reactos/drivers/base/kdcom/i386/kdbg.c | 103 +++++----------------- 2 files changed, 29 insertions(+), 84 deletions(-) diff --git a/reactos/drivers/base/kdcom/CMakeLists.txt b/reactos/drivers/base/kdcom/CMakeLists.txt index 7f5718a170e..1594382f2b1 100644 --- a/reactos/drivers/base/kdcom/CMakeLists.txt +++ b/reactos/drivers/base/kdcom/CMakeLists.txt @@ -2,11 +2,11 @@ spec2def(kdcom.dll kdcom.spec ADD_IMPORTLIB) if(ARCH STREQUAL "i386") -list(APPEND SOURCE i386/kdbg.c) + list(APPEND SOURCE i386/kdbg.c) elseif(ARCH STREQUAL "amd64") -list(APPEND SOURCE i386/kdbg.c) + list(APPEND SOURCE i386/kdbg.c) elseif(ARCH STREQUAL "arm") -list(APPEND SOURCE arm/kdbg.c) + list(APPEND SOURCE arm/kdbg.c) endif(ARCH STREQUAL "i386") list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/kdcom.def) @@ -17,7 +17,7 @@ set_subsystem(kdcom native) set_image_base(kdcom 0x00010000) add_importlibs(kdcom ntoskrnl hal) - +target_link_libraries(kdcom cportlib) add_dependencies(kdcom psdk bugcodes) -add_cd_file(TARGET kdcom DESTINATION reactos/system32 NO_CAB FOR all) +add_cd_file(TARGET kdcom DESTINATION reactos/system32 NO_CAB FOR all) diff --git a/reactos/drivers/base/kdcom/i386/kdbg.c b/reactos/drivers/base/kdcom/i386/kdbg.c index 3c729988f3d..45a736de954 100644 --- a/reactos/drivers/base/kdcom/i386/kdbg.c +++ b/reactos/drivers/base/kdcom/i386/kdbg.c @@ -11,14 +11,17 @@ #define NOEXTAPI #include -#define NDEBUG #include #include -#include #include "arc/arc.h" #include "windbgkd.h" #include #include /* port intrinsics */ +#include + +#define NDEBUG +#include + typedef struct _KD_PORT_INFORMATION { @@ -54,14 +57,14 @@ KdPortPutByteEx( #define DEFAULT_BAUD_RATE 19200 -#ifdef _M_IX86 -const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; +#if defined(_M_IX86) || defined(_M_AMD64) +const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; #elif defined(_M_PPC) -const ULONG BaseArray[2] = {0, 0x800003f8}; +const ULONG BaseArray[] = {0, 0x800003F8}; #elif defined(_M_MIPS) -const ULONG BaseArray[3] = {0, 0x80006000, 0x80007000}; +const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; #elif defined(_M_ARM) -const ULONG BaseArray[2] = {0, 0xF1012000}; +const ULONG BaseArray[] = {0, 0xF1012000}; #else #error Unknown architecture #endif @@ -122,68 +125,6 @@ static KD_PORT_INFORMATION DefaultPort = { 0, 0, 0 }; static BOOLEAN PortInitialized = FALSE; -/* STATIC FUNCTIONS *********************************************************/ - -static BOOLEAN -KdpDoesComPortExist( - IN ULONG BaseAddress) -{ - BOOLEAN found; - UCHAR mcr; - UCHAR msr; - - found = FALSE; - - /* save Modem Control Register (MCR) */ - mcr = READ_PORT_UCHAR(SER_MCR(BaseAddress)); - - /* enable loop mode (set Bit 4 of the MCR) */ - WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_LOOP); - - /* clear all modem output bits */ - WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_LOOP); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR(SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0x00) - { - /* set all modem output bits */ - WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_DTR | SR_MCR_RTS | SR_MCR_OUT1 | SR_MCR_OUT2 | SR_MCR_LOOP); - - /* read the Modem Status Register */ - msr = READ_PORT_UCHAR(SER_MSR(BaseAddress)); - - /* - * the upper nibble of the MSR (modem output bits) must be - * equal to the lower nibble of the MCR (modem input bits) - */ - if ((msr & 0xF0) == 0xF0) - { - /* - * setup a resonable state for the port: - * enable fifo and clear recieve/transmit buffers - */ - WRITE_PORT_UCHAR(SER_FCR(BaseAddress), - (SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT)); - WRITE_PORT_UCHAR(SER_FCR(BaseAddress), 0); - READ_PORT_UCHAR(SER_RBR(BaseAddress)); - WRITE_PORT_UCHAR(SER_IER(BaseAddress), 0); - found = TRUE; - } - } - - /* restore MCR */ - WRITE_PORT_UCHAR(SER_MCR(BaseAddress), mcr); - - return found; -} - - /* FUNCTIONS ****************************************************************/ /* HAL.KdPortInitialize */ @@ -203,14 +144,18 @@ KdPortInitialize( if (PortInformation->ComPort == 0) { + /* + * Start enumerating COM ports from the last one to the first one, + * and break when we find a valid port. + * If we reach the first element of the list, the invalid COM port, + * then it means that no valid port was found. + */ for (i = sizeof(BaseArray) / sizeof(BaseArray[0]) - 1; i > 0; i--) { - if (KdpDoesComPortExist(BaseArray[i])) + if (CpDoesPortExist(UlongToPtr(BaseArray[i]))) { - DefaultPort.BaseAddress = BaseArray[i]; - DefaultPort.ComPort = i; - PortInformation->BaseAddress = DefaultPort.BaseAddress; - PortInformation->ComPort = DefaultPort.ComPort; + PortInformation->BaseAddress = DefaultPort.BaseAddress = BaseArray[i]; + PortInformation->ComPort = DefaultPort.ComPort = i; break; } } @@ -237,7 +182,7 @@ KdPortInitialize( } -/* HAL.KdPortInitializeEx */ +/* HAL.KdPortInitializeEx ; ReactOS-specific */ BOOLEAN NTAPI KdPortInitializeEx( @@ -260,7 +205,7 @@ KdPortInitializeEx( if (PortInformation->ComPort != 0) { - if (!KdpDoesComPortExist(BaseArray[PortInformation->ComPort])) + if (!CpDoesPortExist(UlongToPtr(BaseArray[PortInformation->ComPort]))) { sprintf(buffer, "\nKernel Debugger: Serial port not found!\n\n"); @@ -335,7 +280,7 @@ KdPortGetByte( } -/* HAL.KdPortGetByteEx */ +/* HAL.KdPortGetByteEx ; ReactOS-specific */ BOOLEAN NTAPI KdPortGetByteEx( @@ -366,7 +311,7 @@ KdPortPollByte( } -/* HAL.KdPortPollByteEx */ +/* HAL.KdPortPollByteEx ; ReactOS-specific */ BOOLEAN NTAPI KdPortPollByteEx( @@ -395,7 +340,7 @@ KdPortPutByte( KdPortPutByteEx(&DefaultPort, ByteToSend); } -/* HAL.KdPortPutByteEx */ +/* HAL.KdPortPutByteEx ; ReactOS-specific */ VOID NTAPI KdPortPutByteEx( From 9b5490c235ef80233e0903141e6fbab96a63d6fe Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 29 Nov 2012 22:02:22 +0000 Subject: [PATCH 24/24] [LSASRV] - Fix object deletion. - Add a registry wrapper function that enables us to delete registry keys which have already been opened. - Make LsarDelete call LsarDeleteObject because otherwise object deletion would not be possible. svn path=/trunk/; revision=57784 --- reactos/dll/win32/lsasrv/database.c | 32 +++++++++++------------------ reactos/dll/win32/lsasrv/lsarpc.c | 3 +-- reactos/dll/win32/lsasrv/lsasrv.h | 8 +++++--- reactos/dll/win32/lsasrv/registry.c | 11 ++++++++-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/reactos/dll/win32/lsasrv/database.c b/reactos/dll/win32/lsasrv/database.c index 3ca4363d449..1afa0a38d7b 100644 --- a/reactos/dll/win32/lsasrv/database.c +++ b/reactos/dll/win32/lsasrv/database.c @@ -796,7 +796,6 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject = RtlAllocateHeap(RtlGetProcessHeap(), 0, -// sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR)); sizeof(LSA_DB_OBJECT)); if (NewObject == NULL) { @@ -810,7 +809,6 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, NewObject->Access = DesiredAccess; NewObject->KeyHandle = ObjectKeyHandle; NewObject->ParentObject = ParentObject; -// wcscpy(NewObject->Name, ObjectName); if (ParentObject != NULL) ParentObject->RefCount++; @@ -901,10 +899,8 @@ NTSTATUS LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) { PLSA_DB_OBJECT ParentObject = NULL; -#if 0 WCHAR KeyName[64]; - ULONG EnumIndex; -#endif + ULONG Index; NTSTATUS Status = STATUS_SUCCESS; DbObject->RefCount--; @@ -914,40 +910,36 @@ LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject) if (DbObject->KeyHandle != NULL) { -#if 0 - EnumIndex = 0; + Index = 0; while (TRUE) { Status = LsapRegEnumerateSubKey(DbObject->KeyHandle, - EnumIndex, + Index, 64 * sizeof(WCHAR), KeyName); if (!NT_SUCCESS(Status)) break; - TRACE("EnumIndex: %lu\n", EnumIndex); + TRACE("Index: %lu\n", Index); TRACE("Key name: %S\n", KeyName); - Status = LsapRegDeleteKey(DbObject->KeyHandle, - KeyName); + Status = LsapRegDeleteSubKey(DbObject->KeyHandle, + KeyName); if (!NT_SUCCESS(Status)) break; - -// EnumIndex++; } -#endif + + if (Status == STATUS_NO_MORE_ENTRIES) + Status = STATUS_SUCCESS; + + LsapRegDeleteKey(DbObject->KeyHandle); + NtClose(DbObject->KeyHandle); } if (DbObject->ParentObject != NULL) - { ParentObject = DbObject->ParentObject; -#if 0 - LsapRegDeleteKey(ParentObject->KeyHandle, - DbObject->Name); -#endif - } RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject); diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index 67375f0156b..db70223619a 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -97,8 +97,7 @@ NTSTATUS WINAPI LsarClose( NTSTATUS WINAPI LsarDelete( LSAPR_HANDLE ObjectHandle) { - /* Deprecated */ - return STATUS_NOT_SUPPORTED; + return LsarDeleteObject(&ObjectHandle); } diff --git a/reactos/dll/win32/lsasrv/lsasrv.h b/reactos/dll/win32/lsasrv/lsasrv.h index 33af276382f..6488585c04e 100644 --- a/reactos/dll/win32/lsasrv/lsasrv.h +++ b/reactos/dll/win32/lsasrv/lsasrv.h @@ -48,7 +48,6 @@ typedef struct _LSA_DB_OBJECT ACCESS_MASK Access; HANDLE KeyHandle; struct _LSA_DB_OBJECT *ParentObject; - WCHAR Name[0]; } LSA_DB_OBJECT, *PLSA_DB_OBJECT; #define LSAP_DB_SIGNATURE 0x12345678 @@ -282,8 +281,11 @@ LsapRegCreateKey(IN HANDLE ParentKeyHandle, OUT HANDLE KeyHandle); NTSTATUS -LsapRegDeleteKey(IN HANDLE ParentKeyHandle, - IN LPCWSTR KeyName); +LsapRegDeleteSubKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName); + +NTSTATUS +LsapRegDeleteKey(IN HANDLE KeyHandle); NTSTATUS LsapRegEnumerateSubKey(IN HANDLE KeyHandle, diff --git a/reactos/dll/win32/lsasrv/registry.c b/reactos/dll/win32/lsasrv/registry.c index 80c083eb57a..2775faad51e 100644 --- a/reactos/dll/win32/lsasrv/registry.c +++ b/reactos/dll/win32/lsasrv/registry.c @@ -60,8 +60,8 @@ LsapRegCreateKey(IN HANDLE ParentKeyHandle, NTSTATUS -LsapRegDeleteKey(IN HANDLE ParentKeyHandle, - IN LPCWSTR KeyName) +LsapRegDeleteSubKey(IN HANDLE ParentKeyHandle, + IN LPCWSTR KeyName) { OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING SubKeyName; @@ -89,6 +89,13 @@ LsapRegDeleteKey(IN HANDLE ParentKeyHandle, } +NTSTATUS +LsapRegDeleteKey(IN HANDLE KeyHandle) +{ + return NtDeleteKey(KeyHandle); +} + + NTSTATUS LsapRegEnumerateSubKey(IN HANDLE KeyHandle, IN ULONG Index,