Click here to Skip to main content
16,016,180 members
Please Sign up or sign in to vote.
3.00/5 (4 votes)
See more:
Is it possible to access Master Boot Record (MBR) of a system. Can we store our file/data in MBR through c# coding? Please explain.
Posted
Updated 27-Jan-11 0:24am
v3

Why do you want to store your file on MBR? It is not file storage location. There are plenty other locations to store your files. Assuming that you are not asking for malicious activity, you can not read/write directly using C#. That would be very high level language with no API, but it is doable using P/Invoke.
 
Share this answer
 
v2
Comments
sk saini 27-Jan-11 6:29am    
I want to keep some inportant data/file on my client system that should not be corrupted/mishandeled by him or any one else there.
sk saini 27-Jan-11 6:32am    
My purpose is to keep security of my software on client systems. The file/data size can be of 100-150 kb (max.).
Sergey Alexandrovich Kryukov 27-Jan-11 22:46pm    
Yusuf,
It would be all correct if you did not mention "language". This is merely a matter or API, languages -- in traditional meaning of this term in programming -- are irrelevant.
Thank you.
--SA
Yusuf 28-Jan-11 7:03am    
Oops, slip of the tongue fingers. Corrected!
Sergey Alexandrovich Kryukov 28-Jan-11 12:03pm    
Nice pun! (Oh, I do understand -- unintended :-)
Be careful, also has some sexual connotation -- well, your understand... :-)
I just voted "5".
--SA
This is possible; Yusuf is right. As to your purpose, this looks like a children Hide-and-Seek game.

If you need security, do yourself a favor, learn about security. I hint? Security is not based on secret hidden techniques; if one person knows, another person can learn it. Security is based on commonly known open algorithms. You think open and secret is a contradiction? This is because you did not learn about security.

Thank you and good luck,
—SA
 
Share this answer
 
It's a big task.

First try to make a function using VC++ (as a dll project) to write to MBR.

To do so look for the windows API in MSDN such as
CreateFile
http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx[^]
DeviceIoControl
http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx[^]

Then using C# pInvoke signature use LoadLibrary(), GetProcAddress() call your function which writes to MBR

But you will also face security problem, hence I recommend you to visit this link
Understanding .NET Code Access Security[^]
 
Share this answer
 
I think this is what you need - it was featured today.
Driver to Hide Processes and Files[^]

Much better than messing with the MBR, which will probably kill the OS (or vice versa) anyway.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900