--- np2/win9x/extromio.cpp 2003/10/16 17:58:43 1.1.1.1 +++ np2/win9x/extromio.cpp 2005/02/09 20:11:35 1.6 @@ -1,17 +1,17 @@ #include "compiler.h" +#include "np2.h" #include "dosio.h" #include "extromio.h" -extern HINSTANCE hInst; +static const OEMCHAR str_extrom[] = OEMTEXT("EXTROM"); -static const char str_extrom[] = "EXTROM"; - -EXTROMH extromio_open(const char *filename, UINT type) { +EXTROMH extromio_open(const OEMCHAR *filename, UINT type) { EXTROMH ret; HRSRC hrsrc; + HGLOBAL hg; ret = (EXTROMH)_MALLOC(sizeof(_EXTROMH), filename); if (ret == NULL) { @@ -27,7 +27,8 @@ EXTROMH extromio_open(const char *filena else if (type == EXTROMIO_RES) { hrsrc = FindResource(hInst, filename, str_extrom); if (hrsrc) { - ret->fh = (void *)LoadResource(hInst, hrsrc); + hg = LoadResource(hInst, hrsrc); + ret->fh = (void *)LockResource(hg); ret->pos = 0; ret->size = SizeofResource(hInst, hrsrc); return(ret); @@ -41,8 +42,6 @@ erope_err1: UINT extromio_read(EXTROMH erh, void *buf, UINT size) { -const char *p; - if (erh) { if (erh->type == EXTROMIO_FILE) { return(file_read((FILEH)erh->fh, buf, size)); @@ -50,10 +49,8 @@ const char *p; else if (erh->type == EXTROMIO_RES) { size = min(size, (UINT)(erh->size - erh->pos)); if (size) { - p = (char *)LockResource((HGLOBAL)erh->fh); - CopyMemory(buf, p + erh->pos, size); + CopyMemory(buf, ((UINT8 *)erh->fh) + erh->pos, size); erh->pos += size; - UnlockResource((HGLOBAL)erh->fh); } return(size); } @@ -96,9 +93,6 @@ void extromio_close(EXTROMH erh) { if (erh->type == EXTROMIO_FILE) { file_close((FILEH)erh->fh); } - else if (erh->type == EXTROMIO_RES) { - FreeResource((HGLOBAL)erh->fh); - } _MFREE(erh); } }