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
June 2006
----- 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
19 participants
595 discussions
Start a n
N
ew thread
[turner] 22683: expand %* to batch file params. bug: #1629
by turner@svn.reactos.org
Author: turner Date: Thu Jun 29 06:48:52 2006 New Revision: 22683 URL:
http://svn.reactos.org/svn/reactos?rev=22683&view=rev
Log: expand %* to batch file params. bug: #1629 Modified: trunk/reactos/base/shell/cmd/batch.c trunk/reactos/base/shell/cmd/batch.h trunk/reactos/base/shell/cmd/cmd.c Modified: trunk/reactos/base/shell/cmd/batch.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev…
============================================================================== --- trunk/reactos/base/shell/cmd/batch.c (original) +++ trunk/reactos/base/shell/cmd/batch.c Thu Jun 29 06:48:52 2006 @@ -272,6 +272,11 @@ bc->forvar = _T('\0'); bc->forproto = NULL; bc->params = BatchParams (firstword, param); + // + // Allocate enough memory to hold the params and copy them over without modifications + // + bc->raw_params = malloc(_tcslen(param)); + _tcscpy(bc->raw_params,param); #ifdef _DEBUG DebugPrintf (_T("Batch: returns TRUE\n")); Modified: trunk/reactos/base/shell/cmd/batch.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.h?rev…
============================================================================== --- trunk/reactos/base/shell/cmd/batch.h (original) +++ trunk/reactos/base/shell/cmd/batch.h Thu Jun 29 06:48:52 2006 @@ -15,6 +15,7 @@ HANDLE hBatchFile; LPTSTR forproto; LPTSTR params; + LPTSTR raw_params; /* Holds the raw params given by the input */ INT shiftlevel; BOOL bEcho; /* Preserve echo flag across batch calls */ HANDLE hFind; /* Preserve find handle when doing a for */ Modified: trunk/reactos/base/shell/cmd/cmd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=2…
============================================================================== --- trunk/reactos/base/shell/cmd/cmd.c (original) +++ trunk/reactos/base/shell/cmd/cmd.c Thu Jun 29 06:48:52 2006 @@ -1274,6 +1274,32 @@ if ( varNameLen ) *varNameLen = 2; return ret; + + case _T('*'): + if(bc == NULL) + { + // + // No batch file to see here, move along + // + if ( !GrowIfNecessary ( 3, &ret, &retlen ) ) + return NULL; + ret[0] = _T('%'); + ret[1] = _T('*'); + ret[2] = 0; + if ( varNameLen ) + *varNameLen = 2; + return ret; + } + + // + // Copy over the raw params(not including the batch file name + // + if ( !GrowIfNecessary ( _tcslen(bc->raw_params)+1, &ret, &retlen ) ) + return NULL; + if ( varNameLen ) + *varNameLen = 2; + _tcscpy ( ret, bc->raw_params ); + return ret; case _T('%'): if ( !GrowIfNecessary ( 2, &ret, &retlen ) )
18 years, 5 months
1
0
0
0
[ion] 22682: - Add some hacks to Cm to allow creating registry keys that finish with a backslash (this works under NT). - Also add a REALLY nasty hack that forces OBJ_CASE_INSENSITIVE on all Registry APIs... this is needed because we seem to completely mess up case sensitivity otherwise and any user-mode caller that doesn't specify that flag will fail. - These two fixes fix all the WINE failures for the "ntdll reg" test and should increase compatibility with some applications. - Runtime Library
by ion@svn.reactos.org
Author: ion Date: Thu Jun 29 04:30:36 2006 New Revision: 22682 URL:
http://svn.reactos.org/svn/reactos?rev=22682&view=rev
Log: - Add some hacks to Cm to allow creating registry keys that finish with a backslash (this works under NT). - Also add a REALLY nasty hack that forces OBJ_CASE_INSENSITIVE on all Registry APIs... this is needed because we seem to completely mess up case sensitivity otherwise and any user-mode caller that doesn't specify that flag will fail. - These two fixes fix all the WINE failures for the "ntdll reg" test and should increase compatibility with some applications. - Runtime Library Registry Wrappers Fixes and Optimizations: - Use an array of registry paths instead of duplicating them - Fix implenmentation of RTL_REGISTRY_HANDLE. - Verify all Appends for failure before continuing. - Use the strict minimum key permissions isntead of KEY_ALL_ACCESS. - Don't use OBJ_OPENIF - Use CAPS for \\REGISTRY\\USER (required to match a Windows quirk exposed by a WINE test) - Use the correct length in RtlpNtQueryValueKey - Generic cleanups, formatting and commenting. Modified: trunk/reactos/lib/rtl/registry.c trunk/reactos/ntoskrnl/cm/ntfunc.c trunk/reactos/ntoskrnl/cm/regobj.c Modified: trunk/reactos/lib/rtl/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/registry.c?rev=226…
============================================================================== --- trunk/reactos/lib/rtl/registry.c (original) +++ trunk/reactos/lib/rtl/registry.c Thu Jun 29 04:30:36 2006 @@ -21,350 +21,541 @@ #define TAG_RTLREGISTRY TAG('R', 't', 'l', 'R') -/* FUNCTIONS ***************************************************************/ - -static NTSTATUS -RtlpGetRegistryHandle(ULONG RelativeTo, - PWSTR Path, - BOOLEAN Create, - PHANDLE KeyHandle) -{ - UNICODE_STRING KeyPath; - UNICODE_STRING KeyName; - WCHAR KeyBuffer[MAX_PATH]; - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status; - - DPRINT("RtlpGetRegistryHandle()\n"); - - if (RelativeTo & RTL_REGISTRY_HANDLE) - { - Status = ZwDuplicateObject(NtCurrentProcess(), - (HANDLE)Path, - NtCurrentProcess(), - KeyHandle, - 0, - 0, - DUPLICATE_SAME_ACCESS); -#ifndef NDEBUG - if(!NT_SUCCESS(Status)) - { - DPRINT("ZwDuplicateObject() failed! Status: 0x%x\n", Status); - } -#endif - - return(Status); - } - - if (RelativeTo & RTL_REGISTRY_OPTIONAL) - RelativeTo &= ~RTL_REGISTRY_OPTIONAL; - - if (RelativeTo >= RTL_REGISTRY_MAXIMUM) - { - DPRINT("Invalid relative flag, parameter invalid!\n"); - return(STATUS_INVALID_PARAMETER); - } - - KeyName.Length = 0; - KeyName.MaximumLength = sizeof(KeyBuffer); - KeyName.Buffer = KeyBuffer; - KeyBuffer[0] = 0; - - switch (RelativeTo) - { - case RTL_REGISTRY_ABSOLUTE: - /* nothing to prefix! */ - break; - - case RTL_REGISTRY_SERVICES: - RtlAppendUnicodeToString(&KeyName, - L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); - break; - - case RTL_REGISTRY_CONTROL: - RtlAppendUnicodeToString(&KeyName, - L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\"); - break; - - case RTL_REGISTRY_WINDOWS_NT: - RtlAppendUnicodeToString(&KeyName, - L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\"); - break; - - case RTL_REGISTRY_DEVICEMAP: - RtlAppendUnicodeToString(&KeyName, - L"\\Registry\\Machine\\Hardware\\DeviceMap\\"); - break; - - case RTL_REGISTRY_USER: - Status = RtlFormatCurrentUserKeyPath (&KeyPath); - if (!NT_SUCCESS(Status)) - return(Status); - RtlAppendUnicodeStringToString (&KeyName, - &KeyPath); - RtlFreeUnicodeString (&KeyPath); - RtlAppendUnicodeToString (&KeyName, - L"\\"); - break; - } - - if (Path[0] == L'\\' && RelativeTo != RTL_REGISTRY_ABSOLUTE) - { - Path++; - } - RtlAppendUnicodeToString(&KeyName, - Path); - - DPRINT("KeyName %wZ\n", &KeyName); - - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - NULL, - NULL); - - if (Create) - { - Status = ZwCreateKey(KeyHandle, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - 0, - NULL); - } - else - { - Status = ZwOpenKey(KeyHandle, - KEY_ALL_ACCESS, - &ObjectAttributes); - } - -#ifndef NDEBUG - if(!NT_SUCCESS(Status)) - { - DPRINT("%s failed! Status: 0x%x\n", (Create ? "ZwCreateKey" : "ZwOpenKey"), Status); - } -#endif - - return(Status); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI +/* DATA **********************************************************************/ + +PCWSTR RtlpRegPaths[RTL_REGISTRY_MAXIMUM] = +{ + NULL, + L"\\Registry\\Machine\\System\\CurrentControlSet\\Services", + L"\\Registry\\Machine\\System\\CurrentControlSet\\Control", + L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion", + L"\\Registry\\Machine\\Hardware\\DeviceMap", + L"\\Registry\\User\\.Default", +}; + +/* PRIVATE FUNCTIONS *********************************************************/ + +NTSTATUS +NTAPI +RtlpGetRegistryHandle(IN ULONG RelativeTo, + IN PCWSTR Path, + IN BOOLEAN Create, + IN PHANDLE KeyHandle) +{ + UNICODE_STRING KeyPath, KeyName; + WCHAR KeyBuffer[MAX_PATH]; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + + /* Check if we just want the handle */ + if (RelativeTo & RTL_REGISTRY_HANDLE) + { + *KeyHandle = (HANDLE)Path; + return STATUS_SUCCESS; + } + + /* Check for optional flag */ + if (RelativeTo & RTL_REGISTRY_OPTIONAL) + { + /* Mask it out */ + RelativeTo &= ~RTL_REGISTRY_OPTIONAL; + } + + /* Fail on invalid parameter */ + if (RelativeTo >= RTL_REGISTRY_MAXIMUM) return STATUS_INVALID_PARAMETER; + + /* Initialize the key name */ + RtlInitEmptyUnicodeString(&KeyName, KeyBuffer, sizeof(KeyBuffer)); + + /* Check if we have to lookup a path to prefix */ + if (RelativeTo != RTL_REGISTRY_ABSOLUTE) + { + /* Check if we need the current user key */ + if (RelativeTo == RTL_REGISTRY_USER) + { + /* Get the path */ + Status = RtlFormatCurrentUserKeyPath(&KeyPath); + if (!NT_SUCCESS(Status)) return(Status); + + /* Append it */ + Status = RtlAppendUnicodeStringToString(&KeyName, &KeyPath); + RtlFreeUnicodeString (&KeyPath); + } + else + { + /* Get one of the prefixes */ + Status = RtlAppendUnicodeToString(&KeyName, + RtlpRegPaths[RelativeTo]); + } + + /* Check for failure, otherwise, append the path separator */ + if (!NT_SUCCESS(Status)) return Status; + Status = RtlAppendUnicodeToString(&KeyName, L"\\"); + if (!NT_SUCCESS(Status)) return Status; + } + + /* And now append the path */ + if (Path[0] == L'\\' && RelativeTo != RTL_REGISTRY_ABSOLUTE) Path++; // HACK! + Status = RtlAppendUnicodeToString(&KeyName, Path); + if (!NT_SUCCESS(Status)) return Status; + + /* Initialize the object attributes */ + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + /* Check if we want to create it */ + if (Create) + { + /* Create the key with write privileges */ + Status = ZwCreateKey(KeyHandle, + GENERIC_WRITE, + &ObjectAttributes, + 0, + NULL, + 0, + NULL); + } + else + { + /* Otherwise, just open it with read access */ + Status = ZwOpenKey(KeyHandle, + MAXIMUM_ALLOWED | GENERIC_READ, + &ObjectAttributes); + } + + /* Return status */ + return Status; +} + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +NTSTATUS +NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, - IN PWSTR Path) -{ - HANDLE KeyHandle; - NTSTATUS Status; - - PAGED_CODE_RTL(); - - Status = RtlpGetRegistryHandle(RelativeTo, - Path, - FALSE, - &KeyHandle); - if (!NT_SUCCESS(Status)) - return(Status); - - ZwClose(KeyHandle); - - return(STATUS_SUCCESS); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI + IN PWSTR Path) +{ + HANDLE KeyHandle; + NTSTATUS Status; + PAGED_CODE_RTL(); + + /* Call the helper */ + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + FALSE, + &KeyHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* All went well, close the handle and return success */ + ZwClose(KeyHandle); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI RtlCreateRegistryKey(IN ULONG RelativeTo, - IN PWSTR Path) -{ - HANDLE KeyHandle; - NTSTATUS Status; - - PAGED_CODE_RTL(); - - Status = RtlpGetRegistryHandle(RelativeTo, - Path, - TRUE, - &KeyHandle); - if (!NT_SUCCESS(Status)) - return(Status); - - ZwClose(KeyHandle); - - return(STATUS_SUCCESS); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI + IN PWSTR Path) +{ + HANDLE KeyHandle; + NTSTATUS Status; + PAGED_CODE_RTL(); + + /* Call the helper */ + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* All went well, close the handle and return success */ + ZwClose(KeyHandle); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI RtlDeleteRegistryValue(IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName) -{ - HANDLE KeyHandle; - NTSTATUS Status; - UNICODE_STRING Name; - - PAGED_CODE_RTL(); - - Status = RtlpGetRegistryHandle(RelativeTo, - (PWSTR)Path, - FALSE, - &KeyHandle); - if (!NT_SUCCESS(Status)) - return(Status); - - RtlInitUnicodeString(&Name, - ValueName); - - Status = ZwDeleteValueKey(KeyHandle, - &Name); - - ZwClose(KeyHandle); - - return(Status); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath) -{ - HANDLE TokenHandle; - UCHAR Buffer[256]; - PSID_AND_ATTRIBUTES SidBuffer; - ULONG Length; - UNICODE_STRING SidString; - NTSTATUS Status; - - PAGED_CODE_RTL(); - - DPRINT ("RtlFormatCurrentUserKeyPath() called\n"); - - Status = ZwOpenThreadToken (NtCurrentThread (), - TOKEN_QUERY, - TRUE, - &TokenHandle); - if (!NT_SUCCESS (Status)) - { - if (Status != STATUS_NO_TOKEN) - { - DPRINT1 ("ZwOpenThreadToken() failed (Status %lx)\n", Status); - return Status; - } - - Status = ZwOpenProcessToken (NtCurrentProcess (), - TOKEN_QUERY, - &TokenHandle); - if (!NT_SUCCESS (Status)) - { - DPRINT1 ("ZwOpenProcessToken() failed (Status %lx)\n", Status); - return Status; - } - } - - SidBuffer = (PSID_AND_ATTRIBUTES)Buffer; - Status = ZwQueryInformationToken (TokenHandle, - TokenUser, - (PVOID)SidBuffer, - 256, - &Length); - ZwClose (TokenHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT1 ("ZwQueryInformationToken() failed (Status %lx)\n", Status); - return Status; - } - - Status = RtlConvertSidToUnicodeString (&SidString, - SidBuffer[0].Sid, - TRUE); - if (!NT_SUCCESS(Status)) - { - DPRINT1 ("RtlConvertSidToUnicodeString() failed (Status %lx)\n", Status); - return Status; - } - - DPRINT ("SidString: '%wZ'\n", &SidString); - - Length = SidString.Length + sizeof(L"\\Registry\\User\\"); - DPRINT ("Length: %lu\n", Length); - - KeyPath->Length = 0; - KeyPath->MaximumLength = Length; - KeyPath->Buffer = RtlpAllocateStringMemory(KeyPath->MaximumLength, TAG_USTR); - if (KeyPath->Buffer == NULL) - { - DPRINT1 ("RtlpAllocateMemory() failed\n"); - RtlFreeUnicodeString (&SidString); - return STATUS_NO_TOKEN; - } - - RtlAppendUnicodeToString (KeyPath, - L"\\Registry\\User\\"); - RtlAppendUnicodeStringToString (KeyPath, - &SidString); - RtlFreeUnicodeString (&SidString); - - return STATUS_SUCCESS; -} - - -/* - * @implemented - */ -NTSTATUS NTAPI + IN PCWSTR Path, + IN PCWSTR ValueName) +{ + HANDLE KeyHandle; + NTSTATUS Status; + UNICODE_STRING Name; + PAGED_CODE_RTL(); + + /* Call the helper */ + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* Initialize the key name and delete it */ + RtlInitUnicodeString(&Name, ValueName); + Status = ZwDeleteValueKey(KeyHandle, &Name); + + /* All went well, close the handle and return status */ + ZwClose(KeyHandle); + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlWriteRegistryValue(IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength) +{ + HANDLE KeyHandle; + NTSTATUS Status; + UNICODE_STRING Name; + PAGED_CODE_RTL(); + + /* Call the helper */ + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* Initialize the key name and set it */ + RtlInitUnicodeString(&Name, ValueName); + Status = ZwSetValueKey(KeyHandle, + &Name, + 0, + ValueType, + ValueData, + ValueLength); + + /* All went well, close the handle and return status */ + ZwClose(KeyHandle); + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess, - OUT PHANDLE KeyHandle) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING KeyPath; - NTSTATUS Status; - - PAGED_CODE_RTL(); - - Status = RtlFormatCurrentUserKeyPath(&KeyPath); - if (NT_SUCCESS(Status)) - { - InitializeObjectAttributes(&ObjectAttributes, - &KeyPath, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = ZwOpenKey(KeyHandle, - DesiredAccess, - &ObjectAttributes); - RtlFreeUnicodeString(&KeyPath); - if (NT_SUCCESS(Status)) - { - return STATUS_SUCCESS; - } - } - - RtlInitUnicodeString (&KeyPath, - L"\\Registry\\User\\.Default"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyPath, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = ZwOpenKey(KeyHandle, - DesiredAccess, - &ObjectAttributes); - - return Status; -} - + OUT PHANDLE KeyHandle) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyPath; + NTSTATUS Status; + PAGED_CODE_RTL(); + + /* Get the user key */ + Status = RtlFormatCurrentUserKeyPath(&KeyPath); + if (NT_SUCCESS(Status)) + { + /* Initialize the attributes and open it */ + InitializeObjectAttributes(&ObjectAttributes, + &KeyPath, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); + + /* Free the path and return success if it worked */ + RtlFreeUnicodeString(&KeyPath); + if (NT_SUCCESS(Status)) return STATUS_SUCCESS; + } + + /* It didn't work, so use the default key */ + RtlInitUnicodeString(&KeyPath, RtlpRegPaths[RTL_REGISTRY_USER]); + InitializeObjectAttributes(&ObjectAttributes, + &KeyPath, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); + + /* Return status */ + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlFormatCurrentUserKeyPath(OUT PUNICODE_STRING KeyPath) +{ + HANDLE TokenHandle; + UCHAR Buffer[256]; + PSID_AND_ATTRIBUTES SidBuffer; + ULONG Length; + UNICODE_STRING SidString; + NTSTATUS Status; + PAGED_CODE_RTL(); + + /* Open the thread token */ + Status = ZwOpenThreadToken(NtCurrentThread(), + TOKEN_QUERY, + TRUE, + &TokenHandle); + if (!NT_SUCCESS(Status)) + { + /* We failed, is it because we don't have a thread token? */ + if (Status != STATUS_NO_TOKEN) return Status; + + /* It is, so use the process token */ + Status = ZwOpenProcessToken(NtCurrentProcess(), + TOKEN_QUERY, + &TokenHandle); + if (!NT_SUCCESS(Status)) return Status; + } + + /* Now query the token information */ + SidBuffer = (PSID_AND_ATTRIBUTES)Buffer; + Status = ZwQueryInformationToken(TokenHandle, + TokenUser, + (PVOID)SidBuffer, + sizeof(Buffer), + &Length); + + /* Close the handle and handle failure */ + ZwClose(TokenHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* Convert the SID */ + Status = RtlConvertSidToUnicodeString(&SidString, SidBuffer[0].Sid, TRUE); + if (!NT_SUCCESS(Status)) return Status; + + /* Add the length of the prefix */ + Length = SidString.Length + sizeof(L"\\REGISTRY\\USER\\"); + + /* Initialize a string */ + RtlInitEmptyUnicodeString(KeyPath, + RtlpAllocateStringMemory(Length, TAG_USTR), + Length); + if (!KeyPath->Buffer) + { + /* Free the string and fail */ + RtlFreeUnicodeString(&SidString); + return STATUS_NO_MEMORY; + } + + /* Append the prefix and SID */ + RtlAppendUnicodeToString(KeyPath, L"\\REGISTRY\\USER\\"); + RtlAppendUnicodeStringToString(KeyPath, &SidString); + + /* Free the temporary string and return success */ + RtlFreeUnicodeString(&SidString); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtCreateKey(OUT HANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class, + OUT PULONG Disposition) +{ + /* Check if we have object attributes */ + if (ObjectAttributes) + { + /* Mask out the unsupported flags */ + ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); + } + + /* Create the key */ + return ZwCreateKey(KeyHandle, + DesiredAccess, + ObjectAttributes, + 0, + NULL, + 0, + Disposition); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtEnumerateSubKey(IN HANDLE KeyHandle, + OUT PUNICODE_STRING SubKeyName, + IN ULONG Index, + IN ULONG Unused) +{ + PKEY_BASIC_INFORMATION KeyInfo = NULL; + ULONG BufferLength = 0; + ULONG ReturnedLength; + NTSTATUS Status; + + /* Check if we have a name */ + if (SubKeyName->MaximumLength) + { + /* Allocate a buffer for it */ + BufferLength = SubKeyName->MaximumLength + + sizeof(KEY_BASIC_INFORMATION); + KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); + if (!KeyInfo) return STATUS_NO_MEMORY; + } + + /* Enumerate the key */ + Status = ZwEnumerateKey(KeyHandle, + Index, + KeyBasicInformation, + KeyInfo, + BufferLength, + &ReturnedLength); + if (NT_SUCCESS(Status)) + { + /* Check if the name fits */ + if (KeyInfo->NameLength <= SubKeyName->MaximumLength) + { + /* Set the length */ + SubKeyName->Length = KeyInfo->NameLength; + + /* Copy it */ + RtlMoveMemory(SubKeyName->Buffer, + KeyInfo->Name, + SubKeyName->Length); + } + else + { + /* Otherwise, we ran out of buffer space */ + Status = STATUS_BUFFER_OVERFLOW; + } + } + + /* Free the buffer and return status */ + if (KeyInfo) RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo); + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtMakeTemporaryKey(IN HANDLE KeyHandle) +{ + /* This just deletes the key */ + return ZwDeleteKey(KeyHandle); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtOpenKey(OUT HANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG Unused) +{ + /* Check if we have object attributes */ + if (ObjectAttributes) + { + /* Mask out the unsupported flags */ + ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); + } + + /* Open the key */ + return ZwOpenKey(KeyHandle, DesiredAccess, ObjectAttributes); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtQueryValueKey(IN HANDLE KeyHandle, + OUT PULONG Type OPTIONAL, + OUT PVOID Data OPTIONAL, + IN OUT PULONG DataLength OPTIONAL, + IN ULONG Unused) +{ + PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; + UNICODE_STRING ValueName; + ULONG BufferLength = 0; + NTSTATUS Status; + + /* Clear the value name */ + RtlInitEmptyUnicodeString(&ValueName, NULL, 0); + + /* Check if we were already given a length */ + if (DataLength) BufferLength = *DataLength; + + /* Add the size of the structure */ + BufferLength += FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data); + + /* Allocate memory for the value */ + ValueInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); + if (!ValueInfo) return STATUS_NO_MEMORY; + + /* Query the value */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + ValueInfo, + BufferLength, + &BufferLength); + if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW)) + { + /* Return the length and type */ + if (DataLength) *DataLength = ValueInfo->DataLength; + if (Type) *Type = ValueInfo->Type; + } + + /* Check if the caller wanted data back, and we got it */ + if ((NT_SUCCESS(Status)) && (Data)) + { + /* Copy it */ + RtlMoveMemory(Data, ValueInfo->Data, ValueInfo->DataLength); + } + + /* Free the memory and return status */ + RtlFreeHeap(RtlGetProcessHeap(), 0, ValueInfo); + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +RtlpNtSetValueKey(IN HANDLE KeyHandle, + IN ULONG Type, + IN PVOID Data, + IN ULONG DataLength) +{ + UNICODE_STRING ValueName; + + /* Set the value */ + RtlInitEmptyUnicodeString(&ValueName, NULL, 0); + return ZwSetValueKey(KeyHandle, + &ValueName, + 0, + Type, + Data, + DataLength); +} /* * @unimplemented @@ -869,234 +1060,4 @@ return(Status); } - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlWriteRegistryValue(IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength) -{ - HANDLE KeyHandle; - NTSTATUS Status; - UNICODE_STRING Name; - - PAGED_CODE_RTL(); - - Status = RtlpGetRegistryHandle(RelativeTo, - (PWSTR)Path, - TRUE, - &KeyHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT("RtlpGetRegistryHandle() failed! Status: 0x%lx\n", Status); - return(Status); - } - - RtlInitUnicodeString(&Name, - ValueName); - - Status = ZwSetValueKey(KeyHandle, - &Name, - 0, - ValueType, - ValueData, - ValueLength); - if (!NT_SUCCESS(Status)) - { - DPRINT1("ZwSetValueKey() failed! Status: 0x%lx\n", Status); - } - - ZwClose(KeyHandle); - - return(Status); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtCreateKey(OUT HANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG Unused1, - OUT PULONG Disposition, - IN ULONG Unused2) -{ - if (ObjectAttributes != NULL) - ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); - - return(ZwCreateKey(KeyHandle, - DesiredAccess, - ObjectAttributes, - 0, - NULL, - 0, - Disposition)); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtEnumerateSubKey(IN HANDLE KeyHandle, - OUT PUNICODE_STRING SubKeyName, - IN ULONG Index, - IN ULONG Unused) -{ - PKEY_BASIC_INFORMATION KeyInfo = NULL; - ULONG BufferLength = 0; - ULONG ReturnedLength; - NTSTATUS Status; - - if (SubKeyName->MaximumLength != 0) - { - BufferLength = SubKeyName->MaximumLength + - sizeof(KEY_BASIC_INFORMATION); - KeyInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY); - if (KeyInfo == NULL) - return(STATUS_NO_MEMORY); - } - - Status = ZwEnumerateKey(KeyHandle, - Index, - KeyBasicInformation, - KeyInfo, - BufferLength, - &ReturnedLength); - if (NT_SUCCESS(Status)) - { - if (KeyInfo->NameLength + sizeof(WCHAR) <= SubKeyName->MaximumLength) - { - memmove(SubKeyName->Buffer, - KeyInfo->Name, - KeyInfo->NameLength); - SubKeyName->Buffer[KeyInfo->NameLength / sizeof(WCHAR)] = 0; - SubKeyName->Length = KeyInfo->NameLength; - } - else - { - Status = STATUS_BUFFER_OVERFLOW; - } - } - - if (KeyInfo != NULL) - { - RtlpFreeMemory(KeyInfo, TAG_RTLREGISTRY); - } - - return(Status); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtMakeTemporaryKey(IN HANDLE KeyHandle) -{ - return(ZwDeleteKey(KeyHandle)); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtOpenKey(OUT HANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG Unused) -{ - if (ObjectAttributes != NULL) - ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); - - return(ZwOpenKey(KeyHandle, - DesiredAccess, - ObjectAttributes)); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtQueryValueKey(IN HANDLE KeyHandle, - OUT PULONG Type OPTIONAL, - OUT PVOID Data OPTIONAL, - IN OUT PULONG DataLength OPTIONAL, - IN ULONG Unused) -{ - PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; - UNICODE_STRING ValueName; - ULONG BufferLength; - ULONG ReturnedLength; - NTSTATUS Status; - - RtlInitUnicodeString(&ValueName, - NULL); - - BufferLength = sizeof(KEY_VALUE_PARTIAL_INFORMATION); - if (DataLength != NULL) - BufferLength = *DataLength; - - ValueInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY); - if (ValueInfo == NULL) - return(STATUS_NO_MEMORY); - - Status = ZwQueryValueKey(KeyHandle, - &ValueName, - KeyValuePartialInformation, - ValueInfo, - BufferLength, - &ReturnedLength); - if (NT_SUCCESS(Status)) - { - if (DataLength != NULL) - *DataLength = ValueInfo->DataLength; - - if (Type != NULL) - *Type = ValueInfo->Type; - - if (Data != NULL) - { - memmove(Data, - ValueInfo->Data, - ValueInfo->DataLength); - } - } - - RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY); - - return(Status); -} - - -/* - * @implemented - */ -NTSTATUS NTAPI -RtlpNtSetValueKey(IN HANDLE KeyHandle, - IN ULONG Type, - IN PVOID Data, - IN ULONG DataLength) -{ - UNICODE_STRING ValueName; - - RtlInitUnicodeString(&ValueName, - NULL); - return(ZwSetValueKey(KeyHandle, - &ValueName, - 0, - Type, - Data, - DataLength)); -} - /* EOF */ Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/cm/ntfunc.c (original) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c Thu Jun 29 04:30:36 2006 @@ -411,13 +411,26 @@ because NtCreateKey doesn't create trees */ Start = RemainingPath.Buffer; if (*Start == L'\\') + { Start++; + //RemainingPath.Length -= sizeof(WCHAR); + //RemainingPath.MaximumLength -= sizeof(WCHAR); + //RemainingPath.Buffer++; + //DPRINT1("String: %wZ\n", &RemainingPath); + } + + if (RemainingPath.Buffer[(RemainingPath.Length / sizeof(WCHAR)) - 1] == '\\') + { + RemainingPath.Buffer[(RemainingPath.Length / sizeof(WCHAR)) - 1] = UNICODE_NULL; + RemainingPath.Length -= sizeof(WCHAR); + RemainingPath.MaximumLength -= sizeof(WCHAR); + } for (i = 1; i < RemainingPath.Length / sizeof(WCHAR); i++) { if (L'\\' == RemainingPath.Buffer[i]) { - DPRINT("NtCreateKey() doesn't create trees! (found \'\\\' in remaining path: \"%wZ\"!)\n", &RemainingPath); + DPRINT1("NtCreateKey() doesn't create trees! (found \'\\\' in remaining path: \"%wZ\"!)\n", &RemainingPath); PostCreateKeyInfo.Object = NULL; PostCreateKeyInfo.Status = STATUS_OBJECT_NAME_NOT_FOUND; @@ -1395,6 +1408,13 @@ { return Status; } + } + + if (ObjectAttributes->ObjectName->Buffer[(ObjectAttributes->ObjectName->Length / sizeof(WCHAR)) - 1] == '\\') + { + ObjectAttributes->ObjectName->Buffer[(ObjectAttributes->ObjectName->Length / sizeof(WCHAR)) - 1] = UNICODE_NULL; + ObjectAttributes->ObjectName->Length -= sizeof(WCHAR); + ObjectAttributes->ObjectName->MaximumLength -= sizeof(WCHAR); } /* WINE checks for the length also */ Modified: trunk/reactos/ntoskrnl/cm/regobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/regobj.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/cm/regobj.c (original) +++ trunk/reactos/ntoskrnl/cm/regobj.c Thu Jun 29 04:30:36 2006 @@ -110,6 +110,7 @@ Attributes = ObjectCreateInfo->Attributes; if (ObjectType == ObSymbolicLinkType) Attributes |= OBJ_OPENLINK; + Attributes |= OBJ_CASE_INSENSITIVE; // hello! My name is ReactOS CM and I'm brain-dead! while (TRUE) {
18 years, 5 months
1
0
0
0
[arty] 22681: Claim a workspace using openfirmware.
by arty@svn.reactos.org
Author: arty Date: Thu Jun 29 02:55:52 2006 New Revision: 22681 URL:
http://svn.reactos.org/svn/reactos?rev=22681&view=rev
Log: Claim a workspace using openfirmware. Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c Modified: branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fr…
============================================================================== --- branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c (original) +++ branches/powerpc/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c Thu Jun 29 02:55:52 2006 @@ -20,6 +20,8 @@ #include "machine.h" #include "of.h" +#define TOTAL_HEAP_NEEDED (16 * 1024 * 1024) /* 16 megs */ + extern void BootMain( char * ); extern char *GetFreeLoaderVersionString(); of_proxy ofproxy; @@ -162,24 +164,38 @@ VOID PpcVideoPrepareForReactOS() { printf( "PrepareForReactOS\n"); } -/* XXX FIXME: - * According to the linux people (this is backed up by my own experience), - * the memory object in older ofw does not do getprop right. - * - * The "right" way is to probe the pci bridge. *sigh* +/* + * Get memory the proper openfirmware way */ ULONG PpcGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize ) { - printf("GetMemoryMap(chosen=%x)\n", chosen_package); - - BiosMemoryMap[0].Type = MEMTYPE_USABLE; - BiosMemoryMap[0].BaseAddress = 0; - BiosMemoryMap[0].Length = 32 * 1024 * 1024; /* Assume 32 meg for now */ - - printf( "Returning memory map (%dk total)\n", - (int)BiosMemoryMap[0].Length / 1024 ); - - return 1; + int i, memhandle, returned, total = 0, num_mem = 0; + int memdata[256]; + + ofw_getprop(chosen_package, "memory", + (char *)&memhandle, sizeof(memhandle)); + returned = ofw_getprop(memhandle, "available", + (char *)memdata, sizeof(memdata)); + + /* We need to leave some for open firmware. Let's claim up to 16 megs + * for now */ + + for( i = 0; i < returned / sizeof(int) && !num_mem; i += 2 ) { + BiosMemoryMap[num_mem].Type = MEMTYPE_USABLE; + BiosMemoryMap[num_mem].BaseAddress = memdata[i]; + BiosMemoryMap[num_mem].Length = memdata[i+1]; + if( BiosMemoryMap[num_mem].Length >= TOTAL_HEAP_NEEDED ) { + BiosMemoryMap[num_mem].Length = TOTAL_HEAP_NEEDED; + ofw_claim(BiosMemoryMap[num_mem].BaseAddress, + BiosMemoryMap[num_mem].Length, 0x1000); /* claim it */ + total += BiosMemoryMap[0].Length; + num_mem++; + } + } + + printf( "Returning memory map (%dk total)\n", total / 1024 ); + + return num_mem; } /* Strategy: @@ -284,27 +300,15 @@ chosen_package = ofw_finddevice( "/chosen" ); - ofw_print_string("Chosen package: "); - ofw_print_number(chosen_package); - ofw_print_string("\n"); - ofw_getprop( chosen_package, "stdin", (char *)&stdin_handle, sizeof(stdin_handle) ); - ofw_print_string("ofw_getprop done\n"); - /* stdin_handle = REV(stdin_handle); */ - - ofw_print_string("Populating MachVtbl: "); - ofw_print_number((int)&MachVtbl); - ofw_print_string("\n"); MachVtbl.ConsPutChar = PpcPutChar; MachVtbl.ConsKbHit = PpcConsKbHit; MachVtbl.ConsGetCh = PpcConsGetCh; - ofw_print_string("About to do printf\n"); - printf( "stdin_handle is %x\n", stdin_handle ); MachVtbl.VideoClearScreen = PpcVideoClearScreen;
18 years, 5 months
1
0
0
0
[arty] 22680: Fixed actual bug in freeldr printf. Probably used to depend on a bug in _itoa, which was later made compliant. I'm guessing that this went unnoticed because nobody used freeldr's printf very often.
by arty@svn.reactos.org
Author: arty Date: Thu Jun 29 02:26:04 2006 New Revision: 22680 URL:
http://svn.reactos.org/svn/reactos?rev=22680&view=rev
Log: Fixed actual bug in freeldr printf. Probably used to depend on a bug in _itoa, which was later made compliant. I'm guessing that this went unnoticed because nobody used freeldr's printf very often. Modified: branches/powerpc/reactos/boot/freeldr/freeldr/ui/tui.c Modified: branches/powerpc/reactos/boot/freeldr/freeldr/ui/tui.c URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/boot/freeldr/fr…
============================================================================== --- branches/powerpc/reactos/boot/freeldr/freeldr/ui/tui.c (original) +++ branches/powerpc/reactos/boot/freeldr/freeldr/ui/tui.c Thu Jun 29 02:26:04 2006 @@ -22,6 +22,8 @@ PVOID TextVideoBuffer = NULL; extern BOOLEAN UiDrawTime; extern BOOLEAN UiMinimal; +extern void ofw_print_string(const char *); +extern void ofw_print_number(int x); /* * printf() - prints formatted text to stdout @@ -43,19 +45,20 @@ { switch (c = *(format++)) { - case 'd': case 'u': case 'x': - if (c == 'x') - *_itoa(va_arg(ap, unsigned long), str, 16) = 0; - else - *_itoa(va_arg(ap, unsigned long), str, 10) = 0; + case 'd': case 'u': case 'x': { + unsigned long x = va_arg(ap, unsigned long); + if (c == 'x') + _itoa(x, str, 16); + else + _itoa(x, str, 10); ptr = str; while (*ptr) { - MachConsPutChar(*(ptr++)); + MachConsPutChar(*(ptr++)); } - break; + } break; case 'c': MachConsPutChar((va_arg(ap,int))&0xff); break;
18 years, 5 months
1
0
0
0
[ion] 22679: - Sync RtlBitmap* implementation with WINE: Fixes 278 regression failures (for a total of 0 now). - Also adds implementations for RtlFindMostSignificantBit , RtlFindLeastSignificantBit, RtlFindNextForwardRunClear, RtlFindClearRuns. - The RtlBitmap* package is essential for compatibility with NTFS.SYS and other File System Drivers, but these fixes should not really improve user-mode app. compat.
by ion@svn.reactos.org
Author: ion Date: Thu Jun 29 00:51:51 2006 New Revision: 22679 URL:
http://svn.reactos.org/svn/reactos?rev=22679&view=rev
Log: - Sync RtlBitmap* implementation with WINE: Fixes 278 regression failures (for a total of 0 now). - Also adds implementations for RtlFindMostSignificantBit , RtlFindLeastSignificantBit, RtlFindNextForwardRunClear, RtlFindClearRuns. - The RtlBitmap* package is essential for compatibility with NTFS.SYS and other File System Drivers, but these fixes should not really improve user-mode app. compat. Modified: trunk/reactos/lib/rtl/bitmap.c Modified: trunk/reactos/lib/rtl/bitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/bitmap.c?rev=22679…
============================================================================== --- trunk/reactos/lib/rtl/bitmap.c (original) +++ trunk/reactos/lib/rtl/bitmap.c Thu Jun 29 00:51:51 2006 @@ -12,64 +12,347 @@ #define NDEBUG #include <debug.h> - /* MACROS *******************************************************************/ -#define MASK(Count, Shift) \ - ((Count) == 32 ? 0xFFFFFFFF : ~(0xFFFFFFFF << (Count)) << (Shift)) - +/* Bits set from LSB to MSB; used as mask for runs < 8 bits */ +static const BYTE NTDLL_maskBits[8] = { 0, 1, 3, 7, 15, 31, 63, 127 }; + +/* Number of set bits for each value of a nibble; used for counting */ +static const BYTE NTDLL_nibbleBitCount[16] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 +}; + +/* First set bit in a nibble; used for determining least significant bit */ +static const BYTE NTDLL_leastSignificant[16] = { + 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 +}; + +/* Last set bit in a nibble; used for determining most significant bit */ +static const signed char NTDLL_mostSignificant[16] = { + -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 +}; + +/* PRIVATE FUNCTIONS *********************************************************/ + +static +int +NTDLL_RunSortFn(const void *lhs, + const void *rhs) +{ + if (((const RTL_BITMAP_RUN*)lhs)->NumberOfBits > ((const RTL_BITMAP_RUN*)rhs)->NumberOfBits) + return -1; + return 1; +} + +static +ULONG +WINAPI +NTDLL_FindRuns(PRTL_BITMAP lpBits, + PRTL_BITMAP_RUN lpSeries, + ULONG ulCount, + BOOLEAN bLongest, + ULONG (*fn)(PRTL_BITMAP,ULONG,PULONG)) +{ + BOOL bNeedSort = ulCount > 1 ? TRUE : FALSE; + ULONG ulPos = 0, ulRuns = 0; + + if (!ulCount) + return ~0U; + + while (ulPos < lpBits->SizeOfBitMap) + { + /* Find next set/clear run */ + ULONG ulSize, ulNextPos = fn(lpBits, ulPos, &ulSize); + + if (ulNextPos == ~0U) + break; + + if (bLongest && ulRuns == ulCount) + { + /* Sort runs with shortest at end, if they are out of order */ + if (bNeedSort) + qsort(lpSeries, ulRuns, sizeof(RTL_BITMAP_RUN), NTDLL_RunSortFn); + + /* Replace last run if this one is bigger */ + if (ulSize > lpSeries[ulRuns - 1].NumberOfBits) + { + lpSeries[ulRuns - 1].StartingIndex = ulNextPos; + lpSeries[ulRuns - 1].NumberOfBits = ulSize; + + /* We need to re-sort the array, _if_ we didn't leave it sorted */ + if (ulRuns > 1 && ulSize > lpSeries[ulRuns - 2].NumberOfBits) + bNeedSort = TRUE; + } + } + else + { + /* Append to found runs */ + lpSeries[ulRuns].StartingIndex = ulNextPos; + lpSeries[ulRuns].NumberOfBits = ulSize; + ulRuns++; + + if (!bLongest && ulRuns == ulCount) + break; + } + ulPos = ulNextPos + ulSize; + } + return ulRuns; +} + +static +ULONG +NTDLL_FindSetRun(PRTL_BITMAP lpBits, + ULONG ulStart, + PULONG lpSize) +{ + LPBYTE lpOut; + ULONG ulFoundAt = 0, ulCount = 0; + + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)lpBits->Buffer) + (ulStart >> 3u); + + while (1) + { + /* Check bits in first byte */ + const BYTE bMask = (0xff << (ulStart & 7)) & 0xff; + const BYTE bFirst = *lpOut & bMask; + + if (bFirst) + { + /* Have a set bit in first byte */ + if (bFirst != bMask) + { + /* Not every bit is set */ + ULONG ulOffset; + + if (bFirst & 0x0f) + ulOffset = NTDLL_leastSignificant[bFirst & 0x0f]; + else + ulOffset = 4 + NTDLL_leastSignificant[bFirst >> 4]; + ulStart += ulOffset; + ulFoundAt = ulStart; + for (;ulOffset < 8; ulOffset++) + { + if (!(bFirst & (1 << ulOffset))) + { + *lpSize = ulCount; + return ulFoundAt; /* Set from start, but not until the end */ + } + ulCount++; + ulStart++; + } + /* Set to the end - go on to count further bits */ + lpOut++; + break; + } + /* every bit from start until the end of the byte is set */ + ulFoundAt = ulStart; + ulCount = 8 - (ulStart & 7); + ulStart = (ulStart & ~7u) + 8; + lpOut++; + break; + } + ulStart = (ulStart & ~7u) + 8; + lpOut++; + if (ulStart >= lpBits->SizeOfBitMap) + return ~0U; + } + + /* Count blocks of 8 set bits */ + while (*lpOut == 0xff) + { + ulCount += 8; + ulStart += 8; + if (ulStart >= lpBits->SizeOfBitMap) + { + *lpSize = ulCount - (ulStart - lpBits->SizeOfBitMap); + return ulFoundAt; + } + lpOut++; + } + + /* Count remaining contiguous bits, if any */ + if (*lpOut & 1) + { + ULONG ulOffset = 0; + + for (;ulOffset < 7u; ulOffset++) + { + if (!(*lpOut & (1 << ulOffset))) + break; + ulCount++; + } + } + *lpSize = ulCount; + return ulFoundAt; +} + +static +ULONG +NTDLL_FindClearRun(PRTL_BITMAP lpBits, + ULONG ulStart, + PULONG lpSize) +{ + LPBYTE lpOut; + ULONG ulFoundAt = 0, ulCount = 0; + + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)lpBits->Buffer) + (ulStart >> 3u); + + while (1) + { + /* Check bits in first byte */ + const BYTE bMask = (0xff << (ulStart & 7)) & 0xff; + const BYTE bFirst = (~*lpOut) & bMask; + + if (bFirst) + { + /* Have a clear bit in first byte */ + if (bFirst != bMask) + { + /* Not every bit is clear */ + ULONG ulOffset; + + if (bFirst & 0x0f) + ulOffset = NTDLL_leastSignificant[bFirst & 0x0f]; + else + ulOffset = 4 + NTDLL_leastSignificant[bFirst >> 4]; + ulStart += ulOffset; + ulFoundAt = ulStart; + for (;ulOffset < 8; ulOffset++) + { + if (!(bFirst & (1 << ulOffset))) + { + *lpSize = ulCount; + return ulFoundAt; /* Clear from start, but not until the end */ + } + ulCount++; + ulStart++; + } + /* Clear to the end - go on to count further bits */ + lpOut++; + break; + } + /* Every bit from start until the end of the byte is clear */ + ulFoundAt = ulStart; + ulCount = 8 - (ulStart & 7); + ulStart = (ulStart & ~7u) + 8; + lpOut++; + break; + } + ulStart = (ulStart & ~7u) + 8; + lpOut++; + if (ulStart >= lpBits->SizeOfBitMap) + return ~0U; + } + + /* Count blocks of 8 clear bits */ + while (!*lpOut) + { + ulCount += 8; + ulStart += 8; + if (ulStart >= lpBits->SizeOfBitMap) + { + *lpSize = ulCount - (ulStart - lpBits->SizeOfBitMap); + return ulFoundAt; + } + lpOut++; + } + + /* Count remaining contiguous bits, if any */ + if (!(*lpOut & 1)) + { + ULONG ulOffset = 0; + + for (;ulOffset < 7u; ulOffset++) + { + if (*lpOut & (1 << ulOffset)) + break; + ulCount++; + } + } + *lpSize = ulCount; + return ulFoundAt; +} /* FUNCTIONS ****************************************************************/ /* * @implemented */ -VOID NTAPI -RtlInitializeBitMap(PRTL_BITMAP BitMapHeader, - PULONG BitMapBuffer, - ULONG SizeOfBitMap) -{ - BitMapHeader->SizeOfBitMap = SizeOfBitMap; - BitMapHeader->Buffer = BitMapBuffer; -} - - -/* - * @implemented - */ -BOOLEAN NTAPI -RtlAreBitsClear(PRTL_BITMAP BitMapHeader, - ULONG StartingIndex, - ULONG Length) -{ - ULONG Size; - ULONG Shift; - ULONG Count; - PULONG Ptr; - - Size = BitMapHeader->SizeOfBitMap; - if (StartingIndex >= Size || - !Length || - (StartingIndex + Length > Size)) - return FALSE; - - Ptr = (PULONG)BitMapHeader->Buffer + (StartingIndex / 32); - while (Length) - { - /* Get bit shift in current ulong */ - Shift = StartingIndex & 0x1F; - - /* Get number of bits to check in current ulong */ - Count = (Length > 32 - Shift) ? 32 - Shift : Length; - - /* Check ulong */ - if (*Ptr++ & MASK(Count, Shift)) +VOID +NTAPI +RtlInitializeBitMap(IN PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap) +{ + /* Setup the bitmap header */ + BitMapHeader->SizeOfBitMap = SizeOfBitMap; + BitMapHeader->Buffer = BitMapBuffer; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +RtlAreBitsClear(IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length) +{ + LPBYTE lpOut; + ULONG ulRemainder; + + if (!BitMapHeader || !Length || + StartingIndex >= BitMapHeader->SizeOfBitMap || + Length > BitMapHeader->SizeOfBitMap - StartingIndex) + return FALSE; + + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)BitMapHeader->Buffer) + (StartingIndex >> 3u); + + /* Check bits in first byte, if StartingIndex isn't a byte boundary */ + if (StartingIndex & 7) + { + if (Length > 7) + { + /* Check from start bit to the end of the byte */ + if (*lpOut & ((0xff << (StartingIndex & 7)) & 0xff)) + return FALSE; + lpOut++; + Length -= (8 - (StartingIndex & 7)); + } + else + { + /* Check from the start bit, possibly into the next byte also */ + USHORT initialWord = NTDLL_maskBits[Length] << (StartingIndex & 7); + + if (*lpOut & (initialWord & 0xff)) + return FALSE; + if ((initialWord & 0xff00) && (lpOut[1] & (initialWord >> 8))) + return FALSE; + return TRUE; + } + } + + /* Check bits in blocks of 8 bytes */ + ulRemainder = Length & 7; + Length >>= 3; + while (Length--) + { + if (*lpOut++) return FALSE; - - Length -= Count; - StartingIndex += Count; - } - + } + + /* Check remaining bits, if any */ + if (ulRemainder && *lpOut & NTDLL_maskBits[ulRemainder]) + return FALSE; return TRUE; } @@ -82,107 +365,139 @@ ULONG StartingIndex, ULONG Length) { - ULONG Size; - ULONG Shift; - ULONG Count; - PULONG Ptr; - - Size = BitMapHeader->SizeOfBitMap; - if (StartingIndex >= Size || - Length == 0 || - (StartingIndex + Length > Size)) + LPBYTE lpOut; + ULONG ulRemainder; + + + if (!BitMapHeader || !Length || + StartingIndex >= BitMapHeader->SizeOfBitMap || + Length > BitMapHeader->SizeOfBitMap - StartingIndex) return FALSE; - Ptr = (PULONG)BitMapHeader->Buffer + (StartingIndex / 32); - while (Length) - { - /* Get bit shift in current ulong */ - Shift = StartingIndex & 0x1F; - - /* Get number of bits to check in current ulong */ - Count = (Length > 32 - Shift) ? 32 - Shift : Length; - - /* Check ulong */ - if (~*Ptr++ & MASK(Count, Shift)) + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)BitMapHeader->Buffer) + (StartingIndex >> 3u); + + /* Check bits in first byte, if StartingIndex isn't a byte boundary */ + if (StartingIndex & 7) + { + if (Length > 7) + { + /* Check from start bit to the end of the byte */ + if ((*lpOut & + ((0xff << (StartingIndex & 7))) & 0xff) != ((0xff << (StartingIndex & 7) & 0xff))) + return FALSE; + lpOut++; + Length -= (8 - (StartingIndex & 7)); + } + else + { + /* Check from the start bit, possibly into the next byte also */ + USHORT initialWord = NTDLL_maskBits[Length] << (StartingIndex & 7); + + if ((*lpOut & (initialWord & 0xff)) != (initialWord & 0xff)) + return FALSE; + if ((initialWord & 0xff00) && + ((lpOut[1] & (initialWord >> 8)) != (initialWord >> 8))) + return FALSE; + return TRUE; + } + } + + /* Check bits in blocks of 8 bytes */ + ulRemainder = Length & 7; + Length >>= 3; + while (Length--) + { + if (*lpOut++ != 0xff) return FALSE; - - Length -= Count; - StartingIndex += Count; - } - + } + + /* Check remaining bits, if any */ + if (ulRemainder && + (*lpOut & NTDLL_maskBits[ulRemainder]) != NTDLL_maskBits[ulRemainder]) + return FALSE; return TRUE; } /* * @implemented - * - * Note: According to the documentation, SizeOfBitmap is in bits, so the - * ROUND_UP(...) must be divided by the number of bits per byte here. - * This function is exercised by the whole page allocator in npool.c - * which is how i came across this error. */ VOID NTAPI RtlClearAllBits(IN OUT PRTL_BITMAP BitMapHeader) { - memset(BitMapHeader->Buffer, - 0x00, - ROUND_UP(BitMapHeader->SizeOfBitMap, 8) / 8); - -} - - -/* - * @implemented - */ -VOID NTAPI + memset(BitMapHeader->Buffer, 0, ((BitMapHeader->SizeOfBitMap + 31) & ~31) >> 3); +} + +/* + * @implemented + */ +VOID +NTAPI RtlClearBit(PRTL_BITMAP BitMapHeader, - ULONG BitNumber) -{ - PULONG Ptr; - - if (BitNumber >= BitMapHeader->SizeOfBitMap) + ULONG BitNumber) +{ + PULONG Ptr; + + if (BitNumber >= BitMapHeader->SizeOfBitMap) return; + + Ptr = (PULONG)BitMapHeader->Buffer + (BitNumber / 32); + *Ptr &= ~(1 << (BitNumber % 32)); +} + +/* + * @implemented + */ +VOID +NTAPI +RtlClearBits(IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToClear) +{ + LPBYTE lpOut; + + if (!BitMapHeader || !NumberToClear || + StartingIndex >= BitMapHeader->SizeOfBitMap || + NumberToClear > BitMapHeader->SizeOfBitMap - StartingIndex) return; - Ptr = (PULONG)BitMapHeader->Buffer + (BitNumber / 32); - - *Ptr &= ~(1 << (BitNumber % 32)); -} - - -/* - * @implemented - */ -VOID NTAPI -RtlClearBits(PRTL_BITMAP BitMapHeader, - ULONG StartingIndex, - ULONG NumberToClear) -{ - ULONG Size; - ULONG Count; - ULONG Shift; - PULONG Ptr; - - Size = BitMapHeader->SizeOfBitMap; - if (StartingIndex >= Size || NumberToClear == 0) - return; - - ASSERT(StartingIndex + NumberToClear <= Size); - - Ptr = (PULONG)BitMapHeader->Buffer + (StartingIndex / 32); - while (NumberToClear) - { - /* Bit shift in current ulong */ - Shift = StartingIndex & 0x1F; - - /* Number of bits to change in current ulong */ - Count = (NumberToClear > 32 - Shift ) ? 32 - Shift : NumberToClear; - - /* Adjust ulong */ - *Ptr++ &= ~MASK(Count, Shift); - NumberToClear -= Count; - StartingIndex += Count; - } + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)BitMapHeader->Buffer) + (StartingIndex >> 3u); + + /* Clear bits in first byte, if StartingIndex isn't a byte boundary */ + if (StartingIndex & 7) + { + if (NumberToClear > 7) + { + /* Clear from start bit to the end of the byte */ + *lpOut++ &= ~(0xff << (StartingIndex & 7)); + NumberToClear -= (8 - (StartingIndex & 7)); + } + else + { + /* Clear from the start bit, possibly into the next byte also */ + USHORT initialWord = ~(NTDLL_maskBits[NumberToClear] << (StartingIndex & 7)); + + *lpOut++ &= (initialWord & 0xff); + *lpOut &= (initialWord >> 8); + return; + } + } + + /* Clear bits (in blocks of 8) on whole byte boundaries */ + if (NumberToClear >> 3) + { + memset(lpOut, 0, NumberToClear >> 3); + lpOut = lpOut + (NumberToClear >> 3); + } + + /* Clear remaining bits, if any */ + if (NumberToClear & 0x7) + *lpOut &= ~NTDLL_maskBits[NumberToClear & 0x7]; } @@ -194,171 +509,44 @@ ULONG NumberToFind, ULONG HintIndex) { - ULONG Size; - ULONG Index; - ULONG Count; - PULONG Ptr; - ULONG Mask; - ULONG Loop; - ULONG End; - ULONG OriginalHint = HintIndex; - - Size = BitMapHeader->SizeOfBitMap; - if (NumberToFind > Size || NumberToFind == 0) - return -1; - - if (HintIndex >= Size) + ULONG ulPos, ulEnd; + + if (!BitMapHeader || !NumberToFind || NumberToFind > BitMapHeader->SizeOfBitMap) + return ~0U; + + ulEnd = BitMapHeader->SizeOfBitMap; + + if (HintIndex + NumberToFind > BitMapHeader->SizeOfBitMap) HintIndex = 0; - /* Initialize the values to the hint location. */ - Index = HintIndex; - Ptr = BitMapHeader->Buffer + (Index / 32); - Mask = 1 << (Index & 0x1F); - End = Size; - - /* The outer loop does the magic of first searching from the - * hint to the bitmap end and then going again from beginning - * of the bitmap to the hint location. - */ - for (Loop = 0; Loop < 2; Loop++) - { - while (HintIndex < End) - { - /* Count clear bits */ - for (Count = 0; Index < End && ~*Ptr & Mask; Index++) - { - if (++Count >= NumberToFind) - return HintIndex; - - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - /* Skip set bits */ - for (; Index < End && *Ptr & Mask; Index++) - { - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - HintIndex = Index; - } - - /* Optimalization */ - if (OriginalHint == 0) - break; - - /* Initialize the values for the beginning -> hint loop. */ - HintIndex = Index = 0; - End = OriginalHint + NumberToFind - 1; - End = End > Size ? Size : End; - Ptr = BitMapHeader->Buffer; - Mask = 1; - } - - return (ULONG)-1; -} - - -/* - * @implemented - */ -ULONG NTAPI -RtlFindClearBitsAndSet(PRTL_BITMAP BitMapHeader, - ULONG NumberToFind, - ULONG HintIndex) -{ - ULONG Index; - - Index = RtlFindClearBits(BitMapHeader, - NumberToFind, - HintIndex); - if (Index != (ULONG)-1) - { - RtlSetBits(BitMapHeader, - Index, - NumberToFind); - } - - return Index; -} - - -/* - * @implemented - */ -ULONG NTAPI -RtlFindFirstRunClear(PRTL_BITMAP BitMapHeader, - PULONG StartingIndex) -{ - ULONG Size; - ULONG Index; - ULONG Count; - PULONG Ptr; - ULONG Mask; - - Size = BitMapHeader->SizeOfBitMap; - if (*StartingIndex > Size) - { - *StartingIndex = (ULONG)-1; - return 0; - } - - Index = *StartingIndex; - Ptr = (PULONG)BitMapHeader->Buffer + (Index / 32); - Mask = 1 << (Index & 0x1F); - - /* Skip set bits */ - for (; Index < Size && *Ptr & Mask; Index++) - { - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - /* Return index of first clear bit */ - if (Index >= Size) - { - *StartingIndex = (ULONG)-1; - return 0; - } - else - { - *StartingIndex = Index; - } - - /* Count clear bits */ - for (Count = 0; Index < Size && ~*Ptr & Mask; Index++) - { - Count++; - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - return Count; -} - - -/* - * @unimplemented + ulPos = HintIndex; + + while (ulPos < ulEnd) + { + /* FIXME: This could be made a _lot_ more efficient */ + if (RtlAreBitsClear(BitMapHeader, ulPos, NumberToFind)) + return ulPos; + + /* Start from the beginning if we hit the end and started from HintIndex */ + if (ulPos == ulEnd - 1 && HintIndex) + { + ulEnd = HintIndex; + ulPos = HintIndex = 0; + } + else + ulPos++; + } + return ~0U; +} + + + + + + + +/* + * @implemented */ ULONG NTAPI RtlFindClearRuns(PRTL_BITMAP BitMapHeader, @@ -366,8 +554,7 @@ ULONG SizeOfRunArray, BOOLEAN LocateLongestRuns) { - UNIMPLEMENTED; - return 0; + return NTDLL_FindRuns(BitMapHeader, RunArray, SizeOfRunArray, LocateLongestRuns, NTDLL_FindClearRun); } @@ -383,19 +570,21 @@ return 0; } - -/* - * @unimplemented +/* + * @implemented */ ULONG NTAPI RtlFindNextForwardRunClear(IN PRTL_BITMAP BitMapHeader, IN ULONG FromIndex, IN PULONG StartingRunIndex) { - UNIMPLEMENTED; - return 0; -} - + ULONG ulSize = 0; + + if (BitMapHeader && FromIndex < BitMapHeader->SizeOfBitMap && StartingRunIndex) + *StartingRunIndex = NTDLL_FindClearRun(BitMapHeader, FromIndex, &ulSize); + + return ulSize; +} /* * @implemented @@ -468,60 +657,15 @@ RtlFindLongestRunClear(PRTL_BITMAP BitMapHeader, PULONG StartingIndex) { - ULONG Size; - PULONG Ptr; - ULONG Index = 0; - ULONG Count; - ULONG Max = 0; - ULONG Start; - ULONG Maxstart = 0; - ULONG Mask = 1; - - Size = BitMapHeader->SizeOfBitMap; - Ptr = (PULONG)BitMapHeader->Buffer; - - while (Index < Size) - { - Start = Index; - - /* Count clear bits */ - for (Count = 0; Index < Size && ~*Ptr & Mask; Index++) - { - Count++; - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - /* Skip set bits */ - for (; Index < Size && *Ptr & Mask; Index++) - { - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - if (Count > Max) - { - Max = Count; - Maxstart = Start; - } - } - - if (StartingIndex != NULL) - { - *StartingIndex = Maxstart; - } - - return Max; + RTL_BITMAP_RUN br; + + if (RtlFindClearRuns(BitMapHeader, &br, 1, TRUE) == 1) + { + if (StartingIndex) + *StartingIndex = br.StartingIndex; + return br.NumberOfBits; + } + return 0; } @@ -532,60 +676,15 @@ RtlFindLongestRunSet(PRTL_BITMAP BitMapHeader, PULONG StartingIndex) { - ULONG Size; - PULONG Ptr; - ULONG Index = 0; - ULONG Count; - ULONG Max = 0; - ULONG Start; - ULONG Maxstart = 0; - ULONG Mask = 1; - - Size = BitMapHeader->SizeOfBitMap; - Ptr = (PULONG)BitMapHeader->Buffer; - - while (Index < Size) - { - Start = Index; - - /* Count set bits */ - for (Count = 0; Index < Size && *Ptr & Mask; Index++) - { - Count++; - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - /* Skip clear bits */ - for (; Index < Size && ~*Ptr & Mask; Index++) - { - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - if (Count > Max) - { - Max = Count; - Maxstart = Start; - } - } - - if (StartingIndex != NULL) - { - *StartingIndex = Maxstart; - } - - return Max; + RTL_BITMAP_RUN br; + + if (NTDLL_FindRuns(BitMapHeader, &br, 1, TRUE, NTDLL_FindSetRun) == 1) + { + if (StartingIndex) + *StartingIndex = br.StartingIndex; + return br.NumberOfBits; + } + return 0; } @@ -597,79 +696,34 @@ ULONG NumberToFind, ULONG HintIndex) { - ULONG Size; - ULONG Index; - ULONG Count; - PULONG Ptr; - ULONG Mask; - ULONG Loop; - ULONG End; - ULONG OriginalHint = HintIndex; - - Size = BitMapHeader->SizeOfBitMap; - if (NumberToFind > Size || NumberToFind == 0) - return (ULONG)-1; - - if (HintIndex >= Size) + ULONG ulPos, ulEnd; + + if (!BitMapHeader || !NumberToFind || NumberToFind > BitMapHeader->SizeOfBitMap) + return ~0U; + + ulEnd = BitMapHeader->SizeOfBitMap; + + if (HintIndex + NumberToFind > BitMapHeader->SizeOfBitMap) HintIndex = 0; - /* Initialize the values to the hint location. */ - Index = HintIndex; - Ptr = BitMapHeader->Buffer + (Index / 32); - Mask = 1 << (Index & 0x1F); - End = Size; - - /* The outer loop does the magic of first searching from the - * hint to the bitmap end and then going again from beginning - * of the bitmap to the hint location. - */ - for (Loop = 0; Loop < 2; Loop++) - { - while (HintIndex < End) - { - /* Count set bits */ - for (Count = 0; Index < End && *Ptr & Mask; Index++) - { - if (++Count >= NumberToFind) - return HintIndex; - - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - /* Skip clear bits */ - for (; Index < End && ~*Ptr & Mask; Index++) - { - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - HintIndex = Index; - } - - /* Optimalization */ - if (OriginalHint == 0) - break; - - /* Initialize the values for the beginning -> hint loop. */ - HintIndex = Index = 0; - End = OriginalHint + NumberToFind - 1; - End = End > Size ? Size : End; - Ptr = BitMapHeader->Buffer; - Mask = 1; - } - - return (ULONG)-1; + ulPos = HintIndex; + + while (ulPos < ulEnd) + { + /* FIXME: This could be made a _lot_ more efficient */ + if (RtlAreBitsSet(BitMapHeader, ulPos, NumberToFind)) + return ulPos; + + /* Start from the beginning if we hit the end and had a hint */ + if (ulPos == ulEnd - 1 && HintIndex) + { + ulEnd = HintIndex; + ulPos = HintIndex = 0; + } + else + ulPos++; + } + return ~0U; } @@ -681,52 +735,16 @@ ULONG NumberToFind, ULONG HintIndex) { - ULONG Index; - - Index = RtlFindSetBits(BitMapHeader, - NumberToFind, - HintIndex); - if (Index != (ULONG)-1) - { - RtlClearBits(BitMapHeader, - Index, - NumberToFind); - } - - return Index; -} - - -/* - * @implemented - */ -ULONG NTAPI -RtlNumberOfClearBits(PRTL_BITMAP BitMapHeader) -{ - PULONG Ptr; - ULONG Size; - ULONG Index; - ULONG Count; - ULONG Mask; - - Size = BitMapHeader->SizeOfBitMap; - Ptr = (PULONG)BitMapHeader->Buffer; - - for (Mask = 1, Index = 0, Count = 0; Index < Size; Index++) - { - if (~*Ptr & Mask) - Count++; - - Mask <<= 1; - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - return Count; -} + ULONG ulPos; + + ulPos = RtlFindSetBits(BitMapHeader, NumberToFind, HintIndex); + if (ulPos != ~0U) + RtlClearBits(BitMapHeader, ulPos, NumberToFind); + return ulPos; +} + + + /* @@ -735,46 +753,39 @@ ULONG NTAPI RtlNumberOfSetBits(PRTL_BITMAP BitMapHeader) { - PULONG Ptr; - ULONG Size; - ULONG Index; - ULONG Count; - ULONG Mask; - - Ptr = (PULONG)BitMapHeader->Buffer; - Size = BitMapHeader->SizeOfBitMap; - for (Mask = 1, Index = 0, Count = 0; Index < Size; Index++) - { - if (*Ptr & Mask) - Count++; - - Mask <<= 1; - - if (Mask == 0) - { - Mask = 1; - Ptr++; - } - } - - return Count; -} - - -/* - * @implemented - * - * Note: According to the documentation, SizeOfBitmap is in bits, so the - * ROUND_UP(...) must be divided by the number of bits per byte here. - * The companion function, RtlClearAllBits, is exercised by the whole page - * allocator in npool.c which is how i came across this error. + ULONG ulSet = 0; + + if (BitMapHeader) + { + LPBYTE lpOut = (BYTE *)BitMapHeader->Buffer; + ULONG Length, ulRemainder; + BYTE bMasked; + + Length = BitMapHeader->SizeOfBitMap >> 3; + ulRemainder = BitMapHeader->SizeOfBitMap & 0x7; + + while (Length--) + { + ulSet += NTDLL_nibbleBitCount[*lpOut >> 4]; + ulSet += NTDLL_nibbleBitCount[*lpOut & 0xf]; + lpOut++; + } + + bMasked = *lpOut & NTDLL_maskBits[ulRemainder]; + ulSet += NTDLL_nibbleBitCount[bMasked >> 4]; + ulSet += NTDLL_nibbleBitCount[bMasked & 0xf]; + } + return ulSet; +} + + +/* + * @implemented */ VOID NTAPI RtlSetAllBits(IN OUT PRTL_BITMAP BitMapHeader) { - memset(BitMapHeader->Buffer, - 0xFF, - ROUND_UP(BitMapHeader->SizeOfBitMap, 8) / 8); + memset(BitMapHeader->Buffer, 0xff, ((BitMapHeader->SizeOfBitMap + 31) & ~31) >> 3); } @@ -804,31 +815,47 @@ ULONG StartingIndex, ULONG NumberToSet) { - ULONG Size; - ULONG Count; - ULONG Shift; - PULONG Ptr; - - Size = BitMapHeader->SizeOfBitMap; - if (StartingIndex >= Size || NumberToSet == 0) + LPBYTE lpOut; + + if (!BitMapHeader || !NumberToSet || + StartingIndex >= BitMapHeader->SizeOfBitMap || + NumberToSet > BitMapHeader->SizeOfBitMap - StartingIndex) return; - ASSERT(StartingIndex + NumberToSet <= Size); - - Ptr = (PULONG)BitMapHeader->Buffer + (StartingIndex / 32); - while (NumberToSet) - { - /* Bit shift in current ulong */ - Shift = StartingIndex & 0x1F; - - /* Number of bits to change in current ulong */ - Count = (NumberToSet > 32 - Shift) ? 32 - Shift : NumberToSet; - - /* Adjust ulong */ - *Ptr++ |= MASK(Count, Shift); - NumberToSet -= Count; - StartingIndex += Count; - } + /* FIXME: It might be more efficient/cleaner to manipulate four bytes + * at a time. But beware of the pointer arithmetics... + */ + lpOut = ((BYTE*)BitMapHeader->Buffer) + (StartingIndex >> 3u); + + /* Set bits in first byte, if StartingIndex isn't a byte boundary */ + if (StartingIndex & 7) + { + if (NumberToSet > 7) + { + /* Set from start bit to the end of the byte */ + *lpOut++ |= 0xff << (StartingIndex & 7); + NumberToSet -= (8 - (StartingIndex & 7)); + } + else + { + /* Set from the start bit, possibly into the next byte also */ + USHORT initialWord = NTDLL_maskBits[NumberToSet] << (StartingIndex & 7); + + *lpOut++ |= (initialWord & 0xff); + *lpOut |= (initialWord >> 8); + return; + } + } + + /* Set bits up to complete byte count */ + if (NumberToSet >> 3) + { + memset(lpOut, 0xff, NumberToSet >> 3); + lpOut = lpOut + (NumberToSet >> 3); + } + + /* Set remaining bits, if any */ + *lpOut |= NTDLL_maskBits[NumberToSet & 0x7]; } @@ -849,4 +876,104 @@ return (*Ptr & (1 << (BitNumber % 32))); } +/* + * @implemented + */ +ULONG NTAPI +RtlFindFirstRunClear(PRTL_BITMAP BitMapHeader, + PULONG StartingIndex) +{ + return RtlFindNextForwardRunClear(BitMapHeader, 0, StartingIndex); +} + +/* + * @implemented + */ +ULONG NTAPI +RtlNumberOfClearBits(PRTL_BITMAP BitMapHeader) +{ + + if (BitMapHeader) + return BitMapHeader->SizeOfBitMap - RtlNumberOfSetBits(BitMapHeader); + return 0; +} + +/* + * @implemented + */ +ULONG NTAPI +RtlFindClearBitsAndSet(PRTL_BITMAP BitMapHeader, + ULONG NumberToFind, + ULONG HintIndex) +{ + ULONG ulPos; + + ulPos = RtlFindClearBits(BitMapHeader, NumberToFind, HintIndex); + if (ulPos != ~0U) + RtlSetBits(BitMapHeader, ulPos, NumberToFind); + return ulPos; +} + +/* + * @implemented + */ +CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG ulLong) +{ + signed char ret = 32; + DWORD dw; + + if (!(dw = (ulLong >> 32))) + { + ret = 0; + dw = (DWORD)ulLong; + } + if (dw & 0xffff0000) + { + dw >>= 16; + ret += 16; + } + if (dw & 0xff00) + { + dw >>= 8; + ret += 8; + } + if (dw & 0xf0) + { + dw >>= 4; + ret += 4; + } + return ret + NTDLL_mostSignificant[dw]; +} + +/* + * @implemented + */ +CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG ulLong) +{ + signed char ret = 0; + DWORD dw; + + if (!(dw = (DWORD)ulLong)) + { + ret = 32; + if (!(dw = ulLong >> 32)) return -1; + } + if (!(dw & 0xffff)) + { + dw >>= 16; + ret += 16; + } + if (!(dw & 0xff)) + { + dw >>= 8; + ret += 8; + } + if (!(dw & 0x0f)) + { + dw >>= 4; + ret += 4; + } + return ret + NTDLL_leastSignificant[dw & 0x0f]; +} + /* EOF */
18 years, 5 months
1
0
0
0
[fireball] 22678: Mikhail Zvyozdochkin: Fix compilation of msafd without precompiled header (also fixes compilation process on linux)
by fireball@svn.reactos.org
Author: fireball Date: Thu Jun 29 00:27:41 2006 New Revision: 22678 URL:
http://svn.reactos.org/svn/reactos?rev=22678&view=rev
Log: Mikhail Zvyozdochkin: Fix compilation of msafd without precompiled header (also fixes compilation process on linux) Modified: trunk/reactos/dll/win32/msafd/msafd.rbuild Modified: trunk/reactos/dll/win32/msafd/msafd.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.rbui…
============================================================================== --- trunk/reactos/dll/win32/msafd/msafd.rbuild (original) +++ trunk/reactos/dll/win32/msafd/msafd.rbuild Thu Jun 29 00:27:41 2006 @@ -1,5 +1,6 @@ <module name="msafd" type="win32dll" baseaddress="${BASEADDRESS_MSAFD}" installbase="system32" installname="msafd.dll"> <importlibrary definition="msafd.def" /> + <include base="msafd">.</include> <include base="msafd">include</include> <include base="ReactOS">include/reactos/drivers</include> <define name="UNICODE" />
18 years, 5 months
1
0
0
0
[ion] 22677: [AUDIT] - Unlock these files, they're just lame wrappers around the NT Kernel APIs that handle them and they're tested by WINE tests.
by ion@svn.reactos.org
Author: ion Date: Wed Jun 28 23:52:45 2006 New Revision: 22677 URL:
http://svn.reactos.org/svn/reactos?rev=22677&view=rev
Log: [AUDIT] - Unlock these files, they're just lame wrappers around the NT Kernel APIs that handle them and they're tested by WINE tests. Modified: trunk/reactos/dll/win32/kernel32/synch/event.c (props changed) trunk/reactos/dll/win32/kernel32/synch/mutex.c (props changed) trunk/reactos/dll/win32/kernel32/synch/sem.c (props changed) trunk/reactos/dll/win32/kernel32/synch/timer.c (props changed) trunk/reactos/dll/win32/kernel32/synch/wait.c (props changed) Propchange: trunk/reactos/dll/win32/kernel32/synch/event.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/dll/win32/kernel32/synch/mutex.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/dll/win32/kernel32/synch/sem.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/dll/win32/kernel32/synch/timer.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/dll/win32/kernel32/synch/wait.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
18 years, 5 months
1
0
0
0
[ion] 22676: - Rewrite all synch object wrappers in kernel32 to use a single unified method of implementation: - A->W converstion through static TEB buffer. - Failure if opening without a name. - Special warning code for objects that already exist (fixes some WINE test failures and probably makes a myriad of applications work). - Use BasepConvertObjectAttributes when creating an object to remove code duplication. - InitializeCrticalSectionAndSpinCount shouldn't raise an exception on failure. - O
by ion@svn.reactos.org
Author: ion Date: Wed Jun 28 21:08:35 2006 New Revision: 22676 URL:
http://svn.reactos.org/svn/reactos?rev=22676&view=rev
Log: - Rewrite all synch object wrappers in kernel32 to use a single unified method of implementation: - A->W converstion through static TEB buffer. - Failure if opening without a name. - Special warning code for objects that already exist (fixes some WINE test failures and probably makes a myriad of applications work). - Use BasepConvertObjectAttributes when creating an object to remove code duplication. - InitializeCrticalSectionAndSpinCount shouldn't raise an exception on failure. - Optimize WaitForMultipleObjects to cache 8 objects on the stack instead of only 3. - Reformat and comment all the files to ROS standards. Modified: trunk/reactos/dll/win32/kernel32/synch/critical.c trunk/reactos/dll/win32/kernel32/synch/event.c trunk/reactos/dll/win32/kernel32/synch/mutex.c trunk/reactos/dll/win32/kernel32/synch/sem.c trunk/reactos/dll/win32/kernel32/synch/timer.c trunk/reactos/dll/win32/kernel32/synch/wait.c Modified: trunk/reactos/dll/win32/kernel32/synch/critical.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/c…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/critical.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/critical.c Wed Jun 28 21:08:35 2006 @@ -1,58 +1,58 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/sync/critical.c - * PURPOSE: Critical sections - * PROGRAMMER: Filip Navara - * Eric Kohl - * UPDATE HISTORY: - * Created 30/09/98 +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/critical.c + * PURPOSE: Wrappers for the RTL Critical Section Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *****************************************************************/ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - +#include "debug.h" /* FUNCTIONS *****************************************************************/ /* * @implemented */ -VOID STDCALL -InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +VOID +WINAPI +InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection) { - NTSTATUS Status; + NTSTATUS Status; - Status = RtlInitializeCriticalSection((PRTL_CRITICAL_SECTION)lpCriticalSection); - if (!NT_SUCCESS(Status)) - { - RtlRaiseStatus(Status); - } + /* Initialize the critical section and raise an exception if we failed */ + Status = RtlInitializeCriticalSection( + (PRTL_CRITICAL_SECTION)lpCriticalSection); + if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status); } /* * @implemented */ BOOL -STDCALL -InitializeCriticalSectionAndSpinCount( - LPCRITICAL_SECTION lpCriticalSection, - DWORD dwSpinCount - ) +WINAPI +InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, + IN DWORD dwSpinCount) { NTSTATUS Status; - Status = RtlInitializeCriticalSectionAndSpinCount((PRTL_CRITICAL_SECTION)lpCriticalSection, dwSpinCount); - if (Status) - { - RtlRaiseStatus(Status); - } - return NT_SUCCESS(Status); + /* Initialize the critical section */ + Status = RtlInitializeCriticalSectionAndSpinCount( + (PRTL_CRITICAL_SECTION)lpCriticalSection, + dwSpinCount); + if (!NT_SUCCESS(Status)) + { + /* Set failure code */ + SetLastErrorByStatus(Status); + return FALSE; + } + + /* Success */ + return TRUE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/synch/event.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/e…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/event.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/event.c Wed Jun 28 21:08:35 2006 @@ -1,12 +1,9 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/synch/event.c - * PURPOSE: Local string functions - * PROGRAMMER: Ariadne ( ariadne(a)xs4all.nl) - * UPDATE HISTORY: - * Created 01/11/98 +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/event.c + * PURPOSE: Wrappers for the NT Event Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES *****************************************************************/ @@ -14,228 +11,233 @@ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - +#include "debug.h" /* FUNCTIONS ****************************************************************/ +HANDLE +WINAPI +CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, + IN BOOL bManualReset, + IN BOOL bInitialState, + IN LPCSTR lpName OPTIONAL) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + LPCWSTR UnicodeName = NULL; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Otherwise, save the buffer */ + UnicodeName = (LPCWSTR)UnicodeCache->Buffer; + } + + /* Call the Unicode API */ + return CreateEventW(lpEventAttributes, + bManualReset, + bInitialState, + UnicodeName); +} + +HANDLE +WINAPI +CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, + IN BOOL bManualReset, + IN BOOL bInitialState, + IN LPCWSTR lpName OPTIONAL) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES LocalAttributes; + POBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + UNICODE_STRING ObjectName; + + /* Now check if we got a name */ + if (lpName) RtlInitUnicodeString(&ObjectName, lpName); + + /* Now convert the object attributes */ + ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, + lpEventAttributes, + lpName ? &ObjectName : NULL); + + /* Create the event */ + Status = NtCreateEvent(&Handle, + EVENT_ALL_ACCESS, + ObjectAttributes, + bManualReset ? + NotificationEvent : SynchronizationEvent, + (BOOLEAN)bInitialState); + if (NT_SUCCESS(Status)) + { + /* Check if the object already existed */ + if (Status == STATUS_OBJECT_NAME_EXISTS) + { + /* Set distinguished Win32 error code */ + SetLastError(ERROR_ALREADY_EXISTS); + } + else + { + /* Otherwise, set success */ + SetLastError(ERROR_SUCCESS); + } + + /* Return the handle */ + return Handle; + } + else + { + /* Convert the NT Status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } +} + +HANDLE +WINAPI +OpenEventA(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCSTR lpName) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + } + else + { + /* We need a name */ + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + /* Call the Unicode API */ + return OpenEventW(dwDesiredAccess, + bInheritHandle, + (LPCWSTR)UnicodeCache->Buffer); +} + +HANDLE +WINAPI +OpenEventW(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCWSTR lpName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ObjectName; + NTSTATUS Status; + HANDLE Handle; + + /* Make sure we got a name */ + if (!lpName) + { + /* Fail without one */ + SetLastErrorByStatus(STATUS_INVALID_PARAMETER); + return NULL; + } + + /* Initialize the object name and attributes */ + RtlInitUnicodeString(&ObjectName, lpName); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + bInheritHandle ? OBJ_INHERIT : 0, + hBaseDir, + NULL); + + /* Open the event */ + Status = NtOpenEvent(&Handle, dwDesiredAccess, &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + /* Convert the status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Return the handle */ + return Handle; +} + /* * @implemented */ -HANDLE STDCALL -CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, - BOOL bManualReset, - BOOL bInitialState, - LPCSTR lpName) -{ - UNICODE_STRING EventNameU; - ANSI_STRING EventName; - HANDLE EventHandle; - - if (lpName) - { - RtlInitAnsiString(&EventName, - (LPSTR)lpName); - RtlAnsiStringToUnicodeString(&EventNameU, - &EventName, - TRUE); - } - - EventHandle = CreateEventW(lpEventAttributes, - bManualReset, - bInitialState, - (lpName ? EventNameU.Buffer : NULL)); - - if (lpName) - { - RtlFreeUnicodeString(&EventNameU); - } - - return EventHandle; -} - +BOOL +WINAPI +PulseEvent(IN HANDLE hEvent) +{ + NTSTATUS Status; + + /* Pulse the event */ + Status = NtPulseEvent(hEvent, NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; +} /* * @implemented */ -HANDLE STDCALL -CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, - BOOL bManualReset, - BOOL bInitialState, - LPCWSTR lpName) -{ - NTSTATUS Status; - HANDLE hEvent; - UNICODE_STRING UnicodeName; - OBJECT_ATTRIBUTES ObjectAttributes; - - if (lpName != NULL) - { - RtlInitUnicodeString(&UnicodeName, (LPWSTR)lpName); - } - - InitializeObjectAttributes(&ObjectAttributes, - (lpName ? &UnicodeName : NULL), - 0, - (lpName ? hBaseDir : NULL), - NULL); - - if (lpEventAttributes != NULL) - { - ObjectAttributes.SecurityDescriptor = lpEventAttributes->lpSecurityDescriptor; - if (lpEventAttributes->bInheritHandle) - { - ObjectAttributes.Attributes |= OBJ_INHERIT; - } - } - - Status = NtCreateEvent(&hEvent, - EVENT_ALL_ACCESS, - &ObjectAttributes, - (bManualReset ? NotificationEvent : SynchronizationEvent), - bInitialState); - DPRINT( "Called\n" ); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return hEvent; -} - +BOOL +WINAPI +ResetEvent(IN HANDLE hEvent) +{ + NTSTATUS Status; + + /* Clear the event */ + Status = NtResetEvent(hEvent, NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; +} /* * @implemented */ -HANDLE STDCALL -OpenEventA(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName) -{ - UNICODE_STRING EventNameU; - ANSI_STRING EventName; - HANDLE EventHandle; - - if (lpName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitUnicodeString(&EventNameU, - NULL); - - RtlInitAnsiString(&EventName, - (LPSTR)lpName); - RtlAnsiStringToUnicodeString(&EventNameU, - &EventName, - TRUE); - - EventHandle = OpenEventW(dwDesiredAccess, - bInheritHandle, - EventNameU.Buffer); - - RtlFreeUnicodeString(&EventNameU); - - return EventHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenEventW(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCWSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING EventNameString; - NTSTATUS Status; - HANDLE hEvent = NULL; - - if (lpName == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName); - - InitializeObjectAttributes(&ObjectAttributes, - &EventNameString, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenEvent(&hEvent, - dwDesiredAccess, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return hEvent; -} - - -/* - * @implemented - */ -BOOL STDCALL -PulseEvent(HANDLE hEvent) -{ - NTSTATUS Status; - - Status = NtPulseEvent(hEvent, NULL); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus (Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -ResetEvent(HANDLE hEvent) -{ - NTSTATUS Status; - - Status = NtClearEvent(hEvent); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -SetEvent(HANDLE hEvent) -{ - NTSTATUS Status; - - Status = NtSetEvent(hEvent, NULL); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; +BOOL +WINAPI +SetEvent(IN HANDLE hEvent) +{ + NTSTATUS Status; + + /* Set the event */ + Status = NtSetEvent(hEvent, NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/synch/mutex.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/m…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/mutex.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/mutex.c Wed Jun 28 21:08:35 2006 @@ -1,12 +1,9 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/synch/mutex.c - * PURPOSE: Mutex functions - * PROGRAMMER: Eric Kohl (ekohl(a)rz-online.de) - * UPDATE HISTORY: - * Created 01/20/2001 +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/mutex.c + * PURPOSE: Wrappers for the NT Mutant Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES *****************************************************************/ @@ -14,214 +11,204 @@ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - +#include "debug.h" /* FUNCTIONS *****************************************************************/ /* * @implemented */ -HANDLE STDCALL -CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCSTR lpName) -{ - UNICODE_STRING NameU; - ANSI_STRING Name; - HANDLE Handle; - - if (lpName != NULL) - { - RtlInitAnsiString(&Name, - (LPSTR)lpName); - - RtlAnsiStringToUnicodeString(&NameU, - &Name, - TRUE); - } - - Handle = CreateMutexW(lpMutexAttributes, - bInitialOwner, - (lpName ? NameU.Buffer : NULL)); - - if (lpName != NULL) - { - RtlFreeUnicodeString(&NameU); - } - - return Handle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCWSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status; - UNICODE_STRING UnicodeName; - HANDLE MutantHandle; - - if (lpName != NULL) - { - RtlInitUnicodeString(&UnicodeName, - (LPWSTR)lpName); - } - - InitializeObjectAttributes(&ObjectAttributes, - (lpName ? &UnicodeName : NULL), - 0, - (lpName ? hBaseDir : NULL), - NULL); - - if (lpMutexAttributes != NULL) - { - ObjectAttributes.SecurityDescriptor = lpMutexAttributes->lpSecurityDescriptor; - if (lpMutexAttributes->bInheritHandle) - { - ObjectAttributes.Attributes |= OBJ_INHERIT; - } - } - - Status = NtCreateMutant(&MutantHandle, - MUTEX_ALL_ACCESS, - &ObjectAttributes, - (BOOLEAN)bInitialOwner); - if (Status == STATUS_OBJECT_NAME_COLLISION) - { - Status = NtOpenMutant(&MutantHandle, - MUTEX_ALL_ACCESS, - &ObjectAttributes); - if (NT_SUCCESS(Status)) - { - SetLastError(ERROR_ALREADY_EXISTS); - } - } - else if (NT_SUCCESS(Status)) - { - SetLastError(ERROR_SUCCESS); - } - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return MutantHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenMutexA(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING NameU; - ANSI_STRING Name; - HANDLE Handle; - NTSTATUS Status; - - if (lpName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitAnsiString(&Name, - (LPSTR)lpName); - RtlAnsiStringToUnicodeString(&NameU, - &Name, - TRUE); - - InitializeObjectAttributes(&ObjectAttributes, - &NameU, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenMutant(&Handle, - (ACCESS_MASK)dwDesiredAccess, - &ObjectAttributes); - - RtlFreeUnicodeString(&NameU); - - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return Handle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenMutexW(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCWSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; - HANDLE Handle; - NTSTATUS Status; - - if (lpName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitUnicodeString(&Name, - (LPWSTR)lpName); - - InitializeObjectAttributes(&ObjectAttributes, - &Name, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenMutant(&Handle, - (ACCESS_MASK)dwDesiredAccess, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return Handle; -} - - -/* - * @implemented - */ -BOOL STDCALL -ReleaseMutex(HANDLE hMutex) -{ - NTSTATUS Status; - - Status = NtReleaseMutant(hMutex, - NULL); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; +HANDLE +WINAPI +CreateMutexA(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, + IN BOOL bInitialOwner, + IN LPCSTR lpName OPTIONAL) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + LPCWSTR UnicodeName = NULL; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Otherwise, save the buffer */ + UnicodeName = (LPCWSTR)UnicodeCache->Buffer; + } + + /* Call the Unicode API */ + return CreateMutexW(lpMutexAttributes, + bInitialOwner, + UnicodeName); +} + +/* + * @implemented + */ +HANDLE +WINAPI +CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, + IN BOOL bInitialOwner, + IN LPCWSTR lpName OPTIONAL) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES LocalAttributes; + POBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + UNICODE_STRING ObjectName; + + /* Now check if we got a name */ + if (lpName) RtlInitUnicodeString(&ObjectName, lpName); + + /* Now convert the object attributes */ + ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, + lpMutexAttributes, + lpName ? &ObjectName : NULL); + + /* Create the mutant */ + Status = NtCreateMutant(&Handle, + MUTANT_ALL_ACCESS, + ObjectAttributes, + (BOOLEAN)bInitialOwner); + if (NT_SUCCESS(Status)) + { + /* Check if the object already existed */ + if (Status == STATUS_OBJECT_NAME_EXISTS) + { + /* Set distinguished Win32 error code */ + SetLastError(ERROR_ALREADY_EXISTS); + } + else + { + /* Otherwise, set success */ + SetLastError(ERROR_SUCCESS); + } + + /* Return the handle */ + return Handle; + } + else + { + /* Convert the NT Status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenMutexA(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCSTR lpName) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + } + else + { + /* We need a name */ + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + /* Call the Unicode API */ + return OpenMutexW(dwDesiredAccess, + bInheritHandle, + (LPCWSTR)UnicodeCache->Buffer); +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenMutexW(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCWSTR lpName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ObjectName; + NTSTATUS Status; + HANDLE Handle; + + /* Make sure we got a name */ + if (!lpName) + { + /* Fail without one */ + SetLastErrorByStatus(STATUS_INVALID_PARAMETER); + return NULL; + } + + /* Initialize the object name and attributes */ + RtlInitUnicodeString(&ObjectName, lpName); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + bInheritHandle ? OBJ_INHERIT : 0, + hBaseDir, + NULL); + + /* Open the mutant */ + Status = NtOpenMutant(&Handle, dwDesiredAccess, &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + /* Convert the status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Return the handle */ + return Handle; +} + +/* + * @implemented + */ +BOOL +WINAPI +ReleaseMutex(IN HANDLE hMutex) +{ + NTSTATUS Status; + + /* Release the mutant */ + Status = NtReleaseMutant(hMutex, NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; } Modified: trunk/reactos/dll/win32/kernel32/synch/sem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/s…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/sem.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/sem.c Wed Jun 28 21:08:35 2006 @@ -1,12 +1,9 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/synch/sem.c - * PURPOSE: Semaphore functions - * PROGRAMMER: Eric Kohl (ekohl(a)rz-online.de) - * UPDATE HISTORY: - * Created 01/20/2001 +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/sem.c + * PURPOSE: Wrappers for the NT Semaphore Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES *****************************************************************/ @@ -14,204 +11,210 @@ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - +#include "debug.h" /* FUNCTIONS ****************************************************************/ /* * @implemented */ -HANDLE STDCALL -CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, - LONG lMaximumCount, - LPCSTR lpName) -{ - UNICODE_STRING NameU; - ANSI_STRING Name; - HANDLE Handle; - - if (lpName != NULL) - { - RtlInitAnsiString(&Name, - (LPSTR)lpName); - RtlAnsiStringToUnicodeString(&NameU, - &Name, - TRUE); - } - - Handle = CreateSemaphoreW(lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - (lpName ? NameU.Buffer : NULL)); - - if (lpName != NULL) - { - RtlFreeUnicodeString (&NameU); - } - - return Handle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, - LONG lMaximumCount, - LPCWSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status; - UNICODE_STRING UnicodeName; - HANDLE SemaphoreHandle; - - if (lpName != NULL) - { - RtlInitUnicodeString(&UnicodeName, lpName); - } - - InitializeObjectAttributes(&ObjectAttributes, - (lpName ? &UnicodeName : NULL), - 0, - (lpName ? hBaseDir : NULL), - NULL); - - if (lpSemaphoreAttributes != NULL) - { - ObjectAttributes.SecurityDescriptor = lpSemaphoreAttributes->lpSecurityDescriptor; - if (lpSemaphoreAttributes->bInheritHandle) - { - ObjectAttributes.Attributes |= OBJ_INHERIT; - } - } - - Status = NtCreateSemaphore(&SemaphoreHandle, - SEMAPHORE_ALL_ACCESS, - &ObjectAttributes, - lInitialCount, - lMaximumCount); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - return SemaphoreHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenSemaphoreA(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING NameU; - ANSI_STRING Name; - HANDLE Handle; - NTSTATUS Status; - - if (lpName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitAnsiString(&Name, - (LPSTR)lpName); - RtlAnsiStringToUnicodeString(&NameU, - &Name, - TRUE); - - InitializeObjectAttributes(&ObjectAttributes, - &NameU, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenSemaphore(&Handle, - (ACCESS_MASK)dwDesiredAccess, - &ObjectAttributes); - - RtlFreeUnicodeString(&NameU); - - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return Handle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenSemaphoreW(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCWSTR lpName) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING Name; - HANDLE Handle; - NTSTATUS Status; - - if (lpName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitUnicodeString(&Name, - (LPWSTR)lpName); - - InitializeObjectAttributes(&ObjectAttributes, - &Name, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenSemaphore(&Handle, - (ACCESS_MASK)dwDesiredAccess, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return Handle; -} - - -/* - * @implemented - */ -BOOL STDCALL -ReleaseSemaphore(HANDLE hSemaphore, - LONG lReleaseCount, - LPLONG lpPreviousCount) -{ - NTSTATUS Status; - - Status = NtReleaseSemaphore(hSemaphore, - lReleaseCount, - lpPreviousCount); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - return TRUE; +HANDLE +WINAPI +CreateSemaphoreA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, + IN LONG lInitialCount, + IN LONG lMaximumCount, + IN LPCSTR lpName OPTIONAL) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + LPCWSTR UnicodeName = NULL; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Otherwise, save the buffer */ + UnicodeName = (LPCWSTR)UnicodeCache->Buffer; + } + + /* Call the Unicode API */ + return CreateSemaphoreW(lpSemaphoreAttributes, + lInitialCount, + lMaximumCount, + UnicodeName); +} + +/* + * @implemented + */ +HANDLE +WINAPI +CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, + IN LONG lInitialCount, + IN LONG lMaximumCount, + IN LPCWSTR lpName OPTIONAL) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES LocalAttributes; + POBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + UNICODE_STRING ObjectName; + + /* Now check if we got a name */ + if (lpName) RtlInitUnicodeString(&ObjectName, lpName); + + /* Now convert the object attributes */ + ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, + lpSemaphoreAttributes, + lpName ? &ObjectName : NULL); + + /* Create the semaphore */ + Status = NtCreateSemaphore(&Handle, + SEMAPHORE_ALL_ACCESS, + ObjectAttributes, + lInitialCount, + lMaximumCount); + if (NT_SUCCESS(Status)) + { + /* Check if the object already existed */ + if (Status == STATUS_OBJECT_NAME_EXISTS) + { + /* Set distinguished Win32 error code */ + SetLastError(ERROR_ALREADY_EXISTS); + } + else + { + /* Otherwise, set success */ + SetLastError(ERROR_SUCCESS); + } + + /* Return the handle */ + return Handle; + } + else + { + /* Convert the NT Status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenSemaphoreA(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCSTR lpName) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + + /* Check for a name */ + if (lpName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + } + else + { + /* We need a name */ + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + /* Call the Unicode API */ + return OpenSemaphoreW(dwDesiredAccess, + bInheritHandle, + (LPCWSTR)UnicodeCache->Buffer); +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenSemaphoreW(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCWSTR lpName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ObjectName; + NTSTATUS Status; + HANDLE Handle; + + /* Make sure we got a name */ + if (!lpName) + { + /* Fail without one */ + SetLastErrorByStatus(STATUS_INVALID_PARAMETER); + return NULL; + } + + /* Initialize the object name and attributes */ + RtlInitUnicodeString(&ObjectName, lpName); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + bInheritHandle ? OBJ_INHERIT : 0, + hBaseDir, + NULL); + + /* Open the semaphore */ + Status = NtOpenSemaphore(&Handle, dwDesiredAccess, &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + /* Convert the status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Return the handle */ + return Handle; +} + +/* + * @implemented + */ +BOOL +WINAPI +ReleaseSemaphore(IN HANDLE hSemaphore, + IN LONG lReleaseCount, + IN LPLONG lpPreviousCount) +{ + NTSTATUS Status; + + /* Release the semaphore */ + Status = NtReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/synch/timer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/t…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/timer.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/timer.c Wed Jun 28 21:08:35 2006 @@ -1,224 +1,244 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/kernel32/synch/timer.c - * PURPOSE: Implementing timer - * PROGRAMMER: - */ - -/* INCLUDES ******************************************************************/ +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/timer.c + * PURPOSE: Wrappers for the NT Timer Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES *****************************************************************/ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - - -/* FUNCTIONS *****************************************************************/ - -/* - * @implemented - */ -HANDLE STDCALL -CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, - BOOL bManualReset, - LPCWSTR lpTimerName) -{ - NTSTATUS Status; - HANDLE TimerHandle; - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING UnicodeName; - - if (lpTimerName) - { - RtlInitUnicodeString(&UnicodeName, lpTimerName); - } - - InitializeObjectAttributes(&ObjectAttributes, - (lpTimerName ? &UnicodeName : NULL), - 0, - (lpTimerName ? hBaseDir : NULL), - NULL); - - if (lpTimerAttributes != NULL) - { - ObjectAttributes.SecurityDescriptor = lpTimerAttributes->lpSecurityDescriptor; - if(lpTimerAttributes->bInheritHandle) - { - ObjectAttributes.Attributes |= OBJ_INHERIT; - } - } - - Status = NtCreateTimer(&TimerHandle, - TIMER_ALL_ACCESS, - &ObjectAttributes, - (bManualReset ? NotificationTimer : SynchronizationTimer)); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return TimerHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, - BOOL bManualReset, - LPCSTR lpTimerName) -{ - UNICODE_STRING TimerNameU; - ANSI_STRING TimerName; - HANDLE TimerHandle; - - if (lpTimerName != NULL) - { - RtlInitAnsiString (&TimerName, - (LPSTR)lpTimerName); - RtlAnsiStringToUnicodeString (&TimerNameU, - &TimerName, - TRUE); - } - - TimerHandle = CreateWaitableTimerW (lpTimerAttributes, - bManualReset, - (lpTimerName ? TimerNameU.Buffer : NULL)); - - if (lpTimerName != NULL) - { - RtlFreeUnicodeString (&TimerNameU); - } - - return TimerHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenWaitableTimerW(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCWSTR lpTimerName) -{ - NTSTATUS Status; - HANDLE TimerHandle; - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING UnicodeName; - - if (lpTimerName == NULL) - { - SetLastErrorByStatus(STATUS_INVALID_PARAMETER); - return NULL; - } - - RtlInitUnicodeString(&UnicodeName, - lpTimerName); - InitializeObjectAttributes(&ObjectAttributes, - &UnicodeName, - (bInheritHandle ? OBJ_INHERIT : 0), - hBaseDir, - NULL); - - Status = NtOpenTimer(&TimerHandle, - dwDesiredAccess, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return TimerHandle; -} - - -/* - * @implemented - */ -HANDLE STDCALL -OpenWaitableTimerA(DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpTimerName) -{ - UNICODE_STRING TimerNameU; - ANSI_STRING TimerName; - HANDLE TimerHandle; - - if (lpTimerName == NULL) - { +#include "debug.h" + +/* FUNCTIONS ****************************************************************/ + +/* + * @implemented + */ +HANDLE +WINAPI +CreateWaitableTimerW(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, + IN BOOL bManualReset, + IN LPCWSTR lpTimerName OPTIONAL) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES LocalAttributes; + POBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + UNICODE_STRING ObjectName; + + /* Now check if we got a name */ + if (lpTimerName) RtlInitUnicodeString(&ObjectName, lpTimerName); + + /* Now convert the object attributes */ + ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, + lpTimerAttributes, + lpTimerName ? &ObjectName : NULL); + + /* Create the timer */ + Status = NtCreateTimer(&Handle, + TIMER_ALL_ACCESS, + ObjectAttributes, + bManualReset ? + NotificationTimer : SynchronizationTimer); + if (NT_SUCCESS(Status)) + { + /* Check if the object already existed */ + if (Status == STATUS_OBJECT_NAME_EXISTS) + { + /* Set distinguished Win32 error code */ + SetLastError(ERROR_ALREADY_EXISTS); + } + else + { + /* Otherwise, set success */ + SetLastError(ERROR_SUCCESS); + } + + /* Return the handle */ + return Handle; + } + else + { + /* Convert the NT Status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } +} + +/* + * @implemented + */ +HANDLE +WINAPI +CreateWaitableTimerA(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, + IN BOOL bManualReset, + IN LPCSTR lpTimerName OPTIONAL) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + LPCWSTR UnicodeName = NULL; + + /* Check for a name */ + if (lpTimerName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpTimerName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Otherwise, save the buffer */ + UnicodeName = (LPCWSTR)UnicodeCache->Buffer; + } + + /* Call the Unicode API */ + return CreateWaitableTimerW(lpTimerAttributes, + bManualReset, + UnicodeName); +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenWaitableTimerW(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCWSTR lpTimerName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ObjectName; + NTSTATUS Status; + HANDLE Handle; + + /* Make sure we got a name */ + if (!lpTimerName) + { + /* Fail without one */ SetLastErrorByStatus(STATUS_INVALID_PARAMETER); return NULL; - } - - RtlInitAnsiString (&TimerName, - (LPSTR)lpTimerName); - RtlAnsiStringToUnicodeString (&TimerNameU, - &TimerName, - TRUE); - - TimerHandle = OpenWaitableTimerW (dwDesiredAccess, - bInheritHandle, - TimerNameU.Buffer); - - RtlFreeUnicodeString (&TimerNameU); - - return TimerHandle; -} - - -/* - * @implemented - */ -BOOL STDCALL -SetWaitableTimer(HANDLE hTimer, - const LARGE_INTEGER *pDueTime, - LONG lPeriod, - PTIMERAPCROUTINE pfnCompletionRoutine, - LPVOID lpArgToCompletionRoutine, - BOOL fResume) -{ - NTSTATUS Status; - BOOLEAN pState; - - Status = NtSetTimer(hTimer, - (LARGE_INTEGER *)pDueTime, - (PTIMER_APC_ROUTINE)pfnCompletionRoutine, - lpArgToCompletionRoutine, - fResume, - lPeriod, - &pState); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - return TRUE; -} - - -/* - * @implemented - */ -BOOL STDCALL -CancelWaitableTimer(HANDLE hTimer) -{ - NTSTATUS Status; - BOOLEAN CurrentState; - - Status = NtCancelTimer(hTimer, - &CurrentState); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - return TRUE; + } + + /* Initialize the object name and attributes */ + RtlInitUnicodeString(&ObjectName, lpTimerName); + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + bInheritHandle ? OBJ_INHERIT : 0, + hBaseDir, + NULL); + + /* Open the timer */ + Status = NtOpenTimer(&Handle, dwDesiredAccess, &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + /* Convert the status and fail */ + SetLastErrorByStatus(Status); + return NULL; + } + + /* Return the handle */ + return Handle; +} + +/* + * @implemented + */ +HANDLE +WINAPI +OpenWaitableTimerA(IN DWORD dwDesiredAccess, + IN BOOL bInheritHandle, + IN LPCSTR lpTimerName) +{ + NTSTATUS Status; + ANSI_STRING AnsiName; + PUNICODE_STRING UnicodeCache; + + /* Check for a name */ + if (lpTimerName) + { + /* Use TEB Cache */ + UnicodeCache = &NtCurrentTeb()->StaticUnicodeString; + + /* Convert to unicode */ + RtlInitAnsiString(&AnsiName, lpTimerName); + Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE); + if (!NT_SUCCESS(Status)) + { + /* Conversion failed */ + SetLastErrorByStatus(Status); + return NULL; + } + } + else + { + /* We need a name */ + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + /* Call the Unicode API */ + return OpenWaitableTimerW(dwDesiredAccess, + bInheritHandle, + (LPCWSTR)UnicodeCache->Buffer); +} + +/* + * @implemented + */ +BOOL +WINAPI +SetWaitableTimer(IN HANDLE hTimer, + IN const LARGE_INTEGER *pDueTime, + IN LONG lPeriod, + IN PTIMERAPCROUTINE pfnCompletionRoutine OPTIONAL, + IN OPTIONAL LPVOID lpArgToCompletionRoutine, + IN BOOL fResume) +{ + NTSTATUS Status; + + /* Set the timer */ + Status = NtSetTimer(hTimer, + (PLARGE_INTEGER)pDueTime, + (PTIMER_APC_ROUTINE)pfnCompletionRoutine, + lpArgToCompletionRoutine, + fResume, + lPeriod, + NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; +} + +/* + * @implemented + */ +BOOL +WINAPI +CancelWaitableTimer(IN HANDLE hTimer) +{ + NTSTATUS Status; + + /* Cancel the timer */ + Status = NtCancelTimer(hTimer, NULL); + if (NT_SUCCESS(Status)) return TRUE; + + /* If we got here, then we failed */ + SetLastErrorByStatus(Status); + return FALSE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/synch/wait.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/synch/w…
============================================================================== --- trunk/reactos/dll/win32/kernel32/synch/wait.c (original) +++ trunk/reactos/dll/win32/kernel32/synch/wait.c Wed Jun 28 21:08:35 2006 @@ -1,12 +1,9 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/synch/wait.c - * PURPOSE: Wait functions - * PROGRAMMER: Ariadne ( ariadne(a)xs4all.nl) - * UPDATE HISTORY: - * Created 01/11/98 +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/synch/wait.c + * PURPOSE: Wrappers for the NT Wait Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES *****************************************************************/ @@ -14,296 +11,310 @@ #include <k32.h> #define NDEBUG -#include "../include/debug.h" - - -/* FUNCTIONS ****************************************************************/ - -DWORD STDCALL -GetConsoleInputWaitHandle (VOID); - -/* - * @implemented - */ -DWORD STDCALL -WaitForSingleObject(HANDLE hHandle, - DWORD dwMilliseconds) -{ - return WaitForSingleObjectEx(hHandle, - dwMilliseconds, - FALSE); -} - - -/* - * @implemented - */ -DWORD STDCALL -WaitForSingleObjectEx(HANDLE hHandle, - DWORD dwMilliseconds, - BOOL bAlertable) +#include "debug.h" + +/* FUNCTIONS *****************************************************************/ + +/* + * @implemented + */ +DWORD +WINAPI +WaitForSingleObject(IN HANDLE hHandle, + IN DWORD dwMilliseconds) +{ + /* Call the extended API */ + return WaitForSingleObjectEx(hHandle, dwMilliseconds, FALSE); +} + +/* + * @implemented + */ +DWORD +WINAPI +WaitForSingleObjectEx(IN HANDLE hHandle, + IN DWORD dwMilliseconds, + IN BOOL bAlertable) { PLARGE_INTEGER TimePtr; LARGE_INTEGER Time; NTSTATUS Status; - /* Get real handle */ - switch ((ULONG)hHandle) - { - case STD_INPUT_HANDLE: - hHandle = NtCurrentPeb()->ProcessParameters->StandardInput; - break; - - case STD_OUTPUT_HANDLE: - hHandle = NtCurrentPeb()->ProcessParameters->StandardOutput; - break; - - case STD_ERROR_HANDLE: - hHandle = NtCurrentPeb()->ProcessParameters->StandardError; - break; - } - - /* Check for console handle */ - if (IsConsoleHandle(hHandle)) - { - if (!VerifyConsoleIoHandle(hHandle)) - { - SetLastError (ERROR_INVALID_HANDLE); - return WAIT_FAILED; - } - - hHandle = (HANDLE)GetConsoleInputWaitHandle(); - if (hHandle == NULL || hHandle == INVALID_HANDLE_VALUE) - { - SetLastError (ERROR_INVALID_HANDLE); - return WAIT_FAILED; - - } - } - - if (dwMilliseconds == INFINITE) - { - TimePtr = NULL; - } - else - { - Time.QuadPart = -10000 * (LONGLONG)dwMilliseconds; - TimePtr = &Time; - } - - do - { - Status = NtWaitForSingleObject(hHandle, - (BOOLEAN) bAlertable, - TimePtr); - - if (HIWORD(Status)) - { - SetLastErrorByStatus (Status); - return WAIT_FAILED; - } - - } while (Status == STATUS_ALERTED && bAlertable); - - return Status; -} - - -/* - * @implemented - */ -DWORD STDCALL -WaitForMultipleObjects(DWORD nCount, - CONST HANDLE *lpHandles, - BOOL bWaitAll, - DWORD dwMilliseconds) -{ - return WaitForMultipleObjectsEx(nCount, - lpHandles, - bWaitAll, - dwMilliseconds, - FALSE); -} - - -/* - * @implemented - */ -DWORD STDCALL -WaitForMultipleObjectsEx(DWORD nCount, - CONST HANDLE *lpHandles, - BOOL bWaitAll, - DWORD dwMilliseconds, - BOOL bAlertable) -{ - PLARGE_INTEGER TimePtr; - LARGE_INTEGER Time; - PHANDLE HandleBuffer; - HANDLE Handle[3]; - DWORD i; - NTSTATUS Status; - - DPRINT("nCount %lu\n", nCount); - - if (nCount > 3) - { - HandleBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, nCount * sizeof(HANDLE)); - if (HandleBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return WAIT_FAILED; - } - } - else - { - HandleBuffer = Handle; - } - for (i = 0; i < nCount; i++) - { - switch ((DWORD)lpHandles[i]) - { - case STD_INPUT_HANDLE: - HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardInput; - break; - - case STD_OUTPUT_HANDLE: - HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardOutput; - break; - - case STD_ERROR_HANDLE: - HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardError; - break; - - default: - HandleBuffer[i] = lpHandles[i]; - break; - } - - /* Check for console handle */ - if (IsConsoleHandle(HandleBuffer[i])) - { - if (!VerifyConsoleIoHandle(HandleBuffer[i])) - { - if (HandleBuffer != Handle) - { - RtlFreeHeap(GetProcessHeap(),0,HandleBuffer); - } - SetLastError (ERROR_INVALID_HANDLE); - return WAIT_FAILED; - } - HandleBuffer[i] = (HANDLE)GetConsoleInputWaitHandle(); - if (HandleBuffer[i] == NULL || HandleBuffer[i] == INVALID_HANDLE_VALUE) - { - if (HandleBuffer != Handle) - { - RtlFreeHeap(GetProcessHeap(),0,HandleBuffer); - } - SetLastError (ERROR_INVALID_HANDLE); - return WAIT_FAILED; - } - } - } - - if (dwMilliseconds == INFINITE) - { - TimePtr = NULL; - } - else - { - Time.QuadPart = -10000 * (LONGLONG)dwMilliseconds; - TimePtr = &Time; - } - - do - { - Status = NtWaitForMultipleObjects (nCount, - HandleBuffer, - bWaitAll ? WaitAll : WaitAny, - (BOOLEAN)bAlertable, - TimePtr); - if (HIWORD(Status)) - { - SetLastErrorByStatus (Status); - Status = WAIT_FAILED; - } - - } while (Status == STATUS_ALERTED && bAlertable); - - if (HandleBuffer != Handle) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, HandleBuffer); - } - - return Status; -} - - -/* - * @implemented - */ -DWORD STDCALL -SignalObjectAndWait(HANDLE hObjectToSignal, - HANDLE hObjectToWaitOn, - DWORD dwMilliseconds, - BOOL bAlertable) -{ - PLARGE_INTEGER TimePtr; - LARGE_INTEGER Time; - NTSTATUS Status; - - /* Get real handle */ - switch ((ULONG)hObjectToWaitOn) - { - case STD_INPUT_HANDLE: - hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardInput; - break; - - case STD_OUTPUT_HANDLE: - hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardOutput; - break; - - case STD_ERROR_HANDLE: - hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardError; - break; - } - - /* Check for console handle */ - if (IsConsoleHandle(hObjectToWaitOn)) - { - if (VerifyConsoleIoHandle(hObjectToWaitOn)) - { - DPRINT1("Console handles are not supported yet!\n"); - SetLastError(ERROR_INVALID_HANDLE); - return WAIT_FAILED; - } - } - - if (dwMilliseconds == INFINITE) - { - TimePtr = NULL; - } - else - { - Time.QuadPart = -10000 * (LONGLONG)dwMilliseconds; - TimePtr = &Time; - } - - do - { - Status = NtSignalAndWaitForSingleObject (hObjectToSignal, - hObjectToWaitOn, - (BOOLEAN)bAlertable, - TimePtr); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus (Status); - return WAIT_FAILED; - } - - } while (Status == STATUS_ALERTED && bAlertable); - - /* STATUS_SUCCESS maps to WAIT_OBJECT_0 */ - return Status; + /* Get real handle */ + switch ((ULONG)hHandle) + { + /* Input handle */ + case STD_INPUT_HANDLE: + + /* Read it from the PEB */ + hHandle = NtCurrentPeb()->ProcessParameters->StandardInput; + break; + + /* Output handle */ + case STD_OUTPUT_HANDLE: + + /* Read it from the PEB */ + hHandle = NtCurrentPeb()->ProcessParameters->StandardOutput; + break; + + /* Error handle */ + case STD_ERROR_HANDLE: + + /* Read it from the PEB */ + hHandle = NtCurrentPeb()->ProcessParameters->StandardError; + break; + } + + /* Check for console handle */ + if ((IsConsoleHandle(hHandle)) && (!VerifyConsoleIoHandle(hHandle))) + { + /* Get the real wait handle */ + hHandle = GetConsoleInputWaitHandle(); + } + + /* Check if this is an infinite wait */ + if (dwMilliseconds == INFINITE) + { + /* Under NT, this means no timer argument */ + TimePtr = NULL; + } + else + { + /* Otherwise, convert the time to NT Format */ + Time.QuadPart = UInt32x32To64(-10000, dwMilliseconds); + TimePtr = &Time; + } + + /* Start wait loop */ + do + { + /* Do the wait */ + Status = NtWaitForSingleObject(hHandle, (BOOLEAN)bAlertable, TimePtr); + if (!NT_SUCCESS(Status)) + { + /* The wait failed */ + SetLastErrorByStatus (Status); + return WAIT_FAILED; + } + } while ((Status == STATUS_ALERTED) && (bAlertable)); + + /* Return wait status */ + return Status; +} + +/* + * @implemented + */ +DWORD +WINAPI +WaitForMultipleObjects(IN DWORD nCount, + IN CONST HANDLE *lpHandles, + IN BOOL bWaitAll, + IN DWORD dwMilliseconds) +{ + /* Call the extended API */ + return WaitForMultipleObjectsEx(nCount, + lpHandles, + bWaitAll, + dwMilliseconds, + FALSE); +} + +/* + * @implemented + */ +DWORD +WINAPI +WaitForMultipleObjectsEx(IN DWORD nCount, + IN CONST HANDLE *lpHandles, + IN BOOL bWaitAll, + IN DWORD dwMilliseconds, + IN BOOL bAlertable) +{ + PLARGE_INTEGER TimePtr; + LARGE_INTEGER Time; + PHANDLE HandleBuffer; + HANDLE Handle[8]; + DWORD i; + NTSTATUS Status; + + /* Check if we have more handles then we locally optimize */ + if (nCount > 8) + { + /* Allocate a buffer for them */ + HandleBuffer = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + nCount * sizeof(HANDLE)); + if (!HandleBuffer) + { + /* No buffer, fail the wait */ + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return WAIT_FAILED; + } + } + else + { + /* Otherwise, use our local buffer */ + HandleBuffer = Handle; + } + + /* Copy the handles into our buffer and loop them all */ + RtlCopyMemory(HandleBuffer, (LPVOID)lpHandles, nCount * sizeof(HANDLE)); + for (i = 0; i < nCount; i++) + { + /* Check what kind of handle this is */ + switch ((ULONG)HandleBuffer[i]) + { + /* Input handle */ + case STD_INPUT_HANDLE: + HandleBuffer[i] = NtCurrentPeb()-> + ProcessParameters->StandardInput; + break; + + /* Output handle */ + case STD_OUTPUT_HANDLE: + HandleBuffer[i] = NtCurrentPeb()-> + ProcessParameters->StandardOutput; + break; + + /* Error handle */ + case STD_ERROR_HANDLE: + HandleBuffer[i] = NtCurrentPeb()-> + ProcessParameters->StandardError; + break; + } + + /* Check for console handle */ + if ((IsConsoleHandle(HandleBuffer[i])) && + (!VerifyConsoleIoHandle(HandleBuffer[i]))) + { + /* Get the real wait handle */ + HandleBuffer[i] = GetConsoleInputWaitHandle(); + } + } + + /* Check if this is an infinite wait */ + if (dwMilliseconds == INFINITE) + { + /* Under NT, this means no timer argument */ + TimePtr = NULL; + } + else + { + /* Otherwise, convert the time to NT Format */ + Time.QuadPart = UInt32x32To64(-10000, dwMilliseconds); + TimePtr = &Time; + } + + /* Start wait loop */ + do + { + /* Do the wait */ + Status = NtWaitForMultipleObjects(nCount, + HandleBuffer, + bWaitAll ? WaitAll : WaitAny, + (BOOLEAN)bAlertable, + TimePtr); + if (!NT_SUCCESS(Status)) + { + /* Wait failed */ + SetLastErrorByStatus (Status); + return WAIT_FAILED; + } + } while ((Status == STATUS_ALERTED) && (bAlertable)); + + /* Check if we didn't use our local buffer */ + if (HandleBuffer != Handle) + { + /* Free the allocated one */ + RtlFreeHeap(RtlGetProcessHeap(), 0, HandleBuffer); + } + + /* Return wait status */ + return Status; +} + +/* + * @implemented + */ +DWORD +WINAPI +SignalObjectAndWait(IN HANDLE hObjectToSignal, + IN HANDLE hObjectToWaitOn, + IN DWORD dwMilliseconds, + IN BOOL bAlertable) +{ + PLARGE_INTEGER TimePtr; + LARGE_INTEGER Time; + NTSTATUS Status; + + /* Get real handle */ + switch ((ULONG)hObjectToWaitOn) + { + /* Input handle */ + case STD_INPUT_HANDLE: + + /* Read it from the PEB */ + hObjectToWaitOn = NtCurrentPeb()-> + ProcessParameters->StandardInput; + break; + + /* Output handle */ + case STD_OUTPUT_HANDLE: + + /* Read it from the PEB */ + hObjectToWaitOn = NtCurrentPeb()-> + ProcessParameters->StandardOutput; + break; + + /* Error handle */ + case STD_ERROR_HANDLE: + + /* Read it from the PEB */ + hObjectToWaitOn = NtCurrentPeb()-> + ProcessParameters->StandardError; + break; + } + + /* Check for console handle */ + if ((IsConsoleHandle(hObjectToWaitOn)) && + (!VerifyConsoleIoHandle(hObjectToWaitOn))) + { + /* Get the real wait handle */ + hObjectToWaitOn = GetConsoleInputWaitHandle(); + } + + /* Check if this is an infinite wait */ + if (dwMilliseconds == INFINITE) + { + /* Under NT, this means no timer argument */ + TimePtr = NULL; + } + else + { + /* Otherwise, convert the time to NT Format */ + Time.QuadPart = UInt32x32To64(-10000, dwMilliseconds); + TimePtr = &Time; + } + + /* Start wait loop */ + do + { + /* Do the wait */ + Status = NtSignalAndWaitForSingleObject(hObjectToSignal, + hObjectToWaitOn, + (BOOLEAN)bAlertable, + TimePtr); + if (!NT_SUCCESS(Status)) + { + /* The wait failed */ + SetLastErrorByStatus (Status); + return WAIT_FAILED; + } + } while ((Status == STATUS_ALERTED) && (bAlertable)); + + /* Return wait status */ + return Status; } /* EOF */
18 years, 5 months
1
0
0
0
[ion] 22675: - Implement, export and NDKize: DbgUiGetThreadDebugObject, DbgUiDebugActiveProcess, DbgUiStopDebugging, NtSetInformationDebugObject. - Make CheckRemoteDebuggerPresent fail if no process was specified. - Implement DebugActiveProcess, DebugActiveProcessStop, DebugBreakProcess, DebugSetProcessKillOnExit. - Add *.vcproj to ignore lists.
by ion@svn.reactos.org
Author: ion Date: Wed Jun 28 21:02:37 2006 New Revision: 22675 URL:
http://svn.reactos.org/svn/reactos?rev=22675&view=rev
Log: - Implement, export and NDKize: DbgUiGetThreadDebugObject, DbgUiDebugActiveProcess, DbgUiStopDebugging, NtSetInformationDebugObject. - Make CheckRemoteDebuggerPresent fail if no process was specified. - Implement DebugActiveProcess, DebugActiveProcessStop, DebugBreakProcess, DebugSetProcessKillOnExit. - Add *.vcproj to ignore lists. Removed: trunk/reactos/dll/win32/kernel32/debug/break.c Modified: trunk/reactos/dll/3rdparty/freetype/ (props changed) trunk/reactos/dll/3rdparty/mesa32/ (props changed) trunk/reactos/dll/cpl/access/ (props changed) trunk/reactos/dll/cpl/appwiz/ (props changed) trunk/reactos/dll/cpl/desk/ (props changed) trunk/reactos/dll/cpl/hdwwiz/ (props changed) trunk/reactos/dll/cpl/intl/ (props changed) trunk/reactos/dll/cpl/intl_new/ (props changed) trunk/reactos/dll/cpl/main/ (props changed) trunk/reactos/dll/cpl/mmsys/ (props changed) trunk/reactos/dll/cpl/ncpa/ (props changed) trunk/reactos/dll/cpl/powercfg/ (props changed) trunk/reactos/dll/cpl/sysdm/ (props changed) trunk/reactos/dll/cpl/timedate/ (props changed) trunk/reactos/dll/directx/d3d8thk/ (props changed) trunk/reactos/dll/directx/ddraw/ (props changed) trunk/reactos/dll/directx/devenum/ (props changed) trunk/reactos/dll/directx/dinput/ (props changed) trunk/reactos/dll/directx/dinput8/ (props changed) trunk/reactos/dll/directx/dplay/ (props changed) trunk/reactos/dll/directx/dplayx/ (props changed) trunk/reactos/dll/directx/dsound/ (props changed) trunk/reactos/dll/directx/dxdiagn/ (props changed) trunk/reactos/dll/keyboard/kbdbe/ (props changed) trunk/reactos/dll/keyboard/kbdda/ (props changed) trunk/reactos/dll/keyboard/kbddv/ (props changed) trunk/reactos/dll/keyboard/kbdes/ (props changed) trunk/reactos/dll/keyboard/kbdfr/ (props changed) trunk/reactos/dll/keyboard/kbdgr/ (props changed) trunk/reactos/dll/keyboard/kbdhe/ (props changed) trunk/reactos/dll/keyboard/kbdheb/ (props changed) trunk/reactos/dll/keyboard/kbdhu/ (props changed) trunk/reactos/dll/keyboard/kbdpo/ (props changed) trunk/reactos/dll/keyboard/kbdru/ (props changed) trunk/reactos/dll/keyboard/kbdse/ (props changed) trunk/reactos/dll/keyboard/kbdsg/ (props changed) trunk/reactos/dll/keyboard/kbdsk/ (props changed) trunk/reactos/dll/keyboard/kbduk/ (props changed) trunk/reactos/dll/keyboard/kbdur/ (props changed) trunk/reactos/dll/keyboard/kbdus/ (props changed) trunk/reactos/dll/ntdll/ (props changed) trunk/reactos/dll/ntdll/dbg/dbgui.c (contents, props changed) trunk/reactos/dll/ntdll/def/ntdll.def trunk/reactos/dll/win32/acledit/ (props changed) trunk/reactos/dll/win32/aclui/ (props changed) trunk/reactos/dll/win32/advapi32/ (props changed) trunk/reactos/dll/win32/advpack/ (props changed) trunk/reactos/dll/win32/authz/ (props changed) trunk/reactos/dll/win32/avifil32/ (props changed) trunk/reactos/dll/win32/cabinet/ (props changed) trunk/reactos/dll/win32/cards/ (props changed) trunk/reactos/dll/win32/cfgmgr32/ (props changed) trunk/reactos/dll/win32/comctl32/ (props changed) trunk/reactos/dll/win32/comdlg32/ (props changed) trunk/reactos/dll/win32/crtdll/ (props changed) trunk/reactos/dll/win32/crypt32/ (props changed) trunk/reactos/dll/win32/cryptdll/ (props changed) trunk/reactos/dll/win32/dbghelp/ (props changed) trunk/reactos/dll/win32/devmgr/ (props changed) trunk/reactos/dll/win32/dhcpcsvc/ (props changed) trunk/reactos/dll/win32/dnsapi/ (props changed) trunk/reactos/dll/win32/fmifs/ (props changed) trunk/reactos/dll/win32/gdi32/ (props changed) trunk/reactos/dll/win32/gdiplus/ (props changed) trunk/reactos/dll/win32/glu32/ (props changed) trunk/reactos/dll/win32/hid/ (props changed) trunk/reactos/dll/win32/icmp/ (props changed) trunk/reactos/dll/win32/imagehlp/ (props changed) trunk/reactos/dll/win32/imm32/ (props changed) trunk/reactos/dll/win32/iphlpapi/ (props changed) trunk/reactos/dll/win32/kernel32/ (props changed) trunk/reactos/dll/win32/kernel32/debug/debugger.c trunk/reactos/dll/win32/kernel32/include/kernel32.h trunk/reactos/dll/win32/kernel32/kernel32.rbuild trunk/reactos/dll/win32/kernel32/misc/console.c trunk/reactos/dll/win32/kernel32/tests/ (props changed) trunk/reactos/dll/win32/lsasrv/ (props changed) trunk/reactos/dll/win32/lzexpand/ (props changed) trunk/reactos/dll/win32/mapi32/ (props changed) trunk/reactos/dll/win32/mmdrv/ (props changed) trunk/reactos/dll/win32/mpr/ (props changed) trunk/reactos/dll/win32/msacm/ (props changed) trunk/reactos/dll/win32/msafd/ (props changed) trunk/reactos/dll/win32/msgina/ (props changed) trunk/reactos/dll/win32/msi/ (props changed) trunk/reactos/dll/win32/msimg32/ (props changed) trunk/reactos/dll/win32/msvcrt/ (props changed) trunk/reactos/dll/win32/msvcrt20/ (props changed) trunk/reactos/dll/win32/msvideo/ (props changed) trunk/reactos/dll/win32/mswsock/ (props changed) trunk/reactos/dll/win32/netapi32/ (props changed) trunk/reactos/dll/win32/netcfgx/ (props changed) trunk/reactos/dll/win32/newdev/ (props changed) trunk/reactos/dll/win32/ntmarta/ (props changed) trunk/reactos/dll/win32/objsel/ (props changed) trunk/reactos/dll/win32/ole32/ (props changed) trunk/reactos/dll/win32/oleacc/ (props changed) trunk/reactos/dll/win32/oleaut32/ (props changed) trunk/reactos/dll/win32/oledlg/ (props changed) trunk/reactos/dll/win32/olepro32/ (props changed) trunk/reactos/dll/win32/opengl32/ (props changed) trunk/reactos/dll/win32/powrprof/ (props changed) trunk/reactos/dll/win32/psapi/ (props changed) trunk/reactos/dll/win32/riched20/ (props changed) trunk/reactos/dll/win32/richedit/ (props changed) trunk/reactos/dll/win32/rpcrt4/ (props changed) trunk/reactos/dll/win32/samlib/ (props changed) trunk/reactos/dll/win32/samsrv/ (props changed) trunk/reactos/dll/win32/secur32/ (props changed) trunk/reactos/dll/win32/security/ (props changed) trunk/reactos/dll/win32/serialui/ (props changed) trunk/reactos/dll/win32/setupapi/ (props changed) trunk/reactos/dll/win32/shdocvw/ (props changed) trunk/reactos/dll/win32/shell32/ (props changed) trunk/reactos/dll/win32/shellext/slayer/ (props changed) trunk/reactos/dll/win32/shfolder/ (props changed) trunk/reactos/dll/win32/shlwapi/ (props changed) trunk/reactos/dll/win32/smdll/ (props changed) trunk/reactos/dll/win32/snmpapi/ (props changed) trunk/reactos/dll/win32/syssetup/ (props changed) trunk/reactos/dll/win32/twain/ (props changed) trunk/reactos/dll/win32/urlmon/ (props changed) trunk/reactos/dll/win32/user32/ (props changed) trunk/reactos/dll/win32/userenv/ (props changed) trunk/reactos/dll/win32/uxtheme/ (props changed) trunk/reactos/dll/win32/vdmdbg/ (props changed) trunk/reactos/dll/win32/version/ (props changed) trunk/reactos/dll/win32/wininet/ (props changed) trunk/reactos/dll/win32/winmm/ (props changed) trunk/reactos/dll/win32/winmm/midimap/ (props changed) trunk/reactos/dll/win32/winmm/wavemap/ (props changed) trunk/reactos/dll/win32/winspool/ (props changed) trunk/reactos/dll/win32/wintrust/ (props changed) trunk/reactos/dll/win32/ws2_32/ (props changed) trunk/reactos/dll/win32/ws2help/ (props changed) trunk/reactos/dll/win32/wshirda/ (props changed) trunk/reactos/dll/win32/wsock32/ (props changed) trunk/reactos/include/ndk/dbgkfuncs.h trunk/reactos/include/ndk/umfuncs.h trunk/reactos/include/reactos/idl/ (props changed) trunk/reactos/ntoskrnl/ (props changed) trunk/reactos/tools/nci/sysfuncs.lst Propchange: trunk/reactos/dll/3rdparty/freetype/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ doxy-doc freetype.coff GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/3rdparty/mesa32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/access/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ Debug Release GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/appwiz/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ Debug Release GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/desk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ Debug Release GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/hdwwiz/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/intl/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/intl_new/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,0 +1,1 @@ +*.vcproj Propchange: trunk/reactos/dll/cpl/main/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/mmsys/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/ncpa/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -14,3 +14,4 @@ Debug Release GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/powercfg/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,0 +1,1 @@ +*.vcproj Propchange: trunk/reactos/dll/cpl/sysdm/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/cpl/timedate/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/d3d8thk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.tmp *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/ddraw/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/devenum/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ devenum.spec.def devenum.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dinput/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dinput8/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dplay/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dplayx/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dsound/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ dsound.spec.def dsound.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/directx/dxdiagn/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdbe/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdda/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbddv/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdes/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -16,3 +16,4 @@ *.bak *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdfr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdgr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdhe/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdheb/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdhu/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdpo/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,0 +1,1 @@ +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdru/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdse/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdsg/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdsk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbduk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdur/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/keyboard/kbdus/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/ntdll/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map doxy-doc GNUmakefile +*.vcproj Modified: trunk/reactos/dll/ntdll/dbg/dbgui.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/dbg/dbgui.c?rev=…
============================================================================== --- trunk/reactos/dll/ntdll/dbg/dbgui.c (original) +++ trunk/reactos/dll/ntdll/dbg/dbgui.c Wed Jun 28 21:02:37 2006 @@ -1,9 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/ntdll/dbg/dbgui.c - * PURPOSE: User-Mode DbgUI Support - * PROGRAMMER: Alex Ionescu (alex(a)relsoft.net) + * PROJECT: ReactOS NT Layer/System API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/ntdll/dbg/dbgui.c + * PURPOSE: Native Wrappers for the NT Debug Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES *****************************************************************/ @@ -135,4 +135,52 @@ return Status; } +/* + * @implemented + */ +HANDLE +NTAPI +DbgUiGetThreadDebugObject(VOID) +{ + /* Just return the handle from the TEB */ + return NtCurrentTeb()->DbgSsReserved[0]; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +DbgUiDebugActiveProcess(IN HANDLE Process) +{ + NTSTATUS Status; + + /* Tell the kernel to start debugging */ + Status = NtDebugActiveProcess(Process, NtCurrentTeb()->DbgSsReserved[0]); + if (NT_SUCCESS(Status)) + { + /* Now break-in the process */ + Status = DbgUiIssueRemoteBreakin(Process); + if (!NT_SUCCESS(Status)) + { + /* We couldn't break-in, cancel debugging */ + DbgUiStopDebugging(Process); + } + } + + /* Return status */ + return Status; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +DbgUiStopDebugging(IN HANDLE Process) +{ + /* Call the kernel to remove the debug object */ + return NtRemoveProcessDebug(Process, NtCurrentTeb()->DbgSsReserved[0]); +} + /* EOF */ Propchange: trunk/reactos/dll/ntdll/dbg/dbgui.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Modified: trunk/reactos/dll/ntdll/def/ntdll.def URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.def?re…
============================================================================== --- trunk/reactos/dll/ntdll/def/ntdll.def (original) +++ trunk/reactos/dll/ntdll/def/ntdll.def Wed Jun 28 21:02:37 2006 @@ -24,10 +24,13 @@ DbgPrint DbgPrintEx DbgPrompt@12 +DbgUiDebugActiveProcess@4 DbgUiConnectToDbg@0 DbgUiContinue@8 +DbgUiGetThreadDebugObject@0 DbgUiIssueRemoteBreakin@4 DbgUiRemoteBreakin@0 +DbgUiStopDebugging@4 DbgUiWaitStateChange@8 DbgUserBreakPoint@0 KiRaiseUserExceptionDispatcher@0 @@ -230,6 +233,7 @@ NtSetEvent@8 NtSetHighEventPair@4 NtSetHighWaitLowEventPair@4 +NtSetInformationDebugObject@20 NtSetInformationFile@20 NtSetInformationJobObject@16 NtSetInformationKey@16 Propchange: trunk/reactos/dll/win32/acledit/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/aclui/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/advapi32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.gch *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/advpack/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/authz/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/avifil32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/cabinet/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ cabinet.spec.def cabinet.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/cards/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.tmp *.o GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/cfgmgr32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -16,3 +16,4 @@ *.bak *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/comctl32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.spec.def *.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/comdlg32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -13,3 +13,4 @@ *.stubs.c *.ico GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/crtdll/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/crypt32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/cryptdll/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,0 +1,1 @@ +*.vcproj Propchange: trunk/reactos/dll/win32/dbghelp/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -26,3 +26,4 @@ dbghelp.spec.def dbghelp.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/devmgr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/dhcpcsvc/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/dnsapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.txt *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/fmifs/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.d *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/gdi32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -5,3 +5,4 @@ *.a *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/gdiplus/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -5,3 +5,4 @@ *.a *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/glu32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp *.o GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/hid/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/icmp/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/imagehlp/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.txt *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/imm32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/iphlpapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -20,3 +20,4 @@ iphlpapi.spec.def iphlpapi.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/kernel32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -13,3 +13,4 @@ *.pch *.map GNUmakefile +*.vcproj Removed: trunk/reactos/dll/win32/kernel32/debug/break.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/debug/b…
============================================================================== --- trunk/reactos/dll/win32/kernel32/debug/break.c (original) +++ trunk/reactos/dll/win32/kernel32/debug/break.c (removed) @@ -1,32 +1,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/debug/debugger.c - * PURPOSE: DebugBreakProcess() - * PROGRAMMER: KJK::Hyperion <noog(a)libero.it> - */ - -/* INCLUDES ******************************************************************/ - -#include <k32.h> - -/* FUNCTIONS *****************************************************************/ - -/* - * @implemented - */ -WINBASEAPI BOOL WINAPI DebugBreakProcess(HANDLE Process) -{ - NTSTATUS nErrCode = DbgUiIssueRemoteBreakin(Process); - - if(!NT_SUCCESS(nErrCode)) - { - SetLastErrorByStatus(nErrCode); - return FALSE; - } - - return TRUE; -} - -/* EOF */ Modified: trunk/reactos/dll/win32/kernel32/debug/debugger.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/debug/d…
============================================================================== --- trunk/reactos/dll/win32/kernel32/debug/debugger.c (original) +++ trunk/reactos/dll/win32/kernel32/debug/debugger.c Wed Jun 28 21:02:37 2006 @@ -1,147 +1,261 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/debug/debugger.c - * PURPOSE: Win32 Debugger API - * PROGRAMMER: Thomas Weidenmueller - * KJK::Hyperion - */ - -/* INCLUDES ******************************************************************/ +/* + * PROJECT: ReactOS Win32 Base API + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/kernel32/debug/debugger.c + * PURPOSE: Wrappers for the NT Debug Implementation + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES *****************************************************************/ #include <k32.h> +#define NDEBUG +#include "debug.h" + /* FUNCTIONS *****************************************************************/ /* * @implemented */ -BOOL WINAPI -CheckRemoteDebuggerPresent ( - HANDLE hProcess, - PBOOL pbDebuggerPresent - ) -{ - HANDLE DebugPort; - NTSTATUS Status; - - if (pbDebuggerPresent == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - Status = NtQueryInformationProcess(hProcess, - ProcessDebugPort, - (PVOID)&DebugPort, - sizeof(HANDLE), - NULL); - if (NT_SUCCESS(Status)) - { - *pbDebuggerPresent = ((DebugPort != NULL) ? TRUE : FALSE); - return TRUE; - } - - SetLastErrorByStatus(Status); - return FALSE; -} - - -/* - * @implemented - */ -BOOL WINAPI -ContinueDebugEvent ( - DWORD dwProcessId, - DWORD dwThreadId, - DWORD dwContinueStatus - ) -{ - CLIENT_ID ClientId; - NTSTATUS Status; - - ClientId.UniqueProcess = (HANDLE)dwProcessId; - ClientId.UniqueThread = (HANDLE)dwThreadId; - - Status = DbgUiContinue(&ClientId, dwContinueStatus); - if (!NT_SUCCESS(Status)) - { +BOOL +WINAPI +CheckRemoteDebuggerPresent(IN HANDLE hProcess, + OUT PBOOL pbDebuggerPresent) +{ + HANDLE DebugPort; + NTSTATUS Status; + + /* Make sure we have an output and process*/ + if (!(pbDebuggerPresent) || !(hProcess)) + { + /* Fail */ + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + /* Check if the process has a debug object/port */ + Status = NtQueryInformationProcess(hProcess, + ProcessDebugPort, + (PVOID)&DebugPort, + sizeof(HANDLE), + NULL); + if (NT_SUCCESS(Status)) + { + /* Return the current state */ + *pbDebuggerPresent = (DebugPort) ? TRUE : FALSE; + return TRUE; + } + + /* Otherwise, fail */ SetLastErrorByStatus(Status); return FALSE; - } - - return TRUE; -} - - -/* - * NOTE: I'm not sure if the function is complete. - * +} + +/* + * @implemented + */ +BOOL +WINAPI +ContinueDebugEvent(IN DWORD dwProcessId, + IN DWORD dwThreadId, + IN DWORD dwContinueStatus) +{ + CLIENT_ID ClientId; + NTSTATUS Status; + + /* Set the Client ID */ + ClientId.UniqueProcess = (HANDLE)dwProcessId; + ClientId.UniqueThread = (HANDLE)dwThreadId; + + /* Continue debugging */ + Status = DbgUiContinue(&ClientId, dwContinueStatus); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastErrorByStatus(Status); + return FALSE; + } + + /* Succes */ + return TRUE; +} + +HANDLE +ProcessIdToHandle(IN DWORD dwProcessId) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + CLIENT_ID ClientId; + + /* If we don't have a PID, look it up */ + if (dwProcessId == 0xFFFFFFFF) dwProcessId = (DWORD)CsrGetProcessId(); + + /* Open a handle to the process */ + ClientId.UniqueProcess = (HANDLE)dwProcessId; + InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL); + Status = NtOpenProcess(&Handle, + PROCESS_ALL_ACCESS, + &ObjectAttributes, + &ClientId); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastErrorByStatus(Status); + return 0; + } + + /* Return the handle */ + return Handle; +} + +/* + * @implemented + */ +BOOL +WINAPI +DebugActiveProcess(IN DWORD dwProcessId) +{ + NTSTATUS Status; + HANDLE Handle; + + /* Connect to the debugger */ + Status = DbgUiConnectToDbg(); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + } + + /* Get the process handle */ + Handle = ProcessIdToHandle(dwProcessId); + if (!Handle) return FALSE; + + /* Now debug the process */ + Status = DbgUiDebugActiveProcess(Handle); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastErrorByStatus(Status); + return FALSE; + } + + /* Success */ + return TRUE; +} + +/* + * @implemented + */ +BOOL +WINAPI +DebugActiveProcessStop(IN DWORD dwProcessId) +{ + NTSTATUS Status; + HANDLE Handle; + + /* Get the process handle */ + Handle = ProcessIdToHandle(dwProcessId); + if (!Handle) return FALSE; + + /* Now stop debgging the process */ + Status = DbgUiStopDebugging(Handle); + NtClose(Handle); + + /* Check for failure */ + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastError(ERROR_ACCESS_DENIED); + return FALSE; + } + + /* Success */ + return TRUE; +} + +/* + * @implemented + */ +BOOL +WINAPI +DebugBreakProcess(IN HANDLE Process) +{ + NTSTATUS Status; + + /* Send the breakin request */ + Status = DbgUiIssueRemoteBreakin(Process); + if(!NT_SUCCESS(Status)) + { + /* Failure */ + SetLastErrorByStatus(Status); + return FALSE; + } + + /* Success */ + return TRUE; +} + +/* + * @implemented + */ +BOOL +WINAPI +DebugSetProcessKillOnExit(IN BOOL KillOnExit) +{ + HANDLE Handle; + NTSTATUS Status; + ULONG State; + + /* Get the debug object */ + Handle = DbgUiGetThreadDebugObject(); + if (!Handle) + { + /* Fail */ + SetLastErrorByStatus(STATUS_INVALID_HANDLE); + return FALSE; + } + + /* Now set the kill-on-exit state */ + State = KillOnExit; + Status = NtSetInformationDebugObject(Handle, + DebugObjectKillProcessOnExitInformation, + &State, + sizeof(State), + NULL); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastError(Status); + return FALSE; + } + + /* Success */ + return TRUE; +} + +/* + * @implemented + */ +BOOL +WINAPI +IsDebuggerPresent (VOID) +{ + return (BOOL)NtCurrentPeb()->BeingDebugged; +} + +/* * @unimplemented */ BOOL WINAPI -DebugActiveProcess( - DWORD dwProcessId - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -DebugActiveProcessStop ( - DWORD dwProcessId - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -DebugSetProcessKillOnExit ( - BOOL KillOnExit - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -IsDebuggerPresent (VOID) -{ - return (BOOL)NtCurrentPeb()->BeingDebugged; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -WaitForDebugEvent ( - LPDEBUG_EVENT lpDebugEvent, - DWORD dwMilliseconds - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; +WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, + DWORD dwMilliseconds) +{ + /* FIXME: TODO */ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } /* EOF */ Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
============================================================================== --- trunk/reactos/dll/win32/kernel32/include/kernel32.h (original) +++ trunk/reactos/dll/win32/kernel32/include/kernel32.h Wed Jun 28 21:02:37 2006 @@ -62,6 +62,9 @@ BOOL STDCALL VerifyConsoleIoHandle(HANDLE Handle); BOOL STDCALL CloseConsoleHandle(HANDLE Handle); + +HANDLE STDCALL +GetConsoleInputWaitHandle (VOID); HANDLE STDCALL OpenConsoleW (LPWSTR wsName, DWORD dwDesiredAccess, Modified: trunk/reactos/dll/win32/kernel32/kernel32.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
============================================================================== --- trunk/reactos/dll/win32/kernel32/kernel32.rbuild (original) +++ trunk/reactos/dll/win32/kernel32/kernel32.rbuild Wed Jun 28 21:02:37 2006 @@ -10,7 +10,6 @@ <define name="WINVER">0x502</define> <pch>k32.h</pch> <directory name="debug"> - <file>break.c</file> <file>debugger.c</file> <file>output.c</file> </directory> Modified: trunk/reactos/dll/win32/kernel32/misc/console.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/console.c (original) +++ trunk/reactos/dll/win32/kernel32/misc/console.c Wed Jun 28 21:02:37 2006 @@ -567,7 +567,7 @@ /* * @implemented */ -DWORD STDCALL +HANDLE STDCALL GetConsoleInputWaitHandle (VOID) /* * Undocumented @@ -585,7 +585,7 @@ SetLastErrorByStatus(Status); return 0; } - return (DWORD) Request.Data.GetConsoleInputWaitHandle.InputWaitHandle; + return Request.Data.GetConsoleInputWaitHandle.InputWaitHandle; } Propchange: trunk/reactos/dll/win32/kernel32/tests/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.a *.pch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/lsasrv/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.map *.sys GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/lzexpand/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -5,3 +5,4 @@ *.coff *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/mapi32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/mmdrv/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp temp.exp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/mpr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msacm/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ msacm32.spec.def msacm32.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msafd/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.o *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msgina/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msimg32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.spec.def *.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msvcrt/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -11,3 +11,4 @@ *.map *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msvcrt20/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.opt *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/msvideo/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ msvfw32.spec.def msvfw32.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/mswsock/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp temp.exp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/netapi32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/netcfgx/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,2 +1,3 @@ GNUmakefile *.bak +*.vcproj Propchange: trunk/reactos/dll/win32/newdev/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/ntmarta/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/objsel/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/ole32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.spec.def *.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/oleacc/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/oleaut32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/oledlg/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/olepro32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/opengl32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.tmp *.o GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/powrprof/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,0 +1,1 @@ +*.vcproj Propchange: trunk/reactos/dll/win32/psapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.gch misc GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/riched20/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -9,3 +9,4 @@ *.spec.def *.stubs.c GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/richedit/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/rpcrt4/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/samlib/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -5,3 +5,4 @@ *.a *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/samsrv/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/secur32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -6,3 +6,4 @@ *.d *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/security/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/serialui/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.a *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/setupapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ pnp_c.c GNUmakefile *.bak +*.vcproj Propchange: trunk/reactos/dll/win32/shdocvw/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/shell32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.stubs.c *.ico GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/shellext/slayer/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/shfolder/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/shlwapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/smdll/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.map *.sys GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/snmpapi/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -18,3 +18,4 @@ *.tmp *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/syssetup/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -6,3 +6,4 @@ *.map *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/twain/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -5,3 +5,4 @@ *.map *.coff GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/urlmon/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/user32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -7,3 +7,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/userenv/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.o *.gch GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/uxtheme/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.stubs.c *.ico GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/vdmdbg/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/version/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -6,3 +6,4 @@ *.a *.d GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/wininet/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/winmm/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/winmm/midimap/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/winmm/wavemap/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -12,3 +12,4 @@ *.bmp *.cur GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/winspool/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -10,3 +10,4 @@ *.map *.tmp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/wintrust/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,1 +1,2 @@ GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/ws2_32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp temp.exp GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/ws2help/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -18,3 +18,4 @@ *.tmp *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/wshirda/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -18,3 +18,4 @@ *.tmp *.map GNUmakefile +*.vcproj Propchange: trunk/reactos/dll/win32/wsock32/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -8,3 +8,4 @@ *.tmp temp.exp GNUmakefile +*.vcproj Modified: trunk/reactos/include/ndk/dbgkfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/dbgkfuncs.h?re…
============================================================================== --- trunk/reactos/include/ndk/dbgkfuncs.h (original) +++ trunk/reactos/include/ndk/dbgkfuncs.h Wed Jun 28 21:02:37 2006 @@ -23,10 +23,19 @@ // Dependencies // #include <umtypes.h> +#include <dbgktypes.h> // // Native calls // +NTSYSCALLAPI +NTSTATUS +NTAPI +NtDebugActiveProcess( + IN HANDLE Process, + IN HANDLE DebugObject +); + NTSYSCALLAPI NTSTATUS NTAPI @@ -56,6 +65,33 @@ OUT PDBGUI_WAIT_STATE_CHANGE StateChange ); +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRemoveProcessDebug( + IN HANDLE Process, + IN HANDLE DebugObject +); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationDebugObject( + IN HANDLE DebugObject, + IN DEBUGOBJECTINFOCLASS InformationClass, + IN PVOID Information, + IN ULONG InformationLength, + OUT PULONG ReturnLength OPTIONAL +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDebugActiveProcess( + IN HANDLE Process, + IN HANDLE DebugObject +); + NTSYSAPI NTSTATUS NTAPI @@ -78,10 +114,29 @@ NTSYSAPI NTSTATUS NTAPI +ZwRemoveProcessDebug( + IN HANDLE Process, + IN HANDLE DebugObject +); + +NTSYSAPI +NTSTATUS +NTAPI ZwWaitForDebugEvent( IN HANDLE DebugObject, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PDBGUI_WAIT_STATE_CHANGE StateChange ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationDebugObject( + IN HANDLE DebugObject, + IN DEBUGOBJECTINFOCLASS InformationClass, + IN PVOID Information, + IN ULONG InformationLength, + OUT PULONG ReturnLength OPTIONAL +); #endif Modified: trunk/reactos/include/ndk/umfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/umfuncs.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/umfuncs.h (original) +++ trunk/reactos/include/ndk/umfuncs.h Wed Jun 28 21:02:37 2006 @@ -89,6 +89,12 @@ struct _CSR_CAPTURE_BUFFER *CaptureBuffer ); +HANDLE +NTAPI +CsrGetProcessId( + VOID +); + NTSTATUS NTAPI CsrNewThread(VOID); @@ -141,6 +147,18 @@ NTSTATUS NTAPI +DbgUiDebugActiveProcess( + IN HANDLE Process +); + +NTSTATUS +NTAPI +DbgUiStopDebugging( + IN HANDLE Process +); + +NTSTATUS +NTAPI DbgUiWaitStateChange( IN PDBGUI_WAIT_STATE_CHANGE DbgUiWaitStateCange, IN PLARGE_INTEGER TimeOut @@ -156,6 +174,12 @@ NTAPI DbgUiIssueRemoteBreakin( IN HANDLE Process +); + +HANDLE +NTAPI +DbgUiGetThreadDebugObject( + VOID ); // Propchange: trunk/reactos/include/reactos/idl/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -1,2 +1,3 @@ makefile *.h +*.vcproj Propchange: trunk/reactos/ntoskrnl/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Jun 28 21:02:37 2006 @@ -14,3 +14,4 @@ *.exe doxy-doc GNUmakefile +*.vcproj Modified: trunk/reactos/tools/nci/sysfuncs.lst URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/nci/sysfuncs.lst?rev…
============================================================================== --- trunk/reactos/tools/nci/sysfuncs.lst (original) +++ trunk/reactos/tools/nci/sysfuncs.lst Wed Jun 28 21:02:37 2006 @@ -42,6 +42,7 @@ NtCreateTimer 4 NtCreateToken 13 NtCreateWaitablePort 5 +NtDebugActiveProcess 2 NtDebugContinue 3 NtDelayExecution 2 NtDeleteAtom 1 @@ -162,6 +163,7 @@ NtReleaseMutant 2 NtReleaseSemaphore 3 NtRemoveIoCompletion 5 +NtRemoveProcessDebug 2 NtReplaceKey 3 NtReplyPort 2 NtReplyWaitReceivePort 4 @@ -188,6 +190,7 @@ NtSetEvent 2 NtSetHighEventPair 1 NtSetHighWaitLowEventPair 1 +NtSetInformationDebugObject 5 NtSetInformationFile 5 NtSetInformationKey 4 NtSetInformationJobObject 4
18 years, 5 months
1
0
0
0
[fireball] 22674: [FORMATTING] - Amend file header slightly - Add functions headers
by fireball@svn.reactos.org
Author: fireball Date: Wed Jun 28 19:56:09 2006 New Revision: 22674 URL:
http://svn.reactos.org/svn/reactos?rev=22674&view=rev
Log: [FORMATTING] - Amend file header slightly - Add functions headers Modified: trunk/reactos/ntoskrnl/ex/error.c Modified: trunk/reactos/ntoskrnl/ex/error.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/error.c?rev=22…
============================================================================== --- trunk/reactos/ntoskrnl/ex/error.c (original) +++ trunk/reactos/ntoskrnl/ex/error.c Wed Jun 28 19:56:09 2006 @@ -1,6 +1,6 @@ /* - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/ex/error.c * PURPOSE: Error Functions and Status/Exception Dispatching/Raising * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) @@ -22,6 +22,34 @@ /* FUNCTIONS ****************************************************************/ +/*++ + * @name ExpRaiseHardError + * + * For now it's a stub + * + * @param ErrorStatus + * FILLME + * + * @param NumberOfParameters + * FILLME + * + * @param UnicodeStringParameterMask + * FILLME + * + * @param Parameters + * FILLME + * + * @param ValidResponseOptions + * FILLME + * + * @param Response + * FILLME + * + * @return None + * + * @remarks None + * + *--*/ VOID NTAPI ExpRaiseHardError(IN NTSTATUS ErrorStatus, @@ -34,9 +62,21 @@ UNIMPLEMENTED; } -/* - * @implemented - */ +/*++ + * @name ExRaiseAccessViolation + * @implemented + * + * The ExRaiseAccessViolation routine can be used with structured exception + * handling to throw a driver-determined exception for a memory access + * violation that occurs when a driver processes I/O requests. + * See:
http://msdn.microsoft.com/library/en-us/Kernel_r/hh/Kernel_r/k102_71b4c053-…
+ *
http://www.osronline.com/ddkx/kmarch/k102_814i.htm
+ * + * @return None + * + * @remarks None + * + *--*/ VOID NTAPI ExRaiseAccessViolation(VOID) @@ -45,20 +85,39 @@ RtlRaiseStatus(STATUS_ACCESS_VIOLATION); } -/* - * @implemented - */ +/*++ + * @name ExRaiseDatatypeMisalignment + * @implemented + * + * ExRaiseDatatypeMisalignment raises an exception with the exception + * code set to STATUS_DATATYPE_MISALIGNMENT + * See: MSDN / DDK + *
http://www.osronline.com/ddkx/kmarch/k102_814i.htm
+ * + * @return None + * + * @remarks None + * + *--*/ VOID NTAPI -ExRaiseDatatypeMisalignment (VOID) +ExRaiseDatatypeMisalignment(VOID) { /* Raise the Right Status */ RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } -/* - * @implemented - */ +/*++ + * @name ExSystemExceptionFilter + * @implemented + * + * TODO: Add description + * + * @return FILLME + * + * @remarks None + * + *--*/ LONG NTAPI ExSystemExceptionFilter(VOID) @@ -67,9 +126,35 @@ EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; } -/* - * @unimplemented - */ +/*++ + * @name ExRaiseHardError + * @implemented + * + * See NtRaiseHardError + * + * @param ErrorStatus + * Error Code + * + * @param NumberOfParameters + * Number of optional parameters in Parameters array + * + * @param UnicodeStringParameterMask + * Optional string parameter (can be only one per error code) + * + * @param Parameters + * Array of DWORD parameters for use in error message string + * + * @param ValidResponseOptions + * See HARDERROR_RESPONSE_OPTION for possible values description + * + * @param Response + * Pointer to HARDERROR_RESPONSE enumeration + * + * @return None + * + * @remarks None + * + *--*/ VOID NTAPI ExRaiseHardError(IN NTSTATUS ErrorStatus, @@ -90,6 +175,38 @@ Response); } +/*++ + * @name NtRaiseHardError + * @implemented + * + * This function sends HARDERROR_MSG LPC message to listener + * (typically CSRSS.EXE). See NtSetDefaultHardErrorPort for more information + * See:
http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Error…
+ * + * @param ErrorStatus + * Error Code + * + * @param NumberOfParameters + * Number of optional parameters in Parameters array + * + * @param UnicodeStringParameterMask + * Optional string parameter (can be only one per error code) + * + * @param Parameters + * Array of DWORD parameters for use in error message string + * + * @param ValidResponseOptions + * See HARDERROR_RESPONSE_OPTION for possible values description + * + * @param Response + * Pointer to HARDERROR_RESPONSE enumeration + * + * @return Status + * + * @remarks NtRaiseHardError is easy way to display message in GUI + * without loading Win32 API libraries + * + *--*/ NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, @@ -258,6 +375,24 @@ return Status; } +/*++ + * @name NtSetDefaultHardErrorPort + * @implemented + * + * NtSetDefaultHardErrorPort is typically called only once. After call, + * kernel set BOOLEAN flag named _ExReadyForErrors to TRUE, and all other + * tries to change default port are broken with STATUS_UNSUCCESSFUL error code + * See:
http://www.windowsitlibrary.com/Content/356/08/2.html
+ *
http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Error…
+ * + * @param PortHandle + * Handle to named port object + * + * @return Status + * + * @remarks Privileges: SE_TCB_PRIVILEGE + * + *--*/ NTSTATUS NTAPI NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
18 years, 5 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
60
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Results per page:
10
25
50
100
200