ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2013
----- 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
13 participants
199 discussions
Start a n
N
ew thread
[cgutman] 59413: [TCPIP] - Add missing reference for lwIP on listeners
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Jul 3 09:04:52 2013 New Revision: 59413 URL:
http://svn.reactos.org/svn/reactos?rev=59413&view=rev
Log: [TCPIP] - Add missing reference for lwIP on listeners Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
============================================================================== --- trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Wed Jul 3 09:04:52 2013 @@ -618,9 +618,11 @@ Connection->AddressFile->Protocol ); } - if( NT_SUCCESS(Status) ) + if( NT_SUCCESS(Status) ) { + ReferenceObject(Connection->AddressFile->Listener); Status = TCPListen( Connection->AddressFile->Listener, 1024 ); /* BACKLOG */ + } } if( NT_SUCCESS(Status) ) {
11 years, 5 months
1
0
0
0
[cgutman] 59412: [TCPIP] - Add asserts to ReferenceObject and DereferenceObject to catch reference misuse
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Jul 3 08:52:17 2013 New Revision: 59412 URL:
http://svn.reactos.org/svn/reactos?rev=59412&view=rev
Log: [TCPIP] - Add asserts to ReferenceObject and DereferenceObject to catch reference misuse Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
============================================================================== --- trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] Wed Jul 3 08:52:17 2013 @@ -13,6 +13,7 @@ */ #define ReferenceObject(Object) \ { \ + ASSERT((Object)->RefCount); \ InterlockedIncrement(&((Object)->RefCount)); \ } @@ -22,6 +23,7 @@ */ #define DereferenceObject(Object) \ { \ + ASSERT((Object)->RefCount); \ if (InterlockedDecrement(&((Object)->RefCount)) == 0) \ (((Object)->Free)(Object)); \ }
11 years, 5 months
1
0
0
0
[hbelusca] 59411: [CMD] Remove extra \r put by hand in some console output functions, so that we use there only \n. But modify the ConWrite function so that, if we redirect output to something else...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Jul 2 23:07:15 2013 New Revision: 59411 URL:
http://svn.reactos.org/svn/reactos?rev=59411&view=rev
Log: [CMD] Remove extra \r put by hand in some console output functions, so that we use there only \n. But modify the ConWrite function so that, if we redirect output to something else than a console (e.g. redirect to a file or to a serial console via ... > AUX), newline characters \n get converted into \r\n automatically. What you get, for instance, is:
https://imageshack.com/a/img853/5834/l34.png
Modified: trunk/reactos/base/shell/cmd/assoc.c trunk/reactos/base/shell/cmd/attrib.c trunk/reactos/base/shell/cmd/choice.c trunk/reactos/base/shell/cmd/cmd.c trunk/reactos/base/shell/cmd/cmdinput.c trunk/reactos/base/shell/cmd/cmdtable.c trunk/reactos/base/shell/cmd/console.c trunk/reactos/base/shell/cmd/echo.c trunk/reactos/base/shell/cmd/error.c trunk/reactos/base/shell/cmd/filecomp.c trunk/reactos/base/shell/cmd/free.c trunk/reactos/base/shell/cmd/misc.c trunk/reactos/base/shell/cmd/path.c trunk/reactos/base/shell/cmd/set.c trunk/reactos/base/shell/cmd/ver.c Modified: trunk/reactos/base/shell/cmd/assoc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/assoc.c?rev…
============================================================================== --- trunk/reactos/base/shell/cmd/assoc.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/assoc.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -80,7 +80,7 @@ if (fileTypeLength != 0) /* if there is a default key, display relevant information */ { - ConOutPrintf(_T("%s=%s\r\n"), extension, fileType); + ConOutPrintf(_T("%s=%s\n"), extension, fileType); } if (fileTypeLength) Modified: trunk/reactos/base/shell/cmd/attrib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/attrib.c?re…
============================================================================== --- trunk/reactos/base/shell/cmd/attrib.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/attrib.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -96,15 +96,15 @@ _tcscpy (pszFileName, findData.cFileName); - ConOutPrintf (_T("%c %c%c%c %s\n"), - (findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '), - (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '), - (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '), - (findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '), - szFullName); - } - while (FindNextFile (hFind, &findData)); - FindClose (hFind); + ConOutPrintf(_T("%c %c%c%c %s\n"), + (findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '), + (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '), + (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '), + (findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '), + szFullName); + } + while (FindNextFile(hFind, &findData)); + FindClose(hFind); } Modified: trunk/reactos/base/shell/cmd/choice.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/choice.c?re…
============================================================================== --- trunk/reactos/base/shell/cmd/choice.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/choice.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -296,7 +296,7 @@ GetTickCount () - clk); val = IsKeyInString (lpOptions, cDefault, bCaseSensitive); - ConOutPrintf (_T("%c\n"), lpOptions[val]); + ConOutPrintf(_T("%c\n"), lpOptions[val]); nErrorLevel = val + 1; Modified: trunk/reactos/base/shell/cmd/cmd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=5…
============================================================================== --- trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -1378,7 +1378,7 @@ if (bEcho) { if (!bIgnoreEcho) - ConOutChar('\n'); + ConOutChar(_T('\n')); PrintPrompt(); } } @@ -1391,7 +1391,7 @@ if (CheckCtrlBreak(BREAK_INPUT)) { - ConOutPuts(_T("\n")); + ConOutChar(_T('\n')); return FALSE; } ip = readline; Modified: trunk/reactos/base/shell/cmd/cmdinput.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmdinput.c?…
============================================================================== --- trunk/reactos/base/shell/cmd/cmdinput.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmdinput.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -438,7 +438,7 @@ #endif str[charcount++] = _T('\n'); str[charcount] = _T('\0'); - ConOutChar (_T('\n')); + ConOutChar(_T('\n')); bReturn = TRUE; break; Modified: trunk/reactos/base/shell/cmd/cmdtable.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmdtable.c?…
============================================================================== --- trunk/reactos/base/shell/cmd/cmdtable.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmdtable.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -271,7 +271,7 @@ } if (y != 0) - ConOutChar('\n'); + ConOutChar(_T('\n')); } VOID PrintCommandListDetail(VOID) Modified: trunk/reactos/base/shell/cmd/console.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/console.c?r…
============================================================================== --- trunk/reactos/base/shell/cmd/console.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/console.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -138,6 +138,7 @@ { DWORD dwWritten; HANDLE hOutput = GetStdHandle(nStdHandle); + PVOID p; /* Check whether we are writing to a console and if so, write to it */ if (IsConsoleHandle(hOutput)) @@ -157,10 +158,35 @@ error_out_of_memory(); return; } - len = MultiByteToWideChar(OutputCodePage, 0, str, len, buffer, len); + len = (DWORD)MultiByteToWideChar(OutputCodePage, 0, str, (INT)len, buffer, (INT)len); str = (PVOID)buffer; #endif - WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); + /* + * Find any newline character in the buffer, + * send the part BEFORE the newline, then send + * a carriage-return + newline, and then send + * the remaining part of the buffer. + * + * This fixes output in files and serial console. + */ + while (str && *(PWCHAR)str && len > 0) + { + p = wcspbrk((PWCHAR)str, L"\r\n"); + if (p) + { + len -= ((PWCHAR)p - (PWCHAR)str) + 1; + WriteFile(hOutput, str, ((PWCHAR)p - (PWCHAR)str) * sizeof(WCHAR), &dwWritten, NULL); + WriteFile(hOutput, L"\r\n", 2 * sizeof(WCHAR), &dwWritten, NULL); + str = (PVOID)((PWCHAR)p + 1); + } + else + { + WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); + break; + } + } + + // WriteFile(hOutput, str, len * sizeof(WCHAR), &dwWritten, NULL); #ifndef _UNICODE cmd_free(buffer); #endif @@ -177,21 +203,46 @@ len = WideCharToMultiByte(OutputCodePage, 0, str, len, buffer, len * MB_LEN_MAX, NULL, NULL); str = (PVOID)buffer; #endif - WriteFile(hOutput, str, len, &dwWritten, NULL); + /* + * Find any newline character in the buffer, + * send the part BEFORE the newline, then send + * a carriage-return + newline, and then send + * the remaining part of the buffer. + * + * This fixes output in files and serial console. + */ + while (str && *(PCHAR)str && len > 0) + { + p = strpbrk((PCHAR)str, "\r\n"); + if (p) + { + len -= ((PCHAR)p - (PCHAR)str) + 1; + WriteFile(hOutput, str, ((PCHAR)p - (PCHAR)str), &dwWritten, NULL); + WriteFile(hOutput, "\r\n", 2, &dwWritten, NULL); + str = (PVOID)((PCHAR)p + 1); + } + else + { + WriteFile(hOutput, str, len, &dwWritten, NULL); + break; + } + } + + // WriteFile(hOutput, str, len, &dwWritten, NULL); #ifdef _UNICODE cmd_free(buffer); #endif } } -VOID ConOutChar (TCHAR c) +VOID ConOutChar(TCHAR c) { ConWrite(&c, 1, STD_OUTPUT_HANDLE); } VOID ConPuts(LPTSTR szText, DWORD nStdHandle) { - ConWrite(szText, _tcslen(szText), nStdHandle); + ConWrite(szText, (DWORD)_tcslen(szText), nStdHandle); } VOID ConOutResPaging(BOOL NewPage, UINT resID) @@ -201,15 +252,14 @@ ConOutPrintfPaging(NewPage, szMsg); } -VOID ConOutResPuts (UINT resID) +VOID ConOutResPuts(UINT resID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, resID, szMsg, RC_STRING_MAX_SIZE); - ConPuts(szMsg, STD_OUTPUT_HANDLE); } -VOID ConOutPuts (LPTSTR szText) +VOID ConOutPuts(LPTSTR szText) { ConPuts(szText, STD_OUTPUT_HANDLE); } @@ -218,7 +268,10 @@ VOID ConPrintf(LPTSTR szFormat, va_list arg_ptr, DWORD nStdHandle) { TCHAR szOut[OUTPUT_BUFFER_SIZE]; - ConWrite(szOut, _vstprintf(szOut, szFormat, arg_ptr), nStdHandle); + DWORD len; + + len = (DWORD)_vstprintf(szOut, szFormat, arg_ptr); + ConWrite(szOut, len, nStdHandle); } INT ConPrintfPaging(BOOL NewPage, LPTSTR szFormat, va_list arg_ptr, DWORD nStdHandle) @@ -247,29 +300,29 @@ if (szFormat == NULL) return 0; - //get the size of the visual screen that can be printed too + /* Get the size of the visual screen that can be printed too */ if (!IsConsoleHandle(hOutput) || !GetConsoleScreenBufferInfo(hOutput, &csbi)) { - // we assuming its a file handle + /* We assume it's a file handle */ ConPrintf(szFormat, arg_ptr, nStdHandle); return 0; } - //subtract 2 to account for "press any key..." and for the blank line at the end of PagePrompt() + /* Subtract 2 to account for "press any key..." and for the blank line at the end of PagePrompt() */ ScreenLines = (csbi.srWindow.Bottom - csbi.srWindow.Top) - 4; CharSL = csbi.dwCursorPosition.X; - //make sure they didnt make the screen to small - if (ScreenLines<4) + /* Make sure they didn't make the screen to small */ + if (ScreenLines < 4) { ConPrintf(szFormat, arg_ptr, nStdHandle); return 0; } - len = _vstprintf (szOut, szFormat, arg_ptr); + len = _vstprintf(szOut, szFormat, arg_ptr); while (i < len) { - // Search until the end of a line is reached + /* Search until the end of a line is reached */ if (szOut[i++] != _T('\n') && ++CharSL < csbi.dwSize.X) continue; @@ -285,7 +338,7 @@ { return 1; } - //reset the number of lines being printed + /* Reset the number of lines being printed */ LineCount = 0; } } @@ -295,43 +348,14 @@ return 0; } -VOID ConErrFormatMessage (DWORD MessageId, ...) +VOID ConErrFormatMessage(DWORD MessageId, ...) { TCHAR szMsg[RC_STRING_MAX_SIZE]; DWORD ret; LPTSTR text; va_list arg_ptr; - va_start (arg_ptr, MessageId); - ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - MessageId, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &text, - 0, - &arg_ptr); - - va_end (arg_ptr); - if (ret > 0) - { - ConErrPuts (text); - LocalFree(text); - } - else - { - LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf(szMsg); - } -} - -VOID ConOutFormatMessage (DWORD MessageId, ...) -{ - TCHAR szMsg[RC_STRING_MAX_SIZE]; - DWORD ret; - LPTSTR text; - va_list arg_ptr; - - va_start (arg_ptr, MessageId); + va_start(arg_ptr, MessageId); ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, MessageId, @@ -340,10 +364,10 @@ 0, &arg_ptr); - va_end (arg_ptr); + va_end(arg_ptr); if (ret > 0) { - ConErrPuts (text); + ConErrPuts(text); LocalFree(text); } else @@ -353,118 +377,152 @@ } } -VOID ConOutResPrintf (UINT resID, ...) -{ - TCHAR szMsg[RC_STRING_MAX_SIZE]; - va_list arg_ptr; - - va_start (arg_ptr, resID); +VOID ConOutFormatMessage(DWORD MessageId, ...) +{ + TCHAR szMsg[RC_STRING_MAX_SIZE]; + DWORD ret; + LPTSTR text; + va_list arg_ptr; + + va_start(arg_ptr, MessageId); + ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + MessageId, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &text, + 0, + &arg_ptr); + + va_end(arg_ptr); + if (ret > 0) + { + ConErrPuts(text); + LocalFree(text); + } + else + { + LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + } +} + +VOID ConOutResPrintf(UINT resID, ...) +{ + TCHAR szMsg[RC_STRING_MAX_SIZE]; + va_list arg_ptr; + + va_start(arg_ptr, resID); LoadString(CMD_ModuleHandle, resID, szMsg, RC_STRING_MAX_SIZE); ConPrintf(szMsg, arg_ptr, STD_OUTPUT_HANDLE); - va_end (arg_ptr); -} - -VOID ConOutPrintf (LPTSTR szFormat, ...) -{ - va_list arg_ptr; - - va_start (arg_ptr, szFormat); + va_end(arg_ptr); +} + +VOID ConOutPrintf(LPTSTR szFormat, ...) +{ + va_list arg_ptr; + + va_start(arg_ptr, szFormat); ConPrintf(szFormat, arg_ptr, STD_OUTPUT_HANDLE); - va_end (arg_ptr); -} - -INT ConOutPrintfPaging (BOOL NewPage, LPTSTR szFormat, ...) + va_end(arg_ptr); +} + +INT ConOutPrintfPaging(BOOL NewPage, LPTSTR szFormat, ...) { INT iReturn; va_list arg_ptr; - va_start (arg_ptr, szFormat); + va_start(arg_ptr, szFormat); iReturn = ConPrintfPaging(NewPage, szFormat, arg_ptr, STD_OUTPUT_HANDLE); - va_end (arg_ptr); + va_end(arg_ptr); return iReturn; } -VOID ConErrChar (TCHAR c) +VOID ConErrChar(TCHAR c) { ConWrite(&c, 1, STD_ERROR_HANDLE); } -VOID ConErrResPuts (UINT resID) +VOID ConErrResPuts(UINT resID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, resID, szMsg, RC_STRING_MAX_SIZE); ConPuts(szMsg, STD_ERROR_HANDLE); } -VOID ConErrPuts (LPTSTR szText) +VOID ConErrPuts(LPTSTR szText) { ConPuts(szText, STD_ERROR_HANDLE); } -VOID ConErrResPrintf (UINT resID, ...) -{ - TCHAR szMsg[RC_STRING_MAX_SIZE]; - va_list arg_ptr; - - va_start (arg_ptr, resID); +VOID ConErrResPrintf(UINT resID, ...) +{ + TCHAR szMsg[RC_STRING_MAX_SIZE]; + va_list arg_ptr; + + va_start(arg_ptr, resID); LoadString(CMD_ModuleHandle, resID, szMsg, RC_STRING_MAX_SIZE); ConPrintf(szMsg, arg_ptr, STD_ERROR_HANDLE); - va_end (arg_ptr); -} - -VOID ConErrPrintf (LPTSTR szFormat, ...) -{ - va_list arg_ptr; - - va_start (arg_ptr, szFormat); + va_end(arg_ptr); +} + +VOID ConErrPrintf(LPTSTR szFormat, ...) +{ + va_list arg_ptr; + + va_start(arg_ptr, szFormat); ConPrintf(szFormat, arg_ptr, STD_ERROR_HANDLE); - va_end (arg_ptr); -} - -VOID SetCursorXY (SHORT x, SHORT y) + va_end(arg_ptr); +} + + +VOID SetCursorXY(SHORT x, SHORT y) { COORD coPos; coPos.X = x; coPos.Y = y; - SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), coPos); -} - - -VOID GetCursorXY (PSHORT x, PSHORT y) + SetConsoleCursorPosition(GetStdHandle (STD_OUTPUT_HANDLE), coPos); +} + +VOID GetCursorXY(PSHORT x, PSHORT y) { CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); *x = csbi.dwCursorPosition.X; *y = csbi.dwCursorPosition.Y; } - -SHORT GetCursorX (VOID) +SHORT GetCursorX(VOID) { CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); return csbi.dwCursorPosition.X; } - -SHORT GetCursorY (VOID) +SHORT GetCursorY(VOID) { CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); return csbi.dwCursorPosition.Y; } - -VOID GetScreenSize (PSHORT maxx, PSHORT maxy) +VOID SetCursorType(BOOL bInsert, BOOL bVisible) +{ + CONSOLE_CURSOR_INFO cci; + + cci.dwSize = bInsert ? 10 : 99; + cci.bVisible = bVisible; + + SetConsoleCursorInfo(GetStdHandle (STD_OUTPUT_HANDLE), &cci); +} + +VOID GetScreenSize(PSHORT maxx, PSHORT maxy) { CONSOLE_SCREEN_BUFFER_INFO csbi; @@ -474,21 +532,8 @@ csbi.dwSize.Y = 25; } - if (maxx) - *maxx = csbi.dwSize.X; - if (maxy) - *maxy = csbi.dwSize.Y; -} - - -VOID SetCursorType (BOOL bInsert, BOOL bVisible) -{ - CONSOLE_CURSOR_INFO cci; - - cci.dwSize = bInsert ? 10 : 99; - cci.bVisible = bVisible; - - SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); + if (maxx) *maxx = csbi.dwSize.X; + if (maxy) *maxy = csbi.dwSize.Y; } /* EOF */ Modified: trunk/reactos/base/shell/cmd/echo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/echo.c?rev=…
============================================================================== --- trunk/reactos/base/shell/cmd/echo.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/echo.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -83,7 +83,7 @@ { /* skip the first character */ ConOutPuts(param + 1); - ConOutPuts(_T("\r\n")); + ConOutChar(_T('\n')); } return 0; } Modified: trunk/reactos/base/shell/cmd/error.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/error.c?rev…
============================================================================== --- trunk/reactos/base/shell/cmd/error.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/error.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -46,7 +46,7 @@ NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&szError, 0, NULL)) { - ConErrPrintf (_T("%s %s\n"), szError, szMessage); + ConErrPrintf(_T("%s %s\n"), szError, szMessage); if (szError) LocalFree (szError); return; @@ -54,9 +54,9 @@ /* Fall back just in case the error is not defined */ if (szFormat) - ConErrPrintf (_T("%s -- %s\n"), szMsg, szMessage); + ConErrPrintf(_T("%s -- %s\n"), szMsg, szMessage); else - ConErrPrintf (_T("%s\n"), szMsg); + ConErrPrintf(_T("%s\n"), szMsg); } VOID error_parameter_format(TCHAR ch) Modified: trunk/reactos/base/shell/cmd/filecomp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/filecomp.c?…
============================================================================== --- trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -302,7 +302,7 @@ longestfname += 3; /* find anything */ - ConOutChar (_T('\n')); + ConOutChar(_T('\n')); do { /* ignore . and .. */ @@ -323,7 +323,7 @@ /* print the new line only if we aren't on the * last column, in this case it wraps anyway */ if (count * longestfname != (UINT)screenwidth) - ConOutPrintf (_T("\n")); + ConOutChar(_T('\n')); count = 0; } } @@ -332,7 +332,7 @@ FindClose (hFile); if (count) - ConOutChar (_T('\n')); + ConOutChar(_T('\n')); } else { Modified: trunk/reactos/base/shell/cmd/free.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/free.c?rev=…
============================================================================== --- trunk/reactos/base/shell/cmd/free.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/free.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -66,7 +66,7 @@ &dwBytPerSec, &dwFreeCl, &dwTotCl)) { LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE); - ConErrPrintf (_T("%s %s:\n"), szMsg, szDrive); + ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive); return; } Modified: trunk/reactos/base/shell/cmd/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/misc.c?rev=…
============================================================================== --- trunk/reactos/base/shell/cmd/misc.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/misc.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -157,7 +157,7 @@ c = _totupper(cgetchar()); } while (!(_tcschr(options, c) || c == _T('\3')) || !c); - ConOutPuts (_T("\r\n")); + ConOutChar(_T('\n')); if (c == options[1]) return bCtrlBreak = FALSE; /* ignore */ @@ -578,8 +578,8 @@ ConOutResPrintf (resID); /* preliminary fix */ - ConInString (szIn, 10); - ConOutPrintf (_T("\n")); + ConInString(szIn, 10); + ConOutChar(_T('\n')); _tcsupr (szIn); for (p = szIn; _istspace (*p); p++) @@ -642,8 +642,8 @@ ConOutResPrintf (resID); /* preliminary fix */ - ConInString (szIn, 10); - ConOutPrintf (_T("\n")); + ConInString(szIn, 10); + ConOutChar(_T('\n')); _tcsupr (szIn); for (p = szIn; _istspace (*p); p++) Modified: trunk/reactos/base/shell/cmd/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/path.c?rev=…
============================================================================== --- trunk/reactos/base/shell/cmd/path.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/path.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -63,7 +63,7 @@ GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer); } - ConOutPrintf (_T("PATH=%s\n"), pszBuffer); + ConOutPrintf(_T("PATH=%s\n"), pszBuffer); cmd_free (pszBuffer); return 0; Modified: trunk/reactos/base/shell/cmd/set.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/set.c?rev=5…
============================================================================== --- trunk/reactos/base/shell/cmd/set.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/set.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -96,7 +96,7 @@ if (*lpOutput != _T('=')) ConOutPuts(lpOutput); lpOutput += _tcslen(lpOutput) + 1; - ConOutPuts(_T("\r\n")); + ConOutChar(_T('\n')); } FreeEnvironmentStrings (lpEnv); } @@ -185,7 +185,7 @@ if (!_tcsnicmp(lpOutput, param, p - param)) { ConOutPuts(lpOutput); - ConOutPuts(_T("\r\n")); + ConOutChar(_T('\n')); bFound = TRUE; } lpOutput += _tcslen(lpOutput) + 1; Modified: trunk/reactos/base/shell/cmd/ver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/ver.c?rev=5…
============================================================================== --- trunk/reactos/base/shell/cmd/ver.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/ver.c [iso-8859-1] Tue Jul 2 23:07:15 2013 @@ -46,7 +46,7 @@ ConOutResPrintf(STRING_VERSION_RUNVER, RosVersion); } } - ConOutPuts (_T("\n")); + ConOutChar(_T('\n')); }
11 years, 5 months
1
0
0
0
[aandrejevic] 59410: [NTVDM] Add more debug output. [SOFTX86] Properly set the carry and overflow flags.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Tue Jul 2 21:40:11 2013 New Revision: 59410 URL:
http://svn.reactos.org/svn/reactos?rev=59410&view=rev
Log: [NTVDM] Add more debug output. [SOFTX86] Properly set the carry and overflow flags. Modified: branches/ntvdm/lib/3rdparty/softx86/softx86/add.c branches/ntvdm/subsystems/ntvdm/bios.c branches/ntvdm/subsystems/ntvdm/emulator.c branches/ntvdm/subsystems/ntvdm/ntvdm.c Modified: branches/ntvdm/lib/3rdparty/softx86/softx86/add.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/3rdparty/softx86/soft…
============================================================================== --- branches/ntvdm/lib/3rdparty/softx86/softx86/add.c [iso-8859-1] (original) +++ branches/ntvdm/lib/3rdparty/softx86/softx86/add.c [iso-8859-1] Tue Jul 2 21:40:11 2013 @@ -386,13 +386,13 @@ /* peform the addition */ ret = src - val; -/* if carry/overflow */ - if (ret > src) - ctx->state->reg_flags.val |= - (SX86_CPUFLAG_CARRY | SX86_CPUFLAG_OVERFLOW); - else - ctx->state->reg_flags.val &= - ~(SX86_CPUFLAG_CARRY | SX86_CPUFLAG_OVERFLOW); +/* if carry */ + if (val > src) ctx->state->reg_flags.val |= SX86_CPUFLAG_CARRY; + else ctx->state->reg_flags.val &= ~SX86_CPUFLAG_CARRY; + +/* if overflow */ + if ((ret & 0x8000) != (src & 0x8000)) ctx->state->reg_flags.val |= SX86_CPUFLAG_OVERFLOW; + else ctx->state->reg_flags.val &= ~SX86_CPUFLAG_OVERFLOW; /* if result treated as signed value is negative */ if (ret & 0x8000) ctx->state->reg_flags.val |= SX86_CPUFLAG_SIGN; Modified: branches/ntvdm/subsystems/ntvdm/bios.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Tue Jul 2 21:40:11 2013 @@ -369,6 +369,12 @@ { break; } + + default: + { + DPRINT1("BIOS Function INT 10h, AH = 0x%02X NOT IMPLEMENTED\n", + HIBYTE(Eax)); + } } } @@ -404,6 +410,12 @@ break; } + + default: + { + DPRINT1("BIOS Function INT 16h, AH = 0x%02X NOT IMPLEMENTED\n", + HIBYTE(Eax)); + } } } @@ -441,6 +453,12 @@ BiosPassedMidnight = FALSE; break; + } + + default: + { + DPRINT1("BIOS Function INT 1Ah, AH = 0x%02X NOT IMPLEMENTED\n", + HIBYTE(Eax)); } } } Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Tue Jul 2 21:40:11 2013 @@ -385,6 +385,11 @@ VOID EmulatorStep() { + /* Print the current position - useful for debugging */ + DPRINT("Executing at CS:IP = %04X:%04X\n", + EmulatorGetRegister(EMULATOR_REG_CS), + EmulatorContext.state->reg_ip); + /* Call the softx86 API */ if (!softx86_step(&EmulatorContext)) { Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.c?…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] Tue Jul 2 21:40:11 2013 @@ -69,7 +69,10 @@ { INT i; CHAR CommandLine[128]; - DWORD CurrentTickCount, LastTickCount = 0, Cycles = 0, LastCyclePrintout = 0; + DWORD CurrentTickCount; + DWORD LastTickCount = GetTickCount(); + DWORD Cycles = 0; + DWORD LastCyclePrintout = GetTickCount(); LARGE_INTEGER Frequency, LastTimerTick, Counter; LONGLONG TimerTicks; @@ -79,7 +82,11 @@ /* The DOS command line must be ASCII */ WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL); - if (!EmulatorInitialize()) return 1; + if (!EmulatorInitialize()) + { + wprintf(L"FATAL: Failed to initialize the CPU emulator\n"); + return 1; + } /* Initialize the performance counter (needed for hardware timers) */ if (!QueryPerformanceFrequency(&Frequency))
11 years, 5 months
1
0
0
0
[aandrejevic] 59409: [NTVDM] Fix several bugs: The file was not entirely read due to an integer overflow. The second WORD of the Program Segment Prefix (PSP) is not the number of allocated paragrap...
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Tue Jul 2 02:08:30 2013 New Revision: 59409 URL:
http://svn.reactos.org/svn/reactos?rev=59409&view=rev
Log: [NTVDM] Fix several bugs: The file was not entirely read due to an integer overflow. The second WORD of the Program Segment Prefix (PSP) is not the number of allocated paragraphs, but the segment of the last paragraph. Fix the order of registers (SI and DI were mixed up with SP and BP). Implement interrupt 0x11. Implement redirection for reading/writing characters. Modified: branches/ntvdm/subsystems/ntvdm/bios.c branches/ntvdm/subsystems/ntvdm/bios.h branches/ntvdm/subsystems/ntvdm/dos.c branches/ntvdm/subsystems/ntvdm/dos.h branches/ntvdm/subsystems/ntvdm/emulator.c branches/ntvdm/subsystems/ntvdm/emulator.h Modified: branches/ntvdm/subsystems/ntvdm/bios.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -445,6 +445,12 @@ } } +VOID BiosEquipmentService() +{ + /* Return the equipment list */ + EmulatorSetRegister(EMULATOR_REG_AX, BIOS_EQUIPMENT_LIST); +} + VOID BiosHandleIrq(BYTE IrqNumber) { switch (IrqNumber) Modified: branches/ntvdm/subsystems/ntvdm/bios.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -23,10 +23,12 @@ #define BIOS_PIC_SLAVE_INT 0x70 #define BIOS_SEGMENT 0xF000 #define BIOS_VIDEO_INTERRUPT 0x10 +#define BIOS_EQUIPMENT_INTERRUPT 0x11 #define BIOS_KBD_INTERRUPT 0x16 #define BIOS_TIME_INTERRUPT 0x1A #define CONSOLE_FONT_HEIGHT 8 #define BIOS_KBD_BUFFER_SIZE 256 +#define BIOS_EQUIPMENT_LIST 0x3C // HACK: Disable FPU for now /* FUNCTIONS ******************************************************************/ @@ -36,6 +38,7 @@ WORD BiosPeekCharacter(); WORD BiosGetCharacter(); VOID BiosVideoService(); +VOID BiosEquipmentService(); VOID BiosKeyboardService(); VOID BiosTimeService(); VOID BiosHandleIrq(BYTE IrqNumber); Modified: branches/ntvdm/subsystems/ntvdm/dos.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.c?re…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -79,7 +79,10 @@ /* Advance to the next string */ Ptr += strlen(Ptr) + 1; - DestBuffer += strlen(Ptr) + 1; + DestBuffer += strlen(Ptr); + + /* Put a zero after the string */ + *(DestBuffer++) = 0; } /* Set the final zero */ @@ -590,8 +593,8 @@ PspBlock->Exit[0] = 0xCD; // int 0x20 PspBlock->Exit[1] = 0x20; - /* Set the program size */ - PspBlock->MemSize = ProgramSize; + /* Set the number of the last paragraph */ + PspBlock->LastParagraph = PspSegment + ProgramSize - 1; /* Save the interrupt vectors */ PspBlock->TerminateAddress = IntVecTable[0x22]; @@ -633,7 +636,8 @@ LPSTR ProgramFilePath, Parameters[128]; CHAR CommandLineCopy[128]; INT ParamCount = 0; - WORD i, Segment = 0, FileSize, ExeSize; + DWORD Segment = 0; + DWORD i, FileSize, ExeSize; PIMAGE_DOS_HEADER Header; PDWORD RelocationTable; PWORD RelocWord; @@ -700,13 +704,22 @@ // TODO: Verify checksum and executable! /* Get the base size of the file, in paragraphs (rounded up) */ - ExeSize = (((Header->e_cp - 1) << 8) + Header->e_cblp + 0x0F) >> 4; - - /* Loop from the maximum to the minimum number of extra paragraphs */ - for (i = Header->e_maxalloc; i >= Header->e_minalloc; i--) + ExeSize = (((Header->e_cp - 1) * 512) + Header->e_cblp + 0x0F) >> 4; + + /* Add the PSP size, in paragraphs */ + ExeSize += sizeof(DOS_PSP) >> 4; + + /* Add the maximum size that should be allocated */ + ExeSize += Header->e_maxalloc; + + /* Make sure it does not pass 0xFFFF */ + if (ExeSize > 0xFFFF) ExeSize = 0xFFFF; + + /* Reduce the size one by one until the allocation is successful */ + for (i = Header->e_maxalloc; i >= Header->e_minalloc; i--, ExeSize--) { /* Try to allocate that much memory */ - Segment = DosAllocateMemory(ExeSize + (sizeof(DOS_PSP) >> 4) + i, NULL); + Segment = DosAllocateMemory(ExeSize, NULL); if (Segment != 0) break; } @@ -715,7 +728,8 @@ /* Initialize the PSP */ DosInitializePsp(Segment, - CommandLine, ExeSize + (sizeof(DOS_PSP) >> 4) + i, + CommandLine, + ExeSize, EnvBlock); /* The process owns its own memory */ @@ -865,21 +879,21 @@ CHAR DosReadCharacter() { - // TODO: STDIN can be redirected under DOS 2.0+ - CHAR Character = 0; - - /* A zero value for the character indicates a special key */ - do Character = BiosGetCharacter(); - while (!Character); + CHAR Character = '\0'; + WORD BytesRead; + + /* Use the file reading function */ + DosReadFile(DOS_INPUT_HANDLE, &Character, sizeof(CHAR), &BytesRead); return Character; } VOID DosPrintCharacter(CHAR Character) { - // TODO: STDOUT can be redirected under DOS 2.0+ - if (Character == '\r') Character = '\n'; - putchar(Character); + WORD BytesWritten; + + /* Use the file writing function */ + DosWriteFile(DOS_OUTPUT_HANDLE, &Character, sizeof(CHAR), &BytesWritten); } VOID DosInt20h(WORD CodeSegment) @@ -1382,7 +1396,7 @@ /* Initialize the MCB */ Mcb->BlockType = 'Z'; - Mcb->Size = (WORD)USER_MEMORY_SIZE; + Mcb->Size = USER_MEMORY_SIZE; Mcb->OwnerPsp = 0; /* Get the environment strings */ @@ -1428,8 +1442,10 @@ /* Move to the next string */ SourcePtr += wcslen(SourcePtr) + 1; - DestPtr += strlen(AsciiString) + 1; - } + DestPtr += strlen(AsciiString); + *(DestPtr++) = 0; + } + *DestPtr = 0; /* Free the memory allocated for environment strings */ FreeEnvironmentStringsW(Environment); Modified: branches/ntvdm/subsystems/ntvdm/dos.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.h?re…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -19,10 +19,13 @@ #define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT" #define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT" #define FIRST_MCB_SEGMENT 0x1000 -#define USER_MEMORY_SIZE 0x8FFFF +#define USER_MEMORY_SIZE 0x8FFF #define SYSTEM_PSP 0x08 #define SYSTEM_ENV_BLOCK 0x800 #define INVALID_DOS_HANDLE 0xFFFF +#define DOS_INPUT_HANDLE 0 +#define DOS_OUTPUT_HANDLE 1 +#define DOS_ERROR_HANDLE 2 #define DOS_SFT_SIZE 255 #define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) #define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) @@ -56,7 +59,7 @@ typedef struct _DOS_PSP { BYTE Exit[2]; - WORD MemSize; + WORD LastParagraph; BYTE Reserved0[6]; DWORD TerminateAddress; DWORD BreakAddress; Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -216,6 +216,12 @@ BiosVideoService(); break; } + case BIOS_EQUIPMENT_INTERRUPT: + { + /* This is the BIOS "get equipment" command, call the BIOS */ + BiosEquipmentService(); + break; + } case BIOS_KBD_INTERRUPT: { /* This is the keyboard BIOS interrupt, call the BIOS */ @@ -267,7 +273,7 @@ BOOLEAN EmulatorInitialize() { /* Allocate memory for the 16-bit address space */ - BaseAddress = HeapAlloc(GetProcessHeap(), 0, MAX_ADDRESS); + BaseAddress = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_ADDRESS); if (BaseAddress == NULL) return FALSE; /* Initialize the softx86 CPU emulator */ Modified: branches/ntvdm/subsystems/ntvdm/emulator.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] Tue Jul 2 02:08:30 2013 @@ -53,10 +53,10 @@ EMULATOR_REG_CX, EMULATOR_REG_DX, EMULATOR_REG_BX, + EMULATOR_REG_SP, + EMULATOR_REG_BP, EMULATOR_REG_SI, EMULATOR_REG_DI, - EMULATOR_REG_SP, - EMULATOR_REG_BP, EMULATOR_REG_ES, EMULATOR_REG_CS, EMULATOR_REG_SS,
11 years, 5 months
1
0
0
0
[ekohl] 59408: [MSV1_0] Add dispatcher code to LsaApCallPackage and start working on password change code.
by ekohl@svn.reactos.org
Author: ekohl Date: Mon Jul 1 18:43:36 2013 New Revision: 59408 URL:
http://svn.reactos.org/svn/reactos?rev=59408&view=rev
Log: [MSV1_0] Add dispatcher code to LsaApCallPackage and start working on password change code. Modified: trunk/reactos/dll/win32/msv1_0/msv1_0.c Modified: trunk/reactos/dll/win32/msv1_0/msv1_0.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msv1_0/msv1_0.c?…
============================================================================== --- trunk/reactos/dll/win32/msv1_0/msv1_0.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msv1_0/msv1_0.c [iso-8859-1] Mon Jul 1 18:43:36 2013 @@ -729,6 +729,41 @@ } +static +NTSTATUS +ChangePassword(IN PLSA_CLIENT_REQUEST ClientRequest, + IN PVOID ProtocolSubmitBuffer, + IN PVOID ClientBufferBase, + IN ULONG SubmitBufferLength, + OUT PVOID *ProtocolReturnBuffer, + OUT PULONG ReturnBufferLength, + OUT PNTSTATUS ProtocolStatus) +{ + PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer; + ULONG_PTR PtrOffset; + + TRACE("()\n"); + + RequestBuffer = (PMSV1_0_CHANGEPASSWORD_REQUEST)ProtocolSubmitBuffer; + + /* Fix-up pointers in the request buffer info */ + PtrOffset = (ULONG_PTR)ProtocolSubmitBuffer - (ULONG_PTR)ClientBufferBase; + + RequestBuffer->DomainName.Buffer = (PWSTR)((ULONG_PTR)RequestBuffer->DomainName.Buffer + PtrOffset); + RequestBuffer->AccountName.Buffer = (PWSTR)((ULONG_PTR)RequestBuffer->AccountName.Buffer + PtrOffset); + RequestBuffer->OldPassword.Buffer = (PWSTR)((ULONG_PTR)RequestBuffer->OldPassword.Buffer + PtrOffset); + RequestBuffer->NewPassword.Buffer = (PWSTR)((ULONG_PTR)RequestBuffer->NewPassword.Buffer + PtrOffset); + + TRACE("Domain: %S\n", RequestBuffer->DomainName.Buffer); + TRACE("Account: %S\n", RequestBuffer->AccountName.Buffer); + TRACE("Old Password: %S\n", RequestBuffer->OldPassword.Buffer); + TRACE("New Password: %S\n", RequestBuffer->NewPassword.Buffer); + + + return STATUS_SUCCESS; +} + + /* * @unimplemented */ @@ -742,8 +777,53 @@ OUT PULONG ReturnBufferLength, OUT PNTSTATUS ProtocolStatus) { + ULONG MessageType; + NTSTATUS Status; + TRACE("()\n"); - return STATUS_NOT_IMPLEMENTED; + + if (SubmitBufferLength < sizeof(MSV1_0_PROTOCOL_MESSAGE_TYPE)) + return STATUS_INVALID_PARAMETER; + + MessageType = (ULONG)*((PMSV1_0_PROTOCOL_MESSAGE_TYPE)ProtocolSubmitBuffer); + + *ProtocolReturnBuffer = NULL; + *ReturnBufferLength = 0; + + switch (MessageType) + { + case MsV1_0Lm20ChallengeRequest: + case MsV1_0Lm20GetChallengeResponse: + case MsV1_0EnumerateUsers: + case MsV1_0GetUserInfo: + case MsV1_0ReLogonUsers: + Status = STATUS_NOT_IMPLEMENTED; + break; + + case MsV1_0ChangePassword: + Status = ChangePassword(ClientRequest, + ProtocolSubmitBuffer, + ClientBufferBase, + SubmitBufferLength, + ProtocolReturnBuffer, + ReturnBufferLength, + ProtocolStatus); + break; + + case MsV1_0ChangeCachedPassword: + case MsV1_0GenericPassthrough: + case MsV1_0CacheLogon: + case MsV1_0SubAuth: + case MsV1_0DeriveCredential: + case MsV1_0CacheLookup: + Status = STATUS_NOT_IMPLEMENTED; + break; + + default: + return STATUS_INVALID_PARAMETER; + } + + return Status; }
11 years, 5 months
1
0
0
0
[jjones] 59407: Add support for compiling USBUHCI.SYS, courtesy of Mr. Wang.
by jjones@svn.reactos.org
Author: jjones Date: Mon Jul 1 16:57:17 2013 New Revision: 59407 URL:
http://svn.reactos.org/svn/reactos?rev=59407&view=rev
Log: Add support for compiling USBUHCI.SYS, courtesy of Mr. Wang. Modified: branches/vs_jc/reactos/ (props changed) branches/vs_jc/reactos/_IMAGES/CD_Live/CD_Live.vcxproj branches/vs_jc/reactos/lib/drivers/libusb/libusb.vcxproj Propchange: branches/vs_jc/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Jul 1 16:57:17 2013 @@ -15,4 +15,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:59302-59337 +/trunk/reactos:59302-59397 Modified: branches/vs_jc/reactos/_IMAGES/CD_Live/CD_Live.vcxproj URL:
http://svn.reactos.org/svn/reactos/branches/vs_jc/reactos/_IMAGES/CD_Live/C…
============================================================================== --- branches/vs_jc/reactos/_IMAGES/CD_Live/CD_Live.vcxproj [iso-8859-1] (original) +++ branches/vs_jc/reactos/_IMAGES/CD_Live/CD_Live.vcxproj [iso-8859-1] Mon Jul 1 16:57:17 2013 @@ -42,6 +42,7 @@ copy "$(SolutionDir)\drivers\filesystems\CDFS\$(OutDir)\CDFS.SYS" . copy "$(SolutionDir)\drivers\bus\PCI\$(OutDir)\PCI.SYS" . copy "$(SolutionDir)\drivers\usb\usbuhci\$(OutDir)\USBUHCI.SYS" . +copy "$(SolutionDir)\drivers\usb\usbd\$(OutDir)\USBD.SYS" . cd .. mkdir config cd "$(SolutionDir)\boot\bootdata" @@ -78,6 +79,7 @@ copy "$(SolutionDir)\drivers\filesystems\CDFS\$(OutDir)\CDFS.SYS" . copy "$(SolutionDir)\drivers\bus\PCI\$(OutDir)\PCI.SYS" . copy "$(SolutionDir)\drivers\usb\usbuhci\$(OutDir)\USBUHCI.SYS" . +copy "$(SolutionDir)\drivers\usb\usbd\$(OutDir)\USBD.SYS" . cd .. mkdir config cd "$(SolutionDir)\boot\bootdata" @@ -106,6 +108,12 @@ </ProjectReference> <ProjectReference Include="..\..\drivers\filesystems\cdfs\cdfs.vcxproj"> <Project>{1f0d3cae-da53-40bd-b7ea-77a521c4bbc2}</Project> + </ProjectReference> + <ProjectReference Include="..\..\drivers\usb\usbd\usbd.vcxproj"> + <Project>{17786c00-926d-45ff-a031-3800821afc7a}</Project> + </ProjectReference> + <ProjectReference Include="..\..\drivers\usb\usbuhci\usbuhci.vcxproj"> + <Project>{1bf87245-cd63-4e76-a594-1790bd61c498}</Project> </ProjectReference> <ProjectReference Include="..\..\hal\hal.vcxproj"> <Project>{ba5347bf-c0fd-44f0-976e-510b4d48e07b}</Project> @@ -192,4 +200,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project> Modified: branches/vs_jc/reactos/lib/drivers/libusb/libusb.vcxproj URL:
http://svn.reactos.org/svn/reactos/branches/vs_jc/reactos/lib/drivers/libus…
============================================================================== --- branches/vs_jc/reactos/lib/drivers/libusb/libusb.vcxproj [iso-8859-1] (original) +++ branches/vs_jc/reactos/lib/drivers/libusb/libusb.vcxproj [iso-8859-1] Mon Jul 1 16:57:17 2013 @@ -56,7 +56,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..\..\include\psdk;..\..\..\include\ddk;..\..\..\include\reactos\mc\build\x86_32\$(Configuration)\ReactOS;..\..\..\include\reactos</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\..\include\psdk;..\..\..\include\ddk;..\..\..\include\reactos\mc\build\x86_32\$(Configuration)\ReactOS;..\..\..\include\crt;..\..\..\include\crt\msc;..\..\..\include\reactos</AdditionalIncludeDirectories> <BasicRuntimeChecks>Default</BasicRuntimeChecks> <CompileAs>CompileAsCpp</CompileAs> <BufferSecurityCheck>false</BufferSecurityCheck> @@ -81,7 +81,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..\..\include\psdk;..\..\..\include\ddk;..\..\..\include\reactos\mc\build\x86_32\$(Configuration)\ReactOS</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\..\include\psdk;..\..\..\include\ddk;..\..\..\include\reactos\mc\build\x86_32\$(Configuration)\ReactOS;..\..\..\include\crt;..\..\..\include\crt\msc;..\..\..\include\reactos</AdditionalIncludeDirectories> <BasicRuntimeChecks>Default</BasicRuntimeChecks> <BufferSecurityCheck>false</BufferSecurityCheck> <ExceptionHandling>false</ExceptionHandling> @@ -117,4 +117,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project>
11 years, 5 months
1
0
0
0
[aandrejevic] 59406: [NTVDM] Implement file creation, opening, reading and writing.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Mon Jul 1 02:29:29 2013 New Revision: 59406 URL:
http://svn.reactos.org/svn/reactos?rev=59406&view=rev
Log: [NTVDM] Implement file creation, opening, reading and writing. Modified: branches/ntvdm/subsystems/ntvdm/dos.c branches/ntvdm/subsystems/ntvdm/dos.h branches/ntvdm/subsystems/ntvdm/ntvdm.h Modified: branches/ntvdm/subsystems/ntvdm/dos.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.c?re…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] Mon Jul 1 02:29:29 2013 @@ -16,6 +16,8 @@ static WORD CurrentPsp = SYSTEM_PSP; static DWORD DiskTransferArea; +static HANDLE DosSystemFileTable[DOS_SFT_SIZE]; +static WORD DosSftRefCount[DOS_SFT_SIZE]; /* PRIVATE FUNCTIONS **********************************************************/ @@ -92,6 +94,125 @@ /* Just set the owner */ Mcb->OwnerPsp = NewOwner; +} + +static WORD DosOpenHandle(HANDLE Handle) +{ + BYTE i; + WORD DosHandle; + PDOS_PSP PspBlock; + LPBYTE HandleTable; + + /* The system PSP has no handle table */ + if (CurrentPsp == SYSTEM_PSP) return INVALID_DOS_HANDLE; + + /* Get a pointer to the handle table */ + PspBlock = SEGMENT_TO_PSP(CurrentPsp); + HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr); + + /* Find a free entry in the JFT */ + for (DosHandle = 0; DosHandle < PspBlock->HandleTableSize; DosHandle++) + { + if (HandleTable[DosHandle] == 0xFF) break; + } + + /* If there are no free entries, fail */ + if (DosHandle == PspBlock->HandleTableSize) return INVALID_DOS_HANDLE; + + /* Check if the handle is already in the SFT */ + for (i = 0; i < DOS_SFT_SIZE; i++) + { + /* Check if this is the same handle */ + if (DosSystemFileTable[i] != Handle) continue; + + /* Already in the table, reference it */ + DosSftRefCount[i]++; + + /* Set the JFT entry to that SFT index */ + HandleTable[DosHandle] = i; + + /* Return the new handle */ + return DosHandle; + } + + /* Add the handle to the SFT */ + for (i = 0; i < DOS_SFT_SIZE; i++) + { + /* Make sure this is an empty table entry */ + if (DosSystemFileTable[i] != INVALID_HANDLE_VALUE) continue; + + /* Initialize the empty table entry */ + DosSystemFileTable[i] = Handle; + DosSftRefCount[i] = 1; + + /* Set the JFT entry to that SFT index */ + HandleTable[DosHandle] = i; + + /* Return the new handle */ + return DosHandle; + } + + /* The SFT is full */ + return INVALID_DOS_HANDLE; +} + +static HANDLE DosGetRealHandle(WORD DosHandle) +{ + PDOS_PSP PspBlock; + LPBYTE HandleTable; + + /* The system PSP has no handle table */ + if (CurrentPsp == SYSTEM_PSP) return INVALID_HANDLE_VALUE; + + /* Get a pointer to the handle table */ + PspBlock = SEGMENT_TO_PSP(CurrentPsp); + HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr); + + /* Make sure the handle is open */ + if (HandleTable[DosHandle] == 0xFF) return INVALID_HANDLE_VALUE; + + /* Return the Win32 handle */ + return DosSystemFileTable[HandleTable[DosHandle]]; +} + +static VOID DosCopyHandleTable(LPBYTE DestinationTable) +{ + INT i; + PDOS_PSP PspBlock; + LPBYTE SourceTable; + + /* Clear the table first */ + for (i = 0; i < 20; i++) DestinationTable[i] = 0xFF; + + /* Check if this is the initial process */ + if (CurrentPsp == SYSTEM_PSP) + { + /* Set up the standard I/O devices */ + for (i = 0; i <= 2; i++) + { + /* Set the index in the SFT */ + DestinationTable[i] = i; + + /* Increase the reference count */ + DosSftRefCount[i]++; + } + + /* Done */ + return; + } + + /* Get the parent PSP block and handle table */ + PspBlock = SEGMENT_TO_PSP(CurrentPsp); + SourceTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr); + + /* Copy the first 20 handles into the new table */ + for (i = 0; i < 20; i++) + { + DestinationTable[i] = SourceTable[i]; + + /* Increase the reference count */ + DosSftRefCount[SourceTable[i]]++; + } } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -273,21 +394,193 @@ return TRUE; } -WORD DosCreateFile(LPCSTR FilePath) -{ - // TODO: NOT IMPLEMENTED - return 0; -} - -WORD DosOpenFile(LPCSTR FilePath) -{ - // TODO: NOT IMPLEMENTED - return 0; +WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD Attributes) +{ + HANDLE FileHandle; + WORD DosHandle; + + /* Create the file */ + FileHandle = CreateFileA(FilePath, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + CREATE_ALWAYS, + Attributes, + NULL); + + if (FileHandle == INVALID_HANDLE_VALUE) + { + /* Return the error code */ + return GetLastError(); + } + + /* Open the DOS handle */ + DosHandle = DosOpenHandle(FileHandle); + + if (DosHandle == INVALID_DOS_HANDLE) + { + /* Close the handle */ + CloseHandle(FileHandle); + + /* Return the error code */ + return ERROR_TOO_MANY_OPEN_FILES; + } + + /* It was successful */ + *Handle = DosHandle; + return ERROR_SUCCESS; +} + +WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessMode) +{ + HANDLE FileHandle; + ACCESS_MASK Access = 0; + WORD DosHandle; + + /* Parse the access mode */ + switch (AccessMode & 3) + { + case 0: + { + /* Read-only */ + Access = GENERIC_READ; + break; + } + + case 1: + { + /* Write only */ + Access = GENERIC_WRITE; + break; + } + + case 2: + { + /* Read and write */ + Access = GENERIC_READ | GENERIC_WRITE; + break; + } + + default: + { + /* Invalid */ + return ERROR_INVALID_PARAMETER; + } + } + + /* Open the file */ + FileHandle = CreateFileA(FilePath, + Access, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (FileHandle == INVALID_HANDLE_VALUE) + { + /* Return the error code */ + return GetLastError(); + } + + /* Open the DOS handle */ + DosHandle = DosOpenHandle(FileHandle); + + if (DosHandle == INVALID_DOS_HANDLE) + { + /* Close the handle */ + CloseHandle(FileHandle); + + /* Return the error code */ + return ERROR_TOO_MANY_OPEN_FILES; + } + + /* It was successful */ + *Handle = DosHandle; + return ERROR_SUCCESS; +} + +WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead) +{ + WORD Result = ERROR_SUCCESS; + DWORD BytesRead32 = 0; + HANDLE Handle = DosGetRealHandle(FileHandle); + + /* Make sure the handle is valid */ + if (Handle == INVALID_HANDLE_VALUE) return ERROR_INVALID_PARAMETER; + + /* Read the file */ + if (!ReadFile(Handle, Buffer, Count, &BytesRead32, NULL)) + { + /* Store the error code */ + Result = GetLastError(); + } + + /* The number of bytes read is always 16-bit */ + *BytesRead = LOWORD(BytesRead32); + + /* Return the error code */ + return Result; +} + +WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten) +{ + WORD Result = ERROR_SUCCESS; + DWORD BytesWritten32 = 0; + HANDLE Handle = DosGetRealHandle(FileHandle); + + /* Make sure the handle is valid */ + if (Handle == INVALID_HANDLE_VALUE) return ERROR_INVALID_PARAMETER; + + /* Write the file */ + if (!WriteFile(Handle, Buffer, Count, &BytesWritten32, NULL)) + { + /* Store the error code */ + Result = GetLastError(); + } + + /* The number of bytes written is always 16-bit */ + *BytesWritten = LOWORD(BytesWritten32); + + /* Return the error code */ + return Result; +} + +BOOLEAN DosCloseHandle(WORD DosHandle) +{ + BYTE SftIndex; + PDOS_PSP PspBlock; + LPBYTE HandleTable; + + /* The system PSP has no handle table */ + if (CurrentPsp == SYSTEM_PSP) return FALSE; + + /* Get a pointer to the handle table */ + PspBlock = SEGMENT_TO_PSP(CurrentPsp); + HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr); + + /* Make sure the handle is open */ + if (HandleTable[DosHandle] == 0xFF) return FALSE; + + /* Decrement the reference count of the SFT entry */ + SftIndex = HandleTable[DosHandle]; + DosSftRefCount[SftIndex]--; + + /* Check if the reference count fell to zero */ + if (!DosSftRefCount[SftIndex]) + { + /* Close the file, it's no longer needed */ + CloseHandle(DosSystemFileTable[SftIndex]); + + /* Clear the handle */ + DosSystemFileTable[SftIndex] = INVALID_HANDLE_VALUE; + } + + return TRUE; } VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment) { - INT i; PDOS_PSP PspBlock = SEGMENT_TO_PSP(PspSegment); LPDWORD IntVecTable = (LPDWORD)((ULONG_PTR)BaseAddress); @@ -308,11 +601,10 @@ /* Set the parent PSP */ PspBlock->ParentPsp = CurrentPsp; - /* Initialize the handle table */ - for (i = 0; i < 20; i++) PspBlock->HandleTable[i] = 0xFF; - - - + /* Copy the parent handle table */ + DosCopyHandleTable(PspBlock->HandleTable); + + /* Set the environment block */ PspBlock->EnvBlock = Environment; /* Set the handle table pointers to the internal handle table */ @@ -863,6 +1155,152 @@ break; } + /* Create File */ + case 0x3C: + { + WORD FileHandle; + WORD ErrorCode = DosCreateFile(&FileHandle, + (LPCSTR)(ULONG_PTR)BaseAddress + + TO_LINEAR(DataSegment, LOWORD(Edx)), + LOWORD(Ecx)); + + if (ErrorCode == 0) + { + /* Clear CF */ + EmulatorClearFlag(EMULATOR_FLAG_CF); + + /* Return the handle in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | FileHandle); + } + else + { + /* Set CF */ + EmulatorSetFlag(EMULATOR_FLAG_CF); + + /* Return the error code in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | ErrorCode); + } + + break; + } + + /* Open File */ + case 0x3D: + { + WORD FileHandle; + WORD ErrorCode = DosCreateFile(&FileHandle, + (LPCSTR)(ULONG_PTR)BaseAddress + + TO_LINEAR(DataSegment, LOWORD(Edx)), + LOBYTE(Eax)); + + if (ErrorCode == 0) + { + /* Clear CF */ + EmulatorClearFlag(EMULATOR_FLAG_CF); + + /* Return the handle in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | FileHandle); + } + else + { + /* Set CF */ + EmulatorSetFlag(EMULATOR_FLAG_CF); + + /* Return the error code in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | ErrorCode); + } + + break; + } + + /* Close File */ + case 0x3E: + { + if (DosCloseHandle(LOWORD(Ebx))) + { + /* Clear CF */ + EmulatorClearFlag(EMULATOR_FLAG_CF); + } + else + { + /* Set CF */ + EmulatorSetFlag(EMULATOR_FLAG_CF); + + /* Return the error code in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | ERROR_INVALID_PARAMETER); + } + + break; + } + + /* Read File */ + case 0x3F: + { + WORD BytesRead = 0; + WORD ErrorCode = DosReadFile(LOWORD(Ebx), + (LPVOID)((ULONG_PTR)BaseAddress + + TO_LINEAR(DataSegment, LOWORD(Edx))), + LOWORD(Ecx), + &BytesRead); + + if (ErrorCode == 0) + { + /* Clear CF */ + EmulatorClearFlag(EMULATOR_FLAG_CF); + + /* Return the number of bytes read in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | BytesRead); + } + else + { + /* Set CF */ + EmulatorSetFlag(EMULATOR_FLAG_CF); + + /* Return the error code in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | ErrorCode); + } + break; + } + + /* Write File */ + case 0x40: + { + WORD BytesWritten = 0; + WORD ErrorCode = DosWriteFile(LOWORD(Ebx), + (LPVOID)((ULONG_PTR)BaseAddress + + TO_LINEAR(DataSegment, LOWORD(Edx))), + LOWORD(Ecx), + &BytesWritten); + + if (ErrorCode == 0) + { + /* Clear CF */ + EmulatorClearFlag(EMULATOR_FLAG_CF); + + /* Return the number of bytes written in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | BytesWritten); + } + else + { + /* Set CF */ + EmulatorSetFlag(EMULATOR_FLAG_CF); + + /* Return the error code in AX */ + EmulatorSetRegister(EMULATOR_REG_AX, + (Eax & 0xFFFF0000) | ErrorCode); + } + + break; + } + /* Allocate Memory */ case 0x48: { @@ -933,6 +1371,7 @@ BOOLEAN DosInitialize() { + BYTE i; PDOS_MCB Mcb = SEGMENT_TO_MCB(FIRST_MCB_SEGMENT); FILE *Stream; WCHAR Buffer[256]; @@ -1006,6 +1445,18 @@ fclose(Stream); } + /* Initialize the SFT */ + for (i = 0; i < DOS_SFT_SIZE; i++) + { + DosSystemFileTable[i] = INVALID_HANDLE_VALUE; + DosSftRefCount[i] = 0; + } + + /* Get handles to standard I/O devices */ + DosSystemFileTable[0] = GetStdHandle(STD_INPUT_HANDLE); + DosSystemFileTable[1] = GetStdHandle(STD_OUTPUT_HANDLE); + DosSystemFileTable[2] = GetStdHandle(STD_ERROR_HANDLE); + return TRUE; } Modified: branches/ntvdm/subsystems/ntvdm/dos.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.h?re…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] Mon Jul 1 02:29:29 2013 @@ -22,6 +22,8 @@ #define USER_MEMORY_SIZE 0x8FFFF #define SYSTEM_PSP 0x08 #define SYSTEM_ENV_BLOCK 0x800 +#define INVALID_DOS_HANDLE 0xFFFF +#define DOS_SFT_SIZE 255 #define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) #define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) @@ -76,34 +78,6 @@ CHAR CommandLine[127]; } DOS_PSP, *PDOS_PSP; -typedef struct _DOS_SFT_ENTRY -{ - WORD ReferenceCount; - WORD Mode; - BYTE Attribute; - WORD DeviceInfo; - DWORD DriveParamBlock; - WORD FirstCluster; - WORD FileTime; - WORD FileDate; - DWORD FileSize; - DWORD CurrentOffset; - WORD LastClusterAccessed; - DWORD DirEntSector; - BYTE DirEntryIndex; - CHAR FileName[11]; - BYTE Reserved0[6]; - WORD OwnerPsp; - BYTE Reserved1[8]; -} DOS_SFT_ENTRY, *PDOS_SFT_ENTRY; - -typedef struct _DOS_SFT -{ - DWORD NextTablePtr; - WORD FileCount; - DOS_SFT_ENTRY Entry[ANYSIZE_ARRAY]; -} DOS_SFT, *PDOS_SFT; - typedef struct _DOS_INPUT_BUFFER { BYTE MaxLength, Length; @@ -117,6 +91,10 @@ WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable); BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable); BOOLEAN DosFreeMemory(WORD BlockData); +WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD Attributes); +WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessMode); +WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead); +WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten); VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment); BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock); VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode); Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.h?…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] Mon Jul 1 02:29:29 2013 @@ -26,6 +26,7 @@ #define MAX_SEGMENT 0xFFFF #define MAX_OFFSET 0xFFFF #define MAX_ADDRESS TO_LINEAR(MAX_SEGMENT, MAX_OFFSET) +#define FAR_POINTER(x) ((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x))) #define STEPS_PER_CYCLE 256 /* FUNCTIONS ******************************************************************/
11 years, 5 months
1
0
0
0
[hbelusca] 59405: [CMD] Fix the default input & output console modes. Now, you can use the command interpreter via serial port redirection, by: 1- Enabling a serial port on the machine on which Rea...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Jul 1 00:07:39 2013 New Revision: 59405 URL:
http://svn.reactos.org/svn/reactos?rev=59405&view=rev
Log: [CMD] Fix the default input & output console modes. Now, you can use the command interpreter via serial port redirection, by: 1- Enabling a serial port on the machine on which ReactOS runs. 2- Launching: cmd > AUX at a command prompt. Modified: trunk/reactos/base/shell/cmd/cmd.c trunk/reactos/base/shell/cmd/redir.c Modified: trunk/reactos/base/shell/cmd/cmd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=5…
============================================================================== --- trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] Mon Jul 1 00:07:39 2013 @@ -414,21 +414,20 @@ stui.dwFlags = STARTF_USESHOWWINDOW; stui.wShowWindow = SW_SHOWDEFAULT; - // return console to standard mode + /* Set the console to standard mode */ SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), - ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT); - - if (CreateProcess (szFullName, - szFullCmdLine, - NULL, - NULL, - TRUE, - 0, /* CREATE_NEW_PROCESS_GROUP */ - NULL, - NULL, - &stui, - &prci)) - + ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + + if (CreateProcess(szFullName, + szFullCmdLine, + NULL, + NULL, + TRUE, + 0, /* CREATE_NEW_PROCESS_GROUP */ + NULL, + NULL, + &stui, + &prci)) { CloseHandle(prci.hThread); } @@ -449,32 +448,33 @@ EnterCriticalSection(&ChildProcessRunningLock); dwChildProcessId = prci.dwProcessId; - WaitForSingleObject (prci.hProcess, INFINITE); + WaitForSingleObject(prci.hProcess, INFINITE); LeaveCriticalSection(&ChildProcessRunningLock); - GetExitCodeProcess (prci.hProcess, &dwExitCode); + GetExitCodeProcess(prci.hProcess, &dwExitCode); nErrorLevel = (INT)dwExitCode; } - CloseHandle (prci.hProcess); + CloseHandle(prci.hProcess); } else { TRACE ("[ShellExecute failed!: %s]\n", debugstr_aw(Full)); - error_bad_command (first); + error_bad_command(first); dwExitCode = 1; } - // restore console mode - SetConsoleMode ( - GetStdHandle( STD_INPUT_HANDLE ), - ENABLE_PROCESSED_INPUT ); - } - - /* Get code page if it has been change */ + /* Restore our default console mode */ + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), + ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), + ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); + } + + /* Get code page if it has been changed */ InputCodePage= GetConsoleCP(); OutputCodePage = GetConsoleOutputCP(); - SetConsoleTitle (szWindowTitle); + SetConsoleTitle(szWindowTitle); return dwExitCode; } @@ -1360,7 +1360,7 @@ */ BOOL -ReadLine (TCHAR *commandline, BOOL bMore) +ReadLine(TCHAR *commandline, BOOL bMore) { TCHAR readline[CMDLINE_LENGTH]; LPTSTR ip; @@ -1426,7 +1426,7 @@ /* * control-break handler. */ -BOOL WINAPI BreakHandler (DWORD dwCtrlType) +BOOL WINAPI BreakHandler(DWORD dwCtrlType) { DWORD dwWritten; INPUT_RECORD rec; @@ -1637,18 +1637,18 @@ NtReadVirtualMemoryPtr = (NtReadVirtualMemoryProc)GetProcAddress(NtDllModule, "NtReadVirtualMemory"); } - InitLocale (); + InitLocale(); /* get default input and output console handles */ - hOut = GetStdHandle (STD_OUTPUT_HANDLE); - hIn = GetStdHandle (STD_INPUT_HANDLE); + hOut = GetStdHandle(STD_OUTPUT_HANDLE); + hIn = GetStdHandle(STD_INPUT_HANDLE); /* Set EnvironmentVariable PROMPT if it does not exists any env value. for you can change the EnvirommentVariable for prompt before cmd start this patch are not 100% right, if it does not exists a PROMPT value cmd should use $P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */ if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, sizeof(lpBuffer) / sizeof(lpBuffer[0])) == 0) - SetEnvironmentVariable (_T("PROMPT"), _T("$P$G")); + SetEnvironmentVariable(_T("PROMPT"), _T("$P$G")); #ifdef FEATURE_DIR_STACK /* initialize directory stack */ @@ -1667,10 +1667,13 @@ SetEnvironmentVariable (_T("COMSPEC"), ModuleName); } - /* add ctrl break handler */ - AddBreakHandler (); - - SetConsoleMode (hIn, ENABLE_PROCESSED_INPUT); + /* Add ctrl break handler */ + AddBreakHandler(); + + /* Set our default console mode */ + SetConsoleMode(hOut, 0); // Reinitialize the console output mode + SetConsoleMode(hOut, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); + SetConsoleMode(hIn , ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); cmdLine = GetCommandLine(); TRACE ("[command args: %s]\n", debugstr_aw(cmdLine)); @@ -1800,10 +1803,15 @@ /* free GetEnvVar's buffer */ GetEnvVar(NULL); - /* remove ctrl break handler */ - RemoveBreakHandler (); - SetConsoleMode(GetStdHandle( STD_INPUT_HANDLE ), - ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT); + /* Remove ctrl break handler */ + RemoveBreakHandler(); + + /* Restore the default console mode */ + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), + ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), + ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); + DeleteCriticalSection(&ChildProcessRunningLock); } Modified: trunk/reactos/base/shell/cmd/redir.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/redir.c?rev…
============================================================================== --- trunk/reactos/base/shell/cmd/redir.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/redir.c [iso-8859-1] Mon Jul 1 00:07:39 2013 @@ -61,8 +61,7 @@ static SECURITY_ATTRIBUTES SecAttr = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; /* Some parameters used for read, write, and append, respectively */ - static - struct REDIR_PARAMS + static struct REDIR_PARAMS { DWORD dwDesiredAccess; DWORD dwShareMode;
11 years, 5 months
1
0
0
0
← Newer
1
...
17
18
19
20
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Results per page:
10
25
50
100
200