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 2018
----- 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
24 participants
223 discussions
Start a n
N
ew thread
01/01: [FREELDR] Fix MSVC warnings C4146 (#863)
by Extravert-ir
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0e29db1cb61c057d0d67…
commit d0e29db1cb61c057d0d674ad06337d9582ae89c6 Author: Extravert-ir <Extravert34(a)gmail.com> AuthorDate: Sun Sep 16 17:14:07 2018 +0300 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Sep 16 16:14:07 2018 +0200 [FREELDR] Fix MSVC warnings C4146 (#863) --- boot/freeldr/freeldr/lib/fs/btrfs.c | 50 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/boot/freeldr/freeldr/lib/fs/btrfs.c b/boot/freeldr/freeldr/lib/fs/btrfs.c index 7c3aa5c4ce..f3a8619262 100644 --- a/boot/freeldr/freeldr/lib/fs/btrfs.c +++ b/boot/freeldr/freeldr/lib/fs/btrfs.c @@ -18,7 +18,9 @@ DBG_DEFAULT_CHANNEL(FILESYSTEM); #define TAG_BTRFS_FILE 'FftB' #define TAG_BTRFS_LINK 'LftB' -#define INVALID_INODE ((ULONGLONG)-1) +#define INVALID_INODE _UI64_MAX +#define INVALID_ADDRESS _UI64_MAX +#define READ_ERROR _UI64_MAX struct BTRFS_INFO { ULONG DeviceId; @@ -239,9 +241,9 @@ static u64 logical_physical(u64 logical) if (ret == 0) slot++; else if (slot == 0) - return -1; + return INVALID_ADDRESS; if (logical >= chunk_map->map[slot - 1].logical + chunk_map->map[slot - 1].length) - return -1; + return INVALID_ADDRESS; TRACE("Address translation: 0x%llx -> 0x%llx\n", logical, chunk_map->map[slot - 1].physical + logical - chunk_map->map[slot - 1].logical); @@ -408,7 +410,7 @@ static int next_slot(struct btrfs_disk_key *key, } path->slots[0] = slot; - out: +out: if (path_current_disk_key(path)->objectid && !btrfs_comp_keys_type(key, path_current_disk_key(path))) return 0; else @@ -626,7 +628,7 @@ static BOOLEAN BtrFsLookupDirItemI(const struct btrfs_root_item *root, u64 dir_h } while (!next_slot(&key, &path)); - cleanup: +cleanup: free_path(&path); return result; } @@ -652,7 +654,7 @@ static u64 btrfs_read_extent_inline(struct btrfs_path *path, if (offset > dlen) { ERR("Tried to read offset (%llu) beyond extent length (%lu)\n", offset, dlen); - return INVALID_INODE; + return READ_ERROR; } if (size > dlen - offset) @@ -666,7 +668,7 @@ static u64 btrfs_read_extent_inline(struct btrfs_path *path, } ERR("No compression supported right now\n"); - return INVALID_INODE; + return READ_ERROR; } static u64 btrfs_read_extent_reg(struct btrfs_path *path, struct btrfs_file_extent_item *extent, @@ -679,17 +681,17 @@ static u64 btrfs_read_extent_reg(struct btrfs_path *path, struct btrfs_file_exte if (offset > dlen) { ERR("Tried to read offset (%llu) beyond extent length (%lu)\n", offset, dlen); - return -1ULL; + return READ_ERROR; } if (size > dlen - offset) size = dlen - offset; physical = logical_physical(extent->disk_bytenr); - if (physical == -1ULL) + if (physical == INVALID_ADDRESS) { ERR("Unable to convert logical address to physical: %llu\n", extent->disk_bytenr); - return -1ULL; + return READ_ERROR; } if (extent->compression == BTRFS_COMPRESS_NONE) @@ -704,7 +706,7 @@ static u64 btrfs_read_extent_reg(struct btrfs_path *path, struct btrfs_file_exte if (!disk_read(physical, temp_out, size + offset)) { FrLdrTempFree(temp_out, TAG_BTRFS_FILE); - return -1ULL; + return READ_ERROR; } memcpy(out, temp_out + offset, size); @@ -712,14 +714,14 @@ static u64 btrfs_read_extent_reg(struct btrfs_path *path, struct btrfs_file_exte } else { if (!disk_read(physical, out, size)) - return -1ULL; + return READ_ERROR; } return size; } ERR("No compression supported right now\n"); - return -1ULL; + return READ_ERROR; } static u64 btrfs_file_read(const struct btrfs_root_item *root, u64 inr, u64 offset, u64 size, char *buf) @@ -728,7 +730,7 @@ static u64 btrfs_file_read(const struct btrfs_root_item *root, u64 inr, u64 offs struct btrfs_disk_key key; struct btrfs_file_extent_item *extent; int res = 0; - u64 rd, seek_pointer = (u64) -1ULL, offset_in_extent; + u64 rd, seek_pointer = READ_ERROR, offset_in_extent; BOOLEAN find_res; TRACE("btrfs_file_read inr=%llu offset=%llu size=%llu\n", inr, offset, size); @@ -776,10 +778,10 @@ static u64 btrfs_file_read(const struct btrfs_root_item *root, u64 inr, u64 offs rd = btrfs_read_extent_reg(&path, extent, offset_in_extent, size, buf); } - if (rd == -1ULL) + if (rd == READ_ERROR) { ERR("Error while reading extent\n"); - seek_pointer = (u64) -1ULL; + seek_pointer = READ_ERROR; goto out; } @@ -794,12 +796,12 @@ static u64 btrfs_file_read(const struct btrfs_root_item *root, u64 inr, u64 offs if (res) { - seek_pointer = (u64) -1ULL; + seek_pointer = READ_ERROR; goto out; } seek_pointer -= offset; - out: +out: free_path(&path); return seek_pointer; } @@ -814,7 +816,7 @@ static u64 btrfs_lookup_inode_ref(const struct btrfs_root_item *root, u64 inr, { struct btrfs_path path; struct btrfs_inode_ref *ref; - u64 ret = -1ULL; + u64 ret = INVALID_INODE; init_path(&path); if (BtrFsSearchTreeType(root, inr, BTRFS_INODE_REF_KEY, &path)) @@ -915,7 +917,7 @@ static BOOLEAN btrfs_readlink(const struct btrfs_root_item *root, u64 inr, char res = TRUE; - out: +out: free_path(&path); return res; } @@ -1023,7 +1025,7 @@ static u64 btrfs_lookup_path(const struct btrfs_root_item *root, u64 inr, const if (len > BTRFS_NAME_MAX) { ERR("%s: Name too long at \"%.*s\"\n", BTRFS_NAME_MAX, cur); - return -1ULL; + return INVALID_INODE; } if (len == 1 && cur[0] == '.') @@ -1150,7 +1152,7 @@ ARC_STATUS BtrFsOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId) inr = btrfs_lookup_path(&BtrFsInfo->FsRoot, BtrFsInfo->FsRoot.root_dirid, Path, &type, &temp_file_info.inode, 40); - if (inr == -1ULL) + if (inr == INVALID_INODE) { TRACE("Cannot lookup file %s\n", Path); return ENOENT; @@ -1191,7 +1193,7 @@ ARC_STATUS BtrFsRead(ULONG FileId, VOID *Buffer, ULONG Size, ULONG *BytesRead) Size = phandle->inode.size; rd = btrfs_file_read(&BtrFsInfo->FsRoot, phandle->inr, phandle->position, Size, Buffer); - if (rd == -1ULL) + if (rd == READ_ERROR) { TRACE("An error occured while reading file %lu\n", FileId); return ENOENT; @@ -1245,7 +1247,7 @@ const DEVVTBL *BtrFsMount(ULONG DeviceId) return NULL; } - /* Check if SuperBlock is valid. If yes, return Ext2 function table */ + /* Check if SuperBlock is valid. If yes, return BTRFS function table */ if (BtrFsInfo->SuperBlock.magic == BTRFS_MAGIC_N) { BtrFsInfo->DeviceId = DeviceId;
6 years, 3 months
1
0
0
0
01/01: [GITIGNORE] Ignore [boot|live|hybrid]cd_extras (#866)
by BieHDC
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6458e12ffee13c36e4600…
commit 6458e12ffee13c36e46004ad5ef01c44a5401a19 Author: BieHDC <43303168+BieHDC(a)users.noreply.github.com> AuthorDate: Sun Sep 16 16:05:15 2018 +0200 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Sep 16 16:05:15 2018 +0200 [GITIGNORE] Ignore [boot|live|hybrid]cd_extras (#866) Exclude [boot|live|hybrid]cd_extras from git as well since they are not part of the source code itself. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a9817100ac..1e7e8dc7bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ output-* modules/optional +modules/bootcd_extras +modules/livecd_extras +modules/hybridcd_extras
6 years, 3 months
1
0
0
0
01/01: [KERNEL32_VISTA] Make SleepConditionVariableSRW fail when it times out
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c5b0fbff3ffa86a435e2…
commit 8c5b0fbff3ffa86a435e28d11d7fbfb54e6f421c Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 16 14:50:01 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 16 14:50:01 2018 +0200 [KERNEL32_VISTA] Make SleepConditionVariableSRW fail when it times out This fixes a few newly added winetests. --- dll/win32/kernel32_vista/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/win32/kernel32_vista/sync.c b/dll/win32/kernel32_vista/sync.c index 57fc81a333..d8be19c52d 100644 --- a/dll/win32/kernel32_vista/sync.c +++ b/dll/win32/kernel32_vista/sync.c @@ -124,7 +124,7 @@ SleepConditionVariableSRW(PCONDITION_VARIABLE ConditionVariable, PSRWLOCK Lock, LARGE_INTEGER Time; Status = RtlSleepConditionVariableSRW(ConditionVariable, Lock, GetNtTimeout(&Time, Timeout), Flags); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE;
6 years, 3 months
1
0
0
0
01/01: [KERNEL32_VISTA] Make SleepConditionVariableCS fail when it times out
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58853297dc98ddfceac6f…
commit 58853297dc98ddfceac6f0ebc28522072b453b82 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 16 14:42:43 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 16 14:42:43 2018 +0200 [KERNEL32_VISTA] Make SleepConditionVariableCS fail when it times out This fixes a few newly added winetests. --- dll/win32/kernel32_vista/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/win32/kernel32_vista/sync.c b/dll/win32/kernel32_vista/sync.c index 1f13206445..57fc81a333 100644 --- a/dll/win32/kernel32_vista/sync.c +++ b/dll/win32/kernel32_vista/sync.c @@ -108,7 +108,7 @@ SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTIO LARGE_INTEGER Time; Status = RtlSleepConditionVariableCS(ConditionVariable, (PRTL_CRITICAL_SECTION)CriticalSection, GetNtTimeout(&Time, Timeout)); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE;
6 years, 3 months
1
0
0
0
01/01: [KERNEL32_WINETEST] Enable ConditionVariable and SRW lock tests
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d69a00e0393906320cd57…
commit d69a00e0393906320cd572b642f08e1d8f611e1e Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 16 12:03:08 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 16 12:05:42 2018 +0200 [KERNEL32_WINETEST] Enable ConditionVariable and SRW lock tests If we cannot find the functions in kernel32, try to get them from kernel32_vista. This will allow testing our own implementation, while still failing in W2K3 (no implementation available). --- modules/rostests/winetests/kernel32/sync.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/rostests/winetests/kernel32/sync.c b/modules/rostests/winetests/kernel32/sync.c index fb368de405..0de706bd26 100644 --- a/modules/rostests/winetests/kernel32/sync.c +++ b/modules/rostests/winetests/kernel32/sync.c @@ -2644,6 +2644,9 @@ START_TEST(sync) int argc; HMODULE hdll = GetModuleHandleA("kernel32.dll"); HMODULE hntdll = GetModuleHandleA("ntdll.dll"); +#ifdef __REACTOS__ + HMODULE hdll_vista = GetModuleHandleA("kernel32_vista.dll"); +#endif pInitOnceInitialize = (void *)GetProcAddress(hdll, "InitOnceInitialize"); pInitOnceExecuteOnce = (void *)GetProcAddress(hdll, "InitOnceExecuteOnce"); @@ -2668,6 +2671,28 @@ START_TEST(sync) pRtlInterlockedPushListSList = (void *)GetProcAddress(hntdll, "RtlInterlockedPushListSList"); pRtlInterlockedPushListSListEx = (void *)GetProcAddress(hntdll, "RtlInterlockedPushListSListEx"); +#ifdef __REACTOS__ + if (!pInitializeConditionVariable) + { + pInitializeConditionVariable = (void *)GetProcAddress(hdll_vista, "InitializeConditionVariable"); + pSleepConditionVariableCS = (void *)GetProcAddress(hdll_vista, "SleepConditionVariableCS"); + pSleepConditionVariableSRW = (void *)GetProcAddress(hdll_vista, "SleepConditionVariableSRW"); + pWakeAllConditionVariable = (void *)GetProcAddress(hdll_vista, "WakeAllConditionVariable"); + pWakeConditionVariable = (void *)GetProcAddress(hdll_vista, "WakeConditionVariable"); + } + + if (!pInitializeSRWLock) + { + pInitializeSRWLock = (void *)GetProcAddress(hdll_vista, "InitializeSRWLock"); + pAcquireSRWLockExclusive = (void *)GetProcAddress(hdll_vista, "AcquireSRWLockExclusive"); + pAcquireSRWLockShared = (void *)GetProcAddress(hdll_vista, "AcquireSRWLockShared"); + pReleaseSRWLockExclusive = (void *)GetProcAddress(hdll_vista, "ReleaseSRWLockExclusive"); + pReleaseSRWLockShared = (void *)GetProcAddress(hdll_vista, "ReleaseSRWLockShared"); + pTryAcquireSRWLockExclusive = (void *)GetProcAddress(hdll_vista, "TryAcquireSRWLockExclusive"); + pTryAcquireSRWLockShared = (void *)GetProcAddress(hdll_vista, "TryAcquireSRWLockShared"); + } +#endif + argc = winetest_get_mainargs( &argv ); if (argc >= 3) {
6 years, 3 months
1
0
0
0
01/01: [RAMDISK] Implement missing IOCTLs
by Bernhard Feichtinger
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9d1ee2400a64f14764edd…
commit 9d1ee2400a64f14764edda1199828dd8467c62eb Author: Bernhard Feichtinger <43303168+BieHDC(a)users.noreply.github.com> AuthorDate: Sat Sep 15 23:08:30 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 16 11:46:24 2018 +0200 [RAMDISK] Implement missing IOCTLs --- drivers/storage/class/ramdisk/ramdisk.c | 64 ++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/drivers/storage/class/ramdisk/ramdisk.c b/drivers/storage/class/ramdisk/ramdisk.c index 0bef2ef247..de6d2d5ca1 100644 --- a/drivers/storage/class/ramdisk/ramdisk.c +++ b/drivers/storage/class/ramdisk/ramdisk.c @@ -702,7 +702,7 @@ RamdiskCreateRamdisk(IN PDEVICE_OBJECT DeviceObject, Irp->IoStatus.Information = STATUS_SUCCESS; } - /* We're done */ + /* We are done */ return Status; } @@ -1025,7 +1025,7 @@ DoCopy: CurrentOffset.QuadPart += BytesRead; CurrentBase = (PVOID)((ULONG_PTR)CurrentBase + BytesRead); - /* Check if we're done */ + /* Check if we are done */ if (!BytesLeft) return Status; } } @@ -1195,7 +1195,7 @@ RamdiskDeviceControl(IN PDEVICE_OBJECT DeviceObject, DiskGeometry->MediaType = DriveExtension->DiskOptions.Fixed ? FixedMedia : RemovableMedia; - /* We're done */ + /* We are done */ Status = STATUS_SUCCESS; Information = sizeof(DISK_GEOMETRY); break; @@ -1225,7 +1225,7 @@ RamdiskDeviceControl(IN PDEVICE_OBJECT DeviceObject, Toc->TrackData[0].Control = TOC_DATA_TRACK; Toc->TrackData[0].TrackNumber = 1; - /* We're done */ + /* We are done */ Status = STATUS_SUCCESS; Information = RAMDISK_TOC_SIZE; break; @@ -1260,13 +1260,62 @@ RamdiskDeviceControl(IN PDEVICE_OBJECT DeviceObject, goto CallWorker; } - /* We're done */ + /* We are done */ Information = Irp->IoStatus.Information; break; } - case IOCTL_DISK_GET_DRIVE_LAYOUT: case IOCTL_DISK_GET_LENGTH_INFO: + { + PGET_LENGTH_INFORMATION LengthInformation = Irp->AssociatedIrp.SystemBuffer; + + /* Validate the length */ + if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GET_LENGTH_INFORMATION)) + { + /* Invalid length */ + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + /* Fill it out */ + LengthInformation->Length = DriveExtension->DiskLength; + + /* We are done */ + Status = STATUS_SUCCESS; + Information = sizeof(GET_LENGTH_INFORMATION); + break; + } + case IOCTL_VOLUME_GET_GPT_ATTRIBUTES: + { + PVOLUME_GET_GPT_ATTRIBUTES_INFORMATION GptInformation; + + /* Validate the length */ + if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(VOLUME_GET_GPT_ATTRIBUTES_INFORMATION)) + { + /* Invalid length */ + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + /* Fill it out */ + GptInformation = Irp->AssociatedIrp.SystemBuffer; + GptInformation->GptAttributes = 0; + + /* Translate the Attributes */ + if (DriveExtension->DiskOptions.Readonly) + GptInformation->GptAttributes |= GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY; + if (DriveExtension->DiskOptions.Hidden) + GptInformation->GptAttributes |= GPT_BASIC_DATA_ATTRIBUTE_HIDDEN; + if (DriveExtension->DiskOptions.NoDriveLetter) + GptInformation->GptAttributes |= GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER; + + /* We are done */ + Status = STATUS_SUCCESS; + Information = sizeof(VOLUME_GET_GPT_ATTRIBUTES_INFORMATION); + break; + } + + case IOCTL_DISK_GET_DRIVE_LAYOUT: case IOCTL_DISK_IS_WRITABLE: case IOCTL_SCSI_MINIPORT: case IOCTL_STORAGE_QUERY_PROPERTY: @@ -1274,7 +1323,6 @@ RamdiskDeviceControl(IN PDEVICE_OBJECT DeviceObject, case IOCTL_MOUNTDEV_QUERY_STABLE_GUID: case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS: case IOCTL_VOLUME_SET_GPT_ATTRIBUTES: - case IOCTL_VOLUME_GET_GPT_ATTRIBUTES: case IOCTL_VOLUME_OFFLINE: { UNIMPLEMENTED_DBGBREAK("IOCTL: 0x%lx is UNIMPLEMENTED!\n", @@ -2456,7 +2504,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, Status = RamdiskAddDevice(DriverObject, PhysicalDeviceObject); if (NT_SUCCESS(Status)) { - /* We're done */ + /* We are done */ PhysicalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; Status = STATUS_SUCCESS; }
6 years, 3 months
1
0
0
0
04/04: [KERNEL32] Ensure the PebLock is always released in FlsFree
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12654d28522a70618de16…
commit 12654d28522a70618de162912f6a97c3e59c0ff1 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Fri May 11 22:23:52 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Sep 15 17:56:03 2018 +0200 [KERNEL32] Ensure the PebLock is always released in FlsFree --- dll/win32/kernel32/client/fiber.c | 56 ++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/dll/win32/kernel32/client/fiber.c b/dll/win32/kernel32/client/fiber.c index 47d2616e66..1b1e1e37ac 100644 --- a/dll/win32/kernel32/client/fiber.c +++ b/dll/win32/kernel32/client/fiber.c @@ -1,12 +1,12 @@ /* - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS System Libraries - * FILE: dll/win32/kernel32/client/fiber.c + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Fiber Implementation - * PROGRAMMERS: - * Alex Ionescu (alex(a)relsoft.net) - * KJK::Hyperion <noog(a)libero.it> + * COPYRIGHT: Copyright 2005-2011 Alex Ionescu (alex(a)relsoft.net) + * Copyright 2003-2008 KJK::Hyperion (noog(a)libero.it) + * Copyright 2018 Mark Jansen (mark.jansen(a)reactos.org) */ + #include <k32.h> #include <ndk/rtltypes.h> @@ -410,36 +410,44 @@ FlsFree(DWORD dwFlsIndex) RtlAcquirePebLock(); - ret = RtlAreBitsSet(Peb->FlsBitmap, dwFlsIndex, 1); - if (ret) + _SEH2_TRY { - PLIST_ENTRY Entry; - PFLS_CALLBACK_FUNCTION lpCallback; - - RtlClearBits(Peb->FlsBitmap, dwFlsIndex, 1); - lpCallback = Peb->FlsCallback[dwFlsIndex]; - Peb->FlsCallback[dwFlsIndex] = NULL; - - for (Entry = Peb->FlsListHead.Flink; Entry != &Peb->FlsListHead; Entry = Entry->Flink) + ret = RtlAreBitsSet(Peb->FlsBitmap, dwFlsIndex, 1); + if (ret) { - PRTL_FLS_DATA pFlsData; + PLIST_ENTRY Entry; + PFLS_CALLBACK_FUNCTION lpCallback; + + RtlClearBits(Peb->FlsBitmap, dwFlsIndex, 1); + lpCallback = Peb->FlsCallback[dwFlsIndex]; - pFlsData = CONTAINING_RECORD(Entry, RTL_FLS_DATA, ListEntry); - if (pFlsData->Data[dwFlsIndex]) + for (Entry = Peb->FlsListHead.Flink; Entry != &Peb->FlsListHead; Entry = Entry->Flink) { - if (lpCallback) + PRTL_FLS_DATA pFlsData; + + pFlsData = CONTAINING_RECORD(Entry, RTL_FLS_DATA, ListEntry); + if (pFlsData->Data[dwFlsIndex]) { - lpCallback(pFlsData->Data[dwFlsIndex]); + if (lpCallback) + { + lpCallback(pFlsData->Data[dwFlsIndex]); + } + pFlsData->Data[dwFlsIndex] = NULL; } - pFlsData->Data[dwFlsIndex] = NULL; } + Peb->FlsCallback[dwFlsIndex] = NULL; + } + else + { + SetLastError(ERROR_INVALID_PARAMETER); } } - else + _SEH2_FINALLY { - SetLastError(ERROR_INVALID_PARAMETER); + RtlReleasePebLock(); } - RtlReleasePebLock(); + _SEH2_END; + return ret; }
6 years, 3 months
1
0
0
0
03/04: [KERNEL32_APITEST] Test FLS locking & exception behavior.
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b6e3cf3c03633effca22e…
commit b6e3cf3c03633effca22e9a2605187f8ea13f2d8 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Fri May 11 22:22:47 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Sep 15 17:56:03 2018 +0200 [KERNEL32_APITEST] Test FLS locking & exception behavior. --- modules/rostests/apitests/kernel32/FLS.c | 84 +++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/modules/rostests/apitests/kernel32/FLS.c b/modules/rostests/apitests/kernel32/FLS.c index 769b5be597..3d40df7608 100644 --- a/modules/rostests/apitests/kernel32/FLS.c +++ b/modules/rostests/apitests/kernel32/FLS.c @@ -24,6 +24,10 @@ PVOID g_FlsData1 = NULL; LONG g_FlsCalled1 = 0; PVOID g_FlsData2 = NULL; LONG g_FlsCalled2 = 0; +PVOID g_FlsData3 = NULL; +LONG g_FlsCalled3 = 0; +BOOL g_FlsExcept3 = FALSE; + VOID WINAPI FlsCallback1(PVOID lpFlsData) { @@ -37,6 +41,18 @@ VOID WINAPI FlsCallback2(PVOID lpFlsData) InterlockedIncrement(&g_FlsCalled2); } +VOID WINAPI FlsCallback3(PVOID lpFlsData) +{ + ok(lpFlsData == g_FlsData3, "Expected g_FlsData3(%p), got %p\n", g_FlsData3, lpFlsData); + + if (g_WinVersion <= WINVER_2003) + ok(RtlIsCriticalSectionLockedByThread(NtCurrentPeb()->FastPebLock), "Expected lock on PEB\n"); + InterlockedIncrement(&g_FlsCalled3); + if (g_FlsExcept3) + { + RaiseException(ERROR_INVALID_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, NULL); + } +} typedef struct _FLS_CALLBACK_INFO { @@ -78,11 +94,14 @@ void ok_fls_(DWORD dwIndex, PVOID pValue, PFLS_CALLBACK_FUNCTION lpCallback) dwIndex, lpCallback, FlsCallback[dwIndex].lpCallback); - winetest_ok(FlsCallback[dwIndex].Unknown == NULL, - "Expected FlsCallback[%lu].Unknown to be %p, was %p\n", - dwIndex, - NULL, - FlsCallback[dwIndex].Unknown); + if (lpCallback != &FlsCallback3 || !g_FlsExcept3) + { + winetest_ok(FlsCallback[dwIndex].Unknown == NULL, + "Expected FlsCallback[%lu].Unknown to be %p, was %p\n", + dwIndex, + NULL, + FlsCallback[dwIndex].Unknown); + } } winetest_ok(FlsData[dwIndex + 2] == pValue, "Expected FlsData[%lu + 2] to be %p, was %p\n", @@ -113,7 +132,8 @@ static VOID init_funcs(void) START_TEST(FLS) { RTL_OSVERSIONINFOW rtlinfo = { sizeof(rtlinfo) }; - DWORD dwIndex1, dwIndex2; + DWORD dwIndex1, dwIndex2, dwIndex3, dwErr; + BOOL bRet; init_funcs(); if (!pFlsAlloc || !pFlsFree || !pFlsGetValue || !pFlsSetValue) @@ -131,7 +151,11 @@ START_TEST(FLS) ok(dwIndex2 != FLS_OUT_OF_INDEXES, "Unable to allocate FLS index\n"); ok(dwIndex1 != dwIndex2, "Expected different indexes, got %lu\n", dwIndex1); - if (dwIndex1 == FLS_OUT_OF_INDEXES || dwIndex2 == FLS_OUT_OF_INDEXES) + dwIndex3 = pFlsAlloc(FlsCallback3); + ok(dwIndex3 != FLS_OUT_OF_INDEXES, "Unable to allocate FLS index\n"); + ok(dwIndex1 != dwIndex3, "Expected different indexes, got %lu\n", dwIndex1); + + if (dwIndex1 == FLS_OUT_OF_INDEXES || dwIndex2 == FLS_OUT_OF_INDEXES || dwIndex3 == FLS_OUT_OF_INDEXES) { skip("Unable to continue test\n"); return; @@ -139,31 +163,75 @@ START_TEST(FLS) ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); g_FlsData1 = (PVOID)0x123456; ok(pFlsSetValue(dwIndex1, g_FlsData1), "FlsSetValue(%lu, %p) failed\n", dwIndex1, g_FlsData1); ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); ok_int(g_FlsCalled1, 0); ok_int(g_FlsCalled2, 0); + ok_int(g_FlsCalled3, 0); g_FlsData2 = (PVOID)0x9876112; ok(pFlsSetValue(dwIndex2, g_FlsData2), "FlsSetValue(%lu, %p) failed\n", dwIndex2, g_FlsData2); ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); + ok_int(g_FlsCalled1, 0); ok_int(g_FlsCalled2, 0); + ok_int(g_FlsCalled3, 0); - ok(pFlsFree(dwIndex1), "FlsFree(%lu) failed\n", dwIndex1); + g_FlsData3 = (PVOID)0x98762; + ok(pFlsSetValue(dwIndex3, g_FlsData3), "FlsSetValue(%lu, %p) failed\n", dwIndex3, g_FlsData3); + + ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); + + ok_int(g_FlsCalled1, 0); + ok_int(g_FlsCalled2, 0); + ok_int(g_FlsCalled3, 0); + + ok(pFlsFree(dwIndex1) == TRUE, "FlsFree(%lu) failed\n", dwIndex1); g_FlsData1 = NULL; ok_fls(dwIndex1, g_FlsData1, NULL); ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); + + ok_int(g_FlsCalled1, 1); + ok_int(g_FlsCalled2, 0); + ok_int(g_FlsCalled3, 0); + + g_FlsExcept3 = TRUE; + _SEH2_TRY + { + bRet = pFlsFree(dwIndex3); + dwErr = GetLastError(); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + bRet = 12345; + dwErr = 0xdeaddead; + } + _SEH2_END; + ok(RtlIsCriticalSectionLockedByThread(NtCurrentPeb()->FastPebLock) == FALSE, "Expected no lock on PEB\n"); + + ok(bRet == 12345, "FlsFree(%lu) should have failed, got %u\n", dwIndex3, bRet); + ok(dwErr == 0xdeaddead, "Expected GetLastError() to be 0xdeaddead, was %lx\n", dwErr); + + ok_fls(dwIndex1, g_FlsData1, NULL); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + ok_fls(dwIndex3, g_FlsData3, &FlsCallback3); ok_int(g_FlsCalled1, 1); ok_int(g_FlsCalled2, 0); + ok_int(g_FlsCalled3, 1); }
6 years, 3 months
1
0
0
0
02/04: [NTDLL][KERNEL32] Implement FLS callbacks.
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=06eb99edefc821c932492…
commit 06eb99edefc821c9324923eae9eeebf0cf6f9d48 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Thu May 10 22:23:16 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Sep 15 17:56:03 2018 +0200 [NTDLL][KERNEL32] Implement FLS callbacks. --- dll/ntdll/ldr/ldrinit.c | 26 +++++++++- dll/win32/kernel32/client/fiber.c | 101 ++++++++++++++++++++++++++++---------- sdk/include/ndk/rtltypes.h | 11 +++++ 3 files changed, 109 insertions(+), 29 deletions(-) diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c index 14f0272dd3..e40db1717a 100644 --- a/dll/ntdll/ldr/ldrinit.c +++ b/dll/ntdll/ldr/ldrinit.c @@ -1207,8 +1207,29 @@ LdrShutdownThread(VOID) /* Check for FLS Data */ if (Teb->FlsData) { - /* FIXME */ - DPRINT1("We don't support FLS Data yet\n"); + /* Mimic BaseRundownFls */ + ULONG n, FlsHighIndex; + PRTL_FLS_DATA pFlsData; + PFLS_CALLBACK_FUNCTION lpCallback; + + pFlsData = Teb->FlsData; + + RtlAcquirePebLock(); + FlsHighIndex = NtCurrentPeb()->FlsHighIndex; + RemoveEntryList(&pFlsData->ListEntry); + RtlReleasePebLock(); + + for (n = 1; n <= FlsHighIndex; ++n) + { + lpCallback = NtCurrentPeb()->FlsCallback[n]; + if (lpCallback && pFlsData->Data[n]) + { + lpCallback(pFlsData->Data[n]); + } + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, pFlsData); + Teb->FlsData = NULL; } /* Check for Fiber data */ @@ -1786,6 +1807,7 @@ LdrpInitializeProcess(IN PCONTEXT Context, Peb->FlsBitmapBits, FLS_MAXIMUM_AVAILABLE); RtlSetBit(&FlsBitMap, 0); + InitializeListHead(&Peb->FlsListHead); /* Initialize TLS Bitmap */ RtlInitializeBitMap(&TlsBitMap, diff --git a/dll/win32/kernel32/client/fiber.c b/dll/win32/kernel32/client/fiber.c index a3a38ecd7f..47d2616e66 100644 --- a/dll/win32/kernel32/client/fiber.c +++ b/dll/win32/kernel32/client/fiber.c @@ -8,6 +8,7 @@ * KJK::Hyperion <noog(a)libero.it> */ #include <k32.h> +#include <ndk/rtltypes.h> #define NDEBUG #include <debug.h> @@ -21,6 +22,7 @@ C_ASSERT(FIELD_OFFSET(FIBER, FiberContext) == 0x14); C_ASSERT(FIELD_OFFSET(FIBER, GuaranteedStackBytes) == 0x2E0); C_ASSERT(FIELD_OFFSET(FIBER, FlsData) == 0x2E4); C_ASSERT(FIELD_OFFSET(FIBER, ActivationContextStackPointer) == 0x2E8); +C_ASSERT(RTL_FLS_MAXIMUM_AVAILABLE == FLS_MAXIMUM_AVAILABLE); #endif // _M_IX86 /* PRIVATE FUNCTIONS **********************************************************/ @@ -29,7 +31,27 @@ VOID WINAPI BaseRundownFls(_In_ PVOID FlsData) { - /* No FLS support yet */ + ULONG n, FlsHighIndex; + PRTL_FLS_DATA pFlsData; + PFLS_CALLBACK_FUNCTION lpCallback; + + pFlsData = FlsData; + + RtlAcquirePebLock(); + FlsHighIndex = NtCurrentPeb()->FlsHighIndex; + RemoveEntryList(&pFlsData->ListEntry); + RtlReleasePebLock(); + + for (n = 1; n <= FlsHighIndex; ++n) + { + lpCallback = NtCurrentPeb()->FlsCallback[n]; + if (lpCallback && pFlsData->Data[n]) + { + lpCallback(pFlsData->Data[n]); + } + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, FlsData); } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -61,7 +83,7 @@ ConvertFiberToThread(VOID) /* Free the fiber */ ASSERT(FiberData != NULL); - RtlFreeHeap(GetProcessHeap(), + RtlFreeHeap(RtlGetProcessHeap(), 0, FiberData); @@ -295,7 +317,7 @@ DeleteFiber(_In_ LPVOID lpFiber) RtlFreeActivationContextStack(Fiber->ActivationContextStackPointer); /* Free the fiber data */ - RtlFreeHeap(GetProcessHeap(), + RtlFreeHeap(RtlGetProcessHeap(), 0, lpFiber); } @@ -320,11 +342,11 @@ FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback) { DWORD dwFlsIndex; PPEB Peb = NtCurrentPeb(); - PVOID *ppFlsSlots; + PRTL_FLS_DATA pFlsData; RtlAcquirePebLock(); - ppFlsSlots = NtCurrentTeb()->FlsData; + pFlsData = NtCurrentTeb()->FlsData; if (!Peb->FlsCallback && !(Peb->FlsCallback = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, @@ -338,9 +360,8 @@ FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback) dwFlsIndex = RtlFindClearBitsAndSet(Peb->FlsBitmap, 1, 1); if (dwFlsIndex != FLS_OUT_OF_INDEXES) { - if (!ppFlsSlots && - !(ppFlsSlots = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, - (FLS_MAXIMUM_AVAILABLE + 2) * sizeof(PVOID)))) + if (!pFlsData && + !(pFlsData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RTL_FLS_DATA)))) { RtlClearBits(Peb->FlsBitmap, dwFlsIndex, 1); dwFlsIndex = FLS_OUT_OF_INDEXES; @@ -349,13 +370,16 @@ FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback) else { if (!NtCurrentTeb()->FlsData) - NtCurrentTeb()->FlsData = ppFlsSlots; + { + NtCurrentTeb()->FlsData = pFlsData; + InsertTailList(&Peb->FlsListHead, &pFlsData->ListEntry); + } - if (lpCallback) - DPRINT1("FlsAlloc: Got lpCallback 0x%p, UNIMPLEMENTED!\n", lpCallback); - - ppFlsSlots[dwFlsIndex + 2] = NULL; /* clear the value */ + pFlsData->Data[dwFlsIndex] = NULL; /* clear the value */ Peb->FlsCallback[dwFlsIndex] = lpCallback; + + if (dwFlsIndex > Peb->FlsHighIndex) + Peb->FlsHighIndex = dwFlsIndex; } } else @@ -377,7 +401,6 @@ FlsFree(DWORD dwFlsIndex) { BOOL ret; PPEB Peb = NtCurrentPeb(); - PVOID *ppFlsSlots; if (dwFlsIndex >= FLS_MAXIMUM_AVAILABLE) { @@ -387,15 +410,30 @@ FlsFree(DWORD dwFlsIndex) RtlAcquirePebLock(); - ppFlsSlots = NtCurrentTeb()->FlsData; ret = RtlAreBitsSet(Peb->FlsBitmap, dwFlsIndex, 1); if (ret) { + PLIST_ENTRY Entry; + PFLS_CALLBACK_FUNCTION lpCallback; + RtlClearBits(Peb->FlsBitmap, dwFlsIndex, 1); - /* FIXME: call Fls callback */ - /* FIXME: add equivalent of ThreadZeroTlsCell here */ - if (ppFlsSlots) - ppFlsSlots[dwFlsIndex + 2] = NULL; + lpCallback = Peb->FlsCallback[dwFlsIndex]; + Peb->FlsCallback[dwFlsIndex] = NULL; + + for (Entry = Peb->FlsListHead.Flink; Entry != &Peb->FlsListHead; Entry = Entry->Flink) + { + PRTL_FLS_DATA pFlsData; + + pFlsData = CONTAINING_RECORD(Entry, RTL_FLS_DATA, ListEntry); + if (pFlsData->Data[dwFlsIndex]) + { + if (lpCallback) + { + lpCallback(pFlsData->Data[dwFlsIndex]); + } + pFlsData->Data[dwFlsIndex] = NULL; + } + } } else { @@ -413,17 +451,17 @@ PVOID WINAPI FlsGetValue(DWORD dwFlsIndex) { - PVOID *ppFlsSlots; + PRTL_FLS_DATA pFlsData; - ppFlsSlots = NtCurrentTeb()->FlsData; - if (!dwFlsIndex || dwFlsIndex >= FLS_MAXIMUM_AVAILABLE || !ppFlsSlots) + pFlsData = NtCurrentTeb()->FlsData; + if (!dwFlsIndex || dwFlsIndex >= FLS_MAXIMUM_AVAILABLE || !pFlsData) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } SetLastError(ERROR_SUCCESS); - return ppFlsSlots[dwFlsIndex + 2]; + return pFlsData->Data[dwFlsIndex]; } @@ -435,22 +473,31 @@ WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData) { - PVOID *ppFlsSlots; + PRTL_FLS_DATA pFlsData; if (!dwFlsIndex || dwFlsIndex >= FLS_MAXIMUM_AVAILABLE) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + + pFlsData = NtCurrentTeb()->FlsData; + if (!NtCurrentTeb()->FlsData && !(NtCurrentTeb()->FlsData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, - (FLS_MAXIMUM_AVAILABLE + 2) * sizeof(PVOID)))) + sizeof(RTL_FLS_DATA)))) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - ppFlsSlots = NtCurrentTeb()->FlsData; - ppFlsSlots[dwFlsIndex + 2] = lpFlsData; + if (!pFlsData) + { + pFlsData = NtCurrentTeb()->FlsData; + RtlAcquirePebLock(); + InsertTailList(&NtCurrentPeb()->FlsListHead, &pFlsData->ListEntry); + RtlReleasePebLock(); + } + pFlsData->Data[dwFlsIndex] = lpFlsData; return TRUE; } diff --git a/sdk/include/ndk/rtltypes.h b/sdk/include/ndk/rtltypes.h index 7070564389..02d65a2971 100644 --- a/sdk/include/ndk/rtltypes.h +++ b/sdk/include/ndk/rtltypes.h @@ -1210,6 +1210,17 @@ typedef struct _RTL_DEBUG_INFORMATION PVOID Reserved[4]; } RTL_DEBUG_INFORMATION, *PRTL_DEBUG_INFORMATION; +// +// Fiber local storage data +// +#define RTL_FLS_MAXIMUM_AVAILABLE 128 +typedef struct _RTL_FLS_DATA +{ + LIST_ENTRY ListEntry; + PVOID Data[RTL_FLS_MAXIMUM_AVAILABLE]; +} RTL_FLS_DATA, *PRTL_FLS_DATA; + + // // Unload Event Trace Structure for RtlGetUnloadEventTrace //
6 years, 3 months
1
0
0
0
01/04: [KERNEL32_APITEST] Add test exposing FLS internals.
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f0f8f1c7d907f5fa27ad7…
commit f0f8f1c7d907f5fa27ad7848e6ba9e82a9117361 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Tue May 8 22:09:04 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Sep 15 17:55:57 2018 +0200 [KERNEL32_APITEST] Add test exposing FLS internals. --- modules/rostests/apitests/kernel32/CMakeLists.txt | 1 + modules/rostests/apitests/kernel32/FLS.c | 169 ++++++++++++++++++++++ modules/rostests/apitests/kernel32/testlist.c | 2 + 3 files changed, 172 insertions(+) diff --git a/modules/rostests/apitests/kernel32/CMakeLists.txt b/modules/rostests/apitests/kernel32/CMakeLists.txt index 37c5b6adc8..455ee37920 100644 --- a/modules/rostests/apitests/kernel32/CMakeLists.txt +++ b/modules/rostests/apitests/kernel32/CMakeLists.txt @@ -11,6 +11,7 @@ list(APPEND SOURCE dosdev.c FindActCtxSectionStringW.c FindFiles.c + FLS.c FormatMessage.c GetComputerNameEx.c GetCurrentDirectory.c diff --git a/modules/rostests/apitests/kernel32/FLS.c b/modules/rostests/apitests/kernel32/FLS.c new file mode 100644 index 0000000000..769b5be597 --- /dev/null +++ b/modules/rostests/apitests/kernel32/FLS.c @@ -0,0 +1,169 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Tests for FLS implementation details + * COPYRIGHT: Copyright 2018 Mark Jansen (mark.jansen(a)reactos.org) + */ + +#include "precomp.h" +#include <ndk/pstypes.h> +#include <ndk/rtlfuncs.h> + +/* XP does not have these functions */ +static DWORD (WINAPI *pFlsAlloc)(PFLS_CALLBACK_FUNCTION); +static BOOL (WINAPI *pFlsFree)(DWORD); +static PVOID (WINAPI *pFlsGetValue)(DWORD); +static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID); + + +#define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock) +#define WINVER_2003 0x0502 + +static DWORD g_WinVersion = 0; +PVOID g_FlsData1 = NULL; +LONG g_FlsCalled1 = 0; +PVOID g_FlsData2 = NULL; +LONG g_FlsCalled2 = 0; + +VOID WINAPI FlsCallback1(PVOID lpFlsData) +{ + ok(lpFlsData == g_FlsData1, "Expected g_FlsData1(%p), got %p\n", g_FlsData1, lpFlsData); + InterlockedIncrement(&g_FlsCalled1); +} + +VOID WINAPI FlsCallback2(PVOID lpFlsData) +{ + ok(lpFlsData == g_FlsData2, "Expected g_FlsData2(%p), got %p\n", g_FlsData2, lpFlsData); + InterlockedIncrement(&g_FlsCalled2); +} + + +typedef struct _FLS_CALLBACK_INFO +{ + PFLS_CALLBACK_FUNCTION lpCallback; + PVOID Unknown; +} FLS_CALLBACK_INFO, *PFLS_CALLBACK_INFO; + + +void ok_fls_(DWORD dwIndex, PVOID pValue, PFLS_CALLBACK_FUNCTION lpCallback) +{ + PFLS_CALLBACK_INFO FlsCallback; + PVOID* FlsData; + PVOID gotValue; + + FlsCallback = (PFLS_CALLBACK_INFO)NtCurrentPeb()->FlsCallback; + FlsData = (PVOID*)NtCurrentTeb()->FlsData; + + winetest_ok(FlsData != NULL, "Expected FlsData\n"); + winetest_ok(FlsCallback != NULL, "Expected FlsCallback\n"); + + if (FlsData == NULL || FlsCallback == NULL) + { + winetest_skip("Unable to continue test\n"); + return; + } + + if (g_WinVersion <= WINVER_2003) + { + winetest_ok(NtCurrentPeb()->FlsCallback[dwIndex] == lpCallback, + "Expected NtCurrentPeb()->FlsCallback[%lu] to be %p, was %p\n", + dwIndex, + lpCallback, + NtCurrentPeb()->FlsCallback[dwIndex]); + } + else + { + winetest_ok(FlsCallback[dwIndex].lpCallback == lpCallback, + "Expected FlsCallback[%lu].lpCallback to be %p, was %p\n", + dwIndex, + lpCallback, + FlsCallback[dwIndex].lpCallback); + winetest_ok(FlsCallback[dwIndex].Unknown == NULL, + "Expected FlsCallback[%lu].Unknown to be %p, was %p\n", + dwIndex, + NULL, + FlsCallback[dwIndex].Unknown); + } + winetest_ok(FlsData[dwIndex + 2] == pValue, + "Expected FlsData[%lu + 2] to be %p, was %p\n", + dwIndex, + pValue, + FlsData[dwIndex + 2]); + + gotValue = pFlsGetValue(dwIndex); + winetest_ok(gotValue == pValue, "Expected FlsGetValue(%lu) to be %p, was %p\n", dwIndex, pValue, gotValue); +} + +#define ok_fls (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_fls_ + +static VOID init_funcs(void) +{ + HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); + +#define X(f) p##f = (void*)GetProcAddress(hKernel32, #f); + X(FlsAlloc); + X(FlsFree); + X(FlsGetValue); + X(FlsSetValue); +#undef X +} + + + +START_TEST(FLS) +{ + RTL_OSVERSIONINFOW rtlinfo = { sizeof(rtlinfo) }; + DWORD dwIndex1, dwIndex2; + + init_funcs(); + if (!pFlsAlloc || !pFlsFree || !pFlsGetValue || !pFlsSetValue) + { + skip("Fls functions not available\n"); + return; + } + + RtlGetVersion(&rtlinfo); + g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion; + + dwIndex1 = pFlsAlloc(FlsCallback1); + ok(dwIndex1 != FLS_OUT_OF_INDEXES, "Unable to allocate FLS index\n"); + dwIndex2 = pFlsAlloc(FlsCallback2); + ok(dwIndex2 != FLS_OUT_OF_INDEXES, "Unable to allocate FLS index\n"); + ok(dwIndex1 != dwIndex2, "Expected different indexes, got %lu\n", dwIndex1); + + if (dwIndex1 == FLS_OUT_OF_INDEXES || dwIndex2 == FLS_OUT_OF_INDEXES) + { + skip("Unable to continue test\n"); + return; + } + + ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + + g_FlsData1 = (PVOID)0x123456; + ok(pFlsSetValue(dwIndex1, g_FlsData1), "FlsSetValue(%lu, %p) failed\n", dwIndex1, g_FlsData1); + + ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + + ok_int(g_FlsCalled1, 0); + ok_int(g_FlsCalled2, 0); + + g_FlsData2 = (PVOID)0x9876112; + ok(pFlsSetValue(dwIndex2, g_FlsData2), "FlsSetValue(%lu, %p) failed\n", dwIndex2, g_FlsData2); + + ok_fls(dwIndex1, g_FlsData1, &FlsCallback1); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + + ok_int(g_FlsCalled1, 0); + ok_int(g_FlsCalled2, 0); + + ok(pFlsFree(dwIndex1), "FlsFree(%lu) failed\n", dwIndex1); + g_FlsData1 = NULL; + + ok_fls(dwIndex1, g_FlsData1, NULL); + ok_fls(dwIndex2, g_FlsData2, &FlsCallback2); + + ok_int(g_FlsCalled1, 1); + ok_int(g_FlsCalled2, 0); +} diff --git a/modules/rostests/apitests/kernel32/testlist.c b/modules/rostests/apitests/kernel32/testlist.c index 6364cab804..8c671c1b68 100644 --- a/modules/rostests/apitests/kernel32/testlist.c +++ b/modules/rostests/apitests/kernel32/testlist.c @@ -10,6 +10,7 @@ extern void func_DeviceIoControl(void); extern void func_dosdev(void); extern void func_FindActCtxSectionStringW(void); extern void func_FindFiles(void); +extern void func_FLS(void); extern void func_FormatMessage(void); extern void func_GetComputerNameEx(void); extern void func_GetCurrentDirectory(void); @@ -41,6 +42,7 @@ const struct test winetest_testlist[] = { "dosdev", func_dosdev }, { "FindActCtxSectionStringW", func_FindActCtxSectionStringW }, { "FindFiles", func_FindFiles }, + { "FLS", func_FLS }, { "FormatMessage", func_FormatMessage }, { "GetComputerNameEx", func_GetComputerNameEx }, { "GetCurrentDirectory", func_GetCurrentDirectory },
6 years, 3 months
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
15
...
23
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
Results per page:
10
25
50
100
200