https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe9838f578ea56cfae51286992b4c84238050843

commit fe9838f578ea56cfae51286992b4c84238050843
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sun May 17 17:45:56 2020 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sun May 17 17:45:56 2020 +0900

    [SERVICES][DCOMLAUNCH] Don't hardcode C: drive (#2779)
    
    CORE-13235
---
 base/services/dcomlaunch/network.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/base/services/dcomlaunch/network.c 
b/base/services/dcomlaunch/network.c
index c6475c85e23..b978e9faee4 100644
--- a/base/services/dcomlaunch/network.c
+++ b/base/services/dcomlaunch/network.c
@@ -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;
     }
 
     /*

Reply via email to