Also habe ich diese Python verwendet Skript zum Festplatten < /p>
Code: Select all
disk_path = r"\\.\PHYSICALDRIVE3"
offset = 120176576 * 512
i = 0
while True:
try:
with open(disk_path, 'r+b') as disk:
disk.seek(offset)
disk.read(512)
print(f"Successfully wrote {len(data)} bytes to {disk_path} at offset {offset}.")
except Exception as e:
print(e)
print(offset)
break
i += 1
offset += 512
Code: Select all
disk_path = r"\\.\PHYSICALDRIVE3"
hex_data = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
data = bytes.fromhex(hex_data)
offset = 120176576 * 512
i = 0
while True:
try:
with open(disk_path, 'r+b') as disk:
disk.seek(offset)
disk.write(data)
print(f"Successfully wrote {len(data)} bytes to {disk_path} at offset {offset}.")
except Exception as e:
print(e)
print(offset)
break
i += 1
offset += 512
Bearbeiten: Ich habe den Code aktualisiert, um den Fehler zu ermitteln. Der Fehler ist der Erlaubnisfehler, zuerst ist bei Write geschieht. Wenn wir ihn nicht brechen, hat Flush ebenfalls Fehler. Dann geht es weiter zum nächsten Sektor, im nächsten Sektor wird ein Fehler sowie Schreib- und Flush -. < /P>
haben
Code: Select all
try:
# Open the disk once and keep it open
with open(disk_path, 'r+b') as disk:
while True:
try:
try:
disk.seek(offset)
except Exception as e:
print("3", e)
break
try:
disk.write(data)
except Exception as e:
print("4", e)
break
try:
disk.flush() # Force buffer to write to disk
except Exception as e:
print("5", e)
break
print(f"Wrote at offset: {offset}")
offset += sector_size
except Exception as e:
print("1", e)
break
except Exception as e:
print("2", e)
< /code>
Ich habe den Fehler im Code benannt, um den Speicherort
zu identifizieren, wenn der Fehler angewendet wird [Loop1] 4 -> 2 [Break] < /code> Wenn Break ist Nicht angewendet wird die Schleife für immer weiter: [Loop1] 4 -> 5 -> [Loop2] 3 -> 4 -> 5 -> [Loop3] etc ......