1. HELP WANTED!

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>&nbsp;</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>&nbsp;</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&nbsp;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>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *look =
for --=20
MACHINE LEVEL CRASH HERE!*<BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>&lt;code by Euman 2003&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>with trace</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include dll.e<BR>include =
misc.e</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>integer xHeapCreate, xHeapDestroy, =
xHeapAlloc,=20
xHeapFree, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xCreateFile,=20
xReadFile, xWriteFile, xSetFilePointer,=20
xCloseHandle,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xFDICreate,=20
xFDIIsCabinet, xFDICopy,=20
xFDIDestroy<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>procedure=20
not_found(sequence name)<BR>&nbsp;&nbsp;&nbsp; puts(1, "Couldn't find " =
&amp;=20
name &amp; '\n')<BR>&nbsp;&nbsp;&nbsp; abort(1)<BR>end =
procedure</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>function link_c_func(atom dll, sequence =
name,=20
sequence args, atom result)<BR>&nbsp;integer handle</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; handle =3D =
define_c_func(dll, name,=20
args, result)<BR>&nbsp;&nbsp; if handle =3D -1=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not_found(name)<BR>&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return handle<BR>&nbsp;&nbsp; end =

if<BR>end function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>function link_c_proc(atom dll, sequence =
name,=20
sequence args)<BR>&nbsp;integer handle<BR>&nbsp;&nbsp; handle =3D=20
define_c_proc(dll, name, args)<BR>&nbsp;&nbsp; if handle =3D -1=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not_found(name)<BR>&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return handle<BR>&nbsp;&nbsp; end =

if<BR>end function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>procedure link_dll_routines()<BR>&nbsp; =
atom=20
kernel32, cabinet<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; kernel32 =
=3D=20
open_dll("kernel32.dll")<BR>&nbsp;&nbsp;&nbsp; if kernel32 =3D NULL=20
then<BR>&nbsp;not_found("kernel32.dll")<BR>&nbsp;&nbsp;&nbsp; end=20
if&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; cabinet =3D=20
open_dll("cabinet.dll")<BR>&nbsp;&nbsp;&nbsp; if cabinet =3D NULL=20
then<BR>&nbsp;not_found("cabinet.dll")<BR>&nbsp;&nbsp;&nbsp; end=20
if&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; xHeapCreate =3D=20
link_c_func(kernel32,"HeapCreate",{C_LONG,C_LONG,C_LONG},C_LONG)<BR>&nbsp=
;&nbsp;&nbsp;=20
xHeapDestroy =3D=20
link_c_func(kernel32,"HeapDestroy",{C_LONG},C_LONG)<BR>&nbsp;&nbsp;&nbsp;=
=20
xHeapAlloc =3D=20
link_c_func(kernel32,"HeapAlloc",{C_LONG,C_LONG,C_LONG},C_LONG)<BR>&nbsp;=
&nbsp;&nbsp;=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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;=20
xReadFile =3D=20
link_c_func(kernel32,"ReadFile",{C_INT,C_POINTER,C_UINT,C_POINTER,C_POINT=
ER},C_LONG)<BR>&nbsp;&nbsp;&nbsp;=20
xWriteFile =3D=20
link_c_func(kernel32,"WriteFile",{C_INT,C_POINTER,C_LONG,C_POINTER,C_POIN=
TER},C_LONG)<BR>&nbsp;&nbsp;&nbsp;=20
xSetFilePointer =3D=20
link_c_func(kernel32,"SetFilePointer",{C_LONG,C_LONG,C_POINTER,C_LONG},C_=
LONG)<BR>&nbsp;&nbsp;&nbsp;=20
xCloseHandle =3D =
link_c_func(kernel32,"CloseHandle",{C_LONG},C_LONG)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;=
=20
xFDIIsCabinet =3D=20
link_c_func(cabinet,"FDIIsCabinet",{C_LONG,C_INT,C_POINTER},C_LONG)<BR>&n=
bsp;&nbsp;&nbsp;=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>&nbsp;&nbsp;&nbsp;=20
xFDIDestroy =3D link_c_proc(cabinet,"FDIDestroy",{C_LONG})</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>end procedure</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>constant =
HEAP_ZERO_MEMORY=3D#00000008<BR>&nbsp;=20
<BR>global atom pHeap<BR>pHeap =3D =
c_func(xHeapCreate,{0,16384,0})</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><FONT face=3DArial =
size=3D2>
<DIV><BR>global function myalloc(atom size)<BR>&nbsp;&nbsp; return=20
c_func(xHeapAlloc,{pHeap,HEAP_ZERO_MEMORY,size})<BR>end function<BR>atom =

