[CMDUTILS][NETWORK][LOGOFF][RUNAS][CMD][SYSTEM] Improve imports and headers for some tools

This commit is contained in:
Hermès Bélusca-Maïto
2026-03-26 21:14:18 +01:00
parent e4aaf68c2d
commit cab720aa2c
41 changed files with 121 additions and 148 deletions

View File

@@ -1,9 +1,7 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(chcp chcp.c chcp.rc)
set_module_type(chcp win32cui UNICODE)
target_link_libraries(chcp conutils ${PSEH_LIB})
target_link_libraries(chcp conutils)
add_importlibs(chcp msvcrt kernel32)
set_target_properties(chcp PROPERTIES SUFFIX ".com")
add_cd_file(TARGET chcp DESTINATION reactos/system32 FOR all)

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(clip clip.c clip.rc)
set_module_type(clip win32cui UNICODE)
target_link_libraries(clip conutils ${PSEH_LIB})
target_link_libraries(clip conutils)
add_importlibs(clip advapi32 user32 msvcrt kernel32)
add_cd_file(TARGET clip DESTINATION reactos/system32 FOR all)

View File

@@ -1,7 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(fc fc.c texta.c textw.c fc.rc)
set_module_type(fc win32cui UNICODE)
target_link_libraries(fc conutils ${PSEH_LIB})
add_importlibs(fc msvcrt shlwapi user32 kernel32)
target_link_libraries(fc conutils)
add_importlibs(fc shlwapi msvcrt kernel32)
add_cd_file(TARGET fc DESTINATION reactos/system32 FOR all)

View File

@@ -0,0 +1,33 @@
#pragma once
#include <stdio.h>
#define ConInitStdStreams() /* empty */
#define StdOut stdout
#define StdErr stderr
void ConPuts(FILE *fp, LPCWSTR psz)
{
fputws(psz, fp);
}
void ConPrintf(FILE *fp, LPCWSTR psz, ...)
{
va_list va;
va_start(va, psz);
vfwprintf(fp, psz, va);
va_end(va);
}
void ConResPuts(FILE *fp, UINT nID)
{
WCHAR sz[MAX_PATH];
LoadStringW(NULL, nID, sz, _countof(sz));
fputws(sz, fp);
}
void ConResPrintf(FILE *fp, UINT nID, ...)
{
va_list va;
WCHAR sz[MAX_PATH];
va_start(va, nID);
LoadStringW(NULL, nID, sz, _countof(sz));
vfwprintf(fp, sz, va);
va_end(va);
}

View File

@@ -2,43 +2,15 @@
* PROJECT: ReactOS FC Command
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Comparing files
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "fc.h"
#ifdef __REACTOS__
#include <conutils.h>
#include <conutils.h>
#else
#include <stdio.h>
#define ConInitStdStreams() /* empty */
#define StdOut stdout
#define StdErr stderr
void ConPuts(FILE *fp, LPCWSTR psz)
{
fputws(psz, fp);
}
void ConPrintf(FILE *fp, LPCWSTR psz, ...)
{
va_list va;
va_start(va, psz);
vfwprintf(fp, psz, va);
va_end(va);
}
void ConResPuts(FILE *fp, UINT nID)
{
WCHAR sz[MAX_PATH];
LoadStringW(NULL, nID, sz, _countof(sz));
fputws(sz, fp);
}
void ConResPrintf(FILE *fp, UINT nID, ...)
{
va_list va;
WCHAR sz[MAX_PATH];
va_start(va, nID);
LoadStringW(NULL, nID, sz, _countof(sz));
vfwprintf(fp, sz, va);
va_end(va);
}
#include "conutils_noros.h"
#endif
#include <strsafe.h>
#include <shlwapi.h>

View File

@@ -2,20 +2,20 @@
* PROJECT: ReactOS FC Command
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Comparing files
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#pragma once
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef __REACTOS__
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winnls.h>
#else
#include <windows.h>
#endif
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winnls.h>
#include <wine/list.h>
#include "resource.h"

View File

@@ -1,3 +1,5 @@
#pragma once
#define IDS_USAGE 1000
#define IDS_NO_DIFFERENCE 1001
#define IDS_LONGER_THAN 1002

View File

@@ -2,7 +2,7 @@
* PROJECT: ReactOS FC Command
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Comparing text files
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "fc.h"

View File

@@ -1,9 +1,7 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(cmd_help help.c help.rc)
set_module_type(cmd_help win32cui UNICODE)
target_link_libraries(cmd_help conutils ${PSEH_LIB})
target_link_libraries(cmd_help conutils)
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)

View File

