I finished implementing the CAB compression file, now I'm implementing the decompression but everytime I call the FDICopy or FDIIsCabinet my app crashed so I thought it might be because of the way I implemented the FDICreate callbacks, but still can't find any solution to it
Here's the extract function
FDICABINETINFO fdici;
int hf;
char *p;
// Set up some important globals
g_hfdi = NULL;
g_pFDIProgress = NULL;
g_hfdi = FDICreate(
fdi_mem_alloc,
fdi_mem_free,
fdi_file_open,
fdi_file_read,
fdi_file_write,
fdi_file_close,
fdi_file_seek,
cpu80386,
&g_fdi_erf
);
if (g_hfdi == NULL)
{
return FALSE;
}
hf = fdi_file_open(
cCABFullPath,
_O_BINARY | _O_RDONLY | _O_SEQUENTIAL,
0
);
if (hf == -1)
{
return FALSE;
}
if ( g_hfdi != NULL) {
if (FALSE == FDICopy(
g_hfdi,
"INSTALL.cab",
"C:\\xx\\xx\\",
0,
notification_function,
NULL,
NULL)) // NULL or DEST Folder?
{
PRINTF(
"FDICOPY() FAILED: CODE %D [%S]\N",
g_fdi_erf.ERFOPER
);
return FALSE;
}
}
if (FALSE == FDIIsCabinet(
g_hfdi,
hf,
&fdici))
{
/*
* No, it's not a cabinet!
*/
_close(hf);
PRINTF(
"FDICOPY() FAILED: CODE %D [%S]\N",
g_fdi_erf.ERFOPER
);
return FALSE;
}
And these are the related callbacks used by the FDICreate
FNALLOC(fdi_mem_alloc)
{
return malloc(cb);
}
/*
* Memory free function
*/
FNFREE(fdi_mem_free)
{
free(memory);
}
FNOPEN(fdi_file_open)
{
#if _MSC_VER >= 1500
int fh;
return _sopen_s(&fh, pszFile, oflag, _SH_DENYNO, pmode);
#else
return _open(pszFile, oflag, pmode);
#endif
}
FNREAD(fdi_file_read)
{
return _read(hf, pv, cb);
}
FNWRITE(fdi_file_write)
{
return _write(hf, pv, cb);
}
FNCLOSE(fdi_file_close)
{
return _close(hf);
}
FNSEEK(fdi_file_seek)
{
return _lseek(hf, dist, seektype);
}
I didn't put the notification_function callback as well since it's a really long one
By debugging it I can just see the g_hfdi
actually receives an address and hf = 0, but once it reaches the FDICopy
function it just crashes without letting me even check the error, and if i move the piece of code FDIIsCabinet
above the previous it just returns false without letting me check anything again..