DLLs called from COPIAFACTS should follow normal Windows calling conventions, as described in the example that follows:

An example of a trivial C program which could be called from COPIAFACTS is as follows:

BOOL WINAPI DllMain (HANDLE hModule, 

                     DWORD fdwReason,

                     LPVOID lpReserved)

{

  switch (fdwReason)

  {

    case DLL_PROCESS_ATTACH: …

    case DLL_THREAD_ATTACH: …

    case DLL_THREAD_DETACH: …

    case DLL_PROCESS_DETACH: …

  }

  return TRUE;

}

 

__declspec(dllexport) int WINAPI TestFunc (int lineno, 

                                           int callno, 

                                           char * arg)

{

  return strlen(arg);

}

This program should be built with a definition file as follows:

LIBRARY TESTDLL

EXPORTS

TestFunc @1

You should select a base address for your library which does not conflict with other DLLs loaded by COPIAFACTS. Even though Windows is supposed to re-base DLLs to avoid conflicts, this is not always successful. Standard CopiaFacts DLLs use the space from 0x11000000 to 0x11FFFFFF but DLLs from hardware manufacturers may use other ranges.

If you encounter a conflict, loading your DLL may result in a Windows error. Re-run COPIAFACTS and key 'D' to display a list of DLL addresses already in use by the program.