- Set the ip address, subnet mask and default gateway when an alternate configuration has been configured.
- Set registry values for the alternate configuration and APIPA.
In `SmpTranslateSystemPartitionInformation()`, fall back to using the
OS boot drive letter if none was found to be assigned to the SystemPartition.
Otherwise, just fail if any other error was encountered.
(This behaviour has been introduced in a post-SP1 Windows 7 update.)
Additionally, simplify very slightly the code.
wlanconf\wlanconf.c(592):
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
wlanconf\wlanconf.c(602),(683):
warning C4267: '=': conversion from 'size_t' to 'ULONG', possible loss of data
netsh\helper.c(84):
warningC4267: 'function': conversion from 'size_t' to 'DWORD', possible loss of data
netsh\netsh.c(65):
warning C4267: '+=': conversion from 'size_t' to 'INT', possible loss of data
net\cmdLocalGroup.c(125):
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
net\cmdShare.c(115),(128),(142):
warning C4267: '=': conversion from 'size_t' to 'INT', possible loss of data
net\cmdUse.c(89),(178),(194):
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
net\cmdUser.c(597),(631),(676):
warning C4267: '=': conversion from 'size_t' to 'INT', possible loss of data
ipconfig\ipconfig.c(236):
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
ipconfig\ipconfig.c(263),(306),(380):
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
ipconfig\ipconfig.c(303):
warning C4267: 'initializing': conversion from 'size_t' to 'DWORD', possible loss of data
ipconfig\ipconfig.c(1318): warning C4267: 'function': conversion from 'size_t' to 'DWORD', possible loss of data
dwnl\dwnl.c(387):
warning C4267: 'function': conversion from 'size_t' to 'DWORD', possible loss of data
dwnl\dwnl.c(401):
warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
whoami\whoami.c(134):
warning C4267: 'initializing': conversion from 'size_t' to 'DWORD', possible loss of data
whoami\whoami.c(241),(256):
warning C4267: 'initializing': conversion from 'size_t' to 'UINT', possible loss of data
CORE-20537
- `WhoamiSetTable()`: Specify the correct size for allocating a buffer
for a NUL-terminated UTF16 string (previously, only half the space for
the NUL terminator was considered).
This caused a heap corruption when the corresponding NUL-terminate
string was then copied into this buffer, and potentially leading to
reading past the end of the string (since no real NUL terminator
would be found).
- `WhoamiPrintTable()`: Just make it do what it needs to do: print the
table and nothing more: no "side-effect" behaviour like table freeing.
- Instead, add a `WhoamiFreeTable()` routine whose purpose is just to
free the table. And the tables are freed in the routines where they
have been previously allocated.
- `WhoamiPrintTable()`:
* Allocate a column-lengths table *ONLY* when needed, i.e. when
printing the table in "table" format. When printing it in "list"
format, there is no need to allocate anything and we can instead
use only a single variable.
* The old code handling "those pesky ':'" -- used when tables are
displayed in list format, using: `whoami /all /fo list` -- was buggy,
because it was patching the table header names, writing a ':' and a
NUL-terminator past the end of the allocated string buffer (see bug
described above in `WhoamiSetTable()`). As a result, once the table
was freed, a heap corruption would happen, leading to a crash.
Now, displaying the ':' is handled as part of the wprintf()-formatting
table item string.
* For developers, two ways of displaying these ':' are proposed:
the way Windows displays the table in "list" format, where the ':'
directly follow the item names in the 1st column; and a "nicer" one
(to my taste!), where all the ':' are vertically aligned -- currently
disabled.
The point of kernel32_vista was to provide a dll that can be used for winesyncs to still have NT6 APIs.
We're now switching to an architecture where we'll have kernelbase OR a kernel32_win7 depending on NT target compile
but this means that for an ANSI exe such as this, we need an alternative solution.
Thankfully it's pretty much only for this but just in case i made it a library.
In particular:
- `IDS_NOSET`: When the user tries `hostname -s ...`, tell them that for
changing the computer host's name, one has to go in the "Computer Name"
tab in the "System" control panel applet.
NOTE: You may observe that Windows' hostname says instead,
"Use the Network Control Panel Applet to set hostname."
This piece of information is wrong since Windows 2000. Indeed:
* From NT 3.1 to NT 4, one had to change the host's name via the
"Network" control panel applet; the message was accurate back then.
* Since Windows 2000, one changes the computer's host name via the
"Network Identification" (Win2000) / "Computer Name" (WinXP and above)
tab of the "System" properties Control Panel applet.
* In addition, the ony "Network" feature in the Control Panel is the
"Network Connections" special folder and doesn't deal with the host name.
- Use the ConUtils library for uniform output (on console or redirected)
of localized string resources/messages. Supersedes PR #8739.
- Improve output of last-errors by showing their description, only
falling back to showing the error number if no description exists.
...but wait until the partitions are actually updated on disk.
CORE-13525
DeletePartition() deletes partitions only in the virtual partitions list
in memory; the partitions still exist on the disk and are written only
later when committing all partition changes.
Thus, we do the same for file system volumes that lay on top of these
partitions being deleted: we move the linked VOLENTRY structures to a
list of "pending volumes to unmount", while they still actually stay
mounted on the system. Only when partition changes are about to be
committed to disk, the "pending volumes to unmount" list is processed
and the volumes actually unmounted, prior to modifying the partitions.
Someone familiar with this should do a more proper fix.
C:/ReactOS/reactos/sdk/lib/atl/atlcom.h: In instantiation of 'class ATL::CComObject<CRShellClassFactory>':
C:/ReactOS/reactos/sdk/include/reactos/shellutils.h:357:45: required from 'HRESULT ShellObjectCreatorInit(T1, const IID&, void**) [with T = CRShellClassFactory; T1 = _GUID; HRESULT = long int; IID = _GUID]'
C:/ReactOS/reactos/base/shell/rshell/misc.cpp:256:55: required from here
C:/ReactOS/reactos/base/shell/rshell/misc.cpp:210:28: error: 'virtual HRESULT CRShellClassFactory::CreateInstance(LPUNKNOWN, const IID&, void**)' was hidden [-Werror=overloaded-virtual=]
210 | virtual HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
| ^~~~~~~~~~~~~~
In file included from C:/ReactOS/reactos/base/shell/rshell/misc.cpp:33:
C:/ReactOS/reactos/sdk/lib/atl/atlcom.h:171:27: note: by 'static HRESULT ATL::CComObject<Base>::CreateInstance(ATL::CComObject<Base>**) [with Base = CRShellClassFactory; HRESULT = long int]'
171 | static HRESULT WINAPI CreateInstance(CComObject<Base> **pp)
| ^~~~~~~~~~~~~~
While our glob is a dummy anyway and always returns NULL, the basic idea is that glob returns a NULL terminated array of pointers. The original code only calls blkfree to free any allocation in the array after the first one and doesn't free the array itself. Our code tried to be "smart" and free the array as well, but the array pointer was already changed by a "globbed++", resulting in trying to free an invalid address. Also the free was only called, when glob returned more than one result. This is now fixed by removing the "++", doing the blkfree on "&globbed[1]" and calling free on the originally returned array in all cases.
Fixes GCC 13 warning:
C:/ReactOS/reactos/base/applications/network/ftp/cmds.c: In function 'globulize':
C:/ReactOS/reactos/base/applications/network/ftp/cmds.c:1684:25: error: 'free' called on pointer 'globbed' with nonzero offset 4 [-Werror=free-nonheap-object]
1684 | free((char *)globbed);
| ^~~~~~~~~~~~~~~~~~~~~
C:/ReactOS/reactos/base/applications/network/ftp/cmds.c:1669:19: note: returned from 'glob'
1669 | globbed = glob(*cpp);
| ^~~~~~~~~~
In our port glob is a dummy that always returns NULL, and the original code does not have a free here, either.
C:/ReactOS/reactos/base/shell/cmd/del.c: In function 'ProcessDirectory':
C:/ReactOS/reactos/base/shell/cmd/del.c:333:17: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
333 | if (!(f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
| ^~
In file included from C:/ReactOS/reactos/base/shell/cmd/precomp.h:14,
from C:/ReactOS/reactos/base/shell/cmd/del.c:48:
C:/ReactOS/reactos/sdk/include/crt/tchar.h:246:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
246 | #define _tcscpy wcscpy
| ^~~~~~
C:/ReactOS/reactos/base/shell/cmd/del.c:338:21: note: in expansion of macro '_tcscpy'
338 | _tcscpy(pFilePart, f.cFileName);
| ^~~~~~~
GCC 13 doesn't like if you keep a dangling pointer around.
C:/ReactOS/reactos/base/shell/cmd/for.c: In function 'ForF':
C:/ReactOS/reactos/base/shell/cmd/for.c:307:20: error: storing the address of local variable 'Variables' in '*fc.values' [-Werror=dangling-pointer=]
307 | fc->values = Variables;
| ~~~~~~~~~~~^~~~~~~~~~~
C:/ReactOS/reactos/base/shell/cmd/for.c:141:12: note: 'Variables' declared here
141 | LPTSTR Variables[32];
| ^~~~~~~~~
C:/ReactOS/reactos/base/shell/cmd/for.c:57:14: note: 'fc' declared here
57 | PFOR_CONTEXT fc = NULL;
| ^~
Make the code simpler, so GCC doesn't get confused.
C:/ReactOS/reactos/base/shell/cmd/misc.c: In function 'add_entry':
C:/ReactOS/reactos/base/shell/cmd/misc.c:216:14: error: pointer 'oldarg' may be used after 'realloc' [-Werror=use-after-free]
216 | *arg = oldarg;
| ~~~~~^~~~~~~~
In file included from C:/ReactOS/reactos/base/shell/cmd/cmd.h:29,
from C:/ReactOS/reactos/base/shell/cmd/precomp.h:34,
from C:/ReactOS/reactos/base/shell/cmd/misc.c:35:
C:/ReactOS/reactos/base/shell/cmd/cmddbg.h:30:31: note: call to 'realloc' here
30 | #define cmd_realloc(ptr,size) realloc(ptr, size)
| ^~~~~~~~~~~~~~~~~~
C:/ReactOS/reactos/base/shell/cmd/misc.c:212:12: note: in expansion of macro 'cmd_realloc'
212 | *arg = cmd_realloc (oldarg, (*ac + 2) * sizeof (LPTSTR));
| ^~~~~~~~~~~
Don't strncpy 0 bytes. Also add an assert that source and dest are not the same.
C:/ReactOS/reactos/base/applications/network/nslookup/utility.c: In function 'ReverseIP':
C:/ReactOS/reactos/base/applications/network/nslookup/utility.c:264:5: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation]
264 | strncpy( &pReturn[k], &pIP[i + 1], (j - i) );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instead give IMAGE_PART a complete default contructor. Fixes GCC 13 warning.
In file included from C:/ReactOS/reactos/sdk/include/psdk/minwindef.h:171,
from C:/ReactOS/reactos/sdk/include/psdk/windef.h:17,
from C:/ReactOS/reactos/base/applications/mspaint/precomp.h:17,
from C:/ReactOS/reactos/base/applications/mspaint/history.cpp:9:
C:/ReactOS/reactos/base/applications/mspaint/history.cpp: In constructor 'ImageModel::ImageModel()':
C:/ReactOS/build-gcc-x86/sdk/include/psdk/winnt.h:8732:47: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct IMAGE_PART'; use assignment or value-initialization instead [-Werror=class-memaccess]
8732 | #define RtlFillMemory(Dest,Length,Fill) memset((Dest),(Fill),(Length))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
C:/ReactOS/build-gcc-x86/sdk/include/psdk/winnt.h:8733:36: note: in expansion of macro 'RtlFillMemory'
8733 | #define RtlZeroMemory(Dest,Length) RtlFillMemory((Dest),(Length),0)
| ^~~~~~~~~~~~~
C:/ReactOS/reactos/sdk/include/psdk/minwinbase.h:31:20: note: in expansion of macro 'RtlZeroMemory'
31 | #define ZeroMemory RtlZeroMemory
| ^~~~~~~~~~~~~
C:/ReactOS/reactos/base/applications/mspaint/history.cpp:41:5: note: in expansion of macro 'ZeroMemory'
41 | ZeroMemory(m_historyItems, sizeof(m_historyItems));
| ^~~~~~~~~~
C:/ReactOS/reactos/base/services/dhcpcsvc/dhcp/adapter.c: In function 'AdapterDiscoveryThread':
C:/ReactOS/reactos/base/services/dhcpcsvc/dhcp/adapter.c:326:28: error: 'AdapterFindByHardwareAddress' accessing 16 bytes in a region of size 8 [-Werror=stringop-overflow=]
326 | if ((Adapter = AdapterFindByHardwareAddress(Table->table[i].bPhysAddr, Table->table[i].dwPhysAddrLen)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ReactOS/reactos/base/services/dhcpcsvc/dhcp/adapter.c:326:28: note: referencing argument 1 of type 'u_int8_t[16]' {aka 'unsigned char[16]'}
C:/ReactOS/reactos/base/services/dhcpcsvc/dhcp/adapter.c:544:15: note: in a call to function 'AdapterFindByHardwareAddress'
544 | PDHCP_ADAPTER AdapterFindByHardwareAddress( u_int8_t haddr[16], u_int8_t hlen ) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~