Please Help Me With File Into Memory
Hey,
I really need to work out how to do this, i need to basically load a .rar file into the memory so i can decompress it, currently i am loading the rar file from a resource into the memory then decompressing it, but i need to load it from a file rather than resource.
Heres how im loading it from resource:
Code:
void openRARResource(MemoryFile *memfile, int resource_id)
{
HRSRC hsResourceFH;
HGLOBAL hgResourceLH;
HINSTANCE hInstance = GetModuleHandleA(NULL);
memfile->data = 0;
memfile->size = 0;
memfile->offset = 0;
hsResourceFH = FindResource(hInstance, MAKEINTRESOURCE(resource_id), "RARFILE");
if(hsResourceFH)
{
hgResourceLH = LoadResource(hInstance, hsResourceFH);
if(hgResourceLH)
{
memfile->size = SizeofResource(hInstance, hsResourceFH);
memfile->data = (void*)LockResource(hgResourceLH);
}
}
}
This is how its called:
Code:
MemoryFile rarfile;
openRARResource(&rarfile, IDR_RAR);
This is how MemoryFile Is defined:
Code:
typedef struct memory_file
{
void *data; /* pointer to the file data */
unsigned long size; /* total size of the file data */
unsigned long offset; /* offset within "memory-file" */
} MemoryFile;
You can see there that i need the file data, file size, and memory offset...
I would like if possible to load the file into the MemoryFile varible, but as i said from a .rar on the hdd rather than from the programs resources.
I would majorly appreciate any help,
Thanks guys
TNT