PFNALLOC</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("myalloc") <BR>PFNALLOC =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>global function myfree(atom pmem)<BR>&nbsp;&nbsp; return=20
c_func(xHeapFree,{pHeap,0,pmem})<BR>end function<BR>atom PFNFREE</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("myfree") <BR>PFNFREE =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>global procedure mypoke(atom mem, object s)<BR>&nbsp;&nbsp; =
poke(mem,=20
s)<BR>end procedure</DIV>
<DIV>&nbsp;</DIV>
<DIV>global procedure mypoke4(atom mem, object s)<BR>&nbsp;&nbsp; =
poke4(mem, s)=20
<BR>end procedure</DIV>
<DIV>&nbsp;</DIV>
<DIV>global function mypeek(object si)<BR>&nbsp;&nbsp; if integer(si)=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return=20
peek(si)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return peek({si[1],si[2]})=20
<BR>&nbsp;&nbsp; end if<BR>end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>global function mypeek4s(object si)<BR>&nbsp;&nbsp; if integer(si)=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return peek4s(si) =
<BR>&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return peek4s({si[1],si[2]})=20
<BR>&nbsp;&nbsp; end if<BR>end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>global function mypeek4u(object si)<BR>&nbsp;&nbsp; if integer(si)=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return peek4u(si) =
<BR>&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return peek4u({si[1],si[2]})=20
<BR>&nbsp;&nbsp; end if<BR>end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>global function allocate_string2(sequence s)<BR>atom=20
mem<BR>&nbsp;&nbsp;&nbsp; mem =3D =
myalloc(length(s)+1)<BR>&nbsp;&nbsp;&nbsp;=20
mypoke(mem, s)<BR>&nbsp;&nbsp;&nbsp; return mem<BR>end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>global constant GENERIC_READ&nbsp; =3D=20
#80000000,<BR>&nbsp;&nbsp;GENERIC_WRITE =3D=20
#40000000,<BR>&nbsp;&nbsp;FILE_ATTRIBUTE_NORMAL =3D =
#80,<BR>&nbsp;&nbsp;FILE_BEGIN=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
0,<BR>&nbsp;&nbsp;FILE_CURRENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D=20
1,<BR>&nbsp;&nbsp;FILE_END&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D 2,<BR>&nbsp;&nbsp;FILE_FLAG_WRITE_THROUGH&nbsp;&nbsp;&nbsp; =3D=20
#80000000,<BR>&nbsp;&nbsp;FILE_FLAG_OVERLAPPED&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
=3D =
#40000000,<BR>&nbsp;&nbsp;FILE_FLAG_NO_BUFFERING&nbsp;&nbsp;&nbsp;&nbsp; =
=3D=20
#20000000,<BR>&nbsp;&nbsp;FILE_FLAG_RANDOM_ACCESS&nbsp;&nbsp;&nbsp; =3D=20
#10000000,<BR>&nbsp;&nbsp;FILE_FLAG_SEQUENTIAL_SCAN&nbsp; =3D=20
#8000000,<BR>&nbsp;&nbsp;FILE_FLAG_DELETE_ON_CLOSE&nbsp; =3D=20
#4000000,<BR>&nbsp;&nbsp;FILE_FLAG_BACKUP_SEMANTICS =3D=20
#2000000,<BR>&nbsp;&nbsp;FILE_FLAG_POSIX_SEMANTICS&nbsp; =3D=20
#1000000,<BR>&nbsp;&nbsp;CREATE_NEW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; =3D=20
1,<BR>&nbsp;&nbsp;CREATE_ALWAYS&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
2,<BR>&nbsp;&nbsp;OPEN_EXISTING&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
3,<BR>&nbsp;&nbsp;OPEN_ALWAYS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
4,<BR>&nbsp;&nbsp;TRUNCATE_EXISTING =3D =
5,<BR>&nbsp;&nbsp;INVALID_HANDLE_VALUE =3D=20
-1<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>global function =
CreateFile(sequence fname,=20
sequence accmode)<BR>atom File, FileName <BR>&nbsp; FileName =3D=20
allocate_string2(fname)<BR>&nbsp; if compare(accmode,"rb")=3D0=20
then<BR>&nbsp;&nbsp;&nbsp; File =3D=20
c_func(xCreateFile,{FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRI=
BUTE_NORMAL+<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
FILE_FLAG_SEQUENTIAL_SCAN,NULL})<BR>&nbsp; elsif =
compare(accmode,"wb")=3D0=20
then<BR>&nbsp;&nbsp;&nbsp; File =3D=20
c_func(xCreateFile,{FileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTR=
IBUTE_NORMAL+<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
FILE_FLAG_SEQUENTIAL_SCAN,NULL})<BR>&nbsp; end if<BR>&nbsp; junk =3D=20
myfree(FileName)<BR>&nbsp; return File<BR>end function<BR>atom =
PFNOPEN</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("CreateFile") <BR>PFNOPEN =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;--WriteFile()<BR>&nbsp;--hFile (handle) obtained by =
CreateFile=20
<BR>&nbsp;--must have GENERIC_WRITE access</DIV>
<DIV>&nbsp;</DIV>
<DIV>atom writebytes<BR>writebytes =3D myalloc(4)</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>function WriteFile(atom hFile, atom lpBuffer, atom=20
nNumberOfBytesToWrite)<BR>&nbsp; return=20
c_func(xWriteFile,{hFile,lpBuffer,nNumberOfBytesToWrite,writebytes,0})<BR=
>end=20
function&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
<BR>atom PFNWRITE</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("CreateFile") <BR>PFNWRITE =3D =
call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;--ReadFile()<BR>&nbsp;--hFile (handle) obtained by CreateFile =

