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
2025
January
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
July 2005
----- 2025 -----
January 2025
----- 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
21 participants
563 discussions
Start a n
N
ew thread
[greatlrd] 16739: Implement /S /F and code clean up by Brandon Turner
by greatlrd@svn.reactos.com
Implement /S /F and code clean up by Brandon Turner Modified: trunk/reactos/subsys/system/cmd/del.c _____ Modified: trunk/reactos/subsys/system/cmd/del.c --- trunk/reactos/subsys/system/cmd/del.c 2005-07-26 12:22:55 UTC (rev 16738) +++ trunk/reactos/subsys/system/cmd/del.c 2005-07-26 13:15:50 UTC (rev 16739) @@ -1,44 +1,44 @@ /* - * DEL.C - del internal command. - * - * - * History: - * - * 06/29/98 (Rob Lake rlake(a)cs.mun.ca) - * rewrote del to support wildcards - * added my name to the contributors - * - * 07/13/98 (Rob Lake) - * fixed bug that caused del not to delete file with out - * attribute. moved set, del, ren, and ver to there own files - * - * 27-Jul-1998 (John P Price <linux-guru(a)gcfl.net>) - * added config.h include - * - * 09-Dec-1998 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) - * Fixed command line parsing bugs. - * - * 21-Jan-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) - * Started major rewrite using a new structure. - * - * 03-Feb-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) - * First working version. - * - * 30-Mar-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) - * Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option. - * - * 06-Nov-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) - * Little fix to keep DEL quiet inside batch files. - * - * 28-Jan-2004 (Michael Fritscher <michael(a)fritscher.net>) - * Added prompt ("/P"), yes ("/Y") and wipe("/W") option. - * - * 22-Jun-2005 (Brandon Turner <turnerb7(a)msu.edu>) - * Added exclusive deletion "del * -abc.txt -text*.txt" - * - * 22-Jun-2005 (Brandon Turner <turnerb7(a)msu.edu>) - * Implemented /A example "del /A:H /A:-R *.exe -ping.exe" - */ +* DEL.C - del internal command. +* +* +* History: +* +* 06/29/98 (Rob Lake rlake(a)cs.mun.ca) +* rewrote del to support wildcards +* added my name to the contributors +* +* 07/13/98 (Rob Lake) +* fixed bug that caused del not to delete file with out +* attribute. moved set, del, ren, and ver to there own files +* +* 27-Jul-1998 (John P Price <linux-guru(a)gcfl.net>) +* added config.h include +* +* 09-Dec-1998 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) +* Fixed command line parsing bugs. +* +* 21-Jan-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) +* Started major rewrite using a new structure. +* +* 03-Feb-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) +* First working version. +* +* 30-Mar-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) +* Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option. +* +* 06-Nov-1999 (Eric Kohl <ekohl(a)abo.rhein-zeiung.de>) +* Little fix to keep DEL quiet inside batch files. +* +* 28-Jan-2004 (Michael Fritscher <michael(a)fritscher.net>) +* Added prompt ("/P"), yes ("/Y") and wipe("/W") option. +* +* 22-Jun-2005 (Brandon Turner <turnerb7(a)msu.edu>) +* Added exclusive deletion "del * -abc.txt -text*.txt" +* +* 22-Jun-2005 (Brandon Turner <turnerb7(a)msu.edu>) +* Implemented /A example "del /A:H /A:-R *.exe -ping.exe" +*/ #include <precomp.h> #include "resource.h" @@ -49,16 +49,15 @@ enum { DEL_ATTRIBUTES = 0x001, /* /A */ - DEL_ERROR = 0x002, /* /E : not implemented */ DEL_NOTHING = 0x004, /* /N */ DEL_PROMPT = 0x008, /* /P */ DEL_QUIET = 0x010, /* /Q */ - DEL_SUBDIR = 0x020, /* /S : not implemented */ + DEL_SUBDIR = 0x020, /* /S */ DEL_TOTAL = 0x040, /* /T */ DEL_WIPE = 0x080, /* /W */ DEL_EMPTYDIR = 0x100, /* /X : not implemented */ DEL_YES = 0x200, /* /Y */ - DEL_ZAP = 0x400 /* /Z */ + DEL_FORCE = 0x800 /* /F */ }; enum @@ -79,8 +78,8 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags) { /*This function is called by CommandDelete and - does the actual process of deleting the single - file*/ + does the actual process of deleting the single + file*/ if (dwFlags & DEL_WIPE) { @@ -115,10 +114,10 @@ CloseHandle (file); } /*check to see if it is read only and if this is done based on /A - if it is done by file name, access is denied. However, if it is done - using the /A switch you must un-read only the file and allow it to be - deleted*/ - if((dwFlags & DEL_ATTRIBUTES)) + if it is done by file name, access is denied. However, if it is done + using the /A switch you must un-read only the file and allow it to be + deleted*/ + if((dwFlags & DEL_ATTRIBUTES) || (dwFlags & DEL_FORCE)) { HANDLE hFile; WIN32_FIND_DATA f2; @@ -126,9 +125,9 @@ if(f2.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { /*setting file to normal, not saving old attrs first - because the file is going to be deleted anyways - so the only thing that matters is that it isnt - read only.*/ + because the file is going to be deleted anyways + so the only thing that matters is that it isnt + read only.*/ SetFileAttributes(lpFileName,FILE_ATTRIBUTE_NORMAL); } @@ -136,11 +135,93 @@ return DeleteFile (lpFileName); } +BOOL _SearchPathex(TCHAR *lpPath,TCHAR *lpFileName,TCHAR *lpBuffer, DWORD dwFlags) +{ + TCHAR szFullPath[MAX_PATH]; + WIN32_FIND_DATA f; + HANDLE hFile; + TCHAR CMDPath[MAX_PATH]; + + /* Make the Full Path Name */ + _tcscpy(szFullPath,lpPath); + _tcscat(szFullPath,lpFileName); + + /* Open up the handle to the file(s) */ + hFile = FindFirstFile(szFullPath, &f); + do + { + /* Build the full name again, this time using the handle + as it might have had a * in the name before */ + _tcscpy(szFullPath,lpPath); + _tcscat(szFullPath,f.cFileName); + + /* We cant delete . or .. */ + if (!_tcscmp (f.cFileName, _T(".")) || + !_tcscmp (f.cFileName, _T(".."))) + continue; + + /* We cant delete ourselves */ + GetModuleFileName(NULL, CMDPath, MAX_PATH); + if(!_tcscmp (CMDPath,szFullPath)) + continue; + + /* If there is a read only / system file and they are forcing, then we can delete it + But we must first set it to normal. Otherwise we cant delete it */ + if(((dwFlags & DEL_FORCE) || (dwFlags & DEL_ATTRIBUTES)) && ((f.dwFileAttributes & FILE_ATTRIBUTE_READONLY) || (f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))) + { + + SetFileAttributes(szFullPath,FILE_ATTRIBUTE_NORMAL); + + } + else if(!((dwFlags & DEL_FORCE) || (dwFlags & DEL_ATTRIBUTES)) && ((f.dwFileAttributes & FILE_ATTRIBUTE_READONLY) || (f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))) + continue; + + /* If we find a file, we can return and continue to delete it */ + if(IsExistingFile(szFullPath)) + { + _tcscpy(lpBuffer,szFullPath); + CloseHandle(hFile); + return TRUE; + } + }while(FindNextFile (hFile, &f)); + + CloseHandle(hFile); + + /* None in this folder, so lets drop down to another folder */ + _tcscat(lpPath,_T("*")); + hFile = FindFirstFile(lpPath, &f); + lpPath[_tcslen(lpPath) - 1] = _T('\0'); + + do + { + /* dont count this folder or the folder above */ + if (!_tcscmp (f.cFileName, _T(".")) || + !_tcscmp (f.cFileName, _T(".."))) + continue; + + /* Assemble full path to file */ + _tcscpy(szFullPath,lpPath); + _tcscat(szFullPath,f.cFileName); + if(IsExistingDirectory(szFullPath)) + { + _tcscat(szFullPath,_T("\\")); + /* If it is a directory, move into(Recurvsily) */ + if(_SearchPathex(szFullPath,lpFileName,lpBuffer,dwFlags)) + { + return TRUE; + } + + } + }while(FindNextFile (hFile, &f)); + return FALSE; +} + + INT CommandDelete (LPTSTR cmd, LPTSTR param) { /*cmd is the command that was given, in this case it will always be "del" or "delete" - param is whatever is given after the command*/ + param is whatever is given after the command*/ TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szFullPath[MAX_PATH]; @@ -161,11 +242,14 @@ WIN32_FIND_DATA f; WIN32_FIND_DATA f2; LONG ch; + BOOL bSubFileFound = FALSE; BOOL bExclusion; - + TCHAR szOrginalArg[MAX_PATH]; + TCHAR AltArg[MAX_PATH]; + /*checks the first two chars of param to see if it is /? - this however allows the following command to not show help - "del frog.txt /?" */ + this however allows the following command to not show help + "del frog.txt /?" */ if (!_tcsncmp (param, _T("/?"), 2)) { @@ -175,396 +259,375 @@ arg = split (param, &args, FALSE); - if (args > 0) + if (args == 0) { - /* check for options anywhere in command line */ - for (i = 0; i < args; i++) + /* only command given */ + error_req_param_missing (); + freep (arg); + return 1; + } + /* check for options anywhere in command line */ + for (i = 0; i < args; i++) + { + if (*arg[i] == _T('/')) { - if (*arg[i] == _T('/')) + /*found a command, but check to make sure it has something after it*/ + if (_tcslen (arg[i]) >= 2) { - /*found a command, but check to make sure it has something after it*/ - if (_tcslen (arg[i]) >= 2) + ch = _totupper (arg[i][1]); + if (ch == _T('N')) { - ch = _totupper (arg[i][1]); - if (ch == _T('N')) + dwFlags |= DEL_NOTHING; + } + else if (ch == _T('P')) + { + dwFlags |= DEL_PROMPT; + } + else if (ch == _T('Q')) + { + dwFlags |= DEL_QUIET; + } + else if (ch == _T('F')) + { + dwFlags |= DEL_FORCE; + } + else if (ch == _T('S')) + { + dwFlags |= DEL_SUBDIR; + } + else if (ch == _T('T')) + { + dwFlags |= DEL_TOTAL; + } + else if (ch == _T('W')) + { + dwFlags |= DEL_WIPE; + } + else if (ch == _T('Y')) + { + dwFlags |= DEL_YES; + } + else if (ch == _T('A')) + { + + dwFlags |= DEL_ATTRIBUTES; + /*the proper syntax for /A has a min of 4 chars + i.e. /A:R or /A:-H */ + if (_tcslen (arg[i]) < 4) { - dwFlags |= DEL_NOTHING; + error_invalid_parameter_format(arg[i]); + return 0; } - else if (ch == _T('P')) - { - dwFlags |= DEL_PROMPT; + ch = _totupper (arg[i][3]); + if (_tcslen (arg[i]) == 4) + { + if(ch == _T('A')) + { + dwAttrFlags |= ATTR_ARCHIVE; + } + if(ch == _T('H')) + { + dwAttrFlags |= ATTR_HIDDEN; + } + if(ch == _T('S')) + { + dwAttrFlags |= ATTR_SYSTEM; + } + if(ch == _T('R')) + { + dwAttrFlags |= ATTR_READ_ONLY; + } } - else if (ch == _T('Q')) + if (_tcslen (arg[i]) == 5) { - dwFlags |= DEL_QUIET; - } - else if (ch == _T('S')) - { - dwFlags |= DEL_SUBDIR; - } - else if (ch == _T('T')) - { - dwFlags |= DEL_TOTAL; - } - else if (ch == _T('W')) - { - dwFlags |= DEL_WIPE; - } - else if (ch == _T('Y')) - { - dwFlags |= DEL_YES; - } - else if (ch == _T('Z')) - { - dwFlags |= DEL_ZAP; - } - else if (ch == _T('A')) - { - - dwFlags |= DEL_ATTRIBUTES; - /*the proper syntax for /A has a min of 4 chars - i.e. /A:R or /A:-H */ - if (_tcslen (arg[i]) < 4) + if(ch == _T('-')) { - error_invalid_parameter_format(arg[i]); - return 0; - } - ch = _totupper (arg[i][3]); - if (_tcslen (arg[i]) == 4) - { + ch = _totupper (arg[i][4]); if(ch == _T('A')) { - dwAttrFlags |= ATTR_ARCHIVE; + dwAttrFlags |= ATTR_N_ARCHIVE; } if(ch == _T('H')) { - dwAttrFlags |= ATTR_HIDDEN; + dwAttrFlags |= ATTR_N_HIDDEN; } if(ch == _T('S')) { - dwAttrFlags |= ATTR_SYSTEM; + dwAttrFlags |= ATTR_N_SYSTEM; } if(ch == _T('R')) { - dwAttrFlags |= ATTR_READ_ONLY; + dwAttrFlags |= ATTR_N_READ_ONLY; } } - if (_tcslen (arg[i]) == 5) - { - if(ch == _T('-')) - { - ch = _totupper (arg[i][4]); - if(ch == _T('A')) - { - dwAttrFlags |= ATTR_N_ARCHIVE; - } - if(ch == _T('H')) - { - dwAttrFlags |= ATTR_N_HIDDEN; - } - if(ch == _T('S')) - { - dwAttrFlags |= ATTR_N_SYSTEM; - } - if(ch == _T('R')) - { - dwAttrFlags |= ATTR_N_READ_ONLY; - } - } - } } } + } - nEvalArgs++; - } + nEvalArgs++; } - - /* there are only options on the command line --> error!!! - there is the same number of args as there is flags, so none of the args were filenames*/ - if (args == nEvalArgs) + } + + /* there are only options on the command line --> error!!! + there is the same number of args as there is flags, so none of the args were filenames*/ + if (args == nEvalArgs) + { + error_req_param_missing (); + freep (arg); + return 1; + } + + /* keep quiet within batch files */ + if (bc != NULL) + dwFlags |= DEL_QUIET; + + /* check for filenames anywhere in command line */ + for (i = 0; i < args; i++) + { + + /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/ + if((*arg[i] == _T('/')) || (*arg[i] == _T('-'))) + continue; + bSubFileFound = FALSE; + + /* We want to make 2 copies of the argument, + 1. copy will stay the same as the argument + 2. will be edited and striped down to the bad folder */ + if(_tcslen(arg[i]) == 2 && arg[i][1] == _T(':')) { - error_req_param_missing (); - freep (arg); - return 1; + /* Check for C: D: ... */ + GetRootPath(arg[i],szOrginalArg,MAX_PATH); + GetRootPath(arg[i],AltArg,MAX_PATH); } + else + { + _tcscpy(szOrginalArg,arg[i]); + _tcscpy(AltArg,arg[i]); + } - /* keep quiet within batch files */ - if (bc != NULL) - dwFlags |= DEL_QUIET; + do + { + - /* check for filenames anywhere in command line */ - for (i = 0; i < args; i++) - { - if (!_tcscmp (arg[i], _T("*")) || - !_tcscmp (arg[i], _T("*.*"))) + if(dwFlags & DEL_SUBDIR) { - /*well, the user wants to delete everything but if they didnt yes DEL_YES, DEL_QUIET, or DEL_PROMPT - then we are going to want to make sure that in fact they want to do that. */ + + TCHAR FoundPath[MAX_PATH]; + TCHAR * PathFileName; + TCHAR PathBaseFolder[MAX_PATH]; - if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT))) + /* Get just the file name */ + PathFileName = _tcsrchr(szOrginalArg,_T('\\')); + if(PathFileName != NULL) + PathFileName++; + else + PathFileName = szOrginalArg; + + /* Get the full path to the file */ + GetFullPathName (szOrginalArg,MAX_PATH,PathBaseFolder,NULL); + + /* strip the filename off of it */ + for(ii = (_tcslen(PathBaseFolder) - 1); ii > -1; ii--) { - LoadString( CMD_ModuleHandle, STRING_DEL_HELP2, szMsg, RC_STRING_MAX_SIZE); - - res = FilePromptYN (szMsg); - if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) + if(PathBaseFolder[ii] != _T('\\')) + PathBaseFolder[ii] = _T('\0'); + else + { break; + } + } + + /* Start looking for it, once it cant find anymore files on that name + it returns false and that is how we know we have found all files in sub directories. */ + if(_SearchPathex(PathBaseFolder,PathFileName,FoundPath,dwFlags)) + { + bSubFileFound = TRUE; + _tcscpy(AltArg,FoundPath); + } + else + { + bSubFileFound = FALSE; + continue; + } + } - - /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/ - if ((*arg[i] != _T('/')) && (*arg[i] != _T('-'))) + + + if(_tcschr (AltArg, _T('*')) == NULL && + IsExistingDirectory (AltArg)) + { + /* If it doesnt have a \ at the end already then on needs to be added */ + if(AltArg[_tcslen(AltArg) - 1] != _T('\\')) + _tcscat (AltArg, _T("\\")); + /* Add a wildcard after the \ */ + _tcscat (AltArg, _T("*")); + } + + if(!_tcscmp (AltArg, _T("*")) || + !_tcscmp (AltArg, _T("*.*"))|| + (AltArg[_tcslen(AltArg) - 2] == _T('\\') && AltArg[_tcslen(AltArg) - 1] == _T('*'))) + { + /*well, the user wants to delete everything but if they didnt yes DEL_YES, DEL_QUIET, or DEL_PROMPT + then we are going to want to make sure that in fact they want to do that. */ + + if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT))) { + LoadString( CMD_ModuleHandle, STRING_DEL_HELP2, szMsg, RC_STRING_MAX_SIZE); + + res = FilePromptYNA (szMsg); + if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) + break; + if(res == PROMPT_ALL) + dwFlags |= DEL_YES; + } + } + + + #ifdef _DEBUG - ConErrPrintf (_T("File: %s\n"), arg[i]); + ConErrPrintf (_T("File: %s\n"), arg[i]); #endif - if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?'))) - { - /* wildcards in filespec */ #ifdef _DEBUG - ConErrPrintf(_T("Wildcards!\n\n")); + ConErrPrintf(_T("Wildcards!\n\n")); #endif - - GetFullPathName (arg[i], - MAX_PATH, - szFullPath, - &pFilePart); + + GetFullPathName (AltArg, + MAX_PATH, + szFullPath, + &pFilePart); #ifdef _DEBUG - ConErrPrintf(_T("Full path: %s\n"), szFullPath); - ConErrPrintf(_T("File part: %s\n"), pFilePart); + ConErrPrintf(_T("Full path: %s\n"), szFullPath); + ConErrPrintf(_T("File part: %s\n"), pFilePart); #endif - hFile = FindFirstFile (szFullPath, &f); + hFile = FindFirstFile (szFullPath, &f); + + do + { + + if (hFile == INVALID_HANDLE_VALUE) + { + error_file_not_found (); + freep (arg); + return 0; + } + + /*bExclusion is the check varible to see if it has a match + and it needs to be set to false before each loop, as it hasnt been matched yet*/ + bExclusion = 0; + + /*loop through each of the arguments*/ + for (ii = 0; ii < args; ii++) + { + /*check to see if it is a exclusion tag but not a ':' (used in ATTR)*/ + if(_tcschr (arg[ii], _T('-')) && _tcschr (arg[ii], _T(':')) == NULL) + { + /*remove the - from the front to get the real name*/ + _tcscpy (exfileName , arg[ii]); + szFileName = strtok (exfileName,"-"); + GetFullPathName (szFileName, + MAX_PATH, + szFullPath, + &pFilePart); + hFileExcl = FindFirstFile (szFullPath, &f2); do { + /*check to see if the filenames match*/ + if(!_tcscmp (f.cFileName, f2.cFileName)) + bExclusion = 1; + } + while (FindNextFile (hFileExcl, &f2)); + } + } + + /*if it is going to be excluded by - no need to check attrs*/ + if(dwFlags & DEL_ATTRIBUTES && bExclusion == 0) + { + /*save if file attr check if user doesnt care about that attr anyways*/ + if(dwAttrFlags & ATTR_ARCHIVE && !(f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)) + bExclusion = 1; + if(dwAttrFlags & ATTR_HIDDEN && !(f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) + bExclusion = 1; + if(dwAttrFlags & ATTR_SYSTEM && !(f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) + bExclusion = 1; + if(dwAttrFlags & ATTR_READ_ONLY && !(f.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) + bExclusion = 1; + if(dwAttrFlags & ATTR_N_ARCHIVE && (f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)) + bExclusion = 1; + if(dwAttrFlags & ATTR_N_HIDDEN && (f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) + bExclusion = 1; + if(dwAttrFlags & ATTR_N_SYSTEM && (f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) + bExclusion = 1; + if(dwAttrFlags & ATTR_N_READ_ONLY && (f.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) + bExclusion = 1; + } - if (hFile == INVALID_HANDLE_VALUE) - { - error_file_not_found (); - freep (arg); - return 0; - } + if(bExclusion) + continue; - /*bExclusion is the check varible to see if it has a match - and it needs to be set to false before each loop, as it hasnt been matched yet*/ - bExclusion = 0; + /* ignore ".", ".." and directories */ + if (!_tcscmp (f.cFileName, _T(".")) || + !_tcscmp (f.cFileName, _T("..")) || + f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + continue; - /*loop through each of the arguments*/ - for (ii = 0; ii < args; ii++) - { - /*check to see if it is a exclusion tag but not a ':' (used in ATTR)*/ - if(_tcschr (arg[ii], _T('-')) && _tcschr (arg[ii], _T(':')) == NULL) - { - /*remove the - from the front to get the real name*/ - _tcscpy (exfileName , arg[ii]); - szFileName = strtok (exfileName,"-"); - GetFullPathName (szFileName, - MAX_PATH, - szFullPath, - &pFilePart); - hFileExcl = FindFirstFile (szFullPath, &f2); - do - { - /*check to see if the filenames match*/ - if(!_tcscmp (f.cFileName, f2.cFileName)) - bExclusion = 1; - } - while (FindNextFile (hFileExcl, &f2)); - } - } + _tcscpy (pFilePart, f.cFileName); - /*if it is going to be excluded by - no need to check attrs*/ - if(dwFlags & DEL_ATTRIBUTES && bExclusion == 0) - { - - /*save if file attr check if user doesnt care about that attr anyways*/ - if(dwAttrFlags & ATTR_ARCHIVE) - {if(!(f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)) - bExclusion = 1;} - if(dwAttrFlags & ATTR_HIDDEN) - {if(!(f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) - bExclusion = 1;} - if(dwAttrFlags & ATTR_SYSTEM) - {if(!(f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) - bExclusion = 1;} - if(dwAttrFlags & ATTR_READ_ONLY) - {if(!(f.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - bExclusion = 1;} - if(dwAttrFlags & ATTR_N_ARCHIVE) - {if(f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) - bExclusion = 1;} - if(dwAttrFlags & ATTR_N_HIDDEN) - {if(f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - bExclusion = 1;} - if(dwAttrFlags & ATTR_N_SYSTEM) - {if(f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) - bExclusion = 1;} - if(dwAttrFlags & ATTR_N_READ_ONLY) - {if(f.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - bExclusion = 1;} - } - - if(!bExclusion) - { - /* ignore ".", ".." and directories */ - if (!_tcscmp (f.cFileName, _T(".")) || - !_tcscmp (f.cFileName, _T("..")) || - f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - continue; - - _tcscpy (pFilePart, f.cFileName); - #ifdef _DEBUG - ConErrPrintf(_T("Full filename: %s\n"), szFullPath); + ConErrPrintf(_T("Full filename: %s\n"), szFullPath); #endif - /* ask for deleting */ - if (dwFlags & DEL_PROMPT) - { - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR5, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf(szMsg, szFullPath); + /* ask for deleting */ + if (dwFlags & DEL_PROMPT) + { + LoadString(CMD_ModuleHandle, STRING_DEL_ERROR5, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR6, szMsg, RC_STRING_MAX_SIZE); - res = FilePromptYN (szMsg); + LoadString(CMD_ModuleHandle, STRING_DEL_ERROR6, szMsg, RC_STRING_MAX_SIZE); + res = FilePromptYN (szMsg); - if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) - { - continue; //FIXME: Errorcode? - } - } - - /*user cant ask it to be quiet and tell you what it did*/ - if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) - { - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR7, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf(szMsg, szFullPath); - } - - /* delete the file */ - if (!(dwFlags & DEL_NOTHING)) - { - if (RemoveFile (szFullPath, dwFlags)) - { - dwFiles++; - } - else - { - if (dwFlags & DEL_ZAP) - { - if (SetFileAttributes (szFullPath, 0)) - { - if (RemoveFile (szFullPath, dwFlags)) - { - dwFiles++; - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - } - } - } - while (FindNextFile (hFile, &f)); - FindClose (hFile); + if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) + { + continue; //FIXME: Errorcode? } - else - { - - /* no wildcards in filespec */ -#ifdef _DEBUG - ConErrPrintf(_T("No Wildcards!\n")); -#endif - GetFullPathName (arg[i], - MAX_PATH, - szFullPath, - &pFilePart); + } - /* ask for deleting */ - // Don't ask if the file doesn't exist, the following code will make the error-msg - if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) - { - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR5, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf(szMsg, szFullPath); + /*user cant ask it to be quiet and tell you what it did*/ + if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) + { + LoadString(CMD_ModuleHandle, STRING_DEL_ERROR7, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); + } - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR6, szMsg, RC_STRING_MAX_SIZE); - res = FilePromptYN (szMsg); + /* delete the file */ + if(dwFlags & DEL_NOTHING) + continue; - if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) - { - break; //FIXME: Errorcode? - } - } -#ifdef _DEBUG - ConErrPrintf(_T("Full path: %s\n"), szFullPath); -#endif - if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) - { - LoadString(CMD_ModuleHandle, STRING_DEL_ERROR7, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf(szMsg, szFullPath); - } - - if (!(dwFlags & DEL_NOTHING)) - { - if (RemoveFile (szFullPath, dwFlags)) - { - dwFiles++; - } - else - { - if (dwFlags & DEL_ZAP) - { - if (SetFileAttributes (szFullPath, 0)) - { - if (RemoveFile (szFullPath, dwFlags)) - { - dwFiles++; - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - else - { - ErrorMessage (GetLastError(), _T("")); - } - } - } - } + if(RemoveFile (szFullPath, dwFlags)) + dwFiles++; + else + { + bSubFileFound = FALSE; + ErrorMessage (GetLastError(), _T("")); + break; } } + while (FindNextFile (hFile, &f)); + } + while(bSubFileFound); } - else - { - /* only command given */ - error_req_param_missing (); - freep (arg); - return 1; - } - + FindClose (hFile); + freep (arg); - if (!(dwFlags & DEL_QUIET)) + /*Based on MS cmd, we only tell what files are being deleted when /S is used */ + if (dwFlags & DEL_TOTAL) { if (dwFiles < 2) { @@ -577,7 +640,9 @@ ConOutPrintf(szMsg, dwFiles); } + return 0; } + #endif
19 years, 6 months
1
0
0
0
[weiden] 16738: removed some MmCopyTo/FromCaller calls from win32k's GDI
by weiden@svn.reactos.com
removed some MmCopyTo/FromCaller calls from win32k's GDI Modified: trunk/reactos/subsys/win32k/objects/brush.c Modified: trunk/reactos/subsys/win32k/objects/cliprgn.c Modified: trunk/reactos/subsys/win32k/objects/coord.c Modified: trunk/reactos/subsys/win32k/objects/dc.c Modified: trunk/reactos/subsys/win32k/objects/fillshap.c Modified: trunk/reactos/subsys/win32k/objects/line.c Modified: trunk/reactos/subsys/win32k/objects/pen.c Modified: trunk/reactos/subsys/win32k/objects/print.c Modified: trunk/reactos/subsys/win32k/objects/rect.c Modified: trunk/reactos/subsys/win32k/objects/region.c _____ Modified: trunk/reactos/subsys/win32k/objects/brush.c --- trunk/reactos/subsys/win32k/objects/brush.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/brush.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -563,7 +563,7 @@ CONST VOID *PackedDIB) { BITMAPINFO *SafeBitmapInfoAndData; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; HBRUSH hBrush; SafeBitmapInfoAndData = EngAllocMem(0, BitmapInfoSize, 0); @@ -573,10 +573,24 @@ return NULL; } - Status = MmCopyFromCaller(SafeBitmapInfoAndData, BitmapInfoAndData, - BitmapInfoSize); + _SEH_TRY + { + ProbeForRead(BitmapInfoAndData, + BitmapInfoSize, + 1); + RtlCopyMemory(SafeBitmapInfoAndData, + BitmapInfoAndData, + BitmapInfoSize); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (!NT_SUCCESS(Status)) { + EngFreeMem(SafeBitmapInfoAndData); SetLastNtError(Status); return 0; } @@ -632,11 +646,23 @@ if (Point != NULL) { - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; POINT SafePoint; SafePoint.x = dc->w.brushOrgX; SafePoint.y = dc->w.brushOrgY; - Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); + _SEH_TRY + { + ProbeForWrite(Point, + sizeof(POINT), + 1); + *Point = SafePoint; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -661,7 +687,7 @@ ULONG Reserved) { PPATRECT rb = NULL; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; BOOL Ret; if (cRects > 0) @@ -672,7 +698,21 @@ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - Status = MmCopyFromCaller(rb, pRects, sizeof(PATRECT) * cRects); + _SEH_TRY + { + ProbeForRead(pRects, + cRects * sizeof(PATRECT), + 1); + RtlCopyMemory(rb, + pRects, + cRects * sizeof(PATRECT)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (!NT_SUCCESS(Status)) { ExFreePool(rb); _____ Modified: trunk/reactos/subsys/win32k/objects/cliprgn.c --- trunk/reactos/subsys/win32k/objects/cliprgn.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/cliprgn.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -192,7 +192,19 @@ Ret = IntGdiGetClipBox(hDC, &Saferect); - Status = MmCopyToCaller(rc, &Saferect, sizeof(RECT)); + _SEH_TRY + { + ProbeForWrite(rc, + sizeof(RECT), + 1); + *rc = Saferect; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { @@ -341,7 +353,7 @@ BOOL STDCALL NtGdiRectVisible(HDC hDC, CONST PRECT UnsafeRect) { - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; PROSRGNDATA Rgn; PDC dc = DC_LockDc(hDC); BOOL Result = FALSE; @@ -353,10 +365,23 @@ return FALSE; } - Status = MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT)); + _SEH_TRY + { + ProbeForRead(UnsafeRect, + sizeof(RECT), + 1); + Rect = *UnsafeRect; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); + SetLastNtError(Status); return FALSE; } _____ Modified: trunk/reactos/subsys/win32k/objects/coord.c --- trunk/reactos/subsys/win32k/objects/coord.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/coord.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -63,17 +63,29 @@ { XFORM xformTemp; XFORM xform1, xform2; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; BOOL Ret; - - Status = MmCopyFromCaller( &xform1, Unsafexform1, sizeof(XFORM) ); - if(!NT_SUCCESS(Status)) + _SEH_TRY { - SetLastNtError(Status); - return FALSE; + ProbeForWrite(UnsafeXFormResult, + sizeof(XFORM), + 1); + ProbeForRead(Unsafexform1, + sizeof(XFORM), + 1); + ProbeForRead(Unsafexform2, + sizeof(XFORM), + 1); + xform1 = *Unsafexform1; + xform2 = *Unsafexform2; } - Status = MmCopyFromCaller( &xform2, Unsafexform2, sizeof(XFORM) ); + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -83,7 +95,17 @@ Ret = IntGdiCombineTransform(&xformTemp, &xform1, &xform2); /* Copy the result to xformResult */ - Status = MmCopyToCaller( UnsafeXFormResult, &xformTemp, sizeof(XFORM) ); + _SEH_TRY + { + /* pointer was already probed! */ + *UnsafeXFormResult = xformTemp; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -131,7 +153,7 @@ int Count) { PDC dc; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; LPPOINT Points; ULONG Size; @@ -159,7 +181,21 @@ return FALSE; } - Status = MmCopyFromCaller(Points, UnsafePoints, Size); + _SEH_TRY + { + ProbeForWrite(UnsafePoints, + Size, + 1); + RtlCopyMemory(Points, + UnsafePoints, + Size); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -170,7 +206,19 @@ IntDPtoLP(dc, Points, Count); - Status = MmCopyToCaller(UnsafePoints, Points, Size); + _SEH_TRY + { + /* pointer was already probed! */ + RtlCopyMemory(UnsafePoints, + Points, + Size); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -218,7 +266,7 @@ LPXFORM XForm) { PDC dc; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; dc = DC_LockDc ( hDC ); if (!dc) @@ -233,7 +281,18 @@ return FALSE; } - Status = MmCopyToCaller(XForm, &dc->w.xformWorld2Wnd, sizeof(XFORM)); + _SEH_TRY + { + ProbeForWrite(XForm, + sizeof(XFORM), + 1); + *XForm = dc->w.xformWorld2Wnd; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; DC_UnlockDc(dc); return NT_SUCCESS(Status); @@ -280,7 +339,7 @@ NtGdiLPtoDP ( HDC hDC, LPPOINT UnsafePoints, INT Count ) { PDC dc; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; LPPOINT Points; ULONG Size; @@ -308,7 +367,21 @@ return FALSE; } - Status = MmCopyFromCaller(Points, UnsafePoints, Size); + _SEH_TRY + { + ProbeForWrite(UnsafePoints, + Size, + 1); + RtlCopyMemory(Points, + UnsafePoints, + Size); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -319,7 +392,19 @@ IntLPtoDP(dc, Points, Count); - Status = MmCopyToCaller(UnsafePoints, Points, Size); + _SEH_TRY + { + /* pointer was already probed! */ + RtlCopyMemory(UnsafePoints, + Points, + Size); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -341,7 +426,7 @@ { PDC dc; XFORM SafeXForm; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; dc = DC_LockDc(hDC); if (!dc) @@ -357,7 +442,19 @@ return FALSE; } - Status = MmCopyFromCaller(&SafeXForm, UnsafeXForm, sizeof(XFORM)); + _SEH_TRY + { + ProbeForRead(UnsafeXForm, + sizeof(XFORM), + 1); + SafeXForm = *UnsafeXForm; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -403,8 +500,7 @@ LPPOINT UnsafePoint) { PDC dc; - POINT Point; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; dc = DC_LockDc ( hDC ); if(!dc) @@ -415,9 +511,20 @@ if (UnsafePoint) { - Point.x = dc->vportOrgX; - Point.y = dc->vportOrgY; - Status = MmCopyToCaller(UnsafePoint, &Point, sizeof(POINT)); + _SEH_TRY + { + ProbeForWrite(UnsafePoint, + sizeof(POINT), + 1); + UnsafePoint->x = dc->vportOrgX; + UnsafePoint->y = dc->vportOrgY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if ( !NT_SUCCESS(Status) ) { SetLastNtError(Status); @@ -452,13 +559,22 @@ if (Point) { - POINT SafePoint; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; + + _SEH_TRY + { + ProbeForWrite(Point, + sizeof(POINT), + 1); + Point->x = dc->wndOrgX; + Point->y = dc->wndOrgY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - SafePoint.x = dc->wndOrgX; - SafePoint.y = dc->wndOrgY; - - Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -594,13 +710,22 @@ if (Size) { - SIZE SafeSize; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; - SafeSize.cx = dc->vportExtX; - SafeSize.cy = dc->vportExtY; + _SEH_TRY + { + ProbeForWrite(Size, + sizeof(SIZE), + 1); + Size->cx = dc->vportExtX; + Size->cy = dc->vportExtY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -636,13 +761,22 @@ if (Point) { - POINT SafePoint; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; + + _SEH_TRY + { + ProbeForWrite(Point, + sizeof(POINT), + 1); + Point->x = dc->vportOrgX; + Point->y = dc->vportOrgY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - SafePoint.x = dc->vportOrgX; - SafePoint.y = dc->vportOrgY; - - Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -690,13 +824,22 @@ if (Size) { - SIZE SafeSize; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; + + _SEH_TRY + { + ProbeForWrite(Size, + sizeof(SIZE), + 1); + Size->cx = dc->wndExtX; + Size->cy = dc->wndExtY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - SafeSize.cx = dc->wndExtX; - SafeSize.cy = dc->wndExtY; - - Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -732,13 +875,22 @@ if (Point) { - POINT SafePoint; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; + + _SEH_TRY + { + ProbeForWrite(Point, + sizeof(POINT), + 1); + Point->x = dc->wndOrgX; + Point->y = dc->wndOrgY; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - SafePoint.x = dc->wndOrgX; - SafePoint.y = dc->wndOrgY; - - Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -762,7 +914,7 @@ CONST LPXFORM XForm) { PDC dc; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; dc = DC_LockDc (hDC); if ( !dc ) @@ -785,7 +937,19 @@ return FALSE; } - Status = MmCopyFromCaller(&dc->w.xformWorld2Wnd, XForm, sizeof(XFORM)); + _SEH_TRY + { + ProbeForRead(XForm, + sizeof(XFORM), + 1); + dc->w.xformWorld2Wnd = *XForm; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); _____ Modified: trunk/reactos/subsys/win32k/objects/dc.c --- trunk/reactos/subsys/win32k/objects/dc.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/dc.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -69,7 +69,7 @@ } \ BOOL STDCALL NtGdi##FuncName ( HDC hdc, LP##type pt ) \ { \ - NTSTATUS Status; \ + NTSTATUS Status = STATUS_SUCCESS; \ type Safept; \ PDC dc; \ if(!pt) \ @@ -84,7 +84,18 @@ } \ Int##FuncName( dc, &Safept); \ DC_UnlockDc(dc); \ - Status = MmCopyToCaller(pt, &Safept, sizeof( type )); \ + _SEH_TRY \ + { \ + ProbeForWrite(pt, \ + sizeof( type ), \ + 1); \ + *pt = Safept; \ + } \ + _SEH_HANDLE \ + { \ + Status = _SEH_GetExceptionCode(); \ + } \ + _SEH_END; \ if(!NT_SUCCESS(Status)) \ { \ SetLastNtError(Status); \ @@ -830,11 +841,25 @@ UNICODE_STRING SafeDriver, SafeDevice; DEVMODEW SafeInitData; HDC Ret; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; if(InitData) { - Status = MmCopyFromCaller(&SafeInitData, InitData, sizeof(DEVMODEW)); + _SEH_TRY + { + ProbeForRead(InitData, + sizeof(DEVMODEW), + 1); + RtlCopyMemory(&SafeInitData, + InitData, + sizeof(DEVMODEW)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -878,11 +903,24 @@ UNICODE_STRING SafeDriver, SafeDevice; DEVMODEW SafeInitData; HDC Ret; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; if(InitData) { - Status = MmCopyFromCaller(&SafeInitData, InitData, sizeof(DEVMODEW)); + _SEH_TRY + { + ProbeForRead(InitData, + sizeof(DEVMODEW), + 1); + RtlCopyMemory(&SafeInitData, + InitData, + sizeof(DEVMODEW)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -1076,7 +1114,7 @@ BOOL Ret; DC *dc; POINT SafePoint; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; if(!Point) { @@ -1093,7 +1131,19 @@ Ret = IntGdiGetDCOrgEx(dc, &SafePoint); - Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); + _SEH_TRY + { + ProbeForWrite(Point, + sizeof(POINT), + 1); + *Point = SafePoint; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -1621,12 +1671,30 @@ { INT Ret; LPVOID SafeBuf; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; if (count <= 0) { return 0; } + + _SEH_TRY + { + ProbeForWrite(buffer, + count, + 1); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return 0; + } SafeBuf = ExAllocatePoolWithTag(PagedPool, count, TAG_GDIOBJ); if(!SafeBuf) @@ -1637,7 +1705,19 @@ Ret = IntGdiGetObject(handle, count, SafeBuf); - Status = MmCopyToCaller(buffer, SafeBuf, count); + _SEH_TRY + { + /* pointer already probed! */ + RtlCopyMemory(buffer, + SafeBuf, + count); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + ExFreePool(SafeBuf); if(!NT_SUCCESS(Status)) { _____ Modified: trunk/reactos/subsys/win32k/objects/fillshap.c --- trunk/reactos/subsys/win32k/objects/fillshap.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/fillshap.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -845,7 +845,7 @@ { DC *dc; LPPOINT Safept; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; BOOL Ret = FALSE; if ( Count < 2 ) @@ -853,6 +853,24 @@ SetLastWin32Error(ERROR_INVALID_PARAMETER); return FALSE; } + + _SEH_TRY + { + ProbeForRead(UnsafePoints, + Count * sizeof(POINT), + 1); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } dc = DC_LockDc(hDC); if(!dc) @@ -870,7 +888,19 @@ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); else { - Status = MmCopyFromCaller(Safept, UnsafePoints, sizeof(POINT) * Count); + _SEH_TRY + { + /* pointer was already probed! */ + RtlCopyMemory(Safept, + UnsafePoints, + Count * sizeof(POINT)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) SetLastNtError(Status); else @@ -913,6 +943,28 @@ if(Count > 0) { + _SEH_TRY + { + ProbeForRead(Points, + Count * sizeof(POINT), + 1); + ProbeForRead(PolyCounts, + Count * sizeof(INT), + 1); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if (!NT_SUCCESS(Status)) + { + DC_UnlockDc(dc); + SetLastNtError(Status); + return FALSE; + } + Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(INT)) * Count, TAG_SHAPE); if(!Safept) { @@ -922,16 +974,23 @@ } SafePolyPoints = (LPINT)&Safept[Count]; - - Status = MmCopyFromCaller(Safept, Points, sizeof(POINT) * Count); - if(!NT_SUCCESS(Status)) + + _SEH_TRY { - DC_UnlockDc(dc); - ExFreePool(Safept); - SetLastNtError(Status); - return FALSE; + /* pointers already probed! */ + RtlCopyMemory(Safept, + Points, + Count * sizeof(POINT)); + RtlCopyMemory(SafePolyPoints, + PolyCounts, + Count * sizeof(INT)); } - Status = MmCopyFromCaller(SafePolyPoints, PolyCounts, sizeof(INT) * Count); + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -1520,7 +1579,7 @@ PTRIVERTEX SafeVertex; PVOID SafeMesh; ULONG SizeMesh; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; dc = DC_LockDc(hdc); if(!dc) @@ -1555,6 +1614,28 @@ SetLastWin32Error(ERROR_INVALID_PARAMETER); return FALSE; } + + _SEH_TRY + { + ProbeForRead(pVertex, + uVertex * sizeof(TRIVERTEX), + 1); + ProbeForRead(pMesh, + SizeMesh, + 1); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if (!NT_SUCCESS(Status)) + { + DC_UnlockDc(dc); + SetLastWin32Error(Status); + return FALSE; + } if(!(SafeVertex = ExAllocatePoolWithTag(PagedPool, (uVertex * sizeof(TRIVERTEX)) + SizeMesh, TAG_SHAPE))) { @@ -1562,16 +1643,25 @@ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - Status = MmCopyFromCaller(SafeVertex, pVertex, uVertex * sizeof(TRIVERTEX)); - if(!NT_SUCCESS(Status)) + + SafeMesh = (PTRIVERTEX)(SafeVertex + uVertex); + + _SEH_TRY { - DC_UnlockDc(dc); - ExFreePool(SafeVertex); - SetLastNtError(Status); - return FALSE; + /* pointers were already probed! */ + RtlCopyMemory(SafeVertex, + pVertex, + uVertex * sizeof(TRIVERTEX)); + RtlCopyMemory(SafeMesh, + pMesh, + SizeMesh); } - SafeMesh = (PTRIVERTEX)(SafeVertex + uVertex); - Status = MmCopyFromCaller(SafeMesh, pMesh, SizeMesh); + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); _____ Modified: trunk/reactos/subsys/win32k/objects/line.c --- trunk/reactos/subsys/win32k/objects/line.c 2005-07-26 11:22:48 UTC (rev 16737) +++ trunk/reactos/subsys/win32k/objects/line.c 2005-07-26 12:22:55 UTC (rev 16738) @@ -503,7 +503,7 @@ { DC *dc; POINT SafePoint; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; BOOL Ret; dc = DC_LockDc(hDC); @@ -521,7 +521,19 @@ if(Point) { - Status = MmCopyFromCaller(&SafePoint, Point, sizeof(POINT)); + _SEH_TRY + { + ProbeForRead(Point, + sizeof(POINT), + 1); + SafePoint = *Point; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); @@ -544,7 +556,7 @@ { DC *dc; LPPOINT Safept; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; BOOL Ret; dc = DC_LockDc(hDC); @@ -562,6 +574,25 @@ if(Count > 0) { [truncated at 1000 lines; 1059 more skipped]
19 years, 6 months
1
0
0
0
[navaraf] 16737: Fix some bugs in DIB mapping code to prevent instant system crashes.
by navaraf@svn.reactos.com
Fix some bugs in DIB mapping code to prevent instant system crashes. Modified: trunk/reactos/subsys/win32k/objects/dib.c _____ Modified: trunk/reactos/subsys/win32k/objects/dib.c --- trunk/reactos/subsys/win32k/objects/dib.c 2005-07-26 11:00:15 UTC (rev 16736) +++ trunk/reactos/subsys/win32k/objects/dib.c 2005-07-26 11:22:48 UTC (rev 16737) @@ -175,7 +175,7 @@ RECTL DestRect; XLATEOBJ *XlateObj; PPALGDI hDCPalette; - //RGBQUAD *lpRGB; + //RGBQUAD *lpRGB; HPALETTE DDB_Palette, DIB_Palette; ULONG DDB_Palette_Type, DIB_Palette_Type; INT DIBWidth; @@ -190,7 +190,7 @@ //if (ColorUse == DIB_PAL_COLORS) // lpRGB = DIB_MapPaletteColors(hDC, bmi); //else - // lpRGB = &bmi->bmiColors[0]; + // lpRGB = &bmi->bmiColors; DestSurf = &bitmap->SurfObj; @@ -810,6 +810,7 @@ UINT Entries = 0; BITMAP bm; SIZEL Size; + RGBQUAD *lpRGB; DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n", bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount, @@ -846,7 +847,9 @@ } if(usage == DIB_PAL_COLORS) - memcpy(bmi->bmiColors, (UINT *)DIB_MapPaletteColors(dc, bmi), sizeof(UINT *)); + lpRGB = DIB_MapPaletteColors(dc, bmi); + else + lpRGB = bmi->bmiColors; // Allocate Memory for DIB and fill structure if (bm.bmBits) @@ -869,9 +872,9 @@ else switch(bi->biBitCount) { case 16: - dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)bmi->bmiColors : 0x7c00; - dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)bmi->bmiColors + 1) : 0x03e0; - dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)bmi->bmiColors + 2) : 0x001f; break; + dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB : 0x7c00; + dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB + 1) : 0x03e0; + dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB + 2) : 0x001f; break; case 24: dib->dsBitfields[0] = 0xff0000; @@ -880,9 +883,9 @@ break; case 32: - dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)bmi->bmiColors : 0xff0000; - dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)bmi->bmiColors + 1) : 0x00ff00; - dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)bmi->bmiColors + 2) : 0x0000ff; + dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB : 0xff0000; + dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB + 1) : 0x00ff00; + dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB + 2) : 0x0000ff; break; } dib->dshSection = section; @@ -901,12 +904,20 @@ bm.bmBits); if (! res) { + if (lpRGB != bmi->bmiColors) + { + ExFreePool(lpRGB); + } SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); return NULL; } bmp = BITMAPOBJ_LockBitmap(res); if (NULL == bmp) { + if (lpRGB != bmi->bmiColors) + { + ExFreePool(lpRGB); + } SetLastWin32Error(ERROR_INVALID_HANDLE); NtGdiDeleteObject(bmp); return NULL; @@ -921,7 +932,7 @@ if(bi->biBitCount == 8) { Entries = 256; } if (Entries) - bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(Entries, bmi->bmiColors); + bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(Entries, lpRGB); else bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL, dib->dsBitfields[0], @@ -946,6 +957,11 @@ if (res) { BITMAPOBJ_FreeBitmap(res); res = 0; } } + if (lpRGB != bmi->bmiColors) + { + ExFreePool(lpRGB); + } + if (bmp) { BITMAPOBJ_UnlockBitmap(bmp); @@ -1097,6 +1113,12 @@ return NULL; } + if (palGDI->Mode != PAL_INDEXED) + { + PALETTE_UnlockPalette(palGDI); + return NULL; + } + nNumColors = 1 << lpbmi->bmiHeader.biBitCount; if (lpbmi->bmiHeader.biClrUsed) {
19 years, 6 months
1
0
0
0
[navaraf] 16736: Properly setup the I/O stack location in IopSecurityFile.
by navaraf@svn.reactos.com
Properly setup the I/O stack location in IopSecurityFile. Modified: trunk/reactos/ntoskrnl/io/file.c _____ Modified: trunk/reactos/ntoskrnl/io/file.c --- trunk/reactos/ntoskrnl/io/file.c 2005-07-26 10:35:13 UTC (rev 16735) +++ trunk/reactos/ntoskrnl/io/file.c 2005-07-26 11:00:15 UTC (rev 16736) @@ -324,6 +324,7 @@ /* Set Stack Parameters */ StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = MajorFunction; StackPtr->FileObject = FileObject; /* Set Parameters */
19 years, 6 months
1
0
0
0
[navaraf] 16735: Don't allow setting menu for child windows in IntSetMenu.
by navaraf@svn.reactos.com
Don't allow setting menu for child windows in IntSetMenu. Modified: trunk/reactos/subsys/win32k/ntuser/window.c _____ Modified: trunk/reactos/subsys/win32k/ntuser/window.c --- trunk/reactos/subsys/win32k/ntuser/window.c 2005-07-26 08:55:25 UTC (rev 16734) +++ trunk/reactos/subsys/win32k/ntuser/window.c 2005-07-26 10:35:13 UTC (rev 16735) @@ -499,13 +499,19 @@ { PMENU_OBJECT OldMenuObject, NewMenuObject = NULL; + if ((WindowObject->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + *Changed = (WindowObject->IDMenu != (UINT) Menu); if (! *Changed) { return TRUE; } - if (0 != WindowObject->IDMenu) + if (WindowObject->IDMenu) { OldMenuObject = IntGetMenuObject((HMENU) WindowObject->IDMenu); ASSERT(NULL == OldMenuObject || OldMenuObject->MenuInfo.Wnd == WindowObject->Self);
19 years, 6 months
1
0
0
0
[navaraf] 16734: #include "csrss.h" -> #include <csrss.h>
by navaraf@svn.reactos.com
#include "csrss.h" -> #include <csrss.h> Modified: trunk/reactos/subsys/csrss/api/handle.c Modified: trunk/reactos/subsys/csrss/api/process.c Modified: trunk/reactos/subsys/csrss/api/user.c Modified: trunk/reactos/subsys/csrss/api/wapi.c Modified: trunk/reactos/subsys/csrss/csrss.c Modified: trunk/reactos/subsys/csrss/init.c Modified: trunk/reactos/subsys/csrss/print.c Modified: trunk/reactos/subsys/csrss/video.c _____ Modified: trunk/reactos/subsys/csrss/api/handle.c --- trunk/reactos/subsys/csrss/api/handle.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/api/handle.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -9,7 +9,7 @@ /* INCLUDES ******************************************************************/ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/api/process.c --- trunk/reactos/subsys/csrss/api/process.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/api/process.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -9,7 +9,7 @@ /* INCLUDES ******************************************************************/ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/api/user.c --- trunk/reactos/subsys/csrss/api/user.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/api/user.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -9,7 +9,7 @@ /* INCLUDES ******************************************************************/ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/api/wapi.c --- trunk/reactos/subsys/csrss/api/wapi.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/api/wapi.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -10,7 +10,7 @@ /* INCLUDES ******************************************************************/ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/csrss.c --- trunk/reactos/subsys/csrss/csrss.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/csrss.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -32,7 +32,7 @@ * actually does nothing but running). */ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/init.c --- trunk/reactos/subsys/csrss/init.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/init.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -10,7 +10,7 @@ /* INCLUDES ******************************************************************/ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/print.c --- trunk/reactos/subsys/csrss/print.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/print.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -27,7 +27,7 @@ * Compiled successfully with egcs 1.1.2 */ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/subsys/csrss/video.c --- trunk/reactos/subsys/csrss/video.c 2005-07-26 08:40:02 UTC (rev 16733) +++ trunk/reactos/subsys/csrss/video.c 2005-07-26 08:55:25 UTC (rev 16734) @@ -3,7 +3,7 @@ * ReactOS Project */ -#include "csrss.h" +#include <csrss.h> #define NDEBUG #include <debug.h>
19 years, 6 months
1
0
0
0
[navaraf] 16733: #include "rtl.h" -> #include <rtl.h>
by navaraf@svn.reactos.com
#include "rtl.h" -> #include <rtl.h> Modified: trunk/reactos/lib/rtl/i386/exception.c _____ Modified: trunk/reactos/lib/rtl/i386/exception.c --- trunk/reactos/lib/rtl/i386/exception.c 2005-07-26 08:39:07 UTC (rev 16732) +++ trunk/reactos/lib/rtl/i386/exception.c 2005-07-26 08:40:02 UTC (rev 16733) @@ -9,7 +9,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h>
19 years, 6 months
1
0
0
0
[navaraf] 16732: #include "rtl.h" -> #include <rtl.h>
by navaraf@svn.reactos.com
#include "rtl.h" -> #include <rtl.h> Modified: trunk/reactos/lib/rtl/access.c Modified: trunk/reactos/lib/rtl/acl.c Modified: trunk/reactos/lib/rtl/atom.c Modified: trunk/reactos/lib/rtl/bit.c Modified: trunk/reactos/lib/rtl/bitmap.c Modified: trunk/reactos/lib/rtl/bootdata.c Modified: trunk/reactos/lib/rtl/compress.c Modified: trunk/reactos/lib/rtl/dos8dot3.c Modified: trunk/reactos/lib/rtl/encode.c Modified: trunk/reactos/lib/rtl/env.c Modified: trunk/reactos/lib/rtl/error.c Modified: trunk/reactos/lib/rtl/exception.c Modified: trunk/reactos/lib/rtl/generictable.c Modified: trunk/reactos/lib/rtl/heap.c Modified: trunk/reactos/lib/rtl/image.c Modified: trunk/reactos/lib/rtl/largeint.c Modified: trunk/reactos/lib/rtl/luid.c Modified: trunk/reactos/lib/rtl/mem.c Modified: trunk/reactos/lib/rtl/network.c Modified: trunk/reactos/lib/rtl/nls.c Modified: trunk/reactos/lib/rtl/ppb.c Modified: trunk/reactos/lib/rtl/process.c Modified: trunk/reactos/lib/rtl/random.c Modified: trunk/reactos/lib/rtl/registry.c Modified: trunk/reactos/lib/rtl/sd.c Modified: trunk/reactos/lib/rtl/security.c Modified: trunk/reactos/lib/rtl/sid.c Modified: trunk/reactos/lib/rtl/splaytree.c Modified: trunk/reactos/lib/rtl/thread.c Modified: trunk/reactos/lib/rtl/time.c Modified: trunk/reactos/lib/rtl/timezone.c Modified: trunk/reactos/lib/rtl/unicode.c Modified: trunk/reactos/lib/rtl/unicodeprefix.c Modified: trunk/reactos/lib/rtl/version.c _____ Modified: trunk/reactos/lib/rtl/access.c --- trunk/reactos/lib/rtl/access.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/access.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -9,7 +9,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/acl.c --- trunk/reactos/lib/rtl/acl.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/acl.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/atom.c --- trunk/reactos/lib/rtl/atom.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/atom.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/bit.c --- trunk/reactos/lib/rtl/bit.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/bit.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/bitmap.c --- trunk/reactos/lib/rtl/bitmap.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/bitmap.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -28,7 +28,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/bootdata.c --- trunk/reactos/lib/rtl/bootdata.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/bootdata.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -24,7 +24,7 @@ * FILE: lib/rtl/bootdata.c */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/compress.c --- trunk/reactos/lib/rtl/compress.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/compress.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -27,7 +27,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/dos8dot3.c --- trunk/reactos/lib/rtl/dos8dot3.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/dos8dot3.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -27,7 +27,7 @@ /* INCLUDES ******************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/encode.c --- trunk/reactos/lib/rtl/encode.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/encode.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -12,7 +12,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/env.c --- trunk/reactos/lib/rtl/env.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/env.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES ******************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/error.c --- trunk/reactos/lib/rtl/error.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/error.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -19,7 +19,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/exception.c --- trunk/reactos/lib/rtl/exception.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/exception.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -15,7 +15,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/generictable.c --- trunk/reactos/lib/rtl/generictable.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/generictable.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -24,7 +24,7 @@ * FILE: lib/rtl/genertictbl.c */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/heap.c --- trunk/reactos/lib/rtl/heap.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/heap.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -12,7 +12,7 @@ * require it. */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/image.c --- trunk/reactos/lib/rtl/image.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/image.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -9,7 +9,7 @@ * 17/03/2000 Created */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/largeint.c --- trunk/reactos/lib/rtl/largeint.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/largeint.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/luid.c --- trunk/reactos/lib/rtl/luid.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/luid.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/mem.c --- trunk/reactos/lib/rtl/mem.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/mem.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -12,7 +12,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/network.c --- trunk/reactos/lib/rtl/network.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/network.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -24,7 +24,7 @@ * FILE: lib/rtl/network.c */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/nls.c --- trunk/reactos/lib/rtl/nls.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/nls.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -13,7 +13,7 @@ */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/ppb.c --- trunk/reactos/lib/rtl/ppb.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/ppb.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES ****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/process.c --- trunk/reactos/lib/rtl/process.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/process.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES ****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/random.c --- trunk/reactos/lib/rtl/random.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/random.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/registry.c --- trunk/reactos/lib/rtl/registry.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/registry.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -18,7 +18,7 @@ /* INCLUDES ****************************************************************/ #define __NTDRIVER__ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/sd.c --- trunk/reactos/lib/rtl/sd.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/sd.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/security.c --- trunk/reactos/lib/rtl/security.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/security.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -9,7 +9,7 @@ * 21/11/2001 Created */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/sid.c --- trunk/reactos/lib/rtl/sid.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/sid.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ #define __NTDRIVER__ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/splaytree.c --- trunk/reactos/lib/rtl/splaytree.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/splaytree.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -24,7 +24,7 @@ * FILE: lib/rtl/splaytree.c */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/thread.c --- trunk/reactos/lib/rtl/thread.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/thread.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/time.c --- trunk/reactos/lib/rtl/time.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/time.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -12,7 +12,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/timezone.c --- trunk/reactos/lib/rtl/timezone.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/timezone.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/unicode.c --- trunk/reactos/lib/rtl/unicode.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/unicode.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -20,7 +20,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define __NTDRIVER__ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/unicodeprefix.c --- trunk/reactos/lib/rtl/unicodeprefix.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/unicodeprefix.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -24,7 +24,7 @@ * FILE: lib/rtl/unicodeprfx.c */ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h> _____ Modified: trunk/reactos/lib/rtl/version.c --- trunk/reactos/lib/rtl/version.c 2005-07-26 04:52:11 UTC (rev 16731) +++ trunk/reactos/lib/rtl/version.c 2005-07-26 08:39:07 UTC (rev 16732) @@ -30,7 +30,7 @@ /* INCLUDES *****************************************************************/ -#include "rtl.h" +#include <rtl.h> #define NDEBUG #include <debug.h>
19 years, 6 months
1
0
0
0
[ion] 16731: - Remove ROSRTL. The era is over. Thanks to Filip for his help during the last month.
by ion@svn.reactos.com
- Remove ROSRTL. The era is over. Thanks to Filip for his help during the last month. Modified: trunk/reactos/drivers/net/tcpip/include/precomp.h Added: trunk/reactos/drivers/net/tcpip/recmutex/ Added: trunk/reactos/drivers/net/tcpip/recmutex/recmutex.c Added: trunk/reactos/drivers/net/tcpip/recmutex/recmutex.h Modified: trunk/reactos/drivers/net/tcpip/tcpip.xml Deleted: trunk/reactos/include/rosrtl/ Modified: trunk/reactos/lib/directory.xml Modified: trunk/reactos/lib/dnsapi/dnsapi.xml Modified: trunk/reactos/lib/gdi32/gdi32.xml Modified: trunk/reactos/lib/kernel32/kernel32.xml Modified: trunk/reactos/lib/kernel32/tests/kernel32.xml Modified: trunk/reactos/lib/ntdll/ntdll.xml Deleted: trunk/reactos/lib/rosrtl/ Added: trunk/reactos/lib/rtl/qsort.c Modified: trunk/reactos/lib/rtl/rtl.xml Modified: trunk/reactos/lib/user32/user32.xml Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml Modified: trunk/reactos/subsys/win32k/tests/win32k.xml Modified: trunk/reactos/subsys/win32k/win32k.xml _____ Modified: trunk/reactos/drivers/net/tcpip/include/precomp.h --- trunk/reactos/drivers/net/tcpip/include/precomp.h 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/drivers/net/tcpip/include/precomp.h 2005-07-26 04:52:11 UTC (rev 16731) @@ -1,7 +1,7 @@ #include <roscfg.h> #include <limits.h> #include <ddk/ntddk.h> -#include <rosrtl/recmutex.h> +#include <../recmutex/recmutex.h> #include <roscfg.h> #include <tcpip.h> #include <loopback.h> _____ Copied: trunk/reactos/drivers/net/tcpip/recmutex/recmutex.c (from rev 16725, trunk/reactos/lib/rosrtl/recmutex/recmutex.c) --- trunk/reactos/lib/rosrtl/recmutex/recmutex.c 2005-07-25 20:28:29 UTC (rev 16725) +++ trunk/reactos/drivers/net/tcpip/recmutex/recmutex.c 2005-07-26 04:52:11 UTC (rev 16731) @@ -0,0 +1,83 @@ +#include <ddk/ntddk.h> +#include "recmutex.h" + +VOID RecursiveMutexInit( PRECURSIVE_MUTEX RecMutex ) { + RtlZeroMemory( RecMutex, sizeof(*RecMutex) ); + KeInitializeSpinLock( &RecMutex->SpinLock ); + ExInitializeFastMutex( &RecMutex->Mutex ); + KeInitializeEvent( &RecMutex->StateLockedEvent, + NotificationEvent, FALSE ); +} + +/* NOTE: When we leave, the FAST_MUTEX must have been released. The result + * is that we always exit in the same irql as entering */ +UINT RecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOL ToWrite ) { + NTSTATUS Status = STATUS_SUCCESS; + PVOID CurrentThread = KeGetCurrentThread(); + + /* Wait for the previous user to unlock the RecMutex state. There might be + * multiple waiters waiting to change the state. We need to check each + * time we get the event whether somebody still has the state locked */ + + if( !RecMutex ) return FALSE; + + if( CurrentThread == RecMutex->CurrentThread || + (!ToWrite && !RecMutex->Writer) ) { + RecMutex->LockCount++; + return TRUE; + } + + if( KeGetCurrentIrql() == PASSIVE_LEVEL ) { + ExAcquireFastMutex( &RecMutex->Mutex ); + RecMutex->OldIrql = PASSIVE_LEVEL; + while( RecMutex->Locked ) { + ExReleaseFastMutex( &RecMutex->Mutex ); + Status = KeWaitForSingleObject( &RecMutex->StateLockedEvent, + UserRequest, + KernelMode, + FALSE, + NULL ); + ExAcquireFastMutex( &RecMutex->Mutex ); + if( Status == STATUS_SUCCESS ) break; + } + RecMutex->Locked = TRUE; + RecMutex->Writer = ToWrite; + RecMutex->CurrentThread = CurrentThread; + RecMutex->LockCount++; + ExReleaseFastMutex( &RecMutex->Mutex ); + } else { + KeAcquireSpinLock( &RecMutex->SpinLock, &RecMutex->OldIrql ); + RecMutex->Locked = TRUE; + RecMutex->Writer = ToWrite; + RecMutex->CurrentThread = CurrentThread; + RecMutex->LockCount++; + } + + return TRUE; +} + +VOID RecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex ) { + if( RecMutex->LockCount == 0 ) { + return; + } else + RecMutex->LockCount--; + + if( !RecMutex->LockCount ) { + RecMutex->CurrentThread = NULL; + if( RecMutex->OldIrql == PASSIVE_LEVEL ) { + ExAcquireFastMutex( &RecMutex->Mutex ); + RecMutex->Locked = FALSE; + RecMutex->Writer = FALSE; + ExReleaseFastMutex( &RecMutex->Mutex ); + } else { + RecMutex->Locked = FALSE; + RecMutex->Writer = FALSE; + KeReleaseSpinLock( &RecMutex->SpinLock, RecMutex->OldIrql ); + } + + RecMutex->OldIrql = PASSIVE_LEVEL; + KePulseEvent( &RecMutex->StateLockedEvent, IO_NETWORK_INCREMENT, + FALSE ); + } +} + _____ Copied: trunk/reactos/drivers/net/tcpip/recmutex/recmutex.h (from rev 16725, trunk/reactos/include/rosrtl/recmutex.h) _____ Modified: trunk/reactos/drivers/net/tcpip/tcpip.xml --- trunk/reactos/drivers/net/tcpip/tcpip.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/drivers/net/tcpip/tcpip.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -8,7 +8,6 @@ <library>ip</library> <library>oskittcp</library> <library>ndis</library> - <library>rosrtl</library> <library>pseh</library> <library>ntoskrnl</library> <library>hal</library> @@ -18,6 +17,9 @@ <directory name="datalink"> <file>lan.c</file> </directory> + <directory name="recmutex"> + <file>recmutex.c</file> + </directory> <directory name="tcpip"> <file>buffer.c</file> <file>bug.c</file> _____ Modified: trunk/reactos/lib/directory.xml --- trunk/reactos/lib/directory.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/directory.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -214,9 +214,6 @@ <directory name="riched20"> <xi:include href="riched20/riched20.xml" /> </directory> -<directory name="rosrtl"> - <xi:include href="rosrtl/rosrtl.xml" /> -</directory> <directory name="rossym"> <xi:include href="rossym/rossym.xml" /> </directory> _____ Modified: trunk/reactos/lib/dnsapi/dnsapi.xml --- trunk/reactos/lib/dnsapi/dnsapi.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/dnsapi/dnsapi.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -7,7 +7,6 @@ <define name="ADNS_JGAA_WIN32" /> <define name="__USE_W32API" /> <library>adns</library> - <library>rosrtl</library> <library>ntdll</library> <library>kernel32</library> <library>user32</library> _____ Modified: trunk/reactos/lib/gdi32/gdi32.xml --- trunk/reactos/lib/gdi32/gdi32.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/gdi32/gdi32.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -7,7 +7,6 @@ <define name="WINVER">0x0600</define> <define name="_WIN32_WINNT">0x0501</define> <library>ntdll</library> - <library>rosrtl</library> <library>kernel32</library> <library>advapi32</library> <directory name="include"> _____ Modified: trunk/reactos/lib/kernel32/kernel32.xml --- trunk/reactos/lib/kernel32/kernel32.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/kernel32/kernel32.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -118,7 +118,6 @@ <define name="WINVER">0x0500</define> <library>kernel32_base</library> <library>pseh</library> - <library>rosrtl</library> <library>intrlck</library> <library>ntdll</library> <linkerflag>-lgcc</linkerflag> _____ Modified: trunk/reactos/lib/kernel32/tests/kernel32.xml --- trunk/reactos/lib/kernel32/tests/kernel32.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/kernel32/tests/kernel32.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -10,7 +10,6 @@ <library>regtests</library> <library>kernel32_base</library> <library>pseh</library> - <library>rosrtl</library> <library>ntdll</library> <library>msvcrt</library> <linkerflag>-lgcc</linkerflag> _____ Modified: trunk/reactos/lib/ntdll/ntdll.xml --- trunk/reactos/lib/ntdll/ntdll.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/ntdll/ntdll.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -8,7 +8,6 @@ <define name="_WIN32_WINNT">0x0502</define> <define name="_NTOSKRNL_" /> <library>rtl</library> - <library>rosrtl</library> <library>intrlck</library> <library>string</library> <linkerflag>-lgcc</linkerflag> _____ Added: trunk/reactos/lib/rtl/qsort.c --- trunk/reactos/lib/rtl/qsort.c 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/rtl/qsort.c 2005-07-26 04:52:11 UTC (rev 16731) @@ -0,0 +1,266 @@ +/* $Id: qsort.c 12852 2005-01-06 13:58:04Z mf $ + * + * FILE: ntoskrnl/rtl/qsort.c + * NOTE: Adapted from CygWin newlib 2000-03-12. + */ +/* +FUNCTION +<<qsort>>---sort an array + +INDEX + qsort + +ANSI_SYNOPSIS + #include <stdlib.h> + void qsort(void *<[base]>, size_t <[nmemb]>, size_t <[size]>, + int (*<[compar]>)(const void *, const void *) ); + +TRAD_SYNOPSIS + #include <stdlib.h> + qsort(<[base]>, <[nmemb]>, <[size]>, <[compar]> ) + char *<[base]>; + size_t <[nmemb]>; + size_t <[size]>; + int (*<[compar]>)(); + +DESCRIPTION +<<qsort>> sorts an array (beginning at <[base]>) of <[nmemb]> objects. +<[size]> describes the size of each element of the array. + +You must supply a pointer to a comparison function, using the argument +shown as <[compar]>. (This permits sorting objects of unknown +properties.) Define the comparison function to accept two arguments, +each a pointer to an element of the array starting at <[base]>. The +result of <<(*<[compar]>)>> must be negative if the first argument is +less than the second, zero if the two arguments match, and positive if +the first argument is greater than the second (where ``less than'' and +``greater than'' refer to whatever arbitrary ordering is appropriate). + +The array is sorted in place; that is, when <<qsort>> returns, the +array elements beginning at <[base]> have been reordered. + +RETURNS +<<qsort>> does not return a result. + +PORTABILITY +<<qsort>> is required by ANSI (without specifying the sorting algorithm). +*/ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __GNUC__ +#define inline +#endif + +/* FIXME: these types should be from the default includes */ + +typedef int (* _pfunccmp_t) (char *, char *); +typedef int size_t; + +#define min(a,b) ((a)<(b)?(a):(b)) + +/* + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". + */ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + register TYPE *pi = (TYPE *) (parmi); \ + register TYPE *pj = (TYPE *) (parmj); \ + do { \ + register TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + +static inline void +swapfunc ( + char * a, + char * b, + int n, + int swaptype + ) +{ + if(swaptype <= 1) + swapcode(long, a, b, n) + else + swapcode(char, a, b, n) +} + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, es, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + +static inline char * +med3 ( + char * a, + char * b, + char * c, + _pfunccmp_t cmp + ) +{ + return cmp(a, b) < 0 ? + (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) + :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); +} + + +/* EXPORTED */ +void +qsort ( + void * a, + size_t n, + size_t es, + _pfunccmp_t cmp + ) +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + int d, r, swaptype, swap_cnt; + +loop: SWAPINIT(a, es); + swap_cnt = 0; + if (n < 7) + { + for ( pm = (char *) a + es; + pm < (char *) a + n * es; + pm += es + ) + { + for ( pl = pm; + pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es + ) + { + swap(pl, pl - es); + } + } + return; + } + pm = (char *) a + (n / 2) * es; + if (n > 7) + { + pl = (char *) a; + pn = (char *) a + (n - 1) * es; + if (n > 40) + { + d = (n / 8) * es; + pl = med3(pl, pl + d, pl + 2 * d, cmp); + pm = med3(pm - d, pm, pm + d, cmp); + pn = med3(pn - 2 * d, pn - d, pn, cmp); + } + pm = med3(pl, pm, pn, cmp); + } + swap(a, pm); + pa = pb = (char *) a + es; + + pc = pd = (char *) a + (n - 1) * es; + for (;;) + { + while (pb <= pc && (r = cmp(pb, a)) <= 0) + { + if (r == 0) + { + swap_cnt = 1; + swap(pa, pb); + pa += es; + } + pb += es; + } + while (pb <= pc && (r = cmp(pc, a)) >= 0) + { + if (r == 0) + { + swap_cnt = 1; + swap(pc, pd); + pd -= es; + } + pc -= es; + } + if (pb > pc) + { + break; + } + swap(pb, pc); + swap_cnt = 1; + pb += es; + pc -= es; + } + if (swap_cnt == 0) /* Switch to insertion sort */ + { + for ( pm = (char *) a + es; + pm < (char *) a + n * es; + pm += es + ) + { + for ( pl = pm; + pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es + ) + { + swap(pl, pl - es); + } + } + return; + } + + pn = (char *) a + n * es; + r = min(pa - (char *)a, pb - pa); + vecswap(a, pb - r, r); + r = min(pd - pc, pn - pd - es); + vecswap(pb, pn - r, r); + if ((r = pb - pa) > es) + { + qsort(a, r / es, es, cmp); + } + if ((r = pd - pc) > es) + { + /* Iterate rather than recurse to save stack space */ + a = pn - r; + n = r / es; + goto loop; + } +/* qsort(pn - r, r / es, es, cmp);*/ +} + + +/* EOF */ _____ Modified: trunk/reactos/lib/rtl/rtl.xml --- trunk/reactos/lib/rtl/rtl.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/rtl/rtl.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -37,6 +37,7 @@ <file>nls.c</file> <file>ppb.c</file> <file>process.c</file> + <file>qsort.c</file> <file>random.c</file> <file>registry.c</file> <file>sd.c</file> _____ Modified: trunk/reactos/lib/user32/user32.xml --- trunk/reactos/lib/user32/user32.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/lib/user32/user32.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -11,7 +11,6 @@ <library>wine</library> <library>ntdll</library> <library>gdi32</library> - <library>rosrtl</library> <library>kernel32</library> <library>advapi32</library> <directory name="include"> _____ Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml --- trunk/reactos/ntoskrnl/ntoskrnl.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/ntoskrnl/ntoskrnl.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -14,7 +14,6 @@ <library>kjs</library> <library>pseh</library> <library>rtl</library> - <library>rosrtl</library> <library>rossym</library> <library>string</library> <library>wdmguid</library> _____ Modified: trunk/reactos/subsys/win32k/tests/win32k.xml --- trunk/reactos/subsys/win32k/tests/win32k.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/subsys/win32k/tests/win32k.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -14,7 +14,6 @@ <library>regtests</library> <library>win32k_base</library> <library>pseh</library> - <library>rosrtl</library> <directory name="tests"> <file>DIB_24BPP_ColorFill-performance.c</file> </directory> _____ Modified: trunk/reactos/subsys/win32k/win32k.xml --- trunk/reactos/subsys/win32k/win32k.xml 2005-07-26 04:14:10 UTC (rev 16730) +++ trunk/reactos/subsys/win32k/win32k.xml 2005-07-26 04:52:11 UTC (rev 16731) @@ -132,7 +132,6 @@ <importlibrary definition="win32k.def" /> <library>win32k_base</library> <library>pseh</library> - <library>rosrtl</library> <library>ntoskrnl</library> <library>hal</library> <library>freetype</library>
19 years, 6 months
1
0
0
0
[ion] 16730: - Final ROSRTL removal patch. The next patch will remove the actual library and code.
by ion@svn.reactos.com
- Final ROSRTL removal patch. The next patch will remove the actual library and code. - Changes: - CreateProcess * Cleanup creation of the initial thread using new utility functions and remove rosrtl * Almost entirely rewrote the function to support features such as: - SxS (locally only, patch will follow), - SFP (SAFER) (locally only, patch will follow), - DllPaths (locally only, patch will follow), - Proper process environment/paramter block creation - Proper console handle management (needs more work in kernel32/csr), - Tokens/CreateProcessAsUser (locally only, patch will follow), - Simpler code for path lookup, and more robust. - Support for "auto-correction" (see Raymond Chen's blog) - 16-bit/NE detection - A variety of creation flags are now properly supported - Added support for an undocumented-yet-known (see comment) shell flag - Alert for flags we don't support yet - Catch invalid flag combinations and other caller errors - Improve and correct path searcing to use documented behaviours - Created a multitude of helper functions to make the code easier to read and allow them to be used for other apis as time goes on. - BaseProcessStartup * Call NtSetThreadInformation to let the Kernel know of the Thread's Start Address. * Correct prototype of Thread Startup function for this case. This fixes MANY things, some of which may not be evident, and possibly creates regressions which I have not yet seen but will try to correct. Some of these may be caused by the fact that I've seen code send CreateProcessW incorrect flags. Some things of note: DO NOT send partial names as "lpApplicationName". It's not supposed to work unless you're in the same current directory. Also, do NOT send CREATE_UNICODE_ENVIRONMENT if you don't have a unicode environement, and vice-versa. I've seen lots of code doing mistakes related to this. I hope you appreciate this patch and won't all jump on me for possbile regressions :(. Modified: trunk/reactos/lib/kernel32/process/create.c Modified: trunk/reactos/lib/kernel32/thread/i386/thread.S Modified: trunk/reactos/lib/kernel32/thread/thread.c Modified: trunk/reactos/ntoskrnl/mm/process.c _____ Modified: trunk/reactos/lib/kernel32/process/create.c --- trunk/reactos/lib/kernel32/process/create.c 2005-07-26 00:50:17 UTC (rev 16729) +++ trunk/reactos/lib/kernel32/process/create.c 2005-07-26 04:14:10 UTC (rev 16730) @@ -1,1399 +1,1455 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/kernel32/process/create.c * PURPOSE: Process functions - * PROGRAMMER: Ariadne ( ariadne(a)xs4all.nl) - * UPDATE HISTORY: - * Created 01/11/98 + * PROGRAMMER: Alex Ionescu (alex(a)relsoft.net) + * Ariadne ( ariadne(a)xs4all.nl) */ /* INCLUDES ****************************************************************/ #include <k32.h> -/* FIXME */ -#include <rosrtl/thread.h> - #define NDEBUG -#include "../include/debug.h" +#include <debug.h> -/* FUNCTIONS ****************************************************************/ +#define CMD_STRING L"cmd /c " extern __declspec(noreturn) -VOID CALLBACK ConsoleControlDispatcher(DWORD CodeAndFlag); +VOID +CALLBACK +ConsoleControlDispatcher(DWORD CodeAndFlag); -__declspec(dllimport) -PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine; +/* INTERNAL FUNCTIONS *******************************************************/ -typedef NTSTATUS STDCALL (K32_MBSTR_TO_WCSTR) -( - UNICODE_STRING *, - ANSI_STRING *, - BOOLEAN -); - -NTSTATUS STDCALL K32MbStrToWcStr(IN K32_MBSTR_TO_WCSTR * True, - UNICODE_STRING * DestStr, - ANSI_STRING * SourceStr, - BOOLEAN Allocate) +_SEH_FILTER(BaseExceptionFilter) { - if(SourceStr->Buffer == NULL) - { - DestStr->Length = DestStr->MaximumLength = 0; - DestStr->Buffer = NULL; - return STATUS_SUCCESS; - } + EXCEPTION_POINTERS *ExceptionInfo = _SEH_GetExceptionPointers(); + LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER; - return True(DestStr, SourceStr, Allocate); + if (GlobalTopLevelExceptionFilter != NULL) + { + _SEH_TRY + { + ExceptionDisposition = GlobalTopLevelExceptionFilter(ExceptionInfo); + } + _SEH_HANDLE + { + ExceptionDisposition = UnhandledExceptionFilter(ExceptionInfo); + } + _SEH_END; + } + + return ExceptionDisposition; } -VOID STDCALL RtlRosR32AttribsToNativeAttribs(OUT OBJECT_ATTRIBUTES * NativeAttribs, - IN SECURITY_ATTRIBUTES * Ros32Attribs OPTIONAL) +VOID +STDCALL +BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress) { - NativeAttribs->Length = sizeof(*NativeAttribs); - NativeAttribs->ObjectName = NULL; - NativeAttribs->RootDirectory = NULL; - NativeAttribs->Attributes = 0; - NativeAttribs->SecurityQualityOfService = NULL; + UINT uExitCode = 0; + DPRINT("BaseProcessStartup(..) - setting up exception frame.\n"); - if(Ros32Attribs != NULL && Ros32Attribs->nLength >= sizeof(*Ros32Attribs)) - { - NativeAttribs->SecurityDescriptor = Ros32Attribs->lpSecurityDescriptor; + _SEH_TRY + { + /* Set our Start Address */ + NtSetInformationThread(NtCurrentThread(), + ThreadQuerySetWin32StartAddress, + &lpStartAddress, + sizeof(PPROCESS_START_ROUTINE)); + + /* Call the Start Routine */ + uExitCode = (lpStartAddress)(); + } + _SEH_EXCEPT(BaseExceptionFilter) + { + /* Get the SEH Error */ + uExitCode = _SEH_GetExceptionCode(); + } + _SEH_END; - if(Ros32Attribs->bInheritHandle) - { - NativeAttribs->Attributes |= OBJ_INHERIT; - } - } - else - { - NativeAttribs->SecurityDescriptor = NULL; - } + /* Exit the Process with our error */ + ExitProcess(uExitCode); } -VOID STDCALL RtlRosR32AttribsToNativeAttribsNamed(OUT OBJECT_ATTRIBUTES * NativeAttribs, - IN SECURITY_ATTRIBUTES * Ros32Attribs OPTIONAL, - OUT UNICODE_STRING * NativeName OPTIONAL, - IN WCHAR * Ros32Name OPTIONAL, - IN HANDLE Ros32NameRoot OPTIONAL) +/* + * Tells CSR that a new process was created + */ +NTSTATUS +STDCALL +BasepNotifyCsrOfCreation(ULONG dwCreationFlags, + IN HANDLE ProcessId, + IN ULONG SubsystemType, + OUT PHANDLE ConsoleHandle, + OUT PHANDLE InputHandle, + OUT PHANDLE OutputHandle) { - if(!NativeAttribs) return; + ULONG Request = CREATE_PROCESS; + CSR_API_MESSAGE CsrRequest; + NTSTATUS Status; + + DPRINT("BasepNotifyCsrOfCreation\n"); + + /* Some hacks (heck, this whole API is a hack) */ + if (SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_GUI) + { + dwCreationFlags = (dwCreationFlags &~ CREATE_NEW_CONSOLE) | + DETACHED_PROCESS; + } + else if (SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI) + { + dwCreationFlags |= CREATE_NEW_CONSOLE; + } + + /* Fill out the request */ + CsrRequest.Data.CreateProcessRequest.NewProcessId = ProcessId; + CsrRequest.Data.CreateProcessRequest.Flags = dwCreationFlags; + CsrRequest.Data.CreateProcessRequest.CtrlDispatcher = ConsoleControlDispatcher; + CsrRequest.Data.CreateProcessRequest.InputHandle = 0; + CsrRequest.Data.CreateProcessRequest.OutputHandle = 0; + CsrRequest.Data.CreateProcessRequest.Console = 0; + + /* Call CSR */ + Status = CsrClientCallServer(&CsrRequest, + NULL, + MAKE_CSR_API(Request, CSR_NATIVE), + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status)) + { + DPRINT1("Failed to tell csrss about new process\n"); + return CsrRequest.Status; + } + /* Return Handles */ + *ConsoleHandle = CsrRequest.Data.CreateProcessRequest.Console; + *InputHandle = CsrRequest.Data.CreateProcessRequest.InputHandle; + *OutputHandle = CsrRequest.Data.CreateProcessRequest.OutputHandle; + DPRINT("CSR Created: %lx %lx\n", *InputHandle, *OutputHandle); + + /* REturn Success */ + return STATUS_SUCCESS; +} - RtlRosR32AttribsToNativeAttribs(NativeAttribs, Ros32Attribs); +/* + * Creates the first Thread in a Proces + */ +HANDLE +STDCALL +BasepCreateFirstThread(HANDLE ProcessHandle, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + PSECTION_IMAGE_INFORMATION SectionImageInfo, + PCLIENT_ID ClientId) +{ + OBJECT_ATTRIBUTES LocalObjectAttributes; + POBJECT_ATTRIBUTES ObjectAttributes; + CONTEXT Context; + INITIAL_TEB InitialTeb; + NTSTATUS Status; + HANDLE hThread; + + DPRINT("BasepCreateFirstThread. hProcess: %lx\n", ProcessHandle); - if(Ros32Name != NULL && NativeName != NULL) - { - RtlInitUnicodeString(NativeName, Ros32Name); - - NativeAttribs->ObjectName = NativeName; - NativeAttribs->RootDirectory = Ros32NameRoot; - NativeAttribs->Attributes |= OBJ_CASE_INSENSITIVE; - } + /* Create the Thread's Stack */ + BasepCreateStack(ProcessHandle, + SectionImageInfo->MaximumStackSize, + SectionImageInfo->CommittedStackSize, + &InitialTeb); + + /* Create the Thread's Context */ + BasepInitializeContext(&Context, + NtCurrentPeb(), + SectionImageInfo->TransferAddress, + InitialTeb.StackBase, + 0); + + /* Convert the thread attributes */ + ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes, + lpThreadAttributes, + NULL); + + /* Create the Kernel Thread Object */ + Status = NtCreateThread(&hThread, + THREAD_ALL_ACCESS, + ObjectAttributes, + ProcessHandle, + ClientId, + &Context, + &InitialTeb, + TRUE); + + /* Success */ + return hThread; } - /* - * @implemented + * Converts ANSI to Unicode Environment */ -BOOL STDCALL CreateProcessA(LPCSTR lpApplicationName, - LPSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCSTR lpCurrentDirectory, - LPSTARTUPINFOA lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation) -/* - * FUNCTION: The CreateProcess function creates a new process and its - * primary thread. The new process executes the specified executable file - * ARGUMENTS: - * - * lpApplicationName = Pointer to name of executable module - * lpCommandLine = Pointer to command line string - * lpProcessAttributes = Process security attributes - * lpThreadAttributes = Thread security attributes - * bInheritHandles = Handle inheritance flag - * dwCreationFlags = Creation flags - * lpEnvironment = Pointer to new environment block - * lpCurrentDirectory = Pointer to current directory name - * lpStartupInfo = Pointer to startup info - * lpProcessInformation = Pointer to process information - */ +PVOID +STDCALL +BasepConvertUnicodeEnvironment(IN PVOID lpEnvironment) { - UNICODE_STRING wstrApplicationName; - UNICODE_STRING wstrCurrentDirectory; - UNICODE_STRING wstrCommandLine; - UNICODE_STRING wstrReserved; - UNICODE_STRING wstrDesktop; - UNICODE_STRING wstrTitle; - UNICODE_STRING wstrEnvVar; - ANSI_STRING strApplicationName; - ANSI_STRING strCurrentDirectory; - ANSI_STRING strCommandLine; - ANSI_STRING strReserved; - ANSI_STRING strDesktop; - ANSI_STRING strTitle; - BOOL bRetVal; - STARTUPINFOW wsiStartupInfo; + PCHAR pcScan; + SIZE_T EnvSize = 0; + ANSI_STRING AnsiEnv; + UNICODE_STRING UnicodeEnv; + NTSTATUS Status; + + DPRINT("BasepConvertUnicodeEnvironment\n"); - NTSTATUS (STDCALL *pTrue)(UNICODE_STRING *, - ANSI_STRING *, - BOOLEAN); + /* Scan the environment to calculate its Unicode size */ + AnsiEnv.Buffer = pcScan = lpEnvironment; + while (*pcScan) while (*pcScan++); - ULONG (STDCALL *pRtlMbStringToUnicodeSize)(ANSI_STRING *); - - DPRINT("dwCreationFlags %x, lpEnvironment %x, lpCurrentDirectory %x, " - "lpStartupInfo %x, lpProcessInformation %x\n", - dwCreationFlags, lpEnvironment, lpCurrentDirectory, - lpStartupInfo, lpProcessInformation); - - /* multibyte strings are ANSI */ - if(bIsFileApiAnsi) - { - pTrue = RtlAnsiStringToUnicodeString; - pRtlMbStringToUnicodeSize = RtlAnsiStringToUnicodeSize; - } - /* multibyte strings are OEM */ - else - { - pTrue = RtlOemStringToUnicodeString; - pRtlMbStringToUnicodeSize = RtlOemStringToUnicodeSize; - } - - /* invalid parameter */ - if(lpStartupInfo == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - /* convert the environment */ - if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)) - { - PCHAR pcScan; - SIZE_T nEnvLen = 0; - ANSI_STRING strEnvVar; - NTSTATUS Status; - - /* scan the environment to calculate its Unicode size */ - pcScan = lpEnvironment; - do - { - pcScan += strlen(pcScan) + 1; - } - while (*pcScan); - - nEnvLen = (ULONG_PTR)pcScan - (ULONG_PTR)lpEnvironment + 1; - - /* environment too large */ - if(nEnvLen > (SIZE_T)((USHORT)~0)) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - - strEnvVar.Buffer = lpEnvironment; - strEnvVar.MaximumLength = strEnvVar.Length = nEnvLen; - - Status = K32MbStrToWcStr(pTrue, &wstrEnvVar, &strEnvVar, TRUE); - - /* failure */ - if (!NT_SUCCESS(Status)) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - } - - - /* convert the strings */ - RtlInitAnsiString(&strCommandLine, lpCommandLine); - RtlInitAnsiString(&strApplicationName, (LPSTR)lpApplicationName); - RtlInitAnsiString(&strCurrentDirectory, (LPSTR)lpCurrentDirectory); - RtlInitAnsiString(&strReserved, (LPSTR)lpStartupInfo->lpReserved); - RtlInitAnsiString(&strDesktop, (LPSTR)lpStartupInfo->lpDesktop); - RtlInitAnsiString(&strTitle, (LPSTR)lpStartupInfo->lpTitle); - - K32MbStrToWcStr(pTrue, &wstrCommandLine, &strCommandLine, TRUE); - K32MbStrToWcStr(pTrue, &wstrApplicationName, &strApplicationName, TRUE); - K32MbStrToWcStr(pTrue, &wstrCurrentDirectory, &strCurrentDirectory, TRUE); - K32MbStrToWcStr(pTrue, &wstrReserved, &strReserved, TRUE); - K32MbStrToWcStr(pTrue, &wstrDesktop, &strDesktop, TRUE); - K32MbStrToWcStr(pTrue, &wstrTitle, &strTitle, TRUE); - - /* convert the startup information */ - memcpy(&wsiStartupInfo, lpStartupInfo, sizeof(wsiStartupInfo)); - - wsiStartupInfo.lpReserved = wstrReserved.Buffer; - wsiStartupInfo.lpDesktop = wstrDesktop.Buffer; - wsiStartupInfo.lpTitle = wstrTitle.Buffer; - - DPRINT("wstrApplicationName %wZ\n", &wstrApplicationName); - DPRINT("wstrCommandLine %wZ\n", &wstrCommandLine); - DPRINT("wstrCurrentDirectory %wZ\n", &wstrCurrentDirectory); - DPRINT("wstrReserved %wZ\n", &wstrReserved); - DPRINT("wstrDesktop %wZ\n", &wstrDesktop); - DPRINT("wstrTitle %wZ\n", &wstrTitle); - - DPRINT("wstrApplicationName.Buffer %p\n", wstrApplicationName.Buffer); - DPRINT("wstrCommandLine.Buffer %p\n", wstrCommandLine.Buffer); - DPRINT("wstrCurrentDirectory.Buffer %p\n", wstrCurrentDirectory.Buffer); - DPRINT("wstrReserved.Buffer %p\n", wstrReserved.Buffer); - DPRINT("wstrDesktop.Buffer %p\n", wstrDesktop.Buffer); - DPRINT("wstrTitle.Buffer %p\n", wstrTitle.Buffer); - - DPRINT("sizeof(STARTUPINFOA) %lu\n", sizeof(STARTUPINFOA)); - DPRINT("sizeof(STARTUPINFOW) %lu\n", sizeof(STARTUPINFOW)); - - /* call the Unicode function */ - bRetVal = CreateProcessW(wstrApplicationName.Buffer, - wstrCommandLine.Buffer, - lpProcessAttributes, - lpThreadAttributes, - bInheritHandles, - dwCreationFlags, - !lpEnvironment || (dwCreationFlags & CREATE_UNICODE_ENVIRONMENT) ? lpEnvironment : wstrEnvVar.Buffer, - wstrCurrentDirectory.Buffer, - &wsiStartupInfo, - lpProcessInformation); - - RtlFreeUnicodeString(&wstrApplicationName); - RtlFreeUnicodeString(&wstrCommandLine); - RtlFreeUnicodeString(&wstrCurrentDirectory); - RtlFreeUnicodeString(&wstrReserved); - RtlFreeUnicodeString(&wstrDesktop); - RtlFreeUnicodeString(&wstrTitle); - - if (lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)) - { - RtlFreeUnicodeString(&wstrEnvVar); - } - - return bRetVal; + /* Create our ANSI String */ + AnsiEnv.Length = (ULONG_PTR)pcScan - (ULONG_PTR)lpEnvironment + 1; + AnsiEnv.MaximumLength = AnsiEnv.Length + 1; + + /* Allocate memory for the Unicode Environment */ + UnicodeEnv.Buffer = NULL; + EnvSize = AnsiEnv.MaximumLength * sizeof(WCHAR); + Status = NtAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&UnicodeEnv.Buffer, + 0, + &EnvSize, + MEM_COMMIT, + PAGE_READWRITE); + /* Failure */ + if (!NT_SUCCESS(Status)) + { + SetLastError(Status); + return NULL; + } + + /* Use the allocated size */ + UnicodeEnv.MaximumLength = EnvSize; + + /* Convert */ + RtlAnsiStringToUnicodeString(&UnicodeEnv, &AnsiEnv, FALSE); + return UnicodeEnv.Buffer; } - -_SEH_FILTER(BaseExceptionFilter) +/* + * Converts a Win32 Priority Class to NT + */ +ULONG +STDCALL +BasepConvertPriorityClass(IN ULONG dwCreationFlags) { - EXCEPTION_POINTERS * ExceptionInfo = _SEH_GetExceptionPointers(); - LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER; - - if (GlobalTopLevelExceptionFilter != NULL) - { - _SEH_TRY - { - ExceptionDisposition = GlobalTopLevelExceptionFilter(ExceptionInfo); - } - _SEH_HANDLE - { - ExceptionDisposition = UnhandledExceptionFilter(ExceptionInfo); - } - _SEH_END; - } - - return ExceptionDisposition; + ULONG ReturnClass; + + if(dwCreationFlags & IDLE_PRIORITY_CLASS) + { + ReturnClass = PROCESS_PRIORITY_CLASS_IDLE; + } + else if(dwCreationFlags & BELOW_NORMAL_PRIORITY_CLASS) + { + ReturnClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL; + } + else if(dwCreationFlags & NORMAL_PRIORITY_CLASS) + { + ReturnClass = PROCESS_PRIORITY_CLASS_NORMAL; + } + else if(dwCreationFlags & ABOVE_NORMAL_PRIORITY_CLASS) + { + ReturnClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL; + } + else if(dwCreationFlags & HIGH_PRIORITY_CLASS) + { + ReturnClass = PROCESS_PRIORITY_CLASS_HIGH; + } + else if(dwCreationFlags & REALTIME_PRIORITY_CLASS) + { + /* Check for Privilege First */ + if (BasepCheckRealTimePrivilege()) + { + ReturnClass = PROCESS_PRIORITY_CLASS_REALTIME; + } + else + { + ReturnClass = PROCESS_PRIORITY_CLASS_HIGH; + } + } + else + { + ReturnClass = 0 /* FIXME */; + } + + return ReturnClass; } - -VOID STDCALL -BaseProcessStart(LPTHREAD_START_ROUTINE lpStartAddress, - DWORD lpParameter) +/* + * Duplicates a standard handle and writes it where requested. + */ +VOID +STDCALL +BasepDuplicateAndWriteHandle(IN HANDLE ProcessHandle, + IN HANDLE StandardHandle, + IN PHANDLE Address) { - UINT uExitCode = 0; - - DPRINT("BaseProcessStart(..) - setting up exception frame.\n"); - - _SEH_TRY - { - uExitCode = (lpStartAddress)((PVOID)lpParameter); - } - _SEH_EXCEPT(BaseExceptionFilter) - { - uExitCode = _SEH_GetExceptionCode(); - } - _SEH_END; - - ExitProcess(uExitCode); + NTSTATUS Status; + HANDLE DuplicatedHandle; + ULONG Dummy; + + DPRINT("BasepDuplicateAndWriteHandle. hProcess: %lx, Handle: %lx," + "Address: %p\n", ProcessHandle, StandardHandle, Address); + + /* Don't touch Console Handles */ + if (IsConsoleHandle(StandardHandle)) return; + + /* Duplicate the handle */ + Status = NtDuplicateObject(NtCurrentProcess(), + StandardHandle, + ProcessHandle, + &DuplicatedHandle, + DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES, + 0, + 0); + if (NT_SUCCESS(Status)) + { + /* Write it */ + NtWriteVirtualMemory(ProcessHandle, + Address, + &DuplicatedHandle, + sizeof(HANDLE), + &Dummy); + } } - -HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - PSECTION_IMAGE_INFORMATION Sii, - LPTHREAD_START_ROUTINE lpStartAddress, - DWORD dwCreationFlags, - LPDWORD lpThreadId) +LPWSTR +STDCALL +BasepGetDllPath(LPWSTR FullPath, + PVOID Environment) { - OBJECT_ATTRIBUTES oaThreadAttribs; - CLIENT_ID cidClientId; - PVOID pTrueStartAddress; - NTSTATUS nErrCode; - HANDLE hThread; - - /* convert the thread attributes */ - RtlRosR32AttribsToNativeAttribs(&oaThreadAttribs, lpThreadAttributes); - - /* native image */ - if(Sii->SubsystemType != IMAGE_SUBSYSTEM_NATIVE) - { - pTrueStartAddress = (PVOID)BaseProcessStart; - } - /* Win32 image */ - else - { - pTrueStartAddress = (PVOID)RtlBaseProcessStartRoutine; - } - - DPRINT("RtlRosCreateUserThreadVa\n" - "(\n" - " ProcessHandle %p,\n" - " ObjectAttributes %p,\n" - " CreateSuspended %d,\n" - " StackZeroBits %d,\n" - " StackReserve %lu,\n" - " StackCommit %lu,\n" - " StartAddress %p,\n" - " ThreadHandle %p,\n" - " ClientId %p,\n" - " ParameterCount %u,\n" - " Parameters[0] %p,\n" - " Parameters[1] %p\n" - ")\n", - ProcessHandle, - &oaThreadAttribs, - dwCreationFlags & CREATE_SUSPENDED, - 0, - Sii->MaximumStackSize, - Sii->CommittedStackSize, - pTrueStartAddress, - &hThread, - &cidClientId, - 2, - lpStartAddress, - PEB_BASE); - - /* create the first thread */ - nErrCode = RtlRosCreateUserThreadVa(ProcessHandle, - &oaThreadAttribs, - dwCreationFlags & CREATE_SUSPENDED, - 0, - &(Sii->MaximumStackSize), - &(Sii->CommittedStackSize), - pTrueStartAddress, - &hThread, - &cidClientId, - 2, - (ULONG_PTR)lpStartAddress, - (ULONG_PTR)PEB_BASE); - /* failure */ - if(!NT_SUCCESS(nErrCode)) - { - SetLastErrorByStatus(nErrCode); - return NULL; - } - - DPRINT("StackReserve %p\n" - "StackCommit %p\n" - "ThreadHandle %p\n" - "ClientId.UniqueThread %p\n", - Sii->MaximumStackSize, - Sii->CommittedStackSize, - hThread, - cidClientId.UniqueThread); - - /* success */ - if(lpThreadId) *lpThreadId = (DWORD)cidClientId.UniqueThread; - return hThread; + /* FIXME: Not yet implemented */ + return NULL; } -HANDLE KlMapFile(LPCWSTR lpApplicationName) +VOID +STDCALL +BasepCopyHandles(IN PRTL_USER_PROCESS_PARAMETERS Params, + IN PRTL_USER_PROCESS_PARAMETERS PebParams, + IN BOOL InheritHandles) { - HANDLE hFile; - IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING ApplicationNameString; - OBJECT_ATTRIBUTES ObjectAttributes; - PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; - NTSTATUS Status; - HANDLE hSection; - - hFile = NULL; - - /* - * Find the application name - */ - - if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpApplicationName, - &ApplicationNameString, - NULL, - NULL)) - return NULL; - - DPRINT("ApplicationName %S\n",ApplicationNameString.Buffer); - - InitializeObjectAttributes(&ObjectAttributes, - &ApplicationNameString, - OBJ_CASE_INSENSITIVE, - NULL, - SecurityDescriptor); - - /* - * Try to open the executable - */ - - Status = NtOpenFile(&hFile, - SYNCHRONIZE|FILE_EXECUTE|FILE_READ_DATA, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_DELETE|FILE_SHARE_READ, - FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE); - - RtlFreeUnicodeString (&ApplicationNameString); - - if (!NT_SUCCESS(Status)) - { - DPRINT("Failed to open file\n"); - SetLastErrorByStatus (Status); - return(NULL); - } - - Status = NtCreateSection(&hSection, - SECTION_ALL_ACCESS, - NULL, - NULL, - PAGE_EXECUTE, - SEC_IMAGE, - hFile); - NtClose(hFile); - - if (!NT_SUCCESS(Status)) - { - DPRINT("Failed to create section\n"); - SetLastErrorByStatus (Status); - return(NULL); - } - - return(hSection); + /* Copy the handle if we are inheriting or if it's a console handle */ + if (InheritHandles || IsConsoleHandle(PebParams->StandardInput)) + { + Params->StandardInput = PebParams->StandardInput; + } + if (InheritHandles || IsConsoleHandle(PebParams->StandardOutput)) + { + Params->StandardOutput = PebParams->StandardOutput; + } + if (InheritHandles || IsConsoleHandle(PebParams->StandardError)) + { + Params->StandardError = PebParams->StandardError; + } } -static NTSTATUS KlInitPeb(HANDLE ProcessHandle, - PRTL_USER_PROCESS_PARAMETERS Ppb, - PVOID * ImageBaseAddress, - ULONG ImageSubSystem) +NTSTATUS +STDCALL +BasepInitializeEnvironment(HANDLE ProcessHandle, + PPEB Peb, + LPWSTR ApplicationPathName, + LPWSTR lpCurrentDirectory, + LPWSTR lpCommandLine, + LPVOID Environment, + LPSTARTUPINFOW StartupInfo, + DWORD CreationFlags, + BOOL InheritHandles, + HANDLE hInput, + HANDLE hOutput) { - NTSTATUS Status; - PVOID PpbBase; - ULONG PpbSize; - ULONG BytesWritten; - ULONG Offset; - PVOID ParentEnv = NULL; - PVOID EnvPtr = NULL; - PWCHAR ptr; - ULONG EnvSize = 0, EnvSize1 = 0; + WCHAR FullPath[MAX_PATH]; + LPWSTR Remaining; + LPWSTR DllPathString; + PRTL_USER_PROCESS_PARAMETERS ProcessParameters; + PRTL_USER_PROCESS_PARAMETERS RemoteParameters = NULL; + UNICODE_STRING DllPath, ImageName, CommandLine, CurrentDirectory; + UINT RetVal; + NTSTATUS Status; + PWCHAR ScanChar; + ULONG EnviroSize; + ULONG Size; + UNICODE_STRING Desktop, Shell, Runtime, Title; + PPEB OurPeb = NtCurrentPeb(); + + DPRINT("BasepInitializeEnvironment\n"); + + /* Get the full path name */ + RetVal = GetFullPathNameW(ApplicationPathName, + MAX_PATH, + FullPath, + &Remaining); + DPRINT("ApplicationPathName: %S, FullPath: %S\n", ApplicationPathName, + FullPath); + + /* Get the DLL Path */ + DllPathString = BasepGetDllPath(FullPath, Environment); + + /* Initialize Strings */ + RtlInitUnicodeString(&DllPath, DllPathString); + RtlInitUnicodeString(&ImageName, FullPath); + RtlInitUnicodeString(&CommandLine, lpCommandLine); + RtlInitUnicodeString(&CurrentDirectory, lpCurrentDirectory); + + /* Initialize more Strings from the Startup Info */ + if (StartupInfo->lpDesktop) + { + RtlInitUnicodeString(&Desktop, StartupInfo->lpDesktop); + } + else + { + RtlInitUnicodeString(&Desktop, L""); + } + if (StartupInfo->lpReserved) + { + RtlInitUnicodeString(&Shell, StartupInfo->lpReserved); + } + else + { + RtlInitUnicodeString(&Shell, L""); + } + if (StartupInfo->lpTitle) + { + RtlInitUnicodeString(&Title, StartupInfo->lpTitle); + } + else + { + RtlInitUnicodeString(&Title, L""); + } + + /* This one is special because the length can differ */ + Runtime.Buffer = (LPWSTR)StartupInfo->lpReserved2; + Runtime.MaximumLength = Runtime.Length = StartupInfo->cbReserved2; + + /* Create the Parameter Block */ + DPRINT("Creating Process Parameters: %wZ %wZ %wZ %wZ %wZ %wZ %wZ\n", + &ImageName, &DllPath, &CommandLine, &Desktop, &Title, &Shell, + &Runtime); + Status = RtlCreateProcessParameters(&ProcessParameters, + &ImageName, + &DllPath, + lpCurrentDirectory ? + &CurrentDirectory : NULL, + &CommandLine, + Environment, + &Title, + &Desktop, + &Shell, + &Runtime); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create process parameters!\n"); + return Status; + } + + /* Check if we got an environment. If not, use ours */ + if (Environment) + { + /* Save pointer and start lookup */ + Environment = ScanChar = ProcessParameters->Environment; + } + else + { + /* Save pointer and start lookup */ + Environment = ScanChar = OurPeb->ProcessParameters->Environment; + } + + /* Find the environment size */ + if (ScanChar) + { + while (*ScanChar) while (*ScanChar++); + + /* Calculate the size of the block */ + EnviroSize = (ULONG)((ULONG_PTR)ScanChar - (ULONG_PTR)Environment); + DPRINT("EnvironmentSize %ld\n", EnviroSize); - /* create the Environment */ - if (Ppb->Environment != NULL) - { - ParentEnv = Ppb->Environment; - ptr = ParentEnv; - while (*ptr) - { - while(*ptr++); - } - ptr++; - EnvSize = (ULONG)((ULONG_PTR)ptr - (ULONG_PTR)ParentEnv); - } - else if (NtCurrentPeb()->ProcessParameters->Environment != NULL) - { - MEMORY_BASIC_INFORMATION MemInfo; - ParentEnv = NtCurrentPeb()->ProcessParameters->Environment; + /* Allocate and Initialize new Environment Block */ + Size = EnviroSize; + ProcessParameters->Environment = NULL; + Status = ZwAllocateVirtualMemory(ProcessHandle, + (PVOID*)&ProcessParameters->Environment, + 0, + &Size, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to allocate Environment Block\n"); + return(Status); + } + + /* Write the Environment Block */ + ZwWriteVirtualMemory(ProcessHandle, + ProcessParameters->Environment, + Environment, + EnviroSize, + NULL); + } + + /* Write new parameters */ + ProcessParameters->StartingX = StartupInfo->dwX; + ProcessParameters->StartingY = StartupInfo->dwY; + ProcessParameters->CountX = StartupInfo->dwXSize; + ProcessParameters->CountY = StartupInfo->dwYSize; + ProcessParameters->CountCharsX = StartupInfo->dwXCountChars; + ProcessParameters->CountCharsY = StartupInfo->dwYCountChars; + ProcessParameters->FillAttribute = StartupInfo->dwFillAttribute; + ProcessParameters->WindowFlags = StartupInfo->dwFlags; + ProcessParameters->ShowWindowFlags = StartupInfo->wShowWindow; + + /* Write the handles only if we have to */ + if (StartupInfo->dwFlags & STARTF_USESTDHANDLES) + { + ProcessParameters->StandardInput = StartupInfo->hStdInput; + ProcessParameters->StandardOutput = StartupInfo->hStdOutput; + ProcessParameters->StandardError = StartupInfo->hStdError; + } + + /* Use Special Flags for ConDllInitialize in Kernel32 */ + if (CreationFlags & DETACHED_PROCESS) + { + ProcessParameters->ConsoleHandle = HANDLE_DETACHED_PROCESS; + } + else if (CreationFlags & CREATE_NO_WINDOW) + { + ProcessParameters->ConsoleHandle = HANDLE_CREATE_NO_WINDOW; + } + else if (CreationFlags & CREATE_NEW_CONSOLE) + { + ProcessParameters->ConsoleHandle = HANDLE_CREATE_NEW_CONSOLE; + } + else + { + /* Inherit our Console Handle */ + ProcessParameters->ConsoleHandle = OurPeb->ProcessParameters->ConsoleHandle; + + /* Is the shell trampling on our Handles? */ + if (!(StartupInfo->dwFlags & + (STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE))) + { + /* Use handles from PEB, if inheriting or they are console */ + BasepCopyHandles(ProcessParameters, [truncated at 1000 lines; 3251 more skipped]
19 years, 6 months
1
0
0
0
← Newer
1
...
17
18
19
20
21
22
23
...
57
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
Results per page:
10
25
50
100
200