mirror of
https://github.com/arehnman/yttrium-virtio-gpu.git
synced 2026-10-31 02:05:04 +00:00
[balloon] clean up pre-Win10 code (usermode part).
Signed-off-by: Vadim Rozenfeld <[email protected]>
This commit is contained in:
1 parent
91a68570e9
commit
74e209f6c8
5 files changed
+17
-150
No files matched your search
@@ -152,7 +152,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -173,7 +173,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -194,7 +194,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -215,7 +215,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -236,7 +236,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@@ -257,7 +257,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;UNIVERSAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\sys\</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
|
||||
+2
-90
@@ -69,7 +69,7 @@ VOID CDevice::Fini()
|
||||
|
||||
DWORD CDevice::Run()
|
||||
{
|
||||
PWCHAR DevicePath = GetDevicePath((LPGUID)&GUID_DEVINTERFACE_BALLOON);
|
||||
PWCHAR DevicePath = GetDevicePath((LPGUID)&GUID_DEVINTERFACE_BALLOON);
|
||||
if (DevicePath == NULL) {
|
||||
PrintMessage("File not found.");
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
@@ -85,7 +85,7 @@ DWORD CDevice::Run()
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
NOTIFY_HANDLE devnotify = m_pService->RegisterDeviceHandleNotification(
|
||||
HCMNOTIFICATION devnotify = m_pService->RegisterDeviceHandleNotification(
|
||||
hDevice);
|
||||
|
||||
if (!devnotify) {
|
||||
@@ -192,92 +192,6 @@ DWORD WINAPI CDevice::DeviceThread(LPDWORD lParam)
|
||||
return pDev->Run();
|
||||
}
|
||||
|
||||
#ifndef UNIVERSAL
|
||||
|
||||
PTCHAR CDevice::GetDevicePath( IN LPGUID InterfaceGuid )
|
||||
{
|
||||
HDEVINFO HardwareDeviceInfo;
|
||||
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData = NULL;
|
||||
ULONG Length, RequiredLength = 0;
|
||||
BOOL bResult;
|
||||
PTCHAR DevicePath;
|
||||
|
||||
HardwareDeviceInfo = SetupDiGetClassDevs(
|
||||
InterfaceGuid,
|
||||
NULL,
|
||||
NULL,
|
||||
(DIGCF_PRESENT | DIGCF_DEVICEINTERFACE)
|
||||
);
|
||||
|
||||
if (HardwareDeviceInfo == INVALID_HANDLE_VALUE) {
|
||||
PrintMessage("Cannot get class devices");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
||||
bResult = SetupDiEnumDeviceInterfaces(
|
||||
HardwareDeviceInfo,
|
||||
0,
|
||||
InterfaceGuid,
|
||||
0,
|
||||
&DeviceInterfaceData
|
||||
);
|
||||
|
||||
if (bResult == FALSE) {
|
||||
PrintMessage("Cannot get enumerate device interfaces");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetupDiGetDeviceInterfaceDetail(
|
||||
HardwareDeviceInfo,
|
||||
&DeviceInterfaceData,
|
||||
NULL,
|
||||
0,
|
||||
&RequiredLength,
|
||||
NULL
|
||||
);
|
||||
|
||||
DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalAlloc(LMEM_FIXED, RequiredLength);
|
||||
|
||||
if (DeviceInterfaceDetailData == NULL) {
|
||||
PrintMessage("Cannot allocate memory");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||
|
||||
Length = RequiredLength;
|
||||
|
||||
bResult = SetupDiGetDeviceInterfaceDetail(
|
||||
HardwareDeviceInfo,
|
||||
&DeviceInterfaceData,
|
||||
DeviceInterfaceDetailData,
|
||||
Length,
|
||||
&RequiredLength,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (bResult == FALSE) {
|
||||
PrintMessage("Cannot get device interface details");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
LocalFree(DeviceInterfaceDetailData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DevicePath = _tcsdup(DeviceInterfaceDetailData->DevicePath);
|
||||
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
LocalFree(DeviceInterfaceDetailData);
|
||||
|
||||
return DevicePath;
|
||||
}
|
||||
|
||||
#else // UNIVERSAL
|
||||
|
||||
PTCHAR CDevice::GetDevicePath(IN LPGUID InterfaceGuid)
|
||||
{
|
||||
PWSTR DeviceInterfaceList = NULL;
|
||||
@@ -327,5 +241,3 @@ PTCHAR CDevice::GetDevicePath(IN LPGUID InterfaceGuid)
|
||||
|
||||
return DevicePath;
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL
|
||||
+5
-38
@@ -248,8 +248,6 @@ void CService::GetStatus(SC_HANDLE service)
|
||||
SendStatusToSCM(CurrentState, NO_ERROR, 0, 0, 0);
|
||||
}
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
|
||||
DWORD WINAPI CService::DeviceNotificationCallback(HCMNOTIFICATION Notify,
|
||||
PVOID Context, CM_NOTIFY_ACTION Action, PCM_NOTIFY_EVENT_DATA EventData,
|
||||
DWORD EventDataSize)
|
||||
@@ -296,13 +294,10 @@ VOID WINAPI UnregisterNotificationWork(PTP_CALLBACK_INSTANCE Instance,
|
||||
CloseThreadpoolWork(Work);
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL
|
||||
|
||||
NOTIFY_HANDLE CService::RegisterDeviceInterfaceNotification()
|
||||
HCMNOTIFICATION CService::RegisterDeviceInterfaceNotification()
|
||||
{
|
||||
NOTIFY_HANDLE handle = NULL;
|
||||
HCMNOTIFICATION handle = NULL;
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
CM_NOTIFY_FILTER filter;
|
||||
CONFIGRET cr;
|
||||
|
||||
@@ -319,26 +314,13 @@ NOTIFY_HANDLE CService::RegisterDeviceInterfaceNotification()
|
||||
SetLastError(CM_MapCrToWin32Err(cr, ERROR_NOT_SUPPORTED));
|
||||
}
|
||||
|
||||
#else // UNIVERSAL
|
||||
DEV_BROADCAST_DEVICEINTERFACE filter;
|
||||
|
||||
ZeroMemory(&filter, sizeof(filter));
|
||||
filter.dbcc_size = sizeof(filter);
|
||||
filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||
filter.dbcc_classguid = GUID_DEVINTERFACE_BALLOON;
|
||||
|
||||
handle = ::RegisterDeviceNotification(m_StatusHandle, &filter,
|
||||
DEVICE_NOTIFY_SERVICE_HANDLE);
|
||||
#endif // UNIVERSAL
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
NOTIFY_HANDLE CService::RegisterDeviceHandleNotification(HANDLE DeviceHandle)
|
||||
HCMNOTIFICATION CService::RegisterDeviceHandleNotification(HANDLE DeviceHandle)
|
||||
{
|
||||
NOTIFY_HANDLE handle = NULL;
|
||||
HCMNOTIFICATION handle = NULL;
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
CM_NOTIFY_FILTER filter;
|
||||
CONFIGRET cr;
|
||||
|
||||
@@ -354,28 +336,16 @@ NOTIFY_HANDLE CService::RegisterDeviceHandleNotification(HANDLE DeviceHandle)
|
||||
{
|
||||
SetLastError(CM_MapCrToWin32Err(cr, ERROR_NOT_SUPPORTED));
|
||||
}
|
||||
#else // UNIVERSAL
|
||||
DEV_BROADCAST_HANDLE filter;
|
||||
|
||||
ZeroMemory(&filter, sizeof(filter));
|
||||
filter.dbch_size = sizeof(filter);
|
||||
filter.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
||||
filter.dbch_handle = DeviceHandle;
|
||||
|
||||
handle = ::RegisterDeviceNotification(m_StatusHandle, &filter,
|
||||
DEVICE_NOTIFY_SERVICE_HANDLE);
|
||||
#endif // UNIVERSAL
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
BOOL CService::UnregisterNotification(NOTIFY_HANDLE Handle)
|
||||
BOOL CService::UnregisterNotification(HCMNOTIFICATION Handle)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (Handle)
|
||||
{
|
||||
#ifdef UNIVERSAL
|
||||
PTP_WORK work;
|
||||
|
||||
work = CreateThreadpoolWork(UnregisterNotificationWork, Handle, NULL);
|
||||
@@ -385,9 +355,6 @@ BOOL CService::UnregisterNotification(NOTIFY_HANDLE Handle)
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
#else // UNIVERSAL
|
||||
ret = ::UnregisterDeviceNotification(Handle);
|
||||
#endif // UNIVERSAL
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+4
-12
@@ -4,12 +4,6 @@
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
#define NOTIFY_HANDLE HCMNOTIFICATION
|
||||
#else
|
||||
#define NOTIFY_HANDLE HDEVNOTIFY
|
||||
#endif
|
||||
|
||||
class CDevice;
|
||||
|
||||
class CService
|
||||
@@ -23,15 +17,13 @@ public:
|
||||
static void __stdcall ServiceMainThunk(CService* service, DWORD argc, TCHAR* argv[]);
|
||||
SERVICE_STATUS_HANDLE m_StatusHandle;
|
||||
|
||||
NOTIFY_HANDLE RegisterDeviceInterfaceNotification();
|
||||
NOTIFY_HANDLE RegisterDeviceHandleNotification(HANDLE DeviceHandle);
|
||||
BOOL UnregisterNotification(NOTIFY_HANDLE Handle);
|
||||
HCMNOTIFICATION RegisterDeviceInterfaceNotification();
|
||||
HCMNOTIFICATION RegisterDeviceHandleNotification(HANDLE DeviceHandle);
|
||||
BOOL UnregisterNotification(HCMNOTIFICATION Handle);
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
static DWORD WINAPI DeviceNotificationCallback(HCMNOTIFICATION Notify,
|
||||
PVOID Context, CM_NOTIFY_ACTION Action,
|
||||
PCM_NOTIFY_EVENT_DATA EventData, DWORD EventDataSize);
|
||||
#endif
|
||||
|
||||
private:
|
||||
BOOL SendStatusToSCM(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint);
|
||||
@@ -42,7 +34,7 @@ private:
|
||||
DWORD ServiceHandleDeviceChange(DWORD evtype);
|
||||
DWORD ServiceHandlePowerEvent(DWORD evtype, DWORD flags);
|
||||
|
||||
NOTIFY_HANDLE m_hDevNotify;
|
||||
HCMNOTIFICATION m_hDevNotify;
|
||||
HANDLE m_evTerminate;
|
||||
BOOL m_bRunningService;
|
||||
DWORD m_Status;
|
||||
|
||||
@@ -13,11 +13,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#ifdef UNIVERSAL
|
||||
#include <cfgmgr32.h>
|
||||
#endif // UNIVERSAL
|
||||
|
||||
#include "targetver.h"
|
||||
#include "utils.h"
|
||||
#include "service.h"
|
||||
|
||||
Reference in new issue
Block a user