Reactos

[DISKPART] Fix the drive letter deletion code

The remove and assign commands work properly now.

Eric Kohl b2c1dd83 9d5c0bff

+7 -14
+7 -14
base/system/diskpart/mountmgr.c
··· 219 219 DeviceName, 220 220 DeviceNameLength); 221 221 222 - DPRINT1("\n"); 223 222 Status = OpenMountManager(&MountMgrHandle, GENERIC_READ | GENERIC_WRITE); 224 223 if (!NT_SUCCESS(Status)) 225 224 { ··· 228 227 goto done; 229 228 } 230 229 231 - DPRINT1("\n"); 232 230 Status = NtDeviceIoControlFile(MountMgrHandle, 233 231 NULL, 234 232 NULL, ··· 246 244 goto done; 247 245 } 248 246 249 - DPRINT1("\n"); 250 247 done: 251 248 if (MountMgrHandle) 252 249 NtClose(MountMgrHandle); ··· 270 267 NTSTATUS Status; 271 268 BOOL Ret = TRUE; 272 269 273 - DPRINT1("AssignNextDriveLetter(%S %p)\n", DeviceName, DriveLetter); 270 + DPRINT("AssignNextDriveLetter(%S %p)\n", DeviceName, DriveLetter); 274 271 275 272 DeviceNameLength = wcslen(DeviceName) * sizeof(WCHAR); 276 273 ··· 288 285 DeviceName, 289 286 DeviceNameLength); 290 287 291 - DPRINT1("\n"); 292 288 Status = OpenMountManager(&MountMgrHandle, GENERIC_READ | GENERIC_WRITE); 293 289 if (!NT_SUCCESS(Status)) 294 290 { ··· 297 293 goto done; 298 294 } 299 295 300 - DPRINT1("\n"); 301 296 Status = NtDeviceIoControlFile(MountMgrHandle, 302 297 NULL, 303 298 NULL, ··· 315 310 goto done; 316 311 } 317 312 318 - DPRINT1("\n"); 319 313 done: 320 314 if (MountMgrHandle) 321 315 NtClose(MountMgrHandle); ··· 342 336 PMOUNTMGR_MOUNT_POINTS OutputBuffer = NULL; 343 337 WCHAR DosDeviceName[30]; 344 338 ULONG InputBufferLength, DosDeviceNameLength; 339 + ULONG OutputBufferLength = 0x1000; 345 340 HANDLE MountMgrHandle = NULL; 346 341 IO_STATUS_BLOCK Iosb; 347 342 NTSTATUS Status; 348 343 BOOL Ret = TRUE; 349 344 350 - DPRINT1("DeleteDriveLetter(%c)\n", DriveLetter); 345 + DPRINT("DeleteDriveLetter(%c)\n", DriveLetter); 351 346 352 347 /* Setup the device name of the letter to delete */ 353 348 swprintf(DosDeviceName, L"\\DosDevices\\%c:", DriveLetter); ··· 363 358 } 364 359 365 360 /* Fill it in */ 366 - // RtlZeroMemory(InputBuffer, InputBufferLength); 367 361 InputBuffer->SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); 368 362 InputBuffer->SymbolicLinkNameLength = DosDeviceNameLength; 369 363 RtlCopyMemory(&InputBuffer[1], DosDeviceName, DosDeviceNameLength); 370 364 371 365 /* Allocate big enough output buffer (we don't care about the output) */ 372 - OutputBuffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, 0x1000); 366 + OutputBuffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, OutputBufferLength); 373 367 if (OutputBuffer == NULL) 374 368 { 375 369 DPRINT1("OutputBuffer allocation failed!\n"); ··· 377 371 goto done; 378 372 } 379 373 380 - DPRINT1("\n"); 374 + OutputBuffer->Size = OutputBufferLength; 375 + 381 376 Status = OpenMountManager(&MountMgrHandle, GENERIC_READ | GENERIC_WRITE); 382 377 if (!NT_SUCCESS(Status)) 383 378 { ··· 386 381 goto done; 387 382 } 388 383 389 - DPRINT1("\n"); 390 384 Status = NtDeviceIoControlFile(MountMgrHandle, 391 385 NULL, 392 386 NULL, ··· 396 390 InputBuffer, 397 391 InputBufferLength, 398 392 OutputBuffer, 399 - 0x1000); 393 + OutputBufferLength); 400 394 if (!NT_SUCCESS(Status)) 401 395 { 402 396 DPRINT1("NtDeviceIoControlFile() failed (Status 0x%08lx)\n", Status); ··· 404 398 goto done; 405 399 } 406 400 407 - DPRINT1("\n"); 408 401 done: 409 402 if (MountMgrHandle) 410 403 NtClose(MountMgrHandle);