Author: gedmurphy
Date: Wed Sep 23 08:49:48 2015
New Revision: 69325
URL: http://svn.reactos.org/svn/reactos?rev=69325&view=rev
Log:
[DEVMGR]
Fix building with cmake (msvc)
It needs my local ATL changes to build, I'll add these soon
Added:
trunk/reactos/dll/win32/devmgr_new/api.cpp
- copied, changed from r68739, trunk/reactos/dll/win32/devmgr_new/api.c
Modified:
trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt
trunk/reactos/dll/win32/devmgr_new/properties/misc.cpp
Modified: trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/CMake…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/CMakeLists.txt [iso-8859-1] Wed Sep 23 08:49:48 2015
@@ -21,8 +21,7 @@
devmgmt/DeviceView.cpp
devmgmt/MainWindow.cpp
devmgmt/Node.cpp
- devmgmt/RootNode.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/devmgr_stubs.c)
+ devmgmt/RootNode.cpp)
add_library(devmgr SHARED
${SOURCE}
Copied: trunk/reactos/dll/win32/devmgr_new/api.cpp (from r68739, trunk/reactos/dll/win32/devmgr_new/api.c)
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/api.c…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/api.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/api.cpp [iso-8859-1] Wed Sep 23 08:49:48 2015
@@ -0,0 +1,309 @@
+/*
+*
+* COPYRIGHT: See COPYING in the top level directory
+* PROJECT: ReactOS devmgr.dll
+* FILE: lib/devmgr/stubs.c
+* PURPOSE: devmgr.dll stubs
+* PROGRAMMER: Thomas Weidenmueller (w3seek(a)users.sourceforge.net)
+* Ged Murphy (gedmurphy(a)reactos.org)
+* NOTES:
+* Some helpful resources:
+* http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;815320
+* http://www.jsiinc.com/SUBO/tip7400/rh7482.htm
+* http://www.jsiinc.com/SUBM/tip6400/rh6490.htm
+*
+* UPDATE HISTORY:
+* 04-04-2004 Created
+*/
+
+#include "stdafx.h"
+#include "devmgmt\MainWindow.h"
+
+HINSTANCE hDllInstance = NULL;
+
+WINE_DEFAULT_DEBUG_CHANNEL(devmgr);
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceManager_ExecuteA
+*
+* DESCRIPTION
+* Starts the Device Manager
+*
+* ARGUMENTS
+* hWndParent: Handle to the parent window
+* hInst: Handle to the application instance
+* lpMachineName: Machine Name, NULL is the local machine
+* nCmdShow: Specifies how the window should be shown
+*
+* RETURN VALUE
+* TRUE: if no errors occured
+* FALSE: if the device manager could not be executed
+*
+* REVISIONS
+*
+* NOTE
+* - Win runs the device manager in a separate process, so hWndParent is somehow
+* obsolete.
+*
+* @unimplemented
+*/
+BOOL
+WINAPI
+DeviceManager_ExecuteA(HWND hWndParent,
+ HINSTANCE hInst,
+ LPCSTR lpMachineName,
+ int nCmdShow)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceManager_ExecuteW
+*
+* DESCRIPTION
+* Starts the Device Manager
+*
+* ARGUMENTS
+* hWndParent: Handle to the parent window
+* hInst: Handle to the application instance
+* lpMachineName: Machine Name, NULL is the local machine
+* nCmdShow: Specifies how the window should be shown
+*
+* RETURN VALUE
+* TRUE: if no errors occured
+* FALSE: if the device manager could not be executed
+*
+* REVISIONS
+*
+* NOTE
+* - Win runs the device manager in a separate process, so hWndParent is somehow
+* obsolete.
+*
+* @unimplemented
+*/
+BOOL
+WINAPI
+DeviceManager_ExecuteW(HWND hWndParent,
+ HINSTANCE hInst,
+ LPCWSTR lpMachineName,
+ int nCmdShow)
+{
+ // FIXME: Call mmc with devmgmt.msc
+
+ CDeviceManager DevMgr;
+ return DevMgr.Create(hWndParent, hInst, lpMachineName, nCmdShow);
+}
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceProblemWizard_RunDLLA
+*
+* DESCRIPTION
+* Calls the device problem wizard
+*
+* ARGUMENTS
+* hWndParent: Handle to the parent window
+* hInst: Handle to the application instance
+* lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
+* also see NOTEs
+* nCmdShow: Specifies how the window should be shown
+*
+* RETURN VALUE
+*
+* REVISIONS
+*
+* NOTE
+* - Win XP exports this function as DeviceProblenWizard_RunDLLA, apparently it's
+* a typo so we additionally export an alias function
+* - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
+* (/MachineName is optional). This function only parses this string and eventually
+* calls DeviceProperties().
+*
+* @unimplemented
+*/
+VOID
+WINAPI
+DeviceProblemWizard_RunDLLA(HWND hWndParent,
+ HINSTANCE hInst,
+ LPCSTR lpDeviceCmd,
+ int nCmdShow)
+{
+ UNIMPLEMENTED;
+}
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceProblemWizard_RunDLLW
+*
+* DESCRIPTION
+* Calls the device problem wizard
+*
+* ARGUMENTS
+* hWndParent: Handle to the parent window
+* hInst: Handle to the application instance
+* lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
+* also see NOTEs
+* nCmdShow: Specifies how the window should be shown
+*
+* RETURN VALUE
+*
+* REVISIONS
+*
+* NOTE
+* - Win XP exports this function as DeviceProblenWizard_RunDLLA, apparently it's
+* a typo so we additionally export an alias function
+* - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
+* (/MachineName is optional). This function only parses this string and eventually
+* calls DeviceProperties().
+*
+* @unimplemented
+*/
+VOID
+WINAPI
+DeviceProblemWizard_RunDLLW(HWND hWndParent,
+ HINSTANCE hInst,
+ LPCWSTR lpDeviceCmd,
+ int nCmdShow)
+{
+ UNIMPLEMENTED;
+}
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceManagerPrintA
+*
+* DESCRIPTION
+* Calls the device problem wizard
+*
+* ARGUMENTS
+* lpMachineName: Machine Name, NULL is the local machine
+* lpPrinter: Filename of the printer where it should be printed on
+* nPrintMode: Specifies what kind of information is to be printed
+* DEV_PRINT_ABSTRACT: Prints an abstract of system information, the parameters
+* uNumberOfGuids, Guids are ignored
+* DEV_PRINT_SELECTED: Prints information about the devices listed in Guids
+* DEV_PRINT_ALL: Prints an abstract of system information and all
+* system devices
+* uNumberOfGuids: Numbers of guids in the Guids array, this parameter is ignored unless
+* nPrintMode is DEV_PRINT_SELECTED
+* lpGuids: Array of device guids, this parameter is ignored unless
+* nPrintMode is DEV_PRINT_SELECTED
+*
+* RETURN VALUE
+* TRUE: if no errors occured
+* FALSE: if errors occured
+*
+* REVISIONS
+*
+* NOTE
+*
+* @unimplemented
+*/
+BOOL
+WINAPI
+DeviceManagerPrintA(LPCSTR lpMachineName,
+ LPCSTR lpPrinter,
+ int nPrintMode,
+ UINT uNumberOfGuids,
+ LPGUID lpGuids)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
+
+/***************************************************************************
+* NAME EXPORTED
+* DeviceManagerPrintW
+*
+* DESCRIPTION
+* Calls the device problem wizard
+*
+* ARGUMENTS
+* lpMachineName: Machine Name, NULL is the local machine
+* lpPrinter: Filename of the printer where it should be printed on
+* nPrintMode: Specifies what kind of information is to be printed
+* DEV_PRINT_ABSTRACT: Prints an abstract of system information, the parameters
+* uNumberOfGuids, Guids are ignored
+* DEV_PRINT_SELECTED: Prints information about the devices listed in Guids
+* DEV_PRINT_ALL: Prints an abstract of system information and all
+* system devices
+* uNumberOfGuids: Numbers of guids in the Guids array, this parameter is ignored unless
+* nPrintMode is DEV_PRINT_SELECTED
+* lpGuids: Array of device guids, this parameter is ignored unless
+* nPrintMode is DEV_PRINT_SELECTED
+*
+* RETURN VALUE
+* TRUE: if no errors occured
+* FALSE: if errors occured
+*
+* REVISIONS
+*
+* NOTE
+*
+* @unimplemented
+*/
+BOOL
+WINAPI
+DeviceManagerPrintW(LPCWSTR lpMachineName,
+ LPCWSTR lpPrinter,
+ int nPrintMode,
+ UINT uNumberOfGuids,
+ LPGUID lpGuids)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
+
+BOOL
+WINAPI
+DllMain(IN HINSTANCE hinstDLL,
+IN DWORD dwReason,
+IN LPVOID lpvReserved)
+{
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ hDllInstance = hinstDLL;
+ break;
+ }
+
+ return TRUE;
+}
+
+class CDevMgrUIModule : public CComModule
+{
+public:
+};
+
+CDevMgrUIModule gModule;
+
+STDAPI DllCanUnloadNow()
+{
+ return gModule.DllCanUnloadNow();
+}
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+ return gModule.DllGetClassObject(rclsid, riid, ppv);
+}
+
+STDAPI DllRegisterServer()
+{
+ return gModule.DllRegisterServer(FALSE);
+}
+
+STDAPI DllUnregisterServer()
+{
+ return gModule.DllUnregisterServer(FALSE);
+}
Modified: trunk/reactos/dll/win32/devmgr_new/properties/misc.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr_new/prope…
==============================================================================
--- trunk/reactos/dll/win32/devmgr_new/properties/misc.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr_new/properties/misc.cpp [iso-8859-1] Wed Sep 23 08:49:48 2015
@@ -30,7 +30,7 @@
#include "properties.h"
#include "resource.h"
-HINSTANCE hDllInstance = NULL;
+
INT
LengthOfStrResource(IN HINSTANCE hInst,
@@ -1129,21 +1129,3 @@
return hComCtl32;
}
-
-
-BOOL
-WINAPI
-DllMain(IN HINSTANCE hinstDLL,
- IN DWORD dwReason,
- IN LPVOID lpvReserved)
-{
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDLL);
- hDllInstance = hinstDLL;
- break;
- }
-
- return TRUE;
-}
Author: ion
Date: Wed Sep 23 05:10:58 2015
New Revision: 69324
URL: http://svn.reactos.org/svn/reactos?rev=69324&view=rev
Log:
[NTOSKRNL]: Properly respect the registry's Win32PrioritySeparation value instead of ignoring it.
[NTOSKRNL]: Actually apply the foreground priority boost to threads in a foreground process.
[NTOSKRNL]: Correctly handle the case where the quantum length and fixed/variable flag are set to "default", instead of falling back into the server case.
Thanks to WINSRV doing the right thing, ReactOS console apps now receive the priority separation boost. However, my tests show that it doesn't last as long as it should on Windows (quantums too short? bug in priority decrement?). Also, since Win32k.sys doesn't tell the kernel about foreground GUI apps, they don't get the boost. Someone needs to add a NtSetInformationProcess call in whatever win32k function determines active focus.
Dedicated to ThFabba who needs to write some tests ;-)
Modified:
trunk/reactos/include/ndk/pstypes.h
trunk/reactos/ntoskrnl/config/cmdata.c
trunk/reactos/ntoskrnl/include/internal/ps.h
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/ke/thrdschd.c
trunk/reactos/ntoskrnl/ps/process.c
Modified: trunk/reactos/include/ndk/pstypes.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/pstypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/pstypes.h [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -129,8 +129,11 @@
//
// Process Priority Separation Values (OR)
//
-#define PSP_VARIABLE_QUANTUMS 4
-#define PSP_LONG_QUANTUMS 16
+#define PSP_DEFAULT_QUANTUMS 0x00
+#define PSP_VARIABLE_QUANTUMS 0x04
+#define PSP_FIXED_QUANTUMS 0x08
+#define PSP_LONG_QUANTUMS 0x10
+#define PSP_SHORT_QUANTUMS 0x20
#ifndef NTOS_MODE_USER
//
Modified: trunk/reactos/ntoskrnl/config/cmdata.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmdata.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmdata.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmdata.c [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -765,7 +765,7 @@
{
L"PriorityControl",
L"Win32PrioritySeparation",
- &DummyData,
+ &PsRawPrioritySeparation,
NULL,
NULL
},
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -452,6 +452,7 @@
extern BOOLEAN PspUseJobSchedulingClasses;
extern CHAR PspJobSchedulingClasses[PSP_JOB_SCHEDULING_CLASSES];
extern ULONG PsRawPrioritySeparation;
+extern ULONG PsPrioritySeparation;
extern POBJECT_TYPE _PsThreadType, _PsProcessType;
extern PTOKEN PspBootAccessToken;
extern GENERIC_MAPPING PspJobMapping;
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -1495,7 +1495,7 @@
/* Create a random name and set up the string*/
NameLength = (USHORT)swprintf(NameBuffer,
DRIVER_ROOT_NAME L"%08u",
- KeTickCount);
+ KeTickCount.LowPart);
LocalDriverName.Length = NameLength * sizeof(WCHAR);
LocalDriverName.MaximumLength = LocalDriverName.Length + sizeof(UNICODE_NULL);
LocalDriverName.Buffer = NameBuffer;
Modified: trunk/reactos/ntoskrnl/ke/thrdschd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdschd.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -171,6 +171,14 @@
/* Calculate the new priority after the increment */
OldPriority = Thread->BasePriority + Thread->AdjustIncrement;
+
+ /* Check if this is a foreground process */
+ if (CONTAINING_RECORD(Thread->ApcState.Process, EPROCESS, Pcb)->
+ Vm.Flags.MemoryPriority == MEMORY_PRIORITY_FOREGROUND)
+ {
+ /* Apply the foreground boost */
+ OldPriority += PsPrioritySeparation;
+ }
/* Check if this new priority is higher */
if (OldPriority > Thread->Priority)
Modified: trunk/reactos/ntoskrnl/ps/process.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/process.c [iso-8859-1] Wed Sep 23 05:10:58 2015
@@ -24,7 +24,7 @@
LARGE_INTEGER ShortPsLockDelay;
-ULONG PsRawPrioritySeparation = 0;
+ULONG PsRawPrioritySeparation;
ULONG PsPrioritySeparation;
CHAR PspForegroundQuantum[3];
@@ -255,17 +255,32 @@
/* Use a variable table */
QuantumTable = PspVariableQuantums;
}
- else
+ else if (PspQuantumTypeFromMask(PrioritySeparation) == PSP_FIXED_QUANTUMS)
{
/* Use fixed table */
QuantumTable = PspFixedQuantums;
}
+ else
+ {
+ /* Use default for the type of system we're on */
+ QuantumTable = MmIsThisAnNtAsSystem() ? PspFixedQuantums : PspVariableQuantums;
+ }
/* Now check if we should use long or short */
if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_LONG_QUANTUMS)
{
/* Use long quantums */
QuantumTable += 3;
+ }
+ else if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_SHORT_QUANTUMS)
+ {
+ /* Keep existing table */
+ NOTHING;
+ }
+ else
+ {
+ /* Use default for the type of system we're on */
+ QuantumTable += MmIsThisAnNtAsSystem() ? 3 : 0;
}
/* Check if we're using long fixed quantums */
@@ -292,12 +307,10 @@
Process = PsGetNextProcess(Process);
while (Process)
{
- /*
- * Use the priority separation, unless the process has
- * low memory priority
- */
- i = (Process->Vm.Flags.MemoryPriority == 1) ?
- 0: PsPrioritySeparation;
+ /* Use the priority separation if this is a foreground process */
+ i = (Process->Vm.Flags.MemoryPriority ==
+ MEMORY_PRIORITY_BACKGROUND) ?
+ 0: PsPrioritySeparation;
/* Make sure that the process isn't idle */
if (Process->PriorityClass != PROCESS_PRIORITY_CLASS_IDLE)
@@ -306,8 +319,7 @@
if ((Process->Job) && (PspUseJobSchedulingClasses))
{
/* Use job quantum */
- Quantum = PspJobSchedulingClasses[Process->Job->
- SchedulingClass];
+ Quantum = PspJobSchedulingClasses[Process->Job->SchedulingClass];
}
else
{