+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  GraphiX3
Pages: 1 [2]
Author Topic: GraphiX3  (Read 2 times)
Aerdan
Guest
« Reply #15 on: July 22, 2008, 03:21:13 am »

You, uh, feed it the file's contents and size of said and get back a CRC32. [Or at least, you do with the first one.]
elixirnova
Guest
« Reply #16 on: July 22, 2008, 03:26:31 am »

How on earth do I feed it contents as a "const void* data"?? The other makes sense sort of...

Here is something I have tried. Not too sure what I'm doing so I tried lots of dumb ideas haha this is one of em!
Code:
System::UInt32 crc32val = 0;
FileStream *fs = __gc new FileStream(openFileDialog1->FileName, FileMode::Open);
//System::Byte b[] = __gc new System::Byte[fs->Length];
//BinaryReader *br = __gc new BinaryReader(fs);

const void *fsPtr;
fsPtr = &fs;
const int fsLen = fs->Length;

crc32val = CheckSumCRC32::block_checksum(fsPtr,*fsLen);

fs->Close();
« Last Edit: July 22, 2008, 03:47:53 am by elixirnova »
Aerdan
Guest
« Reply #17 on: July 22, 2008, 05:39:59 am »

Remember that 'void' in most cases is used for non-specific typing. This means you can store the data to be checksummed however you like, so long as it's consistent. You're supposed to feed the contents of the file into the function, which means either mmap()ing it or loading it into RAM.
elixirnova
Guest
« Reply #18 on: July 22, 2008, 03:32:17 pm »

So what namespace or class or w/e it is callled should I use to feed the file to the crc32 class? Obviously filestream doesn't work, which is a stream so probably not what I need?

Browsing through the MSDN I found System::IO::MemoryStream. Would that be useful for "feeding(don't understand how this word is being used)" the contents of the file to the functin? It says it loads the data into RAM...

When I think of feeding i think of giving data to the function one piece at a time, maybe one byte at a time... but that doesn't make sense...

Sorry I am still very new to programming and kinda learning as I go along
Aerdan
Guest
« Reply #19 on: July 22, 2008, 08:31:31 pm »

Look around in the documentation for ways of pulling in a file's entire contents at once. I really can't help you more than this because I don't do .NET at all.
DarthNemesis
Guest
« Reply #20 on: July 22, 2008, 08:52:35 pm »

Try reading the entire contents of the file into a byte[] and passing a pointer to that.
creaothceann
Guest
« Reply #21 on: July 23, 2008, 12:08:28 pm »

Quote from: elixirnova on July 22, 2008, 03:32:17 pm
Browsing through the MSDN I found System::IO::MemoryStream. Would that be useful for "feeding(don't understand how this word is being used)" the contents of the file to the functin? It says it loads the data into RAM...

The function expects a pointer to the first byte of the data. Maybe MemoryStream has something that returns this pointer. If not then create a dynamically-sized array, load the data into it (e.g. via file streams) and pass the address of the first element to the function.
elixirnova
Guest
« Reply #22 on: July 23, 2008, 02:17:31 pm »

I'll try the idea creaothceann. Maybe it'll work I didn't get much time last night, but I was getting some other sort of error I think. I dunno I'll have to check it out.
Pages: 1 [2]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC