[SERVICES][DCOMLAUNCH] Don't hardcode C: drive (#2779)

CORE-13235
This commit is contained in:
Katayama Hirofumi MZ 2020-05-17 17:45:56 +09:00 committed by GitHub
parent e246b9947e
commit fe9838f578
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,8 @@ CookupNodeId(UCHAR * NodeId)
DWORD dwValue;
MEMORYSTATUS MemoryStatus;
LUID Luid;
DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters;
WCHAR szSystem[MAX_PATH];
ULARGE_INTEGER FreeBytesToCaller, TotalBytes, TotalFreeBytes;
/* Initialize node id */
memset(NodeId, 0x11, SEED_BUFFER_SIZE * sizeof(UCHAR));
@ -104,11 +105,16 @@ CookupNodeId(UCHAR * NodeId)
*NodeMiddle = *NodeMiddle ^ Luid.HighPart;
}
/* Get system directory */
GetSystemDirectoryW(szSystem, ARRAYSIZE(szSystem));
/* And finally with free disk space */
if (GetDiskFreeSpaceA("c:\\", &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters))
if (GetDiskFreeSpaceExW(szSystem, &FreeBytesToCaller, &TotalBytes, &TotalFreeBytes))
{
*NodeMiddle = *NodeMiddle ^ TotalNumberOfClusters * BytesPerSector * SectorsPerCluster;
*NodeBegin = *NodeBegin ^ NumberOfFreeClusters * BytesPerSector * SectorsPerCluster;
*NodeMiddle ^= FreeBytesToCaller.LowPart ^ TotalFreeBytes.HighPart;
*NodeMiddle ^= FreeBytesToCaller.HighPart ^ TotalFreeBytes.LowPart;
*NodeBegin ^= TotalBytes.LowPart ^ TotalFreeBytes.LowPart;
*NodeBegin ^= TotalBytes.HighPart ^ TotalFreeBytes.HighPart;
}
/*