@@ -9,7 +9,6 @@
#include <stdlib.h>
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>

View File

@@ -1,9 +1,7 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(mode mode.c mode.rc)
set_module_type(mode win32cui UNICODE)
target_link_libraries(mode conutils ${PSEH_LIB})
target_link_libraries(mode conutils)
add_importlibs(mode user32 msvcrt kernel32)
set_target_properties(mode PROPERTIES SUFFIX ".com")
add_cd_file(TARGET mode DESTINATION reactos/system32 FOR all)

View File

@@ -32,8 +32,8 @@
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wincon.h>
#include <winuser.h>
#include <conutils.h>

View File

@@ -1,5 +1,4 @@
#ifndef RESOURCE_H
#define RESOURCE_H
#pragma once
#define IDS_USAGE 0
@@ -48,5 +47,3 @@
#define IDS_ERROR_NO_MEMORY 36
#define IDS_ERROR_SCREEN_LINES_COL 37
#define IDS_ERROR_INVALID_CODEPAGE 38
#endif /* RESOURCE_H */

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(timeout timeout.c timeout.rc)
set_module_type(timeout win32cui UNICODE)
target_link_libraries(timeout conutils ${PSEH_LIB})
target_link_libraries(timeout conutils)
add_importlibs(timeout msvcrt kernel32)
add_cd_file(TARGET timeout DESTINATION reactos/system32 FOR all)

View File

@@ -13,7 +13,7 @@
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
#include <winuser.h>
#include <winuser.rh>
#include <conutils.h>

View File

@@ -1,9 +1,7 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(tree tree.c tree.rc)
set_module_type(tree win32cui UNICODE)
target_link_libraries(tree conutils ${PSEH_LIB})
target_link_libraries(tree conutils)
add_importlibs(tree msvcrt kernel32)
set_target_properties(tree PROPERTIES SUFFIX ".com")
add_cd_file(TARGET tree DESTINATION reactos/system32 FOR all)

View File

@@ -4,9 +4,9 @@
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Tree Walk Utility"
#define REACTOS_STR_INTERNAL_NAME "tree"
#define REACTOS_STR_ORIGINAL_FILENAME "tree.com"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Tree Walk Utility"
#define REACTOS_STR_INTERNAL_NAME "tree"
#define REACTOS_STR_ORIGINAL_FILENAME "tree.com"
#include <reactos/version.rc>
/* UTF-8 */

View File

@@ -1,7 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(where where.c where.rc)
set_module_type(where win32cui UNICODE)
target_link_libraries(where conutils ${PSEH_LIB})
target_link_libraries(where conutils)
add_importlibs(where msvcrt kernel32)
add_cd_file(TARGET where DESTINATION reactos/system32 FOR all)

View File

@@ -1,3 +1,5 @@
#pragma once
#define IDS_USAGE 100
#define IDS_BAD_ARG 101
#define IDS_NOT_FOUND 103

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
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)
target_link_libraries(logoff conutils)
add_importlibs(logoff user32 msvcrt kernel32)
add_cd_file(TARGET logoff DESTINATION reactos/system32 FOR all)

View File

@@ -2,9 +2,9 @@
#include "resource.h"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Logoff Utility"
#define REACTOS_STR_INTERNAL_NAME "logoff"
#define REACTOS_STR_ORIGINAL_FILENAME "logoff.exe"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Logoff Utility"
#define REACTOS_STR_INTERNAL_NAME "logoff"
#define REACTOS_STR_ORIGINAL_FILENAME "logoff.exe"
#include <reactos/version.rc>
/* UTF-8 */

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(netstat netstat.c netstat.rc)
set_module_type(netstat win32cui UNICODE)
target_link_libraries(netstat conutils ${PSEH_LIB})
add_importlibs(netstat user32 ws2_32 snmpapi iphlpapi msvcrt kernel32)
target_link_libraries(netstat conutils)
add_importlibs(netstat ws2_32 snmpapi iphlpapi msvcrt kernel32)
add_cd_file(TARGET netstat DESTINATION reactos/system32 FOR all)

View File

@@ -14,10 +14,8 @@
#include <stdlib.h>
#include <wchar.h>
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#define _INC_WINDOWS
#include <winsock2.h>
#include <iphlpapi.h>

View File

@@ -3,7 +3,7 @@
/* Maximum string lengths for ASCII ip address and port names */
#define HOSTNAMELEN 256
#define PORTNAMELEN 256
#define ADDRESSLEN HOSTNAMELEN+PORTNAMELEN
#define ADDRESSLEN (HOSTNAMELEN + PORTNAMELEN)
/* command line options */
BOOL bNoOptions = FALSE; // print default

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(route route.c route.rc)
set_module_type(route win32cui UNICODE)
target_link_libraries(route conutils ${PSEH_LIB})
add_importlibs(route ws2_32 iphlpapi msvcrt advapi32 kernel32 ntdll)
target_link_libraries(route conutils)
add_importlibs(route ws2_32 iphlpapi advapi32 msvcrt kernel32 ntdll) ## ntdll for RtlIpv*
add_cd_file(TARGET route DESTINATION reactos/system32 FOR all)

View File

@@ -11,19 +11,19 @@
* Flexible, simple
*/
#define WIN32_NO_STATUS
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <stdio.h>
#include <malloc.h>
#define _INC_WINDOWS
#include <winsock2.h>
#include <iphlpapi.h>
#include <ws2tcpip.h>
#include <ip2string.h>
#include <conutils.h>
#include "resource.h"
@@ -299,6 +299,9 @@ FormatIPv4Address(
if (Ptr->Address.lpSockaddr->sa_family == AF_INET)
{
struct sockaddr_in *si = (struct sockaddr_in *)(Ptr->Address.lpSockaddr);
// DWORD dwStrLen = IPV4_ADDR_STRING_MAX_LEN;
// WSAAddressToStringW(Ptr->Address.lpSockaddr, (DWORD)Ptr->Address.iSockaddrLength, NULL, pBuffer, &dwStrLen);
// (void)InetNtopW(AF_INET, &(si->sin_addr), pBuffer, IPV4_ADDR_STRING_MAX_LEN);
RtlIpv4AddressToStringW(&(si->sin_addr), pBuffer);
return;
}

View File

@@ -2,10 +2,10 @@
#include "resource.h"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Route"
#define REACTOS_STR_INTERNAL_NAME "route"
#define REACTOS_STR_ORIGINAL_FILENAME "route.exe"
#define REACTOS_STR_ORIGINAL_COPYRIGHT "Art Yerkes (arty@users.sourceforge.net)"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Route"
#define REACTOS_STR_INTERNAL_NAME "route"
#define REACTOS_STR_ORIGINAL_FILENAME "route.exe"
#define REACTOS_STR_ORIGINAL_COPYRIGHT "Art Yerkes (arty@users.sourceforge.net)"
#include <reactos/version.rc>
/* UTF-8 */

View File

@@ -1,8 +1,7 @@
project(rapps)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/cryptlib)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
include_directories(
${REACTOS_SOURCE_DIR}/sdk/lib/cryptlib
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib
${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/zlib/contrib)
include_directories(include)
@@ -48,10 +47,10 @@ add_definitions(
file(GLOB_RECURSE rapps_rc_deps res/*.*)
add_rc_deps(rapps.rc ${rapps_rc_deps})
add_executable(rapps ${SOURCE} rapps.rc)
set_module_type(rapps win32gui UNICODE)
target_link_libraries(rapps conutils ${PSEH_LIB} uuid cpprt atl_classes minizip zlib)
add_importlibs(rapps advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32 setupapi gdiplus msvcrt kernel32 ntdll)
add_pch(rapps include/rapps.h SOURCE)
set_module_type(rapps win32gui UNICODE)
target_link_libraries(rapps conutils uuid cpprt atl_classes minizip zlib)
add_importlibs(rapps advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32 setupapi gdiplus msvcrt kernel32 ntdll)
add_dependencies(rapps rappsmsg)
add_message_headers(ANSI rappsmsg.mc)
add_cd_file(TARGET rapps DESTINATION reactos/system32 FOR all)

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(runas runas.c runas.rc)
set_module_type(runas win32cui UNICODE)
target_link_libraries(runas conutils ${PSEH_LIB})
add_importlibs(runas advapi32 msvcrt kernel32 ntdll)
target_link_libraries(runas conutils)
add_importlibs(runas advapi32 msvcrt kernel32)
add_cd_file(TARGET runas DESTINATION reactos/system32 FOR all)

View File

@@ -1,3 +1,5 @@
#pragma once
#define IDS_USAGE01 7000
#define IDS_USAGE02 7001
#define IDS_USAGE03 7002

View File

@@ -20,9 +20,6 @@
#include "resource.h"
#define NDEBUG
#include <debug.h>
#define MAX_PASSWORD_LENGTH 64
static
@@ -257,10 +254,6 @@ wmain(
dwLogonFlags &= ~LOGON_WITH_PROFILE;
}
DPRINT("User: %S\n", pszUserName);
DPRINT("Domain: %S\n", pszDomain);
DPRINT("CommandLine: %S\n", pszCommandLine);
if (pszDomain == NULL)
{
DWORD dwLength = MAX_COMPUTERNAME_LENGTH + 1;

View File

@@ -6,9 +6,9 @@
/* Define language neutral resources */
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_STR_FILE_DESCRIPTION "Run As Utility"
#define REACTOS_STR_INTERNAL_NAME "runas"
#define REACTOS_STR_ORIGINAL_FILENAME "runas.exe"
#define REACTOS_STR_FILE_DESCRIPTION "Run As Utility"
#define REACTOS_STR_INTERNAL_NAME "runas"
#define REACTOS_STR_ORIGINAL_FILENAME "runas.exe"
#include <reactos/version.rc>
#include <reactos/manifest_exe.rc>

View File

@@ -1,6 +1,4 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
list(APPEND SOURCE
gui.c
misc.c
@@ -8,8 +6,8 @@ list(APPEND SOURCE
precomp.h)
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)
set_module_type(shutdown win32cui UNICODE)
target_link_libraries(shutdown conutils)
add_importlibs(shutdown advapi32 powrprof user32 msvcrt kernel32)
add_cd_file(TARGET shutdown DESTINATION reactos/system32 FOR all)

View File

@@ -1,5 +1,10 @@
#ifndef __SHUTDOWN_PRECOMP_H
#define __SHUTDOWN_PRECOMP_H
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS shutdown/logoff utility
* PURPOSE: Precompiled header
*/
#pragma once
/* INCLUDES ******************************************************************/
@@ -57,5 +62,3 @@ VOID DisplayError(DWORD dwError);
/* gui.c */
BOOL ShutdownGuiMain(struct CommandLineOptions opts);
#endif /* __SHUTDOWN_PRECOMP_H */

View File

@@ -6,9 +6,9 @@
/* Define language neutral resources */
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Shutdown Utility"
#define REACTOS_STR_INTERNAL_NAME "shutdown"
#define REACTOS_STR_ORIGINAL_FILENAME "shutdown.exe"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Shutdown Utility"
#define REACTOS_STR_INTERNAL_NAME "shutdown"
#define REACTOS_STR_ORIGINAL_FILENAME "shutdown.exe"
#include <reactos/version.rc>
#include <reactos/manifest_exe.rc>

View File

@@ -1,6 +1,4 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
list(APPEND SOURCE
alias.c
assoc.c
@@ -65,7 +63,7 @@ add_rc_deps(cmd.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/terminal.ico)
add_executable(cmd ${SOURCE} cmd.rc)
add_pch(cmd precomp.h SOURCE)
set_module_type(cmd win32cui UNICODE)
target_link_libraries(cmd wine)
target_link_libraries(cmd conutils ${PSEH_LIB})
add_importlibs(cmd advapi32 user32 msvcrt kernel32 ntdll)
target_link_libraries(cmd conutils wine)
add_importlibs(cmd advapi32 msvcrt kernel32 ntdll)
add_delay_importlibs(cmd user32)
add_cd_file(TARGET cmd DESTINATION reactos/system32 FOR all)

View File

@@ -1,9 +1,8 @@
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)
target_link_libraries(chkdsk conutils)
add_importlibs(chkdsk fmifs msvcrt kernel32)
add_cd_file(TARGET chkdsk DESTINATION reactos/system32 FOR all)

View File

@@ -88,7 +88,7 @@ PCHKDSK Chkdsk;
// Takes the win32 error code and prints the text version.
//
//----------------------------------------------------------------------
static VOID PrintWin32Error(int Message, DWORD ErrorCode)
static VOID PrintWin32Error(UINT Message, DWORD ErrorCode)
{
ConResPuts(StdErr, Message);
ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM,

View File

@@ -1,12 +1,12 @@
/* General IDs */
#pragma once
/* General IDs */
#define IDS_USAGE 101
#define IDS_PERCENT_COMPL 102
#define IDS_ABOUT 103
#define IDS_FILE_SYSTEM 104
/* Failure IDs */
#define IDS_VOLUME_IN_USE 200
#define IDS_CHKDSK_FAIL 201
#define IDS_NO_ENTRY_POINT 202

View File

@@ -1,8 +1,6 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(subst subst.c subst.rc)
set_module_type(subst win32cui UNICODE)
target_link_libraries(subst conutils ${PSEH_LIB})
add_importlibs(subst msvcrt kernel32 ntdll)
target_link_libraries(subst conutils)
add_importlibs(subst msvcrt kernel32)
add_cd_file(TARGET subst DESTINATION reactos/system32 FOR all)

View File

@@ -12,7 +12,6 @@
#include <stdio.h>
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>