Skip to content

Commit ea01202

Browse files
Merge remote-tracking branch 'origin/master' into AppleTV-Desktop
2 parents c979923 + 8501523 commit ea01202

File tree

151 files changed

+15781
-10769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+15781
-10769
lines changed

base/applications/network/net/cmdStatistics.c

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DisplayServerStatistics(VOID)
1818
LARGE_INTEGER LargeValue;
1919
FILETIME FileTime, LocalFileTime;
2020
SYSTEMTIME SystemTime;
21-
WORD wHour;
21+
WCHAR DateBuffer[32], TimeBuffer[32];
2222
INT nPaddedLength = 35;
2323
NET_API_STATUS Status;
2424

@@ -44,21 +44,22 @@ DisplayServerStatistics(VOID)
4444
FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
4545
FileTimeToSystemTime(&LocalFileTime, &SystemTime);
4646

47-
wHour = SystemTime.wHour;
48-
if (wHour == 0)
49-
{
50-
wHour = 12;
51-
}
52-
else if (wHour > 12)
53-
{
54-
wHour = wHour - 12;
55-
}
47+
GetDateFormatW(LOCALE_USER_DEFAULT,
48+
DATE_SHORTDATE,
49+
&SystemTime,
50+
NULL,
51+
DateBuffer,
52+
ARRAYSIZE(DateBuffer));
53+
54+
GetTimeFormatW(LOCALE_USER_DEFAULT,
55+
0,
56+
&SystemTime,
57+
NULL,
58+
TimeBuffer,
59+
ARRAYSIZE(TimeBuffer));
5660

