mirror of
https://github.com/reactos/reactos.git
synced 2025-05-28 13:38:19 +00:00
Limit machine name size
Implement SetupDiGetDeviceInfoListDetailA Rework SetupDiGetDeviceInfoListDetailW svn path=/trunk/; revision=30329
This commit is contained in:
parent
759c0dde2a
commit
019b7e82cd
3 changed files with 135 additions and 128 deletions
|
@ -39,7 +39,7 @@ static const WCHAR DeviceClasses[] = {'S','y','s','t','e','m','\\',
|
|||
|
||||
typedef struct _MACHINE_INFO
|
||||
{
|
||||
WCHAR szMachineName[MAX_PATH];
|
||||
WCHAR szMachineName[SP_MAX_MACHINENAME_LENGTH];
|
||||
RPC_BINDING_HANDLE BindingHandle;
|
||||
HSTRING_TABLE StringTable;
|
||||
BOOL bLocal;
|
||||
|
@ -397,6 +397,11 @@ CONFIGRET WINAPI CM_Connect_MachineW(
|
|||
else
|
||||
{
|
||||
pMachine->bLocal = FALSE;
|
||||
if (wcslen(UNCServerName) >= SP_MAX_MACHINENAME_LENGTH - 1)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, pMachine);
|
||||
return CR_INVALID_MACHINENAME;
|
||||
}
|
||||
lstrcpyW(pMachine->szMachineName, UNCServerName);
|
||||
|
||||
pMachine->StringTable = StringTableInitialize();
|
||||
|
|
|
@ -176,7 +176,7 @@ SetupDiCreateDeviceInfoListExW(
|
|||
DWORD size;
|
||||
DWORD rc;
|
||||
CONFIGRET cr;
|
||||
HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;;
|
||||
HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;
|
||||
|
||||
TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
|
||||
debugstr_w(MachineName), Reserved);
|
||||
|
@ -189,7 +189,15 @@ SetupDiCreateDeviceInfoListExW(
|
|||
|
||||
size = FIELD_OFFSET(struct DeviceInfoSet, szData);
|
||||
if (MachineName)
|
||||
size += (strlenW(MachineName) + 3) * sizeof(WCHAR);
|
||||
{
|
||||
SIZE_T len = strlenW(MachineName);
|
||||
if (len >= SP_MAX_MACHINENAME_LENGTH - 4)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_MACHINENAME);
|
||||
goto cleanup;
|
||||
}
|
||||
size += (len + 3) * sizeof(WCHAR);
|
||||
}
|
||||
list = MyMalloc(size);
|
||||
if (!list)
|
||||
{
|
||||
|
@ -895,6 +903,90 @@ DestroyDeviceInfoSet(struct DeviceInfoSet* list)
|
|||
return HeapFree(GetProcessHeap(), 0, list);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupDiGetDeviceInfoListDetailA(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_A DevInfoData )
|
||||
{
|
||||
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
|
||||
|
||||
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
|
||||
|
||||
if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!DevInfoData ||
|
||||
DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_A))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(
|
||||
&DeviceInfoListDetailData->ClassGuid,
|
||||
&list->ClassGuid,
|
||||
sizeof(GUID));
|
||||
DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
|
||||
if (list->MachineName)
|
||||
{
|
||||
FIXME("Stub\n");
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
DeviceInfoListDetailData->RemoteMachineName[0] = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupDiGetDeviceInfoListDetailW(
|
||||
HDEVINFO DeviceInfoSet,
|
||||
PSP_DEVINFO_LIST_DETAIL_DATA_W DevInfoData )
|
||||
{
|
||||
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
|
||||
|
||||
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
|
||||
|
||||
if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (!DevInfoData ||
|
||||
DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(
|
||||
&DeviceInfoListDetailData->ClassGuid,
|
||||
&list->ClassGuid,
|
||||
sizeof(GUID));
|
||||
DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
|
||||
if (list->MachineName)
|
||||
strcpyW(DeviceInfoListDetailData->RemoteMachineName, list->MachineName + 2);
|
||||
else
|
||||
DeviceInfoListDetailData->RemoteMachineName[0] = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiDestroyDeviceInfoList (SETUPAPI.@)
|
||||
*/
|
||||
|
@ -1753,46 +1845,6 @@ SetupDiGetDeviceInfoListClass(
|
|||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI
|
||||
SetupDiGetDeviceInfoListDetailW(
|
||||
IN HDEVINFO DeviceInfoSet,
|
||||
OUT PSP_DEVINFO_LIST_DETAIL_DATA_W DeviceInfoListDetailData)
|
||||
{
|
||||
struct DeviceInfoSet *list;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
TRACE("%p %p\n", DeviceInfoSet, DeviceInfoListDetailData);
|
||||
|
||||
if (!DeviceInfoSet)
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
else if (!DeviceInfoListDetailData)
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
else if (DeviceInfoListDetailData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
|
||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||
else
|
||||
{
|
||||
memcpy(
|
||||
&DeviceInfoListDetailData->ClassGuid,
|
||||
&list->ClassGuid,
|
||||
sizeof(GUID));
|
||||
DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
|
||||
if (list->MachineName)
|
||||
strcpyW(DeviceInfoListDetailData->RemoteMachineName, list->MachineName + 2);
|
||||
else
|
||||
DeviceInfoListDetailData->RemoteMachineName[0] = 0;
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
TRACE("Returning %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiGetDeviceInstallParamsA (SETUPAPI.@)
|
||||
*/
|
||||
|
|
|
@ -41,101 +41,24 @@ DWORD WINAPI suErrorToIds16( WORD w1, WORD w2 )
|
|||
return 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupDiGetDeviceInfoListDetailA(HDEVINFO devinfo, PSP_DEVINFO_LIST_DETAIL_DATA_A devinfo_data )
|
||||
{
|
||||
FIXME("\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInitializeFileLogW(SETUPAPI.@)
|
||||
*/
|
||||
HANDLE WINAPI SetupInitializeFileLogW(LPCWSTR LogFileName, DWORD Flags)
|
||||
HSPFILELOG WINAPI SetupInitializeFileLogW(LPCWSTR LogFileName, DWORD Flags)
|
||||
{
|
||||
FIXME("Stub %s, 0x%lx\n",debugstr_w(LogFileName),Flags);
|
||||
FIXME("Stub %s, 0x%x\n",debugstr_w(LogFileName),Flags);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInitializeFileLogA(SETUPAPI.@)
|
||||
*/
|
||||
HANDLE WINAPI SetupInitializeFileLogA(LPCSTR LogFileName, DWORD Flags)
|
||||
HSPFILELOG WINAPI SetupInitializeFileLogA(LPCSTR LogFileName, DWORD Flags)
|
||||
{
|
||||
FIXME("Stub %s, 0x%lx\n",debugstr_a(LogFileName),Flags);
|
||||
FIXME("Stub %s, 0x%x\n",debugstr_a(LogFileName),Flags);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupPromptReboot(SETUPAPI.@)
|
||||
*/
|
||||
INT WINAPI SetupPromptReboot(HSPFILEQ FileQueue, HWND Owner, BOOL ScanOnly)
|
||||
{
|
||||
#if 0
|
||||
int ret;
|
||||
TCHAR RebootText[RC_STRING_MAX_SIZE];
|
||||
TCHAR RebootCaption[RC_STRING_MAX_SIZE];
|
||||
INT rc = 0;
|
||||
|
||||
TRACE("%p %p %d\n", FileQueue, Owner, ScanOnly);
|
||||
|
||||
if (ScanOnly && !FileQueue)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (FileQueue)
|
||||
{
|
||||
FIXME("Case 'FileQueue != NULL' not implemented\n");
|
||||
/* In some cases, do 'rc |= SPFILEQ_FILE_IN_USE' */
|
||||
}
|
||||
|
||||
if (ScanOnly)
|
||||
return rc;
|
||||
|
||||
/* We need to ask the question to the user. */
|
||||
rc |= SPFILEQ_REBOOT_RECOMMENDED;
|
||||
if (0 == LoadString(hInstance, IDS_QUERY_REBOOT_TEXT, RebootText, RC_STRING_MAX_SIZE))
|
||||
return -1;
|
||||
if (0 == LoadString(hInstance, IDS_QUERY_REBOOT_CAPTION, RebootCaption, RC_STRING_MAX_SIZE))
|
||||
return -1;
|
||||
ret = MessageBox(Owner, RebootText, RebootCaption, MB_YESNO | MB_DEFBUTTON1);
|
||||
if (IDNO == ret)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
if (ExitWindowsEx(EWX_REBOOT, 0))
|
||||
return rc | SPFILEQ_REBOOT_IN_PROGRESS;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
FIXME("Stub %p %p %d\n", FileQueue, Owner, ScanOnly);
|
||||
SetLastError(ERROR_GEN_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupSetSourceListA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupSetSourceListA(DWORD flags, PCSTR *list, UINT count)
|
||||
{
|
||||
FIXME("0x%08lx %p %d\n", flags, list, count);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupSetSourceListW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupSetSourceListW(DWORD flags, PCWSTR *list, UINT count)
|
||||
{
|
||||
FIXME("0x%08lx %p %d\n", flags, list, count);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupTerminateFileLog(SETUPAPI.@)
|
||||
*/
|
||||
|
@ -150,14 +73,14 @@ BOOL WINAPI SetupTerminateFileLog(HANDLE FileLogHandle)
|
|||
*/
|
||||
BOOL WINAPI RegistryDelnode(DWORD x, DWORD y)
|
||||
{
|
||||
FIXME("%08lx %08lx: stub\n", x, y);
|
||||
FIXME("%08x %08x: stub\n", x, y);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupCloseLog(SETUPAPI.@)
|
||||
*/
|
||||
void WINAPI SetupCloseLog()
|
||||
void WINAPI SetupCloseLog(void)
|
||||
{
|
||||
FIXME("() stub\n");
|
||||
}
|
||||
|
@ -165,9 +88,9 @@ void WINAPI SetupCloseLog()
|
|||
/***********************************************************************
|
||||
* SetupLogErrorW(SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupLogErrorW(PCWSTR MessageString, LogSeverity Severity)
|
||||
BOOL WINAPI SetupLogErrorW(LPCWSTR MessageString, LogSeverity Severity)
|
||||
{
|
||||
FIXME("(%s, %ld) stub\n", debugstr_w(MessageString), Severity);
|
||||
FIXME("(%s, %d) stub\n", debugstr_w(MessageString), Severity);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -180,6 +103,33 @@ BOOL WINAPI SetupOpenLog(BOOL Reserved)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupPromptReboot(SETUPAPI.@)
|
||||
*/
|
||||
INT WINAPI SetupPromptReboot( HSPFILEQ file_queue, HWND owner, BOOL scan_only )
|
||||
{
|
||||
FIXME("%p, %p, %d\n", file_queue, owner, scan_only);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupSetSourceListA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupSetSourceListA(DWORD flags, PCSTR *list, UINT count)
|
||||
{
|
||||
FIXME("0x%08x %p %d\n", flags, list, count);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupSetSourceListW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupSetSourceListW(DWORD flags, PCWSTR *list, UINT count)
|
||||
{
|
||||
FIXME("0x%08x %p %d\n", flags, list, count);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupDiRegisterDeviceInfo(SETUPAPI.@)
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue