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.

164 lines
4.7 KiB

  1. #ifndef WinCEStub_h
  2. #define WinCEStub_h
  3. #include "basetsd_ce.h"
  4. #include <spdebug.h>
  5. #include <spcollec.h>
  6. #define InterlockedExchangePointer( pv, v) InterlockedExchange( (long*)pv, (long)v)
  7. #define SetWindowLongPtr SetWindowLong
  8. #define GetWindowLongPtr GetWindowLong
  9. // winuser.h
  10. #define GWLP_WNDPROC GWL_WNDPROC
  11. #define GWLP_STYLE GWL_STYLE
  12. #define GWLP_EXSTYLE GWL_EXSTYLE
  13. #define GWLP_USERDATA GWL_USERDATA
  14. #define GWLP_ID GWL_ID
  15. // from basetsd.h
  16. /*#define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
  17. #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
  18. #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
  19. #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
  20. #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
  21. #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
  22. #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
  23. #define UlongToPtr(ul) ULongToPtr(ul)
  24. #define UintToPtr(ui) UIntToPtr(ui)
  25. typedef ULONG_PTR SIZE_T, *PSIZE_T;
  26. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  27. */
  28. // from winbase.h
  29. #define NORMAL_PRIORITY_CLASS 0x00000020
  30. // from winbase.h
  31. #define LOCKFILE_FAIL_IMMEDIATELY 0x00000001
  32. #define LOCKFILE_EXCLUSIVE_LOCK 0x00000002
  33. //
  34. #define CSIDL_FLAG_CREATE 0x8000 // new for Win2K, or this in to force creation of folder
  35. // stdlib.d defined in sapiguid.cpp
  36. void *bsearch( const void *key, const void *base, size_t num, size_t width, int ( __cdecl *compare ) ( const void *elem1, const void *elem2 ) );
  37. // Fix misaligment exception
  38. #if defined (_M_ALPHA)||defined(_M_MRX000)||defined(_M_PPC)||defined(_SH4_)
  39. #undef UNALIGNED
  40. #define UNALIGNED __unaligned
  41. #endif
  42. // WCE does not have LockFileEx function. We do need emulate this functionality.
  43. class CWCELock
  44. {
  45. public:
  46. CWCELock( DWORD dwFlags,
  47. DWORD nNumberOfBytesToLockLow,
  48. DWORD nNumberOfBytesToLockHigh,
  49. LPOVERLAPPED pOverlapped): m_dwFlags(dwFlags),
  50. m_nNumberOfBytesToLockLow(nNumberOfBytesToLockLow),
  51. m_nNumberOfBytesToLockHigh(nNumberOfBytesToLockHigh),
  52. m_Offset(0),
  53. m_OffsetHigh(0),
  54. hEvent(0)
  55. {
  56. // memcpy(&m_Overlapped, pOverlapped, sizeof(OVERLAPPED));
  57. if (pOverlapped)
  58. {
  59. m_Offset = pOverlapped->Offset;
  60. m_OffsetHigh = pOverlapped->OffsetHigh;
  61. hEvent = pOverlapped->hEvent;
  62. }
  63. m_ProcessID = ::GetCurrentProcessId();
  64. }
  65. ~CWCELock()
  66. {
  67. m_Offset = 0;
  68. m_OffsetHigh = 0;
  69. hEvent = 0;
  70. m_ProcessID = 0;
  71. }
  72. /* BOOL IsEqual( DWORD nNumberOfBytesToLockLow,
  73. DWORD nNumberOfBytesToLockHigh,
  74. LPOVERLAPPED pOverlapped
  75. )
  76. {
  77. if ( nNumberOfBytesToLockLow==m_nNumberOfBytesToLockLow &&
  78. nNumberOfBytesToLockHigh==m_nNumberOfBytesToLockHigh &&
  79. !memcmp(&m_Overlapped, pOverlapped, sizeof(OVERLAPPED))
  80. )
  81. {
  82. return TRUE;
  83. }
  84. else
  85. {
  86. return FALSE;
  87. }
  88. }
  89. */
  90. private:
  91. DWORD m_dwFlags; // lock options
  92. DWORD m_nNumberOfBytesToLockLow; // low-order word of length
  93. DWORD m_nNumberOfBytesToLockHigh; // high-order word of length
  94. DWORD m_Offset;
  95. DWORD m_OffsetHigh;
  96. HANDLE hEvent;
  97. DWORD m_ProcessID;
  98. };
  99. typedef CSPList<CWCELock*,CWCELock*> CWCELockList;
  100. class CWCELocks
  101. {
  102. public:
  103. CWCELocks() {
  104. m_pCWCELockList = new CWCELockList();
  105. }
  106. ~CWCELocks() {
  107. while(!m_pCWCELockList->IsEmpty())
  108. {
  109. CWCELock* pCWCELock = m_pCWCELockList->RemoveHead();
  110. delete pCWCELock;
  111. }
  112. delete m_pCWCELockList;
  113. }
  114. BOOL LockFileEx(
  115. IN HANDLE hFile,
  116. IN DWORD dwFlags,
  117. IN DWORD dwReserved,
  118. IN DWORD nNumberOfBytesToLockLow,
  119. IN DWORD nNumberOfBytesToLockHigh,
  120. IN LPOVERLAPPED lpOverlapped
  121. )
  122. {
  123. return TRUE;
  124. }
  125. BOOL UnlockFileEx(
  126. IN HANDLE hFile,
  127. IN DWORD dwReserved,
  128. IN DWORD nNumberOfBytesToUnlockLow,
  129. IN DWORD nNumberOfBytesToUnlockHigh,
  130. IN LPOVERLAPPED lpOverlapped
  131. )
  132. {
  133. return TRUE;
  134. }
  135. private:
  136. CWCELockList* m_pCWCELockList;
  137. };
  138. #endif //WinCEStub_h