Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.7 KiB

  1. /* SIM v1.0
  2. *
  3. * SIM32.H
  4. * SIM32 constants and prototypes
  5. *
  6. * History
  7. * Created 05-Feb-91 by Chandan Chauhan and Jeff Parsons
  8. */
  9. /* Public function prototypes
  10. *
  11. * These functions are true pascal functions in the 16-bit case,
  12. * but conform to the default convention (cdecl) for the 32-bit case.
  13. */
  14. #ifndef FAR
  15. #define FAR
  16. #endif
  17. #ifndef PASCAL
  18. #define PASCAL
  19. #endif
  20. USHORT FAR PASCAL Sim32SendSim16(PULONG);
  21. USHORT FAR PASCAL Sim32GetVDMMemory(ULONG, USHORT, PVOID);
  22. USHORT FAR PASCAL Sim32SetVDMMemory(ULONG, USHORT, PVOID);
  23. PSZ FAR PASCAL Sim32GetVDMPSZPointer(ULONG);
  24. VOID FAR PASCAL Sim32FreeVDMPointer(PVOID);
  25. /* Private function prototypes
  26. */
  27. VOID Initialize();
  28. USHORT Xceive(IN USHORT, IN USHORT);
  29. /* Simulator replacement macros
  30. */
  31. #define SENDVDM(pvp) WOW32Receive()
  32. #define RECEIVEVDM(pvp) Sim32SendSim16(pvp)
  33. #ifdef ALLOCA
  34. #define GETPTR(vp,cb,p) ((p=alloca(cb))?Sim32GetVDMMemory(vp, (USHORT)(cb), p):FALSE)
  35. #define GETARGPTR(vp,cb,p) if (p=alloca(cb)) { Sim32GetVDMMemory(vp+OFFSETOF(VDMFRAME,bArgs), (USHORT)(cb), p)
  36. #ifdef WIN_16
  37. #define EQNULL
  38. #define GETPSZPTR(vp,pcb,p) if (vp) if (p=alloca(*pcb=128)) Sim32GetVDMMemory(vp, (USHORT)*pcb, p); else goto Error
  39. #define FREEPSZPTR(p)
  40. #else
  41. #define EQNULL = NULL
  42. #define GETPSZPTR(vp,pcb,p) if (vp) if (!(p=Sim32GetVDMPSZPointer(vp))) goto Error
  43. #define FREEPSZPTR(p) if (p) Sim32FreeVDMPointer(p)
  44. #endif
  45. #define FLUSHPTR(vp,cb,p) Sim32SetVDMMemory(vp, (USHORT)(cb), p)
  46. #define FREEPTR(p)
  47. #define FREEARGPTR(p) ;}
  48. #else
  49. #define EQNULL = NULL
  50. #define GETPTR(vp,cb,p) ((p=malloc(cb))?Sim32GetVDMMemory(vp, (USHORT)(cb), p):FALSE)
  51. #define GETARGPTR(vp,cb,p) if (p=malloc(cb)) { Sim32GetVDMMemory(vp+OFFSETOF(VDMFRAME,bArgs), (USHORT)(cb), p)
  52. #ifdef WIN_16
  53. #define GETPSZPTR(vp,pcb,p) if (vp) if (p=malloc(*pcb=128)) Sim32GetVDMMemory(vp, (USHORT)*pcb, p); else goto Error
  54. #define FREEPSZPTR(p) if (p) free(p)
  55. #else
  56. #define GETPSZPTR(vp,pcb,p) if (vp) if (!(p=Sim32GetVDMPSZPointer(vp))) goto Error
  57. #define FREEPSZPTR(p) if (p) Sim32FreeVDMPointer(p)
  58. #endif
  59. #define FLUSHPTR(vp,cb,p) Sim32SetVDMMemory(vp, (USHORT)(cb), p)
  60. #ifndef DEBUG
  61. #define FREEPTR(p) free(p)
  62. #define FREEARGPTR(p) free(p);}
  63. #else
  64. #define FREEPTR(p) free(p); p=NULL
  65. #define FREEARGPTR(p) free(p); p=NULL;}
  66. #endif
  67. #endif
  68. #define GETOPTPTR(vp,cb,p) if (vp) if (p=malloc(cb)) Sim32GetVDMMemory(vp, (USHORT)(cb), p); else goto Error
  69. #define GETVDMPTR(vp,cb,p) if (p=malloc(cb)) Sim32GetVDMMemory(vp, (USHORT)(cb), p); else goto Error
  70. #define ALLOCVDMPTR(vp,cb,p) if (!(p=malloc(cb))) goto Error
  71. #define FLUSHVDMPTR(vp,cb,p) Sim32SetVDMMemory(vp, (USHORT)(cb), p)
  72. #ifndef DEBUG
  73. #define FREEVDMPTR(p) if (p) free(p)
  74. #else
  75. #define FREEVDMPTR(p) if (p) {free(p); p=NULL;}
  76. #endif
  77. #define GETVDMMEMORY(vp,cb,p) Sim32GetVDMMemory(vp, (USHORT)(cb), p)
  78. #define SETVDMMEMORY(vp,cb,p) Sim32SetVDMMemory(vp, (USHORT)(cb), p)
  79. #ifdef SIM_32 // BUGBUG -- Use the macros in nt header files
  80. #undef FIRSTBYTE
  81. #undef SECONDBYTE
  82. #undef THIRDBYTE
  83. #undef FOURTHBYTE
  84. #endif
  85. #define FIRSTBYTE(VALUE) (VALUE & LO_MASK)
  86. #define SECONDBYTE(VALUE) ((VALUE >> 8) & LO_MASK)
  87. #define THIRDBYTE(VALUE) ((VALUE >> 16) & LO_MASK)
  88. #define FOURTHBYTE(VALUE) ((VALUE >> 24) & LO_MASK)
  89. #define LO_MASK 0x000000FF
  90. #define MAXSIZE 1024 // maximum buffer size
  91. #define MAXTRY 10 // for Transport
  92. /* Packet Codes
  93. */
  94. #define SOH 1 // start of header ie Pkt
  95. #define EOT 4 // end of transmission
  96. #define ToWOW32 1
  97. #define GETMEM 2
  98. #define SETMEM 3
  99. #define WAKEUP 4
  100. #define RESP 5
  101. #define ACK 6
  102. #define NAK 7
  103. #define PSZLEN 8
  104. #define GOOD 1
  105. #define BAD 0
  106. #define BADSIZE 2