To repair a hard drive without losing data, you can take the following steps:
Scan the hard drive for viruses to make sure that any potential malware is removed.
Check the file system integrity using the built-in Windows tool (like chkdsk) or third-party software to fix any errors.
Scan the drive with data recovery software such as Disk Drill, Recuva, EaseUS Data Recovery Wizard, or TestDisk to recover any lost or damaged files.