@@ -104,10 +104,23 @@ procedure HideInfo;
104104 dw: DWORD;
105105Begin
106106 Result:=False;
107+ OutputDebugString(' Trying to query the version of Arsenal driver' );
107108 ImScsiInitializeSrbIoBlock(check.SrbIoControl, sizeof(check), SMP_IMSCSI_QUERY_VERSION, 0 );
108- if Not DeviceIoControl(Device, IOCTL_SCSI_MINIPORT, @check, sizeof(check), @check, sizeof(check), dw, NIL ) then Exit;
109- if dw < sizeof(check) then Exit;
110- if check.SrbIoControl.ReturnCode < IMSCSI_DRIVER_VERSION Then Exit;
109+ if Not DeviceIoControl(Device, IOCTL_SCSI_MINIPORT, @check, sizeof(check), @check, sizeof(check), dw, NIL ) then
110+ Begin
111+ OutputDebugString(' Arsenal driver does not support version checking' );
112+ Exit;
113+ end ;
114+ if dw < sizeof(check) then
115+ Begin
116+ OutputDebugString(PAnsiChar(Format(' Arsenal driver reports the size of data structure for version check as %u which is less than expected %u' ,[dw,SizeOf(check)])));
117+ Exit;
118+ end ;
119+ if check.SrbIoControl.ReturnCode < IMSCSI_DRIVER_VERSION Then
120+ Begin
121+ OutputDebugString(PAnsiChar(Format(' Arsenal driver reports version %u which is less than required %u' ,[check.SrbIoControl.ReturnCode,IMSCSI_DRIVER_VERSION])));
122+ Exit;
123+ end ;
111124 Result:=True;
112125end ;
113126
@@ -164,10 +177,16 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
164177 mustFormat, formatDone, mount_point_found:Boolean;
165178Begin
166179 Result:=False;
180+ OutputDebugString(' Trying to create a new RAM-disk' );
167181 driver := ImScsiOpenScsiAdapter(portNumber);
168- if driver = INVALID_HANDLE_VALUE then Exit;
182+ if driver = INVALID_HANDLE_VALUE then
183+ Begin
184+ OutputDebugString(' Arsenal driver is not running' );
185+ Exit;
186+ end ;
169187 if not ImScsiCheckDriverVersion(driver) then
170188 begin
189+ OutputDebugString(' Arsenal driver version is not suitable' );
171190 CloseHandle(driver);
172191 Raise ERamDiskError.Create(RamDriverVersion);
173192 end ;
@@ -176,7 +195,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
176195 if not ImScsiDeviceIoControl(driver, SMP_IMSCSI_CREATE_DEVICE, create_data.SrbIoControl, SizeOf(create_data), 0 , dw) then
177196 begin
178197 NtClose(driver);
179- OutputDebugString(PAnsiChar(SysErrorMessage(GetLastError)));
198+ OutputDebugString(PAnsiChar(Format( ' Could not create the RAM-disk, error is "%s" ' ,[ SysErrorMessage(GetLastError)] )));
180199 raise ERamDiskError.Create(RamCantCreate);
181200 end ;
182201 NtClose(driver);
@@ -188,6 +207,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
188207
189208 while true do
190209 begin
210+ OutputDebugString(' Disk not attached yet, waiting 200 msec' );
191211 disk := ImScsiOpenDiskByDeviceNumber(create_data.Fields.DeviceNumber, portNumber, diskNumber);
192212 if disk <> INVALID_HANDLE_VALUE then Break;
193213 // printf("Disk not attached yet, waiting... %c\r", NextWaitChar(&wait_char));
@@ -200,6 +220,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
200220 begin
201221 while WaitForSingleObject(event, 200 ) = WAIT_TIMEOUT do
202222 begin
223+ OutputDebugString(' Rescanning SCSI adapters, disk not attached yet. Waiting 200 msec' );
203224 // printf("Disk not attached yet, waiting... %c\r", NextWaitChar(&wait_char));
204225 end ;
205226 CloseHandle(event);
@@ -244,6 +265,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
244265 end ;
245266 if mustFormat then
246267 begin
268+ OutputDebugString(' Will now create a partition on the RAM device' );
247269 rand_seed := GetTickCount();
248270 while true do
249271 begin
@@ -260,14 +282,19 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
260282 drive_layout.PartitionEntry[0 ].RecognizedPartition := TRUE;
261283 drive_layout.PartitionEntry[0 ].RewritePartition := TRUE;
262284
263- if DeviceIoControl(disk, IOCTL_DISK_SET_DRIVE_LAYOUT, @drive_layout, sizeof(drive_layout), NIL , 0 , dw, NIL ) then Break;
285+ if DeviceIoControl(disk, IOCTL_DISK_SET_DRIVE_LAYOUT, @drive_layout, sizeof(drive_layout), NIL , 0 , dw, NIL ) then
286+ Begin
287+ OutputDebugString(' Successfully created the partition' );
288+ Break;
289+ end ;
264290 if GetLastError <> ERROR_WRITE_PROTECT then
265291 begin
266292 CloseHandle(disk);
267293 Raise ERamDiskError.Create(RamCantFormat);
268294 end ;
269295
270296 // printf("Disk not yet ready, waiting... %c\r", NextWaitChar(&wait_char));
297+ OutputDebugString(' Disk is not yet ready for partitioning, waiting ...' );
271298
272299 ZeroMemory(@disk_attributes, sizeof(disk_attributes));
273300 disk_attributes.AttributesMask := DISK_ATTRIBUTE_OFFLINE or DISK_ATTRIBUTE_READ_ONLY;
@@ -285,6 +312,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
285312 numVolumes:=0 ;
286313 while true do
287314 begin
315+ OutputDebugString(' Trying to find the volume (partition) by name' );
288316 volume := FindFirstVolume(volumeName, Length(volumeName));
289317 if volume = INVALID_HANDLE_VALUE then
290318 begin
@@ -297,11 +325,13 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
297325 try
298326 repeat
299327 volumeName[48 ] := #0 ;
328+ OutputDebugString(PAnsiChar(Format(' Quering volume %s' ,[volumeName])));
300329 volHandle := CreateFile(volumeName, 0 , FILE_SHARE_READ or FILE_SHARE_WRITE, NIL , OPEN_EXISTING, 0 , 0 );
301330 if volHandle = INVALID_HANDLE_VALUE then Continue;
302331 if not ImScsiVolumeUsesDisk(volHandle, diskNumber) then
303332 begin
304333 CloseHandle(volHandle);
334+ OutputDebugString(' This volume is not used (created) by Arsenal' );
305335 continue;
306336 end ;
307337
@@ -328,13 +358,14 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
328358 // we use the undocumented FMIFS.DLL instead of Format.COM or VDS or WMI or ShFormatDrive - it always takes at least 5 seconds
329359 formatDriveName:=volumeName;
330360 FormatEx(PWideChar(formatDriveName),FMIFS_HARDDISK,' NTFS' ,' RAMDISK' ,True,4096 ,@FormatCallBack);
361+ OutputDebugString(' Successfully created NTFS filesystem on the RAM-disk' );
331362 if ShowProgress then HideInfo;
332363 end ;
333364
334365 volumeName[48 ] := ' \' ;
335366 if Not GetVolumePathNamesForVolumeName(volumeName, mountName, Length(mountName), dw) then
336367 begin
337- OutputDebugString(' Error enumerating mount points' );
368+ OutputDebugString(PAnsiChar(Format( ' Error enumerating mount points for volume %s ' ,[volumeName])) );
338369 continue;
339370 end ;
340371
@@ -344,9 +375,11 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
344375 mountList.Text:=mountName;
345376 for i:=0 to mountList.Count-1 do
346377 begin
378+ OutputDebugString(PAnsiChar(Format(' Now trying to get a drive letter for "%s"' ,[mountList[i]])));
347379 if mountList[i] = ' ' then Break;
348380 if CompareText(mountPoint,mountList[i])<>0 then
349381 begin
382+ OutputDebugString(' Removing the old mount point' );
350383 if Not DeleteVolumeMountPoint(PAnsiChar(mountList[i])) then
351384 begin
352385 dw:=GetLastError;
@@ -356,6 +389,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
356389 else
357390 begin
358391 mount_point_found := true;
392+ OutputDebugString(PAnsiChar(Format(' Mounted at %s' ,[mountPoint])));
359393 // ImScsiOemPrintF(stdout, " Mounted at %1!ws!", mnt);
360394 end ;
361395 end ;
@@ -366,6 +400,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
366400 MountPoint[1 ] := ImDiskFindFreeDriveLetter();
367401 if MountPoint[1 ] = #0 then raise ERamDiskError.Create(RamNoFreeLetter)
368402 Else config.letter:=MountPoint[1 ];
403+ OutputDebugString(PAnsiChar(' Will use drive letter ' + MountPoint[1 ]));
369404 end ;
370405 if not SetVolumeMountPoint(PAnsiChar(MountPoint), volumeName) then
371406 begin
@@ -389,6 +424,7 @@ function FormatCallback (Command: TCallBackCommand; SubAction: DWORD; ActionInfo
389424 end ;
390425
391426 // printf("Volume not yet attached, waiting... %c\r", NextWaitChar(&wait_char));
427+ OutputDebugString(' Volume not yet attached, waiting 200 msec' );
392428 Sleep(200 );
393429 end ;
394430 LoadRamDisk(config);
0 commit comments