HELP WANTED!
- Posted by euman at bellsouth.net Apr 28, 2003
- 396 views
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C30D99.5528CB00 charset="iso-8859-1" Hello all, I have been waiting to implement Cab file wrappers (Cabinet.dll) I thought once Robert C. had made cdecl available to us that I could whip-up a working set but, I am totally confused about this very mysterious .dll Here is code I have tried (below), I have also tried fptr.e by Matt = Lewis and code published by mic and none have worked. Perhaps this should work before Robert C. post 2.4 final? I hope someone will guide me in the correct direction if it's even = possible. =20 *look for -- MACHINE LEVEL CRASH HERE!* <code by Euman 2003> with trace include dll.e include misc.e integer xHeapCreate, xHeapDestroy, xHeapAlloc, xHeapFree,=20 xCreateFile, xReadFile, xWriteFile, xSetFilePointer, = xCloseHandle, xFDICreate, xFDIIsCabinet, xFDICopy, xFDIDestroy =20 procedure not_found(sequence name) puts(1, "Couldn't find " & name & '\n') abort(1) end procedure function link_c_func(atom dll, sequence name, sequence args, atom = result) integer handle handle =3D define_c_func(dll, name, args, result) if handle =3D -1 then not_found(name) else return handle end if end function function link_c_proc(atom dll, sequence name, sequence args) integer handle handle =3D define_c_proc(dll, name, args) if handle =3D -1 then not_found(name) else return handle end if end function procedure link_dll_routines() atom kernel32, cabinet =20 kernel32 =3D open_dll("kernel32.dll") if kernel32 =3D NULL then not_found("kernel32.dll") end if =20 cabinet =3D open_dll("cabinet.dll") if cabinet =3D NULL then not_found("cabinet.dll") end if =20 xHeapCreate =3D = link_c_func(kernel32,"HeapCreate",{C_LONG,C_LONG,C_LONG},C_LONG) xHeapDestroy =3D link_c_func(kernel32,"HeapDestroy",{C_LONG},C_LONG) xHeapAlloc =3D = link_c_func(kernel32,"HeapAlloc",{C_LONG,C_LONG,C_LONG},C_LONG) xHeapFree =3D = link_c_func(kernel32,"HeapFree",{C_LONG,C_LONG,C_LONG},C_LONG) xCreateFile =3D = link_c_func(kernel32,"CreateFileA",{C_POINTER,C_LONG,C_LONG,C_POINTER,C_L= ONG,C_LONG,C_INT},C_LONG) xReadFile =3D = link_c_func(kernel32,"ReadFile",{C_INT,C_POINTER,C_UINT,C_POINTER,C_POINT= ER},C_LONG) xWriteFile =3D = link_c_func(kernel32,"WriteFile",{C_INT,C_POINTER,C_LONG,C_POINTER,C_POIN= TER},C_LONG) xSetFilePointer =3D = link_c_func(kernel32,"SetFilePointer",{C_LONG,C_LONG,C_POINTER,C_LONG},C_= LONG) xCloseHandle =3D link_c_func(kernel32,"CloseHandle",{C_LONG},C_LONG) xFDICreate =3D = link_c_func(cabinet,"FDICreate",{C_POINTER,C_POINTER,C_POINTER,C_POINTER,= C_POINTER,C_POINTER,C_POINTER,C_INT,C_LONG},C_LONG) xFDIIsCabinet =3D = link_c_func(cabinet,"FDIIsCabinet",{C_LONG,C_INT,C_POINTER},C_LONG) xFDICopy =3D = link_c_func(cabinet,"FDICopy",{C_LONG,C_POINTER,C_POINTER,C_INT,C_POINTER= ,C_POINTER,C_INT},C_LONG) xFDIDestroy =3D link_c_proc(cabinet,"FDIDestroy",{C_LONG}) end procedure link_dll_routines() trace(1) integer id object junk constant HEAP_ZERO_MEMORY=3D#00000008 =20 global atom pHeap pHeap =3D c_func(xHeapCreate,{0,16384,0}) global function myalloc(atom size) return c_func(xHeapAlloc,{pHeap,HEAP_ZERO_MEMORY,size}) end function atom PFNALLOC id =3D routine_id("myalloc")=20 PFNALLOC =3D call_back(id) global function myfree(atom pmem) return c_func(xHeapFree,{pHeap,0,pmem}) end function atom PFNFREE id =3D routine_id("myfree")=20 PFNFREE =3D call_back(id) global procedure mypoke(atom mem, object s) poke(mem, s) end procedure global procedure mypoke4(atom mem, object s) poke4(mem, s)=20 end procedure global function mypeek(object si) if integer(si) then return peek(si) =20 else return peek({si[1],si[2]})=20 end if end function global function mypeek4s(object si) if integer(si) then return peek4s(si)=20 else return peek4s({si[1],si[2]})=20 end if end function global function mypeek4u(object si) if integer(si) then return peek4u(si)=20 else return peek4u({si[1],si[2]})=20 end if end function global function allocate_string2(sequence s) atom mem mem =3D myalloc(length(s)+1) mypoke(mem, s) return mem end function global constant GENERIC_READ =3D #80000000, GENERIC_WRITE =3D #40000000, FILE_ATTRIBUTE_NORMAL =3D #80, FILE_BEGIN =3D 0, FILE_CURRENT =3D 1, FILE_END =3D 2, FILE_FLAG_WRITE_THROUGH =3D #80000000, FILE_FLAG_OVERLAPPED =3D #40000000, FILE_FLAG_NO_BUFFERING =3D #20000000, FILE_FLAG_RANDOM_ACCESS =3D #10000000, FILE_FLAG_SEQUENTIAL_SCAN =3D #8000000, FILE_FLAG_DELETE_ON_CLOSE =3D #4000000, FILE_FLAG_BACKUP_SEMANTICS =3D #2000000, FILE_FLAG_POSIX_SEMANTICS =3D #1000000, CREATE_NEW =3D 1, CREATE_ALWAYS =3D 2, OPEN_EXISTING =3D 3, OPEN_ALWAYS =3D 4, TRUNCATE_EXISTING =3D 5, INVALID_HANDLE_VALUE =3D -1 =20 =20 global function CreateFile(sequence fname, sequence accmode) atom File, FileName=20 FileName =3D allocate_string2(fname) if compare(accmode,"rb")=3D0 then File =3D = c_func(xCreateFile,{FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRI= BUTE_NORMAL+ FILE_FLAG_SEQUENTIAL_SCAN,NULL}) elsif compare(accmode,"wb")=3D0 then File =3D = c_func(xCreateFile,{FileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTR= IBUTE_NORMAL+ FILE_FLAG_SEQUENTIAL_SCAN,NULL}) end if junk =3D myfree(FileName) return File end function atom PFNOPEN id =3D routine_id("CreateFile")=20 PFNOPEN =3D call_back(id) --WriteFile() --hFile (handle) obtained by CreateFile=20 --must have GENERIC_WRITE access atom writebytes writebytes =3D myalloc(4) function WriteFile(atom hFile, atom lpBuffer, atom = nNumberOfBytesToWrite) return = c_func(xWriteFile,{hFile,lpBuffer,nNumberOfBytesToWrite,writebytes,0}) end function =20 atom PFNWRITE id =3D routine_id("CreateFile")=20 PFNWRITE =3D call_back(id) --ReadFile() --hFile (handle) obtained by CreateFile=20 --must have GENERIC_READ access atom readbytes readbytes =3D myalloc(4) --lpNumberOfBytesRead=20 function ReadFile(atom hFile, atom lpBuffer, atom nNumberOfBytesToRead) return = c_func(xReadFile,{hFile,lpBuffer,nNumberOfBytesToRead,readbytes,0}) end function atom PFNREAD id =3D routine_id("ReadFile")=20 PFNREAD =3D call_back(id) constant SEEK_SET =3D 0, --/* seek to an absolute position = */ SEEK_CUR =3D 1, --/* seek relative to current = position */ SEEK_END =3D 2 =20 =20 function SetFilePos(atom hf, atom dist, atom seektype) integer dMethod=20 if seektype =3D SEEK_SET then dMethod =3D FILE_BEGIN elsif seektype =3D SEEK_CUR then dMethod =3D FILE_CURRENT elsif seektype =3D SEEK_END then dMethod =3D FILE_END end if =20 return c_func(xSetFilePointer,{hf,dist,NULL,dMethod}) end function atom PFNSEEK id =3D routine_id("SetFilePos")=20 PFNSEEK =3D call_back(id) atom PFNCLOSE PFNCLOSE=3D0 function CloseFile(atom handle) if handle =3D PFNCLOSE+96 then return 0 elsif handle !=3D 0 then return c_func(xCloseHandle,{handle}) end if end function id =3D routine_id("CloseFile")=20 PFNCLOSE =3D call_back(id) constant cpuUNKNOWN =3D -1, cpu80286 =3D 0,=20 cpu80386 =3D 1 --typedef struct { constant erfOper =3D 0, erfType =3D 4, fError =3D 8 atom ERF ERF =3D myalloc(12) mypoke4(ERF + erfOper, 222) mypoke4(ERF + erfType, 222)=20 mypoke4(ERF + fError, 222) =20 atom hfdi hfdi =3D c_func(xFDICreate,{PFNALLOC, -- MACHINE LEVEL CRASH HERE! PFNFREE, PFNOPEN, PFNREAD, PFNWRITE, PFNCLOSE, PFNSEEK, cpuUNKNOWN, ERF}) junk =3D peek4u(ERF + erfOper) -- NO ERRORS if all are -> 222 junk =3D peek4u(ERF + erfType)=20 junk =3D peek4u(ERF + fError) -- FDICABINETINFO - Information about a cabinet constant cbCabinet =3D 0, --// Total length of cabinet file cFolders =3D 4, --// Count of folders in cabinet cFiles =3D 6, --// Count of files in cabinet setID =3D 8, --// Cabinet set ID iCabinet =3D 10, --// Cabinet number in set (0 based) fReserve =3D 12, --// TRUE =3D> RESERVE present in = cabinet hasprev =3D 16, --// TRUE =3D> Cabinet is chained = prev hasnext =3D 20 --// TRUE =3D> Cabinet is chained = next atom pfdici pfdici =3D myalloc(24) atom hf hf =3D CreateFile("sdkinst.cab","rb") --open " " cab file if hf <=3D 0 then c_proc(xFDIDestroy,{hfdi}) junk =3D CloseFile(hf) abort(0) end if junk =3D c_func(xFDIIsCabinet,{hfdi, hf, pfdici}) if junk =3D 0 then c_proc(xFDIDestroy,{hfdi}) junk =3D CloseFile(hf) end if =20 junk =3D myfree(ERF) ------=_NextPart_000_0009_01C30D99.5528CB00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hello all,</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I have been waiting to implement Cab = file wrappers=20 (Cabinet.dll)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I thought once Robert C. had made cdecl = available=20 to us</FONT></DIV> <DIV><FONT face=3DArial size=3D2>that I could whip-up a working set but, = I am=20 totally confused about</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this very mysterious .dll</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Here is code I have tried (below), I = have also=20 tried fptr.e by Matt Lewis</FONT></DIV> <DIV><FONT face=3DArial size=3D2>and code published by mic and none = have=20 worked. Perhaps this should</FONT></DIV> <DIV><FONT face=3DArial size=3D2>work before Robert C. post 2.4 = final?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I hope someone will guide me in the = correct=20 direction if it's even possible.</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> </FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2> *look = for --=20 MACHINE LEVEL CRASH HERE!*<BR></DIV></FONT> <DIV><FONT face=3DArial size=3D2><code by Euman 2003></FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>with trace</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>include dll.e<BR>include = misc.e</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>integer xHeapCreate, xHeapDestroy, = xHeapAlloc,=20 xHeapFree, <BR> xCreateFile,=20 xReadFile, xWriteFile, xSetFilePointer,=20 xCloseHandle,<BR> xFDICreate,=20 xFDIIsCabinet, xFDICopy,=20 xFDIDestroy<BR> <BR>procedure=20 not_found(sequence name)<BR> puts(1, "Couldn't find " = &=20 name & '\n')<BR> abort(1)<BR>end = procedure</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>function link_c_func(atom dll, sequence = name,=20 sequence args, atom result)<BR> integer handle</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> handle =3D = define_c_func(dll, name,=20 args, result)<BR> if handle =3D -1=20 then<BR> not_found(name)<BR> =20 else<BR> return handle<BR> end = if<BR>end function</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>function link_c_proc(atom dll, sequence = name,=20 sequence args)<BR> integer handle<BR> handle =3D=20 define_c_proc(dll, name, args)<BR> if handle =3D -1=20 then<BR> not_found(name)<BR> =20 else<BR> return handle<BR> end = if<BR>end function</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>procedure link_dll_routines()<BR> = atom=20 kernel32, cabinet<BR> <BR> kernel32 = =3D=20 open_dll("kernel32.dll")<BR> if kernel32 =3D NULL=20 then<BR> not_found("kernel32.dll")<BR> end=20 if <BR> cabinet =3D=20 open_dll("cabinet.dll")<BR> if cabinet =3D NULL=20 then<BR> not_found("cabinet.dll")<BR> end=20 if </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> xHeapCreate =3D=20 link_c_func(kernel32,"HeapCreate",{C_LONG,C_LONG,C_LONG},C_LONG)<BR> = ; =20 xHeapDestroy =3D=20 link_c_func(kernel32,"HeapDestroy",{C_LONG},C_LONG)<BR> = =20 xHeapAlloc =3D=20 link_c_func(kernel32,"HeapAlloc",{C_LONG,C_LONG,C_LONG},C_LONG)<BR> = =20 xHeapFree =3D=20 link_c_func(kernel32,"HeapFree",{C_LONG,C_LONG,C_LONG},C_LONG)</FONT></DI= V> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> xCreateFile =3D=20 link_c_func(kernel32,"CreateFileA",{C_POINTER,C_LONG,C_LONG,C_POINTER,C_L= ONG,C_LONG,C_INT},C_LONG)<BR> =20 xReadFile =3D=20 link_c_func(kernel32,"ReadFile",{C_INT,C_POINTER,C_UINT,C_POINTER,C_POINT= ER},C_LONG)<BR> =20 xWriteFile =3D=20 link_c_func(kernel32,"WriteFile",{C_INT,C_POINTER,C_LONG,C_POINTER,C_POIN= TER},C_LONG)<BR> =20 xSetFilePointer =3D=20 link_c_func(kernel32,"SetFilePointer",{C_LONG,C_LONG,C_POINTER,C_LONG},C_= LONG)<BR> =20 xCloseHandle =3D = link_c_func(kernel32,"CloseHandle",{C_LONG},C_LONG)</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> xFDICreate =3D=20 link_c_func(cabinet,"FDICreate",{C_POINTER,C_POINTER,C_POINTER,C_POINTER,= C_POINTER,C_POINTER,C_POINTER,C_INT,C_LONG},C_LONG)<BR> = =20 xFDIIsCabinet =3D=20 link_c_func(cabinet,"FDIIsCabinet",{C_LONG,C_INT,C_POINTER},C_LONG)<BR>&n= bsp; =20 xFDICopy =3D=20 link_c_func(cabinet,"FDICopy",{C_LONG,C_POINTER,C_POINTER,C_INT,C_POINTER= ,C_POINTER,C_INT},C_LONG)<BR> =20 xFDIDestroy =3D link_c_proc(cabinet,"FDIDestroy",{C_LONG})</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>end procedure</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2>link_dll_routines()<BR>trace(1)<BR>integer=20 id<BR>object junk</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>constant = HEAP_ZERO_MEMORY=3D#00000008<BR> =20 <BR>global atom pHeap<BR>pHeap =3D = c_func(xHeapCreate,{0,16384,0})</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV><FONT face=3DArial = size=3D2> <DIV><BR>global function myalloc(atom size)<BR> return=20 c_func(xHeapAlloc,{pHeap,HEAP_ZERO_MEMORY,size})<BR>end function<BR>atom = PFNALLOC</DIV> <DIV> </DIV> <DIV>id =3D routine_id("myalloc") <BR>PFNALLOC =3D call_back(id)</DIV> <DIV> </DIV> <DIV>global function myfree(atom pmem)<BR> return=20 c_func(xHeapFree,{pHeap,0,pmem})<BR>end function<BR>atom PFNFREE</DIV> <DIV> </DIV> <DIV>id =3D routine_id("myfree") <BR>PFNFREE =3D call_back(id)</DIV> <DIV> </DIV> <DIV>global procedure mypoke(atom mem, object s)<BR> = poke(mem,=20 s)<BR>end procedure</DIV> <DIV> </DIV> <DIV>global procedure mypoke4(atom mem, object s)<BR> = poke4(mem, s)=20 <BR>end procedure</DIV> <DIV> </DIV> <DIV>global function mypeek(object si)<BR> if integer(si)=20 then<BR> return=20 peek(si) <BR> =20 else<BR> return peek({si[1],si[2]})=20 <BR> end if<BR>end function</DIV> <DIV> </DIV> <DIV>global function mypeek4s(object si)<BR> if integer(si)=20 then<BR> return peek4s(si) = <BR> =20 else<BR> return peek4s({si[1],si[2]})=20 <BR> end if<BR>end function</DIV> <DIV> </DIV> <DIV>global function mypeek4u(object si)<BR> if integer(si)=20 then<BR> return peek4u(si) = <BR> =20 else<BR> return peek4u({si[1],si[2]})=20 <BR> end if<BR>end function</DIV> <DIV> </DIV> <DIV>global function allocate_string2(sequence s)<BR>atom=20 mem<BR> mem =3D = myalloc(length(s)+1)<BR> =20 mypoke(mem, s)<BR> return mem<BR>end function</DIV> <DIV> </DIV> <DIV>global constant GENERIC_READ =3D=20 #80000000,<BR> GENERIC_WRITE =3D=20 #40000000,<BR> FILE_ATTRIBUTE_NORMAL =3D = #80,<BR> FILE_BEGIN=20 =3D=20 0,<BR> FILE_CURRENT &= nbsp; =20 =3D=20 1,<BR> FILE_END  = ; =20 =3D 2,<BR> FILE_FLAG_WRITE_THROUGH =3D=20 #80000000,<BR> FILE_FLAG_OVERLAPPED &nb= sp; =20 =3D = #40000000,<BR> FILE_FLAG_NO_BUFFERING = =3D=20 #20000000,<BR> FILE_FLAG_RANDOM_ACCESS =3D=20 #10000000,<BR> FILE_FLAG_SEQUENTIAL_SCAN =3D=20 #8000000,<BR> FILE_FLAG_DELETE_ON_CLOSE =3D=20 #4000000,<BR> FILE_FLAG_BACKUP_SEMANTICS =3D=20 #2000000,<BR> FILE_FLAG_POSIX_SEMANTICS =3D=20 #1000000,<BR> CREATE_NEW &n= bsp; =3D=20 1,<BR> CREATE_ALWAYS =3D=20 2,<BR> OPEN_EXISTING =3D=20 3,<BR> OPEN_ALWAYS =3D=20 4,<BR> TRUNCATE_EXISTING =3D = 5,<BR> INVALID_HANDLE_VALUE =3D=20 -1<BR> <BR> <BR>global function = CreateFile(sequence fname,=20 sequence accmode)<BR>atom File, FileName <BR> FileName =3D=20 allocate_string2(fname)<BR> if compare(accmode,"rb")=3D0=20 then<BR> File =3D=20 c_func(xCreateFile,{FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRI= BUTE_NORMAL+<BR> &nb= sp; &nbs= p; =20 FILE_FLAG_SEQUENTIAL_SCAN,NULL})<BR> elsif = compare(accmode,"wb")=3D0=20 then<BR> File =3D=20 c_func(xCreateFile,{FileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTR= IBUTE_NORMAL+<BR> &n= bsp; &nb= sp; =20 FILE_FLAG_SEQUENTIAL_SCAN,NULL})<BR> end if<BR> junk =3D=20 myfree(FileName)<BR> return File<BR>end function<BR>atom = PFNOPEN</DIV> <DIV> </DIV> <DIV>id =3D routine_id("CreateFile") <BR>PFNOPEN =3D call_back(id)</DIV> <DIV> </DIV> <DIV> --WriteFile()<BR> --hFile (handle) obtained by = CreateFile=20 <BR> --must have GENERIC_WRITE access</DIV> <DIV> </DIV> <DIV>atom writebytes<BR>writebytes =3D myalloc(4)</DIV> <DIV> </DIV> <DIV><BR>function WriteFile(atom hFile, atom lpBuffer, atom=20 nNumberOfBytesToWrite)<BR> return=20 c_func(xWriteFile,{hFile,lpBuffer,nNumberOfBytesToWrite,writebytes,0})<BR= >end=20 function  = ;=20 <BR>atom PFNWRITE</DIV> <DIV> </DIV> <DIV>id =3D routine_id("CreateFile") <BR>PFNWRITE =3D = call_back(id)</DIV> <DIV> </DIV> <DIV> --ReadFile()<BR> --hFile (handle) obtained by CreateFile = <BR> --must have GENERIC_READ access</DIV> <DIV> </DIV> <DIV>atom readbytes<BR>readbytes =3D myalloc(4) --lpNumberOfBytesRead = </DIV> <DIV> </DIV> <DIV><BR>function ReadFile(atom hFile, atom lpBuffer, atom=20 nNumberOfBytesToRead)<BR> return=20 c_func(xReadFile,{hFile,lpBuffer,nNumberOfBytesToRead,readbytes,0})<BR>en= d=20 function<BR>atom PFNREAD</DIV> <DIV> </DIV> <DIV>id =3D routine_id("ReadFile") <BR>PFNREAD =3D call_back(id)</DIV> <DIV> </DIV> <DIV><BR>constant SEEK_SET =3D=20 0,  = ; =20 --/* seek to an absolute position=20 */<BR> SEEK_CUR =3D=20 1,  = ; =20 --/* seek relative to current position=20 */<BR> SEEK_END =3D = 2 =20 <BR> </DIV> <DIV> </DIV> <DIV>function SetFilePos(atom hf, atom dist, atom seektype)<BR> = integer=20 dMethod </DIV> <DIV> </DIV> <DIV> if seektype =3D SEEK_SET = then=20 dMethod =3D FILE_BEGIN<BR> = elsif=20 seektype =3D SEEK_CUR then dMethod =3D=20 FILE_CURRENT<BR> elsif = seektype =3D=20 SEEK_END then dMethod =3D = FILE_END<BR> =20 end if<BR> = <BR> =20 return c_func(xSetFilePointer,{hf,dist,NULL,dMethod})<BR>end = function<BR>atom=20 PFNSEEK</DIV> <DIV> </DIV> <DIV>id =3D routine_id("SetFilePos") <BR>PFNSEEK =3D call_back(id)</DIV> <DIV> </DIV> <DIV>atom PFNCLOSE PFNCLOSE=3D0<BR>function CloseFile(atom handle)</DIV> <DIV> </DIV> <DIV> if handle =3D PFNCLOSE+96 = then<BR> =20 return 0<BR> elsif handle !=3D 0=20 then<BR> return=20 c_func(xCloseHandle,{handle})<BR> end if</DIV> <DIV> </DIV> <DIV>end function</DIV> <DIV> </DIV> <DIV>id =3D routine_id("CloseFile") <BR>PFNCLOSE =3D call_back(id)</DIV> <DIV> </DIV> <DIV>constant cpuUNKNOWN =3D=20 -1,<BR> cpu80286 =3D 0,=20 <BR> cpu80386 =3D = 1</DIV> <DIV> </DIV> <DIV><BR>--typedef struct {<BR>constant erfOper =3D=20 0,<BR> erfType =3D=20 4,<BR> fError =3D = 8</DIV> <DIV> </DIV> <DIV><BR>atom ERF<BR>ERF =3D myalloc(12)</DIV> <DIV> </DIV> <DIV>mypoke4(ERF + erfOper, 222)<BR>mypoke4(ERF + erfType, 222) = <BR>mypoke4(ERF=20 + fError, 222)</DIV> <DIV> </DIV> <DIV> <BR>atom hfdi</DIV> <DIV> </DIV> <DIV>hfdi =3D c_func(xFDICreate,{PFNALLOC, -- MACHINE LEVEL CRASH=20 HERE!<BR> &nbs= p;  = ; =20 PFNFREE,<BR> &= nbsp; &n= bsp; =20 PFNOPEN,<BR> &= nbsp; &n= bsp; =20 PFNREAD,<BR> &= nbsp; &n= bsp; =20 PFNWRITE,<BR> = &= nbsp; =20 PFNCLOSE,<BR> = &= nbsp; =20 PFNSEEK,<BR> &= nbsp; &n= bsp; =20 cpuUNKNOWN,<BR> &nbs= p;  = ; =20 ERF})</DIV> <DIV> </DIV> <DIV>junk =3D peek4u(ERF + erfOper) -- NO ERRORS if all are -> = 222<BR>junk =3D=20 peek4u(ERF + erfType) <BR>junk =3D peek4u(ERF + fError)</DIV> <DIV> </DIV> <DIV>-- FDICABINETINFO - Information about a=20 cabinet<BR>constant<BR> cbCabinet =3D=20 0,  = ; =20 --// Total length of cabinet file<BR> = cFolders =3D=20 4,  = ; =20 --// Count of folders in cabinet<BR> = cFiles =3D=20 6,  = ; =20 --// Count of files in cabinet<BR> setID = =3D=20 8,  = ; =20 --// Cabinet set ID<BR> iCabinet =3D=20 10, &nbs= p; =20 --// Cabinet number in set (0 based)<BR> = fReserve=20 =3D=20 12, &nbs= p; =20 --// TRUE =3D> RESERVE present in = cabinet<BR> =20 hasprev =3D=20 16, &nbs= p; =20 --// TRUE =3D> Cabinet is chained = prev<BR> =20 hasnext =3D=20 20  = ; =20 --// TRUE =3D> Cabinet is chained next</DIV> <DIV> </DIV> <DIV>atom pfdici<BR>pfdici =3D myalloc(24)</DIV> <DIV> </DIV> <DIV>atom hf<BR>hf =3D CreateFile("sdkinst.cab","rb") --open " = " cab=20 file</DIV> <DIV> </DIV> <DIV>if hf <=3D 0 then<BR> =20 c_proc(xFDIDestroy,{hfdi})<BR> junk =3D = CloseFile(hf)<BR> =20 abort(0)<BR>end if</DIV> <DIV> </DIV> <DIV>junk =3D c_func(xFDIIsCabinet,{hfdi, hf, pfdici})</DIV> <DIV> </DIV> <DIV>if junk =3D 0 then<BR> = c_proc(xFDIDestroy,{hfdi})<BR> =20 junk =3D CloseFile(hf)<BR>end if<BR> <BR>junk =3D=20 ------=_NextPart_000_0009_01C30D99.5528CB00--