Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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 27-Jan-11 1:11am
sk saini5.6K
Edited 27-Jan-11 1:24am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
sk saini at 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 at 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.).
SAKryukov at 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 at 28-Jan-11 7:03am
   
Oops, slip of the tongue fingers. Corrected!
SAKryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100