<BR>&nbsp;--must have GENERIC_READ access</DIV>
<DIV>&nbsp;</DIV>
<DIV>atom readbytes<BR>readbytes =3D myalloc(4) --lpNumberOfBytesRead =
</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>function ReadFile(atom hFile, atom lpBuffer, atom=20
nNumberOfBytesToRead)<BR>&nbsp; return=20
c_func(xReadFile,{hFile,lpBuffer,nNumberOfBytesToRead,readbytes,0})<BR>en=
d=20
function<BR>atom PFNREAD</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("ReadFile") <BR>PFNREAD =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>constant SEEK_SET =3D=20
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
--/* seek to an absolute position=20
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SEEK_CUR =3D=20
1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
--/* seek relative to current position=20
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SEEK_END =3D =
2&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>function SetFilePos(atom hf, atom dist, atom seektype)<BR>&nbsp; =
integer=20
dMethod </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if seektype =3D SEEK_SET =
then=20
dMethod =3D FILE_BEGIN<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
elsif=20
seektype =3D SEEK_CUR then dMethod =3D=20
FILE_CURRENT<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif =
seektype =3D=20
SEEK_END then dMethod =3D =
FILE_END<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
end if<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
<BR>&nbsp;&nbsp;&nbsp;=20
return c_func(xSetFilePointer,{hf,dist,NULL,dMethod})<BR>end =
function<BR>atom=20
PFNSEEK</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("SetFilePos") <BR>PFNSEEK =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>atom PFNCLOSE PFNCLOSE=3D0<BR>function CloseFile(atom handle)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; if handle =3D PFNCLOSE+96 =
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
return 0<BR>&nbsp;&nbsp; elsif handle !=3D 0=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return=20
c_func(xCloseHandle,{handle})<BR>&nbsp;&nbsp; end if</DIV>
<DIV>&nbsp;</DIV>
<DIV>end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>id =3D routine_id("CloseFile") <BR>PFNCLOSE =3D call_back(id)</DIV>
<DIV>&nbsp;</DIV>
<DIV>constant cpuUNKNOWN =3D=20
-1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu80286 =3D 0,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu80386 =3D =
1</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>--typedef struct {<BR>constant erfOper =3D=20
0,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; erfType =3D=20
4,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fError =3D =
8</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>atom ERF<BR>ERF =3D myalloc(12)</DIV>
<DIV>&nbsp;</DIV>
<DIV>mypoke4(ERF + erfOper, 222)<BR>mypoke4(ERF + erfType, 222) =
<BR>mypoke4(ERF=20
+ fError, 222)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; <BR>atom hfdi</DIV>
<DIV>&nbsp;</DIV>
<DIV>hfdi =3D c_func(xFDICreate,{PFNALLOC, -- MACHINE LEVEL CRASH=20
HERE!<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
PFNFREE,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
PFNOPEN,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
PFNREAD,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
PFNWRITE,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
PFNCLOSE,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
PFNSEEK,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
cpuUNKNOWN,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
ERF})</DIV>
<DIV>&nbsp;</DIV>
<DIV>junk =3D peek4u(ERF + erfOper) -- NO ERRORS if all are -&gt; =
222<BR>junk =3D=20
peek4u(ERF + erfType) <BR>junk =3D peek4u(ERF + fError)</DIV>
<DIV>&nbsp;</DIV>
<DIV>-- FDICABINETINFO - Information about a=20
cabinet<BR>constant<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cbCabinet =3D=20
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
--// Total length of cabinet file<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
cFolders =3D=20
4,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
--// Count of folders in cabinet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
cFiles =3D=20
6,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
--// Count of files in cabinet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setID =
=3D=20
8,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
--// Cabinet set ID<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iCabinet =3D=20
10,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
--// Cabinet number in set (0 based)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
fReserve=20
=3D=20
12,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
--// TRUE =3D&gt; RESERVE present in =
cabinet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
hasprev =3D=20
16,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
--// TRUE =3D&gt; Cabinet is chained =
prev<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
hasnext =3D=20
20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
--// TRUE =3D&gt; Cabinet is chained next</DIV>
<DIV>&nbsp;</DIV>
<DIV>atom pfdici<BR>pfdici =3D myalloc(24)</DIV>
<DIV>&nbsp;</DIV>
<DIV>atom hf<BR>hf =3D CreateFile("sdkinst.cab","rb") --open " =
"&nbsp;cab=20
file</DIV>
<DIV>&nbsp;</DIV>
<DIV>if hf &lt;=3D 0 then<BR>&nbsp;&nbsp;=20
c_proc(xFDIDestroy,{hfdi})<BR>&nbsp;&nbsp; junk =3D =
CloseFile(hf)<BR>&nbsp;&nbsp;=20
abort(0)<BR>end if</DIV>
<DIV>&nbsp;</DIV>
<DIV>junk =3D c_func(xFDIIsCabinet,{hfdi, hf, pfdici})</DIV>
<DIV>&nbsp;</DIV>
<DIV>if junk =3D 0 then<BR>&nbsp;&nbsp; =
c_proc(xFDIDestroy,{hfdi})<BR>&nbsp;&nbsp;=20
junk =3D CloseFile(hf)<BR>end if<BR>&nbsp;&nbsp; <BR>junk =3D=20

------=_NextPart_000_0009_01C30D99.5528CB00--

new topic     » topic index » view message » categorize

2. Re: HELP WANTED!

----- Original Message -----
From: <euman at bellsouth.net>
To: "EUforum" <EUforum at topica.com>
Subject: HELP WANTED!


>
> 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.
>
>           *look for -- MACHINE LEVEL CRASH HERE!*
>

[snip]

It seems that you have the definition of FDICreate incorrectly specified. I
don't have the C code header for that so can you post it on the list.

I suspect this because when you trace through the code, you can see the
callback function for allocate and free being called, but the parameter's
being passed to those functions are obviously wrong. The first allocate
callback is passed 2052, which seems ok. However the next call is passed the
PFNOPEN value! On my system that means it is being asked to allocate 4530592
bytes. Then the first myfree callback is being asked to free the PFNWRITE
address. Next the ReadFile callback is being asked to use the PFNSEEK value
as the file handle and to read the ERF value number of bytes. In my system
that means 4559848 bytes!

So I suspect that you may have missed a parameter?
----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

3. Re: HELP WANTED!

You need to add a '+' to the name of the function, so that Eu will know it 
is a __cdecl function. Also, the last parameter of FDICreate() is a pointer 
to an ERF structure and the return value is a pointer, as well; you have 
them defined as C_LONG's.
So, the correct definition for FDICreate would be:
xFDICreate = link_c_func(cabinet, "+FDICreate", {C_POINTER, C_POINTER, 
C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_INT, C_POINTER}, 
C_POINTER)

>From: euman at bellsouth.net
>Subject: HELP WANTED!
>
>
>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.
>
>           *look for -- MACHINE LEVEL CRASH HERE!*
>
><code by Euman 2003>
>
>with trace
>
>include dll.e
>include misc.e
>
>integer xHeapCreate, xHeapDestroy, xHeapAlloc, xHeapFree,
>         xCreateFile, xReadFile, xWriteFile, xSetFilePointer, xCloseHandle,
>         xFDICreate, xFDIIsCabinet, xFDICopy, xFDIDestroy
>
>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 = define_c_func(dll, name, args, result)
>    if handle = -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 = define_c_proc(dll, name, args)
>    if handle = -1 then
>       not_found(name)
>    else
>       return handle
>    end if
>end function
>
>procedure link_dll_routines()
>   atom kernel32, cabinet
>
>     kernel32 = open_dll("kernel32.dll")
>     if kernel32 = NULL then
>  not_found("kernel32.dll")
>     end if
>     cabinet = open_dll("cabinet.dll")
>     if cabinet = NULL then
>  not_found("cabinet.dll")
>     end if
>
>     xHeapCreate = 
>link_c_func(kernel32,"HeapCreate",{C_LONG,C_LONG,C_LONG},C_LONG)
>     xHeapDestroy = link_c_func(kernel32,"HeapDestroy",{C_LONG},C_LONG)
>     xHeapAlloc = 
>link_c_func(kernel32,"HeapAlloc",{C_LONG,C_LONG,C_LONG},C_LONG)
>     xHeapFree = 
>link_c_func(kernel32,"HeapFree",{C_LONG,C_LONG,C_LONG},C_LONG)
>
>     xCreateFile = 
>>link_c_func(kernel32,"CreateFileA",{C_POINTER,C_LONG,C_LONG,C_POINTER,C_LONG,C_LONG,C_INT},C_LONG)
>     xReadFile = 
>>link_c_func(kernel32,"ReadFile",{C_INT,C_POINTER,C_UINT,C_POINTER,C_POINTER},C_LONG)
>     xWriteFile = 
>>link_c_func(kernel32,"WriteFile",{C_INT,C_POINTER,C_LONG,C_POINTER,C_POINTER},C_LONG)
>     xSetFilePointer = 
>link_c_func(kernel32,"SetFilePointer",{C_LONG,C_LONG,C_POINTER,C_LONG},C_LONG)
>     xCloseHandle = link_c_func(kernel32,"CloseHandle",{C_LONG},C_LONG)
>
>     xFDICreate = 
>>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 = 
>link_c_func(cabinet,"FDIIsCabinet",{C_LONG,C_INT,C_POINTER},C_LONG)
>     xFDICopy = 
>>link_c_func(cabinet,"FDICopy",{C_LONG,C_POINTER,C_POINTER,C_INT,C_POINTER,C_POINTER,C_INT},C_LONG)
>     xFDIDestroy = link_c_proc(cabinet,"FDIDestroy",{C_LONG})
>
>end procedure
>
>link_dll_routines()
<snip>

>
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: HELP WANTED!

----- Original Message -----
From: "Elliott Sales de Andrade" <quantum_analyst at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: HELP WANTED!


>
>
> You need to add a '+' to the name of the function, so that Eu will know it
> is a __cdecl function. Also, the last parameter of FDICreate() is a
pointer
> to an ERF structure and the return value is a pointer, as well; you have
> them defined as C_LONG's.
> So, the correct definition for FDICreate would be:
> xFDICreate = link_c_func(cabinet, "+FDICreate", {C_POINTER, C_POINTER,
> C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_INT, C_POINTER},
> C_POINTER)
>

I just tried this Elliott, but it still behaves in the manner I outlined
earlier.

----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

5. Re: HELP WANTED!

This is a multi-part message in MIME format.

------=_NextPart_000_0014_01C30DAE.9351D470
	charset="iso-8859-1"

Hello and Thanks for taking time to respond.

Attached is the zip file which include the C headers + examples and
the documentation as supplied with my copy of the Cab-SDK.

I tried Elliott's usefull info but Eucab.ew is still broken.
Thanks Elliott for opening my eyes to read the 2.4 doco for the new
Euphoria. I never thought we had a change to use cdecl dll's, I must
re-read the entire doco again.

Derek I notice the behavior you mentioned where allocation takes place
twice then free then readfile, I cant explain why the .dll is doing this.
I believe mic say'd he had parts working thru some major asm trickery
but most of that stuff is over my head.

Thanks again,
Euman

----- Original Message ----- 
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, April 28, 2003 4:57 PM
Subject: Re: HELP WANTED!


>
> ----- Original Message -----
> From: <euman at bellsouth.net>
> To: "EUforum" <EUforum at topica.com>
> Sent: Tuesday, April 29, 2003 5:17 AM
> Subject: HELP WANTED!
>
>
> > 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.
> >
> >           *look for -- MACHINE LEVEL CRASH HERE!*
> >
>
> [snip]
>
> It seems that you have the definition of FDICreate incorrectly specified.
I
> don't have the C code header for that so can you post it on the list.
>
> I suspect this because when you trace through the code, you can see the
> callback function for allocate and free being called, but the parameter's
> being passed to those functions are obviously wrong. The first allocate
> callback is passed 2052, which seems ok. However the next call is passed
the
> PFNOPEN value! On my system that means it is being asked to allocate
4530592
> bytes. Then the first myfree callback is being asked to free the PFNWRITE
> address. Next the ReadFile callback is being asked to use the PFNSEEK
value
> as the file handle and to read the ERF value number of bytes. In my system
> that means 4559848 bytes!
>
> So I suspect that you may have missed a parameter?
> ----------------
> cheers,
> Derek Parnell
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

------=_NextPart_000_0014_01C30DAE.9351D470
Content-Type: application/zip;
	name="FCI-FDI.zip"

new topic     » goto parent     » topic index » view message » categorize

6. Re: HELP WANTED!

On Mon, 28 Apr 2003 17:49:54 -0400, <euman at bellsouth.net> wrote:

>
> Hello and Thanks for taking time to respond.
>
> Attached is the zip file which include the C headers + examples and
> the documentation as supplied with my copy of the Cab-SDK.
>
> I tried Elliott's usefull info but Eucab.ew is still broken.
> Thanks Elliott for opening my eyes to read the 2.4 doco for the new
> Euphoria. I never thought we had a change to use cdecl dll's, I must
> re-read the entire doco again.
>
> Derek I notice the behavior you mentioned where allocation takes place
> twice then free then readfile, I cant explain why the .dll is doing this.
> I believe mic say'd he had parts working thru some major asm trickery
> but most of that stuff is over my head.
>
> Thanks again,
> Euman

I think I see a problem. It seems that the callback routines must also be 
_cdecl. But I don't think that we can specify that in Euphoria.

You might have to write a DLL that converts the _cdecl calls to ones that 
Eu can cope with.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

7. Re: HELP WANTED!

From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: HELP WANTED!


> I think I see a problem. It seems that the callback routines must also be
> _cdecl. But I don't think that we can specify that in Euphoria.
>
> You might have to write a DLL that converts the _cdecl calls to ones that
> Eu can cope with.

I sure hope not....
Im concerned that what we may have is a one sided cdecl implementation to
work with.
Robert, can you add this to the core language? I havent tried using
file-mapping
here because I could only imagine a cut in speed/reliability. Maybe there is
a way to do this
in Euphoria Im not sure. Derek shot it down and Ive had no luck so, maybe it
isnt at all possible.

> cheers,
> Derek Parnell

Euman

new topic     » goto parent     » topic index » view message » categorize

8. Re: HELP WANTED!

--- Derek Parnell <ddparnell at bigpond.com> wrote:

> 
> I think I see a problem. It seems that the callback routines must also be 
> _cdecl. But I don't think that we can specify that in Euphoria.
> 
> You might have to write a DLL that converts the _cdecl calls to ones that 
> Eu can cope with.

You can do this with fptr.e.  Take a look at call_back_cdecl() in the latest
version.  It's in the archives or on my page:

http://www14.brinkster.com/matthewlewis/projects.html

Matt Lewis


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

new topic     » goto parent     » topic index » view message » categorize

9. Re: HELP WANTED!

Thank-you much everyone.
PFN* = call_back({'+',id})
seems to work properly....

Even the ole-timers need to read the docs again......
If all goes well, I'll have the Cab wrappers to Rob
in a few days...

Euman

----- Original Message ----- 
From: "Brian Broker" <bkb at cnw.com>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, April 28, 2003 7:38 PM
Subject: RE: HELP WANTED!


>
> In Eu 2.4, the call_back function provides a way to declare your routine
> so that it works with cdecl.  I've not found any issues working with
> cdecl libs using 2.4.
>
> -- Brian
>
> Derek Parnell wrote:
> >
> > On Mon, 28 Apr 2003 17:49:54 -0400, <euman at bellsouth.net> wrote:
> >
> > >
> > > Hello and Thanks for taking time to respond.
> > >
> > > Attached is the zip file which include the C headers + examples and
> > > the documentation as supplied with my copy of the Cab-SDK.
> > >
> > > I tried Elliott's usefull info but Eucab.ew is still broken.
> > > Thanks Elliott for opening my eyes to read the 2.4 doco for the new
> > > Euphoria. I never thought we had a change to use cdecl dll's, I must
> > > re-read the entire doco again.
> > >
> > > Derek I notice the behavior you mentioned where allocation takes place
> > > twice then free then readfile, I cant explain why the .dll is doing
> > > this.
> > > I believe mic say'd he had parts working thru some major asm trickery
> > > but most of that stuff is over my head.
> > >
> > > Thanks again,
> > > Euman
> >
> > I think I see a problem. It seems that the callback routines must also
> > be
> > _cdecl. But I don't think that we can specify that in Euphoria.
> >
> > You might have to write a DLL that converts the _cdecl calls to ones
> > that
> > Eu can cope with.
> >
> > -- 
> >
> > cheers,
> > Derek Parnell
> >
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

10. Re: HELP WANTED!

Thanks Matt, I was using an older version of fptr.e

-- fptr.e

-- Call functions via pointers

-- Matt Lewis

-- 3/4/02

I believe I figured out how to use Euphoria now but will certainly

punt if I need to.

Euman

----- Original Message ----- 
From: "Matt Lewis" <matthewwalkerlewis at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, April 28, 2003 8:27 PM
Subject: Re: HELP WANTED!


>
>
> --- Derek Parnell <ddparnell at bigpond.com> wrote:
>
> >
> > I think I see a problem. It seems that the callback routines must also
be
> > _cdecl. But I don't think that we can specify that in Euphoria.
> >
> > You might have to write a DLL that converts the _cdecl calls to ones
that
> > Eu can cope with.
>
> You can do this with fptr.e.  Take a look at call_back_cdecl() in the
latest
> version.  It's in the archives or on my page:
>
> http://www14.brinkster.com/matthewlewis/projects.html
>
> Matt Lewis
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu