|
Then you did something else wrong in your code. Post the read and write sections and we may be able to tell you where that is.
|
|
|
|
|
Yeah, it will work since I used it to read and parse PE format executables myself.
|
|
|
|
|
what do you mean by "raw file image"?
is it a file containing an image (i.e. header plus pixel data)?
is it a file containing the raw data of an image (i.e. pixel data only)?
is it the "image" of an executaable?
you can read( or write) all the bytes of a file at once using File.ReadAllBytes (WriteAllBytes).
If you don't want to have them all at once in memory, use a BinaryReader (BinaryWriter).
And what do you mean by "encoding"?
if it refers to the Encoding class, that one only applies to text.
if it refers to the way pixels get represented, that one is called PixelFormat.
Please learn to ask questions properly.
And don't say "it didn't run and OS complained invalid image", show the code and the exact compile-time or run-time error message(s).
|
|
|
|
|
|
No I do not understand you, you fail to provide necessary information and ask a clear question.
And no I did not suggest anything would be possible or impossible, as it is still completely unclear what you want in the first place.
Now stop reading things that are not present; and start providing information that is necessary but missing.
|
|
|
|
|
Covean did - learn post only if you have something to offer mate
dev
|
|
|
|
|
Please don't remove any messages that have been replied to. It is against the forum guidelines as it results in messy threads.
Yours said:
thanks yes you understand me - i will post the code but you're suggesting this can't be done in dotnet?
which is what you also replied to Covean !?!?!?
|
|
|
|
|
I figured originally i intend to reply to Covean, but instead went to you. To avoid further confusion I removed it (MOVED back to under Covean's thread)
dev
|
|
|
|
|
@devvvy: YOU don´t understand: You were asked to provide the piece of code making troubles .... you didn´t, instead you started to moan ... ANYWAY:
byte[] an_image = File.ReadAllBytes("hello_world.exe");
File.WriteAllBytes("another_hello_world.exe", an_image);
No P/Invoke, not really difficult ...
|
|
|
|
|
hey thanks it works!
<br />
static void Main(string[] args)<br />
{<br />
string TargetFile = null;<br />
byte[] an_image = null;<br />
<br />
try<br />
{<br />
TargetFile = args[0];<br />
<br />
if (!string.IsNullOrEmpty(TargetFil ))<br />
{<br />
an_image = File.ReadAllBytes(TargetFile );<br />
File.WriteAllBytes("SomeClone.exe", an_image);<br />
}<br />
}<br />
catch (Exception Ex)<br />
{<br />
Console.WriteLine("Yike");<br />
}<br />
<br />
return;<br />
}<br />
dev
modified on Wednesday, August 11, 2010 4:30 AM
|
|
|
|
|
|
I must have made a mistake - I thought I tried ReadAllBytes too but apparently not.
dev
|
|
|
|
|
If I'm right then he asks for a way to read all the file data plus the file system (NTFS as example) specific information.
On a hard disk there are also a file header / footer for every file.
Now this data he wants to read (and maybe) write.
1. Handle a file is the wrong approach you have to handle the file system in your case.
2. There is no class (or?) to read/write from/to the hard disk at this i/o level in C#.
3. Take a look at CreateFile. There is a possibility to read the physical disk.
Greetings
Covean
|
|
|
|
|
thanks yes you understand me - i will post the code but you're suggesting this can't be done in dotnet?
dev
|
|
|
|
|
He didn't "understand" you. He frickin' guessed at it using the link you posted and your replies in this thread.
I took a look at the link and guessed that you were trying to read the entire contents of the file, uninterpreted, because of the HexEdit screen shots in the link and your mentioning of using Encoding to read the file. You made no mention at all of what you were ultimately trying to do with this information.
Luc is correct. You still don't know how to ask a question in a format that is answerable, nor do you provide any of the details to questions that would fill in the missing bits of information critical to giving you the correct answer on the first try. You've demonstrated a history of this. People have to constantly guess at what you're talking about.
|
|
|
|
|
screw you sis go find someone else to argue with, if you don't know the sh*t, don't litter the forum pass on to another thread which you actually have something to offer
dev
|
|
|
|
|
The only way someone can actually offer you anything useful is if they take a wild ass guess at what your trying to do.
|
|
|
|
|
and why do you think Covean gave me the answer I was looking for? There's troops of losers littering this forum these days - like i said, if you have no better to say just move on and play with yourself
dev
|
|
|
|
|
This can be done in .NET / C# by using PInvoke.
But on the other hand I think that accessing the file system directly from C# should be avoided.
If you have problems to get started with this, google for "PInvoke" and try to figure out how to call Windows API from within C#.
PS: To get a better start with this forum and all those helper/cpians here, please read the pinned forum guidelines at the start and try to think about / rephrase your question. One more sentences could avoid further inquiry.
Greetings
Covean
|
|
|
|
|
Covean wrote: If you have problems to get started with this, google for "PInvoke" and try to figure out how to call Windows API from within C#.
I understand pinvoke, but why ... that such things done via platform win32 api better...?
dev
|
|
|
|
|
I just only know this way ... so why should be something better to the only way I know ... better than what?
Let me know if you know an other way, than maybe we could speak about things like that one way is better than the other
... but how should I be able to tell you if win32 api platform invoke is better than ... what???
Greetings
Covean
|
|
|
|
|
Covean wrote: This can be done in .NET / C# by using PInvoke.
It can be done WITHOUT P/Invoke
Covean wrote: But on the other hand I think that accessing the file system directly from C# should be avoided.
Why? For what reason is the namespace "System.IO"?
|
|
|
|
|
And what class from System.IO allows direct access to the hard disk/file system (and how)?
And as I mentioned before, I don't know if there is a way without PInvoke, this doesn't mean there
is no way!
Greetings
Covean
|
|
|
|
|
The original question was NOT about raw disc access, but raw FILE access, therefore the solution without api calls.
And of course, direct disc access is only possible through CreateFile or CreateFileTransacted - api calls.
And I fully agree, that this should only be done if you know exactly what you are doing. BUT if you do it, use the language you know best ...
|
|
|
|
|
Hi , have a good day ,
I have to do a project like :
A book pages as Images files , and audio file reading the book !
My Question is :
how I can replace the color of the Text in the image file , When the Audio file reading that sentence !
I don't need a code , but if you do I would be happy !
I need hints , links , TAG words to google it , Ideas ! , similar projects
P.S:
There is no WAY I can accept to make the book pages as normal TEXT , they MUST be images !
Thank you in advance
I know nothing , I know nothing ...
|
|
|
|