5761
PrintMessageString(4600);
58-
ConPrintf(StdOut, L" %d/%d/%d %d:%02d %s\n\n\n",
59-
SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
60-
wHour, SystemTime.wMinute,
61-
(SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
62+
ConPrintf(StdOut, L" %s %s\n\n\n", DateBuffer, TimeBuffer);
6263

6364
PrintPaddedMessageString(4601, nPaddedLength);
6465
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_sopens);
@@ -131,7 +132,7 @@ DisplayWorkstationStatistics(VOID)
131132
LARGE_INTEGER LargeValue;
132133
FILETIME FileTime, LocalFileTime;
133134
SYSTEMTIME SystemTime;
134-
WORD wHour;
135+
WCHAR DateBuffer[32], TimeBuffer[32];
135136
INT nPaddedLength = 47;
136137
NET_API_STATUS Status;
137138

@@ -142,7 +143,7 @@ DisplayWorkstationStatistics(VOID)
142143
goto done;
143144

144145
Status = NetStatisticsGet(NULL,
145-
SERVICE_SERVER,
146+
SERVICE_WORKSTATION,
146147
0,
147148
0,
148149
(LPBYTE*)&StatisticsInfo);
@@ -159,21 +160,22 @@ DisplayWorkstationStatistics(VOID)
159160
FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
160161
FileTimeToSystemTime(&LocalFileTime, &SystemTime);
161162

162-
wHour = SystemTime.wHour;
163-
if (wHour == 0)
164-
{
165-
wHour = 12;
166-
}
167-
else if (wHour > 12)
168-
{
169-
wHour = wHour - 12;
170-
}
163+
GetDateFormatW(LOCALE_USER_DEFAULT,
164+
DATE_SHORTDATE,
165+
&SystemTime,
166+
NULL,
167+
DateBuffer,
168+
ARRAYSIZE(DateBuffer));
169+
170+
GetTimeFormatW(LOCALE_USER_DEFAULT,
171+
0,
172+
&SystemTime,
173+
NULL,
174+
TimeBuffer,
175+
ARRAYSIZE(TimeBuffer));
171176

172177
PrintMessageString(4600);
173-
ConPrintf(StdOut, L" %d/%d/%d %d:%02d %s\n\n\n",
174-
SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
175-
wHour, SystemTime.wMinute,
176-
(SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
178+
ConPrintf(StdOut, L" %s %s\n\n\n", DateBuffer, TimeBuffer);
177179

178180
PrintPaddedMessageString(4630, nPaddedLength);
179181
ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesReceived.QuadPart);

base/applications/taskmgr/run.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,49 @@ void TaskManager_OnFileNew(void)
1515
WCHAR szTitle[40];
1616
WCHAR szText[256];
1717

18+
/* If CTRL is held, start the user's command-line shell */
19+
if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
20+
{
21+
STARTUPINFOW si = { sizeof(si) };
22+
PROCESS_INFORMATION pi;
23+
WCHAR szComSpec[MAX_PATH];
24+
WCHAR fallbackCmd[] = L"cmd.exe";
25+
DWORD cchEnv = GetEnvironmentVariableW(L"ComSpec", szComSpec, _countof(szComSpec));
26+
if (cchEnv == 0 || cchEnv > _countof(szComSpec))
27+
{
28+
/* Couldn't get the environment variable, default to cmd.exe */
29+
wcscpy(szComSpec, fallbackCmd);
30+
}
31+
BOOL result = CreateProcessW(NULL,
32+
szComSpec,
33+
NULL,
34+
NULL,
35+
FALSE,
36+
CREATE_NEW_CONSOLE,
37+
NULL,
38+
NULL,
39+
&si, &pi);
40+
if (!result)
41+
{
42+
/* Couldn't start the user's command-line shell, fall back to cmd.exe */
43+
result = CreateProcessW(NULL,
44+
fallbackCmd,
45+
NULL,
46+
NULL,
47+
FALSE,
48+
CREATE_NEW_CONSOLE,
49+
NULL,
50+
NULL,
51+
&si, &pi);
52+
}
53+
if (result)
54+
{
55+
CloseHandle(pi.hThread);
56+
CloseHandle(pi.hProcess);
57+
}
58+
return;
59+
}
60+
1861
/* Load language strings from resource file */
1962
LoadStringW(hInst, IDS_CREATENEWTASK, szTitle, _countof(szTitle));
2063
LoadStringW(hInst, IDS_CREATENEWTASK_DESC, szText, _countof(szText));

base/services/srvsvc/precomp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <winreg.h>
1111
#include <winsvc.h>
1212
#include <lmserver.h>
13+
#include <ndk/exfuncs.h>
1314

1415
#include <srvsvc_s.h>
1516

base/services/srvsvc/rpcserver.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ NetrServerStatisticsGet(
476476
DWORD Options,
477477
LPSTAT_SERVER_0 *InfoStruct)
478478
{
479-
PSTAT_SERVER_0 pStatBuffer;
479+
SYSTEM_TIMEOFDAY_INFORMATION TimeOfDayInfo;
480+
PSTAT_SERVER_0 pStatBuffer = NULL;
481+
NTSTATUS Status;
480482

481483
TRACE("NetrServerStatisticsGet(%p %p %lu 0x%lx %p)\n",
482484
ServerName, Service, Level, Options, InfoStruct);
@@ -493,6 +495,20 @@ NetrServerStatisticsGet(
493495

494496
ZeroMemory(pStatBuffer, sizeof(STAT_SERVER_0));
495497

498+
/* Query the boot time */
499+
Status = NtQuerySystemInformation(SystemTimeOfDayInformation,
500+
&TimeOfDayInfo,
501+
sizeof(TimeOfDayInfo),
502+
NULL);
503+
if (NT_SUCCESS(Status))
504+
{
505+
ULONG Seconds = 0;
506+
if (RtlTimeToSecondsSince1970(&TimeOfDayInfo.BootTime, &Seconds))
507+
{
508+
pStatBuffer->sts0_start = Seconds;
509+
}
510+
}
511+
496512
// FIXME: Return the actual statistcs data!
497513

498514
*InfoStruct = pStatBuffer;

base/services/wkssvc/precomp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <ntsecapi.h>
1818
#include <ntmsv1_0.h>
1919
//#include <ntstatus.h>
20+
#include <ndk/exfuncs.h>
2021
#include <ndk/obfuncs.h>
2122
#include <ndk/psfuncs.h>
2223
#include <ndk/rtlfuncs.h>

base/services/wkssvc/rpcserver.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,9 @@ NetrWorkstationStatisticsGet(
10121012
unsigned long Options,
10131013
LPSTAT_WORKSTATION_0 *Buffer)
10141014
{
1015-
PSTAT_WORKSTATION_0 pStatBuffer;
1015+
SYSTEM_TIMEOFDAY_INFORMATION TimeOfDayInfo;
1016+
PSTAT_WORKSTATION_0 pStatBuffer = NULL;
1017+
NTSTATUS Status;
10161018

10171019
TRACE("NetrWorkstationStatisticsGet(%p %p %lu 0x%lx %p)\n",
10181020
ServerName, ServiceName, Level, Options, Buffer);
@@ -1029,6 +1031,21 @@ NetrWorkstationStatisticsGet(
10291031

10301032
ZeroMemory(pStatBuffer, sizeof(STAT_WORKSTATION_0));
10311033

1034+
/* Query the boot time */
1035+
Status = NtQuerySystemInformation(SystemTimeOfDayInformation,
1036+
&TimeOfDayInfo,
1037+
sizeof(TimeOfDayInfo),
1038+
NULL);
1039+
if (NT_SUCCESS(Status))
1040+
{
1041+
ULONG Seconds = 0;
1042+
if (RtlTimeToSecondsSince1970(&TimeOfDayInfo.BootTime, &Seconds))
1043+
{
1044+
pStatBuffer->StatisticsStartTime.u.HighPart = 0;
1045+
pStatBuffer->StatisticsStartTime.u.LowPart = Seconds;
1046+
}
1047+
}
1048+
10321049
// FIXME: Return the actual statistcs data!
10331050

10341051
*Buffer = pStatBuffer;

base/setup/reactos/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ add_pch(reactos reactos.h SOURCE)
2222
set_module_type(reactos win32gui UNICODE)
2323
target_link_libraries(reactos uuid)
2424
target_link_libraries(reactos zlib_solo) ## We use USETUP's cabinet implementation
25-
add_importlibs(reactos advapi32 gdi32 user32 comctl32 shlwapi setupapi setuplib msvcrt kernel32 ntdll)
25+
add_delay_importlibs(reactos setuplib)
26+
add_importlibs(reactos advapi32 gdi32 user32 comctl32 shlwapi setupapi msvcrt kernel32 ntdll)
2627
add_cd_file(TARGET reactos DESTINATION reactos NO_CAB FOR bootcd)

base/setup/reactos/reactos.c

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,132 @@ HotkeyThread(LPVOID Parameter)
28382838
return 0;
28392839
}
28402840

2841+
2842+
static PCWSTR
2843+
GetLocalSetupDllPath(VOID)
2844+
{
2845+
static WCHAR SetupDllPath[MAX_PATH] = L"";
2846+
static BOOL Init = FALSE;
2847+
BOOL Success;
2848+
DWORD PathSize;
2849+
2850+
/* Don't rebuild the path if we did it already */
2851+
if (Init)
2852+
return SetupDllPath;
2853+
Init = TRUE;
2854+
2855+
/*
2856+
* Retrieve the full path of the current running Setup instance.
2857+
* From this we build the suitable path to the Setup DLL.
2858+
*/
2859+
PathSize = GetModuleFileNameW(NULL, SetupDllPath, _countof(SetupDllPath));
2860+
SetupDllPath[_countof(SetupDllPath) - 1] = UNICODE_NULL; // Ensure NULL-termination (see WinXP bug)
2861+
2862+
Success = ((PathSize != 0) && (PathSize < _countof(SetupDllPath)) &&
2863+
(GetLastError() != ERROR_INSUFFICIENT_BUFFER));
2864+
if (Success)
2865+
{
2866+
/* Find the last path separator, remove it as well as the file name */
2867+
PWCHAR pch = wcsrchr(SetupDllPath, L'\\');
2868+
if (!pch)
2869+
pch = SetupDllPath;
2870+
2871+
/* The Setup DLL is inside the System32 sub-directory */
2872+
PathSize = _countof(SetupDllPath) - (pch - SetupDllPath);
2873+
Success = SUCCEEDED(StringCchCopyW(pch, PathSize, L"\\system32"));
2874+
}
2875+
if (!Success)
2876+
{
2877+
/* Failure: invalidate the path; the DLL won't be found and delay-loaded */
2878+
*SetupDllPath = UNICODE_NULL;
2879+
}
2880+
2881+
return SetupDllPath;
2882+
}
2883+
2884+
#ifndef DECLARE_UNICODE_STRING_SIZE
2885+
#define DECLARE_UNICODE_STRING_SIZE(_var, _size) \
2886+
WCHAR _var ## _buffer[_size]; \
2887+
UNICODE_STRING _var = { 0, (_size) * sizeof(WCHAR) , _var ## _buffer }
2888+
#endif
2889+
#include <ndk/exfuncs.h> // For NtRaiseHardError()
2890+
#define DELAYIMP_INSECURE_WRITABLE_HOOKS
2891+
#include <delayimp.h>
2892+
2893+
/**
2894+
* @brief
2895+
* Controls the delay-loading of Setup DLLs from a suitable path.
2896+
*
2897+
* @see
2898+
* https://stackoverflow.com/a/75325443
2899+
* https://devblogs.microsoft.com/oldnewthing/20170126-00/?p=95265
2900+
**/
2901+
static FARPROC
2902+
WINAPI setupDelayHook(unsigned dliNotify, PDelayLoadInfo pdli)
2903+
{
2904+
static CHAR dllPath[MAX_PATH];
2905+
static PCWSTR setupDllPath = NULL;
2906+
2907+
switch (dliNotify)
2908+
{
2909+
case dliNotePreLoadLibrary:
2910+
{
2911+
// NOTE: Add any other needed setup-specific DLLs there.
2912+
if (_stricmp(pdli->szDll, "setuplib.dll") == 0)
2913+
{
2914+
if (!setupDllPath)
2915+
setupDllPath = GetLocalSetupDllPath();
2916+
if (setupDllPath && *setupDllPath &&
2917+
SUCCEEDED(StringCchPrintfA(dllPath, _countof(dllPath), "%S\\%s",
2918+
setupDllPath, pdli->szDll)))
2919+
{
2920+
pdli->szDll = dllPath; /* Set szDll to the new path */
2921+
}
2922+
}
2923+
break; /* Load the DLL using the modified path */
2924+
}
2925+
2926+
case dliFailLoadLib:
2927+
{
2928+
/*
2929+
* Library loading failed.
2930+
* Raise a hard error instead of the default
2931+
* exception, and "cleanly" kill the process.
2932+
*/
2933+
ANSI_STRING DllPathA;
2934+
DECLARE_UNICODE_STRING_SIZE(DllPathU, MAX_PATH);
2935+
ULONG_PTR Parameters[] = {(ULONG_PTR)&DllPathU};
2936+
ULONG Response;
2937+
2938+
RtlInitAnsiString(&DllPathA, pdli->szDll);
2939+
RtlAnsiStringToUnicodeString(&DllPathU, &DllPathA, FALSE);
2940+
NtRaiseHardError(STATUS_DLL_NOT_FOUND | HARDERROR_OVERRIDE_ERRORMODE,
2941+
_countof(Parameters),
2942+
0x1,
2943+
Parameters,
2944+
OptionOk,
2945+
&Response);
2946+
ExitProcess(-1);
2947+
break;
2948+
}
2949+
2950+
default:
2951+
break;
2952+
}
2953+
2954+
return NULL;
2955+
}
2956+
2957+
/**
2958+
* @brief
2959+
* Custom delay-loading hooks for loading the Setup DLLs from a suitable path.
2960+
**/
2961+
// NOTE: MSVC 2015 Update 3 makes this a const variable.
2962+
// #if (_MSC_VER > 1900) || (_MSC_VER == 1900 && _MSC_FULL_VER >= 190024210) ...
2963+
/*ExternC*/ PfnDliHook __pfnDliNotifyHook2 = setupDelayHook;
2964+
/*ExternC*/ PfnDliHook __pfnDliFailureHook2 = setupDelayHook;
2965+
2966+
28412967
int WINAPI
28422968
_tWinMain(HINSTANCE hInst,
28432969
HINSTANCE hPrevInstance,

boot/freeldr/freeldr/arch/amd64/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ SwitchToRealCompSegment:
214214
.byte HEX(0EA) // 32bit long jmp
215215
AddressOfRealModeEntryPoint:
216216
.long 0 // receives address of RealModeEntryPoint
217-
.word HEX(20)//RMODE_CS
217+
.word L_RMODE_CS
218218
nop
219219

220220
CallRealMode_return:

boot/freeldr/freeldr/arch/i386/entry.S

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ SwitchToReal16Address:
233233
nop
234234

235235

236-
/* 16-bit stack pointer */
237-
stack16:
238-
.word STACK16ADDR
239-
240236
/* 32-bit stack pointer */
241237
stack32:
242238
.long STACKADDR

0 commit comments

Comments
 (0)