ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2009
----- 2024 -----
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
21 participants
654 discussions
Start a n
N
ew thread
[tkreuzer] 42535: [FORMATTING] 4 spaces indentation, no code change
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat Aug 8 21:53:21 2009 New Revision: 42535 URL:
http://svn.reactos.org/svn/reactos?rev=42535&view=rev
Log: [FORMATTING] 4 spaces indentation, no code change Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Sat Aug 8 21:53:21 2009 @@ -130,70 +130,70 @@ /* Check arguments */ #ifdef CDS_VIDEOPARAMETERS + if (dwflags != CDS_VIDEOPARAMETERS && lParam != NULL) +#else + if (lParam != NULL) +#endif + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return DISP_CHANGE_BADPARAM; + } - if (dwflags != CDS_VIDEOPARAMETERS && lParam != NULL) -#else + if (hwnd != NULL) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return DISP_CHANGE_BADPARAM; + } - if (lParam != NULL) -#endif + /* Copy devmode */ + if (lpDevMode != NULL) + { + _SEH2_TRY + { + ProbeForRead(lpDevMode, sizeof(DevMode.dmSize), 1); + DevMode.dmSize = lpDevMode->dmSize; + DevMode.dmSize = min(sizeof(DevMode), DevMode.dmSize); + ProbeForRead(lpDevMode, DevMode.dmSize, 1); + RtlCopyMemory(&DevMode, lpDevMode, DevMode.dmSize); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return DISP_CHANGE_BADPARAM; - } - if (hwnd != NULL) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return DISP_CHANGE_BADPARAM; - } + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return DISP_CHANGE_BADPARAM; + } - /* Copy devmode */ - if (lpDevMode != NULL) - { - _SEH2_TRY - { - ProbeForRead(lpDevMode, sizeof(DevMode.dmSize), 1); - DevMode.dmSize = lpDevMode->dmSize; - DevMode.dmSize = min(sizeof(DevMode), DevMode.dmSize); - ProbeForRead(lpDevMode, DevMode.dmSize, 1); - RtlCopyMemory(&DevMode, lpDevMode, DevMode.dmSize); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return DISP_CHANGE_BADPARAM; - } - if (DevMode.dmDriverExtra > 0) - { - DPRINT1("lpDevMode->dmDriverExtra is IGNORED!\n"); - DevMode.dmDriverExtra = 0; - } - lpSafeDevMode = &DevMode; - } + if (DevMode.dmDriverExtra > 0) + { + DPRINT1("lpDevMode->dmDriverExtra is IGNORED!\n"); + DevMode.dmDriverExtra = 0; + } + lpSafeDevMode = &DevMode; + } - /* Copy the device name */ - if (lpszDeviceName != NULL) - { - Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName); - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return DISP_CHANGE_BADPARAM; - } - pSafeDeviceName = &SafeDeviceName; - } + /* Copy the device name */ + if (lpszDeviceName != NULL) + { + Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return DISP_CHANGE_BADPARAM; + } + pSafeDeviceName = &SafeDeviceName; + } - /* Call internal function */ - Ret = IntChangeDisplaySettings(pSafeDeviceName, lpSafeDevMode, dwflags, lParam); + /* Call internal function */ + Ret = IntChangeDisplaySettings(pSafeDeviceName, lpSafeDevMode, dwflags, lParam); - if (pSafeDeviceName != NULL) - RtlFreeUnicodeString(pSafeDeviceName); + if (pSafeDeviceName != NULL) + RtlFreeUnicodeString(pSafeDeviceName); - return Ret; + return Ret; }
15 years, 1 month
1
0
0
0
[dgorbachev] 42534: - Do not compare an ULONG variable with -1 in DbgPrint(). - Simplify TuiPrintf().
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Sat Aug 8 21:34:21 2009 New Revision: 42534 URL:
http://svn.reactos.org/svn/reactos?rev=42534&view=rev
Log: - Do not compare an ULONG variable with -1 in DbgPrint(). - Simplify TuiPrintf(). Modified: trunk/reactos/boot/freeldr/freeldr/debug.c trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c trunk/reactos/boot/freeldr/freeldr/ui/tui.c Modified: trunk/reactos/boot/freeldr/freeldr/debug.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/debug…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/debug.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/debug.c [iso-8859-1] Sat Aug 8 21:34:21 2009 @@ -102,209 +102,208 @@ ULONG DbgPrint(const char *Format, ...) { + int i; + int Length; + va_list ap; + CHAR Buffer[512]; + + va_start(ap, Format); + Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap); + va_end(ap); + + /* Check if we went past the buffer */ + if (Length == -1) + { + /* Terminate it if we went over-board */ + Buffer[sizeof(Buffer) - 1] = '\n'; + + /* Put maximum */ + Length = sizeof(Buffer); + } + + for (i = 0; i < Length; i++) + { + DebugPrintChar(Buffer[i]); + } + + return 0; +} + +VOID DebugPrintHeader(ULONG Mask) +{ + /* No header */ + if (Mask == 0) + return; + + switch (Mask) + { + case DPRINT_WARNING: + DbgPrint("WARNING: "); + break; + case DPRINT_MEMORY: + DbgPrint("MEMORY: "); + break; + case DPRINT_FILESYSTEM: + DbgPrint("FILESYS: "); + break; + case DPRINT_INIFILE: + DbgPrint("INIFILE: "); + break; + case DPRINT_UI: + DbgPrint("UI: "); + break; + case DPRINT_DISK: + DbgPrint("DISK: "); + break; + case DPRINT_CACHE: + DbgPrint("CACHE: "); + break; + case DPRINT_REGISTRY: + DbgPrint("REGISTER: "); + break; + case DPRINT_REACTOS: + DbgPrint("REACTOS: "); + break; + case DPRINT_LINUX: + DbgPrint("LINUX: "); + break; + case DPRINT_WINDOWS: + DbgPrint("WINLDR: "); + break; + case DPRINT_HWDETECT: + DbgPrint("HWDETECT: "); + break; + default: + DbgPrint("UNKNOWN: "); + break; + } +} + +char* g_file; +int g_line; + +VOID DbgPrintMask(ULONG Mask, char *format, ...) +{ + va_list ap; + char Buffer[2096]; + char *ptr = Buffer; + + // Mask out unwanted debug messages + if (!(Mask & DebugPrintMask)) + { + return; + } + + // Print the header if we have started a new line + if (DebugStartOfLine) + { + DbgPrint("(%s:%d) ", g_file, g_line); + DebugPrintHeader(Mask); + DebugStartOfLine = FALSE; + } + + va_start(ap, format); + vsprintf(Buffer, format, ap); + va_end(ap); + + while (*ptr) + { + DebugPrintChar(*ptr++); + } +} + +VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length) +{ + PUCHAR BufPtr = (PUCHAR)Buffer; + ULONG Idx; + ULONG Idx2; + + // Mask out unwanted debug messages + if (!(Mask & DebugPrintMask)) + { + return; + } + + DebugStartOfLine = FALSE; // We don't want line headers + DbgPrintMask(Mask, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer, Length); + + for (Idx=0; Idx<Length; ) + { + DebugStartOfLine = FALSE; // We don't want line headers + + if (Idx < 0x0010) + { + DbgPrintMask(Mask, "000%x:\t", Idx); + } + else if (Idx < 0x0100) + { + DbgPrintMask(Mask, "00%x:\t", Idx); + } + else if (Idx < 0x1000) + { + DbgPrintMask(Mask, "0%x:\t", Idx); + } + else + { + DbgPrintMask(Mask, "%x:\t", Idx); + } + + for (Idx2=0; Idx2<16; Idx2++,Idx++) + { + if (BufPtr[Idx] < 0x10) + { + DbgPrintMask(Mask, "0"); + } + DbgPrintMask(Mask, "%x", BufPtr[Idx]); + + if (Idx2 == 7) + { + DbgPrintMask(Mask, "-"); + } + else + { + DbgPrintMask(Mask, " "); + } + } + + Idx -= 16; + DbgPrintMask(Mask, " "); + + for (Idx2=0; Idx2<16; Idx2++,Idx++) + { + if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80)) + { + DbgPrintMask(Mask, "%c", BufPtr[Idx]); + } + else + { + DbgPrintMask(Mask, "."); + } + } + + DbgPrintMask(Mask, "\n"); + } +} + +#else + +VOID DbgPrintMask(ULONG Mask, char *format, ...) +{ +} + +ULONG DbgPrint(PCCH Format, ...) +{ + return 0; +} + +#endif // DBG + +ULONG +MsgBoxPrint(const char *Format, ...) +{ va_list ap; CHAR Buffer[512]; ULONG Length; - char *ptr = Buffer; - - va_start(ap, Format); - - /* Construct a string */ - Length = _vsnprintf(Buffer, 512, Format, ap); - - /* Check if we went past the buffer */ - if (Length == -1) - { - /* Terminate it if we went over-board */ - Buffer[sizeof(Buffer) - 1] = '\n'; - - /* Put maximum */ - Length = sizeof(Buffer); - } - - while (*ptr) - { - DebugPrintChar(*ptr++); - } - - va_end(ap); - return 0; -} - -VOID DebugPrintHeader(ULONG Mask) -{ - /* No header */ - if (Mask == 0) - return; - - switch (Mask) - { - case DPRINT_WARNING: - DbgPrint("WARNING: "); - break; - case DPRINT_MEMORY: - DbgPrint("MEMORY: "); - break; - case DPRINT_FILESYSTEM: - DbgPrint("FILESYS: "); - break; - case DPRINT_INIFILE: - DbgPrint("INIFILE: "); - break; - case DPRINT_UI: - DbgPrint("UI: "); - break; - case DPRINT_DISK: - DbgPrint("DISK: "); - break; - case DPRINT_CACHE: - DbgPrint("CACHE: "); - break; - case DPRINT_REGISTRY: - DbgPrint("REGISTER: "); - break; - case DPRINT_REACTOS: - DbgPrint("REACTOS: "); - break; - case DPRINT_LINUX: - DbgPrint("LINUX: "); - break; - case DPRINT_WINDOWS: - DbgPrint("WINLDR: "); - break; - case DPRINT_HWDETECT: - DbgPrint("HWDETECT: "); - break; - default: - DbgPrint("UNKNOWN: "); - break; - } -} - -char* g_file; -int g_line; - -VOID DbgPrintMask(ULONG Mask, char *format, ...) -{ - va_list ap; - char Buffer[2096]; - char *ptr = Buffer; - - // Mask out unwanted debug messages - if (!(Mask & DebugPrintMask)) - { - return; - } - - // Print the header if we have started a new line - if (DebugStartOfLine) - { - DbgPrint("(%s:%d) ", g_file, g_line); - DebugPrintHeader(Mask); - DebugStartOfLine = FALSE; - } - - va_start(ap, format); - vsprintf(Buffer, format, ap); - va_end(ap); - while (*ptr) - { - DebugPrintChar(*ptr++); - } -} - -VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length) -{ - PUCHAR BufPtr = (PUCHAR)Buffer; - ULONG Idx; - ULONG Idx2; - - // Mask out unwanted debug messages - if (!(Mask & DebugPrintMask)) - { - return; - } - - DebugStartOfLine = FALSE; // We don't want line headers - DbgPrintMask(Mask, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer, Length); - - for (Idx=0; Idx<Length; ) - { - DebugStartOfLine = FALSE; // We don't want line headers - - if (Idx < 0x0010) - { - DbgPrintMask(Mask, "000%x:\t", Idx); - } - else if (Idx < 0x0100) - { - DbgPrintMask(Mask, "00%x:\t", Idx); - } - else if (Idx < 0x1000) - { - DbgPrintMask(Mask, "0%x:\t", Idx); - } - else - { - DbgPrintMask(Mask, "%x:\t", Idx); - } - - for (Idx2=0; Idx2<16; Idx2++,Idx++) - { - if (BufPtr[Idx] < 0x10) - { - DbgPrintMask(Mask, "0"); - } - DbgPrintMask(Mask, "%x", BufPtr[Idx]); - - if (Idx2 == 7) - { - DbgPrintMask(Mask, "-"); - } - else - { - DbgPrintMask(Mask, " "); - } - } - - Idx -= 16; - DbgPrintMask(Mask, " "); - - for (Idx2=0; Idx2<16; Idx2++,Idx++) - { - if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80)) - { - DbgPrintMask(Mask, "%c", BufPtr[Idx]); - } - else - { - DbgPrintMask(Mask, "."); - } - } - - DbgPrintMask(Mask, "\n"); - } -} - -#else - -VOID DbgPrintMask(ULONG Mask, char *format, ...) -{ -} - -ULONG DbgPrint(PCCH Format, ...) -{ - return 0; -} - -#endif // DBG - -ULONG -MsgBoxPrint(const char *Format, ...) -{ - va_list ap; - CHAR Buffer[512]; - ULONG Length; va_start(ap, Format); Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c [iso-8859-1] Sat Aug 8 21:34:21 2009 @@ -871,7 +871,7 @@ UiMessageBox("Could not load the System hive!\n"); return; } - DPRINTM(DPRINT_REACTOS, "SystemHive loaded at 0x%x size %u", (unsigned)Base, (unsigned)Size); + DPRINTM(DPRINT_REACTOS, "SystemHive loaded at 0x%x size %u\n", (unsigned)Base, (unsigned)Size); /* * Import the loaded system hive Modified: trunk/reactos/boot/freeldr/freeldr/ui/tui.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/tu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/ui/tui.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/ui/tui.c [iso-8859-1] Sat Aug 8 21:34:21 2009 @@ -22,61 +22,28 @@ PVOID TextVideoBuffer = NULL; /* - * printf() - prints formatted text to stdout - * originally from GRUB + * TuiPrintf() + * Prints formatted text to the screen */ -int TuiPrintf(const char *format, ... ) -{ - char c, *ptr, str[16]; +int TuiPrintf(const char *Format, ...) +{ + int i; + int Length; va_list ap; - va_start(ap,format); - - while ((c = *(format++))) - { - if (c != '%') - { - MachConsPutChar(c); - } - else - { - switch (c = *(format++)) - { - case 'c': - MachConsPutChar((va_arg(ap, int)) & 0xff); - break; - case 's': - ptr = va_arg(ap, char *); - while ((c = *(ptr++))) - { - MachConsPutChar(c); - } - break; - case '%': - MachConsPutChar(c); - break; - case 'l': - c = *(format++); - /* Fall through. */ - case 'd': case 'u': case 'x': - if (c == 'x') - _itoa(va_arg(ap, unsigned long), str, 16); - else - _itoa(va_arg(ap, unsigned long), str, 10); - ptr = str; - while (*ptr) - { - MachConsPutChar(*(ptr++)); - } - break; - default: - printf("\nprintf() invalid format specifier - %%%c\n", c); - break; - } - } - } - + CHAR Buffer[512]; + + va_start(ap, Format); + Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap); va_end(ap); - return 0; + + if (Length == -1) Length = sizeof(Buffer); + + for (i = 0; i < Length; i++) + { + MachConsPutChar(Buffer[i]); + } + + return Length; } BOOLEAN TuiInitialize(VOID) @@ -447,8 +414,8 @@ CHAR TempString[20]; BOOLEAN PMHour = FALSE; - /* Don't draw the time if this has been disabled */ - if (!UiDrawTime) return; + /* Don't draw the time if this has been disabled */ + if (!UiDrawTime) return; TimeInfo = ArcGetTime(); if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year ||
15 years, 1 month
1
0
0
0
[hpoussin] 42533: HACK FIX DiskGetBootPath() method to return something meaningful when booting from hard disk
by hpoussin@svn.reactos.org
Author: hpoussin Date: Sat Aug 8 21:33:08 2009 New Revision: 42533 URL:
http://svn.reactos.org/svn/reactos?rev=42533&view=rev
Log: HACK FIX DiskGetBootPath() method to return something meaningful when booting from hard disk Modified: trunk/reactos/boot/freeldr/freeldr/disk/disk.c Modified: trunk/reactos/boot/freeldr/freeldr/disk/disk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] Sat Aug 8 21:33:08 2009 @@ -361,6 +361,8 @@ strcat(BootPath, MachDiskBootingFromFloppy() ? "fdisk" : "cdrom"); strcat(strcat(strcat(BootPath, "("), Device), ")"); + if (strcmp(BootPath, "multi(0)disk(0)cdrom(128)") == 0) + strcpy(BootPath, "multi(0)disk(0)rdisk(0)partition(1)"); return TRUE; }
15 years, 1 month
1
0
0
0
[fireball] 42532: - Implement GetDIBits, this was the last piece of code needed to support icons drawing in ROS explorer's Start Menu. - Pass a pointer to the dibsection to RosGdiGetDIBits, currently unused though. - Fix RosGdiCreateDIBSection bug: DIB section bits shouldn't be inverted once again if biHeight<0, this is already taken care of in other places. This fixes correct mask, but topdown icon drawing in the ROS explorer's Start Menu.
by fireball@svn.reactos.org
Author: fireball Date: Sat Aug 8 21:13:20 2009 New Revision: 42532 URL:
http://svn.reactos.org/svn/reactos?rev=42532&view=rev
Log: - Implement GetDIBits, this was the last piece of code needed to support icons drawing in ROS explorer's Start Menu. - Pass a pointer to the dibsection to RosGdiGetDIBits, currently unused though. - Fix RosGdiCreateDIBSection bug: DIB section bits shouldn't be inverted once again if biHeight<0, this is already taken care of in other places. This fixes correct mask, but topdown icon drawing in the ROS explorer's Start Menu. Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c branches/arwinss/reactos/include/psdk/ntrosgdi.h branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -308,8 +308,14 @@ INT CDECL RosDrv_GetDIBits( NTDRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse ) { - UNIMPLEMENTED; - return 0; + size_t obj_size; + DIBSECTION dib; + + /* Check if this bitmap has a DIB section */ + if (!(obj_size = GetObjectW( hbitmap, sizeof(dib), &dib ))) return 0; + + /* Perform GetDIBits */ + return RosGdiGetDIBits(physDev->hKernelDC, hbitmap, startscan, lines, bits, info, coloruse, &dib); } INT CDECL RosDrv_GetDeviceCaps( NTDRV_PDEVICE *physDev, INT cap ) Modified: branches/arwinss/reactos/include/psdk/ntrosgdi.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/psdk/nt…
============================================================================== --- branches/arwinss/reactos/include/psdk/ntrosgdi.h [iso-8859-1] (original) +++ branches/arwinss/reactos/include/psdk/ntrosgdi.h [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -79,7 +79,7 @@ BOOL APIENTRY RosGdiDeleteBitmap( HBITMAP hbitmap ); LONG APIENTRY RosGdiGetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count ); INT APIENTRY RosGdiGetDIBits( HDC physDev, HBITMAP hbitmap, UINT startscan, UINT lines, - LPVOID bits, BITMAPINFO *info, UINT coloruse ); + LPVOID bits, BITMAPINFO *info, UINT coloruse, DIBSECTION *dib ); COLORREF APIENTRY RosGdiGetPixel( HDC physDev, INT x, INT y ); BOOL APIENTRY RosGdiPatBlt( HDC physDev, INT left, INT top, INT width, INT height, DWORD rop ); LONG APIENTRY RosGdiSetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count ); Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -121,7 +121,7 @@ hbmDIB = GreCreateBitmap(szSize, dib->dsBm.bmWidthBytes, ulFormat, BMF_DONTCACHE | BMF_USERMEM | BMF_NOZEROINIT | - (dib->dsBmih.biHeight < 0 ? BMF_TOPDOWN : 0), + 0, dib->dsBm.bmBits); /* Map handles */ @@ -196,11 +196,33 @@ return ret; } -INT APIENTRY RosGdiGetDIBits( HDC physDev, HBITMAP hbitmap, UINT startscan, UINT lines, - LPVOID bits, BITMAPINFO *info, UINT coloruse ) -{ - UNIMPLEMENTED; - return 0; +INT APIENTRY RosGdiGetDIBits( HDC physDev, HBITMAP hUserBitmap, UINT StartScan, UINT ScanLines, + LPVOID Bits, BITMAPINFO *bmi, UINT ColorUse, DIBSECTION *dib ) +{ + PDC pDC; + + HGDIOBJ hBitmap = GDI_MapUserHandle(hUserBitmap); + + /* Get a pointer to the DCs */ + pDC = DC_Lock(physDev); + + DPRINT1("RosGdiGetDIBits for bitmap %x (user handle %x), StartScan %d, ScanLines %d, height %d\n", + hBitmap, hUserBitmap, StartScan, ScanLines, dib->dsBm.bmHeight); + + /* Set the bits */ + GreGetDIBits(pDC, + hBitmap, + StartScan, + ScanLines, + Bits, + bmi, + ColorUse); + + /* Release DC objects */ + DC_Unlock(pDC); + + /* Return amount of lines set */ + return ScanLines; } COLORREF APIENTRY RosGdiGetPixel( HDC physDev, INT x, INT y ) Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -11,6 +11,50 @@ #include <win32k.h> #define NDEBUG #include <debug.h> + +static const RGBQUAD EGAColorsQuads[16] = { +/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ + { 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x80, 0x00 }, + { 0x00, 0x80, 0x00, 0x00 }, + { 0x00, 0x80, 0x80, 0x00 }, + { 0x80, 0x00, 0x00, 0x00 }, + { 0x80, 0x00, 0x80, 0x00 }, + { 0x80, 0x80, 0x00, 0x00 }, + { 0x80, 0x80, 0x80, 0x00 }, + { 0xc0, 0xc0, 0xc0, 0x00 }, + { 0x00, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0x00, 0xff, 0xff, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0x00, 0xff, 0x00 }, + { 0xff, 0xff, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 } +}; + +static const RGBQUAD DefLogPaletteQuads[20] = { /* Copy of Default Logical Palette */ +/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ + { 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x80, 0x00 }, + { 0x00, 0x80, 0x00, 0x00 }, + { 0x00, 0x80, 0x80, 0x00 }, + { 0x80, 0x00, 0x00, 0x00 }, + { 0x80, 0x00, 0x80, 0x00 }, + { 0x80, 0x80, 0x00, 0x00 }, + { 0xc0, 0xc0, 0xc0, 0x00 }, + { 0xc0, 0xdc, 0xc0, 0x00 }, + { 0xf0, 0xca, 0xa6, 0x00 }, + { 0xf0, 0xfb, 0xff, 0x00 }, + { 0xa4, 0xa0, 0xa0, 0x00 }, + { 0x80, 0x80, 0x80, 0x00 }, + { 0x00, 0x00, 0xf0, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0x00, 0xff, 0xff, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0x00, 0xff, 0x00 }, + { 0xff, 0xff, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 } +}; INT NTAPI DIB_GetDIBWidthBytes(INT width, INT depth) { @@ -538,4 +582,385 @@ return result; } +// Converts a device-dependent bitmap to a DIB +INT +NTAPI +GreGetDIBits( + PDC Dc, + HBITMAP hBitmap, + UINT StartScan, + UINT ScanLines, + VOID *Bits, + BITMAPINFO *Info, + UINT Usage) +{ + SURFACE *psurf = NULL; + HBITMAP hDestBitmap = NULL; + HPALETTE hSourcePalette = NULL; + HPALETTE hDestPalette = NULL; + PPALETTE SourcePalette = NULL; + PPALETTE DestPalette = NULL; + NTSTATUS Status = STATUS_SUCCESS; + ULONG Result = 0; + BOOL bPaletteMatch = FALSE; + PBYTE ChkBits = Bits; + PVOID ColorPtr; + RGBQUAD *rgbQuads; + ULONG SourcePaletteType = 0; + ULONG DestPaletteType; + ULONG Index; + + DPRINT("Entered NtGdiGetDIBitsInternal()\n"); + + if ((Usage && Usage != DIB_PAL_COLORS) || !Info || !hBitmap) + return 0; + + // if ScanLines == 0, no need to copy Bits. + if (!ScanLines) + ChkBits = NULL; + + _SEH2_TRY + { + ProbeForWrite(Info, Info->bmiHeader.biSize, 1); // Comp for Core. + //if (ChkBits) ProbeForWrite(ChkBits, MaxBits, 1); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END + + if (!NT_SUCCESS(Status)) + { + return 0; + } + + /* Get a pointer to the source bitmap object */ + psurf = SURFACE_Lock(hBitmap); + if (psurf == NULL) + return 0; + + hSourcePalette = psurf->hDIBPalette; + if (!hSourcePalette) + { + hSourcePalette = pPrimarySurface->DevInfo.hpalDefault; + } + + ColorPtr = ((PBYTE)Info + Info->bmiHeader.biSize); + rgbQuads = (RGBQUAD *)ColorPtr; + + /* Copy palette information + * Always create a palette for 15 & 16 bit. */ + if (Info->bmiHeader.biBitCount == BitsPerFormat(psurf->SurfObj.iBitmapFormat) && + Info->bmiHeader.biBitCount != 15 && Info->bmiHeader.biBitCount != 16) + { + hDestPalette = hSourcePalette; + bPaletteMatch = TRUE; + } + else + hDestPalette = BuildDIBPalette(Info, (PINT)&DestPaletteType); //hDestPalette = Dc->DevInfo->hpalDefault; + + SourcePalette = PALETTE_LockPalette(hSourcePalette); + /* FIXME - SourcePalette can be NULL!!! Don't assert here! */ + ASSERT(SourcePalette); + SourcePaletteType = SourcePalette->Mode; + PALETTE_UnlockPalette(SourcePalette); + + if (bPaletteMatch) + { + DestPalette = PALETTE_LockPalette(hDestPalette); + /* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */ + DPRINT("DestPalette : %p\n", DestPalette); + ASSERT(DestPalette); + DestPaletteType = DestPalette->Mode; + } + else + { + DestPalette = SourcePalette; + } + + /* Copy palette. */ + /* FIXME: This is largely incomplete. ATM no Core!*/ + switch (Info->bmiHeader.biBitCount) + { + case 1: + case 4: + case 8: + Info->bmiHeader.biClrUsed = 0; + if (/*psurf->hSecure &&*/ + BitsPerFormat(psurf->SurfObj.iBitmapFormat) == Info->bmiHeader.biBitCount) + { + if (Usage == DIB_RGB_COLORS) + { + if (DestPalette->NumColors != 1 << Info->bmiHeader.biBitCount) + Info->bmiHeader.biClrUsed = DestPalette->NumColors; + for (Index = 0; + Index < (1 << Info->bmiHeader.biBitCount) && Index < DestPalette->NumColors; + Index++) + { + rgbQuads[Index].rgbRed = DestPalette->IndexedColors[Index].peRed; + rgbQuads[Index].rgbGreen = DestPalette->IndexedColors[Index].peGreen; + rgbQuads[Index].rgbBlue = DestPalette->IndexedColors[Index].peBlue; + rgbQuads[Index].rgbReserved = 0; + } + } + else + { + PWORD Ptr = ColorPtr; + for (Index = 0; + Index < (1 << Info->bmiHeader.biBitCount); + Index++) + { + Ptr[Index] = (WORD)Index; + } + } + } + else + { + if (Usage == DIB_PAL_COLORS) + { + PWORD Ptr = ColorPtr; + for (Index = 0; + Index < (1 << Info->bmiHeader.biBitCount); + Index++) + { + Ptr[Index] = (WORD)Index; + } + } + else if (Info->bmiHeader.biBitCount > 1 && bPaletteMatch) + { + for (Index = 0; + Index < (1 << Info->bmiHeader.biBitCount) && Index < DestPalette->NumColors; + Index++) + { + Info->bmiColors[Index].rgbRed = DestPalette->IndexedColors[Index].peRed; + Info->bmiColors[Index].rgbGreen = DestPalette->IndexedColors[Index].peGreen; + Info->bmiColors[Index].rgbBlue = DestPalette->IndexedColors[Index].peBlue; + Info->bmiColors[Index].rgbReserved = 0; + } + } + else + { + switch (Info->bmiHeader.biBitCount) + { + case 1: + rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue = 0; + rgbQuads[0].rgbReserved = 0; + rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue = 0xff; + rgbQuads[1].rgbReserved = 0; + break; + case 4: + RtlCopyMemory(ColorPtr, EGAColorsQuads, sizeof(EGAColorsQuads)); + break; + case 8: + { + INT r, g, b; + RGBQUAD *color; + + RtlCopyMemory(rgbQuads, DefLogPaletteQuads, 10 * sizeof(RGBQUAD)); + RtlCopyMemory(rgbQuads + 246, DefLogPaletteQuads + 10, 10 * sizeof(RGBQUAD)); + color = rgbQuads + 10; + for (r = 0; r <= 5; r++) /* FIXME */ + for (g = 0; g <= 5; g++) + for (b = 0; b <= 5; b++) + { + color->rgbRed = (r * 0xff) / 5; + color->rgbGreen = (g * 0xff) / 5; + color->rgbBlue = (b * 0xff) / 5; + color->rgbReserved = 0; + color++; + } + } + break; + } + } + } + + case 15: + if (Info->bmiHeader.biCompression == BI_BITFIELDS) + { + ((PDWORD)Info->bmiColors)[0] = 0x7c00; + ((PDWORD)Info->bmiColors)[1] = 0x03e0; + ((PDWORD)Info->bmiColors)[2] = 0x001f; + } + break; + + case 16: + if (Info->bmiHeader.biCompression == BI_BITFIELDS) + { + ((PDWORD)Info->bmiColors)[0] = 0xf800; + ((PDWORD)Info->bmiColors)[1] = 0x07e0; + ((PDWORD)Info->bmiColors)[2] = 0x001f; + } + break; + + case 24: + case 32: + if (Info->bmiHeader.biCompression == BI_BITFIELDS) + { + ((PDWORD)Info->bmiColors)[0] = 0xff0000; + ((PDWORD)Info->bmiColors)[1] = 0x00ff00; + ((PDWORD)Info->bmiColors)[2] = 0x0000ff; + } + break; + } + + if (bPaletteMatch) + PALETTE_UnlockPalette(DestPalette); + + /* fill out the BITMAPINFO struct */ + if (!ChkBits) + { // Core or not to Core? We have converted from Core in Gdi~ so? + if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + BITMAPCOREHEADER* coreheader = (BITMAPCOREHEADER*) Info; + coreheader->bcWidth = psurf->SurfObj.sizlBitmap.cx; + coreheader->bcPlanes = 1; + coreheader->bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); + coreheader->bcHeight = psurf->SurfObj.sizlBitmap.cy; + if (psurf->SurfObj.lDelta > 0) + coreheader->bcHeight = -coreheader->bcHeight; + } + + if (Info->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) + { + Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx; + Info->bmiHeader.biHeight = psurf->SurfObj.sizlBitmap.cy; + Info->bmiHeader.biPlanes = 1; + Info->bmiHeader.biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); + switch (psurf->SurfObj.iBitmapFormat) + { + /* FIXME: What about BI_BITFIELDS? */ + case BMF_1BPP: + case BMF_4BPP: + case BMF_8BPP: + case BMF_16BPP: + case BMF_24BPP: + case BMF_32BPP: + Info->bmiHeader.biCompression = BI_RGB; + break; + case BMF_4RLE: + Info->bmiHeader.biCompression = BI_RLE4; + break; + case BMF_8RLE: + Info->bmiHeader.biCompression = BI_RLE8; + break; + case BMF_JPEG: + Info->bmiHeader.biCompression = BI_JPEG; + break; + case BMF_PNG: + Info->bmiHeader.biCompression = BI_PNG; + break; + } + /* Image size has to be calculated */ + Info->bmiHeader.biSizeImage = DIB_GetDIBWidthBytes(Info->bmiHeader.biWidth, + Info->bmiHeader.biBitCount) * Info->bmiHeader.biHeight; + Info->bmiHeader.biXPelsPerMeter = 0; /* FIXME */ + Info->bmiHeader.biYPelsPerMeter = 0; /* FIXME */ + Info->bmiHeader.biClrUsed = 0; + Info->bmiHeader.biClrImportant = 1 << Info->bmiHeader.biBitCount; /* FIXME */ + /* Report negtive height for top-down bitmaps. */ + if (psurf->SurfObj.lDelta > 0) + Info->bmiHeader.biHeight = -Info->bmiHeader.biHeight; + } + Result = psurf->SurfObj.sizlBitmap.cy; + } + else + { + SIZEL DestSize; + POINTL SourcePoint; + +// +// If we have a good dib pointer, why not just copy bits from there w/o XLATE'ing them. +// + /* Create the destination bitmap too for the copy operation */ + if (StartScan > psurf->SurfObj.sizlBitmap.cy) + { + goto cleanup; + } + else + { + ScanLines = min(ScanLines, psurf->SurfObj.sizlBitmap.cy - StartScan); + DestSize.cx = psurf->SurfObj.sizlBitmap.cx; + DestSize.cy = ScanLines; + + hDestBitmap = NULL; + + if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + BITMAPCOREHEADER* coreheader = (BITMAPCOREHEADER*) Info; + hDestBitmap = EngCreateBitmap(DestSize, + DIB_GetDIBWidthBytes(DestSize.cx, coreheader->bcBitCount), + GrepBitmapFormat(coreheader->bcBitCount, BI_RGB), + 0 < coreheader->bcHeight ? 0 : BMF_TOPDOWN, + Bits); + } + + if (Info->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) + { + Info->bmiHeader.biSizeImage = DIB_GetDIBWidthBytes(DestSize.cx, + Info->bmiHeader.biBitCount) * DestSize.cy; + + hDestBitmap = EngCreateBitmap(DestSize, + DIB_GetDIBWidthBytes(DestSize.cx, Info->bmiHeader.biBitCount), + GrepBitmapFormat(Info->bmiHeader.biBitCount, Info->bmiHeader.biCompression), + 0 < Info->bmiHeader.biHeight ? 0 : BMF_TOPDOWN, + Bits); + } + + if (hDestBitmap == NULL) + goto cleanup; + } + + if (NT_SUCCESS(Status)) + { + XLATEOBJ *XlateObj; + SURFOBJ *DestSurfObj; + RECTL DestRect; + + XlateObj = IntEngCreateXlate(DestPaletteType, + SourcePaletteType, + hDestPalette, + hSourcePalette); + + SourcePoint.x = 0; + SourcePoint.y = psurf->SurfObj.sizlBitmap.cy - (StartScan + ScanLines); + + /* Determine destination rectangle */ + DestRect.top = 0; + DestRect.left = 0; + DestRect.right = DestSize.cx; + DestRect.bottom = DestSize.cy; + + DestSurfObj = EngLockSurface((HSURF)hDestBitmap); + + if (EngCopyBits(DestSurfObj, + &psurf->SurfObj, + NULL, + XlateObj, + &DestRect, + &SourcePoint)) + { + DPRINT("GetDIBits %d \n",abs(Info->bmiHeader.biHeight) - StartScan); + Result = ScanLines; + } + + EngDeleteXlate(XlateObj); + EngUnlockSurface(DestSurfObj); + } + } +cleanup: + if (hDestBitmap != NULL) + EngDeleteSurface((HSURF)hDestBitmap); + + if (hDestPalette != NULL && bPaletteMatch == FALSE) + PALETTE_FreePaletteByHandle(hDestPalette); + + SURFACE_Unlock(psurf); + + DPRINT("leaving GreGetDIBits\n"); + + return Result; +} + /* EOF */ Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -59,6 +59,17 @@ CONST BITMAPINFO *bmi, UINT ColorUse); +INT +NTAPI +GreGetDIBits( + PDC DC, + HBITMAP hBitmap, + UINT StartScan, + UINT ScanLines, + VOID *Bits, + BITMAPINFO *bmi, + UINT ColorUse); + INT FASTCALL BitsPerFormat(ULONG Format); Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sat Aug 8 21:13:20 2009 @@ -5,7 +5,7 @@ RosGdiCreateDIBSection 5 RosGdiDeleteBitmap 1 RosGdiGetBitmapBits 3 -RosGdiGetDIBits 7 +RosGdiGetDIBits 8 RosGdiGetPixel 3 RosGdiPatBlt 6 RosGdiSetBitmapBits 3
15 years, 1 month
1
0
0
0
[sginsberg] 42531: Fix Uniata for msvc: - Add missing msvc intrinsics to winddk.h - Don't assume compiler means a specific header set, and don't rely on the default calling convention being stdcall. - Disable a warning spotted by MSVC -- requesting anyone with understanding of the code to have a look.
by sginsberg@svn.reactos.org
Author: sginsberg Date: Sat Aug 8 20:27:01 2009 New Revision: 42531 URL:
http://svn.reactos.org/svn/reactos?rev=42531&view=rev
Log: Fix Uniata for msvc: - Add missing msvc intrinsics to winddk.h - Don't assume compiler means a specific header set, and don't rely on the default calling convention being stdcall. - Disable a warning spotted by MSVC -- requesting anyone with understanding of the code to have a look. Modified: trunk/reactos/drivers/storage/ide/uniata/config.h trunk/reactos/drivers/storage/ide/uniata/id_sata.cpp trunk/reactos/drivers/storage/ide/uniata/ntddk_ex.h trunk/reactos/include/ddk/winddk.h Modified: trunk/reactos/drivers/storage/ide/uniata/config.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/uniata…
============================================================================== --- trunk/reactos/drivers/storage/ide/uniata/config.h [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/ide/uniata/config.h [iso-8859-1] Sat Aug 8 20:27:01 2009 @@ -86,47 +86,21 @@ /* Compiler dependencies */ /***************************************************/ -/* ReactOS-specific defines */ -#ifdef DDKAPI - #define USE_REACTOS_DDK -#endif //DDKAPI +#define DDKAPI __stdcall +#define DDKFASTAPI __fastcall +#define DDKCDECLAPI __cdecl /* Are we under GNU C (mingw) ??? */ -#if __GNUC__ >=3 +#ifdef __GNUC__ #define DEF_U64(x) (x##ULL) #define DEF_I64(x) (x##LL) - - /* ReactOS-specific defines */ - #ifdef USE_REACTOS_DDK - #define DDKFASTAPI __attribute__((fastcall)) - #else //USE_REACTOS_DDK - - #define DDKAPI __attribute__((stdcall)) - #define DDKFASTAPI __attribute__((fastcall)) - #define DDKCDECLAPI __attribute__((cdecl)) - - #endif //DDKAPI - - #define DECLSPEC_NAKED __attribute__((naked)) #else // !__GNUC__ => MSVC/Intel #define DEF_U64(x) (x##UI64) #define DEF_I64(x) (x##I64) - /* ReactOS-specific defines */ - #ifdef USE_REACTOS_DDK - #else //USE_REACTOS_DDK - - #define DDKAPI __stdcall - #define DDKFASTAPI __fastcall - #define DDKCDECLAPI _cdecl - - #endif //DDKAPI - - #define DECLSPEC_NAKED __declspec(naked) - #endif //__GNUC__ Modified: trunk/reactos/drivers/storage/ide/uniata/id_sata.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/uniata…
============================================================================== --- trunk/reactos/drivers/storage/ide/uniata/id_sata.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/ide/uniata/id_sata.cpp [iso-8859-1] Sat Aug 8 20:27:01 2009 @@ -425,7 +425,15 @@ deviceExtension->lun[ldev].IdentifyData.FeaturesSupport.Address48) { i++; } else { +#ifdef _MSC_VER +#pragma message ("HACK HACK HACK Disabling warning HACK HACK HACK") +#pragma warning(push) +#pragma warning(disable:4333) +#endif fis[7] |= (plba[3] >> 24) & 0x0f; +#ifdef _MSC_VER +#pragma warning(pop) +#endif } fis[8] = plba[3]; Modified: trunk/reactos/drivers/storage/ide/uniata/ntddk_ex.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/uniata…
============================================================================== --- trunk/reactos/drivers/storage/ide/uniata/ntddk_ex.h [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/ide/uniata/ntddk_ex.h [iso-8859-1] Sat Aug 8 20:27:01 2009 @@ -629,12 +629,14 @@ NTHALAPI VOID +NTAPI HalDisplayString ( PUCHAR String ); NTHALAPI VOID +NTAPI HalQueryDisplayParameters ( OUT PULONG WidthInCharacters, OUT PULONG HeightInLines, @@ -644,6 +646,7 @@ NTHALAPI VOID +NTAPI HalSetDisplayParameters ( IN ULONG CursorColumn, IN ULONG CursorRow Modified: trunk/reactos/include/ddk/winddk.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=4…
============================================================================== --- trunk/reactos/include/ddk/winddk.h [iso-8859-1] (original) +++ trunk/reactos/include/ddk/winddk.h [iso-8859-1] Sat Aug 8 20:27:01 2009 @@ -33,6 +33,24 @@ #ifdef __GNUC__ #include "intrin.h" +#endif + +#ifdef _MSC_VER +// +// FIXME: MSVC Intrinsics +// +unsigned char __readfsbyte(const unsigned long Offset); +#pragma intrinsic(__readfsbyte) +long _InterlockedExchange(volatile long * const Target, const long Value); +#pragma intrinsic(_InterlockedExchange) +long _InterlockedExchangeAdd(volatile long * const Addend, const long Value); +#pragma intrinsic(_InterlockedExchangeAdd) +long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand); +#pragma intrinsic(_InterlockedCompareExchange) +long _InterlockedDecrement(volatile long * const lpAddend); +#pragma intrinsic(_InterlockedDecrement) +long _InterlockedIncrement(volatile long * const lpAddend); +#pragma intrinsic(_InterlockedIncrement) #endif #if !defined(_NTHAL_) @@ -5116,15 +5134,6 @@ ULONG Spare1; } KFLOATING_SAVE, *PKFLOATING_SAVE; -#ifdef _MSC_VER -// -// FIXME: Intrinsics -// -unsigned char __readfsbyte(const unsigned long Offset); -#pragma intrinsic(__readfsbyte) -#endif - - FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
15 years, 1 month
1
0
0
0
[hyperion] 42530: modified base/setup/vmwinst/vmwinst.c modified base/setup/vmwinst/vmwinst.rbuild Implement VMWare detection for Visual C++ as well For cleaner code, use SEH instead of VEH, even if it means losing this pearl of ReactOS wisdom: /* Setup a vectored exception handler to protect the detection. Don't use SEH here so we notice the next time someone removes support for vectored exception handling from ros... */ (www.passiveaggressivecommits.com, brought to you by Arch Blackmann!) Of c
by hyperion@svn.reactos.org
Author: hyperion Date: Sat Aug 8 20:03:48 2009 New Revision: 42530 URL:
http://svn.reactos.org/svn/reactos?rev=42530&view=rev
Log: modified base/setup/vmwinst/vmwinst.c modified base/setup/vmwinst/vmwinst.rbuild Implement VMWare detection for Visual C++ as well For cleaner code, use SEH instead of VEH, even if it means losing this pearl of ReactOS wisdom: /* Setup a vectored exception handler to protect the detection. Don't use SEH here so we notice the next time someone removes support for vectored exception handling from ros... */ (
www.passiveaggressivecommits.com
, brought to you by Arch Blackmann!) Of course, it also means trading our VEH bugs for our SEH bugs, so I'm not sure if it was worth changing Modified: trunk/reactos/base/setup/vmwinst/vmwinst.c trunk/reactos/base/setup/vmwinst/vmwinst.rbuild Modified: trunk/reactos/base/setup/vmwinst/vmwinst.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/vmwinst/vmwinst…
============================================================================== --- trunk/reactos/base/setup/vmwinst/vmwinst.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/vmwinst/vmwinst.c [iso-8859-1] Sat Aug 8 20:03:48 2009 @@ -29,6 +29,7 @@ #include <newdev.h> #include <stdio.h> #include <string.h> +#include <pseh/pseh2.h> #include "vmwinst.h" #include <debug.h> @@ -61,14 +62,6 @@ #define WM_INSTSTATUSUPDATE (WM_USER + 4) /* Helper functions */ - -LONG CALLBACK VectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) -{ - /* we're not running in VMware, just terminate the process */ - ExitProcess(ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION); - return EXCEPTION_CONTINUE_EXECUTION; -} - BOOL DetectVMware(int *Version) { @@ -77,16 +70,35 @@ magic = 0; ver = 0; - /* Try using a VMware I/O port. If not running in VMware this'll throw an - exception! */ -#ifndef _MSC_VER - __asm__ __volatile__("inl %%dx, %%eax" - : "=a" (ver), "=b" (magic) - : "0" (0x564d5868), "d" (0x5658), "c" (0xa)); + _SEH2_TRY + { + /* Try using a VMware I/O port. If not running in VMware this'll throw an + exception! */ +#if defined(__GNUC__) + __asm__ __volatile__("inl %%dx, %%eax" + : "=a" (ver), "=b" (magic) + : "0" (0x564d5868), "d" (0x5658), "c" (0xa)); +#elif defined(_MSC_VER) + __asm + { + push ebx + mov ecx, 0xa + mov edx, 0x5658 + mov eax, 0x564d5868 + in eax, dx + mov [ver], eax + mov [magic], ebx + pop ebx + } #else -#error PLEASE WRITE THIS IN ASSEMBLY +#error TODO #endif - + } + _SEH2_EXCEPT(_SEH2_GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + return FALSE; + } + _SEH2_END; if(magic == 0x564d5868) { @@ -1036,28 +1048,15 @@ int nCmdShow) { - PVOID ExceptionHandler; int Version; WCHAR *lc; hAppInstance = hInstance; - /* Setup a vectored exception handler to protect the detection. Don't use SEH - here so we notice the next time someone removes support for vectored - exception handling from ros... */ - if (!(ExceptionHandler = AddVectoredExceptionHandler(0, - VectoredExceptionHandler))) + if(!DetectVMware(&Version)) { return 1; } - - if(!DetectVMware(&Version)) - { - return 1; - } - - /* unregister the handler */ - RemoveVectoredExceptionHandler(ExceptionHandler); lc = DestinationPath; lc += GetSystemDirectory(DestinationPath, MAX_PATH) - 1; Modified: trunk/reactos/base/setup/vmwinst/vmwinst.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/vmwinst/vmwinst…
============================================================================== --- trunk/reactos/base/setup/vmwinst/vmwinst.rbuild [iso-8859-1] (original) +++ trunk/reactos/base/setup/vmwinst/vmwinst.rbuild [iso-8859-1] Sat Aug 8 20:03:48 2009 @@ -11,6 +11,7 @@ <library>setupapi</library> <library>shell32</library> <library>ntdll</library> + <library>pseh</library> <file>vmwinst.c</file> <file>vmwinst.rc</file> </module>
15 years, 1 month
1
0
0
0
[hyperion] 42529: modified dll/3rdparty/mesa32/src/main/imports.c We don't have _aligned_malloc in our CRT, whatever compiler we use modified dll/3rdparty/mesa32/src/main/imports.h The mysterious MESA compilation bug has been found: seems the Visual C++ preprocessor doesn't know about the "F" number suffix modified dll/3rdparty/mesa32/reactos.diff Updated the diff
by hyperion@svn.reactos.org
Author: hyperion Date: Sat Aug 8 19:18:34 2009 New Revision: 42529 URL:
http://svn.reactos.org/svn/reactos?rev=42529&view=rev
Log: modified dll/3rdparty/mesa32/src/main/imports.c We don't have _aligned_malloc in our CRT, whatever compiler we use modified dll/3rdparty/mesa32/src/main/imports.h The mysterious MESA compilation bug has been found: seems the Visual C++ preprocessor doesn't know about the "F" number suffix modified dll/3rdparty/mesa32/reactos.diff Updated the diff Modified: trunk/reactos/dll/3rdparty/mesa32/reactos.diff trunk/reactos/dll/3rdparty/mesa32/src/main/imports.c trunk/reactos/dll/3rdparty/mesa32/src/main/imports.h Modified: trunk/reactos/dll/3rdparty/mesa32/reactos.diff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/3rdparty/mesa32/reacto…
============================================================================== --- trunk/reactos/dll/3rdparty/mesa32/reactos.diff [iso-8859-1] (original) +++ trunk/reactos/dll/3rdparty/mesa32/reactos.diff [iso-8859-1] Sat Aug 8 19:18:34 2009 @@ -3995,3 +3995,55 @@ if ( cpu_has_xmm ) { _mesa_debug(NULL, "Yes.\n"); +Index: main/imports.c +=================================================================== +--- main/imports.c (revision 42472) ++++ main/imports.c (working copy) +@@ -104,7 +104,7 @@ + + (void) posix_memalign(& mem, alignment, bytes); + return mem; +-#elif defined(_WIN32) && defined(_MSC_VER) ++#elif 0/*defined(_WIN32) && defined(_MSC_VER)*/ + return _aligned_malloc(bytes, alignment); + #else + uintptr_t ptr, buf; +@@ -146,7 +146,7 @@ + } + + return mem; +-#elif defined(_WIN32) && defined(_MSC_VER) ++#elif 0/*defined(_WIN32) && defined(_MSC_VER)*/ + void *mem; + + mem = _aligned_malloc(bytes, alignment); +Index: main/imports.h +=================================================================== +--- main/imports.h (revision 42472) ++++ main/imports.h (working copy) +@@ -482,10 +482,10 @@ + /* This function/macro is sensitive to precision. Test very carefully + * if you change it! + */ +-#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ ++#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F_) \ + do { \ + fi_type __tmp; \ +- __tmp.f = (F); \ ++ __tmp.f = (F_); \ + if (__tmp.i < 0) \ + UB = (GLubyte) 0; \ + else if (__tmp.i >= IEEE_0996) \ +@@ -495,10 +495,10 @@ + UB = (GLubyte) __tmp.i; \ + } \ + } while (0) +-#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ ++#define CLAMPED_FLOAT_TO_UBYTE(UB, F_) \ + do { \ + fi_type __tmp; \ +- __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ ++ __tmp.f = (F_) * (255.0F/256.0F) + 32768.0F; \ + UB = (GLubyte) __tmp.i; \ + } while (0) + #else Modified: trunk/reactos/dll/3rdparty/mesa32/src/main/imports.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/3rdparty/mesa32/src/ma…
============================================================================== --- trunk/reactos/dll/3rdparty/mesa32/src/main/imports.c [iso-8859-1] (original) +++ trunk/reactos/dll/3rdparty/mesa32/src/main/imports.c [iso-8859-1] Sat Aug 8 19:18:34 2009 @@ -104,7 +104,7 @@ (void) posix_memalign(& mem, alignment, bytes); return mem; -#elif defined(_WIN32) && defined(_MSC_VER) +#elif 0/*defined(_WIN32) && defined(_MSC_VER)*/ return _aligned_malloc(bytes, alignment); #else uintptr_t ptr, buf; @@ -146,7 +146,7 @@ } return mem; -#elif defined(_WIN32) && defined(_MSC_VER) +#elif 0/*defined(_WIN32) && defined(_MSC_VER)*/ void *mem; mem = _aligned_malloc(bytes, alignment); Modified: trunk/reactos/dll/3rdparty/mesa32/src/main/imports.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/3rdparty/mesa32/src/ma…
============================================================================== --- trunk/reactos/dll/3rdparty/mesa32/src/main/imports.h [iso-8859-1] (original) +++ trunk/reactos/dll/3rdparty/mesa32/src/main/imports.h [iso-8859-1] Sat Aug 8 19:18:34 2009 @@ -482,10 +482,10 @@ /* This function/macro is sensitive to precision. Test very carefully * if you change it! */ -#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ +#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F_) \ do { \ fi_type __tmp; \ - __tmp.f = (F); \ + __tmp.f = (F_); \ if (__tmp.i < 0) \ UB = (GLubyte) 0; \ else if (__tmp.i >= IEEE_0996) \ @@ -495,10 +495,10 @@ UB = (GLubyte) __tmp.i; \ } \ } while (0) -#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ +#define CLAMPED_FLOAT_TO_UBYTE(UB, F_) \ do { \ fi_type __tmp; \ - __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ + __tmp.f = (F_) * (255.0F/256.0F) + 32768.0F; \ UB = (GLubyte) __tmp.i; \ } while (0) #else
15 years, 1 month
1
0
0
0
[hpoussin] 42528: Rework ISO9660 filesystem to use ARC file architecture. ISO filesystem doesn't depend anymore of boot volume/system volume
by hpoussin@svn.reactos.org
Author: hpoussin Date: Sat Aug 8 19:13:14 2009 New Revision: 42528 URL:
http://svn.reactos.org/svn/reactos?rev=42528&view=rev
Log: Rework ISO9660 filesystem to use ARC file architecture. ISO filesystem doesn't depend anymore of boot volume/system volume Modified: trunk/reactos/boot/freeldr/freeldr/fs/fs.c trunk/reactos/boot/freeldr/freeldr/fs/iso.c trunk/reactos/boot/freeldr/freeldr/include/fs/iso.h Modified: trunk/reactos/boot/freeldr/freeldr/fs/fs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/fs…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/fs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/fs.c [iso-8859-1] Sat Aug 8 19:13:14 2009 @@ -202,7 +202,7 @@ pFSVtbl = &Ext2Vtbl; break; case FS_ISO9660: - pFSVtbl = &Iso9660Vtbl; + pFSVtbl = &CompatArcVtbl; break; default: pFSVtbl = NULL; @@ -638,8 +638,12 @@ } /* Try to detect the file system */ - /* FIXME: we link there to old infrastructure... */ - FileData[DeviceId].FileFuncTable = &CompatFsFuncTable; + FileData[DeviceId].FileFuncTable = IsoMount(DeviceId); + if (!FileData[DeviceId].FileFuncTable) + { + /* FIXME: we link there to old infrastructure... */ + FileData[DeviceId].FileFuncTable = &CompatFsFuncTable; + } pDevice->DeviceId = DeviceId; } Modified: trunk/reactos/boot/freeldr/freeldr/fs/iso.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/is…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/iso.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/iso.c [iso-8859-1] Sat Aug 8 19:13:14 2009 @@ -1,6 +1,7 @@ /* * FreeLoader * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> + * Copyright (C) 2009 Hervé Poussineau <hpoussin(a)reactos.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,39 +23,6 @@ #define SECTORSIZE 2048 -static ULONG IsoRootSector; // Starting sector of the root directory -static ULONG IsoRootLength; // Length of the root directory - -ULONG IsoDriveNumber = 0; - - -BOOLEAN IsoOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG PartitionSectorCount) -{ - PPVD Pvd = (PPVD)DISKREADBUFFER; - - DPRINTM(DPRINT_FILESYSTEM, "IsoOpenVolume() DriveNumber = 0x%x VolumeStartSector = 16\n", DriveNumber); - - // Store the drive number - IsoDriveNumber = DriveNumber; - - IsoRootSector = 0; - IsoRootLength = 0; - - if (!MachDiskReadLogicalSectors(DriveNumber, 16, 1, Pvd)) - { - FileSystemError("Failed to read the PVD."); - return FALSE; - } - - IsoRootSector = Pvd->RootDirRecord.ExtentLocationL; - IsoRootLength = Pvd->RootDirRecord.DataLengthL; - - DPRINTM(DPRINT_FILESYSTEM, "IsoRootSector = %u IsoRootLegth = %u\n", IsoRootSector, IsoRootLength); - - return TRUE; -} - - static BOOLEAN IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer) { PDIR_RECORD Record; @@ -119,16 +87,18 @@ /* * IsoBufferDirectory() * This function allocates a buffer, reads the specified directory - * and returns a pointer to that buffer. The function returns NULL - * if allocation or read fails. The directory is specified by its - * starting sector and length. + * and returns a pointer to that buffer into pDirectoryBuffer. The + * function returns an ARC error code. The directory is specified + * by its starting sector and length. */ -static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLength) -{ - PVOID DirectoryBuffer; - PVOID Ptr; - ULONG SectorCount; - ULONG i; +static LONG IsoBufferDirectory(ULONG DeviceId, ULONG DirectoryStartSector, ULONG DirectoryLength, + PVOID* pDirectoryBuffer) +{ + PVOID DirectoryBuffer; + ULONG SectorCount; + LARGE_INTEGER Position; + ULONG Count; + ULONG ret; DPRINTM(DPRINT_FILESYSTEM, "IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength); @@ -140,26 +110,29 @@ // DPRINTM(DPRINT_FILESYSTEM, "Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength); DirectoryBuffer = MmHeapAlloc(DirectoryLength); - - if (DirectoryBuffer == NULL) - { - return NULL; - } + if (!DirectoryBuffer) + return ENOMEM; // // Now read directory contents into DirectoryBuffer // - for (i = 0, Ptr = DirectoryBuffer; i < SectorCount; i++, Ptr = (PVOID)((ULONG_PTR)Ptr + SECTORSIZE)) - { - if (!MachDiskReadLogicalSectors(IsoDriveNumber, DirectoryStartSector + i, 1, (PVOID)DISKREADBUFFER)) - { - MmHeapFree(DirectoryBuffer); - return NULL; - } - RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, SECTORSIZE); - } - - return DirectoryBuffer; + Position.HighPart = 0; + Position.LowPart = DirectoryStartSector * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + { + MmHeapFree(DirectoryBuffer); + return ret; + } + ret = ArcRead(DeviceId, DirectoryBuffer, SectorCount * SECTORSIZE, &Count); + if (ret != ESUCCESS || Count != SectorCount * SECTORSIZE) + { + MmHeapFree(DirectoryBuffer); + return EIO; + } + + *pDirectoryBuffer = DirectoryBuffer; + return ESUCCESS; } @@ -167,11 +140,12 @@ * IsoLookupFile() * This function searches the file system for the * specified filename and fills in an ISO_FILE_INFO structure - * with info describing the file, etc. returns true - * if the file exists or false otherwise + * with info describing the file, etc. returns ARC error code */ -static BOOLEAN IsoLookupFile(PCSTR FileName, PISO_FILE_INFO IsoFileInfoPointer) -{ +static LONG IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO IsoFileInfoPointer) +{ + UCHAR Buffer[SECTORSIZE]; + PPVD Pvd = (PPVD)Buffer; UINT32 i; ULONG NumberOfPathParts; CHAR PathPart[261]; @@ -179,19 +153,34 @@ ULONG DirectorySector; ULONG DirectoryLength; ISO_FILE_INFO IsoFileInfo; + LARGE_INTEGER Position; + ULONG Count; + LONG ret; DPRINTM(DPRINT_FILESYSTEM, "IsoLookupFile() FileName = %s\n", FileName); RtlZeroMemory(IsoFileInfoPointer, sizeof(ISO_FILE_INFO)); // + // Read The Primary Volume Descriptor + // + Position.HighPart = 0; + Position.LowPart = 16 * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + return ret; + ret = ArcRead(DeviceId, Pvd, SECTORSIZE, &Count); + if (ret != ESUCCESS || Count < sizeof(PVD)) + return EIO; + + DirectorySector = Pvd->RootDirRecord.ExtentLocationL; + DirectoryLength = Pvd->RootDirRecord.DataLengthL; + + // // Figure out how many sub-directories we are nested in // NumberOfPathParts = FsGetNumPathParts(FileName); - DirectorySector = IsoRootSector; - DirectoryLength = IsoRootLength; - // // Loop once for each part // @@ -213,11 +202,9 @@ // // Buffer the directory contents // - DirectoryBuffer = IsoBufferDirectory(DirectorySector, DirectoryLength); - if (DirectoryBuffer == NULL) - { - return FALSE; - } + ret = IsoBufferDirectory(DeviceId, DirectorySector, DirectoryLength, &DirectoryBuffer); + if (ret != ESUCCESS) + return ret; // // Search for file name in directory @@ -225,7 +212,7 @@ if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer, DirectoryLength, PathPart, &IsoFileInfo)) { MmHeapFree(DirectoryBuffer); - return FALSE; + return ENOENT; } MmHeapFree(DirectoryBuffer); @@ -244,78 +231,101 @@ RtlCopyMemory(IsoFileInfoPointer, &IsoFileInfo, sizeof(ISO_FILE_INFO)); - return TRUE; -} - - -/* - * IsoOpenFile() - * Tries to open the file 'name' and returns true or false - * for success and failure respectively - */ -FILE* IsoOpenFile(PCSTR FileName) -{ - ISO_FILE_INFO TempFileInfo; - PISO_FILE_INFO FileHandle; - - DPRINTM(DPRINT_FILESYSTEM, "IsoOpenFile() FileName = %s\n", FileName); - - if (!IsoLookupFile(FileName, &TempFileInfo)) - { - return NULL; - } + return ESUCCESS; +} + +LONG IsoClose(ULONG FileId) +{ + PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); + + MmHeapFree(FileHandle); + + return ESUCCESS; +} + +LONG IsoGetFileInformation(ULONG FileId, FILEINFORMATION* Information) +{ + PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); + + DPRINTM(DPRINT_FILESYSTEM, "IsoGetFileInformation() FileSize = %d\n", FileHandle->FileSize); + DPRINTM(DPRINT_FILESYSTEM, "IsoGetFileInformation() FilePointer = %d\n", FileHandle->FilePointer); + + RtlZeroMemory(Information, sizeof(FILEINFORMATION)); + Information->EndingAddress.LowPart = FileHandle->FileSize; + Information->CurrentAddress.LowPart = FileHandle->FilePointer; + + return ESUCCESS; +} + +LONG IsoOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) +{ + ISO_FILE_INFO TempFileInfo; + PISO_FILE_INFO FileHandle; + ULONG DeviceId; + LONG ret; + + if (OpenMode != OpenReadOnly) + return EACCES; + + DeviceId = FsGetDeviceId(*FileId); + + DPRINTM(DPRINT_FILESYSTEM, "IsoOpen() FileName = %s\n", Path); + + if (*Path == '\\') + Path++; + + RtlZeroMemory(&TempFileInfo, sizeof(TempFileInfo)); + ret = IsoLookupFile(Path, DeviceId, &TempFileInfo); + if (ret != ESUCCESS) + return ENOENT; FileHandle = MmHeapAlloc(sizeof(ISO_FILE_INFO)); - - if (FileHandle == NULL) - { - return NULL; - } + if (!FileHandle) + return ENOMEM; RtlCopyMemory(FileHandle, &TempFileInfo, sizeof(ISO_FILE_INFO)); - return (FILE*)FileHandle; -} - - -/* - * IsoReadFile() - * Reads BytesToRead from open file and - * returns the number of bytes read in BytesRead - */ -BOOLEAN IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer) -{ - PISO_FILE_INFO IsoFileInfo = (PISO_FILE_INFO)FileHandle; + FsSetDeviceSpecific(*FileId, FileHandle); + return ESUCCESS; +} + +LONG IsoRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) +{ + PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); + UCHAR SectorBuffer[SECTORSIZE]; + LARGE_INTEGER Position; + ULONG DeviceId; + ULONG FilePointer; ULONG SectorNumber; ULONG OffsetInSector; ULONG LengthInSector; ULONG NumberOfSectors; - ULONG i; - - DPRINTM(DPRINT_FILESYSTEM, "IsoReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer); - - if (BytesRead != NULL) - { - *BytesRead = 0; - } + ULONG BytesRead; + LONG ret; + + DPRINTM(DPRINT_FILESYSTEM, "IsoRead() Buffer = %p, N = %lu\n", Buffer, N); + + DeviceId = FsGetDeviceId(FileId); + *Count = 0; // // If they are trying to read past the // end of the file then return success - // with BytesRead == 0 - // - if (IsoFileInfo->FilePointer >= IsoFileInfo->FileSize) - { - return TRUE; + // with Count == 0 + // + FilePointer = FileHandle->FilePointer; + if (FilePointer >= FileHandle->FileSize) + { + return ESUCCESS; } // // If they are trying to read more than there is to read // then adjust the amount to read // - if ((IsoFileInfo->FilePointer + BytesToRead) > IsoFileInfo->FileSize) - { - BytesToRead = (IsoFileInfo->FileSize - IsoFileInfo->FilePointer); + if (FilePointer + N > FileHandle->FileSize) + { + N = FileHandle->FileSize - FilePointer; } // @@ -332,7 +342,7 @@ // | | // +---------------+--------------------+ // | - // BytesToRead -------+ + // N -----------------+ // // 1 - The first calculation (and read) will align // the file pointer with the next sector @@ -351,129 +361,154 @@ // Only do the first read if we // aren't aligned on a cluster boundary // - if (IsoFileInfo->FilePointer % SECTORSIZE) + if (FilePointer % SECTORSIZE) { // // Do the math for our first read // - SectorNumber = IsoFileInfo->FileStart + (IsoFileInfo->FilePointer / SECTORSIZE); - OffsetInSector = IsoFileInfo->FilePointer % SECTORSIZE; - LengthInSector = (BytesToRead > (SECTORSIZE - OffsetInSector)) ? (SECTORSIZE - OffsetInSector) : BytesToRead; - - // - // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer - // - if (!MachDiskReadLogicalSectors(IsoDriveNumber, SectorNumber, 1, (PVOID)DISKREADBUFFER)) - { - return FALSE; - } - RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)DISKREADBUFFER + OffsetInSector), LengthInSector); - if (BytesRead != NULL) - { - *BytesRead += LengthInSector; - } - BytesToRead -= LengthInSector; - IsoFileInfo->FilePointer += LengthInSector; + SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE); + OffsetInSector = FilePointer % SECTORSIZE; + LengthInSector = (N > (SECTORSIZE - OffsetInSector)) ? (SECTORSIZE - OffsetInSector) : N; + + // + // Now do the read and update Count, N, FilePointer, & Buffer + // + Position.HighPart = 0; + Position.LowPart = SectorNumber * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + { + return ret; + } + ret = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead); + if (ret != ESUCCESS || BytesRead != SECTORSIZE) + { + return EIO; + } + RtlCopyMemory(Buffer, SectorBuffer + OffsetInSector, LengthInSector); + *Count += LengthInSector; + N -= LengthInSector; + FilePointer += LengthInSector; Buffer = (PVOID)((ULONG_PTR)Buffer + LengthInSector); } // // Do the math for our second read (if any data left) // - if (BytesToRead > 0) + if (N > 0) { // // Determine how many full clusters we need to read // - NumberOfSectors = (BytesToRead / SECTORSIZE); - - for (i = 0; i < NumberOfSectors; i++) - { - SectorNumber = IsoFileInfo->FileStart + (IsoFileInfo->FilePointer / SECTORSIZE); - - // - // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer - // - if (!MachDiskReadLogicalSectors(IsoDriveNumber, SectorNumber, 1, (PVOID)DISKREADBUFFER)) - { - return FALSE; - } - - RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, SECTORSIZE); - - if (BytesRead != NULL) - { - *BytesRead += SECTORSIZE; - } - BytesToRead -= SECTORSIZE; - IsoFileInfo->FilePointer += SECTORSIZE; - Buffer = (PVOID)((ULONG_PTR)Buffer + SECTORSIZE); - } + NumberOfSectors = (N / SECTORSIZE); + + SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE); + + // + // Now do the read and update Count, N, FilePointer, & Buffer + // + Position.HighPart = 0; + Position.LowPart = SectorNumber * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + { + return ret; + } + ret = ArcRead(DeviceId, Buffer, NumberOfSectors * SECTORSIZE, &BytesRead); + if (ret != ESUCCESS || BytesRead != NumberOfSectors * SECTORSIZE) + { + return EIO; + } + + *Count += NumberOfSectors * SECTORSIZE; + N -= NumberOfSectors * SECTORSIZE; + FilePointer += NumberOfSectors * SECTORSIZE; + Buffer = (PVOID)((ULONG_PTR)Buffer + NumberOfSectors * SECTORSIZE); } // // Do the math for our third read (if any data left) // - if (BytesToRead > 0) - { - SectorNumber = IsoFileInfo->FileStart + (IsoFileInfo->FilePointer / SECTORSIZE); - - // - // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer - // - if (!MachDiskReadLogicalSectors(IsoDriveNumber, SectorNumber, 1, (PVOID)DISKREADBUFFER)) - { - return FALSE; - } - RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, BytesToRead); - if (BytesRead != NULL) - { - *BytesRead += BytesToRead; - } - IsoFileInfo->FilePointer += BytesToRead; - BytesToRead -= BytesToRead; - Buffer = (PVOID)((ULONG_PTR)Buffer + BytesToRead); - } - - DPRINTM(DPRINT_FILESYSTEM, "IsoReadFile() done\n"); - - return TRUE; -} - - -ULONG IsoGetFileSize(FILE *FileHandle) -{ - PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle; - - DPRINTM(DPRINT_FILESYSTEM, "IsoGetFileSize() FileSize = %d\n", IsoFileHandle->FileSize); - - return IsoFileHandle->FileSize; -} - -VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer) -{ - PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle; - - DPRINTM(DPRINT_FILESYSTEM, "IsoSetFilePointer() NewFilePointer = %d\n", NewFilePointer); - - IsoFileHandle->FilePointer = NewFilePointer; -} - -ULONG IsoGetFilePointer(FILE *FileHandle) -{ - PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle; - - DPRINTM(DPRINT_FILESYSTEM, "IsoGetFilePointer() FilePointer = %d\n", IsoFileHandle->FilePointer); - - return IsoFileHandle->FilePointer; -} - -const FS_VTBL Iso9660Vtbl = { - IsoOpenVolume, - IsoOpenFile, - NULL, - IsoReadFile, - IsoGetFileSize, - IsoSetFilePointer, - IsoGetFilePointer, + if (N > 0) + { + SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE); + + // + // Now do the read and update Count, N, FilePointer, & Buffer + // + Position.HighPart = 0; + Position.LowPart = SectorNumber * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + { + return ret; + } + ret = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead); + if (ret != ESUCCESS || BytesRead != SECTORSIZE) + { + return EIO; + } + RtlCopyMemory(Buffer, SectorBuffer, N); + *Count += N; + FilePointer += N; + } + + DPRINTM(DPRINT_FILESYSTEM, "IsoRead() done\n"); + + return ESUCCESS; +} + +LONG IsoSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) +{ + PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); + + DPRINTM(DPRINT_FILESYSTEM, "IsoSeek() NewFilePointer = %lu\n", Position->LowPart); + + if (SeekMode != SeekAbsolute) + return EINVAL; + if (Position->HighPart != 0) + return EINVAL; + if (Position->LowPart >= FileHandle->FileSize) + return EINVAL; + + FileHandle->FilePointer = Position->LowPart; + return ESUCCESS; +} + +const DEVVTBL Iso9660FuncTable = +{ + IsoClose, + IsoGetFileInformation, + IsoOpen, + IsoRead, + IsoSeek, }; + +const DEVVTBL* IsoMount(ULONG DeviceId) +{ + UCHAR Buffer[SECTORSIZE]; + PPVD Pvd = (PPVD)Buffer; + LARGE_INTEGER Position; + ULONG Count; + LONG ret; + + // + // Read The Primary Volume Descriptor + // + Position.HighPart = 0; + Position.LowPart = 16 * SECTORSIZE; + ret = ArcSeek(DeviceId, &Position, SeekAbsolute); + if (ret != ESUCCESS) + return NULL; + ret = ArcRead(DeviceId, Pvd, SECTORSIZE, &Count); + if (ret != ESUCCESS || Count < sizeof(PVD)) + return NULL; + + // + // Check if PVD is valid. If yes, return ISO9660 function table + // + if (Pvd->VdType == 1 && RtlCompareMemory(Pvd->StandardId, "CD001", 5) == 5) + return &Iso9660FuncTable; + else + return NULL; +} Modified: trunk/reactos/boot/freeldr/freeldr/include/fs/iso.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/fs/iso.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/fs/iso.h [iso-8859-1] Sat Aug 8 19:13:14 2009 @@ -99,14 +99,8 @@ ULONG DriveNumber; } ISO_FILE_INFO, * PISO_FILE_INFO; - -BOOLEAN IsoOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG PartitionSectorCount); -FILE* IsoOpenFile(PCSTR FileName); -BOOLEAN IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer); -ULONG IsoGetFileSize(FILE *FileHandle); -VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer); -ULONG IsoGetFilePointer(FILE *FileHandle); - extern const FS_VTBL Iso9660Vtbl; +const DEVVTBL* IsoMount(ULONG DeviceId); + #endif // #defined __FAT_H
15 years, 1 month
1
0
0
0
[hpoussin] 42527: Read freeldr.ini file using ARC file infrastructure
by hpoussin@svn.reactos.org
Author: hpoussin Date: Sat Aug 8 19:08:51 2009 New Revision: 42527 URL:
http://svn.reactos.org/svn/reactos?rev=42527&view=rev
Log: Read freeldr.ini file using ARC file infrastructure Modified: trunk/reactos/boot/freeldr/freeldr/include/inifile.h trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c Modified: trunk/reactos/boot/freeldr/freeldr/include/inifile.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/inifile.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/inifile.h [iso-8859-1] Sat Aug 8 19:08:51 2009 @@ -54,8 +54,6 @@ extern ULONG IniFileSectionCount; extern ULONG IniFileSettingCount; -PFILE IniOpenIniFile(); - BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize); ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset); ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset); Modified: trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inifi…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c [iso-8859-1] Sat Aug 8 19:08:51 2009 @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> + * Copyright (C) 2009 Hervé Poussineau <hpoussin(a)reactos.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,58 +19,86 @@ #include <freeldr.h> +static LONG IniOpenIniFile(ULONG* FileId) +{ + CHAR FreeldrPath[MAX_PATH]; + LONG ret; + + // + // Create full freeldr.ini path + // + MachDiskGetBootPath(FreeldrPath, sizeof(FreeldrPath)); + strcat(FreeldrPath, "\\freeldr.ini"); + + // Try to open freeldr.ini + ret = ArcOpen(FreeldrPath, OpenReadOnly, FileId); + + return ret; +} + BOOLEAN IniFileInitialize(VOID) { - PFILE Freeldr_Ini; // File handle for freeldr.ini - PCHAR FreeLoaderIniFileData; - ULONG FreeLoaderIniFileSize; - BOOLEAN Success; + FILEINFORMATION FileInformation; + ULONG FileId; // File handle for freeldr.ini + PCHAR FreeLoaderIniFileData; + ULONG FreeLoaderIniFileSize, Count; + LONG ret; + BOOLEAN Success; + // // Open freeldr.ini - Freeldr_Ini = IniOpenIniFile(); - - if (Freeldr_Ini == NULL) + // + ret = IniOpenIniFile(&FileId); + if (ret != ESUCCESS) { UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader."); return FALSE; } - // Get the file size & allocate enough memory for it - FreeLoaderIniFileSize = FsGetFileSize(Freeldr_Ini); + // + // Get the file size + // + ret = ArcGetFileInformation(FileId, &FileInformation); + if (ret != ESUCCESS || FileInformation.EndingAddress.HighPart != 0) + { + UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou need to re-install FreeLoader."); + return FALSE; + } + FreeLoaderIniFileSize = FileInformation.EndingAddress.LowPart; + + // + // Allocate memory to cache the whole freeldr.ini + // FreeLoaderIniFileData = MmHeapAlloc(FreeLoaderIniFileSize); - - // If we are out of memory then return FALSE - if (FreeLoaderIniFileData == NULL) + if (!FreeLoaderIniFileData) { UiMessageBoxCritical("Out of memory while loading freeldr.ini."); - FsCloseFile(Freeldr_Ini); + ArcClose(FileId); return FALSE; } + // // Read freeldr.ini off the disk - if (!FsReadFile(Freeldr_Ini, FreeLoaderIniFileSize, NULL, FreeLoaderIniFileData)) + // + ret = ArcRead(FileId, FreeLoaderIniFileData, FreeLoaderIniFileSize, &Count); + if (ret != ESUCCESS || Count != FreeLoaderIniFileSize) { - FsCloseFile(Freeldr_Ini); + UiMessageBoxCritical("Error while reading freeldr.ini."); + ArcClose(FileId); MmHeapFree(FreeLoaderIniFileData); return FALSE; } - FsCloseFile(Freeldr_Ini); - + // // Parse the .ini file data + // Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize); + // + // Do some cleanup, and return + // + ArcClose(FileId); MmHeapFree(FreeLoaderIniFileData); return Success; } - -PFILE IniOpenIniFile() -{ - PFILE IniFileHandle; // File handle for freeldr.ini - - // Try to open freeldr.ini - IniFileHandle = FsOpenFile("freeldr.ini"); - - return IniFileHandle; -}
15 years, 1 month
1
0
0
0
[hpoussin] 42526: Improve ARC file infrastructure, by adding a compatibility layer from old to new system (new to old already exists) i386: when reading sectors, use dedicated scratch area Increase number of available open files to 60, because something seems to leak file descriptors
by hpoussin@svn.reactos.org
Author: hpoussin Date: Sat Aug 8 19:04:53 2009 New Revision: 42526 URL:
http://svn.reactos.org/svn/reactos?rev=42526&view=rev
Log: Improve ARC file infrastructure, by adding a compatibility layer from old to new system (new to old already exists) i386: when reading sectors, use dedicated scratch area Increase number of available open files to 60, because something seems to leak file descriptors Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c trunk/reactos/boot/freeldr/freeldr/bootmgr.c trunk/reactos/boot/freeldr/freeldr/fs/fs.c trunk/reactos/boot/freeldr/freeldr/include/fs.h Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Sat Aug 8 19:04:53 2009 @@ -449,19 +449,26 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) { DISKCONTEXT* Context = FsGetDeviceSpecific(FileId); + UCHAR* Ptr = (UCHAR*)Buffer; + ULONG i; BOOLEAN ret; *Count = 0; if (N & (Context->SectorSize - 1)) return EINVAL; - ret = MachDiskReadLogicalSectors( - Context->DriveNumber, - Context->SectorNumber + Context->SectorOffset, - N / Context->SectorSize, - Buffer); - if (!ret) - return EIO; + for (i = 0; i < N / Context->SectorSize; i++) + { + ret = MachDiskReadLogicalSectors( + Context->DriveNumber, + Context->SectorNumber + Context->SectorOffset + i, + 1, + (PVOID)DISKREADBUFFER); + if (!ret) + return EIO; + RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Context->SectorSize); + Ptr += Context->SectorSize; + } *Count = N; return ESUCCESS; Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootm…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] Sat Aug 8 19:04:53 2009 @@ -37,6 +37,13 @@ return; } + // FIXME: if possible, only detect and register ARC devices... + if (!MachHwDetect()) + { + UiMessageBoxCritical("Error when detecting hardware"); + return; + } + if (!IniFileInitialize()) { UiMessageBoxCritical("Error initializing .ini file"); Modified: trunk/reactos/boot/freeldr/freeldr/fs/fs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/fs…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/fs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/fs.c [iso-8859-1] Sat Aug 8 19:04:53 2009 @@ -1,6 +1,7 @@ /* * FreeLoader * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> + * Copyright (C) 2008-2009 Hervé Poussineau <hpoussin(a)reactos.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +34,134 @@ // FUNCTIONS ///////////////////////////////////////////////////////////////////////////////////////////// +static BOOLEAN CompatArcOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG PartitionSectorCount) +{ + // + // Always return success + // + return TRUE; +} + +static FILE* CompatArcOpenFile(PCSTR FileName) +{ + CHAR FullPath[MAX_PATH]; + ULONG FileId; + LONG ret; + + // + // Create full file name + // + MachDiskGetBootPath(FullPath, sizeof(FullPath)); + strcat(FullPath, FileName); + + // + // Open the file + // + ret = ArcOpen(FullPath, OpenReadOnly, &FileId); + + // + // Check for success + // + if (ret == ESUCCESS) + return (FILE*)FileId; + else + return NULL; +} + +static BOOLEAN CompatArcReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer) +{ + ULONG FileId = (ULONG)FileHandle; + LONG ret; + + // + // Read the file + // + ret = ArcRead(FileId, Buffer, BytesToRead, BytesRead); + + // + // Check for success + // + if (ret == ESUCCESS) + return TRUE; + else + return FALSE; +} + +ULONG CompatArcGetFileSize(FILE *FileHandle) +{ + ULONG FileId = (ULONG)FileHandle; + FILEINFORMATION Information; + LONG ret; + + // + // Query file informations + // + ret = ArcGetFileInformation(FileId, &Information); + + // + // Check for error + // + if (ret != ESUCCESS || Information.EndingAddress.HighPart != 0) + return 0; + + // + // Return file size + // + return Information.EndingAddress.LowPart; +} + +VOID CompatArcSetFilePointer(FILE *FileHandle, ULONG NewFilePointer) +{ + ULONG FileId = (ULONG)FileHandle; + LARGE_INTEGER Position; + + // + // Set file position + // + Position.HighPart = 0; + Position.LowPart = NewFilePointer; + ArcSeek(FileId, &Position, SeekAbsolute); + + // + // Do not check for error; this function is + // supposed to always succeed + // +} + +ULONG CompatArcGetFilePointer(FILE *FileHandle) +{ + ULONG FileId = (ULONG)FileHandle; + FILEINFORMATION Information; + LONG ret; + + // + // Query file informations + // + ret = ArcGetFileInformation(FileId, &Information); + + // + // Check for error + // + if (ret != ESUCCESS || Information.CurrentAddress.HighPart != 0) + return 0; + + // + // Return file pointer position + // + return Information.CurrentAddress.LowPart; +} + +static const FS_VTBL CompatArcVtbl = +{ + CompatArcOpenVolume, + CompatArcOpenFile, + NULL, + CompatArcReadFile, + CompatArcGetFileSize, + CompatArcSetFilePointer, + CompatArcGetFilePointer, +}; + VOID FileSystemError(PCSTR ErrorString) { DPRINTM(DPRINT_FILESYSTEM, "%s\n", ErrorString); @@ -385,7 +514,7 @@ CompatFsSeek, }; -#define MAX_FDS 20 +#define MAX_FDS 60 typedef struct tagFILEDATA { ULONG DeviceId; @@ -420,6 +549,7 @@ { FileData[FileId].FuncTable = NULL; FileData[FileId].Specific = NULL; + FileData[FileId].DeviceId = -1; } return ret; } @@ -443,6 +573,9 @@ ULONG dwCount, dwLength; OPENMODE DeviceOpenMode; ULONG DeviceId; + + /* Print status message */ + DPRINTM(DPRINT_FILESYSTEM, "Opening file '%s'...\n", Path); *FileId = MAX_FDS; @@ -535,6 +668,7 @@ /* Open the file */ FileData[i].FuncTable = FileData[DeviceId].FileFuncTable; + FileData[i].DeviceId = DeviceId; *FileId = i; ret = FileData[i].FuncTable->Open(FileName, OpenMode, FileId); if (ret != ESUCCESS) @@ -590,8 +724,20 @@ return FileData[FileId].Specific; } +ULONG FsGetDeviceId(ULONG FileId) +{ + if (FileId >= MAX_FDS) + return (ULONG)-1; + return FileData[FileId].DeviceId; +} + VOID FsInit(VOID) { - memset(FileData, 0, sizeof(FileData)); + ULONG i; + + RtlZeroMemory(FileData, sizeof(FileData)); + for (i = 0; i < MAX_FDS; i++) + FileData[i].DeviceId = (ULONG)-1; + InitializeListHead(&DeviceListHead); } Modified: trunk/reactos/boot/freeldr/freeldr/include/fs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/fs.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/fs.h [iso-8859-1] Sat Aug 8 19:04:53 2009 @@ -29,14 +29,10 @@ ARC_SEEK Seek; } DEVVTBL; -//#define EOF -1 - #define FS_FAT 1 #define FS_NTFS 2 #define FS_EXT2 3 -#define FS_REISER 4 #define FS_ISO9660 5 -#define FS_PXE 6 #define FILE VOID #define PFILE FILE * @@ -44,6 +40,7 @@ VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable); VOID FsSetDeviceSpecific(ULONG FileId, VOID* Specific); VOID* FsGetDeviceSpecific(ULONG FileId); +ULONG FsGetDeviceId(ULONG FileId); VOID FsInit(VOID); LONG ArcClose(ULONG FileId);
15 years, 1 month
1
0
0
0
← Newer
1
...
42
43
44
45
46
47
48
...
66
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Results per page:
10
25
50
100
200