Index: rostests/apitests/advapi32/IsTextUnicode.c =================================================================== --- rostests/apitests/advapi32/IsTextUnicode.c (revision 72475) +++ rostests/apitests/advapi32/IsTextUnicode.c (revision 72486) @@ -79,6 +79,16 @@ NEW_TEST(L"\xFFFE" L"UNICODE String 5 Привет!", IS_TEXT_UNICODE_UNICODE_MASK, IS_TEXT_UNICODE_CONTROLS, TRUE), NEW_TEST(L"\xFFFE" L"UNICODE String 5 Привет!", IS_TEXT_UNICODE_STATISTICS, 0, FALSE), NEW_TEST(L"\xFFFE" L"UNICODE String 5 Привет!", INVALID_FLAG, 0, FALSE), + + // 31 + /* Reverse BOM */ + NEW_TEST(L"UNICODE S" L"\xFFFE" L"tring 5 Привет!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS, FALSE), + /* UNICODE_NUL */ + NEW_TEST(L"UNICODE S" L"\x0000" L"tring 5 Привет!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS, FALSE), + /* ASCII CRLF (packed into one word) */ + NEW_TEST(L"UNICODE S" L"\x0A0D" L"tring 5 Привет!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS, FALSE), + /* Unicode 0xFFFF */ + NEW_TEST(L"UNICODE S" L"\xFFFF" L"tring 5 Привет!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS, FALSE), }; UINT i; Index: reactos/ntoskrnl/mm/section.c =================================================================== --- reactos/ntoskrnl/mm/section.c (revision 72475) +++ reactos/ntoskrnl/mm/section.c (revision 72486) @@ -4299,7 +4299,7 @@ _In_ SIZE_T SectionInformationLength, _Out_opt_ PSIZE_T ResultLength) { - PROS_SECTION_OBJECT Section; + PSECTION Section; KPROCESSOR_MODE PreviousMode; NTSTATUS Status; PAGED_CODE(); @@ -4357,68 +4357,126 @@ return Status; } - switch (SectionInformationClass) + if (MiIsRosSectionObject(Section)) { - case SectionBasicInformation: + PROS_SECTION_OBJECT RosSection = (PROS_SECTION_OBJECT)Section; + + switch (SectionInformationClass) { - PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation; + case SectionBasicInformation: + { + PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation; - _SEH2_TRY - { - Sbi->Attributes = Section->AllocationAttributes; - if (Section->AllocationAttributes & SEC_IMAGE) + _SEH2_TRY { - Sbi->BaseAddress = 0; - Sbi->Size.QuadPart = 0; + Sbi->Attributes = RosSection->AllocationAttributes; + if (RosSection->AllocationAttributes & SEC_IMAGE) + { + Sbi->BaseAddress = 0; + Sbi->Size.QuadPart = 0; + } + else + { + Sbi->BaseAddress = (PVOID)RosSection->Segment->Image.VirtualAddress; + Sbi->Size.QuadPart = RosSection->Segment->Length.QuadPart; + } + + if (ResultLength != NULL) + { + *ResultLength = sizeof(SECTION_BASIC_INFORMATION); + } + Status = STATUS_SUCCESS; } - else + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Sbi->BaseAddress = (PVOID)Section->Segment->Image.VirtualAddress; - Sbi->Size.QuadPart = Section->Segment->Length.QuadPart; + Status = _SEH2_GetExceptionCode(); } + _SEH2_END; - if (ResultLength != NULL) + break; + } + + case SectionImageInformation: + { + PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation; + + _SEH2_TRY { - *ResultLength = sizeof(SECTION_BASIC_INFORMATION); + if (RosSection->AllocationAttributes & SEC_IMAGE) + { + PMM_IMAGE_SECTION_OBJECT ImageSectionObject; + ImageSectionObject = RosSection->ImageSection; + + *Sii = ImageSectionObject->ImageInformation; + } + + if (ResultLength != NULL) + { + *ResultLength = sizeof(SECTION_IMAGE_INFORMATION); + } + Status = STATUS_SUCCESS; } - Status = STATUS_SUCCESS; + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + break; } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + } + } + else + { + switch(SectionInformationClass) + { + case SectionBasicInformation: { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; + SECTION_BASIC_INFORMATION Sbi; - break; - } + Sbi.Size = Section->SizeOfSection; + Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn; - case SectionImageInformation: - { - PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation; + Sbi.Attributes = 0; + if (Section->u.Flags.Image) + Sbi.Attributes |= SEC_IMAGE; + if (Section->u.Flags.Commit) + Sbi.Attributes |= SEC_COMMIT; + if (Section->u.Flags.Reserve) + Sbi.Attributes |= SEC_RESERVE; + if (Section->u.Flags.File) + Sbi.Attributes |= SEC_FILE; + if (Section->u.Flags.Image) + Sbi.Attributes |= SEC_IMAGE; - _SEH2_TRY - { - if (Section->AllocationAttributes & SEC_IMAGE) + /* FIXME : Complete/test the list of flags passed back from NtCreateSection */ + + _SEH2_TRY { - PMM_IMAGE_SECTION_OBJECT ImageSectionObject; - ImageSectionObject = Section->ImageSection; - - *Sii = ImageSectionObject->ImageInformation; + *((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi; + if (ResultLength) + *ResultLength = sizeof(Sbi); } - - if (ResultLength != NULL) + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - *ResultLength = sizeof(SECTION_IMAGE_INFORMATION); + Status = _SEH2_GetExceptionCode(); } - Status = STATUS_SUCCESS; + _SEH2_END; + break; } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + case SectionImageInformation: { - Status = _SEH2_GetExceptionCode(); + if (!Section->u.Flags.Image) + { + Status = STATUS_SECTION_NOT_IMAGE; + } + else + { + /* Currently not supported */ + ASSERT(FALSE); + } + break; } - _SEH2_END; - - break; } } Index: reactos/ntoskrnl/mm/i386/page.c =================================================================== --- reactos/ntoskrnl/mm/i386/page.c (revision 72475) +++ reactos/ntoskrnl/mm/i386/page.c (revision 72486) @@ -765,7 +765,7 @@ /* There should not be anything valid here */ if (Pte != 0) { - DPRINT1("Bad PTE %lx\n", Pte); + DPRINT1("Bad PTE %lx at %p for %p + %lu\n", Pte, Pt, Address, i); KeBugCheck(MEMORY_MANAGEMENT); } Index: reactos/drivers/usb/usbhub/pdo.c =================================================================== --- reactos/drivers/usb/usbhub/pdo.c (revision 72475) +++ reactos/drivers/usb/usbhub/pdo.c (revision 72486) @@ -703,7 +703,7 @@ } /* allocate device relations */ - DeviceRelation = (PDEVICE_RELATIONS)ExAllocatePool(NonPagedPool, sizeof(DEVICE_RELATIONS)); + DeviceRelation = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, sizeof(DEVICE_RELATIONS)); if (!DeviceRelation) { /* no memory */ @@ -717,7 +717,7 @@ ObReferenceObject(DeviceRelation->Objects[0]); /* store result */ - Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation; + Information = (ULONG_PTR)DeviceRelation; Status = STATUS_SUCCESS; break; } Index: reactos/drivers/usb/usbhub =================================================================== --- reactos/drivers/usb/usbhub (revision 72475) +++ reactos/drivers/usb/usbhub (revision 72486) Property changes on: reactos/drivers/usb/usbhub ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /branches/GSoC_2016/USB/drivers/usb/usbhub:r72376 Index: reactos/subsystems/mvdm/ntvdm/clock.c =================================================================== --- reactos/subsystems/mvdm/ntvdm/clock.c (revision 72475) +++ reactos/subsystems/mvdm/ntvdm/clock.c (revision 72486) @@ -38,8 +38,6 @@ /* VARIABLES ******************************************************************/ static LIST_ENTRY Timers; -static ULONGLONG Cycles = 0ULL; -static ULONGLONG CurrentIps = 20000000ULL; // 20 MIPS is a good estimate static LARGE_INTEGER StartPerfCount, Frequency; // static ULONG StartTickCount; static LARGE_INTEGER Counter; @@ -47,17 +45,30 @@ static ULONGLONG LastCycles = 0ULL; static PHARDWARE_TIMER IpsTimer; +ULONGLONG CurrentCycleCount = 0ULL; +ULONGLONG CurrentIps = 20000000ULL; // 20 MIPS is a good estimate + /* PRIVATE FUNCTIONS **********************************************************/ static VOID FASTCALL IpsCallback(ULONGLONG ElapsedTime) { - CurrentIps = (Cycles - LastCycles) / ElapsedTime; +#ifdef IPS_DISPLAY + static INT NumCalls = 0; +#endif + + ULONGLONG NewIps = 10ULL * (CurrentCycleCount - LastCycles) / ElapsedTime; + CurrentIps = (CurrentIps + NewIps) >> 1; #ifdef IPS_DISPLAY - DPRINT1("NTVDM: %I64u Instructions Per Second\n", CurrentIps); + NumCalls++; + if (NumCalls == 10) + { + DPRINT1("NTVDM: %I64u Instructions Per Second\n", CurrentIps); + NumCalls = 0; + } #endif - LastCycles = Cycles; + LastCycles = CurrentCycleCount; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -81,7 +92,7 @@ for (i = 0; VdmRunning && CpuRunning && (i < STEPS_PER_CYCLE); i++) { CpuStep(); - ++Cycles; + ++CurrentCycleCount; } Entry = Timers.Flink; @@ -205,16 +216,6 @@ } } -ULONGLONG GetCycleCount(VOID) -{ - return Cycles; -} - -ULONGLONG GetCycleSpeed(VOID) -{ - return CurrentIps; -} - BOOLEAN ClockInitialize(VOID) { InitializeListHead(&Timers); @@ -231,7 +232,7 @@ /* Find the starting tick count */ // StartTickCount = GetTickCount(); - IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(1), IpsCallback); + IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(10), IpsCallback); if (IpsTimer == NULL) { wprintf(L"FATAL: Cannot create IPS timer.\n"); Index: reactos/subsystems/mvdm/ntvdm/clock.h =================================================================== --- reactos/subsystems/mvdm/ntvdm/clock.h (revision 72475) +++ reactos/subsystems/mvdm/ntvdm/clock.h (revision 72486) @@ -33,6 +33,9 @@ /* FUNCTIONS ******************************************************************/ +extern ULONGLONG CurrentCycleCount; +extern ULONGLONG CurrentIps; + PHARDWARE_TIMER CreateHardwareTimer ( ULONG Flags, @@ -39,14 +42,12 @@ ULONGLONG Delay, /* nanoseconds */ PHARDWARE_TIMER_PROC Callback ); + VOID EnableHardwareTimer(PHARDWARE_TIMER Timer); VOID DisableHardwareTimer(PHARDWARE_TIMER Timer); VOID SetHardwareTimerDelay(PHARDWARE_TIMER Timer, ULONGLONG NewDelay); VOID DestroyHardwareTimer(PHARDWARE_TIMER Timer); -ULONGLONG GetCycleCount(VOID); -ULONGLONG GetCycleSpeed(VOID); - VOID ClockUpdate(VOID); BOOLEAN ClockInitialize(VOID); Index: reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c =================================================================== --- reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c (revision 72475) +++ reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c (revision 72486) @@ -327,14 +327,31 @@ * See Ralf Brown: http://www.ctyme.com/intr/rb-1525.htm * for more information. */ - LARGE_INTEGER TimeOut; - TimeOut.QuadPart = MAKELONG(getDX(), getCX()) * -10LL; - // HACK: For now, use the NT API (time in hundreds of nanoseconds). - NtDelayExecution(FALSE, &TimeOut); + static ULONG CompletionTime = 0; - /* Clear CF */ - Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF; + /* Check if we're already looping */ + if (getCF()) + { + if (GetTickCount() >= CompletionTime) + { + /* Stop looping */ + setCF(0); + + /* Clear the CF on the stack too */ + Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF; + } + } + else + { + /* Set the CF on the stack */ + Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF; + + /* Set the completion time and start looping */ + CompletionTime = GetTickCount() + (MAKELONG(getDX(), getCX()) / 1000); + setCF(1); + } + break; } Index: reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c =================================================================== --- reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c (revision 72475) +++ reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c (revision 72486) @@ -1104,8 +1104,8 @@ { BYTE Result = 0; BOOLEAN Vsync, Hsync; - ULONGLONG Cycles = GetCycleCount(); - ULONG CyclesPerMicrosecond = (ULONG)((GetCycleSpeed() + 500000ULL) / 1000000ULL); + ULONGLONG Cycles = CurrentCycleCount; + ULONG CyclesPerMicrosecond = (ULONG)((CurrentIps + 500000ULL) / 1000000ULL); ULONG Dots = (VgaSeqRegisters[VGA_SEQ_CLOCK_REG] & 1) ? 9 : 8; ULONG Clock = VgaGetClockFrequency() / 1000000; ULONG HblankStart, HblankEnd; @@ -1624,18 +1624,20 @@ { ULONG VerticalTotal = VgaCrtcRegisters[VGA_CRTC_VERT_TOTAL_REG]; ULONG VerticalRetraceStart = VgaCrtcRegisters[VGA_CRTC_START_VERT_RETRACE_REG]; - ULONG VerticalRetraceEnd; - BOOLEAN BeforeVSyncStart, BeforeVSyncEnd; - ULONG CurrentCycleCount = GetCycleCount(); + BOOLEAN BeforeVSync; ULONG ElapsedCycles = CurrentCycleCount - HorizontalRetraceCycle; ULONG Dots = (VgaSeqRegisters[VGA_SEQ_CLOCK_REG] & 1) ? 9 : 8; ULONG HorizTotalDots = ((ULONG)VgaCrtcRegisters[VGA_CRTC_HORZ_TOTAL_REG] + 5) * Dots; - ULONG HSyncsPerSecond = VgaGetClockFrequency() / HorizTotalDots; - ULONG HSyncs = (ElapsedCycles * HSyncsPerSecond) / GetCycleSpeed(); + BYTE MaximumScanLine = 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F); + ULONG HSyncsPerSecond, HSyncs; + UNREFERENCED_PARAMETER(ElapsedTime); - UNREFERENCED_PARAMETER(ElapsedTime); + if (VgaAcRegisters[VGA_AC_CONTROL_REG] & VGA_AC_CONTROL_8BIT) HorizTotalDots >>= 1; + + HSyncsPerSecond = VgaGetClockFrequency() / HorizTotalDots; + HSyncs = (ElapsedCycles * HSyncsPerSecond + (CurrentIps >> 1)) / CurrentIps; if (HSyncs == 0) HSyncs = 1; - + VerticalTotal |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VT8) << 8; VerticalTotal |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VT9) << 4; @@ -1642,21 +1644,25 @@ VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS8) << 6; VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS9) << 2; - VerticalRetraceEnd = VerticalRetraceStart + (VgaCrtcRegisters[VGA_CRTC_END_VERT_RETRACE_REG] & 0x0F); + if (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & VGA_CRTC_MAXSCANLINE_DOUBLE) + { + VerticalRetraceStart <<= 1; + VerticalTotal <<= 1; + } + else + { + VerticalRetraceStart *= MaximumScanLine; + VerticalTotal *= MaximumScanLine; + } /* Set the cycle */ HorizontalRetraceCycle = CurrentCycleCount; /* Increment the scanline counter, but make sure we don't skip any part of the vertical retrace */ - BeforeVSyncStart = (ScanlineCounter < VerticalRetraceStart); - BeforeVSyncEnd = (ScanlineCounter < VerticalRetraceEnd); + BeforeVSync = (ScanlineCounter < VerticalRetraceStart); ScanlineCounter += HSyncs; - if (BeforeVSyncStart && ScanlineCounter >= VerticalRetraceStart) ScanlineCounter = VerticalRetraceStart; - else if (BeforeVSyncEnd && ScanlineCounter >= VerticalRetraceEnd) ScanlineCounter = VerticalRetraceEnd; + if (BeforeVSync && ScanlineCounter >= VerticalRetraceStart) ScanlineCounter = VerticalRetraceStart; - /* The scanline counter wraps around */ - ScanlineCounter %= VerticalTotal; - if (ScanlineCounter == VerticalRetraceStart) { /* Save the scanline size */ @@ -1673,8 +1679,9 @@ + ((VgaCrtcRegisters[VGA_CRTC_PRESET_ROW_SCAN_REG] >> 5) & 3); } - if (ScanlineCounter == VerticalRetraceEnd) + if (ScanlineCounter > VerticalTotal) { + ScanlineCounter = 0; VgaVerticalRetrace(); } } @@ -1822,16 +1829,16 @@ } else { - const ULONG BitExpandTable[] = + const ULONG BitExpandInvertTable[] = { - 0x00000000, 0x000000FF, 0x0000FF00, 0x0000FFFF, - 0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x00FFFFFF, - 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF, - 0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFFFF + 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF00FF, 0xFFFF0000, + 0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFF000000, + 0x00FFFFFF, 0x00FFFF00, 0x00FF00FF, 0x00FF0000, + 0x0000FFFF, 0x0000FF00, 0x000000FF, 0x00000000 }; - ULONG ColorCompareBytes = BitExpandTable[VgaGcRegisters[VGA_GC_COLOR_COMPARE_REG] & 0x0F]; - ULONG ColorIgnoreBytes = BitExpandTable[VgaGcRegisters[VGA_GC_COLOR_IGNORE_REG] & 0x0F]; + ULONG ColorCompareBytes = BitExpandInvertTable[VgaGcRegisters[VGA_GC_COLOR_COMPARE_REG] & 0x0F]; + ULONG ColorIgnoreBytes = BitExpandInvertTable[VgaGcRegisters[VGA_GC_COLOR_IGNORE_REG] & 0x0F]; /* * These values can also be computed in the following way, but using the table seems to be faster: @@ -1838,17 +1845,17 @@ * * ColorCompareBytes = VgaGcRegisters[VGA_GC_COLOR_COMPARE_REG] * 0x000204081; * ColorCompareBytes &= 0x01010101; - * ColorCompareBytes = (ColorCompareBytes << 8) - ColorCompareBytes; + * ColorCompareBytes = ~((ColorCompareBytes << 8) - ColorCompareBytes); * * ColorIgnoreBytes = VgaGcRegisters[VGA_GC_COLOR_IGNORE_REG] * 0x000204081; * ColorIgnoreBytes &= 0x01010101; - * ColorIgnoreBytes = (ColorIgnoreBytes << 8) - ColorIgnoreBytes; + * ColorIgnoreBytes = ~((ColorIgnoreBytes << 8) - ColorIgnoreBytes); */ /* Loop through each byte */ for (i = 0; i < Size; i++) { - ULONG PlaneData; + ULONG PlaneData = 0; /* This should always return a plane 0 address */ VideoAddress = VgaTranslateAddress(Address + i); @@ -1857,13 +1864,13 @@ PlaneData = *(PULONG)&VgaMemory[VideoAddress * VGA_NUM_BANKS]; /* Reverse the bytes for which the color compare register is zero */ - PlaneData ^= ~ColorCompareBytes; + PlaneData ^= ColorCompareBytes; /* Apply the color ignore register */ PlaneData |= ColorIgnoreBytes; /* Store the value in the buffer */ - BufPtr[i] = (PlaneData | (PlaneData >> 8) | (PlaneData >> 16) | (PlaneData >> 24)) & 0xFF; + BufPtr[i] = (PlaneData & (PlaneData >> 8) & (PlaneData >> 16) & (PlaneData >> 24)) & 0xFF; } } Index: reactos/sdk/lib/rtl/unicode.c =================================================================== --- reactos/sdk/lib/rtl/unicode.c (revision 72475) +++ reactos/sdk/lib/rtl/unicode.c (revision 72486) @@ -1245,6 +1245,12 @@ const WCHAR *s = buf; int i; unsigned int flags = MAXULONG, out_flags = 0; + UCHAR last_lo_byte = 0; + UCHAR last_hi_byte = 0; + ULONG hi_byte_diff = 0; + ULONG lo_byte_diff = 0; + ULONG weight = 3; + ULONG lead_byte = 0; if (len < sizeof(WCHAR)) { @@ -1279,21 +1285,64 @@ if (*s == 0xFEFF) out_flags |= IS_TEXT_UNICODE_SIGNATURE; if (*s == 0xFFFE) out_flags |= IS_TEXT_UNICODE_REVERSE_SIGNATURE; - /* apply some statistical analysis */ - if (flags & IS_TEXT_UNICODE_STATISTICS) + for (i = 0; i < len; i++) { - int stats = 0; + UCHAR lo_byte = LOBYTE(s[i]); + UCHAR hi_byte = HIBYTE(s[i]); - /* FIXME: checks only for ASCII characters in the unicode stream */ + lo_byte_diff += max(lo_byte, last_lo_byte) - min(lo_byte, last_lo_byte); + hi_byte_diff += max(hi_byte, last_hi_byte) - min(hi_byte, last_hi_byte); + + last_lo_byte = lo_byte; + last_hi_byte = hi_byte; + + switch (s[i]) + { + case 0xFFFE: /* Reverse BOM */ + case UNICODE_NULL: + case 0x0A0D: /* ASCII CRLF (packed into one word) */ + case 0xFFFF: /* Unicode 0xFFFF */ + out_flags |= IS_TEXT_UNICODE_ILLEGAL_CHARS; + break; + } + } + + if (lo_byte_diff < 127 && !hi_byte_diff) + { + out_flags |= IS_TEXT_UNICODE_ASCII16; + } + + if (NlsMbCodePageTag) + { for (i = 0; i < len; i++) { - if (s[i] <= 255) stats++; + if (NlsLeadByteInfo[s[i]]) + { + ++lead_byte; + ++i; + } } - if (stats > len / 2) - out_flags |= IS_TEXT_UNICODE_STATISTICS; + if (lead_byte) + { + weight = (len / 2) - 1; + + if (lead_byte < (weight / 3)) + weight = 3; + else if (lead_byte < ((weight * 2) / 3)) + weight = 2; + else + weight = 1; + } } + /* apply some statistical analysis */ + if ((flags & IS_TEXT_UNICODE_STATISTICS) && + ((weight * hi_byte_diff) < lo_byte_diff)) + { + out_flags |= IS_TEXT_UNICODE_STATISTICS; + } + /* Check for unicode NULL chars */ if (flags & IS_TEXT_UNICODE_NULL_BYTES) { @@ -1329,6 +1378,16 @@ break; } } + + if (hi_byte_diff && !lo_byte_diff) + { + out_flags |= IS_TEXT_UNICODE_REVERSE_ASCII16; + } + + if ((weight * lo_byte_diff) < hi_byte_diff) + { + out_flags |= IS_TEXT_UNICODE_REVERSE_STATISTICS; + } } if (pf) Index: reactos =================================================================== --- reactos (revision 72475) +++ reactos (revision 72486) Property changes on: reactos ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /branches/GSoC_2016/USB:r72376