How can I make a file permanently immutable (not removable and read-only)?

I need to make the file really read - save it as is. No deletion, nothing.

(Setting the ReadOnly attribute is not an option)

Now I see several approaches:

  • Use the program to open the file. Disadvantage: you can kill the process and then close the file.

  • Use the program to set security attributes. Disadvantage: the file can be deleted. In addition, attributes can be changed back.

Any ideas? In addition, sample code will be appreciated (preferably in Delphi).

UPDATE: . Thanks to all the answers so far. They are really wonderful. I understand that I was not very clear. The problem we want to solve is this:

There are some .txt files containing confidential information. Our customers want to make sure that these files are not changed "behind the scenes" on their computers. It should be mentioned that their PCs can easily be infected with malware specially designed for this. Our customers should be able to open these files using Notepad, Wordpad, etc., but they agree that the files are read-only. If any of our customers takes decisive actions, for example, enter "safe mode", etc., and disgust files from them. We must protect them from any malware, including a zero-day attack. (Therefore, the classic solution for antiviruses is not suitable).

Can you give some ideas?

PS: , .

+3
12

, " " - .

, : + SHA1-Hash . .

: , , , , .

SHA-1- Delphi, , , MessageDigests.

+7

" , ?" . , .

, - .

  • , - ( )?

  • , - , ( Windows - NTUSER.DAT , nix -/bin/ls ..)?

  • , , (, )?

  • , , , - ?

, , . , , ?

+17

, . Mihal, .

101: , , , . , / , . , .

, , , , Massif, . , , -, EXE, , , , .

+14

cd.

+10

...

+6

. , .

, ? , ?

+4

, , Microsoft .

+4

.

+3

? .

, . , , : , ( ) , , .

+2

, windows security acls. , , , , os .

+2

/ ? ?

+2

Microsoft , : - NTFS, . , - , , .

ACL , , . , ! , ( CREATOR OWNER). , , , , . , .

, , . NTFS , , . WINAPI, , (MSDN). CreateFile SetNamedSecurityInfo SetSecurityInfo.

:. , SYSTEM, , , . . , PE, , , SYSTEM. , .

+2

Source: https://habr.com/ru/post/1716092/


All Articles