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
December
November
October
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
September 2011
----- 2024 -----
December 2024
November 2024
October 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
20 participants
399 discussions
Start a n
N
ew thread
[pschweitzer] 53770: [OBJ2BIN] - Fix memory leaks - Fix resources leaks - Fix wrong if statement
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Sep 20 12:29:47 2011 New Revision: 53770 URL:
http://svn.reactos.org/svn/reactos?rev=53770&view=rev
Log: [OBJ2BIN] - Fix memory leaks - Fix resources leaks - Fix wrong if statement Modified: trunk/reactos/tools/obj2bin/obj2bin.c Modified: trunk/reactos/tools/obj2bin/obj2bin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/obj2bin/obj2bin.c?re…
============================================================================== --- trunk/reactos/tools/obj2bin/obj2bin.c [iso-8859-1] (original) +++ trunk/reactos/tools/obj2bin/obj2bin.c [iso-8859-1] Tue Sep 20 12:29:47 2011 @@ -97,6 +97,7 @@ pData = malloc(nFileSize); if (!pData) { + fclose(pSourceFile); fprintf(stderr, "Failed to allocate %ld bytes\n", nFileSize); return -3; } @@ -104,6 +105,8 @@ /* Read the whole source file */ if (!fread(pData, nFileSize, 1, pSourceFile)) { + free(pData); + fclose(pSourceFile); fprintf(stderr, "Failed to read source file: %ld\n", nFileSize); return -4; } @@ -113,8 +116,9 @@ /* Open the destination file */ pDestFile = fopen(pszDestFile, "wb"); - if (!pszDestFile) + if (!pDestFile) { + free(pData); fprintf(stderr, "Couldn't open dest file '%s'\n", pszDestFile); return -5; } @@ -140,6 +144,8 @@ if (!fwrite(pData + pSectionHeader->PointerToRawData, pSectionHeader->SizeOfRawData, 1, pDestFile)) { + free(pData); + fclose(pDestFile); fprintf(stderr, "Failed to write data %ld\n", pSectionHeader->SizeOfRawData); return -6; @@ -151,6 +157,7 @@ pSectionHeader++; } + free(pData); fclose(pDestFile); return 0;
13 years, 3 months
1
0
0
0
[pschweitzer] 53769: [MKHIVE] Fix memory leak
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Sep 20 12:28:23 2011 New Revision: 53769 URL:
http://svn.reactos.org/svn/reactos?rev=53769&view=rev
Log: [MKHIVE] Fix memory leak Modified: trunk/reactos/tools/mkhive/registry.c Modified: trunk/reactos/tools/mkhive/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/registry.c?re…
============================================================================== --- trunk/reactos/tools/mkhive/registry.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/registry.c [iso-8859-1] Tue Sep 20 12:28:23 2011 @@ -84,6 +84,7 @@ Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset); if (!Key->KeyCell) { + free(Key->Name); free(Key); return NULL; }
13 years, 3 months
1
0
0
0
[pschweitzer] 53768: [LOG2LINES] Fix memory leak
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Sep 20 12:27:50 2011 New Revision: 53768 URL:
http://svn.reactos.org/svn/reactos?rev=53768&view=rev
Log: [LOG2LINES] Fix memory leak Modified: trunk/reactos/tools/log2lines/cache.c Modified: trunk/reactos/tools/log2lines/cache.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/cache.c?re…
============================================================================== --- trunk/reactos/tools/log2lines/cache.c [iso-8859-1] (original) +++ trunk/reactos/tools/log2lines/cache.c [iso-8859-1] Tue Sep 20 12:27:50 2011 @@ -243,6 +243,7 @@ l2l_dbg(0, "Cannot list directory %s\n", opt_dir); l2l_dbg(1, "Failed to execute: '%s'\n", Line); remove(tmp_name); + free(Line); return 2; } l2l_dbg(0, "Creating cache ...");
13 years, 3 months
1
0
0
0
[pschweitzer] 53767: [GENINC] Fix resources leak
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Sep 20 12:24:57 2011 New Revision: 53767 URL:
http://svn.reactos.org/svn/reactos?rev=53767&view=rev
Log: [GENINC] Fix resources leak Modified: trunk/reactos/tools/geninc/geninc.c Modified: trunk/reactos/tools/geninc/geninc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/geninc/geninc.c?rev=…
============================================================================== --- trunk/reactos/tools/geninc/geninc.c [iso-8859-1] (original) +++ trunk/reactos/tools/geninc/geninc.c [iso-8859-1] Tue Sep 20 12:24:57 2011 @@ -65,6 +65,7 @@ output = fopen(argv[2], "w"); if (!output) { + fclose(input); fprintf(stderr, "Could not open output file '%s'\n", argv[2]); return -1; }
13 years, 3 months
1
0
0
0
[pschweitzer] 53766: [PEFIXUP] Fix resources leak
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Sep 20 12:10:28 2011 New Revision: 53766 URL:
http://svn.reactos.org/svn/reactos?rev=53766&view=rev
Log: [PEFIXUP] Fix resources leak Modified: trunk/reactos/tools/pefixup.c Modified: trunk/reactos/tools/pefixup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/pefixup.c?rev=53766&…
============================================================================== --- trunk/reactos/tools/pefixup.c [iso-8859-1] (original) +++ trunk/reactos/tools/pefixup.c [iso-8859-1] Tue Sep 20 12:10:28 2011 @@ -282,7 +282,10 @@ */ len = read(fd_in, hdrbuf, sizeof(elfhdr)); if (!memcmp(hdrbuf, elfhdr, sizeof(elfhdr))) + { + close(fd_in); return 0; + } len = lseek(fd_in, 0, SEEK_END); if (len < sizeof(IMAGE_DOS_HEADER))
13 years, 3 months
1
0
0
0
[dgorbachev] 53765: [FREELDR] Fix loading with GRUB (CMake builds).
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Tue Sep 20 08:50:38 2011 New Revision: 53765 URL:
http://svn.reactos.org/svn/reactos?rev=53765&view=rev
Log: [FREELDR] Fix loading with GRUB (CMake builds). Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S trunk/reactos/boot/freeldr/freeldr/arch/i386/multiboot.S Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMake…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Tue Sep 20 08:50:38 2011 @@ -117,8 +117,7 @@ disk/scsiport.c) if(NOT MSVC) list(APPEND FREELDR_COMMON_SOURCE - arch/i386/drvmap.S - arch/i386/multiboot.S) + arch/i386/drvmap.S) endif() elseif(ARCH MATCHES amd64) list(APPEND FREELDR_COMMON_SOURCE @@ -148,6 +147,9 @@ add_library(freeldr_common ${FREELDR_COMMON_SOURCE}) add_dependencies(freeldr_common bugcodes) +if(ARCH MATCHES i386 AND NOT MSVC) + list(APPEND FREELDR_BASE_SOURCE arch/i386/multiboot.S) +endif() list(APPEND FREELDR_BASE_SOURCE bootmgr.c # This file is compiled with custom definitions @@ -159,7 +161,7 @@ add_executable(freeldr_pe ${FREELDR_BASE_SOURCE}) if(NOT MSVC) - set_target_properties(freeldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk") + set_target_properties(freeldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk") else() set_target_properties(freeldr_pe PROPERTIES LINK_FLAGS "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION") endif() @@ -208,7 +210,7 @@ add_executable(setupldr_pe ${FREELDR_BASE_SOURCE} ${SETUPLDR_SOURCE}) if(NOT MSVC) - set_target_properties(setupldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP") + set_target_properties(setupldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP") else() set_target_properties(setupldr_pe PROPERTIES LINK_FLAGS "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP") endif() Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S [iso-8859-1] Tue Sep 20 08:50:38 2011 @@ -70,8 +70,14 @@ /* Initialize the idt */ call _InitIdt + /* Pass the command line to BootMain */ +#ifdef _USE_ML + xor eax, eax +#else + mov eax, offset cmdline +#endif + /* GO! */ - xor eax, eax push eax call _BootMain Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/multiboot.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/multiboot.S [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/multiboot.S [iso-8859-1] Tue Sep 20 08:50:38 2011 @@ -21,195 +21,138 @@ #include <arch/pc/x86common.h> #include <multiboot.h> - /* Multiboot support * * Allows freeldr to be loaded as a "multiboot kernel" by - * other boot loaders like Grub + * other boot loaders like GRUB. * This code is not referenced from anywhere. GRUB searches for * the header signature and uses the header to load it. */ -#define MB_INFO_SIZE 90 #define MB_INFO_FLAGS_OFFSET 0 #define MB_INFO_BOOT_DEVICE_OFFSET 12 #define MB_INFO_COMMAND_LINE_OFFSET 16 #define CMDLINE_SIZE 256 /* - * We want to execute at 0x8000 (to be compatible with bootsector - * loading), but Grub only allows loading of multiboot kernels - * above 1MB. So we let Grub load us there and then relocate - * ourself to 0x8000 + * We want to execute at FREELDR_BASE (to be compatible with + * bootsector loading), but GRUB only allows loading of + * multiboot kernels above 1MB. So we let GRUB load us + * there and then relocate ourself to FREELDR_BASE. */ #define INITIAL_BASE HEX(200000) - /* Align 32 bits boundary */ -.align 4 + /* Align to 32 bits boundary */ + .align 4 - /* Multiboot header */ + /* Multiboot header */ MultibootHeader: - /* magic */ - .long MULTIBOOT_HEADER_MAGIC - /* flags */ - .long MULTIBOOT_HEADER_FLAGS - /* checksum */ - .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) - /* header_addr */ - .long INITIAL_BASE + MultibootHeader - FREELDR_BASE - /* load_addr */ - .long INITIAL_BASE - /* load_end_addr */ - .long INITIAL_BASE + __bss_start__ - FREELDR_BASE - /* bss_end_addr */ - .long INITIAL_BASE + __bss_end__ - FREELDR_BASE - /* entry_addr */ - .long INITIAL_BASE + MultibootEntry - FREELDR_BASE + /* magic */ + .long MULTIBOOT_HEADER_MAGIC + /* flags */ + .long MULTIBOOT_HEADER_FLAGS + /* checksum */ + .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + /* header_addr */ + .long INITIAL_BASE + MultibootHeader - FREELDR_BASE + /* load_addr */ + .long INITIAL_BASE + /* load_end_addr */ + .long INITIAL_BASE + __bss_start__ - FREELDR_BASE + /* bss_end_addr */ + .long 0 + /* entry_addr */ + .long INITIAL_BASE + MultibootEntry - FREELDR_BASE MultibootEntry: - cli /* Even after setting up the our IDT below we are - * not ready to handle hardware interrupts (no entries - * in IDT), so there's no sti here. Interrupts will be - * enabled in due time */ + cld - /* Although the multiboot spec says we should be called with the - * segment registers set to 4GB flat mode, let's be sure and set up - * our own */ - lgdt gdtptrhigh + INITIAL_BASE - FREELDR_BASE - /* Reload segment selectors */ - //ljmp $PMODE_CS, $(mb1 + INITIAL_BASE - FREELDR_BASE) - jmp far ptr PMODE_CS: (mb1 + INITIAL_BASE - FREELDR_BASE) + /* Save command line */ + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE + jz mb2 + mov esi, [ebx + MB_INFO_COMMAND_LINE_OFFSET] + mov edi, offset cmdline + INITIAL_BASE - FREELDR_BASE + mov ecx, CMDLINE_SIZE - 1 mb1: - mov dx, PMODE_DS - mov ds, dx - mov es, dx + lodsb + stosb + test al, al + jz mb2 + dec ecx + jnz mb1 - /* Check for valid multiboot signature */ - cmp eax, MULTIBOOT_BOOTLOADER_MAGIC - jne mbfail +mb2: + /* See if the boot device was passed in */ + test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_BOOT_DEVICE - /* Store multiboot info in a safe place */ - mov esi, ebx - mov edi, offset mb_info + INITIAL_BASE - FREELDR_BASE - mov ecx, MB_INFO_SIZE - rep movsb + /* If no boot device known, assume first partition of first harddisk */ + mov dx, HEX(0180) + jz mb3 - /* Save commandline */ - mov edx, [ebx + MB_INFO_FLAGS_OFFSET] - test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE - jz mb3 - mov esi, [ebx + MB_INFO_COMMAND_LINE_OFFSET] - mov edi, offset cmdline + INITIAL_BASE - FREELDR_BASE - mov ecx, CMDLINE_SIZE -mb2: lodsb - stosb - test al, al - jz mb3 - dec ecx - jnz mb2 + /* Load boot drive into DL, boot partition into DH */ + mov edx, [ebx + MB_INFO_BOOT_DEVICE_OFFSET] + bswap edx + inc dh + mb3: + /* Relocate itself to lower address */ + mov esi, INITIAL_BASE + mov edi, FREELDR_BASE + mov ecx, (offset __bss_start__ - FREELDR_BASE + 3) + shr ecx, 2 + rep movsd - /* Copy to low mem */ - mov esi, INITIAL_BASE - mov edi, FREELDR_BASE - mov ecx, (offset __bss_end__ - FREELDR_BASE) - add ecx, 3 - shr ecx, 2 - rep movsd + /* Clean out bss */ + xor eax, eax + mov ecx, offset __bss_end__ + 3 + sub ecx, offset __bss_start__ + shr ecx, 2 + rep stosd - /* Load the GDT and IDT */ - lgdt gdtptr - lidt i386idtptr + /* Load segment registers for real-address mode */ + lgdt gdtptr + mov ax, HEX(10) + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax - /* Clear prefetch queue & correct CS, - * jump to low mem */ - //ljmp $PMODE_CS, $mb4 - jmp far ptr PMODE_CS:mb4 + /* Jump to relocated code */ + ljmp HEX(08), mb4 + +.code16 mb4: - /* Reload segment selectors */ - mov dx, PMODE_DS - mov ds, dx - mov es, dx - mov fs, dx - mov gs, dx - mov ss, dx - mov esp, STACK32ADDR + /* Disable protected mode */ + mov eax, cr0 + and eax, CR0_PE_CLR + mov cr0, eax - mov ebx, offset mb_info - /* See if the boot device was passed in */ - mov edx, [ebx + MB_INFO_FLAGS_OFFSET] - test edx, MB_INFO_FLAG_BOOT_DEVICE - jz mb5 - /* Retrieve boot device info */ - mov eax, [ebx + MB_INFO_BOOT_DEVICE_OFFSET] - shr eax, 16 - inc al - mov byte ptr [_FrldrBootPartition], al - mov byte ptr [_FrldrBootDrive], ah - jmp mb6 -mb5: /* No boot device known, assume first partition of first harddisk */ - mov byte ptr [_FrldrBootDrive], HEX(80) - mov byte ptr [_FrldrBootPartition], 1 -mb6: - /* Check for command line */ - mov eax, offset cmdline - test dword ptr [ebx + MB_INFO_FLAGS_OFFSET], MB_INFO_FLAG_COMMAND_LINE - jnz mb7 - xor eax, eax -mb7: + /* Jump to real entry point */ + ljmp16 0, FREELDR_BASE - /* GO! */ - push eax - call _BootMain + /* Force 8-byte alignment */ + .align 8 +gdt: + /* 16-bit flat CS (!) */ + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9B00) + .word HEX(008F) -mbfail: - int 3 -mbstop: jmp mbstop /* We should never get here */ + /* 16-bit real mode DS */ + .word HEX(FFFF) + .word HEX(0000) + .word HEX(9300) + .word HEX(0000) -mb_info: - .fill MB_INFO_SIZE, 1, 0 + /* GDT pointer */ +gdtptr: + .word HEX(17) /* Limit */ + .long gdt - 8 /* Base Address */ +PUBLIC cmdline cmdline: - .fill CMDLINE_SIZE, 1, 0 + .space CMDLINE_SIZE -.align 4 /* force 4-byte alignment */ -gdt: - /* NULL Descriptor */ - .word HEX(0000) - .word HEX(0000) - .word HEX(0000) - .word HEX(0000) - - /* 32-bit flat CS */ - .word HEX(FFFF) - .word HEX(0000) - .word HEX(9A00) - .word HEX(00CF) - - /* 32-bit flat DS */ - .word HEX(FFFF) - .word HEX(0000) - .word HEX(9200) - .word HEX(00CF) - - /* 16-bit real mode CS */ - .word HEX(FFFF) - .word HEX(0000) - .word HEX(9E00) - .word HEX(0000) - - /* 16-bit real mode DS */ - .word HEX(FFFF) - .word HEX(0000) - .word HEX(9200) - .word HEX(0000) - -/* GDT table pointer */ -gdtptr: - .word HEX(27) /* Limit */ - .long gdt /* Base Address */ - -/* Initial GDT table pointer for multiboot */ -gdtptrhigh: - .word HEX(27) /* Limit */ - .long gdt + INITIAL_BASE - FREELDR_BASE /* Base Address */ +END
13 years, 3 months
1
0
0
0
[tkreuzer] 53764: [RTL] - Fix a number of MSVC/64 bit warnings/problems - Fix return type of RtlpInitializeHeapSegment (by Roel)
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Sep 19 19:31:21 2011 New Revision: 53764 URL:
http://svn.reactos.org/svn/reactos?rev=53764&view=rev
Log: [RTL] - Fix a number of MSVC/64 bit warnings/problems - Fix return type of RtlpInitializeHeapSegment (by Roel) Modified: trunk/reactos/lib/rtl/critical.c trunk/reactos/lib/rtl/heap.c trunk/reactos/lib/rtl/heap.h trunk/reactos/lib/rtl/heappage.c trunk/reactos/lib/rtl/registry.c trunk/reactos/lib/rtl/rtlp.h trunk/reactos/lib/rtl/srw.c trunk/reactos/lib/rtl/timerqueue.c trunk/reactos/lib/rtl/timezone.c Modified: trunk/reactos/lib/rtl/critical.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/critical.c?rev=537…
============================================================================== --- trunk/reactos/lib/rtl/critical.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/critical.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -299,7 +299,7 @@ NTAPI RtlpFreeDebugInfo(PRTL_CRITICAL_SECTION_DEBUG DebugInfo) { - ULONG EntryId; + SIZE_T EntryId; /* Is it part of our cached entries? */ if ((DebugInfo >= RtlpStaticDebugInfo) && @@ -310,7 +310,7 @@ /* Mark as free */ EntryId = (DebugInfo - RtlpStaticDebugInfo); - DPRINT("Freeing from Buffer: %p. Entry: %lu inside Process: %p\n", + DPRINT("Freeing from Buffer: %p. Entry: %Iu inside Process: %p\n", DebugInfo, EntryId, NtCurrentTeb()->ClientId.UniqueProcess); Modified: trunk/reactos/lib/rtl/heap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=53764&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -126,7 +126,7 @@ ASSERT(HeaderSize <= PAGE_SIZE); /* Initialise the Heap Entry header containing the Heap header */ - Heap->Entry.Size = HeaderSize >> HEAP_ENTRY_SHIFT; + Heap->Entry.Size = (USHORT)(HeaderSize >> HEAP_ENTRY_SHIFT); Heap->Entry.Flags = HEAP_ENTRY_BUSY; Heap->Entry.SmallTagIndex = LOBYTE(Heap->Entry.Size) ^ HIBYTE(Heap->Entry.Size) ^ Heap->Entry.Flags; Heap->Entry.PreviousSize = 0; @@ -157,7 +157,7 @@ /* Initialise the Heap validation info */ Heap->HeaderValidateCopy = NULL; - Heap->HeaderValidateLength = HeaderSize; + Heap->HeaderValidateLength = (USHORT)HeaderSize; /* Initialise the Heap Lock */ if (!(Flags & HEAP_NO_SERIALIZE) && !(Flags & HEAP_LOCK_USER_ALLOCATED)) @@ -656,7 +656,7 @@ } /* Update tracking numbers */ - Segment->NumberOfUnCommittedPages -= *Size / PAGE_SIZE; + Segment->NumberOfUnCommittedPages -= (ULONG)(*Size / PAGE_SIZE); /* Calculate first and last entries */ FirstEntry = (PHEAP_ENTRY)Address; @@ -738,7 +738,7 @@ PHEAP_ENTRY PrecedingInUseEntry = NULL, NextInUseEntry = NULL; PHEAP_FREE_ENTRY NextFreeEntry; PHEAP_UCR_DESCRIPTOR UcrDescriptor; - ULONG PrecedingSize, NextSize, DecommitSize; + SIZE_T PrecedingSize, NextSize, DecommitSize; ULONG_PTR DecommitBase; NTSTATUS Status; @@ -828,7 +828,7 @@ /* Insert uncommitted pages */ RtlpInsertUnCommittedPages(Segment, DecommitBase, DecommitSize); - Segment->NumberOfUnCommittedPages += (DecommitSize / PAGE_SIZE); + Segment->NumberOfUnCommittedPages += (ULONG)(DecommitSize / PAGE_SIZE); if (PrecedingSize) { @@ -866,7 +866,8 @@ } } -BOOLEAN NTAPI +NTSTATUS +NTAPI RtlpInitializeHeapSegment(IN OUT PHEAP Heap, OUT PHEAP_SEGMENT Segment, IN UCHAR SegmentIndex, @@ -908,7 +909,7 @@ /* Initialise the Heap Segment location information */ Segment->BaseAddress = Segment; - Segment->NumberOfPages = SegmentReserve >> PAGE_SHIFT; + Segment->NumberOfPages = (ULONG)(SegmentReserve >> PAGE_SHIFT); /* Initialise the Heap Entries contained within the Heap Segment */ Segment->FirstEntry = &Segment->Entry + Segment->Entry.Size; @@ -928,7 +929,7 @@ } /* Initialise the Heap Segment UnCommitted Range information */ - Segment->NumberOfUnCommittedPages = (SegmentReserve - SegmentCommit) >> PAGE_SHIFT; + Segment->NumberOfUnCommittedPages = (ULONG)((SegmentReserve - SegmentCommit) >> PAGE_SHIFT); Segment->NumberOfUnCommittedRanges = 0; InitializeListHead(&Segment->UCRSegmentList); @@ -1162,7 +1163,7 @@ DPRINT("RtlpExtendHeap(%p %x)\n", Heap, Size); /* Calculate amount in pages */ - Pages = (Size + PAGE_SIZE - 1) / PAGE_SIZE; + Pages = (ULONG)((Size + PAGE_SIZE - 1) / PAGE_SIZE); FreeSize = Pages * PAGE_SIZE; DPRINT("Pages %x, FreeSize %x. Going through segments...\n", Pages, FreeSize); @@ -1998,11 +1999,10 @@ PULONG FreeListsInUse; ULONG FreeListsInUseUlong; SIZE_T AllocationSize; - SIZE_T Index; + SIZE_T Index, InUseIndex, i; PLIST_ENTRY FreeListHead; PHEAP_ENTRY InUseEntry; PHEAP_FREE_ENTRY FreeBlock; - ULONG InUseIndex, i; UCHAR FreeFlags; EXCEPTION_RECORD ExceptionRecord; BOOLEAN HeapLocked = FALSE; @@ -3390,7 +3390,7 @@ } else { - UnCommittedPages += (UcrDescriptor->Size / PAGE_SIZE); + UnCommittedPages += (ULONG)(UcrDescriptor->Size / PAGE_SIZE); UnCommittedRanges++; CurrentEntry = (PHEAP_ENTRY)((PCHAR)UcrDescriptor->Address + UcrDescriptor->Size); Modified: trunk/reactos/lib/rtl/heap.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.h?rev=53764&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.h [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.h [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -151,15 +151,15 @@ { ULONG Allocs; ULONG Frees; - ULONG Size; + SIZE_T Size; } HEAP_PSEUDO_TAG_ENTRY, *PHEAP_PSEUDO_TAG_ENTRY; typedef struct _HEAP_COUNTERS { - ULONG TotalMemoryReserved; - ULONG TotalMemoryCommitted; - ULONG TotalMemoryLargeUCR; - ULONG TotalSizeInVirtualBlocks; + SIZE_T TotalMemoryReserved; + SIZE_T TotalMemoryCommitted; + SIZE_T TotalMemoryLargeUCR; + SIZE_T TotalSizeInVirtualBlocks; ULONG TotalSegments; ULONG TotalUCRs; ULONG CommittOps; @@ -173,13 +173,13 @@ ULONG CompactHeapCalls; ULONG CompactedUCRs; ULONG InBlockDeccommits; - ULONG InBlockDeccomitSize; + SIZE_T InBlockDeccomitSize; } HEAP_COUNTERS, *PHEAP_COUNTERS; typedef struct _HEAP_TUNING_PARAMETERS { ULONG CommittThresholdShift; - ULONG MaxPreCommittThreshold; + SIZE_T MaxPreCommittThreshold; } HEAP_TUNING_PARAMETERS, *PHEAP_TUNING_PARAMETERS; typedef struct _HEAP_LIST_LOOKUP @@ -217,16 +217,16 @@ ULONG CompatibilityFlags; ULONG EncodeFlagMask; HEAP_ENTRY Encoding; - ULONG PointerKey; + ULONG_PTR PointerKey; ULONG Interceptor; ULONG VirtualMemoryThreshold; ULONG Signature; - ULONG SegmentReserve; - ULONG SegmentCommit; - ULONG DeCommitFreeBlockThreshold; - ULONG DeCommitTotalFreeThreshold; - ULONG TotalFreeSize; - ULONG MaximumAllocationSize; + SIZE_T SegmentReserve; + SIZE_T SegmentCommit; + SIZE_T DeCommitFreeBlockThreshold; + SIZE_T DeCommitTotalFreeThreshold; + SIZE_T TotalFreeSize; + SIZE_T MaximumAllocationSize; USHORT ProcessHeapsListIndex; USHORT HeaderValidateLength; PVOID HeaderValidateCopy; @@ -235,8 +235,8 @@ PHEAP_TAG_ENTRY TagEntries; LIST_ENTRY UCRList; LIST_ENTRY UCRSegments; // FIXME: non-Vista - ULONG AlignRound; - ULONG AlignMask; + ULONG_PTR AlignRound; + ULONG_PTR AlignMask; LIST_ENTRY VirtualAllocdBlocks; LIST_ENTRY SegmentList; struct _HEAP_SEGMENT *Segments[HEAP_SEGMENTS]; //FIXME: non-Vista @@ -284,7 +284,7 @@ LIST_ENTRY ListEntry; LIST_ENTRY SegmentEntry; PVOID Address; - ULONG Size; + SIZE_T Size; } HEAP_UCR_DESCRIPTOR, *PHEAP_UCR_DESCRIPTOR; typedef struct _HEAP_UCR_SEGMENT @@ -314,8 +314,8 @@ { LIST_ENTRY Entry; HEAP_ENTRY_EXTRA ExtraStuff; - ULONG CommitSize; - ULONG ReserveSize; + SIZE_T CommitSize; + SIZE_T ReserveSize; HEAP_ENTRY BusyBlock; } HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY; Modified: trunk/reactos/lib/rtl/heappage.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heappage.c?rev=537…
============================================================================== --- trunk/reactos/lib/rtl/heappage.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heappage.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -24,8 +24,8 @@ { ULONG StartStamp; PVOID Heap; - ULONG RequestedSize; - ULONG ActualSize; + SIZE_T RequestedSize; + SIZE_T ActualSize; union { LIST_ENTRY FreeQueue; @@ -46,10 +46,10 @@ }; PUCHAR pUserAllocation; PUCHAR pVirtualBlock; - ULONG nVirtualBlockSize; - ULONG nVirtualAccessSize; - ULONG nUserRequestedSize; - ULONG nUserActualSize; + SIZE_T nVirtualBlockSize; + SIZE_T nVirtualAccessSize; + SIZE_T nUserRequestedSize; + SIZE_T nUserActualSize; PVOID UserValue; ULONG UserFlags; PRTL_TRACE_BLOCK StackTrace; @@ -67,30 +67,30 @@ PDPH_HEAP_BLOCK pVirtualStorageListHead; PDPH_HEAP_BLOCK pVirtualStorageListTail; ULONG nVirtualStorageRanges; - ULONG nVirtualStorageBytes; + SIZE_T nVirtualStorageBytes; RTL_AVL_TABLE BusyNodesTable; PDPH_HEAP_BLOCK NodeToAllocate; ULONG nBusyAllocations; - ULONG nBusyAllocationBytesCommitted; + SIZE_T nBusyAllocationBytesCommitted; PDPH_HEAP_BLOCK pFreeAllocationListHead; PDPH_HEAP_BLOCK pFreeAllocationListTail; ULONG nFreeAllocations; - ULONG nFreeAllocationBytesCommitted; + SIZE_T nFreeAllocationBytesCommitted; LIST_ENTRY AvailableAllocationHead; ULONG nAvailableAllocations; - ULONG nAvailableAllocationBytesCommitted; + SIZE_T nAvailableAllocationBytesCommitted; PDPH_HEAP_BLOCK pUnusedNodeListHead; PDPH_HEAP_BLOCK pUnusedNodeListTail; ULONG nUnusedNodes; - ULONG nBusyAllocationBytesAccessible; + SIZE_T nBusyAllocationBytesAccessible; PDPH_HEAP_BLOCK pNodePoolListHead; PDPH_HEAP_BLOCK pNodePoolListTail; ULONG nNodePools; - ULONG nNodePoolBytes; + SIZE_T nNodePoolBytes; LIST_ENTRY NextHeap; ULONG ExtraFlags; @@ -117,7 +117,7 @@ RTL_CRITICAL_SECTION RtlpDphDelayedFreeQueueLock; LIST_ENTRY RtlpDphDelayedFreeQueue; SLIST_HEADER RtlpDphDelayedTemporaryPushList; -ULONG RtlpDphMemoryUsedByDelayedFreeBlocks; +SIZE_T RtlpDphMemoryUsedByDelayedFreeBlocks; ULONG RtlpDphNumberOfDelayedFreeBlocks; /* Counters */ @@ -429,7 +429,7 @@ RtlFillMemory(FillPtr, ROUND_UP(FillPtr, PAGE_SIZE) - (ULONG_PTR)FillPtr, DPH_FILL_SUFFIX); /* FIXME: Check if logging stack traces is turned on */ - //if (DphRoot->ExtraFlags & + //if (DphRoot->ExtraFlags & return TRUE; } @@ -758,7 +758,7 @@ ULONG NodeCount, i; //NodeCount = (Size >> 6) - 1; - NodeCount = (Size / sizeof(DPH_HEAP_BLOCK)); + NodeCount = (ULONG)(Size / sizeof(DPH_HEAP_BLOCK)); DphStartNode = Virtual; /* Set pNextAlloc for all blocks */ @@ -1903,7 +1903,8 @@ PDPH_HEAP_ROOT DphRoot; PDPH_HEAP_BLOCK Node = NULL, AllocatedNode; BOOLEAN Biased = FALSE, UseNormalHeap = FALSE, OldBlockPageHeap = TRUE; - ULONG DataSize, ValidationInfo; + ULONG ValidationInfo; + SIZE_T DataSize; PVOID NewAlloc = NULL; /* Check requested size */ Modified: trunk/reactos/lib/rtl/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/registry.c?rev=537…
============================================================================== --- trunk/reactos/lib/rtl/registry.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/registry.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -116,8 +116,9 @@ IN PVOID Context, IN PVOID Environment) { - ULONG InfoLength, Length, c; - LONG RequiredLength, SpareLength; + ULONG InfoLength; + SIZE_T Length, SpareLength, c; + LONG RequiredLength; PCHAR SpareData, DataEnd; ULONG Type; PWCHAR Name, p, ValueEnd; @@ -207,7 +208,7 @@ if (SpareLength < RequiredLength) { /* Fail and return the missing length */ - *InfoSize = SpareData - (PCHAR)KeyValueInfo + RequiredLength; + *InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + RequiredLength; return STATUS_BUFFER_TOO_SMALL; } @@ -257,7 +258,7 @@ /* Do the query */ Status = RtlpQueryRegistryDirect(REG_SZ, Data, - Length, + (ULONG)Length, QueryTable->EntryContext); QueryTable->EntryContext = (PVOID)((ULONG_PTR)QueryTable-> EntryContext + @@ -269,7 +270,7 @@ Status = QueryTable->QueryRoutine(Name, REG_SZ, Data, - Length, + (ULONG)Length, Context, QueryTable->EntryContext); } @@ -311,7 +312,7 @@ if (FoundExpander) { /* Setup the source string */ - RtlInitEmptyUnicodeString(&Source, Data, Length); + RtlInitEmptyUnicodeString(&Source, Data, (USHORT)Length); Source.Length = Source.MaximumLength - sizeof(UNICODE_NULL); /* Setup the desination string */ @@ -326,7 +327,7 @@ else if (SpareLength <= MAXUSHORT) { /* This is the good case, where we fit into a string */ - Destination.MaximumLength = SpareLength; + Destination.MaximumLength = (USHORT)SpareLength; Destination.Buffer[SpareLength / 2 - 1] = UNICODE_NULL; } else @@ -356,9 +357,8 @@ if (Status == STATUS_BUFFER_TOO_SMALL) { /* Set the required missing length */ - *InfoSize = SpareData - - (PCHAR)KeyValueInfo + - RequiredLength; + *InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + + RequiredLength; /* Notify debugger */ DPRINT1("RTL: Expand variables for %wZ failed - " @@ -391,7 +391,7 @@ /* Return the data */ Status = RtlpQueryRegistryDirect(Type, Data, - Length, + (ULONG)Length, QueryTable->EntryContext); } else @@ -400,7 +400,7 @@ Status = QueryTable->QueryRoutine(Name, Type, Data, - Length, + (ULONG)Length, Context, QueryTable->EntryContext); } @@ -756,7 +756,7 @@ /* Initialize a string */ RtlInitEmptyUnicodeString(KeyPath, RtlpAllocateStringMemory(Length, TAG_USTR), - Length); + (USHORT)Length); if (!KeyPath->Buffer) { /* Free the string and fail */ @@ -840,7 +840,7 @@ if (KeyInfo->NameLength <= SubKeyName->MaximumLength) { /* Set the length */ - SubKeyName->Length = KeyInfo->NameLength; + SubKeyName->Length = (USHORT)KeyInfo->NameLength; /* Copy it */ RtlMoveMemory(SubKeyName->Buffer, @@ -1094,7 +1094,7 @@ &KeyValueName, KeyValueFullInformation, KeyValueInfo, - InfoSize, + (ULONG)InfoSize, &ResultLength); if (Status == STATUS_BUFFER_OVERFLOW) { @@ -1111,7 +1111,7 @@ /* Setup a default */ KeyValueInfo->Type = REG_NONE; KeyValueInfo->DataLength = 0; - ResultLength = InfoSize; + ResultLength = (ULONG)InfoSize; /* Call the query routine */ Status = RtlpCallQueryRegistryRoutine(QueryTable, @@ -1151,7 +1151,7 @@ } /* Call the query routine */ - ResultLength = InfoSize; + ResultLength = (ULONG)InfoSize; Status = RtlpCallQueryRegistryRoutine(QueryTable, KeyValueInfo, &ResultLength, @@ -1212,7 +1212,7 @@ Value, KeyValueFullInformation, KeyValueInfo, - InfoSize, + (ULONG)InfoSize, &ResultLength); if (Status == STATUS_BUFFER_OVERFLOW) { @@ -1242,7 +1242,7 @@ if (NT_SUCCESS(Status)) { /* Call the query routine */ - ResultLength = InfoSize; + ResultLength = (ULONG)InfoSize; Status = RtlpCallQueryRegistryRoutine(QueryTable, KeyValueInfo, &ResultLength, Modified: trunk/reactos/lib/rtl/rtlp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/rtlp.h?rev=53764&r…
============================================================================== --- trunk/reactos/lib/rtl/rtlp.h [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/rtlp.h [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -63,7 +63,7 @@ PVOID NTAPI RtlpAllocateMemory( - ULONG Bytes, + SIZE_T Bytes, ULONG Tag); VOID Modified: trunk/reactos/lib/rtl/srw.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/srw.c?rev=53764&r1…
============================================================================== --- trunk/reactos/lib/rtl/srw.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/srw.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -630,7 +630,7 @@ /* There are no wait blocks so far, we need to add ourselves as the first wait block. We need to keep the shared count! */ StackWaitBlock.Exclusive = TRUE; - StackWaitBlock.SharedCount = CurrentValue >> RTL_SRWLOCK_BITS; + StackWaitBlock.SharedCount = (LONG)(CurrentValue >> RTL_SRWLOCK_BITS); StackWaitBlock.Next = NULL; StackWaitBlock.Last = &StackWaitBlock; StackWaitBlock.Wake = 0; Modified: trunk/reactos/lib/rtl/timerqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/timerqueue.c?rev=5…
============================================================================== --- trunk/reactos/lib/rtl/timerqueue.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/timerqueue.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -193,7 +193,7 @@ if (t->expire != EXPIRE_NEVER) { ULONGLONG time = queue_current_time(); - timeout = t->expire < time ? 0 : t->expire - time; + timeout = t->expire < time ? 0 : (ULONG)(t->expire - time); } } RtlLeaveCriticalSection(&q->cs); Modified: trunk/reactos/lib/rtl/timezone.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/timezone.c?rev=537…
============================================================================== --- trunk/reactos/lib/rtl/timezone.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/timezone.c [iso-8859-1] Mon Sep 19 19:31:21 2011 @@ -85,7 +85,7 @@ NTSTATUS NTAPI RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation) { - ULONG Length; + SIZE_T Length; NTSTATUS Status; DPRINT("RtlSetTimeZoneInformation()\n"); @@ -109,7 +109,7 @@ L"Standard Name", REG_SZ, TimeZoneInformation->StandardName, - Length); + (ULONG)Length); if (!NT_SUCCESS(Status)) { return Status; @@ -143,7 +143,7 @@ L"Daylight Name", REG_SZ, TimeZoneInformation->DaylightName, - Length); + (ULONG)Length); if (!NT_SUCCESS(Status)) { return Status;
13 years, 3 months
1
0
0
0
[pschweitzer] 53763: [RGENSTAT] Fix memory leaks
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon Sep 19 17:24:27 2011 New Revision: 53763 URL:
http://svn.reactos.org/svn/reactos?rev=53763&view=rev
Log: [RGENSTAT] Fix memory leaks Modified: trunk/reactos/tools/rgenstat/rgenstat.c Modified: trunk/reactos/tools/rgenstat/rgenstat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rgenstat/rgenstat.c?…
============================================================================== --- trunk/reactos/tools/rgenstat/rgenstat.c [iso-8859-1] (original) +++ trunk/reactos/tools/rgenstat/rgenstat.c [iso-8859-1] Mon Sep 19 17:24:27 2011 @@ -113,7 +113,6 @@ static void write_line(char *line) { - int n_out; char buf[200]; memset(buf, 0, sizeof(buf)); @@ -122,7 +121,7 @@ buf[strlen(buf)] = '\r'; buf[strlen(buf)] = '\n'; - n_out = fwrite(&buf[0], 1, strlen(buf), out); + (void)fwrite(&buf[0], 1, strlen(buf), out); } @@ -888,6 +887,7 @@ input_file = convert_path(argv[1]); if (input_file[0] == 0) { + free(input_file); printf("Missing input-filename\n"); return 1; } @@ -895,6 +895,8 @@ output_file = convert_path(argv[2]); if (output_file[0] == 0) { + free(input_file); + free(output_file); printf("Missing output-filename\n"); return 1; } @@ -902,12 +904,16 @@ out = fopen(output_file, "wb"); if (out == NULL) { + free(input_file); + free(output_file); printf("Cannot open output file"); return 1; } read_input_file(input_file); + free(input_file); + free(output_file); fclose(out); return 0;
13 years, 3 months
1
0
0
0
[pschweitzer] 53762: [REGTESTS2XML] Fix memory leaks
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon Sep 19 17:24:01 2011 New Revision: 53762 URL:
http://svn.reactos.org/svn/reactos?rev=53762&view=rev
Log: [REGTESTS2XML] Fix memory leaks Modified: trunk/reactos/tools/regtests2xml/regtests2xml.c Modified: trunk/reactos/tools/regtests2xml/regtests2xml.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/regtests2xml/regtest…
============================================================================== --- trunk/reactos/tools/regtests2xml/regtests2xml.c [iso-8859-1] (original) +++ trunk/reactos/tools/regtests2xml/regtests2xml.c [iso-8859-1] Mon Sep 19 17:24:01 2011 @@ -81,7 +81,6 @@ static void write_line(char *line) { - int n_out; char buf[200]; memset(buf, 0, sizeof(buf)); @@ -90,7 +89,7 @@ buf[strlen(buf)] = '\r'; buf[strlen(buf)] = '\n'; - n_out = fwrite(&buf[0], 1, strlen(buf), out); + (void)fwrite(&buf[0], 1, strlen(buf), out); } @@ -414,6 +413,7 @@ input_file = convert_path(argv[1]); if (input_file[0] == 0) { + free(input_file); printf("Missing input-filename\n"); return 1; } @@ -421,6 +421,8 @@ output_file = convert_path(argv[2]); if (output_file[0] == 0) { + free(output_file); + free(input_file); printf("Missing output-filename\n"); return 1; } @@ -428,6 +430,8 @@ out = fopen(output_file, "wb"); if (out == NULL) { + free(input_file); + free(output_file); printf("Cannot open output file"); return 1; } @@ -436,6 +440,8 @@ generate_xml(); + free(input_file); + free(output_file); fclose(out); return 0;
13 years, 3 months
1
0
0
0
[rmessiant] 53761: [NTOSKRNL] - Keep APC delivery disabled while holding a Heap Lock, not just while acquiring/releasing it (Dedicated to Timo and Ged). - Store the Heap Lock in non-paged pool, the...
by rmessiant@svn.reactos.org
Author: rmessiant Date: Mon Sep 19 16:52:37 2011 New Revision: 53761 URL:
http://svn.reactos.org/svn/reactos?rev=53761&view=rev
Log: [NTOSKRNL] - Keep APC delivery disabled while holding a Heap Lock, not just while acquiring/releasing it (Dedicated to Timo and Ged). - Store the Heap Lock in non-paged pool, the only place where executive resources belong (Dedicated to patient people). [RTL] - Restructure/simplify/correct Heap and Heap Segment initialization (partially to cope with the changed Heap Lock interface). - Restrict the location of Heap Segment headers to the base address of the Heap Segment (which frees up a whopping 60 bytes per Heap!). - Cater for acquiring the Heap Lock exclusively or shared (the latter is only available in kernel-mode); only exclusive locking is used for now. - Use a plain critical section to guard the Process Heap list, no reason to disguise it as a Heap Lock (saves us a handful more bytes). Modified: trunk/reactos/dll/ntdll/rtl/libsupp.c trunk/reactos/lib/rtl/heap.c trunk/reactos/lib/rtl/heap.h trunk/reactos/lib/rtl/heapdbg.c trunk/reactos/lib/rtl/rtlp.h trunk/reactos/ntoskrnl/rtl/libsupp.c Modified: trunk/reactos/dll/ntdll/rtl/libsupp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/rtl/libsupp.c?re…
============================================================================== --- trunk/reactos/dll/ntdll/rtl/libsupp.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/rtl/libsupp.c [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -112,32 +112,30 @@ NTSTATUS NTAPI -RtlDeleteHeapLock( - PHEAP_LOCK Lock) +RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock) { return RtlDeleteCriticalSection(&Lock->CriticalSection); } NTSTATUS NTAPI -RtlEnterHeapLock( - PHEAP_LOCK Lock) -{ +RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive) +{ + UNREFERENCED_PARAMETER(Exclusive); + return RtlEnterCriticalSection(&Lock->CriticalSection); } NTSTATUS NTAPI -RtlInitializeHeapLock( - PHEAP_LOCK Lock) -{ - return RtlInitializeCriticalSection(&Lock->CriticalSection); +RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock) +{ + return RtlInitializeCriticalSection(&(*Lock)->CriticalSection); } NTSTATUS NTAPI -RtlLeaveHeapLock( - PHEAP_LOCK Lock) +RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock) { return RtlLeaveCriticalSection(&Lock->CriticalSection); } Modified: trunk/reactos/lib/rtl/heap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=53761&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -23,7 +23,7 @@ #define NDEBUG #include <debug.h> -HEAP_LOCK RtlpProcessHeapsListLock; +RTL_CRITICAL_SECTION RtlpProcessHeapsListLock; /* Bitmaps stuff */ @@ -82,44 +82,58 @@ /* FUNCTIONS *****************************************************************/ -VOID NTAPI -RtlpInitializeHeap(PHEAP Heap, - PULONG HeaderSize, - ULONG Flags, - BOOLEAN AllocateLock, - PVOID Lock) -{ - PVOID NextHeapBase = Heap + 1; +NTSTATUS NTAPI +RtlpInitializeHeap(OUT PHEAP Heap, + IN ULONG Flags, + IN PHEAP_LOCK Lock OPTIONAL, + IN PRTL_HEAP_PARAMETERS Parameters) +{ + ULONG NumUCRs = 8; + ULONG Index; + SIZE_T HeaderSize; + NTSTATUS Status; PHEAP_UCR_DESCRIPTOR UcrDescriptor; - ULONG NumUCRs = 8; - ULONG i; - NTSTATUS Status; - - /* Add UCRs size */ - *HeaderSize += NumUCRs * sizeof(*UcrDescriptor); - - /* Prepare a list of UCRs */ - InitializeListHead(&Heap->UCRList); - InitializeListHead(&Heap->UCRSegments); - UcrDescriptor = NextHeapBase; - - for (i=0; i<NumUCRs; i++, UcrDescriptor++) - { - InsertTailList(&Heap->UCRList, &UcrDescriptor->ListEntry); - } - - NextHeapBase = UcrDescriptor; - // TODO: Add tagging - - /* Round up header size again */ - *HeaderSize = ROUND_UP(*HeaderSize, HEAP_ENTRY_SIZE); - - ASSERT(*HeaderSize <= PAGE_SIZE); - - /* Initialize heap's header */ - Heap->Entry.Size = (USHORT)((*HeaderSize) >> HEAP_ENTRY_SHIFT); + + /* Preconditions */ + ASSERT(Heap != NULL); + ASSERT(Parameters != NULL); + ASSERT(!(Flags & HEAP_LOCK_USER_ALLOCATED)); + ASSERT(!(Flags & HEAP_NO_SERIALIZE) || (Lock == NULL)); /* HEAP_NO_SERIALIZE => no lock */ + + /* Start out with the size of a plain Heap header */ + HeaderSize = ROUND_UP(sizeof(HEAP), sizeof(HEAP_ENTRY)); + + /* Check if space needs to be added for the Heap Lock */ + if (!(Flags & HEAP_NO_SERIALIZE)) + { + if (Lock != NULL) + /* The user manages the Heap Lock */ + Flags |= HEAP_LOCK_USER_ALLOCATED; + else + if (RtlpGetMode() == UserMode) + { + /* In user mode, the Heap Lock trails the Heap header */ + Lock = (PHEAP_LOCK) ((ULONG_PTR) (Heap) + HeaderSize); + HeaderSize += ROUND_UP(sizeof(HEAP_LOCK), sizeof(HEAP_ENTRY)); + } + } + + /* Add space for the initial Heap UnCommitted Range Descriptor list */ + UcrDescriptor = (PHEAP_UCR_DESCRIPTOR) ((ULONG_PTR) (Heap) + HeaderSize); + HeaderSize += ROUND_UP(NumUCRs * sizeof(HEAP_UCR_DESCRIPTOR), sizeof(HEAP_ENTRY)); + + /* Sanity check */ + ASSERT(HeaderSize <= PAGE_SIZE); + + /* Initialise the Heap Entry header containing the Heap header */ + Heap->Entry.Size = HeaderSize >> HEAP_ENTRY_SHIFT; Heap->Entry.Flags = HEAP_ENTRY_BUSY; - + Heap->Entry.SmallTagIndex = LOBYTE(Heap->Entry.Size) ^ HIBYTE(Heap->Entry.Size) ^ Heap->Entry.Flags; + Heap->Entry.PreviousSize = 0; + Heap->Entry.SegmentOffset = 0; + Heap->Entry.UnusedBytes = 0; + + /* Initialise the Heap header */ Heap->Signature = HEAP_SIGNATURE; Heap->Flags = Flags; Heap->ForceFlags = (Flags & (HEAP_NO_SERIALIZE | @@ -131,32 +145,64 @@ HEAP_TAIL_CHECKING_ENABLED | HEAP_CREATE_ALIGN_16 | HEAP_FREE_CHECKING_ENABLED)); + + /* Initialise the Heap parameters */ + Heap->VirtualMemoryThreshold = ROUND_UP(Parameters->VirtualMemoryThreshold, sizeof(HEAP_ENTRY)) >> HEAP_ENTRY_SHIFT; + Heap->SegmentReserve = Parameters->SegmentReserve; + Heap->SegmentCommit = Parameters->SegmentCommit; + Heap->DeCommitFreeBlockThreshold = Parameters->DeCommitFreeBlockThreshold >> HEAP_ENTRY_SHIFT; + Heap->DeCommitTotalFreeThreshold = Parameters->DeCommitTotalFreeThreshold >> HEAP_ENTRY_SHIFT; + Heap->MaximumAllocationSize = Parameters->MaximumAllocationSize; + Heap->CommitRoutine = Parameters->CommitRoutine; + + /* Initialise the Heap validation info */ Heap->HeaderValidateCopy = NULL; - Heap->HeaderValidateLength = ((PCHAR)NextHeapBase - (PCHAR)Heap); - - /* Initialize free lists */ - for (i=0; i<HEAP_FREELISTS; i++) - { - InitializeListHead(&Heap->FreeLists[i]); - } - - /* Initialize "big" allocations list */ + Heap->HeaderValidateLength = HeaderSize; + + /* Initialise the Heap Lock */ + if (!(Flags & HEAP_NO_SERIALIZE) && !(Flags & HEAP_LOCK_USER_ALLOCATED)) + { + Status = RtlInitializeHeapLock(&Lock); + if (!NT_SUCCESS(Status)) + return Status; + } + Heap->LockVariable = Lock; + + /* Initialise the Heap alignment info */ + if (Flags & HEAP_CREATE_ALIGN_16) + { + Heap->AlignMask = (ULONG) ~15; + Heap->AlignRound = 15 + sizeof(HEAP_ENTRY); + } + else + { + Heap->AlignMask = (ULONG) ~(sizeof(HEAP_ENTRY) - 1); + Heap->AlignRound = 2 * sizeof(HEAP_ENTRY) - 1; + } + + if (Flags & HEAP_TAIL_CHECKING_ENABLED) + Heap->AlignRound += sizeof(HEAP_ENTRY); + + /* Initialise the Heap Segment list */ + for (Index = 0; Index < HEAP_SEGMENTS; ++Index) + Heap->Segments[Index] = NULL; + + /* Initialise the Heap Free Heap Entry lists */ + for (Index = 0; Index < HEAP_FREELISTS; ++Index) + InitializeListHead(&Heap->FreeLists[Index]); + + /* Initialise the Heap Virtual Allocated Blocks list */ InitializeListHead(&Heap->VirtualAllocdBlocks); - /* Initialize lock */ - if (AllocateLock) - { - Lock = NextHeapBase; - Status = RtlInitializeHeapLock((PHEAP_LOCK)Lock); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Initializing the lock failed!\n"); - return /*NULL*/; // FIXME! - } - } - - /* Set the lock variable */ - Heap->LockVariable = Lock; + /* Initialise the Heap UnCommitted Region lists */ + InitializeListHead(&Heap->UCRSegments); + InitializeListHead(&Heap->UCRList); + + /* Register the initial Heap UnCommitted Region Descriptors */ + for (Index = 0; Index < NumUCRs; ++Index) + InsertTailList(&Heap->UCRList, &UcrDescriptor[Index].ListEntry); + + return STATUS_SUCCESS; } VOID FORCEINLINE @@ -821,92 +867,76 @@ } BOOLEAN NTAPI -RtlpInitializeHeapSegment(PHEAP Heap, - PHEAP_SEGMENT Segment, - UCHAR SegmentIndex, - ULONG Flags, - PVOID BaseAddress, - PVOID UncommittedBase, - PVOID LimitAddress) -{ - ULONG Pages, CommitSize; +RtlpInitializeHeapSegment(IN OUT PHEAP Heap, + OUT PHEAP_SEGMENT Segment, + IN UCHAR SegmentIndex, + IN ULONG SegmentFlags, + IN SIZE_T SegmentReserve, + IN SIZE_T SegmentCommit) +{ PHEAP_ENTRY HeapEntry; - USHORT PreviousSize = 0, NewSize; - NTSTATUS Status; - - Pages = ((PCHAR)LimitAddress - (PCHAR)BaseAddress) / PAGE_SIZE; - - HeapEntry = (PHEAP_ENTRY)ROUND_UP(Segment + 1, HEAP_ENTRY_SIZE); - - DPRINT("RtlpInitializeHeapSegment(%p %p %x %x %p %p %p)\n", Heap, Segment, SegmentIndex, Flags, BaseAddress, UncommittedBase, LimitAddress); - DPRINT("Pages %x, HeapEntry %p, sizeof(HEAP_SEGMENT) %x\n", Pages, HeapEntry, sizeof(HEAP_SEGMENT)); - - /* Check if it's the first segment and remember its size */ - if (Heap == BaseAddress) - PreviousSize = Heap->Entry.Size; - - NewSize = ((PCHAR)HeapEntry - (PCHAR)Segment) >> HEAP_ENTRY_SHIFT; - - if ((PVOID)(HeapEntry + 1) >= UncommittedBase) - { - /* Check if it goes beyond the limit */ - if ((PVOID)(HeapEntry + 1) >= LimitAddress) - return FALSE; - - /* Need to commit memory */ - CommitSize = (PCHAR)(HeapEntry + 1) - (PCHAR)UncommittedBase; - Status = ZwAllocateVirtualMemory(NtCurrentProcess(), - (PVOID)&UncommittedBase, - 0, - &CommitSize, - MEM_COMMIT, - PAGE_READWRITE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Committing page failed with status 0x%08X\n", Status); - return FALSE; - } - - DPRINT("Committed %d bytes at base %p\n", CommitSize, UncommittedBase); - - /* Calcule the new uncommitted base */ - UncommittedBase = (PVOID)((PCHAR)UncommittedBase + CommitSize); - } - - /* Initialize the segment entry */ - Segment->Entry.PreviousSize = PreviousSize; - Segment->Entry.Size = NewSize; - Segment->Entry.Flags = HEAP_ENTRY_BUSY; - Segment->Entry.SegmentOffset = SegmentIndex; - - /* Initialize the segment itself */ + + /* Preconditions */ + ASSERT(Heap != NULL); + ASSERT(Segment != NULL); + ASSERT(SegmentCommit >= PAGE_SIZE); + ASSERT(ROUND_DOWN(SegmentCommit, PAGE_SIZE) == SegmentCommit); + ASSERT(SegmentReserve >= SegmentCommit); + ASSERT(ROUND_DOWN(SegmentReserve, PAGE_SIZE) == SegmentReserve); + + DPRINT("RtlpInitializeHeapSegment(%p %p %x %x %lx %lx)\n", Heap, Segment, SegmentIndex, SegmentFlags, SegmentReserve, SegmentCommit); + + /* Initialise the Heap Entry header if this is not the first Heap Segment */ + if ((PHEAP_SEGMENT) (Heap) != Segment) + { + Segment->Entry.Size = ROUND_UP(sizeof(HEAP_SEGMENT), sizeof(HEAP_ENTRY)) >> HEAP_ENTRY_SHIFT; + Segment->Entry.Flags = HEAP_ENTRY_BUSY; + Segment->Entry.SmallTagIndex = LOBYTE(Segment->Entry.Size) ^ HIBYTE(Segment->Entry.Size) ^ Segment->Entry.Flags; + Segment->Entry.PreviousSize = 0; + Segment->Entry.SegmentOffset = SegmentIndex; + Segment->Entry.UnusedBytes = 0; + } + + /* Sanity check */ + ASSERT((Segment->Entry.Size << HEAP_ENTRY_SHIFT) <= PAGE_SIZE); + + /* Initialise the Heap Segment header */ Segment->SegmentSignature = HEAP_SEGMENT_SIGNATURE; + Segment->SegmentFlags = SegmentFlags; Segment->Heap = Heap; - Segment->BaseAddress = BaseAddress; - Segment->FirstEntry = HeapEntry; - Segment->LastValidEntry = (PHEAP_ENTRY)((PCHAR)BaseAddress + Pages * PAGE_SIZE); - Segment->NumberOfPages = Pages; - Segment->NumberOfUnCommittedPages = ((PCHAR)LimitAddress - (PCHAR)UncommittedBase) / PAGE_SIZE; + Heap->Segments[SegmentIndex] = Segment; + + /* Initialise the Heap Segment location information */ + Segment->BaseAddress = Segment; + Segment->NumberOfPages = SegmentReserve >> PAGE_SHIFT; + + /* Initialise the Heap Entries contained within the Heap Segment */ + Segment->FirstEntry = &Segment->Entry + Segment->Entry.Size; + Segment->LastValidEntry = (PHEAP_ENTRY) ((ULONG_PTR) (Segment) + SegmentReserve); + + if ((Segment->Entry.Size << HEAP_ENTRY_SHIFT) < SegmentCommit) + { + HeapEntry = Segment->FirstEntry; + + /* Prepare a Free Heap Entry header */ + HeapEntry->Flags = HEAP_ENTRY_LAST_ENTRY; + HeapEntry->PreviousSize = Segment->Entry.Size; + HeapEntry->SegmentOffset = SegmentIndex; + + /* Register the Free Heap Entry */ + RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY) HeapEntry, (SegmentCommit >> HEAP_ENTRY_SHIFT) - Segment->Entry.Size); + } + + /* Initialise the Heap Segment UnCommitted Range information */ + Segment->NumberOfUnCommittedPages = (SegmentReserve - SegmentCommit) >> PAGE_SHIFT; + Segment->NumberOfUnCommittedRanges = 0; InitializeListHead(&Segment->UCRSegmentList); - /* Insert uncommitted pages into UCR (uncommitted ranges) list */ - if (Segment->NumberOfUnCommittedPages) - { - RtlpInsertUnCommittedPages(Segment, (ULONG_PTR)UncommittedBase, Segment->NumberOfUnCommittedPages * PAGE_SIZE); - } - - /* Set the segment index pointer */ - Heap->Segments[SegmentIndex] = Segment; - - /* Prepare a free heap entry */ - HeapEntry->Flags = HEAP_ENTRY_LAST_ENTRY; - HeapEntry->PreviousSize = Segment->Entry.Size; - HeapEntry->SegmentOffset = SegmentIndex; - - /* Insert it */ - RtlpInsertFreeBlock(Heap, (PHEAP_FREE_ENTRY)HeapEntry, (PHEAP_ENTRY)UncommittedBase - HeapEntry); - - return TRUE; + /* Register the UnCommitted Range of the Heap Segment */ + if (Segment->NumberOfUnCommittedPages != 0) + RtlpInsertUnCommittedPages(Segment, (ULONG_PTR) (Segment) + SegmentCommit, SegmentReserve - SegmentCommit); + + return STATUS_SUCCESS; } VOID NTAPI @@ -944,7 +974,7 @@ Peb = RtlGetCurrentPeb(); /* Acquire the lock */ - RtlEnterHeapLock(&RtlpProcessHeapsListLock); + RtlEnterCriticalSection(&RtlpProcessHeapsListLock); //_SEH2_TRY { /* Check if max number of heaps reached */ @@ -961,7 +991,7 @@ // } _SEH2_FINALLY { /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); + RtlLeaveCriticalSection(&RtlpProcessHeapsListLock); // } _SEH2_END } @@ -978,7 +1008,7 @@ Peb = RtlGetCurrentPeb(); /* Acquire the lock */ - RtlEnterHeapLock(&RtlpProcessHeapsListLock); + RtlEnterCriticalSection(&RtlpProcessHeapsListLock); /* Check if we don't need anything to do */ if ((Heap->ProcessHeapsListIndex == 0) || @@ -986,7 +1016,7 @@ (Peb->NumberOfHeaps == 0)) { /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); + RtlLeaveCriticalSection(&RtlpProcessHeapsListLock); return; } @@ -1023,7 +1053,7 @@ Heap->ProcessHeapsListIndex = 0; /* Release the lock */ - RtlLeaveHeapLock(&RtlpProcessHeapsListLock); + RtlLeaveCriticalSection(&RtlpProcessHeapsListLock); } PHEAP_FREE_ENTRY NTAPI @@ -1228,13 +1258,7 @@ /* Initialize heap segment if commit was successful */ if (NT_SUCCESS(Status)) - { - if (!RtlpInitializeHeapSegment(Heap, Segment, EmptyIndex, 0, Segment, - (PCHAR)Segment + CommitSize, (PCHAR)Segment + ReserveSize)) - { - Status = STATUS_NO_MEMORY; - } - } + Status = RtlpInitializeHeapSegment(Heap, Segment, EmptyIndex, 0, ReserveSize, CommitSize); /* If everything worked - cool */ if (NT_SUCCESS(Status)) return (PHEAP_FREE_ENTRY)Segment->FirstEntry; @@ -1298,8 +1322,7 @@ ULONG NtGlobalFlags = RtlGetNtGlobalFlags(); ULONG HeapSegmentFlags = 0; NTSTATUS Status; - ULONG MaxBlockSize, HeaderSize; - BOOLEAN AllocateLock = FALSE; + ULONG MaxBlockSize; /* Check for a special heap */ if (RtlpPageHeapEnabled && !Addr && !Lock) @@ -1422,25 +1445,9 @@ if (RtlpHeapIsSpecial(Flags)) return RtlDebugCreateHeap(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); - /* Calculate header size */ - HeaderSize = sizeof(HEAP); - if (!(Flags & HEAP_NO_SERIALIZE)) - { - if (Lock) - { - Flags |= HEAP_LOCK_USER_ALLOCATED; - } - else - { - HeaderSize += sizeof(HEAP_LOCK); - AllocateLock = TRUE; - } - } - else if (Lock) - { - /* Invalid parameters */ + /* Without serialization, a lock makes no sense */ + if ((Flags & HEAP_NO_SERIALIZE) && (Lock != NULL)) return NULL; - } /* See if we are already provided with an address for the heap */ if (Addr) @@ -1583,48 +1590,23 @@ UncommittedAddress = (PCHAR)UncommittedAddress + CommitSize; } + /* Initialize the heap */ + Status = RtlpInitializeHeap(Heap, Flags, Lock, Parameters); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to initialize heap (%x)\n", Status); + return NULL; + } + + /* Initialize heap's first segment */ + Status = RtlpInitializeHeapSegment(Heap, (PHEAP_SEGMENT) (Heap), 0, HeapSegmentFlags, TotalSize, CommitSize); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to initialize heap segment (%x)\n", Status); + return NULL; + } + DPRINT("Created heap %p, CommitSize %x, ReserveSize %x\n", Heap, CommitSize, TotalSize); - - /* Initialize the heap */ - RtlpInitializeHeap(Heap, &HeaderSize, Flags, AllocateLock, Lock); - - /* Initialize heap's first segment */ - if (!RtlpInitializeHeapSegment(Heap, - (PHEAP_SEGMENT)((PCHAR)Heap + HeaderSize), - 0, - HeapSegmentFlags, - CommittedAddress, - UncommittedAddress, - (PCHAR)CommittedAddress + TotalSize)) - { - DPRINT1("Failed to initialize heap segment\n"); - return NULL; - } - - /* Set other data */ - Heap->ProcessHeapsListIndex = 0; - Heap->SegmentCommit = Parameters->SegmentCommit; - Heap->SegmentReserve = Parameters->SegmentReserve; - Heap->DeCommitFreeBlockThreshold = Parameters->DeCommitFreeBlockThreshold >> HEAP_ENTRY_SHIFT; - Heap->DeCommitTotalFreeThreshold = Parameters->DeCommitTotalFreeThreshold >> HEAP_ENTRY_SHIFT; - Heap->MaximumAllocationSize = Parameters->MaximumAllocationSize; - Heap->VirtualMemoryThreshold = ROUND_UP(Parameters->VirtualMemoryThreshold, HEAP_ENTRY_SIZE) >> HEAP_ENTRY_SHIFT; - Heap->CommitRoutine = Parameters->CommitRoutine; - - /* Set alignment */ - if (Flags & HEAP_CREATE_ALIGN_16) - { - Heap->AlignMask = (ULONG)~15; - Heap->AlignRound = 15 + sizeof(HEAP_ENTRY); - } - else - { - Heap->AlignMask = (ULONG)~(HEAP_ENTRY_SIZE - 1); - Heap->AlignRound = HEAP_ENTRY_SIZE - 1 + sizeof(HEAP_ENTRY); - } - - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - Heap->AlignRound += HEAP_ENTRY_SIZE; /* Add heap to process list in case of usermode heap */ if (RtlpGetMode() == UserMode) @@ -1634,7 +1616,6 @@ // FIXME: What about lookasides? } - DPRINT("Heap %p, flags 0x%08x\n", Heap, Heap->Flags); return Heap; } @@ -2063,7 +2044,7 @@ /* Acquire the lock if necessary */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; } @@ -2265,7 +2246,7 @@ /* Lock if necessary */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); Locked = TRUE; } @@ -2690,7 +2671,7 @@ /* Acquire the lock if necessary */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; Flags &= ~HEAP_NO_SERIALIZE; } @@ -3071,7 +3052,7 @@ /* Lock if it's lockable */ if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); } return TRUE; @@ -3651,7 +3632,7 @@ /* Acquire the lock if necessary */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; } @@ -3682,7 +3663,7 @@ Peb->NumberOfHeaps = 0; /* Initialize the process heaps list protecting lock */ - RtlInitializeHeapLock(&RtlpProcessHeapsListLock); + RtlInitializeCriticalSection(&RtlpProcessHeapsListLock); } @@ -3759,7 +3740,7 @@ /* Lock if it's lockable */ if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; } @@ -3818,7 +3799,7 @@ /* Lock if it's lockable */ if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; } @@ -3874,7 +3855,7 @@ /* Lock if it's lockable */ if (!(Heap->Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; } Modified: trunk/reactos/lib/rtl/heap.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.h?rev=53761&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.h [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.h [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -320,7 +320,7 @@ } HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY; /* Global variables */ -extern HEAP_LOCK RtlpProcessHeapsListLock; +extern RTL_CRITICAL_SECTION RtlpProcessHeapsListLock; extern BOOLEAN RtlpPageHeapEnabled; /* Functions declarations */ Modified: trunk/reactos/lib/rtl/heapdbg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heapdbg.c?rev=5376…
============================================================================== --- trunk/reactos/lib/rtl/heapdbg.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heapdbg.c [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -163,7 +163,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -230,7 +230,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -288,7 +288,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -345,7 +345,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -397,7 +397,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -461,7 +461,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ @@ -516,7 +516,7 @@ /* Lock the heap ourselves */ if (!(Flags & HEAP_NO_SERIALIZE)) { - RtlEnterHeapLock(Heap->LockVariable); + RtlEnterHeapLock(Heap->LockVariable, TRUE); HeapLocked = TRUE; /* Add no serialize flag so that the main routine won't try to acquire the lock again */ Modified: trunk/reactos/lib/rtl/rtlp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/rtlp.h?rev=53761&r…
============================================================================== --- trunk/reactos/lib/rtl/rtlp.h [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/rtlp.h [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -86,19 +86,19 @@ NTSTATUS NTAPI -RtlDeleteHeapLock(PHEAP_LOCK Lock); +RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock); NTSTATUS NTAPI -RtlEnterHeapLock(PHEAP_LOCK Lock); +RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive); NTSTATUS NTAPI -RtlInitializeHeapLock(PHEAP_LOCK Lock); +RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock); NTSTATUS NTAPI -RtlLeaveHeapLock(PHEAP_LOCK Lock); +RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock); BOOLEAN NTAPI Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] Mon Sep 19 16:52:37 2011 @@ -156,41 +156,49 @@ NTSTATUS NTAPI -RtlDeleteHeapLock( - PHEAP_LOCK Lock) -{ - ExDeleteResource(&Lock->Resource); +RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock) +{ + ExDeleteResourceLite(&Lock->Resource); + ExFreePool(Lock); + return STATUS_SUCCESS; } NTSTATUS NTAPI -RtlEnterHeapLock( - PHEAP_LOCK Lock) +RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive) { KeEnterCriticalRegion(); - ExAcquireResourceExclusive(&Lock->Resource, TRUE); + + if (Exclusive) + ExAcquireResourceExclusiveLite(&Lock->Resource, TRUE); + else + ExAcquireResourceSharedLite(&Lock->Resource, TRUE); + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock) +{ + PHEAP_LOCK HeapLock = ExAllocatePool(NonPagedPool, sizeof(HEAP_LOCK)); + if (HeapLock == NULL) + return STATUS_NO_MEMORY; + + ExInitializeResourceLite(&HeapLock->Resource); + *Lock = HeapLock; + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock) +{ + ExReleaseResourceLite(&Lock->Resource); KeLeaveCriticalRegion(); - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -RtlInitializeHeapLock( - PHEAP_LOCK Lock) -{ - ExInitializeResource(&Lock->Resource); - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -RtlLeaveHeapLock( - PHEAP_LOCK Lock) -{ - KeEnterCriticalRegion(); - ExReleaseResource(&Lock->Resource); - KeLeaveCriticalRegion(); + return STATUS_SUCCESS; }
13 years, 3 months
1
0
0
0
← Newer
1
...
12
13
14
15
16
17
18
...
40
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
Results per page:
10
25
50
100
200