• Welcome to Valhalla Legends Archive.
 

Reading Files

Started by l2k-Shadow, December 11, 2006, 11:53 PM

Previous topic - Next topic

l2k-Shadow

Ok, so I have a function using CreateFile() and ReadFile to read a binary file. Basically what i'm doing is storing length in the first byte of a chunk data that has to be read at once and then parsing it. A single chunk is usually 20-30 bytes long. The function is this:

__declspec(dllexport) int getclong(const char* filename, const char* temp, int mn, unsigned long* clong)

and the part of the chunk of code used to read the file:

while (ReadFile(file, ptr, len, &read, &ol))
{
if (mn == *((BYTE*)ptr+1))
{
if (strcmp(temp, (const char*)ptr+2) == 0)
{
b = strlen(temp)+3;
*clong = *((DWORD*)ptr+b);
}
}

The first if is fine, the second if is fine, however when i'm trying to retrieve the clong value, it returns something completely different, is this because the buffer isn't stored in line in memory, or is there something i'm doing wrong? how can i retrieve the correct value?
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

l2k-Shadow

hmm it appears that if i change the last parameter to a char* and return it like this, it works:

b = strlen(temp)+3;
sprintf(clong,(const char*)ptr+b);


=/ i'll still try to find out why it doesn't work with the other way though.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.