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
October 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
222 discussions
Start a n
N
ew thread
[hbelusca] 72933: [DISKPART][NET][WLANCONF] Make those command tools use the console uilities library, aka. solve all those problems of wrong characters on the console... CORE-10584 #resolve [CONUT...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 22:50:32 2016 New Revision: 72933 URL:
http://svn.reactos.org/svn/reactos?rev=72933&view=rev
Log: [DISKPART][NET][WLANCONF] Make those command tools use the console uilities library, aka. solve all those problems of wrong characters on the console... CORE-10584 #resolve [CONUTILS]: Remove the now unneeded compatibility defines. CORE-10504 Modified: trunk/reactos/base/applications/network/net/CMakeLists.txt trunk/reactos/base/applications/network/net/cmdAccounts.c trunk/reactos/base/applications/network/net/cmdContinue.c trunk/reactos/base/applications/network/net/cmdHelpMsg.c trunk/reactos/base/applications/network/net/cmdLocalGroup.c trunk/reactos/base/applications/network/net/cmdPause.c trunk/reactos/base/applications/network/net/cmdStart.c trunk/reactos/base/applications/network/net/cmdStop.c trunk/reactos/base/applications/network/net/cmdUse.c trunk/reactos/base/applications/network/net/cmdUser.c trunk/reactos/base/applications/network/net/help.c trunk/reactos/base/applications/network/net/main.c trunk/reactos/base/applications/network/net/net.h trunk/reactos/base/applications/network/wlanconf/CMakeLists.txt trunk/reactos/base/applications/network/wlanconf/wlanconf.c trunk/reactos/base/system/diskpart/CMakeLists.txt trunk/reactos/base/system/diskpart/active.c trunk/reactos/base/system/diskpart/automount.c trunk/reactos/base/system/diskpart/break.c trunk/reactos/base/system/diskpart/diskpart.c trunk/reactos/base/system/diskpart/diskpart.h trunk/reactos/base/system/diskpart/help.c trunk/reactos/base/system/diskpart/interpreter.c trunk/reactos/base/system/diskpart/list.c trunk/reactos/base/system/diskpart/online.c trunk/reactos/base/system/diskpart/partlist.c trunk/reactos/base/system/diskpart/repair.c trunk/reactos/base/system/diskpart/rescan.c trunk/reactos/base/system/diskpart/select.c trunk/reactos/sdk/lib/conutils/conutils.h Modified: trunk/reactos/base/applications/network/net/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -1,5 +1,7 @@ add_definitions(-D__USE_W32_SOCKETS) + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) list(APPEND SOURCE main.c @@ -17,6 +19,7 @@ add_executable(net ${SOURCE} net.rc) set_module_type(net win32cui UNICODE) -add_importlibs(net advapi32 netapi32 msvcrt kernel32 user32 ntdll mpr) +target_link_libraries(net conutils ${PSEH_LIB}) +add_importlibs(net advapi32 netapi32 mpr msvcrt kernel32 ntdll) add_pch(net net.h SOURCE) add_cd_file(TARGET net DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/network/net/cmdAccounts.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdAccounts.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdAccounts.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -36,20 +36,20 @@ if (_wcsicmp(argv[i], L"help") == 0) { /* Print short syntax help */ - PrintResourceString(IDS_ACCOUNTS_SYNTAX); + ConResPuts(StdOut, IDS_ACCOUNTS_SYNTAX); return 0; } if (_wcsicmp(argv[i], L"/help") == 0) { /* Print full help text*/ - PrintResourceString(IDS_ACCOUNTS_HELP); + ConResPuts(StdOut, IDS_ACCOUNTS_HELP); return 0; } if (_wcsicmp(argv[i], L"/domain") == 0) { - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); #if 0 Domain = TRUE; #endif @@ -75,7 +75,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/FORCELOGOFF"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/FORCELOGOFF"); result = 1; goto done; } @@ -90,7 +90,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWLEN"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWLEN"); result = 1; goto done; } @@ -112,7 +112,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MAXPWLEN"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/MAXPWLEN"); result = 1; goto done; } @@ -127,7 +127,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWAGE"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWAGE"); result = 1; goto done; } @@ -141,7 +141,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/UNIQUEPW"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/UNIQUEPW"); result = 1; goto done; } @@ -171,61 +171,61 @@ PrintPaddedResourceString(IDS_ACCOUNTS_FORCE_LOGOFF, nPaddedLength); if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER) - PrintResourceString(IDS_GENERIC_NEVER); - else - PrintResourceString(IDS_ACCOUNTS_LOGOFF_SECONDS, Info0->usrmod0_force_logoff); - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_GENERIC_NEVER); + else + ConResPrintf(StdOut, IDS_ACCOUNTS_LOGOFF_SECONDS, Info0->usrmod0_force_logoff); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_AGE, nPaddedLength); - PrintToConsole(L"%lu\n", Info0->usrmod0_min_passwd_age / 86400); + ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400); PrintPaddedResourceString(IDS_ACCOUNTS_MAX_PW_AGE, nPaddedLength); - PrintToConsole(L"%lu\n", Info0->usrmod0_max_passwd_age / 86400); + ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400); PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_LENGTH, nPaddedLength); - PrintToConsole(L"%lu\n", Info0->usrmod0_min_passwd_len); + ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len); PrintPaddedResourceString(IDS_ACCOUNTS_PW_HIST_LENGTH, nPaddedLength); if (Info0->usrmod0_password_hist_len == 0) - PrintResourceString(IDS_GENERIC_NONE); - else - PrintToConsole(L"%lu", Info0->usrmod0_password_hist_len); - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_GENERIC_NONE); + else + ConPrintf(StdOut, L"%lu", Info0->usrmod0_password_hist_len); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_THRESHOLD, nPaddedLength); if (Info3->usrmod3_lockout_threshold == 0) - PrintResourceString(IDS_GENERIC_NEVER); - else - PrintToConsole(L"%lu", Info3->usrmod3_lockout_threshold); - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_GENERIC_NEVER); + else + ConPrintf(StdOut, L"%lu", Info3->usrmod3_lockout_threshold); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_DURATION, nPaddedLength); - PrintToConsole(L"%lu\n", Info3->usrmod3_lockout_duration / 60); + ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60); PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_WINDOW, nPaddedLength); - PrintToConsole(L"%lu\n", Info3->usrmod3_lockout_observation_window / 60); + ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_observation_window / 60); PrintPaddedResourceString(IDS_ACCOUNTS_COMPUTER_ROLE, nPaddedLength); if (Info1->usrmod1_role == UAS_ROLE_PRIMARY) { if (ProductType == NtProductLanManNt) { - PrintResourceString(IDS_ACCOUNTS_PRIMARY_SERVER); + ConResPuts(StdOut, IDS_ACCOUNTS_PRIMARY_SERVER); } else if (ProductType == NtProductServer) { - PrintResourceString(IDS_ACCOUNTS_STANDALONE_SERVER); + ConResPuts(StdOut, IDS_ACCOUNTS_STANDALONE_SERVER); } else { - PrintResourceString(IDS_ACCOUNTS_WORKSTATION); - } - } - else - { - PrintResourceString(IDS_ACCOUNTS_BACKUP_SERVER); - } - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_ACCOUNTS_WORKSTATION); + } + } + else + { + ConResPuts(StdOut, IDS_ACCOUNTS_BACKUP_SERVER); + } + ConPuts(StdOut, L"\n"); } done: Modified: trunk/reactos/base/applications/network/net/cmdContinue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -19,7 +19,7 @@ if (argc != 3) { - PrintResourceString(IDS_CONTINUE_SYNTAX); + ConResPuts(StdOut, IDS_CONTINUE_SYNTAX); return 1; } @@ -27,7 +27,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_CONTINUE_HELP); + ConResPuts(StdOut, IDS_CONTINUE_HELP); return 1; } } @@ -35,7 +35,7 @@ hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE); if (hManager == NULL) { - printf("[OpenSCManager] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError()); nError = 1; goto done; } @@ -43,14 +43,14 @@ hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE); if (hService == NULL) { - printf("[OpenService] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError()); nError = 1; goto done; } if (!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status)) { - printf("[ControlService] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError()); nError = 1; } Modified: trunk/reactos/base/applications/network/net/cmdHelpMsg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdHelpMsg.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdHelpMsg.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -13,14 +13,15 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) { + INT i; + LONG errNum; LPWSTR endptr; + // DWORD dwLength = 0; LPWSTR lpBuffer; - LONG errNum; - INT i; if (argc < 3) { - PrintResourceString(IDS_HELPMSG_SYNTAX); + ConResPuts(StdOut, IDS_HELPMSG_SYNTAX); return 1; } @@ -28,7 +29,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_HELPMSG_HELP); + ConResPuts(StdOut, IDS_HELPMSG_HELP); return 1; } } @@ -36,25 +37,27 @@ errNum = wcstol(argv[2], &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_HELPMSG_SYNTAX); + ConResPuts(StdOut, IDS_HELPMSG_SYNTAX); return 1; } - /* Unicode printing is not supported in ReactOS yet */ - if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errNum, - LANG_USER_DEFAULT, - (LPWSTR)&lpBuffer, - 0, - NULL)) + /* Retrieve the message string without appending extra newlines */ + // dwLength = + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, + errNum, + LANG_USER_DEFAULT, + (LPWSTR)&lpBuffer, + 0, NULL); + if (lpBuffer /* && dwLength */) { - PrintToConsole(L"\n%s\n", lpBuffer); + ConPrintf(StdOut, L"\n%s\n", lpBuffer); LocalFree(lpBuffer); } else { - PrintToConsole(L"Unrecognized error code: %ld\n", errNum); + ConPrintf(StdOut, L"Unrecognized error code: %ld\n", errNum); } return 0; Modified: trunk/reactos/base/applications/network/net/cmdLocalGroup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdLocalGroup.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdLocalGroup.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -38,11 +38,11 @@ if (Status != NERR_Success) return Status; - PrintToConsole(L"\n"); - PrintResourceString(IDS_LOCALGROUP_ALIASES, pServer->sv100_name); - PrintToConsole(L"\n\n"); + ConPuts(StdOut, L"\n"); + ConResPrintf(StdOut, IDS_LOCALGROUP_ALIASES, pServer->sv100_name); + ConPuts(StdOut, L"\n\n"); PrintPadding(L'-', 79); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); NetApiBufferFree(pServer); @@ -64,7 +64,7 @@ for (i = 0; i < dwRead; i++) { if (pBuffer[i].lgrpi0_name) - PrintToConsole(L"*%s\n", pBuffer[i].lgrpi0_name); + ConPrintf(StdOut, L"*%s\n", pBuffer[i].lgrpi0_name); } NetApiBufferFree(pBuffer); @@ -132,23 +132,23 @@ } PrintPaddedResourceString(IDS_LOCALGROUP_ALIAS_NAME, nPaddedLength); - PrintToConsole(L"%s\n", pGroupInfo->lgrpi1_name); + ConPrintf(StdOut, L"%s\n", pGroupInfo->lgrpi1_name); PrintPaddedResourceString(IDS_LOCALGROUP_COMMENT, nPaddedLength); - PrintToConsole(L"%s\n", pGroupInfo->lgrpi1_comment); - - PrintToConsole(L"\n"); - - PrintResourceString(IDS_LOCALGROUP_MEMBERS); - PrintToConsole(L"\n\n"); + ConPrintf(StdOut, L"%s\n", pGroupInfo->lgrpi1_comment); + + ConPuts(StdOut, L"\n"); + + ConResPuts(StdOut, IDS_LOCALGROUP_MEMBERS); + ConPuts(StdOut, L"\n\n"); PrintPadding(L'-', 79); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); for (i = 0; i < dwRead; i++) { if (pNames[i]) - PrintToConsole(L"%s\n", pNames[i]); + ConPrintf(StdOut, L"%s\n", pNames[i]); } done: @@ -192,13 +192,13 @@ if (argc == 2) { Status = EnumerateLocalGroups(); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } else if (argc == 3) { Status = DisplayLocalGroup(argv[2]); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } @@ -217,7 +217,7 @@ dwMemberCount++; } - printf("Member count: %lu\n", dwMemberCount); + ConPrintf(StdOut, L"Member count: %lu\n", dwMemberCount); if (dwMemberCount > 0) { @@ -242,7 +242,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_LOCALGROUP_HELP); + ConResPuts(StdOut, IDS_LOCALGROUP_HELP); return 0; } else if (_wcsicmp(argv[i], L"/add") == 0) @@ -259,7 +259,7 @@ } else if (_wcsicmp(argv[i], L"/domain") == 0) { - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); #if 0 bDomain = TRUE; #endif @@ -284,18 +284,18 @@ } #if 0 - printf("Group:\n %S\n", lpGroupName); + ConPrintf(StdOut, L"Group:\n %s\n", lpGroupName); if (lpMembers != NULL) { - printf("\nMembers:\n"); + ConPuts(StdOut, L"\nMembers:\n"); for (i = 0; i < dwMemberCount; i++) - printf(" %S\n", lpMembers[i].lgrmi3_domainandname); + ConPrintf(StdOut, L" %s\n", lpMembers[i].lgrmi3_domainandname); } if (lpComment != NULL) { - printf("\nComment:\n %S\n", lpComment); + ConPrintf(StdOut, L"\nComment:\n %s\n", lpComment); } #endif @@ -310,7 +310,7 @@ 1002, (LPBYTE)&Info1002, NULL); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else if (bAdd && !bDelete) { @@ -329,14 +329,14 @@ (lpComment == NULL) ? 0 : 1, (lpComment == NULL) ? (LPBYTE)&Info0 : (LPBYTE)&Info1, NULL); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else if (!bAdd && bDelete && lpComment == NULL) { /* Delete the group */ Status = NetLocalGroupDel(NULL, lpGroupName); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else { @@ -353,7 +353,7 @@ 3, (LPBYTE)lpMembers, dwMemberCount); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else if (!bAdd && bDelete && lpComment == NULL) { @@ -363,7 +363,7 @@ 3, (LPBYTE)lpMembers, dwMemberCount); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else { @@ -376,7 +376,7 @@ RtlFreeHeap(RtlGetProcessHeap(), 0, lpMembers); if (result != 0) - PrintResourceString(IDS_LOCALGROUP_SYNTAX); + ConResPuts(StdOut, IDS_LOCALGROUP_SYNTAX); return result; } Modified: trunk/reactos/base/applications/network/net/cmdPause.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdPause.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdPause.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -19,7 +19,7 @@ if (argc != 3) { - PrintResourceString(IDS_PAUSE_SYNTAX); + ConResPuts(StdOut, IDS_PAUSE_SYNTAX); return 1; } @@ -27,7 +27,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_PAUSE_HELP); + ConResPuts(StdOut, IDS_PAUSE_HELP); return 1; } } @@ -35,7 +35,7 @@ hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE); if (hManager == NULL) { - printf("[OpenSCManager] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError()); nError = 1; goto done; } @@ -43,14 +43,14 @@ hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE); if (hService == NULL) { - printf("[OpenService] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError()); nError = 1; goto done; } if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status)) { - printf("[ControlService] Error: %ld\n", GetLastError()); + ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError()); } done: Modified: trunk/reactos/base/applications/network/net/cmdStart.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdStart.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdStart.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -19,7 +19,7 @@ DWORD dwBufferSize = 0; DWORD dwServiceCount; DWORD dwResumeHandle = 0; - LPENUM_SERVICE_STATUS lpServiceBuffer = NULL; + LPENUM_SERVICE_STATUSW lpServiceBuffer = NULL; INT i; INT nError = 0; DWORD dwError = ERROR_SUCCESS; @@ -57,11 +57,11 @@ &dwServiceCount, &dwResumeHandle)) { - PrintToConsole(L"The following services hav been started:\n\n"); + ConPuts(StdOut, L"The following services hav been started:\n\n"); for (i = 0; i < dwServiceCount; i++) { - PrintToConsole(L" %s\n", lpServiceBuffer[i].lpDisplayName); + ConPrintf(StdOut, L" %s\n", lpServiceBuffer[i].lpDisplayName); } } @@ -79,7 +79,7 @@ if (dwError != ERROR_SUCCESS) { /* FIXME: Print proper error message */ - printf("Error: %lu\n", dwError); + ConPrintf(StdErr, L"Error: %lu\n", dwError); } return nError; @@ -153,7 +153,7 @@ if (dwError != ERROR_SUCCESS) { /* FIXME: Print proper error message */ - printf("Error: %lu\n", dwError); + ConPrintf(StdErr, L"Error: %lu\n", dwError); } return nError; @@ -173,7 +173,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_START_HELP); + ConResPuts(StdOut, IDS_START_HELP); return 1; } } Modified: trunk/reactos/base/applications/network/net/cmdStop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdStop.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdStop.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -20,7 +20,7 @@ if (argc != 3) { - PrintResourceString(IDS_STOP_SYNTAX); + ConResPuts(StdOut, IDS_STOP_SYNTAX); return 1; } @@ -28,7 +28,7 @@ { if (_wcsicmp(argv[i], L"/help") == 0) { - PrintResourceString(IDS_STOP_HELP); + ConResPuts(StdOut, IDS_STOP_HELP); return 1; } } @@ -70,7 +70,7 @@ if (dwError != ERROR_SUCCESS) { /* FIXME: Print proper error message */ - printf("Error: %lu\n", dwError); + ConPrintf(StdErr, L"Error: %lu\n", dwError); } return nError; Modified: trunk/reactos/base/applications/network/net/cmdUse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdUse.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdUse.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -22,7 +22,7 @@ DWORD dCount = -1; LPNETRESOURCE lpCur; - printf("%S\t\t\t%S\t\t\t\t%S\n", L"Local", L"Remote", L"Provider"); + ConPrintf(StdOut, L"%s\t\t\t%s\t\t\t\t%s\n", L"Local", L"Remote", L"Provider"); dRet = WNetOpenEnum(RESOURCE_CONNECTED, RESOURCETYPE_DISK, 0, NULL, &hEnum); if (dRet != WN_SUCCESS) @@ -51,7 +51,7 @@ { if (!Local || wcsicmp(lpCur->lpLocalName, Local) == 0) { - printf("%S\t\t\t%S\t\t%S\n", lpCur->lpLocalName, lpCur->lpRemoteName, lpCur->lpProvider); + ConPrintf(StdOut, L"%s\t\t\t%s\t\t%s\n", lpCur->lpLocalName, lpCur->lpRemoteName, lpCur->lpProvider); } lpCur++; @@ -75,7 +75,7 @@ if (argc == 2) { Status = EnumerateConnections(NULL); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } else if (argc == 3) @@ -83,38 +83,38 @@ Len = wcslen(argv[2]); if (Len != 2) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); return 1; } if (!iswalpha(argv[2][0]) || argv[2][1] != L':') { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); return 1; } Status = EnumerateConnections(argv[2]); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } Len = wcslen(argv[2]); if (Len != 1 && Len != 2) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); - printf("Len: %lu\n", Len); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConPrintf(StdOut, L"Len: %lu\n", Len); return 1; } if (Len == 2 && argv[2][1] != L':') { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); return 1; } if (argv[2][0] != L'*' && !iswalpha(argv[2][0])) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); return 1; } @@ -122,7 +122,7 @@ { if (argv[2][0] == L'*') { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName"); return 1; } @@ -138,13 +138,13 @@ Len = wcslen(argv[3]); if (Len < 4) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"Name"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"Name"); return 1; } if (argv[3][0] != L'\\' || argv[3][1] != L'\\') { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"Name"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"Name"); return 1; } @@ -175,7 +175,7 @@ else { HeapFree(GetProcessHeap(), 0, Cpy); - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"Persistent"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"Persistent"); return 1; } } @@ -192,7 +192,7 @@ Status = WNetUseConnection(NULL, &lpNet, NULL, NULL, CONNECT_REDIRECT | (Persist ? CONNECT_UPDATE_PROFILE : 0), Access, &Size, &OutFlags); if (argv[2][0] == L'*' && Status == NO_ERROR && OutFlags == CONNECT_LOCALDRIVE) - printf("%S is now connected to %S\n", argv[3], Access); + ConPrintf(StdOut, L"%s is now connected to %s\n", argv[3], Access); return Status; } Modified: trunk/reactos/base/applications/network/net/cmdUser.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/cmdUser.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/cmdUser.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -38,11 +38,11 @@ if (Status != NERR_Success) return Status; - PrintToConsole(L"\n"); - PrintResourceString(IDS_USER_ACCOUNTS, pServer->sv100_name); - PrintToConsole(L"\n\n"); + ConPuts(StdOut, L"\n"); + ConResPrintf(StdOut, IDS_USER_ACCOUNTS, pServer->sv100_name); + ConPuts(StdOut, L"\n\n"); PrintPadding(L'-', 79); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); NetApiBufferFree(pServer); @@ -67,7 +67,7 @@ for (i = 0; i < dwRead; i++) { if (pBuffer[i].usri0_name) - PrintToConsole(L"%s\n", pBuffer[i].usri0_name); + ConPrintf(StdOut, L"%s\n", pBuffer[i].usri0_name); } NetApiBufferFree(pBuffer); @@ -109,7 +109,7 @@ TimeBuffer, 80); - PrintToConsole(L"%s %s", DateBuffer, TimeBuffer); + ConPrintf(StdOut, L"%s %s", DateBuffer, TimeBuffer); } @@ -181,35 +181,35 @@ goto done; PrintPaddedResourceString(IDS_USER_NAME, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_name); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_name); PrintPaddedResourceString(IDS_USER_FULL_NAME, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_full_name); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_full_name); PrintPaddedResourceString(IDS_USER_COMMENT, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_comment); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_comment); PrintPaddedResourceString(IDS_USER_USER_COMMENT, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_usr_comment); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_usr_comment); PrintPaddedResourceString(IDS_USER_COUNTRY_CODE, nPaddedLength); - PrintToConsole(L"%03ld ()\n", pUserInfo->usri4_country_code); + ConPrintf(StdOut, L"%03ld ()\n", pUserInfo->usri4_country_code); PrintPaddedResourceString(IDS_USER_ACCOUNT_ACTIVE, nPaddedLength); if (pUserInfo->usri4_flags & UF_ACCOUNTDISABLE) - PrintResourceString(IDS_GENERIC_NO); + ConResPuts(StdOut, IDS_GENERIC_NO); else if (pUserInfo->usri4_flags & UF_LOCKOUT) - PrintResourceString(IDS_GENERIC_LOCKED); + ConResPuts(StdOut, IDS_GENERIC_LOCKED); else - PrintResourceString(IDS_GENERIC_YES); - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_GENERIC_YES); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_USER_ACCOUNT_EXPIRES, nPaddedLength); if (pUserInfo->usri4_acct_expires == TIMEQ_FOREVER) - PrintResourceString(IDS_GENERIC_NEVER); + ConResPuts(StdOut, IDS_GENERIC_NEVER); else PrintDateTime(pUserInfo->usri4_acct_expires); - PrintToConsole(L"\n\n"); + ConPuts(StdOut, L"\n\n"); PrintPaddedResourceString(IDS_USER_PW_LAST_SET, nPaddedLength); dwLastSet = GetTimeInSeconds() - pUserInfo->usri4_password_age; @@ -217,51 +217,51 @@ PrintPaddedResourceString(IDS_USER_PW_EXPIRES, nPaddedLength); if ((pUserInfo->usri4_flags & UF_DONT_EXPIRE_PASSWD) || pUserModals->usrmod0_max_passwd_age == TIMEQ_FOREVER) - PrintResourceString(IDS_GENERIC_NEVER); + ConResPuts(StdOut, IDS_GENERIC_NEVER); else PrintDateTime(dwLastSet + pUserModals->usrmod0_max_passwd_age); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_USER_PW_CHANGEABLE, nPaddedLength); PrintDateTime(dwLastSet + pUserModals->usrmod0_min_passwd_age); PrintPaddedResourceString(IDS_USER_PW_REQUIRED, nPaddedLength); - PrintResourceString((pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? IDS_GENERIC_NO : IDS_GENERIC_YES); - PrintToConsole(L"\n"); + ConResPuts(StdOut, (pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? IDS_GENERIC_NO : IDS_GENERIC_YES); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_USER_CHANGE_PW, nPaddedLength); - PrintResourceString((pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? IDS_GENERIC_NO : IDS_GENERIC_YES); - PrintToConsole(L"\n\n"); + ConResPuts(StdOut, (pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? IDS_GENERIC_NO : IDS_GENERIC_YES); + ConPuts(StdOut, L"\n\n"); PrintPaddedResourceString(IDS_USER_WORKSTATIONS, nPaddedLength); if (pUserInfo->usri4_workstations == NULL || wcslen(pUserInfo->usri4_workstations) == 0) - PrintResourceString(IDS_GENERIC_ALL); + ConResPuts(StdOut, IDS_GENERIC_ALL); else - PrintToConsole(L"%s", pUserInfo->usri4_workstations); - PrintToConsole(L"\n"); + ConPrintf(StdOut, L"%s", pUserInfo->usri4_workstations); + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_USER_LOGON_SCRIPT, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_script_path); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_script_path); PrintPaddedResourceString(IDS_USER_PROFILE, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_profile); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_profile); PrintPaddedResourceString(IDS_USER_HOME_DIR, nPaddedLength); - PrintToConsole(L"%s\n", pUserInfo->usri4_home_dir); + ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_home_dir); PrintPaddedResourceString(IDS_USER_LAST_LOGON, nPaddedLength); if (pUserInfo->usri4_last_logon == 0) - PrintResourceString(IDS_GENERIC_NEVER); + ConResPuts(StdOut, IDS_GENERIC_NEVER); else PrintDateTime(pUserInfo->usri4_last_logon); - PrintToConsole(L"\n\n"); + ConPuts(StdOut, L"\n\n"); PrintPaddedResourceString(IDS_USER_LOGON_HOURS, nPaddedLength); if (pUserInfo->usri4_logon_hours == NULL) - PrintResourceString(IDS_GENERIC_ALL); - PrintToConsole(L"\n\n"); - - PrintToConsole(L"\n"); + ConResPuts(StdOut, IDS_GENERIC_ALL); + ConPuts(StdOut, L"\n\n"); + + ConPuts(StdOut, L"\n"); PrintPaddedResourceString(IDS_USER_LOCAL_GROUPS, nPaddedLength); if (dwLocalGroupTotal != 0 && pLocalGroupInfo != NULL) { @@ -269,12 +269,12 @@ { if (i != 0) PrintPadding(L' ', nPaddedLength); - PrintToConsole(L"*%s\n", pLocalGroupInfo[i].lgrui0_name); + ConPrintf(StdOut, L"*%s\n", pLocalGroupInfo[i].lgrui0_name); } } else { - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); } PrintPaddedResourceString(IDS_USER_GLOBAL_GROUPS, nPaddedLength); @@ -284,12 +284,12 @@ { if (i != 0) PrintPadding(L' ', nPaddedLength); - PrintToConsole(L"*%s\n", pGroupInfo[i].grui0_name); + ConPrintf(StdOut, L"*%s\n", pGroupInfo[i].grui0_name); } } else { - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); } done: @@ -323,13 +323,13 @@ while (TRUE) { - PrintResourceString(IDS_USER_ENTER_PASSWORD1); + ConResPuts(StdOut, IDS_USER_ENTER_PASSWORD1); ReadFromConsole(szPassword1, PWLEN + 1, FALSE); - PrintToConsole(L"\n"); - - PrintResourceString(IDS_USER_ENTER_PASSWORD2); + ConPuts(StdOut, L"\n"); + + ConResPuts(StdOut, IDS_USER_ENTER_PASSWORD2); ReadFromConsole(szPassword2, PWLEN + 1, FALSE); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); if (wcslen(szPassword1) == wcslen(szPassword2) && wcscmp(szPassword1, szPassword2) == 0) @@ -347,9 +347,9 @@ } else { - PrintToConsole(L"\n"); - PrintResourceString(IDS_USER_NO_PASSWORD_MATCH); - PrintToConsole(L"\n"); + ConPuts(StdOut, L"\n"); + ConResPuts(StdOut, IDS_USER_NO_PASSWORD_MATCH); + ConPuts(StdOut, L"\n"); *lpPassword = NULL; } } @@ -381,13 +381,13 @@ if (argc == 2) { Status = EnumerateUsers(); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } else if (argc == 3) { Status = DisplayUser(argv[2]); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } @@ -395,14 +395,14 @@ if (argv[i][0] != L'/') { lpUserName = argv[i]; -// printf("User: %S\n", lpUserName); +// ConPrintf(StdOut, L"User: %s\n", lpUserName); i++; } if (argv[i][0] != L'/') { lpPassword = argv[i]; -// printf("Password: %S\n", lpPassword); +// ConPrintf(StdOut, L"Password: %s\n", lpPassword); i++; } @@ -410,7 +410,7 @@ { if (_wcsicmp(argv[j], L"/help") == 0) { - PrintResourceString(IDS_USER_HELP); + ConResPuts(StdOut, IDS_USER_HELP); return 0; } else if (_wcsicmp(argv[j], L"/add") == 0) @@ -423,7 +423,7 @@ } else if (_wcsicmp(argv[j], L"/domain") == 0) { - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN"); #if 0 bDomain = TRUE; #endif @@ -452,7 +452,7 @@ (LPBYTE*)&pUserInfo); if (Status != NERR_Success) { - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); result = 1; goto done; } @@ -484,7 +484,7 @@ } else { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/ACTIVE"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/ACTIVE"); result = 1; goto done; } @@ -499,7 +499,7 @@ value = wcstoul(p, &endptr, 10); if (*endptr != 0) { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/COUNTRYCODE"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/COUNTRYCODE"); result = 1; goto done; } @@ -518,7 +518,7 @@ else { /* FIXME: Parse the date */ - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/EXPIRES"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/EXPIRES"); } } else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0) @@ -542,7 +542,7 @@ } else { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDCHG"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDCHG"); result = 1; goto done; } @@ -560,7 +560,7 @@ } else { - PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDREQ"); + ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDREQ"); result = 1; goto done; } @@ -576,7 +576,7 @@ else if (_wcsnicmp(argv[j], L"/times:", 7) == 0) { /* FIXME */ - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/TIMES"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/TIMES"); } else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0) { @@ -585,7 +585,7 @@ else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0) { /* FIXME */ - PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/WORKSTATIONS"); + ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/WORKSTATIONS"); } } @@ -597,7 +597,7 @@ 4, (LPBYTE)pUserInfo, NULL); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else if (bAdd && !bDelete) { @@ -606,14 +606,14 @@ 4, (LPBYTE)pUserInfo, NULL); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } else if (!bAdd && bDelete) { /* Delete the user */ Status = NetUserDel(NULL, lpUserName); - printf("Status: %lu\n", Status); + ConPrintf(StdOut, L"Status: %lu\n", Status); } done: @@ -624,7 +624,7 @@ NetApiBufferFree(pUserInfo); if (result != 0) - PrintResourceString(IDS_USER_SYNTAX); + ConResPuts(StdOut, IDS_USER_SYNTAX); return result; } Modified: trunk/reactos/base/applications/network/net/help.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/help.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/help.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -13,133 +13,133 @@ { if (argc != 3) { - PrintResourceString(IDS_HELP_SYNTAX); + ConResPuts(StdOut, IDS_HELP_SYNTAX); return 0; } if (_wcsicmp(argv[2],L"ACCOUNTS") == 0) { - PrintResourceString(IDS_ACCOUNTS_HELP); + ConResPuts(StdOut, IDS_ACCOUNTS_HELP); return 0; } if (_wcsicmp(argv[2],L"COMPUTER") == 0) { - PrintResourceString(IDS_COMPUTER_HELP); + ConResPuts(StdOut, IDS_COMPUTER_HELP); return 0; } if (_wcsicmp(argv[2],L"CONFIG") == 0) { - PrintResourceString(IDS_CONFIG_HELP); + ConResPuts(StdOut, IDS_CONFIG_HELP); return 0; } if (_wcsicmp(argv[2],L"CONTINUE") == 0) { - PrintResourceString(IDS_CONTINUE_HELP); + ConResPuts(StdOut, IDS_CONTINUE_HELP); return 0; } if (_wcsicmp(argv[2],L"FILE") == 0) { - PrintResourceString(IDS_FILE_HELP); + ConResPuts(StdOut, IDS_FILE_HELP); return 0; } if (_wcsicmp(argv[2],L"GROUP") == 0) { - PrintResourceString(IDS_GROUP_HELP); + ConResPuts(StdOut, IDS_GROUP_HELP); return 0; } if (_wcsicmp(argv[2],L"HELPMSG") == 0) { - PrintResourceString(IDS_HELPMSG_HELP); + ConResPuts(StdOut, IDS_HELPMSG_HELP); return 0; } if (_wcsicmp(argv[2],L"LOCALGROUP") == 0) { - PrintResourceString(IDS_LOCALGROUP_HELP); + ConResPuts(StdOut, IDS_LOCALGROUP_HELP); return 0; } if (_wcsicmp(argv[2],L"NAME") == 0) { - PrintResourceString(IDS_NAME_HELP); + ConResPuts(StdOut, IDS_NAME_HELP); return 0; } if (_wcsicmp(argv[2],L"PAUSE") == 0) { - PrintResourceString(IDS_PAUSE_HELP); + ConResPuts(StdOut, IDS_PAUSE_HELP); return 0; } if (_wcsicmp(argv[2],L"PRINT") == 0) { - PrintResourceString(IDS_PRINT_HELP); + ConResPuts(StdOut, IDS_PRINT_HELP); return 0; } if (_wcsicmp(argv[2],L"SEND") == 0) { - PrintResourceString(IDS_SEND_HELP); + ConResPuts(StdOut, IDS_SEND_HELP); return 0; } if (_wcsicmp(argv[2],L"SESSION") == 0) { - PrintResourceString(IDS_SESSION_HELP); + ConResPuts(StdOut, IDS_SESSION_HELP); return 0; } if (_wcsicmp(argv[2],L"SHARE") == 0) { - PrintResourceString(IDS_SHARE_HELP); + ConResPuts(StdOut, IDS_SHARE_HELP); return 0; } if (_wcsicmp(argv[2],L"START") == 0) { - PrintResourceString(IDS_START_HELP); + ConResPuts(StdOut, IDS_START_HELP); return 0; } if (_wcsicmp(argv[2],L"STATISTICS") == 0) { - PrintResourceString(IDS_STATISTICS_HELP); + ConResPuts(StdOut, IDS_STATISTICS_HELP); return 0; } if (_wcsicmp(argv[2],L"STOP") == 0) { - PrintResourceString(IDS_STOP_HELP); + ConResPuts(StdOut, IDS_STOP_HELP); return 0; } if (_wcsicmp(argv[2],L"TIME") == 0) { - PrintResourceString(IDS_TIME_HELP); + ConResPuts(StdOut, IDS_TIME_HELP); return 0; } if (_wcsicmp(argv[2],L"USE") == 0) { - PrintResourceString(IDS_USE_HELP); + ConResPuts(StdOut, IDS_USE_HELP); return 0; } if (_wcsicmp(argv[2],L"USER") == 0) { - PrintResourceString(IDS_USER_HELP); + ConResPuts(StdOut, IDS_USER_HELP); return 0; } if (_wcsicmp(argv[2],L"VIEW") == 0) { - PrintResourceString(IDS_VIEW_HELP); + ConResPuts(StdOut, IDS_VIEW_HELP); return 0; } @@ -155,7 +155,7 @@ } #endif - PrintResourceString(IDS_HELP_SYNTAX); + ConResPuts(StdOut, IDS_HELP_SYNTAX); return 0; } Modified: trunk/reactos/base/applications/network/net/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/main.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/main.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -46,41 +46,17 @@ }; -VOID -PrintResourceString( - INT resID, - ...) -{ - WCHAR szMsgBuffer[MAX_BUFFER_SIZE]; - WCHAR szOutBuffer[MAX_BUFFER_SIZE]; - va_list arg_ptr; - - va_start(arg_ptr, resID); - LoadStringW(GetModuleHandle(NULL), resID, szMsgBuffer, MAX_BUFFER_SIZE); - _vsnwprintf(szOutBuffer, MAX_BUFFER_SIZE, szMsgBuffer, arg_ptr); - va_end(arg_ptr); - - WriteToConsole(szOutBuffer); -} - VOID PrintPaddedResourceString( - INT resID, + UINT uID, INT nPaddedLength) { - WCHAR szMsgBuffer[MAX_BUFFER_SIZE]; - INT nLength, i; + INT nLength; - nLength = LoadStringW(GetModuleHandle(NULL), resID, szMsgBuffer, MAX_BUFFER_SIZE); + nLength = ConResPuts(StdOut, uID); if (nLength < nPaddedLength) - { - for (i = nLength; i < nPaddedLength; i++) - szMsgBuffer[i] = L' '; - szMsgBuffer[nPaddedLength] = UNICODE_NULL; - } - - WriteToConsole(szMsgBuffer); + PrintPadding(L' ', nPaddedLength - nLength); } @@ -89,68 +65,14 @@ WCHAR chr, INT nPaddedLength) { + INT i; WCHAR szMsgBuffer[MAX_BUFFER_SIZE]; - INT i; for (i = 0; i < nPaddedLength; i++) szMsgBuffer[i] = chr; szMsgBuffer[nPaddedLength] = UNICODE_NULL; - WriteToConsole(szMsgBuffer); -} - - -VOID -PrintToConsole( - LPWSTR lpFormat, - ...) -{ - WCHAR szBuffer[MAX_BUFFER_SIZE]; - va_list arg_ptr; - - va_start(arg_ptr, lpFormat); - _vsnwprintf(szBuffer, MAX_BUFFER_SIZE, lpFormat, arg_ptr); - va_end(arg_ptr); - - WriteToConsole(szBuffer); -} - - -VOID -WriteToConsole( - LPWSTR lpString) -{ - CHAR szOemBuffer[MAX_BUFFER_SIZE * 2]; - HANDLE hOutput; - DWORD dwLength; - - dwLength = wcslen(lpString); - - hOutput = GetStdHandle(STD_OUTPUT_HANDLE); - if ((GetFileType(hOutput) & ~FILE_TYPE_REMOTE) == FILE_TYPE_CHAR) - { - WriteConsoleW(hOutput, - lpString, - dwLength, - &dwLength, - NULL); - } - else - { - dwLength = WideCharToMultiByte(CP_OEMCP, - 0, - lpString, - dwLength, - szOemBuffer, - MAX_BUFFER_SIZE * 2, - NULL, - NULL); - WriteFile(hOutput, - szOemBuffer, - dwLength, - &dwLength, - NULL); - } + ConPuts(StdOut, szMsgBuffer); } @@ -195,9 +117,12 @@ { PCOMMAND cmdptr; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if (argc < 2) { - PrintResourceString(IDS_NET_SYNTAX); + ConResPuts(StdOut, IDS_NET_SYNTAX); return 1; } @@ -210,13 +135,13 @@ } } - PrintResourceString(IDS_NET_SYNTAX); + ConResPuts(StdOut, IDS_NET_SYNTAX); return 1; } INT unimplemented(INT argc, WCHAR **argv) { - puts("This command is not implemented yet"); + ConPuts(StdOut, L"This command is not implemented yet\n"); return 1; } Modified: trunk/reactos/base/applications/network/net/net.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/net/net.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/net/net.h [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -7,48 +7,34 @@ #ifndef _NET_PCH_ #define _NET_PCH_ -#define WIN32_NO_STATUS - +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> #include <stdarg.h> +#define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> #include <winnls.h> #include <wincon.h> -#include <winuser.h> #include <winsvc.h> #include <winnetwk.h> -#include <stdio.h> -#include <stdlib.h> -#include <limits.h> #include <lm.h> #include <ndk/rtlfuncs.h> + +#include <conutils.h> #include "resource.h" VOID -PrintResourceString( - INT resID, - ...); - -VOID PrintPaddedResourceString( - INT resID, + UINT uID, INT nPaddedLength); VOID PrintPadding( WCHAR chr, INT nPaddedLength); - -VOID -PrintToConsole( - LPWSTR lpFormat, - ...); - -VOID -WriteToConsole( - LPWSTR lpString); VOID ReadFromConsole( Modified: trunk/reactos/base/applications/network/wlanconf/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/wlanconf/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/wlanconf/CMakeLists.txt [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -3,7 +3,10 @@ BEFORE include ${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers/ndisuio) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + add_executable(wlanconf wlanconf.c wlanconf.rc) set_module_type(wlanconf win32cui UNICODE) -add_importlibs(wlanconf msvcrt user32 iphlpapi kernel32) +target_link_libraries(wlanconf conutils ${PSEH_LIB}) +add_importlibs(wlanconf msvcrt iphlpapi kernel32) add_cd_file(TARGET wlanconf DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -6,21 +6,20 @@ * COPYRIGHT: Copyright 2012 Cameron Gutman (cameron.gutman(a)reactos.org) */ +#include <stdio.h> #include <stdarg.h> +#include <tchar.h> + #include <windef.h> #include <winbase.h> -#include <winuser.h> #include <devioctl.h> -#include <tchar.h> -#include <stdio.h> #include <ntddndis.h> #include <nuiouser.h> #include <iphlpapi.h> +#include <conutils.h> + #include "resource.h" - -#define COUNT_OF(a) (sizeof(a) / sizeof(a[0])) -#define MAX_BUFFER_SIZE 5024 BOOL bScan = FALSE; @@ -31,45 +30,13 @@ BOOL bDisconnect = FALSE; -/* This takes strings from a resource stringtable and outputs it to -the command prompt. */ -VOID PrintResourceString(INT resID, ...) -{ - WCHAR szMsgBuf[MAX_BUFFER_SIZE]; - va_list arg_ptr; - - va_start(arg_ptr, resID); - LoadStringW(GetModuleHandle(NULL), resID, szMsgBuf, MAX_BUFFER_SIZE); - vwprintf(szMsgBuf, arg_ptr); - va_end(arg_ptr); -} - -DWORD DoFormatMessage(DWORD ErrorCode) -{ - LPVOID lpMsgBuf; - DWORD RetVal; - - if ((RetVal = FormatMessageW( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - ErrorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ - (LPWSTR) &lpMsgBuf, - 0, - NULL ))) - { - printf("%S", (LPWSTR)lpMsgBuf); - - LocalFree(lpMsgBuf); - - /* return number of WCHAR's stored in output buffer - * excluding '\0' - as FormatMessage does*/ - return RetVal; - } - else - return 0; +VOID DoFormatMessage(DWORD ErrorCode) +{ + if (ErrorCode == ERROR_SUCCESS) + return; + + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, ErrorCode, LANG_USER_DEFAULT); } HANDLE @@ -279,7 +246,7 @@ if (!bSuccess) return FALSE; - PrintResourceString(IDS_SUCCESS); + ConResPuts(StdOut, IDS_SUCCESS); return TRUE; } @@ -355,13 +322,13 @@ NULL); if (SsidInfo->SsidLength == 0 || !bSuccess) { - PrintResourceString(IDS_WLAN_DISCONNECT); + ConResPuts(StdOut, IDS_WLAN_DISCONNECT); HeapFree(GetProcessHeap(), 0, QueryOid); return TRUE; } else { - PrintResourceString(IDS_MSG_CURRENT_WIRELESS); + ConResPuts(StdOut, IDS_MSG_CURRENT_WIRELESS); } printf("SSID: %s\n", SsidBuffer); @@ -400,11 +367,11 @@ return FALSE; } - LoadStringW(GetModuleHandle(NULL), - *(PUINT)QueryOid->Data == Ndis802_11IBSS ? IDS_ADHOC : IDS_INFRASTRUCTURE, - szMsgBuf, - COUNT_OF(szMsgBuf)); - PrintResourceString(IDS_MSG_NETWORK_MODE, szMsgBuf); + K32LoadStringW(GetModuleHandle(NULL), + *(PUINT)QueryOid->Data == Ndis802_11IBSS ? IDS_ADHOC : IDS_INFRASTRUCTURE, + szMsgBuf, + ARRAYSIZE(szMsgBuf)); + ConResPrintf(StdOut, IDS_MSG_NETWORK_MODE, szMsgBuf); QueryOid->Oid = OID_802_11_WEP_STATUS; @@ -422,11 +389,11 @@ return FALSE; } - LoadStringW(GetModuleHandle(NULL), - *(PUINT)QueryOid->Data == Ndis802_11WEPEnabled ? IDS_YES : IDS_NO, - szMsgBuf, - COUNT_OF(szMsgBuf)); - PrintResourceString(IDS_MSG_WEP_ENABLED, szMsgBuf); + K32LoadStringW(GetModuleHandle(NULL), + *(PUINT)QueryOid->Data == Ndis802_11WEPEnabled ? IDS_YES : IDS_NO, + szMsgBuf, + ARRAYSIZE(szMsgBuf)); + ConResPrintf(StdOut, IDS_MSG_WEP_ENABLED, szMsgBuf); printf("\n"); QueryOid->Oid = OID_802_11_RSSI; @@ -458,7 +425,7 @@ if (bSuccess) { /* This OID is optional */ - PrintResourceString(IDS_MSG_TRANSMISSION_POWER, *(PUINT)QueryOid->Data); + ConResPrintf(StdOut, IDS_MSG_TRANSMISSION_POWER, *(PUINT)QueryOid->Data); } printf("\n"); @@ -476,7 +443,7 @@ if (bSuccess) { /* This OID is optional */ - PrintResourceString(IDS_MSG_ANTENNA_COUNT, *(PUINT)QueryOid->Data); + ConResPrintf(StdOut, IDS_MSG_ANTENNA_COUNT, *(PUINT)QueryOid->Data); } QueryOid->Oid = OID_802_11_TX_ANTENNA_SELECTED; @@ -494,9 +461,9 @@ UINT TransmitAntenna = *(PUINT)QueryOid->Data; if (TransmitAntenna != 0xFFFFFFFF) - PrintResourceString(IDS_MSG_TRANSMIT_ANTENNA, TransmitAntenna); + ConResPrintf(StdOut, IDS_MSG_TRANSMIT_ANTENNA, TransmitAntenna); else - PrintResourceString(IDS_MSG_TRANSMIT_ANTENNA_ANY); + ConResPuts(StdOut, IDS_MSG_TRANSMIT_ANTENNA_ANY); } QueryOid->Oid = OID_802_11_RX_ANTENNA_SELECTED; @@ -514,9 +481,9 @@ UINT ReceiveAntenna = *(PUINT)QueryOid->Data; if (ReceiveAntenna != 0xFFFFFFFF) - PrintResourceString(IDS_MSG_RECEIVE_ANTENNA, ReceiveAntenna); + ConResPrintf(StdOut, IDS_MSG_RECEIVE_ANTENNA, ReceiveAntenna); else - PrintResourceString(IDS_MSG_RECEIVE_ANTENNA_ANY); + ConResPuts(StdOut, IDS_MSG_RECEIVE_ANTENNA_ANY); } printf("\n"); @@ -534,7 +501,7 @@ if (bSuccess) { /* This OID is optional */ - PrintResourceString(IDS_MSG_FRAGMENT_THRESHOLD, *(PUINT)QueryOid->Data); + ConResPrintf(StdOut, IDS_MSG_FRAGMENT_THRESHOLD, *(PUINT)QueryOid->Data); } QueryOid->Oid = OID_802_11_RTS_THRESHOLD; @@ -550,7 +517,7 @@ if (bSuccess) { /* This OID is optional */ - PrintResourceString(IDS_MSG_RTS_THRESHOLD, *(PUINT)QueryOid->Data); + ConResPrintf(StdOut, IDS_MSG_RTS_THRESHOLD, *(PUINT)QueryOid->Data); } HeapFree(GetProcessHeap(), 0, QueryOid); @@ -725,7 +692,7 @@ if (!bSuccess) return FALSE; - PrintResourceString(IDS_SUCCESS); + ConResPuts(StdOut, IDS_SUCCESS); return TRUE; } @@ -802,7 +769,7 @@ if (BssidList->NumberOfItems == 0) { - PrintResourceString(IDS_NO_NETWORK); + ConResPuts(StdOut, IDS_NO_NETWORK); } else { @@ -833,18 +800,18 @@ } printf("\n"); - LoadStringW(GetModuleHandle(NULL), - BssidInfo->Privacy == 0 ? IDS_NO : IDS_YES, - szMsgBuf, - COUNT_OF(szMsgBuf)); - PrintResourceString(IDS_MSG_ENCRYPTED, szMsgBuf); - LoadStringW(GetModuleHandle(NULL), - NetworkType == Ndis802_11IBSS ? IDS_ADHOC : IDS_INFRASTRUCTURE, - szMsgBuf, - COUNT_OF(szMsgBuf)); - PrintResourceString(IDS_MSG_NETWORK_TYPE, szMsgBuf); - PrintResourceString(IDS_MSG_RSSI, (int)Rssi); - PrintResourceString(IDS_MSG_SUPPORT_RATE); + K32LoadStringW(GetModuleHandle(NULL), + BssidInfo->Privacy == 0 ? IDS_NO : IDS_YES, + szMsgBuf, + ARRAYSIZE(szMsgBuf)); + ConResPrintf(StdOut, IDS_MSG_ENCRYPTED, szMsgBuf); + K32LoadStringW(GetModuleHandle(NULL), + NetworkType == Ndis802_11IBSS ? IDS_ADHOC : IDS_INFRASTRUCTURE, + szMsgBuf, + ARRAYSIZE(szMsgBuf)); + ConResPrintf(StdOut, IDS_MSG_NETWORK_TYPE, szMsgBuf); + ConResPrintf(StdOut, IDS_MSG_RSSI, (int)Rssi); + ConResPuts(StdOut, IDS_MSG_SUPPORT_RATE); for (j = 0; j < NDIS_802_11_LENGTH_RATES; j++) { @@ -898,7 +865,7 @@ case L'c': if (i == argc - 1) { - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return FALSE; } bConnect = TRUE; @@ -907,7 +874,7 @@ case L'w': if (i == argc - 1) { - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return FALSE; } sWepKey = argv[++i]; @@ -916,14 +883,14 @@ bAdhoc = TRUE; break; default : - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return FALSE; } } else { - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return FALSE; } } @@ -936,12 +903,15 @@ HANDLE hAdapter; IP_ADAPTER_INDEX_MAP IpInfo; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if (!ParseCmdline(argc, argv)) return -1; if (!OpenWlanAdapter(&hAdapter, &IpInfo)) { - PrintResourceString(IDS_NO_WLAN_ADAPTER); + ConResPuts(StdOut, IDS_NO_WLAN_ADAPTER); return -1; } Modified: trunk/reactos/base/system/diskpart/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/CMake…
============================================================================== --- trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -1,3 +1,5 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) list(APPEND SOURCE active.c @@ -43,7 +45,8 @@ add_executable(diskpart ${SOURCE} diskpart.rc) set_module_type(diskpart win32cui UNICODE) -add_importlibs(diskpart user32 advapi32 msvcrt kernel32 ntdll) +target_link_libraries(diskpart conutils ${PSEH_LIB}) +add_importlibs(diskpart advapi32 msvcrt kernel32 ntdll) if(MSVC) add_importlibs(diskpart ntdll) Modified: trunk/reactos/base/system/diskpart/active.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/activ…
============================================================================== --- trunk/reactos/base/system/diskpart/active.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/active.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,7 +10,6 @@ BOOL active_main(INT argc, LPWSTR *argv) { - printf("\nActive\n"); - + ConPuts(StdOut, L"\nActive\n"); return TRUE; } Modified: trunk/reactos/base/system/diskpart/automount.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/autom…
============================================================================== --- trunk/reactos/base/system/diskpart/automount.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/automount.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,6 +10,6 @@ BOOL automount_main(INT argc, LPWSTR *argv) { - printf("Automount\n"); + ConPuts(StdOut, L"Automount\n"); return TRUE; } Modified: trunk/reactos/base/system/diskpart/break.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/break…
============================================================================== --- trunk/reactos/base/system/diskpart/break.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/break.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,7 +10,6 @@ BOOL break_main(INT argc, LPWSTR *argv) { - printf("\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n"); - + ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n"); return TRUE; } Modified: trunk/reactos/base/system/diskpart/diskpart.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/diskp…
============================================================================== --- trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,24 +10,7 @@ #include "diskpart.h" -#include <stdlib.h> -#include <winbase.h> -#include <wincon.h> -#include <winuser.h> - /* FUNCTIONS ******************************************************************/ - -VOID -PrintResourceString(INT resID, ...) -{ - WCHAR szMsg[3072]; - va_list arg_ptr; - - va_start(arg_ptr, resID); - LoadStringW(GetModuleHandle(NULL), resID, szMsg, 3072); - vwprintf(szMsg, arg_ptr); - va_end(arg_ptr); -} VOID ShowHeader(VOID) @@ -39,14 +22,14 @@ GetComputerNameW(szComputerName, &comp_size); /* TODO: Remove this section of code when program becomes stable enough for production use. */ - wprintf(L"\n*WARNING*: This program is incomplete and may not work properly.\n"); + ConPuts(StdOut, L"\n*WARNING*: This program is incomplete and may not work properly.\n"); /* Print the header information */ - wprintf(L"\n"); - PrintResourceString(IDS_APP_HEADER); - wprintf(L"\n"); - PrintResourceString(IDS_APP_LICENSE); - PrintResourceString(IDS_APP_CURR_COMPUTER, szComputerName); + ConPuts(StdOut, L"\n"); + ConResPuts(StdOut, IDS_APP_HEADER); + ConPuts(StdOut, L"\n"); + ConResPuts(StdOut, IDS_APP_LICENSE); + ConResPrintf(StdOut, IDS_APP_CURR_COMPUTER, szComputerName); } /* @@ -65,7 +48,7 @@ if (script == NULL) { /* if there was problems opening the file */ - PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT, filename); + ConResPrintf(StdErr, IDS_ERROR_MSG_NO_SCRIPT, filename); return FALSE; /* if there is no script, exit the program */ } @@ -97,10 +80,13 @@ int index, timeout; int result = EXIT_SUCCESS; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + /* Sets the title of the program so the user will have an easier time determining the current program, especially if diskpart is running a script */ - LoadStringW(GetModuleHandle(NULL), IDS_APP_HEADER, (LPWSTR)appTitle, 50); + K32LoadStringW(GetModuleHandle(NULL), IDS_APP_HEADER, appTitle, ARRAYSIZE(appTitle)); SetConsoleTitleW(appTitle); /* Sets the timeout value to 0 just in case the user doesn't @@ -129,7 +115,7 @@ else { /* If there is no flag, then return an error */ - PrintResourceString(IDS_ERROR_MSG_BAD_ARG, argv[index]); + ConResPrintf(StdErr, IDS_ERROR_MSG_BAD_ARG, argv[index]); result = EXIT_FAILURE; goto done; } @@ -138,7 +124,7 @@ exits as soon as the usage list is shown. */ if (_wcsicmp(tmpBuffer, L"?") == 0) { - PrintResourceString(IDS_APP_USAGE); + ConResPuts(StdOut, IDS_APP_USAGE); result = EXIT_SUCCESS; goto done; } @@ -168,7 +154,7 @@ else { /* Assume that the flag doesn't exist. */ - PrintResourceString(IDS_ERROR_MSG_BAD_ARG, tmpBuffer); + ConResPrintf(StdErr, IDS_ERROR_MSG_BAD_ARG, tmpBuffer); result = EXIT_FAILURE; goto done; } @@ -194,14 +180,14 @@ else { /* Exit failure since the user wanted to run a script */ - PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT, script); + ConResPrintf(StdErr, IDS_ERROR_MSG_NO_SCRIPT, script); result = EXIT_FAILURE; goto done; } } /* Let the user know the program is exiting */ - PrintResourceString(IDS_APP_LEAVING); + ConResPuts(StdOut, IDS_APP_LEAVING); done: DestroyPartitionList(); Modified: trunk/reactos/base/system/diskpart/diskpart.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/diskp…
============================================================================== --- trunk/reactos/base/system/diskpart/diskpart.h [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/diskpart.h [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -18,8 +18,9 @@ #include <windef.h> #include <winbase.h> #include <winreg.h> -#include <winuser.h> #include <wincon.h> + +#include <conutils.h> /* #define NTOS_MODE_USER @@ -223,7 +224,6 @@ BOOL detail_main(INT argc, LPWSTR *argv); /* diskpart.c */ -VOID PrintResourceString(INT resID, ...); /* expand.c */ BOOL expand_main(INT argc, LPWSTR *argv); Modified: trunk/reactos/base/system/diskpart/help.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/help.…
============================================================================== --- trunk/reactos/base/system/diskpart/help.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/help.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -17,14 +17,14 @@ PCOMMAND cmdptr; /* Print the header information */ - PrintResourceString(IDS_APP_HEADER); - printf("\n"); + ConResPuts(StdOut, IDS_APP_HEADER); + ConPuts(StdOut, L"\n"); - /* lists all the commands and the basic descriptions */ - for(cmdptr = cmds; cmdptr->name; cmdptr++) - PrintResourceString(cmdptr->help_desc); + /* List all the commands and the basic descriptions */ + for (cmdptr = cmds; cmdptr->name; cmdptr++) + ConResPuts(StdOut, cmdptr->help_desc); - printf("\n"); + ConPuts(StdOut, L"\n"); } /* help_main(char *arg): @@ -43,9 +43,9 @@ /* Scan internal command table */ for (cmdptr = cmds; cmdptr->name; cmdptr++) { - if(_wcsicmp(argv[1], cmdptr->name) == 0) + if (_wcsicmp(argv[1], cmdptr->name) == 0) { - PrintResourceString(cmdptr->help); + ConResPuts(StdOut, cmdptr->help); return TRUE; } } Modified: trunk/reactos/base/system/diskpart/interpreter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/inter…
============================================================================== --- trunk/reactos/base/system/diskpart/interpreter.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/interpreter.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -152,10 +152,10 @@ args_count = 0; memset(args_vector, 0, sizeof(args_vector)); - /* shown just before the input where the user places commands */ - PrintResourceString(IDS_APP_PROMPT); + /* Shown just before the input where the user places commands */ + ConResPuts(StdOut, IDS_APP_PROMPT); - /* gets input from the user. */ + /* Get input from the user. */ fgetws(input_line, MAX_STRING_SIZE, stdin); ptr = input_line; @@ -178,7 +178,7 @@ ptr++; } - /* sends the string to find the command */ + /* Send the string to find the command */ bRun = InterpretCmd(args_count, args_vector); } } Modified: trunk/reactos/base/system/diskpart/list.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/list.…
============================================================================== --- trunk/reactos/base/system/diskpart/list.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/list.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -35,8 +35,8 @@ LPWSTR lpFreeUnit; /* Header labels */ - PrintResourceString(IDS_LIST_DISK_HEAD); - PrintResourceString(IDS_LIST_DISK_LINE); + ConResPuts(StdOut, IDS_LIST_DISK_HEAD); + ConResPuts(StdOut, IDS_LIST_DISK_LINE); Entry = DiskListHead.Flink; while (Entry != &DiskListHead) @@ -63,21 +63,21 @@ FreeSize = 0; lpFreeUnit = L"B"; - PrintResourceString(IDS_LIST_DISK_FORMAT, - (CurrentDisk == DiskEntry) ? L'*': ' ', - DiskEntry->DiskNumber, - L"Online", - DiskSize, - lpSizeUnit, - FreeSize, - lpFreeUnit, - L" ", - L" "); + ConResPrintf(StdOut, IDS_LIST_DISK_FORMAT, + (CurrentDisk == DiskEntry) ? L'*': ' ', + DiskEntry->DiskNumber, + L"Online", + DiskSize, + lpSizeUnit, + FreeSize, + lpFreeUnit, + L" ", + L" "); Entry = Entry->Flink; } - wprintf(L"\n\n"); + ConPuts(StdOut, L"\n\n"); } static @@ -94,13 +94,13 @@ if (CurrentDisk == NULL) { - PrintResourceString(IDS_LIST_PARTITION_NO_DISK); + ConResPuts(StdOut, IDS_LIST_PARTITION_NO_DISK); return; } /* Header labels */ - PrintResourceString(IDS_LIST_PARTITION_HEAD); - PrintResourceString(IDS_LIST_PARTITION_LINE); + ConResPuts(StdOut, IDS_LIST_PARTITION_HEAD); + ConResPuts(StdOut, IDS_LIST_PARTITION_LINE); Entry = CurrentDisk->PrimaryPartListHead.Flink; while (Entry != &CurrentDisk->PrimaryPartListHead) @@ -145,14 +145,14 @@ lpOffsetUnit = L"KB"; } - PrintResourceString(IDS_LIST_PARTITION_FORMAT, - (CurrentPartition == PartEntry) ? L'*': ' ', - PartNumber++, - IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary", - PartSize, - lpSizeUnit, - PartOffset, - lpOffsetUnit); + ConResPrintf(StdOut, IDS_LIST_PARTITION_FORMAT, + (CurrentPartition == PartEntry) ? L'*': ' ', + PartNumber++, + IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary", + PartSize, + lpSizeUnit, + PartOffset, + lpOffsetUnit); } Entry = Entry->Flink; @@ -201,34 +201,34 @@ lpOffsetUnit = L"KB"; } - PrintResourceString(IDS_LIST_PARTITION_FORMAT, - (CurrentPartition == PartEntry) ? L'*': ' ', - PartNumber++, - L"Logical", - PartSize, - lpSizeUnit, - PartOffset, - lpOffsetUnit); + ConResPrintf(StdOut, IDS_LIST_PARTITION_FORMAT, + (CurrentPartition == PartEntry) ? L'*': ' ', + PartNumber++, + L"Logical", + PartSize, + lpSizeUnit, + PartOffset, + lpOffsetUnit); } Entry = Entry->Flink; } - wprintf(L"\n"); + ConPuts(StdOut, L"\n"); } static VOID ListVolume(VOID) { - PrintResourceString(IDS_LIST_VOLUME_HEAD); + ConResPuts(StdOut, IDS_LIST_VOLUME_HEAD); } static VOID ListVdisk(VOID) { - printf("List VDisk!!\n"); + ConPuts(StdOut, L"List VDisk!!\n"); } BOOL @@ -239,7 +239,7 @@ /* gets the first word from the string */ if (argc == 1) { - PrintResourceString(IDS_HELP_CMD_LIST); + ConResPuts(StdOut, IDS_HELP_CMD_LIST); return TRUE; } @@ -253,7 +253,7 @@ else if (!wcsicmp(argv[1], L"vdisk")) ListVdisk(); else - PrintResourceString(IDS_HELP_CMD_LIST); + ConResPuts(StdOut, IDS_HELP_CMD_LIST); return TRUE; } Modified: trunk/reactos/base/system/diskpart/online.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/onlin…
============================================================================== --- trunk/reactos/base/system/diskpart/online.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/online.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,7 +10,6 @@ BOOL online_main(INT argc, LPWSTR *argv) { - PrintResourceString(IDS_HELP_CMD_ONLINE); - + ConResPuts(StdOut, IDS_HELP_CMD_ONLINE); return TRUE; } Modified: trunk/reactos/base/system/diskpart/partlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/partl…
============================================================================== --- trunk/reactos/base/system/diskpart/partlist.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/partlist.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -9,12 +9,6 @@ /* INCLUDES *******************************************************************/ #include "diskpart.h" - -#include <stdlib.h> -#include <winbase.h> -#include <wincon.h> -#include <winuser.h> - #include <ntddscsi.h> #define NDEBUG Modified: trunk/reactos/base/system/diskpart/repair.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/repai…
============================================================================== --- trunk/reactos/base/system/diskpart/repair.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/repair.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,7 +10,6 @@ BOOL repair_main(INT argc, LPWSTR *argv) { - printf("\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n"); - + ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n"); return TRUE; } Modified: trunk/reactos/base/system/diskpart/rescan.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/resca…
============================================================================== --- trunk/reactos/base/system/diskpart/rescan.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/rescan.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -10,10 +10,10 @@ BOOL rescan_main(INT argc, LPWSTR *argv) { - PrintResourceString(IDS_RESCAN_START); + ConResPuts(StdOut, IDS_RESCAN_START); DestroyPartitionList(); CreatePartitionList(); - PrintResourceString(IDS_RESCAN_END); + ConResPuts(StdOut, IDS_RESCAN_END); return TRUE; } Modified: trunk/reactos/base/system/diskpart/select.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/selec…
============================================================================== --- trunk/reactos/base/system/diskpart/select.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/select.c [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -28,16 +28,16 @@ if (argc > 3) { - PrintResourceString(IDS_ERROR_INVALID_ARGS); + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return; } if (argc == 2) { if (CurrentDisk == NULL) - PrintResourceString(IDS_SELECT_NO_DISK); + ConResPuts(StdOut, IDS_SELECT_NO_DISK); else - PrintResourceString(IDS_SELECT_DISK, CurrentDisk->DiskNumber); + ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber); return; } @@ -45,7 +45,7 @@ if (((lValue == 0) && (endptr == argv[2])) || (lValue < 0)) { - PrintResourceString(IDS_ERROR_INVALID_ARGS); + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return; } @@ -60,14 +60,14 @@ { CurrentDisk = DiskEntry; CurrentPartition = NULL; - PrintResourceString(IDS_SELECT_DISK, CurrentDisk->DiskNumber); + ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber); return; } Entry = Entry->Flink; } - PrintResourceString(IDS_SELECT_DISK_INVALID); + ConResPuts(StdErr, IDS_SELECT_DISK_INVALID); } @@ -87,22 +87,22 @@ if (argc > 3) { - PrintResourceString(IDS_ERROR_INVALID_ARGS); + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return; } if (CurrentDisk == NULL) { - PrintResourceString(IDS_SELECT_PARTITION_NO_DISK); + ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK); return; } if (argc == 2) { if (CurrentPartition == NULL) - PrintResourceString(IDS_SELECT_NO_PARTITION); + ConResPuts(StdOut, IDS_SELECT_NO_PARTITION); else - PrintResourceString(IDS_SELECT_PARTITION, CurrentPartition); + ConResPrintf(StdOut, IDS_SELECT_PARTITION, CurrentPartition); return; } @@ -110,7 +110,7 @@ if (((lValue == 0) && (endptr == argv[2])) || (lValue < 0)) { - PrintResourceString(IDS_ERROR_INVALID_ARGS); + ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return; } @@ -124,7 +124,7 @@ if (PartNumber == (ULONG)lValue) { CurrentPartition = PartEntry; - PrintResourceString(IDS_SELECT_PARTITION, PartNumber); + ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber); return; } @@ -144,7 +144,7 @@ if (PartNumber == (ULONG)lValue) { CurrentPartition = PartEntry; - PrintResourceString(IDS_SELECT_PARTITION, PartNumber); + ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber); return; } @@ -153,7 +153,7 @@ Entry = Entry->Flink; } - PrintResourceString(IDS_SELECT_PARTITION_INVALID); + ConResPuts(StdErr, IDS_SELECT_PARTITION_INVALID); } @@ -165,7 +165,7 @@ /* gets the first word from the string */ if (argc == 1) { - PrintResourceString(IDS_HELP_CMD_SELECT); + ConResPuts(StdOut, IDS_HELP_CMD_SELECT); return TRUE; } @@ -175,7 +175,7 @@ else if (!wcsicmp(argv[1], L"partition")) SelectPartition(argc, argv); else - PrintResourceString(IDS_HELP_CMD_SELECT); + ConResPuts(StdOut, IDS_HELP_CMD_SELECT); return TRUE; } Modified: trunk/reactos/sdk/lib/conutils/conutils.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/conutils.…
============================================================================== --- trunk/reactos/sdk/lib/conutils/conutils.h [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/conutils/conutils.h [iso-8859-1] Fri Oct 7 22:50:32 2016 @@ -243,30 +243,6 @@ ...); -/* - * Those are compatibility #defines for old code! - */ - -/*** tree.c ***/ - -#define PrintStringV(szStr, args) \ - ConPrintfV(StdOut, (szStr), (args)) -#define PrintString(szStr, ...) \ - ConPrintf(StdOut, (szStr), ##__VA_ARGS__) - -/*** network/net/main.c ***/ -#define PrintToConsole(szStr, ...) \ - ConPrintf(StdOut, (szStr), ##__VA_ARGS__) - -/*** clip.c, comp.c, help.c, tree.c ***/ -/*** subst.c ***/ -/*** format.c, network/net/main.c, shutdown.c, wlanconf.c, diskpart.c ***/ - -#define PrintResourceStringV(uID, args) \ - ConResPrintfV(StdOut, (uID), (args)) -#define PrintResourceString(uID, ...) \ - ConResPrintf(StdOut, (uID), ##__VA_ARGS__) - // // TODO: Add Console paged-output printf & ResPrintf functions! //
8 years, 2 months
1
0
0
0
[hbelusca] 72932: [LOGOFF]: Code formatting fixes, including tabs vs. spaces.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 22:08:20 2016 New Revision: 72932 URL:
http://svn.reactos.org/svn/reactos?rev=72932&view=rev
Log: [LOGOFF]: Code formatting fixes, including tabs vs. spaces. Modified: trunk/reactos/base/applications/logoff/logoff.c Modified: trunk/reactos/base/applications/logoff/logoff.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/l…
============================================================================== --- trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] Fri Oct 7 22:08:20 2016 @@ -1,14 +1,14 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS logoff utility - * FILE: base/applications/logoff/logoff.c - * PURPOSE: Logoff current session, or another session, potentially on another machine - * AUTHOR: 30.07.2007 - Frode Lillerud + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS logoff utility + * FILE: base/applications/logoff/logoff.c + * PURPOSE: Logoff current session, or another session, potentially on another machine + * AUTHOR: 30.07.2007 - Frode Lillerud */ /* Note - * This application is a lightweight version of shutdown.exe. It is intended to be function-compatible - * with Windows' system32\logoff.exe commandline application. + * This application is a lightweight version of shutdown.exe. It is intended + * to be function-compatible with Windows' system32\logoff.exe application. */ #include <stdio.h> @@ -21,7 +21,7 @@ #include "resource.h" -// Commandline argument switches +/* Command-line argument switches */ LPWSTR szRemoteServerName = NULL; BOOL bVerbose; @@ -39,37 +39,45 @@ //---------------------------------------------------------------------- // -// Sets flags based on commandline arguments +// Sets flags based on command-line arguments // //---------------------------------------------------------------------- BOOL ParseCommandLine(int argc, WCHAR *argv[]) { - int i; + int i; - //FIXME: Add handling of commandline arguments to select the session number and name, and also name of remote machine - //Example: logoff.exe 4 /SERVER:Master should logoff session number 4 on remote machine called Master. + // FIXME: Add handling of command-line arguments to select + // the session number and name, and also name of remote machine. + // Example: logoff.exe 4 /SERVER:Master + // should logoff session number 4 on remote machine called Master. - for (i = 1; i < argc; i++) { - switch(argv[i][0]){ - case L'-': - case L'/': - // -v (verbose) - if (argv[i][1] == L'v') { - bVerbose = TRUE; - break; //continue parsing the arguments - } - // -? (usage) - else if(argv[i][1] == L'?') { - return FALSE; //display the Usage - } - default: - //Invalid parameter detected - ConResPuts(StdErr, IDS_ILLEGAL_PARAM); - return FALSE; - } - } + for (i = 1; i < argc; i++) + { + switch (argv[i][0]) + { + case L'-': + case L'/': + // -v (verbose) + if (argv[i][1] == L'v') + { + bVerbose = TRUE; + break; + } + // -? (usage) + else if (argv[i][1] == L'?') + { + /* Will display the Usage */ + return FALSE; + } + /* Fall through */ + default: + /* Invalid parameter detected */ + ConResPuts(StdErr, IDS_ILLEGAL_PARAM); + return FALSE; + } + } - return TRUE; + return TRUE; } //---------------------------------------------------------------------- @@ -79,44 +87,43 @@ //---------------------------------------------------------------------- int wmain(int argc, WCHAR *argv[]) { - /* Initialize the Console Standard Streams */ - ConInitStdStreams(); + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); - // - // Parse command line - // - if (!ParseCommandLine(argc, argv)) { - ConResPuts(StdOut, IDS_USAGE); - return 1; - } + /* Parse command line */ + if (!ParseCommandLine(argc, argv)) + { + ConResPuts(StdOut, IDS_USAGE); + return 1; + } - // - // Should we log off session on remote server? - // - if (szRemoteServerName) { - if (bVerbose) { - ConResPuts(StdOut, IDS_LOGOFF_REMOTE); - } + /* Should we log off session on remote server? */ + if (szRemoteServerName) + { + if (bVerbose) + ConResPuts(StdOut, IDS_LOGOFF_REMOTE); - // FIXME: Add Remote Procedure Call to logoff user on a remote machine - ConPuts(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented"); - } - // - // Perform logoff of current session on local machine instead - // - else { - if (bVerbose) { - // Get resource string, and print it. - ConResPuts(StdOut, IDS_LOGOFF_LOCAL); - } + // FIXME: Add Remote Procedure Call to logoff user on a remote machine + ConPuts(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented"); + } + /* Perform logoff of current session on local machine instead */ + else + { + if (bVerbose) + { + /* Get resource string and print it */ + ConResPuts(StdOut, IDS_LOGOFF_LOCAL); + } - // Actual logoff - if (!ExitWindowsEx(EWX_LOGOFF, 0)) { - DisplayError(GetLastError()); - return 1; - } - } + /* Actual logoff */ + if (!ExitWindowsEx(EWX_LOGOFF, 0)) + { + DisplayError(GetLastError()); + return 1; + } + } - return 0; + return 0; } + /* EOF */
8 years, 2 months
1
0
0
0
[hbelusca] 72931: [CONUTILS]: Fix build: - Commit the *Puts functions. - Fix __stdcall that needs to be read __cdecl for variadic functions.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 21:57:59 2016 New Revision: 72931 URL:
http://svn.reactos.org/svn/reactos?rev=72931&view=rev
Log: [CONUTILS]: Fix build: - Commit the *Puts functions. - Fix __stdcall that needs to be read __cdecl for variadic functions. Modified: trunk/reactos/sdk/lib/conutils/conutils.c trunk/reactos/sdk/lib/conutils/conutils.h Modified: trunk/reactos/sdk/lib/conutils/conutils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/conutils.…
============================================================================== --- trunk/reactos/sdk/lib/conutils/conutils.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/conutils/conutils.c [iso-8859-1] Fri Oct 7 21:57:59 2016 @@ -532,23 +532,13 @@ } INT -ConPrintfV( - IN PCON_STREAM Stream, - IN LPWSTR szStr, - IN va_list args) // arg_ptr -{ - INT Len; - WCHAR bufFormatted[CON_RC_STRING_MAX_SIZE]; - -#if 1 /////////////////////////////////////////////////////////////////////// 0 - PWSTR pEnd; - StringCchVPrintfExW(bufFormatted, ARRAYSIZE(bufFormatted), &pEnd, NULL, 0, szStr, args); - Len = pEnd - bufFormatted; -#else - StringCchVPrintfW(bufFormatted, ARRAYSIZE(bufFormatted), szStr, args); - Len = wcslen(bufFormatted); -#endif - Len = Stream->WriteFunc(Stream, bufFormatted, Len); +ConPuts( + IN PCON_STREAM Stream, + IN LPWSTR szStr) +{ + INT Len; + + Len = Stream->WriteFunc(Stream, szStr, wcslen(szStr)); /* Fixup returned length in case of errors */ if (Len < 0) @@ -558,6 +548,33 @@ } INT +ConPrintfV( + IN PCON_STREAM Stream, + IN LPWSTR szStr, + IN va_list args) // arg_ptr +{ + INT Len; + WCHAR bufSrc[CON_RC_STRING_MAX_SIZE]; + +#if 1 /////////////////////////////////////////////////////////////////////// 0 + PWSTR pEnd; + StringCchVPrintfExW(bufSrc, ARRAYSIZE(bufSrc), &pEnd, NULL, 0, szStr, args); + Len = pEnd - bufSrc; +#else + StringCchVPrintfW(bufSrc, ARRAYSIZE(bufSrc), szStr, args); + Len = wcslen(bufSrc); +#endif + Len = Stream->WriteFunc(Stream, bufSrc, Len); + + /* Fixup returned length in case of errors */ + if (Len < 0) + Len = 0; + + return Len; +} + +INT +__cdecl ConPrintf( IN PCON_STREAM Stream, IN LPWSTR szStr, @@ -580,6 +597,33 @@ } INT +ConResPuts( + IN PCON_STREAM Stream, + IN UINT uID) +{ + INT Len; +#if 0 + WCHAR bufSrc[CON_RC_STRING_MAX_SIZE]; + + // NOTE: We may use the special behaviour where nBufMaxSize == 0 + Len = K32LoadStringW(GetModuleHandleW(NULL), uID, bufSrc, ARRAYSIZE(bufSrc)); + if (Len) + Len = ConPuts(Stream, bufSrc); +#else + PWCHAR szStr = NULL; + Len = K32LoadStringW(GetModuleHandleW(NULL), uID, (PWSTR)&szStr, 0); + if (Len) + Len = Stream->WriteFunc(Stream, szStr, Len); + + /* Fixup returned length in case of errors */ + if (Len < 0) + Len = 0; +#endif + + return Len; +} + +INT ConResPrintfV( IN PCON_STREAM Stream, IN UINT uID, @@ -597,6 +641,7 @@ } INT +__cdecl ConResPrintf( IN PCON_STREAM Stream, IN UINT uID, @@ -613,21 +658,20 @@ } INT -ConMsgPrintf2V( +ConMsgPuts( IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, - IN DWORD dwLanguageId, - IN va_list args) // arg_ptr + IN DWORD dwLanguageId) { INT Len; DWORD dwLength = 0; LPWSTR lpMsgBuf = NULL; /* - * Sanitize dwFlags. This version always ignore explicitely the inserts. - * The string that we will return to the user will not be pre-formatted. + * Sanitize dwFlags. This version always ignore explicitely the inserts + * as we emulate the behaviour of the *puts function. */ dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer. dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage. @@ -664,6 +708,72 @@ // ASSERT(dwLength != 0); /* lpMsgBuf is NULL-terminated by FormatMessage */ + // Len = ConPuts(Stream, lpMsgBuf); + Len = Stream->WriteFunc(Stream, lpMsgBuf, dwLength); + + /* Fixup returned length in case of errors */ + if (Len < 0) + Len = 0; + + /* Free the buffer allocated by FormatMessage */ + LocalFree(lpMsgBuf); + } + + return Len; +} + +INT +ConMsgPrintf2V( + IN PCON_STREAM Stream, + IN DWORD dwFlags, + IN LPCVOID lpSource OPTIONAL, + IN DWORD dwMessageId, + IN DWORD dwLanguageId, + IN va_list args) // arg_ptr +{ + INT Len; + DWORD dwLength = 0; + LPWSTR lpMsgBuf = NULL; + + /* + * Sanitize dwFlags. This version always ignore explicitely the inserts. + * The string that we will return to the user will not be pre-formatted. + */ + dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer. + dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage. + dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY; + + dwFlags |= FORMAT_MESSAGE_MAX_WIDTH_MASK; + + /* + * Retrieve the message string without appending extra newlines. + * Wrap in SEH to protect from invalid string parameters. + */ + _SEH2_TRY + { + dwLength = FormatMessageW(dwFlags, + lpSource, + dwMessageId, + dwLanguageId, + (LPWSTR)&lpMsgBuf, + 0, NULL); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END; + + Len = (INT)dwLength; + + if (!lpMsgBuf) + { + // ASSERT(dwLength == 0); + } + else + { + // ASSERT(dwLength != 0); + + /* lpMsgBuf is NULL-terminated by FormatMessage */ Len = ConPrintfV(Stream, lpMsgBuf, args); // Len = Stream->WriteFunc(Stream, lpMsgBuf, dwLength); @@ -739,6 +849,7 @@ } INT +__cdecl ConMsgPrintf( IN PCON_STREAM Stream, IN DWORD dwFlags, Modified: trunk/reactos/sdk/lib/conutils/conutils.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/conutils.…
============================================================================== --- trunk/reactos/sdk/lib/conutils/conutils.h [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/conutils/conutils.h [iso-8859-1] Fri Oct 7 21:57:59 2016 @@ -171,30 +171,50 @@ IN DWORD len); INT +ConPuts( + IN PCON_STREAM Stream, + IN LPWSTR szStr); + +INT ConPrintfV( IN PCON_STREAM Stream, IN LPWSTR szStr, IN va_list args); // arg_ptr INT +__cdecl ConPrintf( IN PCON_STREAM Stream, IN LPWSTR szStr, ...); INT +ConResPuts( + IN PCON_STREAM Stream, + IN UINT uID); + +INT ConResPrintfV( IN PCON_STREAM Stream, IN UINT uID, IN va_list args); // arg_ptr INT +__cdecl ConResPrintf( IN PCON_STREAM Stream, IN UINT uID, ...); INT +ConMsgPuts( + IN PCON_STREAM Stream, + IN DWORD dwFlags, + IN LPCVOID lpSource OPTIONAL, + IN DWORD dwMessageId, + IN DWORD dwLanguageId); + +INT ConMsgPrintf2V( IN PCON_STREAM Stream, IN DWORD dwFlags, @@ -213,6 +233,7 @@ IN va_list args); // arg_ptr INT +__cdecl ConMsgPrintf( IN PCON_STREAM Stream, IN DWORD dwFlags,
8 years, 2 months
1
0
0
0
[hbelusca] 72930: [CACLS][CLIP][COMP][EVENTCREATE][HELP][LOGOFF][SHUTDOWN][CHKDSK][FORMAT][SUBST] - Use Puts functions where needed; - Fix a __stdcall that needs to be read __cdecl for a variadic f...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 21:57:12 2016 New Revision: 72930 URL:
http://svn.reactos.org/svn/reactos?rev=72930&view=rev
Log: [CACLS][CLIP][COMP][EVENTCREATE][HELP][LOGOFF][SHUTDOWN][CHKDSK][FORMAT][SUBST] - Use Puts functions where needed; - Fix a __stdcall that needs to be read __cdecl for a variadic function. [CACLS] Fix some resources so that the strings can hold on the width of a standard console screen (80 chars). Modified: trunk/reactos/base/applications/cacls/cacls.c trunk/reactos/base/applications/cacls/lang/el-GR.rc trunk/reactos/base/applications/cacls/lang/es-ES.rc trunk/reactos/base/applications/cacls/lang/fr-FR.rc trunk/reactos/base/applications/cacls/lang/nl-NL.rc trunk/reactos/base/applications/cacls/lang/pl-PL.rc trunk/reactos/base/applications/cmdutils/clip/clip.c trunk/reactos/base/applications/cmdutils/comp/comp.c trunk/reactos/base/applications/cmdutils/eventcreate/eventcreate.c trunk/reactos/base/applications/cmdutils/help/help.c trunk/reactos/base/applications/logoff/logoff.c trunk/reactos/base/applications/shutdown/misc.c trunk/reactos/base/applications/shutdown/shutdown.c trunk/reactos/base/system/chkdsk/chkdsk.c trunk/reactos/base/system/format/format.c trunk/reactos/base/system/subst/subst.c Modified: trunk/reactos/base/applications/cacls/cacls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/ca…
============================================================================== --- trunk/reactos/base/applications/cacls/cacls.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/cacls.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -33,19 +33,17 @@ }; -static -VOID PrintError(DWORD dwError) +static VOID +PrintError(DWORD dwError) { if (dwError == ERROR_SUCCESS) return; - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dwError, LANG_USER_DEFAULT); -} - -static -BOOL + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, LANG_USER_DEFAULT); +} + +static BOOL PrintFileDacl(IN LPTSTR FilePath, IN LPTSTR FileName) { @@ -63,10 +61,8 @@ return FALSE; } - _tcscpy(FullFileName, - FilePath); - _tcscat(FullFileName, - FileName); + _tcscpy(FullFileName, FilePath); + _tcscat(FullFileName, FileName); /* find out how much memory we need */ if (!GetFileSecurity(FullFileName, @@ -182,8 +178,7 @@ } /* print the file name or space */ - _tprintf(_T("%s "), - FullFileName); + ConPrintf(StdOut, L"%s ", FullFileName); /* attempt to map the SID to a user name */ if (AceIndex == 0) @@ -199,32 +194,29 @@ /* print the domain and/or user if possible, or the SID string */ if (Name != NULL && Domain[0] != _T('\0')) { - _tprintf(_T("%s\\%s:"), - Domain, - Name); + ConPrintf(StdOut, L"%s\\%s:", Domain, Name); IndentAccess = (DWORD)_tcslen(Domain) + _tcslen(Name); } else { LPTSTR DisplayString = (Name != NULL ? Name : SidString); - _tprintf(_T("%s:"), - DisplayString); + ConPrintf(StdOut, L"%s:", DisplayString); IndentAccess = (DWORD)_tcslen(DisplayString); } /* print the ACE Flags */ if (Ace->Header.AceFlags & CONTAINER_INHERIT_ACE) { - IndentAccess += PrintResourceString(IDS_ABBR_CI); + IndentAccess += ConResPuts(StdOut, IDS_ABBR_CI); } if (Ace->Header.AceFlags & OBJECT_INHERIT_ACE) { - IndentAccess += PrintResourceString(IDS_ABBR_OI); + IndentAccess += ConResPuts(StdOut, IDS_ABBR_OI); } if (Ace->Header.AceFlags & INHERIT_ONLY_ACE) { - IndentAccess += PrintResourceString(IDS_ABBR_IO); + IndentAccess += ConResPuts(StdOut, IDS_ABBR_IO); } IndentAccess += 2; @@ -236,11 +228,11 @@ { if (AccessMask == FILE_ALL_ACCESS) { - PrintResourceString(IDS_ABBR_NONE); + ConResPuts(StdOut, IDS_ABBR_NONE); } else { - PrintResourceString(IDS_DENY); + ConResPuts(StdOut, IDS_DENY); goto PrintSpecialAccess; } } @@ -248,20 +240,20 @@ { if (AccessMask == FILE_ALL_ACCESS) { - PrintResourceString(IDS_ABBR_FULL); + ConResPuts(StdOut, IDS_ABBR_FULL); } else if (!(Ace->Mask & (GENERIC_READ | GENERIC_EXECUTE)) && AccessMask == (FILE_GENERIC_READ | FILE_EXECUTE)) { - PrintResourceString(IDS_ABBR_READ); + ConResPuts(StdOut, IDS_ABBR_READ); } else if (AccessMask == (FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_EXECUTE | DELETE)) { - PrintResourceString(IDS_ABBR_CHANGE); + ConResPuts(StdOut, IDS_ABBR_CHANGE); } else if (AccessMask == FILE_GENERIC_WRITE) { - PrintResourceString(IDS_ABBR_WRITE); + ConResPuts(StdOut, IDS_ABBR_WRITE); } else { @@ -301,10 +293,10 @@ {STANDARD_RIGHTS_ALL, IDS_STANDARD_RIGHTS_ALL}, }; - PrintResourceString(IDS_ALLOW); + ConResPuts(StdOut, IDS_ALLOW); PrintSpecialAccess: - PrintResourceString(IDS_SPECIAL_ACCESS); + ConResPuts(StdOut, IDS_SPECIAL_ACCESS); /* print the special access rights */ x = ARRAYSIZE(AccessRights); @@ -312,24 +304,21 @@ { if ((Ace->Mask & AccessRights[x].Access) == AccessRights[x].Access) { - _tprintf(_T("\n%s "), - FullFileName); - for (x2 = 0; - x2 < IndentAccess; - x2++) + ConPrintf(StdOut, L"\n%s ", FullFileName); + for (x2 = 0; x2 < IndentAccess; x2++) { - _tprintf(_T(" ")); + ConPuts(StdOut, L" "); } - PrintResourceString(AccessRights[x].uID); + ConResPuts(StdOut, AccessRights[x].uID); } } - _tprintf(_T("\n")); - } - } - - _tprintf(_T("\n")); + ConPuts(StdOut, L"\n"); + } + } + + ConPuts(StdOut, L"\n"); /* free up all resources */ if (Name != NULL) @@ -451,10 +440,14 @@ } } else + { break; + } } else - _tprintf(_T("\n")); + { + ConPuts(StdOut, L"\n"); + } } while(FindNextFile(hFind, &FindData)); LastError = GetLastError(); FindClose(hFind); @@ -758,9 +751,11 @@ if (argc <= 1) { - PrintResourceString(IDS_HELP); + ConResPuts(StdOut, IDS_HELP); return 0; } + + // FIXME: Convert to proper parsing, with support for /? /* * parse command line options @@ -845,7 +840,7 @@ if (InvalidParameter) { PrintError(ERROR_INVALID_PARAMETER); - PrintResourceString(IDS_HELP); + ConResPuts(StdOut, IDS_HELP); return 1; } Modified: trunk/reactos/base/applications/cacls/lang/el-GR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/la…
============================================================================== --- trunk/reactos/base/applications/cacls/lang/el-GR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/lang/el-GR.rc [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -23,7 +23,8 @@ C Îλλαγή (εγγÏαÏή)\n\ F ΠλήÏÎ·Ï ÎλεγÏοÏ\n\ /D user ÎÏοÏÏοÏή ÏÏήÏÏη αÏÏ ÏÏοÏÏÎλαÏη.\n\ -Τα Wildcards μÏοÏοÏν να ÏÏηÏιμοÏοιηθοÏν για να ÏÏοÏδιοÏίÏÎ¿Ï Î½ ÏαÏαÏαÏÎ¬Î½Ï Î±ÏÏ Îνα αÏÏεία ÏÏην ενÏολή.\n\ +Τα Wildcards μÏοÏοÏν να ÏÏηÏιμοÏοιηθοÏν για να ÏÏοÏδιοÏίÏÎ¿Ï Î½ ÏαÏαÏαÏÎ¬Î½Ï Î±ÏÏ\n\ +Îνα αÏÏεία ÏÏην ενÏολή.\n\ ÎÏοÏείÏε να ÏÏοÏδιοÏίÏεÏε ÏαÏÏÎ±Î¬Î½Ï Î±ÏÏ Îναν ÏÏήÏÏη ÏÏην ενÏολή.\n\n\ Abbreviations:\n\ CI - Container Inherit.\n\ Modified: trunk/reactos/base/applications/cacls/lang/es-ES.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/la…
============================================================================== --- trunk/reactos/base/applications/cacls/lang/es-ES.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/lang/es-ES.rc [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -18,7 +18,8 @@ W Escribir\n\ C Cambiar (escribir)\n\ F Control total\n\ - /R usuario Revoca los derechos de acceso al usuario especificado (unicamente válido con /E).\n\ + /R usuario Revoca los derechos de acceso al usuario especificado\n\ + (unicamente válido con /E).\n\ /P user:perm Reemplaza los derechos de acceso del usuario especificado.\n\ Perm puede ser: N Ninguno\n\ R Leer\n\ Modified: trunk/reactos/base/applications/cacls/lang/fr-FR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/la…
============================================================================== --- trunk/reactos/base/applications/cacls/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/lang/fr-FR.rc [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -15,7 +15,8 @@ W Ãcriture\n\ C Modification (Ãcriture)\n\ F Contrôle total\n\ - /R user Supprime les droits d'accès de l'utilisateur spécifié (valide uniquement avec /E).\n\ + /R user Supprime les droits d'accès de l'utilisateur spécifié\n\ + (valide uniquement avec /E).\n\ /P user:perm Remplace les droits d'accès de l'utilisateur spécifié.\n\ Perm peut valoir : N Aucun \n\ R Lecture\n\ @@ -23,7 +24,8 @@ C Modification (Ãcriture)\n\ F Contrôle total\n\ /D user Interdit l'accès à l'utilisateur spécifié.\n\ -Il est possible d'utiliser des caractères joker pour sélectionner plus d'un fichier avec une commande.\n\ +Il est possible d'utiliser des caractères joker pour sélectionner plus d'un\n\ +fichier avec une commande.\n\ Il est possible de spécifier plus d'un utilisateur dans une commande.\n\n\ Abréviations:\n\ CI - Héritage du conteneur.\n\ Modified: trunk/reactos/base/applications/cacls/lang/nl-NL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/la…
============================================================================== --- trunk/reactos/base/applications/cacls/lang/nl-NL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/lang/nl-NL.rc [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -2,7 +2,9 @@ STRINGTABLE BEGIN - IDS_HELP "ACL's (Access Control Lists, toegangslijsten) van bestanden weergeven\nof bewerken\n\nCACLS bestandsnaam [/T] [/E] [/C] [/G gebr:toeg] [/R gebruiker [...]]\n\ + IDS_HELP "ACL's (Access Control Lists, toegangslijsten) van bestanden weergeven\n\ +of bewerken\n\n\ +CACLS bestandsnaam [/T] [/E] [/C] [/G gebr:toeg] [/R gebruiker [...]]\n\ [/P gebr:toeg [...]] [/D gebruiker [...]]\n\ bestandsnaam ACL's weergeven.\n\ /T ACL's wijzigen van opgegeven bestanden in\n\ Modified: trunk/reactos/base/applications/cacls/lang/pl-PL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/la…
============================================================================== --- trunk/reactos/base/applications/cacls/lang/pl-PL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/lang/pl-PL.rc [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -24,7 +24,8 @@ W Zapis\n\ C Zmiana (zapis)\n\ F PeÅny dostÄp\n\ - /R użytkownik OdwoÅuje prawa dostÄpu okreÅlonemu użytkownikowi (dziaÅa tylko z opcjÄ /E).\n\ + /R użytkownik OdwoÅuje prawa dostÄpu okreÅlonemu użytkownikowi\n\ + (dziaÅa tylko z opcjÄ /E).\n\ /P użytkownik:dostÄp Edytuje prawa dostÄpu okreÅlonego użytkownika.\n\ Poziom dostÄpu:\n\ N Brak\n\ @@ -33,7 +34,8 @@ C Zmiana (zapis)\n\ F PeÅny dostÄp\n\ /D użytkownik Odbiera prawa dostÄpu okreÅlonemu użytkownikowi.\n\ -W jednym poleceniu można edytowaÄ prawa dostÄpu do wielu plików, używajÄ c symboli wieloznacznych.\n\ +W jednym poleceniu można edytowaÄ prawa dostÄpu do wielu plików, używajÄ c\n\ +symboli wieloznacznych.\n\ W jednym poleceniu można edytowaÄ prawa dostÄpu wielu użytkowników.\n\n\ Skróty:\n\ CI - Dziedziczenie kontenera.\n\ Modified: trunk/reactos/base/applications/cmdutils/clip/clip.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/clip/clip.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/clip/clip.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -21,9 +21,8 @@ if (dwError == ERROR_SUCCESS) return; - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dwError, LANG_USER_DEFAULT); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, LANG_USER_DEFAULT); } static BOOL IsDataUnicode(HGLOBAL hGlobal) @@ -55,13 +54,13 @@ /* Check for usage */ if (argc > 1 && wcsncmp(argv[1], L"/?", 2) == 0) { - ConResPrintf(StdOut, IDS_HELP); + ConResPuts(StdOut, IDS_HELP); return 0; } if (GetFileType(hInput) == FILE_TYPE_CHAR) { - ConResPrintf(StdOut, IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return 0; } Modified: trunk/reactos/base/applications/cmdutils/comp/comp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/comp/comp.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/comp/comp.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -26,8 +26,6 @@ #include <stdio.h> #include <stdlib.h> -// #include <string.h> -// #include <wchar.h> #include <assert.h> #define WIN32_NO_STATUS @@ -102,12 +100,12 @@ break; case L'?': - PrintResourceString(IDS_HELP); + ConResPuts(StdOut, IDS_HELP); return EXIT_SUCCESS; default: - PrintResourceString(IDS_INVALIDSWITCH, argv[i][1]); - PrintResourceString(IDS_HELP); + ConResPrintf(StdErr, IDS_INVALIDSWITCH, argv[i][1]); + ConResPuts(StdOut, IDS_HELP); return EXIT_FAILURE; } } @@ -120,14 +118,14 @@ } else { - PrintResourceString(IDS_BADSYNTAX); + ConResPuts(StdErr, IDS_BADSYNTAX); return EXIT_FAILURE; } Buff1 = (PBYTE)malloc(STRBUF); if (Buff1 == NULL) { - ConPrintf(StdErr, L"Can't get free memory for Buff1\n"); + ConPuts(StdErr, L"Can't get free memory for Buff1\n"); Status = EXIT_FAILURE; goto Cleanup; } @@ -135,30 +133,30 @@ Buff2 = (PBYTE)malloc(STRBUF); if (Buff2 == NULL) { - ConPrintf(StdErr, L"Can't get free memory for Buff2\n"); + ConPuts(StdErr, L"Can't get free memory for Buff2\n"); Status = EXIT_FAILURE; goto Cleanup; } if ((fp1 = _wfopen(File1, L"rb")) == NULL) { - PrintResourceString(IDS_FILEERROR, File1); + ConResPrintf(StdErr, IDS_FILEERROR, File1); Status = EXIT_FAILURE; goto Cleanup; } if ((fp2 = _wfopen(File2, L"rb")) == NULL) { - PrintResourceString(IDS_FILEERROR, File2); - Status = EXIT_FAILURE; - goto Cleanup; - } - - PrintResourceString(IDS_COMPARING, File1, File2); + ConResPrintf(StdErr, IDS_FILEERROR, File2); + Status = EXIT_FAILURE; + goto Cleanup; + } + + ConResPrintf(StdOut, IDS_COMPARING, File1, File2); FileSizeFile1 = FileSize(fp1); if (FileSizeFile1 == -1) { - PrintResourceString(IDS_FILESIZEERROR, File1); + ConResPrintf(StdErr, IDS_FILESIZEERROR, File1); Status = EXIT_FAILURE; goto Cleanup; } @@ -166,14 +164,14 @@ FileSizeFile2 = FileSize(fp2); if (FileSizeFile2 == -1) { - PrintResourceString(IDS_FILESIZEERROR, File2); + ConResPrintf(StdErr, IDS_FILESIZEERROR, File2); Status = EXIT_FAILURE; goto Cleanup; } if (FileSizeFile1 != FileSizeFile2) { - PrintResourceString(IDS_SIZEDIFFERS); + ConResPuts(StdOut, IDS_SIZEDIFFERS); Status = EXIT_FAILURE; goto Cleanup; } @@ -187,7 +185,7 @@ if (ferror(fp1) || ferror(fp2)) { - PrintResourceString(IDS_READERROR); + ConResPuts(StdErr, IDS_READERROR); Status = EXIT_FAILURE; goto Cleanup; } @@ -205,22 +203,22 @@ /* Reporting here a mismatch */ if (bLineNos) { - PrintResourceString(IDS_MISMATCHLINE, LineNumber); + ConResPrintf(StdOut, IDS_MISMATCHLINE, LineNumber); } else { - PrintResourceString(IDS_MISMATCHOFFSET, Offset); + ConResPrintf(StdOut, IDS_MISMATCHOFFSET, Offset); } if (bAscii) { - PrintResourceString(IDS_ASCIIDIFF, 1, Buff1[i]); - PrintResourceString(IDS_ASCIIDIFF, 2, Buff2[i]); + ConResPrintf(StdOut, IDS_ASCIIDIFF, 1, Buff1[i]); + ConResPrintf(StdOut, IDS_ASCIIDIFF, 2, Buff2[i]); } else { - PrintResourceString(IDS_HEXADECIMALDIFF, 1, Buff1[i]); - PrintResourceString(IDS_HEXADECIMALDIFF, 2, Buff2[i]); + ConResPrintf(StdOut, IDS_HEXADECIMALDIFF, 1, Buff1[i]); + ConResPrintf(StdOut, IDS_HEXADECIMALDIFF, 2, Buff2[i]); } } @@ -232,7 +230,7 @@ } if (FilesOK) - PrintResourceString(IDS_MATCH); + ConResPuts(StdOut, IDS_MATCH); Cleanup: if (fp2) Modified: trunk/reactos/base/applications/cmdutils/eventcreate/eventcreate.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/eventcreate/eventcreate.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/eventcreate/eventcreate.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -113,10 +113,9 @@ if (dwError == ERROR_SUCCESS) return; - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dwError, LANG_USER_DEFAULT); - ConPrintf(StdErr, L"\n"); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, LANG_USER_DEFAULT); + ConPuts(StdErr, L"\n"); } @@ -594,7 +593,7 @@ else { /* This is NOT a custom source, we must return an error! */ - ConResPrintf(StdErr, IDS_SOURCE_NOT_CUSTOM); + ConResPuts(StdErr, IDS_SOURCE_NOT_CUSTOM); goto Quit; } } @@ -605,7 +604,7 @@ if (!LogNameValid /* && !FoundLog */) { /* The log name is not specified, we cannot create the source */ - ConResPrintf(StdErr, IDS_SOURCE_NOCREATE); + ConResPuts(StdErr, IDS_SOURCE_NOCREATE); goto Quit; } else // LogNameValid && FoundLog @@ -721,7 +720,7 @@ MandatoryOptionAbsent, } PARSER_ERROR; -typedef VOID (__stdcall *PRINT_ERROR_FUNC)(IN PARSER_ERROR, ...); +typedef VOID (__cdecl *PRINT_ERROR_FUNC)(IN PARSER_ERROR, ...); BOOL DoParse( @@ -982,7 +981,7 @@ static VOID -__stdcall +__cdecl PrintParserError(PARSER_ERROR Error, ...) { /* WARNING: Please keep this lookup table in sync with the resources! */ @@ -1008,7 +1007,7 @@ va_end(args); if (Error != Success) - ConResPrintf(StdErr, IDS_USAGE); + ConResPuts(StdErr, IDS_USAGE); } else { @@ -1121,7 +1120,7 @@ return EXIT_FAILURE; } - ConResPrintf(StdOut, IDS_HELP); + ConResPuts(StdOut, IDS_HELP); return EXIT_SUCCESS; } @@ -1141,7 +1140,7 @@ { /* Invalid event identifier */ ConResPrintf(StdErr, IDS_BADSYNTAX_7, OPT_EVTID.OptionStr, EVENT_ID_MIN, EVENT_ID_MAX); - ConResPrintf(StdErr, IDS_USAGE); + ConResPuts(StdErr, IDS_USAGE); return EXIT_FAILURE; } @@ -1238,12 +1237,12 @@ if (!Success) { PrintError(GetLastError()); - ConPrintf(StdErr, L"Failed to report event!\n"); + ConPuts(StdErr, L"Failed to report event!\n"); } else { /* Show success */ - ConPrintf(StdOut, L"\n"); + ConPuts(StdOut, L"\n"); if (!szEventSource) ConResPrintf(StdOut, IDS_SUCCESS_1, szEventType, szLogName); else if (!szLogName) @@ -1257,7 +1256,7 @@ else { PrintError(GetLastError()); - ConPrintf(StdErr, L"GetUserToken() failed!\n"); + ConPuts(StdErr, L"GetUserToken() failed!\n"); } /* Close the event log */ Modified: trunk/reactos/base/applications/cmdutils/help/help.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/help/help.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/help/help.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -66,8 +66,8 @@ */ if (argc <= 1) { - PrintResourceString(IDS_HELP1); - PrintResourceString(IDS_HELP2); + ConResPuts(StdOut, IDS_HELP1); + ConResPuts(StdOut, IDS_HELP2); return 0; } @@ -77,7 +77,7 @@ */ if ((argc > 2) || (wcscmp(argv[1], L"/?") == 0)) { - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return 0; } @@ -87,7 +87,7 @@ */ if (!IsInternalCommand(argv[1])) { - PrintResourceString(IDS_NO_ENTRY, argv[1]); + ConResPrintf(StdOut, IDS_NO_ENTRY, argv[1]); return 0; } Modified: trunk/reactos/base/applications/logoff/logoff.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/l…
============================================================================== --- trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -32,9 +32,8 @@ //---------------------------------------------------------------------- VOID DisplayError(DWORD dwError) { - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dwError, LANG_USER_DEFAULT); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, LANG_USER_DEFAULT); ConPrintf(StdErr, L"Error code: %lu\n", dwError); } @@ -65,7 +64,7 @@ } default: //Invalid parameter detected - ConResPrintf(StdErr, IDS_ILLEGAL_PARAM); + ConResPuts(StdErr, IDS_ILLEGAL_PARAM); return FALSE; } } @@ -87,7 +86,7 @@ // Parse command line // if (!ParseCommandLine(argc, argv)) { - ConResPrintf(StdOut, IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return 1; } @@ -96,11 +95,11 @@ // if (szRemoteServerName) { if (bVerbose) { - ConResPrintf(StdOut, IDS_LOGOFF_REMOTE); + ConResPuts(StdOut, IDS_LOGOFF_REMOTE); } // FIXME: Add Remote Procedure Call to logoff user on a remote machine - ConPrintf(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented"); + ConPuts(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented"); } // // Perform logoff of current session on local machine instead @@ -108,7 +107,7 @@ else { if (bVerbose) { // Get resource string, and print it. - ConResPrintf(StdOut, IDS_LOGOFF_LOCAL); + ConResPuts(StdOut, IDS_LOGOFF_LOCAL); } // Actual logoff Modified: trunk/reactos/base/applications/shutdown/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/misc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/misc.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -162,9 +162,8 @@ /* Writes the last error as both text and error code to the console */ VOID DisplayError(DWORD dwError) { - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dwError, LANG_USER_DEFAULT); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, LANG_USER_DEFAULT); ConPrintf(StdErr, L"Error code: %lu\n", dwError); } Modified: trunk/reactos/base/applications/shutdown/shutdown.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/shutdown.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/shutdown.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -48,7 +48,7 @@ switch (towlower(argv[index][1])) { case L'?': /* Help */ - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return ERROR_SUCCESS; case L'a': /* Cancel delayed shutdown */ @@ -66,7 +66,7 @@ } else { - PrintResourceString(IDS_ERROR_MAX_COMMENT_LENGTH); + ConResPuts(StdErr, IDS_ERROR_MAX_COMMENT_LENGTH); return ERROR_BAD_LENGTH; } break; @@ -125,7 +125,7 @@ default: /* Unknown arguments will exit the program. */ - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return ERROR_SUCCESS; } } @@ -192,7 +192,7 @@ if (argc == 1) /* i.e. no commandline arguments given */ { - PrintResourceString(IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return EXIT_SUCCESS; } @@ -216,7 +216,7 @@ /* Abort the delayed system shutdown specified. */ if (!AbortSystemShutdownW(opts.remote_system)) { - PrintResourceString(IDS_ERROR_ABORT); + ConResPuts(StdErr, IDS_ERROR_ABORT); DisplayError(GetLastError()); return EXIT_FAILURE; } @@ -245,13 +245,13 @@ if (!SetSuspendState(TRUE, FALSE, FALSE)) { - PrintResourceString(IDS_ERROR_HIBERNATE); + ConResPuts(StdErr, IDS_ERROR_HIBERNATE); DisplayError(GetLastError()); return EXIT_FAILURE; } else { - PrintResourceString(IDS_ERROR_HIBERNATE_ENABLED); + ConResPuts(StdOut, IDS_ERROR_HIBERNATE_ENABLED); return EXIT_SUCCESS; } } @@ -264,14 +264,14 @@ /* Both shutdown and restart flags cannot both be true */ if (opts.shutdown && opts.restart) { - PrintResourceString(IDS_ERROR_SHUTDOWN_REBOOT); + ConResPuts(StdErr, IDS_ERROR_SHUTDOWN_REBOOT); return EXIT_FAILURE; } /* Ensure that the timout amount is not too high or a negative number */ if (opts.shutdown_delay > MAX_SHUTDOWN_TIMEOUT) { - PrintResourceString(IDS_ERROR_TIMEOUT, opts.shutdown_delay); + ConResPrintf(StdErr, IDS_ERROR_TIMEOUT, opts.shutdown_delay); return EXIT_FAILURE; } @@ -302,7 +302,7 @@ } else { - PrintResourceString(IDS_ERROR_LOGOFF); + ConResPuts(StdErr, IDS_ERROR_LOGOFF); DisplayError(GetLastError()); return EXIT_FAILURE; } @@ -343,9 +343,9 @@ * on whether the user wanted to shutdown or restart. */ if (opts.restart) - PrintResourceString(IDS_ERROR_RESTART); + ConResPuts(StdErr, IDS_ERROR_RESTART); else - PrintResourceString(IDS_ERROR_SHUTDOWN); + ConResPuts(StdErr, IDS_ERROR_SHUTDOWN); DisplayError(GetLastError()); return EXIT_FAILURE; Modified: trunk/reactos/base/system/chkdsk/chkdsk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/chkdsk/chkdsk.…
============================================================================== --- trunk/reactos/base/system/chkdsk/chkdsk.c [iso-8859-1] (original) +++ trunk/reactos/base/system/chkdsk/chkdsk.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -88,10 +88,9 @@ static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode) { ConPrintf(StdErr, L"%s: ", Message); - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, ErrorCode, LANG_USER_DEFAULT); - ConPrintf(StdErr, L"\n"); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, ErrorCode, LANG_USER_DEFAULT); + ConPuts(StdErr, L"\n"); } @@ -240,59 +239,59 @@ switch (Command) { case UNKNOWN2: - ConPrintf(StdOut, L"UNKNOWN2\r"); + ConPuts(StdOut, L"UNKNOWN2\r"); break; case UNKNOWN3: - ConPrintf(StdOut, L"UNKNOWN3\n"); + ConPuts(StdOut, L"UNKNOWN3\n"); break; case UNKNOWN4: - ConPrintf(StdOut, L"UNKNOWN4\n"); + ConPuts(StdOut, L"UNKNOWN4\n"); break; case UNKNOWN5: - ConPrintf(StdOut, L"UNKNOWN5\n"); + ConPuts(StdOut, L"UNKNOWN5\n"); break; case FSNOTSUPPORTED: - ConPrintf(StdOut, L"FSNOTSUPPORTED\n"); + ConPuts(StdOut, L"FSNOTSUPPORTED\n"); break; case VOLUMEINUSE: - ConPrintf(StdOut, L"VOLUMEINUSE\n"); + ConPuts(StdOut, L"VOLUMEINUSE\n"); break; case UNKNOWN9: - ConPrintf(StdOut, L"UNKNOWN9\n"); + ConPuts(StdOut, L"UNKNOWN9\n"); break; case UNKNOWNA: - ConPrintf(StdOut, L"UNKNOWNA\n"); + ConPuts(StdOut, L"UNKNOWNA\n"); break; case UNKNOWNC: - ConPrintf(StdOut, L"UNKNOWNC\n"); + ConPuts(StdOut, L"UNKNOWNC\n"); break; case UNKNOWND: - ConPrintf(StdOut, L"UNKNOWND\n"); + ConPuts(StdOut, L"UNKNOWND\n"); break; case INSUFFICIENTRIGHTS: - ConPrintf(StdOut, L"INSUFFICIENTRIGHTS\n"); + ConPuts(StdOut, L"INSUFFICIENTRIGHTS\n"); break; case STRUCTUREPROGRESS: - ConPrintf(StdOut, L"STRUCTUREPROGRESS\n"); + ConPuts(StdOut, L"STRUCTUREPROGRESS\n"); break; case DONEWITHSTRUCTURE: - ConPrintf(StdOut, L"DONEWITHSTRUCTURE\n"); + ConPuts(StdOut, L"DONEWITHSTRUCTURE\n"); break; case CLUSTERSIZETOOSMALL: - ConPrintf(StdOut, L"CLUSTERSIZETOOSMALL\n"); + ConPuts(StdOut, L"CLUSTERSIZETOOSMALL\n"); break; case PROGRESS: @@ -309,7 +308,7 @@ status = (PBOOLEAN)Argument; if (*status == FALSE) { - ConPrintf(StdOut, L"Chkdsk was unable to complete successfully.\n\n"); + ConPuts(StdOut, L"Chkdsk was unable to complete successfully.\n\n"); Error = TRUE; } break; @@ -369,7 +368,7 @@ /* Initialize the Console Standard Streams */ ConInitStdStreams(); - ConPrintf(StdOut, + ConPuts(StdOut, L"\n" L"Chkdskx v1.0.1 by Mark Russinovich\n" L"Systems Internals -
http://www.sysinternals.com\n
" @@ -381,7 +380,7 @@ // if (!LoadFMIFSEntryPoints()) { - ConPrintf(StdErr, L"Could not located FMIFS entry points.\n\n"); + ConPuts(StdErr, L"Could not located FMIFS entry points.\n\n"); return -1; } #endif @@ -448,7 +447,7 @@ 0); if (volumeHandle == INVALID_HANDLE_VALUE) { - ConPrintf(StdErr, L"Chkdsk cannot run because the volume is in use by another process.\n\n"); + ConPuts(StdErr, L"Chkdsk cannot run because the volume is in use by another process.\n\n"); return -1; } CloseHandle(volumeHandle); Modified: trunk/reactos/base/system/format/format.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/format/format.…
============================================================================== --- trunk/reactos/base/system/format/format.c [iso-8859-1] (original) +++ trunk/reactos/base/system/format/format.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -117,10 +117,9 @@ static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode) { ConPrintf(StdErr, L"%s: ", Message); - ConMsgPrintf(StdErr, - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, ErrorCode, LANG_USER_DEFAULT); - ConPrintf(StdErr, L"\n"); + ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM, + NULL, ErrorCode, LANG_USER_DEFAULT); + ConPuts(StdErr, L"\n"); } @@ -241,7 +240,7 @@ status = (PBOOLEAN)Argument; if (*status == FALSE) { - ConResPrintf(StdOut, STRING_FORMAT_FAIL); + ConResPuts(StdOut, STRING_FORMAT_FAIL); Error = TRUE; } break; @@ -260,7 +259,7 @@ case UNKNOWND: case STRUCTUREPROGRESS: case CLUSTERSIZETOOSMALL: - ConResPrintf(StdOut, STRING_NO_SUPPORT); + ConResPuts(StdOut, STRING_NO_SUPPORT); return FALSE; } return TRUE; @@ -374,7 +373,7 @@ /* Initialize the Console Standard Streams */ ConInitStdStreams(); - ConPrintf(StdOut, + ConPuts(StdOut, L"\n" L"Formatx v1.0 by Mark Russinovich\n" L"Systems Internals -
http://www.sysinternals.com\n
" @@ -386,7 +385,7 @@ // if (!LoadFMIFSEntryPoints()) { - ConResPrintf(StdErr, STRING_FMIFS_FAIL); + ConResPuts(StdErr, STRING_FMIFS_FAIL); return -1; } #endif @@ -397,7 +396,7 @@ badArg = ParseCommandLine(argc, argv); if (badArg) { - ConResPrintf(StdOut, STRING_UNKNOW_ARG, argv[badArg]); + ConResPrintf(StdErr, STRING_UNKNOW_ARG, argv[badArg]); Usage(argv[0]); return -1; } @@ -407,7 +406,7 @@ // if (!Drive) { - ConResPrintf(StdOut, STRING_DRIVE_PARM); + ConResPuts(StdErr, STRING_DRIVE_PARM); Usage(argv[0]); return -1; } @@ -431,7 +430,7 @@ case DRIVE_REMOTE: case DRIVE_CDROM: - ConResPrintf(StdOut, STRING_NO_SUPPORT); + ConResPuts(StdOut, STRING_NO_SUPPORT); return -1; case DRIVE_NO_ROOT_DIR: @@ -462,7 +461,7 @@ if (towlower(path[0]) == towlower(Drive[0])) { // todo: report "Cannot format system drive" - ConResPrintf(StdOut, STRING_NO_SUPPORT); + ConResPuts(StdOut, STRING_NO_SUPPORT); return -1; } } @@ -507,7 +506,7 @@ if (!wcsicmp(input, volumeName)) break; - ConResPrintf(StdOut, STRING_ERROR_LABEL); + ConResPuts(StdOut, STRING_ERROR_LABEL); } } @@ -520,7 +519,7 @@ if (_wcsnicmp(&input[0], &szMsg[0], 1) == 0) break; if (_wcsnicmp(&input[0], &szMsg[1], 1) == 0) { - ConPrintf(StdOut, L"\n"); + ConPuts(StdOut, L"\n"); return 0; } } @@ -554,7 +553,7 @@ ConPrintf(StdOut, L"%s %.2fM\n", szMsg, ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } - ConResPrintf(StdOut, STRING_CREATE_FSYS); + ConResPuts(StdOut, STRING_CREATE_FSYS); } // @@ -563,7 +562,7 @@ FormatEx(RootDirectory, media, FileSystem, Label, QuickFormat, ClusterSize, FormatExCallback); if (Error) return -1; - ConResPrintf(StdOut, STRING_FMT_COMPLETE); + ConResPuts(StdOut, STRING_FMT_COMPLETE); // // Enable compression if desired @@ -571,7 +570,7 @@ if (CompressDrive) { if (!EnableVolumeCompression(RootDirectory, TRUE)) - ConResPrintf(StdOut, STRING_VOL_COMPRESS); + ConResPuts(StdOut, STRING_VOL_COMPRESS); } // @@ -579,7 +578,7 @@ // if (!GotALabel) { - ConResPrintf(StdOut, STRING_ENTER_LABEL); + ConResPuts(StdOut, STRING_ENTER_LABEL); fgetws(input, ARRAYSIZE(LabelString), stdin); input[wcslen(input) - 1] = 0; Modified: trunk/reactos/base/system/subst/subst.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.c?…
============================================================================== --- trunk/reactos/base/system/subst/subst.c [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/subst.c [iso-8859-1] Fri Oct 7 21:57:12 2016 @@ -267,7 +267,7 @@ case ERROR_IS_SUBSTED: { - ConResPrintf(StdErr, IDS_DRIVE_ALREADY_SUBSTED); + ConResPuts(StdErr, IDS_DRIVE_ALREADY_SUBSTED); return 1; } @@ -305,7 +305,7 @@ { if (!_wcsicmp(argv[i], L"/?")) { - ConResPrintf(StdOut, IDS_USAGE); + ConResPuts(StdOut, IDS_USAGE); return 0; } }
8 years, 2 months
1
0
0
0
[hbelusca] 72929: Fix build.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 20:44:15 2016 New Revision: 72929 URL:
http://svn.reactos.org/svn/reactos?rev=72929&view=rev
Log: Fix build. Modified: trunk/reactos/base/system/subst/subst.c Modified: trunk/reactos/base/system/subst/subst.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.c?…
============================================================================== --- trunk/reactos/base/system/subst/subst.c [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/subst.c [iso-8859-1] Fri Oct 7 20:44:15 2016 @@ -24,7 +24,7 @@ VOID PrintError(IN DWORD ErrCode) { - DWORD dwLength = 0; + // DWORD dwLength = 0; PWSTR pMsgBuf = NULL; #if 0 @@ -33,13 +33,14 @@ #endif /* Retrieve the message string without appending extra newlines */ - dwLength = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, - NULL, - ErrCode, - LANG_USER_DEFAULT, - (PWSTR)&pMsgBuf, - 0, NULL); + // dwLength = + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, + ErrCode, + LANG_USER_DEFAULT, + (PWSTR)&pMsgBuf, + 0, NULL); if (pMsgBuf /* && dwLength */) { ConResPrintf(StdErr, IDS_FAILED_WITH_ERRORCODE,
8 years, 2 months
1
0
0
0
[hbelusca] 72928: [CACLS][CLIP][COMP][HELP][LOGOFF][SHUTDOWN][CHKDSK][FORMAT][SUBST] Make those command tools use the console uilities library, aka. solve all those problems of wrong characters on ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Oct 7 20:37:36 2016 New Revision: 72928 URL:
http://svn.reactos.org/svn/reactos?rev=72928&view=rev
Log: [CACLS][CLIP][COMP][HELP][LOGOFF][SHUTDOWN][CHKDSK][FORMAT][SUBST] Make those command tools use the console uilities library, aka. solve all those problems of wrong characters on the console... Nitpickers may notice that at some places, the usage of a "Puts"-like function would be better than Printf. Don't worry, I'm on it, it's for another commit. CORE-10504 CORE-11909 #resolve Removed: trunk/reactos/base/applications/logoff/misc.c trunk/reactos/base/applications/logoff/precomp.h Modified: trunk/reactos/base/applications/cacls/CMakeLists.txt trunk/reactos/base/applications/cacls/cacls.c trunk/reactos/base/applications/cacls/precomp.h trunk/reactos/base/applications/cmdutils/clip/CMakeLists.txt trunk/reactos/base/applications/cmdutils/clip/clip.c trunk/reactos/base/applications/cmdutils/comp/CMakeLists.txt trunk/reactos/base/applications/cmdutils/comp/comp.c (contents, props changed) trunk/reactos/base/applications/cmdutils/help/CMakeLists.txt trunk/reactos/base/applications/cmdutils/help/help.c trunk/reactos/base/applications/logoff/CMakeLists.txt trunk/reactos/base/applications/logoff/logoff.c trunk/reactos/base/applications/shutdown/CMakeLists.txt trunk/reactos/base/applications/shutdown/misc.c trunk/reactos/base/applications/shutdown/precomp.h trunk/reactos/base/applications/shutdown/shutdown.c trunk/reactos/base/system/chkdsk/CMakeLists.txt trunk/reactos/base/system/chkdsk/chkdsk.c trunk/reactos/base/system/format/CMakeLists.txt trunk/reactos/base/system/format/format.c trunk/reactos/base/system/subst/CMakeLists.txt trunk/reactos/base/system/subst/subst.c Modified: trunk/reactos/base/applications/cacls/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/CM…
============================================================================== --- trunk/reactos/base/applications/cacls/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,6 +1,8 @@ -list(APPEND SOURCE cacls.c cacls.rc) -add_executable(cacls ${SOURCE}) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + +add_executable(cacls cacls.c cacls.rc) set_module_type(cacls win32cui UNICODE) +target_link_libraries(cacls conutils ${PSEH_LIB}) add_importlibs(cacls advapi32 user32 shell32 msvcrt kernel32) add_cd_file(TARGET cacls DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/cacls/cacls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/ca…
============================================================================== --- trunk/reactos/base/applications/cacls/cacls.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/cacls.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -34,151 +34,15 @@ static -INT -LengthOfStrResource(IN HINSTANCE hInst, - IN UINT uID) -{ - HRSRC hrSrc; - HGLOBAL hRes; - LPWSTR lpName, lpStr; - - if (hInst == NULL) - { - hInst = GetModuleHandle(NULL); - } - - /* There are always blocks of 16 strings */ - lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1); - - /* Find the string table block */ - hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING); - if (hrSrc) - { - hRes = LoadResource(hInst, hrSrc); - if (hRes) - { - lpStr = LockResource(hRes); - if (lpStr) - { - UINT x; - - /* Find the string we're looking for */ - uID &= 0xF; /* position in the block, same as % 16 */ - for (x = 0; x < uID; x++) - { - lpStr += (*lpStr) + 1; - } - - /* Found the string */ - return (int)(*lpStr); - } - } - } - return -1; -} - - -static -INT -AllocAndLoadString(OUT LPTSTR *lpTarget, - IN HINSTANCE hInst, - IN UINT uID) -{ - INT ln; - - ln = LengthOfStrResource(hInst, - uID); - if (ln++ > 0) - { - (*lpTarget) = (LPTSTR)HeapAlloc(GetProcessHeap(), - 0, - ln * sizeof(TCHAR)); - if ((*lpTarget) != NULL) - { - INT Ret; - Ret = LoadString(hInst, - uID, - *lpTarget, - ln); - if (!Ret) - { - HeapFree(GetProcessHeap(), - 0, - *lpTarget); - } - return Ret; - } - } - return 0; -} - - -static -VOID -PrintHelp(VOID) -{ - LPTSTR szHelp; - - if (AllocAndLoadString(&szHelp, - NULL, - IDS_HELP) != 0) - { - _tprintf(_T("%s"), - szHelp); - - HeapFree(GetProcessHeap(), - 0, - szHelp); - } -} - - -static -VOID -PrintErrorMessage(IN DWORD dwError) -{ - LPTSTR szError; - - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - dwError, - MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), - (LPTSTR)&szError, - 0, - NULL) != 0) - { - _tprintf(_T("%s"), - szError); - LocalFree((HLOCAL)szError); - } -} - - -static -DWORD -LoadAndPrintString(IN HINSTANCE hInst, - IN UINT uID) -{ - TCHAR szTemp[255]; - DWORD Len; - - Len = (DWORD)LoadString(hInst, - uID, - szTemp, - sizeof(szTemp) / sizeof(szTemp[0])); - - if (Len != 0) - { - _tprintf(_T("%s"), - szTemp); - } - - return Len; -} - +VOID PrintError(DWORD dwError) +{ + if (dwError == ERROR_SUCCESS) + return; + + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dwError, LANG_USER_DEFAULT); +} static BOOL @@ -352,18 +216,15 @@ /* print the ACE Flags */ if (Ace->Header.AceFlags & CONTAINER_INHERIT_ACE) { - IndentAccess += LoadAndPrintString(NULL, - IDS_ABBR_CI); + IndentAccess += PrintResourceString(IDS_ABBR_CI); } if (Ace->Header.AceFlags & OBJECT_INHERIT_ACE) { - IndentAccess += LoadAndPrintString(NULL, - IDS_ABBR_OI); + IndentAccess += PrintResourceString(IDS_ABBR_OI); } if (Ace->Header.AceFlags & INHERIT_ONLY_ACE) { - IndentAccess += LoadAndPrintString(NULL, - IDS_ABBR_IO); + IndentAccess += PrintResourceString(IDS_ABBR_IO); } IndentAccess += 2; @@ -375,13 +236,11 @@ { if (AccessMask == FILE_ALL_ACCESS) { - LoadAndPrintString(NULL, - IDS_ABBR_NONE); + PrintResourceString(IDS_ABBR_NONE); } else { - LoadAndPrintString(NULL, - IDS_DENY); + PrintResourceString(IDS_DENY); goto PrintSpecialAccess; } } @@ -389,24 +248,20 @@ { if (AccessMask == FILE_ALL_ACCESS) { - LoadAndPrintString(NULL, - IDS_ABBR_FULL); + PrintResourceString(IDS_ABBR_FULL); } else if (!(Ace->Mask & (GENERIC_READ | GENERIC_EXECUTE)) && AccessMask == (FILE_GENERIC_READ | FILE_EXECUTE)) { - LoadAndPrintString(NULL, - IDS_ABBR_READ); + PrintResourceString(IDS_ABBR_READ); } else if (AccessMask == (FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_EXECUTE | DELETE)) { - LoadAndPrintString(NULL, - IDS_ABBR_CHANGE); + PrintResourceString(IDS_ABBR_CHANGE); } else if (AccessMask == FILE_GENERIC_WRITE) { - LoadAndPrintString(NULL, - IDS_ABBR_WRITE); + PrintResourceString(IDS_ABBR_WRITE); } else { @@ -446,15 +301,13 @@ {STANDARD_RIGHTS_ALL, IDS_STANDARD_RIGHTS_ALL}, }; - LoadAndPrintString(NULL, - IDS_ALLOW); + PrintResourceString(IDS_ALLOW); PrintSpecialAccess: - LoadAndPrintString(NULL, - IDS_SPECIAL_ACCESS); + PrintResourceString(IDS_SPECIAL_ACCESS); /* print the special access rights */ - x = sizeof(AccessRights) / sizeof(AccessRights[0]); + x = ARRAYSIZE(AccessRights); while (x-- != 0) { if ((Ace->Mask & AccessRights[x].Access) == AccessRights[x].Access) @@ -468,8 +321,7 @@ _tprintf(_T(" ")); } - LoadAndPrintString(NULL, - AccessRights[x].uID); + PrintResourceString(AccessRights[x].uID); } } @@ -541,7 +393,7 @@ *pch = 0; if (!GetFullPathName(FilePath, MAX_PATH, FullPath, NULL)) { - PrintErrorMessage(GetLastError()); + PrintError(GetLastError()); return FALSE; } lstrcpyn(FilePath, FullPath, MAX_PATH); @@ -549,7 +401,7 @@ attrs = GetFileAttributes(FilePath); if (attrs == 0xFFFFFFFF || !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { - PrintErrorMessage(ERROR_DIRECTORY); + PrintError(ERROR_DIRECTORY); return FALSE; } } @@ -591,7 +443,7 @@ LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED) { - PrintErrorMessage(LastError); + PrintError(LastError); if (!OptionC) { FindClose(hFind); @@ -609,7 +461,7 @@ if (LastError != ERROR_NO_MORE_FILES) { - PrintErrorMessage(LastError); + PrintError(LastError); return FALSE; } @@ -771,7 +623,7 @@ LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED) { - PrintErrorMessage(LastError); + PrintError(LastError); if (!OptionC) { FindClose(hFind); @@ -788,7 +640,7 @@ if (LastError != ERROR_NO_MORE_FILES) { - PrintErrorMessage(LastError); + PrintError(LastError); return FALSE; } @@ -826,7 +678,7 @@ LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED) { - PrintErrorMessage(LastError); + PrintError(LastError); if (!OptionC) { FindClose(hFind); @@ -843,7 +695,7 @@ if (LastError != ERROR_NO_MORE_FILES) { - PrintErrorMessage(LastError); + PrintError(LastError); return FALSE; } @@ -872,7 +724,7 @@ LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED) { - PrintErrorMessage(LastError); + PrintError(LastError); if (!OptionC) { FindClose(hFind); @@ -889,23 +741,24 @@ if (LastError != ERROR_NO_MORE_FILES) { - PrintErrorMessage(LastError); + PrintError(LastError); return FALSE; } return TRUE; } -int -__cdecl -_tmain(int argc, const TCHAR *argv[]) +int _tmain(int argc, const TCHAR *argv[]) { INT i; LPTSTR pch; BOOL InvalidParameter = FALSE; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if (argc <= 1) { - PrintHelp(); + PrintResourceString(IDS_HELP); return 0; } @@ -991,8 +844,8 @@ if (InvalidParameter) { - PrintErrorMessage(ERROR_INVALID_PARAMETER); - PrintHelp(); + PrintError(ERROR_INVALID_PARAMETER); + PrintResourceString(IDS_HELP); return 1; } Modified: trunk/reactos/base/applications/cacls/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cacls/pr…
============================================================================== --- trunk/reactos/base/applications/cacls/precomp.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/cacls/precomp.h [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -2,11 +2,14 @@ #define _CACLS_PRECOMP_H #include <stdarg.h> +#include <tchar.h> + #include <windef.h> #include <winbase.h> -#include <winuser.h> +#include <winuser.h> // For CharPrev #include <sddl.h> -#include <tchar.h> + +#include <conutils.h> #include "resource.h" Modified: trunk/reactos/base/applications/cmdutils/clip/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/clip/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/clip/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,5 +1,8 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(clip clip.c clip.rc) set_module_type(clip win32cui UNICODE) -add_importlibs(clip user32 msvcrt kernel32 advapi32) +target_link_libraries(clip conutils ${PSEH_LIB}) +add_importlibs(clip advapi32 user32 msvcrt kernel32) add_cd_file(TARGET clip DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/cmdutils/clip/clip.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/clip/clip.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/clip/clip.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -12,31 +12,18 @@ #include <winbase.h> #include <winuser.h> +#include <conutils.h> + #include "resource.h" -static void PrintError(void) +VOID PrintError(DWORD dwError) { - DWORD dwError; - LPWSTR lpMsgBuf = NULL; - - dwError = GetLastError(); - if (dwError == NO_ERROR) + if (dwError == ERROR_SUCCESS) return; - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, dwError, 0, (LPWSTR)&lpMsgBuf, 0, NULL); - wprintf(L"%s", lpMsgBuf); - LocalFree(lpMsgBuf); -} - -static void PrintResourceString(UINT uID) -{ - WCHAR buff[500]; - - if (LoadStringW(GetModuleHandle(NULL), uID, buff, ARRAYSIZE(buff))) - { - wprintf(L"%s", buff); - } + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dwError, LANG_USER_DEFAULT); } static BOOL IsDataUnicode(HGLOBAL hGlobal) @@ -61,28 +48,27 @@ LPBYTE lpBuffer; SIZE_T dwSize = 0; + /* Initialize the Console Standard Streams */ hInput = GetStdHandle(STD_INPUT_HANDLE); + ConInitStdStreams(); /* Check for usage */ if (argc > 1 && wcsncmp(argv[1], L"/?", 2) == 0) { - PrintResourceString(IDS_HELP); + ConResPrintf(StdOut, IDS_HELP); return 0; } if (GetFileType(hInput) == FILE_TYPE_CHAR) { - PrintResourceString(IDS_USAGE); + ConResPrintf(StdOut, IDS_USAGE); return 0; } /* Initialize a growable buffer for holding clipboard data */ hBuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 4096); if (!hBuffer) - { - PrintError(); - return -1; - } + goto Failure; /* * Read data from the input stream by chunks of 4096 bytes @@ -92,7 +78,7 @@ { lpBuffer = GlobalLock(hBuffer); if (!lpBuffer) - goto cleanup; + goto Failure; bStatus = ReadFile(hInput, lpBuffer + dwSize, 4096, &dwBytesRead, NULL); dwSize += dwBytesRead; @@ -100,7 +86,7 @@ hTemp = GlobalReAlloc(hBuffer, GlobalSize(hBuffer) + 4096, GMEM_ZEROINIT); if (!hTemp) - goto cleanup; + goto Failure; hBuffer = hTemp; } @@ -118,7 +104,7 @@ /* Attempt to open the clipboard */ if (!OpenClipboard(NULL)) - goto cleanup; + goto Failure; /* Empty it, copy our data, then close it */ @@ -138,8 +124,8 @@ CloseClipboard(); return 0; -cleanup: - GlobalFree(hBuffer); - PrintError(); +Failure: + if (hBuffer) GlobalFree(hBuffer); + PrintError(GetLastError()); return -1; } Modified: trunk/reactos/base/applications/cmdutils/comp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/comp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/comp/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,5 +1,8 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(comp comp.c comp.rc) set_module_type(comp win32cui UNICODE) -add_importlibs(comp user32 msvcrt kernel32) +target_link_libraries(comp conutils ${PSEH_LIB}) +add_importlibs(comp msvcrt kernel32) add_cd_file(TARGET comp DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/cmdutils/comp/comp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/comp/comp.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/comp/comp.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,273 +1,251 @@ -/* - * ReactOS Win32 Applications - * Copyright (C) 2005 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -/* - * PROJECT: ReactOS Comp utility - * COPYRIGHT: See COPYING in the top level directory - * FILE: base/applications/cmdutils/comp/comp.c - * PURPOSE: Compares the contents of two files - * PROGRAMMERS: Ged Murphy (gedmurphy(a)gmail.com) - */ - -#include <stdio.h> -#include <stdlib.h> -// #include <string.h> -// #include <wchar.h> -#include <assert.h> - -#define WIN32_NO_STATUS -#include <windef.h> -#include <winbase.h> -#include <winuser.h> - -#include "resource.h" - -#define STRBUF 1024 - -VOID PrintResourceString(INT resID, ...) -{ - WCHAR bufSrc[RC_STRING_MAX_SIZE]; - WCHAR bufFormatted[RC_STRING_MAX_SIZE]; - CHAR bufFormattedOem[RC_STRING_MAX_SIZE]; - - va_list args; - va_start(args, resID); - - if (LoadStringW(GetModuleHandleW(NULL), resID, bufSrc, ARRAYSIZE(bufSrc))) - vswprintf(bufFormatted, bufSrc, args); - else - swprintf(bufFormatted, L"Resource loading error!"); - - CharToOemW(bufFormatted, bufFormattedOem); - fputs(bufFormattedOem, stdout); - - va_end(args); -} - -/* getline: read a line, return length */ -INT GetBuff(PBYTE buff, FILE* in) -{ - return fread(buff, sizeof(BYTE), STRBUF, in); -} - -INT FileSize(FILE* fd) -{ - INT result = -1; - if (fseek(fd, 0, SEEK_END) == 0 && (result = ftell(fd)) != -1) - { - /* Restoring file pointer */ - rewind(fd); - } - return result; -} - -/* Print program usage */ -VOID Usage(VOID) -{ - PrintResourceString(IDS_HELP); -} - - -int wmain (int argc, WCHAR* argv[]) -{ - INT i; - - /* File pointers */ - FILE *fp1 = NULL; - FILE *fp2 = NULL; - - INT BufLen1, BufLen2; - PBYTE Buff1 = NULL; - PBYTE Buff2 = NULL; - WCHAR File1[_MAX_PATH + 1], // File paths - File2[_MAX_PATH + 1]; - BOOL bAscii = FALSE, // /A switch - bLineNos = FALSE; // /L switch - UINT LineNumber; - UINT Offset; - INT FileSizeFile1; - INT FileSizeFile2; - INT NumberOfOptions = 0; - INT FilesOK = 1; - INT Status = EXIT_SUCCESS; - - /* Parse command line for options */ - for (i = 1; i < argc; i++) - { - if (argv[i][0] == L'/') - { - switch (argv[i][1]) - { - case L'A': - bAscii = TRUE; - NumberOfOptions++; - break; - - case L'L': - bLineNos = TRUE; - NumberOfOptions++; - break; - - case L'?': - Usage(); - return EXIT_SUCCESS; - - default: - PrintResourceString(IDS_INVALIDSWITCH, argv[i][1]); - Usage(); - return EXIT_FAILURE; - } - } - } - - if (argc - NumberOfOptions == 3) - { - wcsncpy(File1, argv[1 + NumberOfOptions], _MAX_PATH); - wcsncpy(File2, argv[2 + NumberOfOptions], _MAX_PATH); - } - else - { - PrintResourceString(IDS_BADSYNTAX); - return EXIT_FAILURE; - } - - Buff1 = (PBYTE)malloc(STRBUF); - if (Buff1 == NULL) - { - wprintf(L"Can't get free memory for Buff1\n"); - Status = EXIT_FAILURE; - goto Cleanup; - } - - Buff2 = (PBYTE)malloc(STRBUF); - if (Buff2 == NULL) - { - wprintf(L"Can't get free memory for Buff2\n"); - Status = EXIT_FAILURE; - goto Cleanup; - } - - if ((fp1 = _wfopen(File1, L"rb")) == NULL) - { - PrintResourceString(IDS_FILEERROR, File1); - Status = EXIT_FAILURE; - goto Cleanup; - } - if ((fp2 = _wfopen(File2, L"rb")) == NULL) - { - PrintResourceString(IDS_FILEERROR, File2); - Status = EXIT_FAILURE; - goto Cleanup; - } - - PrintResourceString(IDS_COMPARING, File1, File2); - - FileSizeFile1 = FileSize(fp1); - if (FileSizeFile1 == -1) - { - PrintResourceString(IDS_FILESIZEERROR, File1); - Status = EXIT_FAILURE; - goto Cleanup; - } - - FileSizeFile2 = FileSize(fp2); - if (FileSizeFile2 == -1) - { - PrintResourceString(IDS_FILESIZEERROR, File2); - Status = EXIT_FAILURE; - goto Cleanup; - } - - if (FileSizeFile1 != FileSizeFile2) - { - PrintResourceString(IDS_SIZEDIFFERS); - Status = EXIT_FAILURE; - goto Cleanup; - } - - LineNumber = 1; - Offset = 0; - while (1) - { - BufLen1 = GetBuff(Buff1, fp1); - BufLen2 = GetBuff(Buff2, fp2); - - if (ferror(fp1) || ferror(fp2)) - { - PrintResourceString(IDS_READERROR); - Status = EXIT_FAILURE; - goto Cleanup; - } - - if (!BufLen1 && !BufLen2) - break; - - assert(BufLen1 == BufLen2); - for (i = 0; i < BufLen1; i++) - { - if (Buff1[i] != Buff2[i]) - { - FilesOK = 0; - - /* Reporting here a mismatch */ - if (bLineNos) - { - PrintResourceString(IDS_MISMATCHLINE, LineNumber); - } - else - { - PrintResourceString(IDS_MISMATCHOFFSET, Offset); - } - - if (bAscii) - { - PrintResourceString(IDS_ASCIIDIFF, 1, Buff1[i]); - PrintResourceString(IDS_ASCIIDIFF, 2, Buff2[i]); - } - else - { - PrintResourceString(IDS_HEXADECIMALDIFF, 1, Buff1[i]); - PrintResourceString(IDS_HEXADECIMALDIFF, 2, Buff2[i]); - } - } - - Offset++; - - if (Buff1[i] == '\n') - LineNumber++; - } - } - - if (FilesOK) - PrintResourceString(IDS_MATCH); - -Cleanup: - if (fp2) - fclose(fp2); - if (fp1) - fclose(fp1); - - if (Buff2) - free(Buff2); - if (Buff1) - free(Buff1); - - return Status; -} - -/* EOF */ +/* + * ReactOS Win32 Applications + * Copyright (C) 2005 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * PROJECT: ReactOS Comp utility + * COPYRIGHT: See COPYING in the top level directory + * FILE: base/applications/cmdutils/comp/comp.c + * PURPOSE: Compares the contents of two files + * PROGRAMMERS: Ged Murphy (gedmurphy(a)gmail.com) + */ + +#include <stdio.h> +#include <stdlib.h> +// #include <string.h> +// #include <wchar.h> +#include <assert.h> + +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> + +#include <conutils.h> + +#include "resource.h" + +#define STRBUF 1024 + +/* getline: read a line, return length */ +INT GetBuff(PBYTE buff, FILE* in) +{ + return fread(buff, sizeof(BYTE), STRBUF, in); +} + +INT FileSize(FILE* fd) +{ + INT result = -1; + if (fseek(fd, 0, SEEK_END) == 0 && (result = ftell(fd)) != -1) + { + /* Restoring file pointer */ + rewind(fd); + } + return result; +} + + +int wmain (int argc, WCHAR* argv[]) +{ + INT i; + + /* File pointers */ + FILE *fp1 = NULL; + FILE *fp2 = NULL; + + INT BufLen1, BufLen2; + PBYTE Buff1 = NULL; + PBYTE Buff2 = NULL; + WCHAR File1[_MAX_PATH + 1], // File paths + File2[_MAX_PATH + 1]; + BOOL bAscii = FALSE, // /A switch + bLineNos = FALSE; // /L switch + UINT LineNumber; + UINT Offset; + INT FileSizeFile1; + INT FileSizeFile2; + INT NumberOfOptions = 0; + INT FilesOK = 1; + INT Status = EXIT_SUCCESS; + + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + + /* Parse command line for options */ + for (i = 1; i < argc; i++) + { + if (argv[i][0] == L'/') + { + switch (towlower(argv[i][1])) + { + case L'a': + bAscii = TRUE; + NumberOfOptions++; + break; + + case L'l': + bLineNos = TRUE; + NumberOfOptions++; + break; + + case L'?': + PrintResourceString(IDS_HELP); + return EXIT_SUCCESS; + + default: + PrintResourceString(IDS_INVALIDSWITCH, argv[i][1]); + PrintResourceString(IDS_HELP); + return EXIT_FAILURE; + } + } + } + + if (argc - NumberOfOptions == 3) + { + wcsncpy(File1, argv[1 + NumberOfOptions], _MAX_PATH); + wcsncpy(File2, argv[2 + NumberOfOptions], _MAX_PATH); + } + else + { + PrintResourceString(IDS_BADSYNTAX); + return EXIT_FAILURE; + } + + Buff1 = (PBYTE)malloc(STRBUF); + if (Buff1 == NULL) + { + ConPrintf(StdErr, L"Can't get free memory for Buff1\n"); + Status = EXIT_FAILURE; + goto Cleanup; + } + + Buff2 = (PBYTE)malloc(STRBUF); + if (Buff2 == NULL) + { + ConPrintf(StdErr, L"Can't get free memory for Buff2\n"); + Status = EXIT_FAILURE; + goto Cleanup; + } + + if ((fp1 = _wfopen(File1, L"rb")) == NULL) + { + PrintResourceString(IDS_FILEERROR, File1); + Status = EXIT_FAILURE; + goto Cleanup; + } + if ((fp2 = _wfopen(File2, L"rb")) == NULL) + { + PrintResourceString(IDS_FILEERROR, File2); + Status = EXIT_FAILURE; + goto Cleanup; + } + + PrintResourceString(IDS_COMPARING, File1, File2); + + FileSizeFile1 = FileSize(fp1); + if (FileSizeFile1 == -1) + { + PrintResourceString(IDS_FILESIZEERROR, File1); + Status = EXIT_FAILURE; + goto Cleanup; + } + + FileSizeFile2 = FileSize(fp2); + if (FileSizeFile2 == -1) + { + PrintResourceString(IDS_FILESIZEERROR, File2); + Status = EXIT_FAILURE; + goto Cleanup; + } + + if (FileSizeFile1 != FileSizeFile2) + { + PrintResourceString(IDS_SIZEDIFFERS); + Status = EXIT_FAILURE; + goto Cleanup; + } + + LineNumber = 1; + Offset = 0; + while (1) + { + BufLen1 = GetBuff(Buff1, fp1); + BufLen2 = GetBuff(Buff2, fp2); + + if (ferror(fp1) || ferror(fp2)) + { + PrintResourceString(IDS_READERROR); + Status = EXIT_FAILURE; + goto Cleanup; + } + + if (!BufLen1 && !BufLen2) + break; + + assert(BufLen1 == BufLen2); + for (i = 0; i < BufLen1; i++) + { + if (Buff1[i] != Buff2[i]) + { + FilesOK = 0; + + /* Reporting here a mismatch */ + if (bLineNos) + { + PrintResourceString(IDS_MISMATCHLINE, LineNumber); + } + else + { + PrintResourceString(IDS_MISMATCHOFFSET, Offset); + } + + if (bAscii) + { + PrintResourceString(IDS_ASCIIDIFF, 1, Buff1[i]); + PrintResourceString(IDS_ASCIIDIFF, 2, Buff2[i]); + } + else + { + PrintResourceString(IDS_HEXADECIMALDIFF, 1, Buff1[i]); + PrintResourceString(IDS_HEXADECIMALDIFF, 2, Buff2[i]); + } + } + + Offset++; + + if (Buff1[i] == '\n') + LineNumber++; + } + } + + if (FilesOK) + PrintResourceString(IDS_MATCH); + +Cleanup: + if (fp2) + fclose(fp2); + if (fp1) + fclose(fp1); + + if (Buff2) + free(Buff2); + if (Buff1) + free(Buff1); + + return Status; +} + +/* EOF */ Propchange: trunk/reactos/base/applications/cmdutils/comp/comp.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/base/applications/cmdutils/help/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/help/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/help/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,6 +1,9 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(cmd_help help.c help.rc) set_module_type(cmd_help win32cui UNICODE) -add_importlibs(cmd_help user32 msvcrt kernel32) +target_link_libraries(cmd_help conutils ${PSEH_LIB}) +add_importlibs(cmd_help msvcrt kernel32) set_target_properties(cmd_help PROPERTIES OUTPUT_NAME "help") add_cd_file(TARGET cmd_help DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/cmdutils/help/help.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/help/help.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/help/help.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -14,29 +14,13 @@ #define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> -#include <winuser.h> -#include <wincon.h> + #include <strsafe.h> + +#include <conutils.h> #include "help.h" #include "resource.h" - -VOID PrintResourceString(INT resID, ...) -{ - WCHAR bufSrc[RC_STRING_MAX_SIZE]; - WCHAR bufFormatted[RC_STRING_MAX_SIZE]; - CHAR bufFormattedOem[RC_STRING_MAX_SIZE]; - - va_list args; - va_start(args, resID); - - LoadStringW(GetModuleHandleW(NULL), resID, bufSrc, ARRAYSIZE(bufSrc)); - vswprintf(bufFormatted, bufSrc, args); - CharToOemW(bufFormatted, bufFormattedOem); - fputs(bufFormattedOem, stdout); - - va_end(args); -} BOOL IsInternalCommand(LPCWSTR Cmd) { @@ -73,6 +57,9 @@ { WCHAR CmdLine[CMDLINE_LENGTH]; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + /* * If the user hasn't asked for specific help, * then print out the list of available commands. @@ -108,7 +95,7 @@ * Run "<command> /?" in the current command processor. */ StringCbPrintfW(CmdLine, sizeof(CmdLine), L"%ls /?", argv[1]); - + _flushall(); return _wsystem(CmdLine); } Modified: trunk/reactos/base/applications/logoff/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/C…
============================================================================== --- trunk/reactos/base/applications/logoff/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,11 +1,8 @@ -list(APPEND SOURCE - misc.c - logoff.c - precomp.h) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) -add_executable(logoff ${SOURCE} logoff.rc) -set_module_type(logoff win32cui) +add_executable(logoff logoff.c logoff.rc) +set_module_type(logoff win32cui UNICODE) +target_link_libraries(logoff conutils ${PSEH_LIB}) add_importlibs(logoff advapi32 user32 msvcrt kernel32) -add_pch(logoff precomp.h SOURCE) add_cd_file(TARGET logoff DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/logoff/logoff.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/l…
============================================================================== --- trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/logoff.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -11,88 +11,61 @@ * with Windows' system32\logoff.exe commandline application. */ -#include "precomp.h" +#include <stdio.h> -#include <stdio.h> -#include <tchar.h> +#include <windef.h> +#include <winbase.h> +#include <winuser.h> -//Commandline argument switches -LPTSTR szRemoteServerName = NULL; +#include <conutils.h> + +#include "resource.h" + +// Commandline argument switches +LPWSTR szRemoteServerName = NULL; BOOL bVerbose; - -//---------------------------------------------------------------------- -// -//Retrieve resource string and output the Usage to the console -// -//---------------------------------------------------------------------- -static void PrintUsage() { - LPTSTR lpUsage = NULL; - - if (AllocAndLoadString(&lpUsage, GetModuleHandle(NULL), IDS_USAGE)) { - _putts(lpUsage); - LocalFree(lpUsage); - } - -} //---------------------------------------------------------------------- // // Writes the last error as both text and error code to the console. // //---------------------------------------------------------------------- -void DisplayLastError() +VOID DisplayError(DWORD dwError) { - int errorCode = GetLastError(); - LPTSTR lpMsgBuf; - - // Display the error message to the user - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errorCode, - LANG_USER_DEFAULT, - (LPTSTR) &lpMsgBuf, - 0, - NULL); - - _ftprintf(stderr, lpMsgBuf); - _ftprintf(stderr, _T("Error code: %d\n"), errorCode); - - LocalFree(lpMsgBuf); + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dwError, LANG_USER_DEFAULT); + ConPrintf(StdErr, L"Error code: %lu\n", dwError); } //---------------------------------------------------------------------- // -//Sets flags based on commandline arguments +// Sets flags based on commandline arguments // //---------------------------------------------------------------------- -BOOL ParseCommandLine(int argc, TCHAR *argv[]) +BOOL ParseCommandLine(int argc, WCHAR *argv[]) { int i; - LPTSTR lpIllegalMsg; //FIXME: Add handling of commandline arguments to select the session number and name, and also name of remote machine //Example: logoff.exe 4 /SERVER:Master should logoff session number 4 on remote machine called Master. for (i = 1; i < argc; i++) { switch(argv[i][0]){ - case '-': - case '/': + case L'-': + case L'/': // -v (verbose) - if (argv[i][1] == 'v') { + if (argv[i][1] == L'v') { bVerbose = TRUE; break; //continue parsing the arguments } // -? (usage) - else if(argv[i][1] == '?') { + else if(argv[i][1] == L'?') { return FALSE; //display the Usage } default: //Invalid parameter detected - if (AllocAndLoadString(&lpIllegalMsg, GetModuleHandle(NULL), IDS_ILLEGAL_PARAM)) { - _putts(lpIllegalMsg); - LocalFree(lpIllegalMsg); - } + ConResPrintf(StdErr, IDS_ILLEGAL_PARAM); return FALSE; } } @@ -102,46 +75,45 @@ //---------------------------------------------------------------------- // -//Main entry for program +// Main entry for program // //---------------------------------------------------------------------- -int _tmain(int argc, TCHAR *argv[]) +int wmain(int argc, WCHAR *argv[]) { - LPTSTR lpLogoffRemote, lpLogoffLocal; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); // // Parse command line // if (!ParseCommandLine(argc, argv)) { - PrintUsage(); + ConResPrintf(StdOut, IDS_USAGE); return 1; } // - //Should we log off session on remote server? + // Should we log off session on remote server? // if (szRemoteServerName) { if (bVerbose) { - if (AllocAndLoadString(&lpLogoffRemote, GetModuleHandle(NULL), IDS_LOGOFF_REMOTE)) - _putts(lpLogoffRemote); + ConResPrintf(StdOut, IDS_LOGOFF_REMOTE); } - //FIXME: Add Remote Procedure Call to logoff user on a remote machine - _ftprintf(stderr, "Remote Procedure Call in logoff.exe has not been implemented"); + // FIXME: Add Remote Procedure Call to logoff user on a remote machine + ConPrintf(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented"); } // - //Perform logoff of current session on local machine instead + // Perform logoff of current session on local machine instead // else { if (bVerbose) { - //Get resource string, and print it. - if (AllocAndLoadString(&lpLogoffLocal, GetModuleHandle(NULL), IDS_LOGOFF_LOCAL)) - _putts(lpLogoffLocal); + // Get resource string, and print it. + ConResPrintf(StdOut, IDS_LOGOFF_LOCAL); } - //Actual logoff - if (!ExitWindows(NULL, NULL)) { - DisplayLastError(); + // Actual logoff + if (!ExitWindowsEx(EWX_LOGOFF, 0)) { + DisplayError(GetLastError()); return 1; } } Removed: trunk/reactos/base/applications/logoff/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/m…
============================================================================== --- trunk/reactos/base/applications/logoff/misc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/misc.c (removed) @@ -1,63 +0,0 @@ -#include "precomp.h" - -static INT -LengthOfStrResource(IN HINSTANCE hInst, - IN UINT uID) -{ - HRSRC hrSrc; - HGLOBAL hRes; - LPWSTR lpName, lpStr; - - if (hInst == NULL) - { - return -1; - } - - /* There are always blocks of 16 strings */ - lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1); - - /* Find the string table block */ - if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) && - (hRes = LoadResource(hInst, hrSrc)) && - (lpStr = (WCHAR*) LockResource(hRes))) - { - UINT x; - - /* Find the string we're looking for */ - uID &= 0xF; /* position in the block, same as % 16 */ - for (x = 0; x < uID; x++) - { - lpStr += (*lpStr) + 1; - } - - /* Found the string */ - return (int)(*lpStr); - } - return -1; -} - -INT -AllocAndLoadString(OUT LPTSTR *lpTarget, - IN HINSTANCE hInst, - IN UINT uID) -{ - INT ln; - - ln = LengthOfStrResource(hInst, - uID); - if (ln++ > 0) - { - (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED, - ln * sizeof(TCHAR)); - if ((*lpTarget) != NULL) - { - INT Ret; - if (!(Ret = LoadString(hInst, uID, *lpTarget, ln))) - { - LocalFree((HLOCAL)(*lpTarget)); - } - return Ret; - } - } - return 0; -} Removed: trunk/reactos/base/applications/logoff/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/logoff/p…
============================================================================== --- trunk/reactos/base/applications/logoff/precomp.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/logoff/precomp.h (removed) @@ -1,17 +0,0 @@ -#ifndef __SHUTDOWN_PRECOMP_H -#define __SHUTDOWN_PRECOMP_H - -#include <stdarg.h> - -#include <windef.h> -#include <winbase.h> -#include <winuser.h> - -#include "resource.h" - -/* misc.c */ -INT AllocAndLoadString(OUT LPTSTR *lpTarget, - IN HINSTANCE hInst, - IN UINT uID); - -#endif /* __SHUTDOWN_PRECOMP_H */ Modified: trunk/reactos/base/applications/shutdown/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,3 +1,5 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) list(APPEND SOURCE gui.c @@ -7,6 +9,7 @@ add_executable(shutdown ${SOURCE} shutdown.rc) set_module_type(shutdown win32cui UNICODE) +target_link_libraries(shutdown conutils ${PSEH_LIB}) add_importlibs(shutdown advapi32 user32 powrprof msvcrt kernel32) add_pch(shutdown precomp.h SOURCE) add_cd_file(TARGET shutdown DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/shutdown/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/misc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/misc.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -162,29 +162,10 @@ /* Writes the last error as both text and error code to the console */ VOID DisplayError(DWORD dwError) { - LPWSTR lpMsgBuf = NULL; - DWORD errLength; /* Error message length */ - LPSTR resMsg; /* For error message in OEM symbols */ - - /* Grabs the length of the error message */ - errLength = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - dwError, - LANG_USER_DEFAULT, - (LPWSTR)&lpMsgBuf, - 0, - NULL) + 1; - - /* Gets the error message ready for output */ - resMsg = (LPSTR)LocalAlloc(LPTR, errLength * sizeof(WCHAR)); - CharToOemBuffW(lpMsgBuf, resMsg, errLength); - - /* Prints out the error message to the user */ - fprintf(stderr, resMsg); - fwprintf(stderr, L"Error code: %lu\n", dwError); - - LocalFree(lpMsgBuf); - LocalFree(resMsg); + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dwError, LANG_USER_DEFAULT); + ConPrintf(StdErr, L"Error code: %lu\n", dwError); } /* EOF */ Modified: trunk/reactos/base/applications/shutdown/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/precomp.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/precomp.h [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -10,14 +10,16 @@ #include <winreg.h> #include <winuser.h> +#include <conutils.h> + #include "resource.h" /* DEFINES *******************************************************************/ + #define MAX_MESSAGE_SIZE 512 #define MAX_MAJOR_CODE 256 #define MAX_MINOR_CODE 65536 #define MAX_TIMEOUT 315360000 -#define MAX_BUFFER_SIZE 5024 /* Reason Code List */ typedef struct _REASON Modified: trunk/reactos/base/applications/shutdown/shutdown.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/shutdown…
============================================================================== --- trunk/reactos/base/applications/shutdown/shutdown.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/shutdown/shutdown.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -10,21 +10,6 @@ #include <stdlib.h> #include <tchar.h> #include <powrprof.h> - -/* - * This takes strings from a resource stringtable - * and outputs it to the console. - */ -VOID PrintResourceString(INT resID, ...) -{ - WCHAR tmpBuffer[MAX_BUFFER_SIZE]; - va_list arg_ptr; - - va_start(arg_ptr, resID); - LoadStringW(GetModuleHandle(NULL), resID, tmpBuffer, MAX_BUFFER_SIZE); - vfwprintf(stdout, tmpBuffer, arg_ptr); - va_end(arg_ptr); -} /* * Takes the commandline arguments, and creates a @@ -202,6 +187,9 @@ DWORD error = ERROR_SUCCESS; struct CommandLineOptions opts; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if (argc == 1) /* i.e. no commandline arguments given */ { PrintResourceString(IDS_USAGE); Modified: trunk/reactos/base/system/chkdsk/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/chkdsk/CMakeLi…
============================================================================== --- trunk/reactos/base/system/chkdsk/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/chkdsk/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,7 +1,9 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/fmifs) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(chkdsk chkdsk.c chkdsk.rc) set_module_type(chkdsk win32cui UNICODE) +target_link_libraries(chkdsk conutils ${PSEH_LIB}) add_importlibs(chkdsk fmifs msvcrt kernel32 ntdll) add_cd_file(TARGET chkdsk DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/system/chkdsk/chkdsk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/chkdsk/chkdsk.…
============================================================================== --- trunk/reactos/base/system/chkdsk/chkdsk.c [iso-8859-1] (original) +++ trunk/reactos/base/system/chkdsk/chkdsk.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -47,6 +47,8 @@ #include <winbase.h> #include <wincon.h> +#include <conutils.h> + #define NTOS_MODE_USER #include <ndk/ntndk.h> @@ -60,7 +62,7 @@ // BOOL Error = FALSE; -// switches +// Switches BOOL FixErrors = FALSE; BOOL SkipClean = FALSE; BOOL ScanSectors = FALSE; @@ -85,15 +87,11 @@ //---------------------------------------------------------------------- static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode) { - LPWSTR lpMsgBuf; - - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, ErrorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&lpMsgBuf, 0, NULL); - - wprintf(L"%s: %s\n", Message, lpMsgBuf); - LocalFree(lpMsgBuf); + ConPrintf(StdErr, L"%s: ", Message); + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, ErrorCode, LANG_USER_DEFAULT); + ConPrintf(StdErr, L"\n"); } @@ -126,13 +124,14 @@ static VOID Usage(PWCHAR ProgramName) { - wprintf(L"Usage: %s [drive:] [-F] [-V] [-R] [-C]\n\n" - L"[drive:] Specifies the drive to check.\n" - L"-F Fixes errors on the disk.\n" - L"-V Displays the full path of every file on the disk.\n" - L"-R Locates bad sectors and recovers readable information.\n" - L"-C Checks the drive only if it is dirty.\n\n", - ProgramName); + ConPrintf(StdOut, + L"Usage: %s [drive:] [-F] [-V] [-R] [-C]\n\n" + L"[drive:] Specifies the drive to check.\n" + L"-F Fixes errors on the disk.\n" + L"-V Displays the full path of every file on the disk.\n" + L"-R Locates bad sectors and recovers readable information.\n" + L"-C Checks the drive only if it is dirty.\n\n", + ProgramName); } @@ -241,76 +240,76 @@ switch (Command) { case UNKNOWN2: - wprintf(L"UNKNOWN2\r"); + ConPrintf(StdOut, L"UNKNOWN2\r"); break; case UNKNOWN3: - wprintf(L"UNKNOWN3\n"); + ConPrintf(StdOut, L"UNKNOWN3\n"); break; case UNKNOWN4: - wprintf(L"UNKNOWN4\n"); + ConPrintf(StdOut, L"UNKNOWN4\n"); break; case UNKNOWN5: - wprintf(L"UNKNOWN5\n"); + ConPrintf(StdOut, L"UNKNOWN5\n"); break; case FSNOTSUPPORTED: - wprintf(L"FSNOTSUPPORTED\n"); + ConPrintf(StdOut, L"FSNOTSUPPORTED\n"); break; case VOLUMEINUSE: - wprintf(L"VOLUMEINUSE\n"); + ConPrintf(StdOut, L"VOLUMEINUSE\n"); break; case UNKNOWN9: - wprintf(L"UNKNOWN9\n"); + ConPrintf(StdOut, L"UNKNOWN9\n"); break; case UNKNOWNA: - wprintf(L"UNKNOWNA\n"); + ConPrintf(StdOut, L"UNKNOWNA\n"); break; case UNKNOWNC: - wprintf(L"UNKNOWNC\n"); + ConPrintf(StdOut, L"UNKNOWNC\n"); break; case UNKNOWND: - wprintf(L"UNKNOWND\n"); + ConPrintf(StdOut, L"UNKNOWND\n"); break; case INSUFFICIENTRIGHTS: - wprintf(L"INSUFFICIENTRIGHTS\n"); + ConPrintf(StdOut, L"INSUFFICIENTRIGHTS\n"); break; case STRUCTUREPROGRESS: - wprintf(L"STRUCTUREPROGRESS\n"); + ConPrintf(StdOut, L"STRUCTUREPROGRESS\n"); break; case DONEWITHSTRUCTURE: - wprintf(L"DONEWITHSTRUCTURE\n"); + ConPrintf(StdOut, L"DONEWITHSTRUCTURE\n"); break; case CLUSTERSIZETOOSMALL: - wprintf(L"CLUSTERSIZETOOSMALL\n"); + ConPrintf(StdOut, L"CLUSTERSIZETOOSMALL\n"); break; case PROGRESS: percent = (PDWORD)Argument; - wprintf(L"%d percent completed.\r", *percent); + ConPrintf(StdOut, L"%d percent completed.\r", *percent); break; case OUTPUT: output = (PTEXTOUTPUT)Argument; - wprintf(L"%S", output->Output); + ConPrintf(StdOut, L"%S", output->Output); break; case DONE: status = (PBOOLEAN)Argument; if (*status == FALSE) { - wprintf(L"Chkdsk was unable to complete successfully.\n\n"); + ConPrintf(StdOut, L"Chkdsk was unable to complete successfully.\n\n"); Error = TRUE; } break; @@ -361,16 +360,20 @@ wmain(int argc, WCHAR *argv[]) { int badArg; - HANDLE volumeHandle; - WCHAR fileSystem[1024]; - WCHAR volumeName[1024]; - DWORD serialNumber; - DWORD flags, maxComponent; - - wprintf(L"\n" - L"Chkdskx v1.0.1 by Mark Russinovich\n" - L"Systems Internals -
http://www.sysinternals.com\n
" - L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n"); + HANDLE volumeHandle; + WCHAR fileSystem[1024]; + WCHAR volumeName[1024]; + DWORD serialNumber; + DWORD flags, maxComponent; + + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + + ConPrintf(StdOut, + L"\n" + L"Chkdskx v1.0.1 by Mark Russinovich\n" + L"Systems Internals -
http://www.sysinternals.com\n
" + L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n"); #ifndef FMIFS_IMPORT_DLL // @@ -378,7 +381,7 @@ // if (!LoadFMIFSEntryPoints()) { - wprintf(L"Could not located FMIFS entry points.\n\n"); + ConPrintf(StdErr, L"Could not located FMIFS entry points.\n\n"); return -1; } #endif @@ -389,7 +392,7 @@ badArg = ParseCommandLine(argc, argv); if (badArg) { - wprintf(L"Unknown argument: %s\n", argv[badArg]); + ConPrintf(StdOut, L"Unknown argument: %s\n", argv[badArg]); Usage(argv[0]); return -1; } @@ -445,7 +448,7 @@ 0); if (volumeHandle == INVALID_HANDLE_VALUE) { - wprintf(L"Chdskx cannot run because the volume is in use by another process.\n\n"); + ConPrintf(StdErr, L"Chkdsk cannot run because the volume is in use by another process.\n\n"); return -1; } CloseHandle(volumeHandle); @@ -459,7 +462,7 @@ // // Just do it // - wprintf(L"The type of file system is %s.\n", fileSystem); + ConPrintf(StdOut, L"The type of file system is %s.\n", fileSystem); Chkdsk(Drive, fileSystem, FixErrors, Modified: trunk/reactos/base/system/format/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/format/CMakeLi…
============================================================================== --- trunk/reactos/base/system/format/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/format/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,8 +1,10 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/fmifs) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(format format.c format.rc) set_module_type(format win32cui UNICODE) +target_link_libraries(format conutils ${PSEH_LIB}) +add_importlibs(format fmifs msvcrt kernel32 ntdll) set_target_properties(format PROPERTIES SUFFIX ".com") -add_importlibs(format user32 fmifs msvcrt kernel32 ntdll) add_cd_file(TARGET format DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/system/format/format.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/format/format.…
============================================================================== --- trunk/reactos/base/system/format/format.c [iso-8859-1] (original) +++ trunk/reactos/base/system/format/format.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -46,8 +46,8 @@ #define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> -#include <winnls.h> -#include <winuser.h> + +#include <conutils.h> #define NTOS_MODE_USER #include <ndk/rtlfuncs.h> @@ -62,7 +62,7 @@ // Globals BOOL Error = FALSE; -// switches +// Switches BOOL QuickFormat = FALSE; DWORD ClusterSize = 0; BOOL CompressDrive = FALSE; @@ -107,39 +107,6 @@ }; -VOID PrintStringV(LPWSTR szStr, va_list args) -{ - WCHAR bufFormatted[RC_STRING_MAX_SIZE]; - CHAR bufFormattedOem[RC_STRING_MAX_SIZE]; - - _vsnwprintf(bufFormatted, ARRAYSIZE(bufFormatted), szStr, args); - - CharToOemW(bufFormatted, bufFormattedOem); - puts(bufFormattedOem); -} - -VOID PrintString(LPWSTR szStr, ...) -{ - va_list args; - - va_start(args, szStr); - PrintStringV(szStr, args); - va_end(args); -} - -VOID PrintResourceString(UINT uID, ...) -{ - WCHAR bufSrc[RC_STRING_MAX_SIZE]; - va_list args; - - LoadStringW(GetModuleHandleW(NULL), uID, bufSrc, ARRAYSIZE(bufSrc)); - - va_start(args, uID); - PrintStringV(bufSrc, args); - va_end(args); -} - - //---------------------------------------------------------------------- // // PrintWin32Error @@ -149,15 +116,11 @@ //---------------------------------------------------------------------- static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode) { - LPWSTR lpMsgBuf; - - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, ErrorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&lpMsgBuf, 0, NULL); - - PrintString(L"%s: %s\n", Message, lpMsgBuf); - LocalFree(lpMsgBuf); + ConPrintf(StdErr, L"%s: ", Message); + ConMsgPrintf(StdErr, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, ErrorCode, LANG_USER_DEFAULT); + ConPrintf(StdErr, L"\n"); } @@ -266,19 +229,19 @@ { case PROGRESS: percent = (PDWORD)Argument; - PrintResourceString(STRING_COMPLETE, *percent); + ConResPrintf(StdOut, STRING_COMPLETE, *percent); break; case OUTPUT: output = (PTEXTOUTPUT)Argument; - wprintf(L"%S", output->Output); + ConPrintf(StdOut, L"%S\n", output->Output); break; case DONE: status = (PBOOLEAN)Argument; if (*status == FALSE) { - PrintResourceString(STRING_FORMAT_FAIL); + ConResPrintf(StdOut, STRING_FORMAT_FAIL); Error = TRUE; } break; @@ -297,7 +260,7 @@ case UNKNOWND: case STRUCTUREPROGRESS: case CLUSTERSIZETOOSMALL: - PrintResourceString(STRING_NO_SUPPORT); + ConResPrintf(StdOut, STRING_NO_SUPPORT); return FALSE; } return TRUE; @@ -359,12 +322,12 @@ BYTE dummy; BOOLEAN latestVersion; - LoadStringW(GetModuleHandle(NULL), STRING_HELP, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_HELP, szMsg, ARRAYSIZE(szMsg)); #ifndef FMIFS_IMPORT_DLL if (!LoadFMIFSEntryPoints()) { - PrintString(szMsg, ProgramName, L""); + ConPrintf(StdOut, szMsg, ProgramName, L""); return; } #endif @@ -379,7 +342,7 @@ wcscat(szFormats, szFormatW); } - PrintString(szMsg, ProgramName, szFormats); + ConPrintf(StdOut, szMsg, ProgramName, szFormats); } @@ -408,10 +371,14 @@ ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes; WCHAR szMsg[RC_STRING_MAX_SIZE]; - wprintf(L"\n" - L"Formatx v1.0 by Mark Russinovich\n" - L"Systems Internals -
http://www.sysinternals.com\n
" - L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n"); + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + + ConPrintf(StdOut, + L"\n" + L"Formatx v1.0 by Mark Russinovich\n" + L"Systems Internals -
http://www.sysinternals.com\n
" + L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n"); #ifndef FMIFS_IMPORT_DLL // @@ -419,7 +386,7 @@ // if (!LoadFMIFSEntryPoints()) { - PrintResourceString(STRING_FMIFS_FAIL); + ConResPrintf(StdErr, STRING_FMIFS_FAIL); return -1; } #endif @@ -430,7 +397,7 @@ badArg = ParseCommandLine(argc, argv); if (badArg) { - PrintResourceString(STRING_UNKNOW_ARG, argv[badArg]); + ConResPrintf(StdOut, STRING_UNKNOW_ARG, argv[badArg]); Usage(argv[0]); return -1; } @@ -440,7 +407,7 @@ // if (!Drive) { - PrintResourceString(STRING_DRIVE_PARM); + ConResPrintf(StdOut, STRING_DRIVE_PARM); Usage(argv[0]); return -1; } @@ -458,22 +425,22 @@ switch (driveType) { case DRIVE_UNKNOWN : - LoadStringW(GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; case DRIVE_REMOTE: case DRIVE_CDROM: - PrintResourceString(STRING_NO_SUPPORT); + ConResPrintf(StdOut, STRING_NO_SUPPORT); return -1; case DRIVE_NO_ROOT_DIR: - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; case DRIVE_REMOVABLE: - PrintResourceString(STRING_INSERT_DISK, RootDirectory[0]); + ConResPrintf(StdOut, STRING_INSERT_DISK, RootDirectory[0]); fgetws(input, ARRAYSIZE(input), stdin); media = FMIFS_FLOPPY; break; @@ -495,7 +462,7 @@ if (towlower(path[0]) == towlower(Drive[0])) { // todo: report "Cannot format system drive" - PrintResourceString(STRING_NO_SUPPORT); + ConResPrintf(StdOut, STRING_NO_SUPPORT); return -1; } } @@ -508,7 +475,7 @@ &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } @@ -518,11 +485,11 @@ &totalNumberOfBytes, &totalNumberOfFreeBytes)) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } - PrintResourceString(STRING_FILESYSTEM, fileSystem); + ConResPrintf(StdOut, STRING_FILESYSTEM, fileSystem); // // Make sure they want to do this @@ -533,27 +500,27 @@ { while (TRUE) { - PrintResourceString(STRING_LABEL_NAME_EDIT, RootDirectory[0]); + ConResPrintf(StdOut, STRING_LABEL_NAME_EDIT, RootDirectory[0]); fgetws(input, ARRAYSIZE(input), stdin); input[wcslen(input) - 1] = 0; if (!wcsicmp(input, volumeName)) break; - PrintResourceString(STRING_ERROR_LABEL); + ConResPrintf(StdOut, STRING_ERROR_LABEL); } } - PrintResourceString(STRING_YN_FORMAT, RootDirectory[0]); - - LoadStringW(GetModuleHandle(NULL), STRING_YES_NO_FAQ, szMsg, ARRAYSIZE(szMsg)); + ConResPrintf(StdOut, STRING_YN_FORMAT, RootDirectory[0]); + + K32LoadStringW(GetModuleHandle(NULL), STRING_YES_NO_FAQ, szMsg, ARRAYSIZE(szMsg)); while (TRUE) { fgetws(input, ARRAYSIZE(input), stdin); if (_wcsnicmp(&input[0], &szMsg[0], 1) == 0) break; if (_wcsnicmp(&input[0], &szMsg[1], 1) == 0) { - wprintf(L"\n"); + ConPrintf(StdOut, L"\n"); return 0; } } @@ -564,30 +531,30 @@ // if (!QuickFormat) { - LoadStringW(GetModuleHandle(NULL), STRING_VERIFYING, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_VERIFYING, szMsg, ARRAYSIZE(szMsg)); if (totalNumberOfBytes.QuadPart > 1024*1024*10) { - PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); + ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); } else { - PrintString(L"%s %.1fM\n", szMsg, + ConPrintf(StdOut, L"%s %.1fM\n", szMsg, ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } } else { - LoadStringW(GetModuleHandle(NULL), STRING_FAST_FMT, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_FAST_FMT, szMsg, ARRAYSIZE(szMsg)); if (totalNumberOfBytes.QuadPart > 1024*1024*10) { - PrintString(L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); + ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024))); } else { - PrintString(L"%s %.2fM\n", szMsg, + ConPrintf(StdOut, L"%s %.2fM\n", szMsg, ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0)); } - PrintResourceString(STRING_CREATE_FSYS); + ConResPrintf(StdOut, STRING_CREATE_FSYS); } // @@ -596,7 +563,7 @@ FormatEx(RootDirectory, media, FileSystem, Label, QuickFormat, ClusterSize, FormatExCallback); if (Error) return -1; - PrintResourceString(STRING_FMT_COMPLETE); + ConResPrintf(StdOut, STRING_FMT_COMPLETE); // // Enable compression if desired @@ -604,7 +571,7 @@ if (CompressDrive) { if (!EnableVolumeCompression(RootDirectory, TRUE)) - PrintResourceString(STRING_VOL_COMPRESS); + ConResPrintf(StdOut, STRING_VOL_COMPRESS); } // @@ -612,13 +579,13 @@ // if (!GotALabel) { - PrintResourceString(STRING_ENTER_LABEL); + ConResPrintf(StdOut, STRING_ENTER_LABEL); fgetws(input, ARRAYSIZE(LabelString), stdin); input[wcslen(input) - 1] = 0; if (!SetVolumeLabelW(RootDirectory, input)) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_LABEL, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_LABEL, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } @@ -629,7 +596,7 @@ &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } @@ -642,13 +609,13 @@ &totalNumberOfBytes, &totalNumberOfFreeBytes)) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME_SIZE, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } - PrintResourceString(STRING_FREE_SPACE, totalNumberOfBytes.QuadPart, - totalNumberOfFreeBytes.QuadPart); + ConResPrintf(StdOut, STRING_FREE_SPACE, totalNumberOfBytes.QuadPart, + totalNumberOfFreeBytes.QuadPart); // // Get the drive's serial number @@ -658,13 +625,13 @@ &serialNumber, &maxComponent, &flags, fileSystem, ARRAYSIZE(fileSystem))) { - LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); + K32LoadStringW(GetModuleHandle(NULL), STRING_NO_VOLUME, szMsg, ARRAYSIZE(szMsg)); PrintWin32Error(szMsg, GetLastError()); return -1; } - PrintResourceString(STRING_SERIAL_NUMBER, - (unsigned int)(serialNumber >> 16), - (unsigned int)(serialNumber & 0xFFFF)); + ConResPrintf(StdOut, STRING_SERIAL_NUMBER, + (unsigned int)(serialNumber >> 16), + (unsigned int)(serialNumber & 0xFFFF)); return 0; } Modified: trunk/reactos/base/system/subst/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/CMakeLis…
============================================================================== --- trunk/reactos/base/system/subst/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/CMakeLists.txt [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -1,5 +1,8 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) add_executable(subst subst.c subst.rc) set_module_type(subst win32cui UNICODE) -add_importlibs(subst msvcrt kernel32 user32 ntdll) +target_link_libraries(subst conutils ${PSEH_LIB}) +add_importlibs(subst msvcrt kernel32 ntdll) add_cd_file(TARGET subst DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/system/subst/subst.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.c?…
============================================================================== --- trunk/reactos/base/system/subst/subst.c [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/subst.c [iso-8859-1] Fri Oct 7 20:37:36 2016 @@ -15,7 +15,8 @@ #define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> -#include <winuser.h> + +#include <conutils.h> #include "resource.h" @@ -23,48 +24,28 @@ VOID PrintError(IN DWORD ErrCode) { - WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; - PWSTR buffer, msg = NULL; - - buffer = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2048 * sizeof(WCHAR)); - if (!buffer) + DWORD dwLength = 0; + PWSTR pMsgBuf = NULL; + +#if 0 + if (ErrCode == ERROR_SUCCESS) return; - - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - ErrCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (PWSTR)&msg, - 0, - NULL); - if (msg) - { - LoadStringW(GetModuleHandleW(NULL), - IDS_FAILED_WITH_ERRORCODE, - szFmtString, - ARRAYSIZE(szFmtString)); - _snwprintf(buffer, - 2048, - szFmtString, - ErrCode, - msg); - wprintf(L"%s", buffer); - - LocalFree(msg); - } - - HeapFree(GetProcessHeap(), 0, buffer); -} - -VOID DisplaySubstUsage(VOID) -{ - WCHAR szHelp[RC_STRING_MAX_SIZE] = {0}; - - LoadStringW(GetModuleHandleW(NULL), - IDS_USAGE, - szHelp, - ARRAYSIZE(szHelp)); - wprintf(L"%s", szHelp); +#endif + + /* Retrieve the message string without appending extra newlines */ + dwLength = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, + ErrCode, + LANG_USER_DEFAULT, + (PWSTR)&pMsgBuf, + 0, NULL); + if (pMsgBuf /* && dwLength */) + { + ConResPrintf(StdErr, IDS_FAILED_WITH_ERRORCODE, + ErrCode, pMsgBuf); + LocalFree(pMsgBuf); + } } ULONG QuerySubstedDrive(IN WCHAR DriveLetter, @@ -172,7 +153,7 @@ DriveLetter = L'A' + i; if (QuerySubstedDrive(DriveLetter, &lpTargetPath, &dwSize) == ERROR_IS_SUBSTED) { - wprintf(L"%c:\\: => %s\n", DriveLetter, lpTargetPath + 4); + ConPrintf(StdOut, L"%c:\\: => %s\n", DriveLetter, lpTargetPath + 4); } i++; @@ -184,7 +165,6 @@ INT DeleteSubst(IN PWSTR Drive) { DWORD dwResult; - WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; if ((wcslen(Drive) != 2) || (Drive[1] != L':')) { @@ -212,21 +192,13 @@ // case ERROR_INVALID_DRIVE: case ERROR_INVALID_PARAMETER: { - LoadStringW(GetModuleHandleW(NULL), - IDS_INVALID_PARAMETER2, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, Drive); + ConResPrintf(StdErr, IDS_INVALID_PARAMETER2, Drive); return 1; } case ERROR_ACCESS_DENIED: { - LoadStringW(GetModuleHandleW(NULL), - IDS_ACCESS_DENIED, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, Drive); + ConResPrintf(StdErr, IDS_ACCESS_DENIED, Drive); return 1; } @@ -243,7 +215,6 @@ INT AddSubst(IN PWSTR Drive, IN PWSTR Path) { DWORD dwResult, dwPathAttr; - WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; if ((wcslen(Drive) != 2) || (Drive[1] != L':')) { @@ -289,42 +260,26 @@ case ERROR_INVALID_DRIVE: case ERROR_INVALID_PARAMETER: { - LoadStringW(GetModuleHandleW(NULL), - IDS_INVALID_PARAMETER2, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, Drive); + ConResPrintf(StdErr, IDS_INVALID_PARAMETER2, Drive); return 1; } case ERROR_IS_SUBSTED: { - LoadStringW(GetModuleHandleW(NULL), - IDS_DRIVE_ALREADY_SUBSTED, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString); + ConResPrintf(StdErr, IDS_DRIVE_ALREADY_SUBSTED); return 1; } case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: { - LoadStringW(GetModuleHandleW(NULL), - IDS_PATH_NOT_FOUND, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, Path); + ConResPrintf(StdErr, IDS_PATH_NOT_FOUND, Path); return 1; } case ERROR_ACCESS_DENIED: { - LoadStringW(GetModuleHandleW(NULL), - IDS_ACCESS_DENIED, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, Path); + ConResPrintf(StdErr, IDS_ACCESS_DENIED, Path); return 1; } @@ -341,13 +296,15 @@ int wmain(int argc, WCHAR* argv[]) { INT i; - WCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; + + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); for (i = 0; i < argc; i++) { if (!_wcsicmp(argv[i], L"/?")) { - DisplaySubstUsage(); + ConResPrintf(StdOut, IDS_USAGE); return 0; } } @@ -356,11 +313,7 @@ { if (argc >= 2) { - LoadStringW(GetModuleHandleW(NULL), - IDS_INVALID_PARAMETER, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, argv[1]); + ConResPrintf(StdErr, IDS_INVALID_PARAMETER, argv[1]); return 1; } DumpSubstedDrives(); @@ -369,11 +322,7 @@ if (argc > 3) { - LoadStringW(GetModuleHandleW(NULL), - IDS_INCORRECT_PARAMETER_COUNT, - szFmtString, - ARRAYSIZE(szFmtString)); - wprintf(szFmtString, argv[3]); + ConResPrintf(StdErr, IDS_INCORRECT_PARAMETER_COUNT, argv[3]); return 1; }
8 years, 2 months
1
0
0
0
[mjansen] 72927: [NETID] Cleanup the spec file. Patch by Jared Smudde. CORE-11309 #resolve
by mjansen@svn.reactos.org
Author: mjansen Date: Fri Oct 7 18:40:45 2016 New Revision: 72927 URL:
http://svn.reactos.org/svn/reactos?rev=72927&view=rev
Log: [NETID] Cleanup the spec file. Patch by Jared Smudde. CORE-11309 #resolve Modified: trunk/reactos/dll/win32/netid/netid.spec Modified: trunk/reactos/dll/win32/netid/netid.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/netid.spec…
============================================================================== --- trunk/reactos/dll/win32/netid/netid.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netid/netid.spec [iso-8859-1] Fri Oct 7 18:40:45 2016 @@ -1,4 +1,2 @@ -# netid.dll exports - - 1 stdcall CreateNetIDPropertyPage() -# 2 stdcall ShowDcNotFoundErrorDialog(???) +1 stdcall CreateNetIDPropertyPage() +#2 stdcall -stub ShowDcNotFoundErrorDialog(ptr ptr ptr)
8 years, 2 months
1
0
0
0
[cwittich] 72926: [MSAFD] Implement WSPDuplicateSocket. By Peter Hater. CORE-12092
by cwittich@svn.reactos.org
Author: cwittich Date: Fri Oct 7 17:51:03 2016 New Revision: 72926 URL:
http://svn.reactos.org/svn/reactos?rev=72926&view=rev
Log: [MSAFD] Implement WSPDuplicateSocket. By Peter Hater. CORE-12092 Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c trunk/reactos/dll/win32/msafd/misc/event.c trunk/reactos/dll/win32/msafd/misc/sndrcv.c trunk/reactos/dll/win32/msafd/misc/stubs.c trunk/reactos/dll/win32/msafd/msafd.h Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Fri Oct 7 17:51:03 2016 @@ -70,9 +70,30 @@ UNICODE_STRING DevName; LARGE_INTEGER GroupData; INT Status; + PSOCK_SHARED_INFO SharedData = NULL; TRACE("Creating Socket, getting TDI Name - AddressFamily (%d) SocketType (%d) Protocol (%d).\n", AddressFamily, SocketType, Protocol); + + if (lpProtocolInfo && lpProtocolInfo->dwServiceFlags3 != 0 && lpProtocolInfo->dwServiceFlags4 != 0) + { + /* Duplpicating socket from different process */ + if ((HANDLE)lpProtocolInfo->dwServiceFlags3 == INVALID_HANDLE_VALUE) + return WSAEINVAL; + if ((HANDLE)lpProtocolInfo->dwServiceFlags4 == INVALID_HANDLE_VALUE) + return WSAEINVAL; + SharedData = MapViewOfFile((HANDLE)lpProtocolInfo->dwServiceFlags3, + FILE_MAP_ALL_ACCESS, + 0, + 0, + sizeof(SOCK_SHARED_INFO)); + if (!SharedData) + return WSAEINVAL; + InterlockedIncrement(&SharedData->RefCount); + AddressFamily = SharedData->AddressFamily; + SocketType = SharedData->SocketType; + Protocol = SharedData->Protocol; + } if (AddressFamily == AF_UNSPEC && SocketType == 0 && Protocol == 0) return WSAEINVAL; @@ -117,41 +138,62 @@ /* Set Socket Data */ Socket = HeapAlloc(GlobalHeap, 0, sizeof(*Socket)); if (!Socket) - return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL); - + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto error; + } RtlZeroMemory(Socket, sizeof(*Socket)); - Socket->RefCount = 2; - Socket->Handle = -1; - Socket->SharedData.Listening = FALSE; - Socket->SharedData.State = SocketOpen; - Socket->SharedData.AddressFamily = AddressFamily; - Socket->SharedData.SocketType = SocketType; - Socket->SharedData.Protocol = Protocol; + if (SharedData) + { + Socket->SharedData = SharedData; + Socket->SharedDataHandle = (HANDLE)lpProtocolInfo->dwServiceFlags3; + Sock = (HANDLE)lpProtocolInfo->dwServiceFlags4; + Socket->Handle = (SOCKET)lpProtocolInfo->dwServiceFlags4; + } + else + { + Socket->SharedDataHandle = INVALID_HANDLE_VALUE; + Socket->SharedData = HeapAlloc(GlobalHeap, 0, sizeof(*Socket->SharedData)); + if (!Socket->SharedData) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto error; + } + RtlZeroMemory(Socket->SharedData, sizeof(*Socket->SharedData)); + Socket->SharedData->State = SocketOpen; + Socket->SharedData->RefCount = 1L; + Socket->SharedData->Listening = FALSE; + Socket->SharedData->AddressFamily = AddressFamily; + Socket->SharedData->SocketType = SocketType; + Socket->SharedData->Protocol = Protocol; + Socket->SharedData->SizeOfLocalAddress = HelperData->MaxWSAddressLength; + Socket->SharedData->SizeOfRemoteAddress = HelperData->MaxWSAddressLength; + Socket->SharedData->UseDelayedAcceptance = HelperData->UseDelayedAcceptance; + Socket->SharedData->CreateFlags = dwFlags; + Socket->SharedData->ServiceFlags1 = lpProtocolInfo->dwServiceFlags1; + Socket->SharedData->ProviderFlags = lpProtocolInfo->dwProviderFlags; + Socket->SharedData->UseSAN = FALSE; + Socket->SharedData->NonBlocking = FALSE; /* Sockets start blocking */ + + /* Ask alex about this */ + if( Socket->SharedData->SocketType == SOCK_DGRAM || + Socket->SharedData->SocketType == SOCK_RAW ) + { + TRACE("Connectionless socket\n"); + Socket->SharedData->ServiceFlags1 |= XP1_CONNECTIONLESS; + } + Socket->Handle = -1; + } + Socket->HelperContext = HelperDLLContext; Socket->HelperData = HelperData; Socket->HelperEvents = HelperEvents; - Socket->LocalAddress = &Socket->WSLocalAddress; - Socket->SharedData.SizeOfLocalAddress = HelperData->MaxWSAddressLength; - Socket->RemoteAddress = &Socket->WSRemoteAddress; - Socket->SharedData.SizeOfRemoteAddress = HelperData->MaxWSAddressLength; - Socket->SharedData.UseDelayedAcceptance = HelperData->UseDelayedAcceptance; - Socket->SharedData.CreateFlags = dwFlags; - Socket->SharedData.ServiceFlags1 = lpProtocolInfo->dwServiceFlags1; - Socket->SharedData.ProviderFlags = lpProtocolInfo->dwProviderFlags; - Socket->SharedData.GroupID = g; - Socket->SharedData.GroupType = 0; - Socket->SharedData.UseSAN = FALSE; - Socket->SharedData.NonBlocking = FALSE; /* Sockets start blocking */ + Socket->LocalAddress = &Socket->SharedData->WSLocalAddress; + Socket->RemoteAddress = &Socket->SharedData->WSRemoteAddress; Socket->SanData = NULL; RtlCopyMemory(&Socket->ProtocolInfo, lpProtocolInfo, sizeof(Socket->ProtocolInfo)); - - /* Ask alex about this */ - if( Socket->SharedData.SocketType == SOCK_DGRAM || - Socket->SharedData.SocketType == SOCK_RAW ) - { - TRACE("Connectionless socket\n"); - Socket->SharedData.ServiceFlags1 |= XP1_CONNECTIONLESS; - } + if (SharedData) + goto ok; /* Packet Size */ SizeOfPacket = TransportName.Length + sizeof(AFD_CREATE_PACKET) + sizeof(WCHAR); @@ -162,7 +204,10 @@ /* Set up EA Buffer */ EABuffer = HeapAlloc(GlobalHeap, 0, SizeOfEA); if (!EABuffer) - return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL); + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto error; + } RtlZeroMemory(EABuffer, SizeOfEA); EABuffer->NextEntryOffset = 0; @@ -182,7 +227,7 @@ AfdPacket->GroupID = g; /* Set up Endpoint Flags */ - if ((Socket->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS) != 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS) != 0) { if ((SocketType != SOCK_DGRAM) && (SocketType != SOCK_RAW)) { @@ -192,11 +237,11 @@ AfdPacket->EndpointFlags |= AFD_ENDPOINT_CONNECTIONLESS; } - if ((Socket->SharedData.ServiceFlags1 & XP1_MESSAGE_ORIENTED) != 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_MESSAGE_ORIENTED) != 0) { if (SocketType == SOCK_STREAM) { - if ((Socket->SharedData.ServiceFlags1 & XP1_PSEUDO_STREAM) == 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_PSEUDO_STREAM) == 0) { /* The Provider doesn't actually support Message Oriented Streams */ goto error; @@ -212,7 +257,7 @@ WSA_FLAG_MULTIPOINT_D_ROOT | WSA_FLAG_MULTIPOINT_D_LEAF)) { - if ((Socket->SharedData.ServiceFlags1 & XP1_SUPPORT_MULTIPOINT) == 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_SUPPORT_MULTIPOINT) == 0) { /* The Provider doesn't actually support Multipoint */ goto error; @@ -221,7 +266,7 @@ if (dwFlags & WSA_FLAG_MULTIPOINT_C_ROOT) { - if (((Socket->SharedData.ServiceFlags1 & XP1_MULTIPOINT_CONTROL_PLANE) == 0) + if (((Socket->SharedData->ServiceFlags1 & XP1_MULTIPOINT_CONTROL_PLANE) == 0) || ((dwFlags & WSA_FLAG_MULTIPOINT_C_LEAF) != 0)) { /* The Provider doesn't support Control Planes, or you already gave a leaf */ @@ -232,7 +277,7 @@ if (dwFlags & WSA_FLAG_MULTIPOINT_D_ROOT) { - if (((Socket->SharedData.ServiceFlags1 & XP1_MULTIPOINT_DATA_PLANE) == 0) + if (((Socket->SharedData->ServiceFlags1 & XP1_MULTIPOINT_DATA_PLANE) == 0) || ((dwFlags & WSA_FLAG_MULTIPOINT_D_LEAF) != 0)) { /* The Provider doesn't support Data Planes, or you already gave a leaf */ @@ -270,10 +315,7 @@ if (!NT_SUCCESS(Status)) { ERR("Failed to open socket. Status 0x%08x\n", Status); - - HeapFree(GlobalHeap, 0, Socket); - - return MsafdReturnWithErrno(Status, lpErrno, 0, NULL); + goto error; } /* Save Handle */ @@ -283,22 +325,23 @@ if (g != 0) { GetSocketInformation(Socket, AFD_INFO_GROUP_ID_TYPE, NULL, NULL, &GroupData); - Socket->SharedData.GroupID = GroupData.u.LowPart; - Socket->SharedData.GroupType = GroupData.u.HighPart; + Socket->SharedData->GroupID = GroupData.u.LowPart; + Socket->SharedData->GroupType = GroupData.u.HighPart; } /* Get Window Sizes and Save them */ GetSocketInformation (Socket, AFD_INFO_SEND_WINDOW_SIZE, NULL, - &Socket->SharedData.SizeOfSendBuffer, + &Socket->SharedData->SizeOfSendBuffer, NULL); GetSocketInformation (Socket, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL, - &Socket->SharedData.SizeOfRecvBuffer, + &Socket->SharedData->SizeOfRecvBuffer, NULL); +ok: /* Save in Process Sockets List */ EnterCriticalSection(&SocketListLock); @@ -320,6 +363,17 @@ error: ERR("Ending %x\n", Status); + if( SharedData ) + { + UnmapViewOfFile(SharedData); + NtClose((HANDLE)lpProtocolInfo->dwServiceFlags3); + } + else + { + if( Socket && Socket->SharedData ) + HeapFree(GlobalHeap, 0, Socket->SharedData); + } + if( Socket ) HeapFree(GlobalHeap, 0, Socket); @@ -330,6 +384,96 @@ *lpErrno = Status; return INVALID_SOCKET; +} + + +INT +WSPAPI +WSPDuplicateSocket( + IN SOCKET Handle, + IN DWORD dwProcessId, + OUT LPWSAPROTOCOL_INFOW lpProtocolInfo, + OUT LPINT lpErrno) +{ + HANDLE hProcess, hDuplicatedSharedData, hDuplicatedHandle; + PSOCKET_INFORMATION Socket; + PSOCK_SHARED_INFO pSharedData, pOldSharedData; + BOOL bDuplicated; + + if (Handle == INVALID_SOCKET) + return MsafdReturnWithErrno(STATUS_INVALID_PARAMETER, lpErrno, 0, NULL); + Socket = GetSocketStructure(Handle); + if( !Socket ) + { + if( lpErrno ) + *lpErrno = WSAENOTSOCK; + return SOCKET_ERROR; + } + if ( !(hProcess = OpenProcess(PROCESS_DUP_HANDLE, FALSE, dwProcessId)) ) + return MsafdReturnWithErrno(STATUS_INVALID_PARAMETER, lpErrno, 0, NULL); + + /* It is a not yet duplicated socket, so map the memory, copy the SharedData and free heap */ + if( Socket->SharedDataHandle == INVALID_HANDLE_VALUE ) + { + Socket->SharedDataHandle = CreateFileMapping(INVALID_HANDLE_VALUE, + NULL, + PAGE_READWRITE | SEC_COMMIT, + 0, + (sizeof(SOCK_SHARED_INFO) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1), + NULL); + if( Socket->SharedDataHandle == INVALID_HANDLE_VALUE ) + return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL); + pSharedData = MapViewOfFile(Socket->SharedDataHandle, + FILE_MAP_ALL_ACCESS, + 0, + 0, + sizeof(SOCK_SHARED_INFO)); + + RtlCopyMemory(pSharedData, Socket->SharedData, sizeof(SOCK_SHARED_INFO)); + pOldSharedData = Socket->SharedData; + Socket->SharedData = pSharedData; + HeapFree(GlobalHeap, 0, pOldSharedData); + } + /* Duplicate the handles for the new process */ + bDuplicated = DuplicateHandle(GetCurrentProcess(), + Socket->SharedDataHandle, + hProcess, + (LPHANDLE)&hDuplicatedSharedData, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); + if (!bDuplicated) + { + NtClose(hProcess); + return MsafdReturnWithErrno(STATUS_ACCESS_DENIED, lpErrno, 0, NULL); + } + bDuplicated = DuplicateHandle(GetCurrentProcess(), + (HANDLE)Socket->Handle, + hProcess, + (LPHANDLE)&hDuplicatedHandle, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); + NtClose(hProcess); + if( !bDuplicated ) + return MsafdReturnWithErrno(STATUS_ACCESS_DENIED, lpErrno, 0, NULL); + + + if (!lpProtocolInfo) + return MsafdReturnWithErrno(STATUS_ACCESS_VIOLATION, lpErrno, 0, NULL); + + RtlCopyMemory(lpProtocolInfo, &Socket->ProtocolInfo, sizeof(*lpProtocolInfo)); + + lpProtocolInfo->iAddressFamily = Socket->SharedData->AddressFamily; + lpProtocolInfo->iProtocol = Socket->SharedData->Protocol; + lpProtocolInfo->iSocketType = Socket->SharedData->SocketType; + lpProtocolInfo->dwServiceFlags3 = (DWORD)hDuplicatedSharedData; + lpProtocolInfo->dwServiceFlags4 = (DWORD)hDuplicatedHandle; + + if( lpErrno ) + *lpErrno = NO_ERROR; + + return NO_ERROR; } INT @@ -423,6 +567,7 @@ AFD_DISCONNECT_INFO DisconnectInfo; SOCKET_STATE OldState; LONG LingerWait = -1; + DWORD References; /* Create the Wait Event */ Status = NtCreateEvent(&SockEvent, @@ -463,28 +608,32 @@ } /* If a Close is already in Process, give up */ - if (Socket->SharedData.State == SocketClosed) + if (Socket->SharedData->State == SocketClosed) { WARN("Socket is closing.\n"); NtClose(SockEvent); *lpErrno = WSAENOTSOCK; return SOCKET_ERROR; } - /* Set the state to close */ - OldState = Socket->SharedData.State; - Socket->SharedData.State = SocketClosed; + OldState = Socket->SharedData->State; + Socket->SharedData->State = SocketClosed; + + /* Decrement reference count on SharedData */ + References = InterlockedDecrement(&Socket->SharedData->RefCount); + if (References) + goto ok; /* If SO_LINGER is ON and the Socket is connected, we need to disconnect */ /* FIXME: Should we do this on Datagram Sockets too? */ - if ((OldState == SocketConnected) && (Socket->SharedData.LingerData.l_onoff)) + if ((OldState == SocketConnected) && (Socket->SharedData->LingerData.l_onoff)) { ULONG SendsInProgress; ULONG SleepWait; /* We need to respect the timeout */ SleepWait = 100; - LingerWait = Socket->SharedData.LingerData.l_linger * 1000; + LingerWait = Socket->SharedData->LingerData.l_linger * 1000; /* Loop until no more sends are pending, within the timeout */ while (LingerWait) @@ -514,11 +663,11 @@ * go on since asyncronous operation is expected * and we cannot offer it */ - if (Socket->SharedData.NonBlocking) + if (Socket->SharedData->NonBlocking) { WARN("Would block!\n"); NtClose(SockEvent); - Socket->SharedData.State = OldState; + Socket->SharedData->State = OldState; *lpErrno = WSAEWOULDBLOCK; return SOCKET_ERROR; } @@ -542,8 +691,8 @@ DisconnectInfo.Timeout = RtlConvertLongToLargeInteger(0); DisconnectInfo.DisconnectType = LingerWait < 0 ? AFD_DISCONNECT_SEND : AFD_DISCONNECT_ABORT; - if (((DisconnectInfo.DisconnectType & AFD_DISCONNECT_SEND) && (!Socket->SharedData.SendShutdown)) || - ((DisconnectInfo.DisconnectType & AFD_DISCONNECT_ABORT) && (!Socket->SharedData.ReceiveShutdown))) + if (((DisconnectInfo.DisconnectType & AFD_DISCONNECT_SEND) && (!Socket->SharedData->SendShutdown)) || + ((DisconnectInfo.DisconnectType & AFD_DISCONNECT_ABORT) && (!Socket->SharedData->ReceiveShutdown))) { /* Send IOCTL */ Status = NtDeviceIoControlFile((HANDLE)Handle, @@ -569,12 +718,12 @@ /* Cleanup Time! */ Socket->HelperContext = NULL; - Socket->SharedData.AsyncDisabledEvents = -1; + Socket->SharedData->AsyncDisabledEvents = -1; NtClose(Socket->TdiAddressHandle); Socket->TdiAddressHandle = NULL; NtClose(Socket->TdiConnectionHandle); Socket->TdiConnectionHandle = NULL; - +ok: EnterCriticalSection(&SocketListLock); if (SocketListHead == Socket) { @@ -600,6 +749,17 @@ NtClose((HANDLE)Handle); NtClose(SockEvent); + if( Socket->SharedDataHandle != INVALID_HANDLE_VALUE ) + { + /* It is a duplicated socket, so unmap the memory */ + UnmapViewOfFile(Socket->SharedData); + NtClose(Socket->SharedDataHandle); + Socket->SharedData = NULL; + } + if( !References && Socket->SharedData ) + { + HeapFree(GlobalHeap, 0, Socket->SharedData); + } HeapFree(GlobalHeap, 0, Socket); return MsafdReturnWithErrno(Status, lpErrno, 0, NULL); } @@ -671,7 +831,7 @@ &SocketInfo); /* Set the Share Type */ - if (Socket->SharedData.ExclusiveAddressUse) + if (Socket->SharedData->ExclusiveAddressUse) { BindData->ShareType = AFD_SHARE_EXCLUSIVE; } @@ -679,7 +839,7 @@ { BindData->ShareType = AFD_SHARE_WILDCARD; } - else if (Socket->SharedData.ReuseAddresses) + else if (Socket->SharedData->ReuseAddresses) { BindData->ShareType = AFD_SHARE_REUSE; } @@ -696,9 +856,9 @@ &IOSB, IOCTL_AFD_BIND, BindData, - 0xA + Socket->SharedData.SizeOfLocalAddress, /* Can't figure out a way to calculate this in C*/ + 0xA + Socket->SharedData->SizeOfLocalAddress, /* Can't figure out a way to calculate this in C*/ BindData, - 0xA + Socket->SharedData.SizeOfLocalAddress); /* Can't figure out a way to calculate this C */ + 0xA + Socket->SharedData->SizeOfLocalAddress); /* Can't figure out a way to calculate this C */ /* Wait for return */ if (Status == STATUS_PENDING) @@ -714,7 +874,7 @@ return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL ); /* Set up Socket Data */ - Socket->SharedData.State = SocketBound; + Socket->SharedData->State = SocketBound; Socket->TdiAddressHandle = (HANDLE)IOSB.Information; if (Socket->HelperEvents & WSH_NOTIFY_BIND) @@ -755,7 +915,7 @@ return SOCKET_ERROR; } - if (Socket->SharedData.Listening) + if (Socket->SharedData->Listening) return 0; Status = NtCreateEvent(&SockEvent, @@ -769,7 +929,7 @@ /* Set Up Listen Structure */ ListenData.UseSAN = FALSE; - ListenData.UseDelayedAcceptance = Socket->SharedData.UseDelayedAcceptance; + ListenData.UseDelayedAcceptance = Socket->SharedData->UseDelayedAcceptance; ListenData.Backlog = Backlog; /* Send IOCTL */ @@ -797,7 +957,7 @@ return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL ); /* Set to Listening */ - Socket->SharedData.Listening = TRUE; + Socket->SharedData->Listening = TRUE; if (Socket->HelperEvents & WSH_NOTIFY_LISTEN) { @@ -1157,7 +1317,7 @@ if (lpfnCondition != NULL) { - if ((Socket->SharedData.ServiceFlags1 & XP1_CONNECT_DATA) != 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_CONNECT_DATA) != 0) { /* Find out how much data is pending */ PendingAcceptData.SequenceNumber = ListenReceiveData->SequenceNumber; @@ -1233,14 +1393,14 @@ } } - if ((Socket->SharedData.ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) { /* I don't support this yet */ } /* Build Callee ID */ CalleeID.buf = (PVOID)Socket->LocalAddress; - CalleeID.len = Socket->SharedData.SizeOfLocalAddress; + CalleeID.len = Socket->SharedData->SizeOfLocalAddress; RemoteAddress = HeapAlloc(GlobalHeap, 0, sizeof(*RemoteAddress)); if (!RemoteAddress) @@ -1263,7 +1423,7 @@ CallerData.len = PendingDataLength; /* Check if socket supports Conditional Accept */ - if (Socket->SharedData.UseDelayedAcceptance != 0) + if (Socket->SharedData->UseDelayedAcceptance != 0) { /* Allocate Buffer for Callee Data */ CalleeDataBuffer = HeapAlloc(GlobalHeap, 0, 4096); @@ -1298,7 +1458,7 @@ if (CallBack == CF_ACCEPT) { - if ((Socket->SharedData.ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) + if ((Socket->SharedData->ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) { /* I don't support this yet */ } @@ -1354,12 +1514,12 @@ } /* Create a new Socket */ - AcceptSocket = WSPSocket (Socket->SharedData.AddressFamily, - Socket->SharedData.SocketType, - Socket->SharedData.Protocol, + AcceptSocket = WSPSocket (Socket->SharedData->AddressFamily, + Socket->SharedData->SocketType, + Socket->SharedData->Protocol, &Socket->ProtocolInfo, GroupID, - Socket->SharedData.CreateFlags, + Socket->SharedData->CreateFlags, lpErrno); if (AcceptSocket == INVALID_SOCKET) return INVALID_SOCKET; @@ -1404,7 +1564,7 @@ return INVALID_SOCKET; } - AcceptSocketInfo->SharedData.State = SocketConnected; + AcceptSocketInfo->SharedData->State = SocketConnected; /* Return Address in SOCKADDR FORMAT */ if( SocketAddress ) @@ -1488,7 +1648,7 @@ } /* Bind us First */ - if (Socket->SharedData.State == SocketOpen) + if (Socket->SharedData->State == SocketOpen) { /* Get the Wildcard Address */ BindAddressLength = Socket->HelperData->MaxWSAddressLength; @@ -1558,9 +1718,9 @@ * at the end of this function right after the Async Thread disables it. * This should only happen at the *next* WSPConnect */ - if (Socket->SharedData.AsyncEvents & FD_CONNECT) - { - Socket->SharedData.AsyncDisabledEvents |= FD_CONNECT | FD_WRITE; + if (Socket->SharedData->AsyncEvents & FD_CONNECT) + { + Socket->SharedData->AsyncDisabledEvents |= FD_CONNECT | FD_WRITE; } /* Tell AFD that we want Connection Data back, have it allocate a buffer */ @@ -1595,7 +1755,7 @@ ConnectInfo->Unknown = 0; /* FIXME: Handle Async Connect */ - if (Socket->SharedData.NonBlocking) + if (Socket->SharedData->NonBlocking) { ERR("Async Connect UNIMPLEMENTED!\n"); } @@ -1621,7 +1781,7 @@ if (Status != STATUS_SUCCESS) goto notify; - Socket->SharedData.State = SocketConnected; + Socket->SharedData->State = SocketConnected; Socket->TdiConnectionHandle = (HANDLE)IOSB.Information; /* Get any pending connect data */ @@ -1727,16 +1887,16 @@ { case SD_RECEIVE: DisconnectInfo.DisconnectType = AFD_DISCONNECT_RECV; - Socket->SharedData.ReceiveShutdown = TRUE; + Socket->SharedData->ReceiveShutdown = TRUE; break; case SD_SEND: DisconnectInfo.DisconnectType= AFD_DISCONNECT_SEND; - Socket->SharedData.SendShutdown = TRUE; + Socket->SharedData->SendShutdown = TRUE; break; case SD_BOTH: DisconnectInfo.DisconnectType = AFD_DISCONNECT_RECV | AFD_DISCONNECT_SEND; - Socket->SharedData.ReceiveShutdown = TRUE; - Socket->SharedData.SendShutdown = TRUE; + Socket->SharedData->ReceiveShutdown = TRUE; + Socket->SharedData->SendShutdown = TRUE; break; } @@ -1811,7 +1971,7 @@ /* Allocate a buffer for the address */ TdiAddressSize = - sizeof(TRANSPORT_ADDRESS) + Socket->SharedData.SizeOfLocalAddress; + sizeof(TRANSPORT_ADDRESS) + Socket->SharedData->SizeOfLocalAddress; TdiAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize); if ( TdiAddress == NULL ) @@ -1846,13 +2006,13 @@ if (NT_SUCCESS(Status)) { - if (*NameLength >= Socket->SharedData.SizeOfLocalAddress) + if (*NameLength >= Socket->SharedData->SizeOfLocalAddress) { Name->sa_family = SocketAddress->Address[0].AddressType; RtlCopyMemory (Name->sa_data, SocketAddress->Address[0].Address, SocketAddress->Address[0].AddressLength); - *NameLength = Socket->SharedData.SizeOfLocalAddress; + *NameLength = Socket->SharedData->SizeOfLocalAddress; TRACE("NameLength %d Address: %x Port %x\n", *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr, ((struct sockaddr_in *)Name)->sin_port); @@ -1905,7 +2065,7 @@ return SOCKET_ERROR; } - if (Socket->SharedData.State != SocketConnected) + if (Socket->SharedData->State != SocketConnected) { NtClose(SockEvent); *lpErrno = WSAENOTCONN; @@ -1920,7 +2080,7 @@ } /* Allocate a buffer for the address */ - TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + Socket->SharedData.SizeOfRemoteAddress; + TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + Socket->SharedData->SizeOfRemoteAddress; SocketAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize); if ( SocketAddress == NULL ) @@ -1953,13 +2113,13 @@ if (NT_SUCCESS(Status)) { - if (*NameLength >= Socket->SharedData.SizeOfRemoteAddress) + if (*NameLength >= Socket->SharedData->SizeOfRemoteAddress) { Name->sa_family = SocketAddress->Address[0].AddressType; RtlCopyMemory (Name->sa_data, SocketAddress->Address[0].Address, SocketAddress->Address[0].AddressLength); - *NameLength = Socket->SharedData.SizeOfRemoteAddress; + *NameLength = Socket->SharedData->SizeOfRemoteAddress; TRACE("NameLength %d Address: %x Port %x\n", *NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr, ((struct sockaddr_in *)Name)->sin_port); @@ -2022,7 +2182,7 @@ return SOCKET_ERROR; } NonBlocking = *((PULONG)lpvInBuffer) ? TRUE : FALSE; - Socket->SharedData.NonBlocking = NonBlocking ? 1 : 0; + Socket->SharedData->NonBlocking = NonBlocking ? 1 : 0; *lpErrno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &NonBlocking, NULL, NULL); if (*lpErrno != NO_ERROR) return SOCKET_ERROR; @@ -2060,18 +2220,18 @@ return SOCKET_ERROR; case SIO_ADDRESS_LIST_QUERY: - if (cbOutBuffer < (sizeof(SOCKET_ADDRESS_LIST) + sizeof(Socket->WSLocalAddress)) || IS_INTRESOURCE(lpvOutBuffer)) + if (cbOutBuffer < (sizeof(SOCKET_ADDRESS_LIST) + sizeof(Socket->SharedData->WSLocalAddress)) || IS_INTRESOURCE(lpvOutBuffer)) { *lpErrno = WSAEINVAL; return SOCKET_ERROR; } *lpcbBytesReturned = sizeof(SOCKET_ADDRESS_LIST) + - sizeof(Socket->WSLocalAddress); + sizeof(Socket->SharedData->WSLocalAddress); ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->iAddressCount = 1; - ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].iSockaddrLength = sizeof(Socket->WSLocalAddress); - ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].lpSockaddr = &Socket->WSLocalAddress; + ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].iSockaddrLength = sizeof(Socket->SharedData->WSLocalAddress); + ((SOCKET_ADDRESS_LIST*)lpvOutBuffer)->Address[0].lpSockaddr = &Socket->SharedData->WSLocalAddress; *lpErrno = NO_ERROR; return NO_ERROR; @@ -2130,56 +2290,56 @@ switch (OptionName) { case SO_TYPE: - Buffer = &Socket->SharedData.SocketType; + Buffer = &Socket->SharedData->SocketType; BufferSize = sizeof(INT); break; case SO_RCVBUF: - Buffer = &Socket->SharedData.SizeOfRecvBuffer; + Buffer = &Socket->SharedData->SizeOfRecvBuffer; BufferSize = sizeof(INT); break; case SO_SNDBUF: - Buffer = &Socket->SharedData.SizeOfSendBuffer; + Buffer = &Socket->SharedData->SizeOfSendBuffer; BufferSize = sizeof(INT); break; case SO_ACCEPTCONN: - BoolBuffer = Socket->SharedData.Listening; + BoolBuffer = Socket->SharedData->Listening; Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_BROADCAST: - BoolBuffer = Socket->SharedData.Broadcast; + BoolBuffer = Socket->SharedData->Broadcast; Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_DEBUG: - BoolBuffer = Socket->SharedData.Debug; + BoolBuffer = Socket->SharedData->Debug; Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_DONTLINGER: - BoolBuffer = (Socket->SharedData.LingerData.l_onoff == 0); + BoolBuffer = (Socket->SharedData->LingerData.l_onoff == 0); Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_LINGER: - if (Socket->SharedData.SocketType == SOCK_DGRAM) + if (Socket->SharedData->SocketType == SOCK_DGRAM) { *lpErrno = WSAENOPROTOOPT; return SOCKET_ERROR; } - Buffer = &Socket->SharedData.LingerData; + Buffer = &Socket->SharedData->LingerData; BufferSize = sizeof(struct linger); break; case SO_OOBINLINE: - BoolBuffer = (Socket->SharedData.OobInline != 0); + BoolBuffer = (Socket->SharedData->OobInline != 0); Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; @@ -2190,19 +2350,19 @@ goto SendToHelper; case SO_CONDITIONAL_ACCEPT: - BoolBuffer = (Socket->SharedData.UseDelayedAcceptance != 0); + BoolBuffer = (Socket->SharedData->UseDelayedAcceptance != 0); Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_REUSEADDR: - BoolBuffer = (Socket->SharedData.ReuseAddresses != 0); + BoolBuffer = (Socket->SharedData->ReuseAddresses != 0); Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; case SO_EXCLUSIVEADDRUSE: - BoolBuffer = (Socket->SharedData.ExclusiveAddressUse != 0); + BoolBuffer = (Socket->SharedData->ExclusiveAddressUse != 0); Buffer = &BoolBuffer; BufferSize = sizeof(BOOL); break; @@ -2216,11 +2376,11 @@ BufferSize = sizeof(INT); break; case SO_SNDTIMEO: - Buffer = &Socket->SharedData.SendTimeout; + Buffer = &Socket->SharedData->SendTimeout; BufferSize = sizeof(DWORD); break; case SO_RCVTIMEO: - Buffer = &Socket->SharedData.RecvTimeout; + Buffer = &Socket->SharedData->RecvTimeout; BufferSize = sizeof(DWORD); break; case SO_PROTOCOL_INFOW: @@ -2297,7 +2457,7 @@ *lpErrno = WSAEFAULT; return SOCKET_ERROR; } - Socket->SharedData.Broadcast = (*optval != 0) ? 1 : 0; + Socket->SharedData->Broadcast = (*optval != 0) ? 1 : 0; return 0; case SO_DONTLINGER: @@ -2306,7 +2466,7 @@ *lpErrno = WSAEFAULT; return SOCKET_ERROR; } - Socket->SharedData.LingerData.l_onoff = (*optval != 0) ? 0 : 1; + Socket->SharedData->LingerData.l_onoff = (*optval != 0) ? 0 : 1; return 0; case SO_REUSEADDR: @@ -2315,7 +2475,7 @@ *lpErrno = WSAEFAULT; return SOCKET_ERROR; } - Socket->SharedData.ReuseAddresses = (*optval != 0) ? 1 : 0; + Socket->SharedData->ReuseAddresses = (*optval != 0) ? 1 : 0; return 0; case SO_EXCLUSIVEADDRUSE: @@ -2324,7 +2484,7 @@ *lpErrno = WSAEFAULT; return SOCKET_ERROR; } - Socket->SharedData.ExclusiveAddressUse = (*optval != 0) ? 1 : 0; + Socket->SharedData->ExclusiveAddressUse = (*optval != 0) ? 1 : 0; return 0; case SO_LINGER: @@ -2333,7 +2493,7 @@ *lpErrno = WSAEFAULT; return SOCKET_ERROR; } - RtlCopyMemory(&Socket->SharedData.LingerData, + RtlCopyMemory(&Socket->SharedData->LingerData, optval, sizeof(struct linger)); return 0; @@ -2356,7 +2516,7 @@ return SOCKET_ERROR; } - RtlCopyMemory(&Socket->SharedData.SendTimeout, + RtlCopyMemory(&Socket->SharedData->SendTimeout, optval, sizeof(DWORD)); return 0; @@ -2368,7 +2528,7 @@ return SOCKET_ERROR; } - RtlCopyMemory(&Socket->SharedData.RecvTimeout, + RtlCopyMemory(&Socket->SharedData->RecvTimeout, optval, sizeof(DWORD)); return 0; @@ -2813,14 +2973,14 @@ return -1; /* Create Context */ - ContextData.SharedData = Socket->SharedData; + ContextData.SharedData = *Socket->SharedData; ContextData.SizeOfHelperData = 0; RtlCopyMemory (&ContextData.LocalAddress, Socket->LocalAddress, - Socket->SharedData.SizeOfLocalAddress); + Socket->SharedData->SizeOfLocalAddress); RtlCopyMemory (&ContextData.RemoteAddress, Socket->RemoteAddress, - Socket->SharedData.SizeOfRemoteAddress); + Socket->SharedData->SizeOfRemoteAddress); /* Send IOCTL */ Status = NtDeviceIoControlFile((HANDLE)Socket->Handle, @@ -3012,7 +3172,7 @@ Socket = AsyncData->ParentSocket; /* Check if the Sequence Number Changed behind our back */ - if (AsyncData->SequenceNumber != Socket->SharedData.SequenceNumber ) + if (AsyncData->SequenceNumber != Socket->SharedData->SequenceNumber ) { return; } @@ -3029,90 +3189,90 @@ switch (AsyncData->AsyncSelectInfo.Handles[0].Events & x) { case AFD_EVENT_RECEIVE: - if (0 != (Socket->SharedData.AsyncEvents & FD_READ) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_READ)) + if (0 != (Socket->SharedData->AsyncEvents & FD_READ) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_READ)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_READ, 0)); /* Disable this event until the next read(); */ - Socket->SharedData.AsyncDisabledEvents |= FD_READ; + Socket->SharedData->AsyncDisabledEvents |= FD_READ; } break; case AFD_EVENT_OOB_RECEIVE: - if (0 != (Socket->SharedData.AsyncEvents & FD_OOB) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_OOB)) + if (0 != (Socket->SharedData->AsyncEvents & FD_OOB) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_OOB)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_OOB, 0)); /* Disable this event until the next read(); */ - Socket->SharedData.AsyncDisabledEvents |= FD_OOB; + Socket->SharedData->AsyncDisabledEvents |= FD_OOB; } break; case AFD_EVENT_SEND: - if (0 != (Socket->SharedData.AsyncEvents & FD_WRITE) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_WRITE)) + if (0 != (Socket->SharedData->AsyncEvents & FD_WRITE) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_WRITE)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_WRITE, 0)); /* Disable this event until the next write(); */ - Socket->SharedData.AsyncDisabledEvents |= FD_WRITE; + Socket->SharedData->AsyncDisabledEvents |= FD_WRITE; } break; /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */ case AFD_EVENT_CONNECT: case AFD_EVENT_CONNECT_FAIL: - if (0 != (Socket->SharedData.AsyncEvents & FD_CONNECT) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_CONNECT)) + if (0 != (Socket->SharedData->AsyncEvents & FD_CONNECT) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_CONNECT)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_CONNECT, 0)); /* Disable this event forever; */ - Socket->SharedData.AsyncDisabledEvents |= FD_CONNECT; + Socket->SharedData->AsyncDisabledEvents |= FD_CONNECT; } break; case AFD_EVENT_ACCEPT: - if (0 != (Socket->SharedData.AsyncEvents & FD_ACCEPT) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_ACCEPT)) + if (0 != (Socket->SharedData->AsyncEvents & FD_ACCEPT) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_ACCEPT)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_ACCEPT, 0)); /* Disable this event until the next accept(); */ - Socket->SharedData.AsyncDisabledEvents |= FD_ACCEPT; + Socket->SharedData->AsyncDisabledEvents |= FD_ACCEPT; } break; case AFD_EVENT_DISCONNECT: case AFD_EVENT_ABORT: case AFD_EVENT_CLOSE: - if (0 != (Socket->SharedData.AsyncEvents & FD_CLOSE) && - 0 == (Socket->SharedData.AsyncDisabledEvents & FD_CLOSE)) + if (0 != (Socket->SharedData->AsyncEvents & FD_CLOSE) && + 0 == (Socket->SharedData->AsyncDisabledEvents & FD_CLOSE)) { /* Make the Notifcation */ - (Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd, - Socket->SharedData.wMsg, + (Upcalls.lpWPUPostMessage)(Socket->SharedData->hWnd, + Socket->SharedData->wMsg, Socket->Handle, WSAMAKESELECTREPLY(FD_CLOSE, 0)); /* Disable this event forever; */ - Socket->SharedData.AsyncDisabledEvents |= FD_CLOSE; + Socket->SharedData->AsyncDisabledEvents |= FD_CLOSE; } break; /* FIXME: Support QOS */ @@ -3120,7 +3280,7 @@ } /* Check if there are any events left for us to check */ - if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0 ) + if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) == 0 ) { return; } @@ -3145,7 +3305,7 @@ AsyncData->AsyncSelectInfo.Handles[0].Events = 0; /* Remove unwanted events */ - lNetworkEvents = Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents); + lNetworkEvents = Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents); /* Set Events to wait for */ if (lNetworkEvents & FD_READ) @@ -3223,13 +3383,13 @@ Socket = AsyncData->ParentSocket; /* If someone closed it, stop the function */ - if (Socket->SharedData.State != SocketClosed) + if (Socket->SharedData->State != SocketClosed) { /* Check if the Sequence Number changed by now, in which case quit */ - if (AsyncData->SequenceNumber == Socket->SharedData.SequenceNumber) + if (AsyncData->SequenceNumber == Socket->SharedData->SequenceNumber) { /* Do the actuall select, if needed */ - if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents))) + if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents))) { SockProcessAsyncSelect(Socket, AsyncData); FreeContext = FALSE; @@ -3253,16 +3413,16 @@ PASYNC_DATA AsyncData; /* Make sure the event is actually disabled */ - if (!(Socket->SharedData.AsyncDisabledEvents & Event)) + if (!(Socket->SharedData->AsyncDisabledEvents & Event)) { return; } /* Re-enable it */ - Socket->SharedData.AsyncDisabledEvents &= ~Event; + Socket->SharedData->AsyncDisabledEvents &= ~Event; /* Return if no more events are being polled */ - if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0 ) + if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) == 0 ) { return; } @@ -3275,11 +3435,11 @@ SockCreateOrReferenceAsyncThread(); /* Increase the sequence number to stop anything else */ - Socket->SharedData.SequenceNumber++; + Socket->SharedData->SequenceNumber++; /* Set up the Async Data */ AsyncData->ParentSocket = Socket; - AsyncData->SequenceNumber = Socket->SharedData.SequenceNumber; + AsyncData->SequenceNumber = Socket->SharedData->SequenceNumber; /* Begin Async Select by using I/O Completion */ NtSetIoCompletion(SockAsyncCompletionPort, Modified: trunk/reactos/dll/win32/msafd/misc/event.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/event…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/event.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/event.c [iso-8859-1] Fri Oct 7 17:51:03 2016 @@ -47,14 +47,14 @@ /* Set Socket to Non-Blocking */ BlockMode = TRUE; SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL); - Socket->SharedData.NonBlocking = TRUE; + Socket->SharedData->NonBlocking = TRUE; /* Deactivate Async Select if there is one */ if (Socket->EventObject) { - Socket->SharedData.hWnd = NULL; - Socket->SharedData.wMsg = 0; - Socket->SharedData.AsyncEvents = 0; - Socket->SharedData.SequenceNumber++; // This will kill Async Select after the next completion + Socket->SharedData->hWnd = NULL; + Socket->SharedData->wMsg = 0; + Socket->SharedData->AsyncEvents = 0; + Socket->SharedData->SequenceNumber++; // This will kill Async Select after the next completion } /* Set Structure Info */ Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/sndrc…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] Fri Oct 7 17:51:03 2016 @@ -46,10 +46,10 @@ /* Change the Socket to Non Blocking */ BlockMode = TRUE; SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL); - Socket->SharedData.NonBlocking = TRUE; + Socket->SharedData->NonBlocking = TRUE; /* Deactive WSPEventSelect */ - if (Socket->SharedData.AsyncEvents) + if (Socket->SharedData->AsyncEvents) { if (WSPEventSelect(Handle, NULL, 0, lpErrno) == SOCKET_ERROR) { @@ -65,14 +65,14 @@ SockGetAsyncSelectHelperAfdHandle(); /* Store Socket Data */ - Socket->SharedData.hWnd = hWnd; - Socket->SharedData.wMsg = wMsg; - Socket->SharedData.AsyncEvents = lEvent; - Socket->SharedData.AsyncDisabledEvents = 0; - Socket->SharedData.SequenceNumber++; + Socket->SharedData->hWnd = hWnd; + Socket->SharedData->wMsg = wMsg; + Socket->SharedData->AsyncEvents = lEvent; + Socket->SharedData->AsyncDisabledEvents = 0; + Socket->SharedData->SequenceNumber++; /* Return if there are no more Events */ - if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0) + if ((Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) == 0) { HeapFree(GetProcessHeap(), 0, AsyncData); return 0; @@ -80,7 +80,7 @@ /* Set up the Async Data */ AsyncData->ParentSocket = Socket; - AsyncData->SequenceNumber = Socket->SharedData.SequenceNumber; + AsyncData->SequenceNumber = Socket->SharedData->SequenceNumber; /* Begin Async Select by using I/O Completion */ NtSetIoCompletion(SockAsyncCompletionPort, @@ -136,7 +136,7 @@ RecvInfo.BufferArray = (PAFD_WSABUF)lpBuffers; RecvInfo.BufferCount = dwBufferCount; RecvInfo.TdiFlags = 0; - RecvInfo.AfdFlags = Socket->SharedData.NonBlocking ? AFD_IMMEDIATE : 0; + RecvInfo.AfdFlags = Socket->SharedData->NonBlocking ? AFD_IMMEDIATE : 0; /* Set the TDI Flags */ if (*ReceiveFlags == 0) @@ -281,7 +281,7 @@ return SOCKET_ERROR; } - if (!(Socket->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS)) + if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS)) { /* Call WSPRecv for a non-datagram socket */ return WSPRecv(Handle, @@ -295,6 +295,17 @@ lpErrno); } + /* Bind us First */ + if (Socket->SharedData->State == SocketOpen) + { + Socket->HelperData->WSHGetWildcardSockaddr(Socket->HelperContext, + SocketAddress, + SocketAddressLength); + /* Bind it */ + if (WSPBind(Handle, SocketAddress, *SocketAddressLength, lpErrno) == SOCKET_ERROR) + return SOCKET_ERROR; + } + Status = NtCreateEvent( &SockEvent, EVENT_ALL_ACCESS, NULL, 1, FALSE ); @@ -305,7 +316,7 @@ RecvInfo.BufferArray = (PAFD_WSABUF)lpBuffers; RecvInfo.BufferCount = dwBufferCount; RecvInfo.TdiFlags = 0; - RecvInfo.AfdFlags = Socket->SharedData.NonBlocking ? AFD_IMMEDIATE : 0; + RecvInfo.AfdFlags = Socket->SharedData->NonBlocking ? AFD_IMMEDIATE : 0; RecvInfo.AddressLength = SocketAddressLength; RecvInfo.Address = SocketAddress; @@ -457,7 +468,7 @@ SendInfo.BufferArray = (PAFD_WSABUF)lpBuffers; SendInfo.BufferCount = dwBufferCount; SendInfo.TdiFlags = 0; - SendInfo.AfdFlags = Socket->SharedData.NonBlocking ? AFD_IMMEDIATE : 0; + SendInfo.AfdFlags = Socket->SharedData->NonBlocking ? AFD_IMMEDIATE : 0; /* Set the TDI Flags */ if (iFlags) @@ -574,7 +585,7 @@ return SOCKET_ERROR; } - if (!(Socket->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS)) + if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS)) { /* Use WSPSend for connection-oriented sockets */ return WSPSend(Handle, @@ -589,7 +600,7 @@ } /* Bind us First */ - if (Socket->SharedData.State == SocketOpen) + if (Socket->SharedData->State == SocketOpen) { /* Get the Wildcard Address */ BindAddressLength = Socket->HelperData->MaxWSAddressLength; @@ -639,7 +650,7 @@ /* Set up Structure */ SendInfo.BufferArray = (PAFD_WSABUF)lpBuffers; - SendInfo.AfdFlags = Socket->SharedData.NonBlocking ? AFD_IMMEDIATE : 0; + SendInfo.AfdFlags = Socket->SharedData->NonBlocking ? AFD_IMMEDIATE : 0; SendInfo.BufferCount = dwBufferCount; SendInfo.TdiConnection.RemoteAddress = RemoteAddress; SendInfo.TdiConnection.RemoteAddressLength = Socket->HelperData->MaxTDIAddressLength; Modified: trunk/reactos/dll/win32/msafd/misc/stubs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/stubs…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/stubs.c [iso-8859-1] Fri Oct 7 17:51:03 2016 @@ -21,20 +21,6 @@ UNIMPLEMENTED; return 0; -} - - -INT -WSPAPI -WSPDuplicateSocket( - IN SOCKET s, - IN DWORD dwProcessId, - OUT LPWSAPROTOCOL_INFOW lpProtocolInfo, - OUT LPINT lpErrno) -{ - UNIMPLEMENTED; - - return SOCKET_ERROR; } Modified: trunk/reactos/dll/win32/msafd/msafd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?re…
============================================================================== --- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Fri Oct 7 17:51:03 2016 @@ -47,6 +47,7 @@ typedef struct _SOCK_SHARED_INFO { SOCKET_STATE State; + LONG RefCount; INT AddressFamily; INT SocketType; INT Protocol; @@ -84,12 +85,14 @@ UINT wMsg; LONG AsyncEvents; LONG AsyncDisabledEvents; + SOCKADDR WSLocalAddress; + SOCKADDR WSRemoteAddress; } SOCK_SHARED_INFO, *PSOCK_SHARED_INFO; typedef struct _SOCKET_INFORMATION { - ULONG RefCount; SOCKET Handle; - SOCK_SHARED_INFO SharedData; + PSOCK_SHARED_INFO SharedData; + HANDLE SharedDataHandle; DWORD HelperEvents; PHELPER_DATA HelperData; PVOID HelperContext; @@ -103,8 +106,6 @@ CRITICAL_SECTION Lock; PVOID SanData; BOOL TrySAN; - SOCKADDR WSLocalAddress; - SOCKADDR WSRemoteAddress; WSAPROTOCOL_INFOW ProtocolInfo; struct _SOCKET_INFORMATION *NextSocket; } SOCKET_INFORMATION, *PSOCKET_INFORMATION;
8 years, 2 months
1
0
0
0
[janderwald] 72925: [USBAUDIO] - use IoInitializeIrp over IoAllocateIrp - reinitialize irp and urb when resubmitting it - usbaudio now successfully transfers stream irps (not yet fully working)
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Oct 7 17:30:27 2016 New Revision: 72925 URL:
http://svn.reactos.org/svn/reactos?rev=72925&view=rev
Log: [USBAUDIO] - use IoInitializeIrp over IoAllocateIrp - reinitialize irp and urb when resubmitting it - usbaudio now successfully transfers stream irps (not yet fully working) Modified: trunk/reactos/drivers/usb/usbaudio/filter.c trunk/reactos/drivers/usb/usbaudio/pin.c Modified: trunk/reactos/drivers/usb/usbaudio/filter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/filte…
============================================================================== --- trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] Fri Oct 7 17:30:27 2016 @@ -450,6 +450,7 @@ /* irp sinks / sources can be instantiated */ Pins[Index].InstancesPossible = 1; + Pins[Index].InstancesNecessary = 1; } else { Modified: trunk/reactos/drivers/usb/usbaudio/pin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/pin.c…
============================================================================== --- trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] Fri Oct 7 17:30:27 2016 @@ -8,6 +8,7 @@ */ #include "usbaudio.h" +#include <math.h> NTSTATUS GetMaxPacketSizeForInterface( @@ -283,6 +284,7 @@ BufferSize = 8 * 10 * MaximumPacketSize; /* allocate pin capture buffer */ + PinContext->BufferSize = BufferSize; PinContext->Buffer = AllocFunction(BufferSize); if (!PinContext->Buffer) { @@ -295,13 +297,28 @@ for (Index = 0; Index < 8; Index++) { /* allocate irp */ - Irp = IoAllocateIrp(PinContext->DeviceExtension->LowerDevice->StackSize, FALSE); + Irp = AllocFunction(IoSizeOfIrp(PinContext->DeviceExtension->LowerDevice->StackSize)); if (!Irp) { /* no memory */ return STATUS_INSUFFICIENT_RESOURCES; } + /* initialize irp */ + IoInitializeIrp(Irp, IoSizeOfIrp(PinContext->DeviceExtension->LowerDevice->StackSize), PinContext->DeviceExtension->LowerDevice->StackSize); + + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + Irp->IoStatus.Information = 0; + Irp->Flags = 0; + Irp->UserBuffer = NULL; + + IoStack = IoGetNextIrpStackLocation(Irp); + IoStack->DeviceObject = PinContext->DeviceExtension->LowerDevice; + IoStack->Parameters.Others.Argument2 = NULL; + IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + + DPRINT1("InitCapturePin Irp %p\n", Irp); /* insert into irp list */ InsertTailList(&PinContext->IrpListHead, &Irp->Tail.Overlay.ListEntry); @@ -433,11 +450,22 @@ PKSPIN Pin; PPIN_CONTEXT PinContext; KIRQL OldLevel; + PURB Urb; + PIO_STACK_LOCATION IoStack; + /* get pin context */ Pin = Context; PinContext = Pin->Context; + /* get stack location */ + IoStack = IoGetNextIrpStackLocation(Irp); + + /* get urb */ + Urb = Irp->Tail.Overlay.DriverContext[0]; + + //DPRINT("UsbAudioCaptureComplete Irp %p Urb %p\n", Irp, Urb); + /* acquire lock */ KeAcquireSpinLock(&PinContext->IrpListLock, &OldLevel); @@ -446,8 +474,6 @@ /* release lock */ KeReleaseSpinLock(&PinContext->IrpListLock, OldLevel); - - DPRINT1("UsbAudioCaptureComplete Irp %p\n", Irp); /* done */ return STATUS_MORE_PROCESSING_REQUIRED; @@ -464,8 +490,10 @@ PIRP Irp; PIO_STACK_LOCATION IoStack; PURB Urb; - PUCHAR TransferBuffer; - ULONG Index, Offset; + PUCHAR TransferBuffer, OutBuffer; + ULONG Index, Offset, MaximumPacketSize, Length; + NTSTATUS Status; + //PUSHORT SoundBuffer; LeadingStreamPointer = KsPinGetLeadingEdgeStreamPointer(Pin, KSSTREAM_POINTER_STATE_LOCKED); if (LeadingStreamPointer == NULL) @@ -502,83 +530,104 @@ /* get transfer buffer */ TransferBuffer = Urb->UrbIsochronousTransfer.TransferBuffer; - /* copy data */ - if (LeadingStreamPointer->OffsetOut.Remaining >= Urb->UrbIsochronousTransfer.IsoPacket[Index].Length) - { - /* copy buffer */ - RtlCopyMemory((PUCHAR)LeadingStreamPointer->OffsetOut.Data, &TransferBuffer[Offset], Urb->UrbIsochronousTransfer.IsoPacket[Index].Length); - } - else - { - /* advance to next frame */ - KsStreamPointerAdvanceOffsetsAndUnlock(LeadingStreamPointer, 0, 0, TRUE); + /* get target buffer */ + OutBuffer = (PUCHAR)LeadingStreamPointer->StreamHeader->Data; + + /* calculate length */ + Length = min(LeadingStreamPointer->OffsetOut.Count - LeadingStreamPointer->StreamHeader->DataUsed, Urb->UrbIsochronousTransfer.IsoPacket[Index].Length); + + //DPRINT1("DataUsed %lu Count %lu Remaining %lu Copying %lu Data %p\n", LeadingStreamPointer->StreamHeader->DataUsed, LeadingStreamPointer->OffsetOut.Count, LeadingStreamPointer->OffsetOut.Remaining, Length, LeadingStreamPointer->OffsetOut.Data); + + /* copy buffer */ + RtlCopyMemory((PUCHAR)&OutBuffer[LeadingStreamPointer->StreamHeader->DataUsed], &TransferBuffer[Offset], Length); + + LeadingStreamPointer->StreamHeader->DataUsed += Length; + + if (Length == LeadingStreamPointer->OffsetOut.Remaining) { + KsStreamPointerAdvanceOffsetsAndUnlock(LeadingStreamPointer, 0, Length, TRUE); + LeadingStreamPointer = KsPinGetLeadingEdgeStreamPointer(Pin, KSSTREAM_POINTER_STATE_LOCKED); if (LeadingStreamPointer == NULL) { /* FIXME handle half processed packets */ //ASSERT(FALSE); - break; + //DPRINT1("Warning: ignoring %lu packets\n", Urb->UrbIsochronousTransfer.NumberOfPackets - Index); + + /* acquire spin lock */ + KeAcquireSpinLock(&PinContext->IrpListLock, &OldLevel); + + InsertTailList(&PinContext->IrpListHead, &Irp->Tail.Overlay.ListEntry); + + KeReleaseSpinLock(&PinContext->IrpListLock, OldLevel); + return STATUS_SUCCESS; } - - ASSERT(LeadingStreamPointer->OffsetOut.Remaining >= Urb->UrbIsochronousTransfer.IsoPacket[Index].Length); - - /* copy buffer */ - RtlCopyMemory((PUCHAR)LeadingStreamPointer->OffsetOut.Data, &TransferBuffer[Offset], Urb->UrbIsochronousTransfer.IsoPacket[Index].Length); - } - - if (LeadingStreamPointer->OffsetOut.Remaining == Urb->UrbIsochronousTransfer.IsoPacket[Index].Length) - { - KsStreamPointerAdvanceOffsetsAndUnlock(LeadingStreamPointer, 0, Urb->UrbIsochronousTransfer.IsoPacket[Index].Length, TRUE); - LeadingStreamPointer = KsPinGetLeadingEdgeStreamPointer(Pin, KSSTREAM_POINTER_STATE_LOCKED); - if (LeadingStreamPointer == NULL) - break; } else { - KsStreamPointerAdvanceOffsets(LeadingStreamPointer, 0, Urb->UrbIsochronousTransfer.IsoPacket[Index].Length, FALSE); + Status = KsStreamPointerAdvanceOffsets(LeadingStreamPointer, 0, Length, FALSE); } } + /* acquire spin lock */ KeAcquireSpinLock(&PinContext->IrpListLock, &OldLevel); - /* get next stack location */ + InsertTailList(&PinContext->IrpListHead, &Irp->Tail.Overlay.ListEntry); + + if (LeadingStreamPointer == NULL) + break; + } + + while (!IsListEmpty(&PinContext->IrpListHead)) + { + /* remove entry from list */ + CurEntry = RemoveHeadList(&PinContext->IrpListHead); + + /* release lock */ + KeReleaseSpinLock(&PinContext->IrpListLock, OldLevel); + + /* get irp offset */ + Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); + + /* backup urb and transferbuffer */ + Urb = Irp->Tail.Overlay.DriverContext[0]; + TransferBuffer = Urb->UrbIsochronousTransfer.TransferBuffer; + + /* initialize irp */ + IoInitializeIrp(Irp, IoSizeOfIrp(PinContext->DeviceExtension->LowerDevice->StackSize), PinContext->DeviceExtension->LowerDevice->StackSize); + + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + Irp->IoStatus.Information = 0; + Irp->Flags = 0; + Irp->UserBuffer = NULL; + Irp->Tail.Overlay.DriverContext[0] = Urb; + + /* init stack location */ IoStack = IoGetNextIrpStackLocation(Irp); - - /* init stack location */ + IoStack->DeviceObject = PinContext->DeviceExtension->LowerDevice; IoStack->Parameters.Others.Argument1 = Urb; + IoStack->Parameters.Others.Argument2 = NULL; IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; IoSetCompletionRoutine(Irp, UsbAudioCaptureComplete, Pin, TRUE, TRUE, TRUE); - InsertTailList(&PinContext->IrpListHead, &Irp->Tail.Overlay.ListEntry); - - if (LeadingStreamPointer == NULL) - break; - } - - while (!IsListEmpty(&PinContext->IrpListHead)) - { - /* remove entry from list */ - CurEntry = RemoveHeadList(&PinContext->IrpListHead); - - /* get irp offset */ - Irp = (PIRP)CONTAINING_RECORD(CurEntry, IRP, Tail.Overlay.ListEntry); - - /* get next stack location */ - IoStack = IoGetNextIrpStackLocation(Irp); - - /* init stack location */ - IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; - IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; - - IoSetCompletionRoutine(Irp, UsbAudioCaptureComplete, Pin, TRUE, TRUE, TRUE); - - /* release lock */ - KeReleaseSpinLock(&PinContext->IrpListLock, OldLevel); - - DPRINT1("PinCaptureProcess Irp %p\n", Irp); + RtlZeroMemory(Urb, GET_ISO_URB_SIZE(10)); + + /* init urb */ + Urb->UrbIsochronousTransfer.Hdr.Function = URB_FUNCTION_ISOCH_TRANSFER; + Urb->UrbIsochronousTransfer.Hdr.Length = GET_ISO_URB_SIZE(10); + Urb->UrbIsochronousTransfer.PipeHandle = PinContext->DeviceExtension->InterfaceInfo->Pipes[0].PipeHandle; + Urb->UrbIsochronousTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_START_ISO_TRANSFER_ASAP; + Urb->UrbIsochronousTransfer.TransferBufferLength = PinContext->DeviceExtension->InterfaceInfo->Pipes[0].MaximumPacketSize * 10; + Urb->UrbIsochronousTransfer.TransferBuffer = TransferBuffer; + Urb->UrbIsochronousTransfer.NumberOfPackets = 10; + + for (Index = 0; Index < 10; Index++) + { + Urb->UrbIsochronousTransfer.IsoPacket[Index].Offset = Index * 100; + } + IoCallDriver(PinContext->DeviceExtension->LowerDevice, Irp); /* acquire spin lock */ @@ -651,6 +700,7 @@ PPIN_CONTEXT PinContext; PLIST_ENTRY CurEntry; PIRP Irp; + PURB Urb; PIO_STACK_LOCATION IoStack; NTSTATUS Status; KIRQL OldLevel; @@ -677,12 +727,15 @@ IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + /* backup urb */ + Urb = Irp->Tail.Overlay.DriverContext[0] = IoStack->Parameters.Others.Argument1; + IoSetCompletionRoutine(Irp, UsbAudioCaptureComplete, Pin, TRUE, TRUE, TRUE); /* release lock */ KeReleaseSpinLock(&PinContext->IrpListLock, OldLevel); - DPRINT1("StartCaptureIsocTransfer Irp %p\n", Irp); + DPRINT("StartCaptureIsocTransfer Irp %p Urb %p TransferBuffer %p\n", Irp, Urb, Urb->UrbIsochronousTransfer.TransferBuffer); Status = IoCallDriver(PinContext->DeviceExtension->LowerDevice, Irp); /* acquire spin lock */
8 years, 2 months
1
0
0
0
[cwittich] 72924: [WS2_32] fix various ws2_32:sock failures with return codes. By Peter Hater. CORE-12104
by cwittich@svn.reactos.org
Author: cwittich Date: Fri Oct 7 16:17:49 2016 New Revision: 72924 URL:
http://svn.reactos.org/svn/reactos?rev=72924&view=rev
Log: [WS2_32] fix various ws2_32:sock failures with return codes. By Peter Hater. CORE-12104 Modified: trunk/reactos/dll/win32/ws2_32/src/addrinfo.c Modified: trunk/reactos/dll/win32/ws2_32/src/addrinfo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/addri…
============================================================================== --- trunk/reactos/dll/win32/ws2_32/src/addrinfo.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/src/addrinfo.c [iso-8859-1] Fri Oct 7 16:17:49 2016 @@ -556,6 +556,7 @@ iFlags = ptHints->ai_flags; if ((iFlags & AI_CANONNAME) && !pszNodeName) { + SetLastError(EAI_BADFLAGS); return EAI_BADFLAGS; } @@ -563,6 +564,7 @@ iFamily = ptHints->ai_family; if ((iFamily != PF_UNSPEC) && (iFamily != PF_INET)) { + SetLastError(EAI_FAMILY); return EAI_FAMILY; } @@ -573,6 +575,7 @@ (iSocketType != SOCK_DGRAM) && (iSocketType != SOCK_RAW)) { + SetLastError(EAI_SOCKTYPE); return EAI_SOCKTYPE; } @@ -638,6 +641,7 @@ /* If we got 0, then fail */ if (wPort == 0) { + SetLastError(EAI_SERVICE); return EAI_SERVICE; } @@ -751,6 +755,7 @@ } /* Return to caller */ + SetLastError(iError); return iError; } @@ -908,6 +913,7 @@ else { /* Unsupported family */ + SetLastError(EAI_FAMILY); return EAI_FAMILY; }
8 years, 2 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
23
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Results per page:
10
25
50
100
200