home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Contrib / System / Source / System.h < prev    next >
C/C++ Source or Header  |  2003-09-11  |  4KB  |  106 lines

  1. // The following ifdef block is the standard way of creating macros which make exporting 
  2. // from a DLL simpler. All files within this DLL are compiled with the SYSTEM_EXPORTS
  3. // symbol defined on the command line. this symbol should not be defined on any project
  4. // that uses this DLL. This way any other project whose source files include this file see 
  5. // SYSTEM_API functions as being imported from a DLL, whereas this DLL sees symbols
  6. // defined with this macro as being exported.
  7. #pragma once
  8.  
  9. #ifdef SYSTEM_EXPORTS
  10. #define SYSTEM_API __declspec(dllexport)
  11. #else
  12. #define SYSTEM_API __declspec(dllimport)
  13. #endif
  14.  
  15. #define NEW_STACK_SIZE     256*256
  16.  
  17. // Proc types:
  18. #define PT_NOTHING      0
  19. #define PT_PROC         1
  20. #define PT_STRUCT       2
  21. #define PT_VTABLEPROC   3
  22.  
  23. // Proc results:
  24. #define PR_OK           0
  25. #define PR_ERROR        -1
  26. #define PR_CALLBACK     1
  27.  
  28. // Real world argument types
  29. #define    PAT_VOID        0
  30. #define PAT_INT            1
  31. #define    PAT_LONG        2
  32. #define PAT_STRING        3
  33. #define PAT_WSTRING        4
  34. #define PAT_GUID        5
  35. #define PAT_CALLBACK    6
  36.  
  37. // Input/Output Source/Destination
  38. #define    IOT_NONE    0
  39. #define    IOT_STACK    -1
  40. #define    IOT_REG        1
  41. #define IOT_INLINE  (__INST_LAST+1) // should replace pointer to inline input
  42. // #define INLINE_INPUT -> any other value, will contain pointer to input string
  43.  
  44. // Options
  45. #define POPT_CDECL      0x1    // (Option & 0x1) == 0x1 -> cdecl, otherwise stdcall
  46. #define POPT_PERMANENT  0x2    // Permanent proc, will not be destroyed after calling
  47. #define POPT_ALWRETURN  0x4    // Always return
  48. #define POPT_NEVERREDEF 0x8    // Never redefine
  49. #define POPT_GENSTACK   0x10   // Use general stack (non temporary for callback)
  50. #define POPT_ERROR      0x20   // Call GetLastError after proc and push it to stack
  51. #define POPT_UNLOAD     0x40   // unload dll after call
  52. #define POPT_CLONE      0x80   // This is clone callback
  53.  
  54. // Our single proc parameter
  55. typedef struct
  56. {
  57.     int Type;
  58.     int Option; // -1 -> Pointer, 1-... -> Special+1
  59.  
  60.     // if you'll change ProcParameter or SystemProc structure - update this value
  61. #define  SYSTEM_ZERO_PARAM_VALUE_OFFSET 0x820
  62.  
  63.     int Value;    // it can hold any 4 byte value 
  64.     int _value; // value buffer for structures > 4 bytes (I hope 8 bytes will be enough)
  65.     int Size; // Value real size (should be either 1 or 2 (the number of pushes))
  66.     int Input;
  67.     int Output;
  68.     HGLOBAL allocatedBlock; // block allocated for passing string, wstring or guid param
  69. } ProcParameter;
  70.  
  71. // Our single proc (Since the user will free proc with GlobalFree, 
  72. // I've declared all variables as statics)
  73. typedef struct tag_SystemProc SystemProc;
  74. typedef struct tag_SystemProc
  75. {
  76.     int ProcType;
  77.     int ProcResult;
  78.     char DllName[1024];
  79.     char ProcName[1024];
  80.     HANDLE Dll;
  81.     HANDLE Proc;
  82.     int Options;
  83.     int ParamCount;
  84.     // if you'll change ProcParameter or SystemProc structure - update SYSTEM_ZERO_PARAM_VALUE_OFFSET value
  85.     ProcParameter Params[100];    // I hope nobody will use more than 100 params
  86.  
  87.     // Callback specific
  88.     int CallbackIndex;
  89.     int ArgsSize;
  90.     // Clone of current element (used for multi-level callbacks)
  91.     SystemProc *Clone;
  92. } SystemProc;
  93.  
  94. extern const int ParamSizeByType[];   // Size of every parameter type (*4 bytes)
  95.  
  96. extern HANDLE CreateCallback(SystemProc *cbproc);
  97. extern SystemProc *PrepareProc(BOOL NeedForCall);
  98. extern void ParamAllocate(SystemProc *proc);
  99. extern void ParamsDeAllocate(SystemProc *proc);
  100. extern void ParamsIn(SystemProc *proc);
  101. extern void ParamsOut(SystemProc *proc);
  102. extern SystemProc *CallProc(SystemProc *proc);
  103. extern SystemProc *CallBack(SystemProc *proc);
  104. extern SystemProc *RealCallBack();
  105. extern void CallStruct(SystemProc *proc);
  106.