Source code of Windows XP (NT5)
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.

229 lines
18 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ShimAh.h
  5. Abstract:
  6. Definitions for use by all modules
  7. Notes:
  8. None
  9. History:
  10. 12/09/1999 robkenny Created
  11. 01/10/2000 linstev Format to new style
  12. --*/
  13. #ifndef _SHIMAH_H_
  14. #define _SHIMAH_H_
  15. DWORD_PTR AhCall(LPSTR pszModule, LPSTR pszFunctionName, DWORD dwArgCount, ...);
  16. #define GetLastError() (DWORD) AhCall("KERNEL32.DLL", "GetLastError", 0)
  17. #define FormatMessageA(a, b, c, d, e, f, g) (LONG) AhCall("KERNEL32.DLL", "FormatMessageA", 7, a, b, c, d, e, f, g)
  18. #define FormatMessageW(a, b, c, d, e, f, g) (LONG) AhCall("KERNEL32.DLL", "FormatMessageW", 7, a, b, c, d, e, f, g)
  19. // Memory routines
  20. #define VirtualAlloc(a, b, c, d) (LPVOID) AhCall("KERNEL32.DLL", "VirtualAlloc", 4, a, b, c, d)
  21. #define VirtualFree(a, b, c) (BOOL) AhCall("KERNEL32.DLL", "VirtualFree", 3, a, b, c)
  22. #define VirtualProtect(a, b, c, d) (BOOL) AhCall("KERNEL32.DLL", "VirtualProtect", 4, a, b, c, d)
  23. #define malloc(a) (LPVOID) VirtualAlloc(NULL, a, MEM_COMMIT, PAGE_READWRITE)
  24. #define free(a) (VOID) VirtualFree(a, 0, MEM_RELEASE)
  25. #define memset(a, b, c) (LPVOID) AhCall("NTDLL.DLL", "RtlFillMemory", 3, a, b, c)
  26. #define memmove(a, b, c) (LPVOID) AhCall("NTDLL.DLL", "RtlMoveMemory", 3, a, b, c)
  27. #define memcpy(a, b, c) (VOID *) AhCall("NTDLL.DLL", "memcpy", 3, a, b, c)
  28. #define RtlAllocateHeap(a, b, c) (LPVOID) AhCall("NTDLL.DLL", "RtlAllocateHeap", 3, a, b, c)
  29. #define RtlFreeHeap(a, b, c) (LPVOID) AhCall("NTDLL.DLL", "RtlFreeHeap", 3, a, b, c)
  30. // Disable build warnings due to duplicate macro definitions
  31. #ifdef ZeroMemory
  32. #undef ZeroMemory
  33. #endif
  34. #define ZeroMemory(a, b) (int) AhCall( "NTDLL.DLL", "RtlZeroMemory", 2, a, b)
  35. #ifdef MoveMemory
  36. #undef MoveMemory
  37. #endif
  38. #define MoveMemory(a, b, c) (int) AhCall( "NTDLL.DLL", "RtlMoveMemory", 3, a, b, c)
  39. // String manipulation routines
  40. #define towupper(a) (int) AhCall("NTDLL.DLL", "towupper", 1, a)
  41. #define strstr(a, b) (char *) AhCall("NTDLL.DLL", "strstr", 2, a, b)
  42. #define wcsstr(a, b) (wchar_t *) AhCall("NTDLL.DLL", "wcsstr", 2, a, b)
  43. #define _strupr(a) (char *) AhCall("NTDLL.DLL", "_strupr", 1, a)
  44. #define _wcsupr(a) (wchar_t *) AhCall("NTDLL.DLL", "_wcsupr", 1, a)
  45. #define strncmp(a, b, c) (char *) AhCall("NTDLL.DLL", "strncmp", 3, a, b, c)
  46. #define wcsncmp(a, b, c) (wchar_t *) AhCall("NTDLL.DLL", "wcsncmp", 3, a, b, c)
  47. #define _stricmp(a, b) (int) AhCall("NTDLL.DLL", "_stricmp", 2, a, b)
  48. #define strcat(a, b) (char *) AhCall("NTDLL.DLL", "strcat", 2, a, b)
  49. #define wcscat(a, b) (wchar_t *) AhCall("NTDLL.DLL", "wcscat", 2, a, b)
  50. #define strlen(a) (size_t) AhCall("NTDLL.DLL", "strlen", 1, a)
  51. #define wcslen(a) (size_t) AhCall("NTDLL.DLL", "wcslen", 1, a)
  52. #define strcpy(a, b) (char *) AhCall("NTDLL.DLL", "strcpy", 2, a, b)
  53. #define wcscpy(a, b) (wchar_t *) AhCall("NTDLL.DLL", "wcscpy", 2, a, b)
  54. #define strncpy(a, b, c) (char *) AhCall("NTDLL.DLL", "strncpy", 3, a, b, c)
  55. #define wcsncpy(a, b, c) (wchar_t *) AhCall("NTDLL.DLL", "wcsncpy", 3, a, b, c)
  56. #define _strlwr(a) (char *) AhCall("NTDLL.DLL", "_strlwr", 1, a)
  57. #define _wcslwr(a) (wchar_t *) AhCall("NTDLL.DLL", "_wcslwr", 1, a)
  58. #define _strnicmp(a, b, c) (int) AhCall("NTDLL.DLL", "_strnicmp", 3, a, b, c)
  59. #define _wcsnicmp(a, b, c) (int) AhCall("NTDLL.DLL", "_wcsnicmp", 3, a, b, c)
  60. // ANSI/Unicode routines
  61. #define MultiByteToWideChar(a, b, c, d, e, f) (int) AhCall("KERNEL32.DLL", "MultiByteToWideChar", 6, a, b, c, d, e, f)
  62. #define WideCharToMultiByte(a, b, c, d, e, f, g, h) (int) AhCall("KERNEL32.DLL", "WideCharToMultiByte", 8, a, b, c, d, e, f, g, h)
  63. // Registry routines
  64. #define RegOpenKeyA(a, b, c) (LONG) AhCall("ADVAPI32.DLL", "RegOpenKeyA", 3, a, b, c)
  65. #define RegOpenKeyW(a, b, c) (LONG) AhCall("ADVAPI32.DLL", "RegOpenKeyW", 3, a, b, c)
  66. #define RegCloseKey(a) (LONG) AhCall("ADVAPI32.DLL", "RegCloseKey", 1, a)
  67. #define RegOpenKeyExA(a, b, c, d, e) (LONG) AhCall("ADVAPI32.DLL", "RegOpenKeyExA", 5, a, b, c, d, e)
  68. #define RegOpenKeyExW(a, b, c, d, e) (LONG) AhCall("ADVAPI32.DLL", "RegOpenKeyExW", 5, a, b, c, d, e)
  69. #define RegQueryValueExA(a, b, c, d, e, f) (LONG) AhCall("ADVAPI32.DLL", "RegQueryValueExA", 6, a, b, c, d, e, f)
  70. #define RegQueryValueExW(a, b, c, d, e, f) (LONG) AhCall("ADVAPI32.DLL", "RegQueryValueExW", 6, a, b, c, d, e, f)
  71. #define RegCreateKeyExA(a, b, c, d, e, f, g, h, i) (LONG) AhCall("ADVAPI32.DLL", "RegCreateKeyExA", 9, a, b, c, d, e, f, g, h, i)
  72. #define RegCreateKeyExW(a, b, c, d, e, f, g, h, i) (LONG) AhCall("ADVAPI32.DLL", "RegCreateKeyExA", 9, a, b, c, d, e, f, g, h, i)
  73. #define RegCreateKeyA(a, b, c) (LONG) AhCall("ADVAPI32.DLL", "RegCreateKeyA", 3, a, b, c)
  74. #define RegCreateKeyW(a, b, c) (LONG) AhCall("ADVAPI32.DLL", "RegCreateKeyW", 3, a, b, c)
  75. #define GetPrivateProfileIntA(a, b, c, d) (UINT) AhCall("KERNEL32.DLL", "GetPrivateProfileIntA", 4, a, b, c, d)
  76. #define GetPrivateProfileIntW(a, b, c, d) (UINT) AhCall("KERNEL32.DLL", "GetPrivateProfileIntW", 4, a, b, c, d)
  77. #define GetPrivateProfileSectionA(a, b, c, d) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileSectionA", 4, a, b, c, d)
  78. #define GetPrivateProfileSectionW(a, b, c, d) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileSectionW", 4, a, b, c, d)
  79. #define GetPrivateProfileSectionNamesA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileSectionNamesA", 3, a, b, c)
  80. #define GetPrivateProfileSectionNamesW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileSectionNamesW", 3, a, b, c)
  81. #define GetPrivateProfileStringA(a, b, c, d, e, f) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileStringA", 6, a, b, c, d, e, f)
  82. #define GetPrivateProfileStringW(a, b, c, d, e, f) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileStringW", 6, a, b, c, d, e, f)
  83. #define GetPrivateProfileStructA(a, b, c, d, e) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileStructA", 5, a, b, c, d, e)
  84. #define GetPrivateProfileStructW(a, b, c, d, e) (DWORD) AhCall("KERNEL32.DLL", "GetPrivateProfileStructW", 5, a, b, c, d, e)
  85. #define WritePrivateProfileSectionA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "WritePrivateProfileSectionA", 3, a, b, c)
  86. #define WritePrivateProfileSectionW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "WritePrivateProfileSectionW", 3, a, b, c)
  87. #define WritePrivateProfileStringA(a, b, c, d) (UINT) AhCall("KERNEL32.DLL", "WritePrivateProfileStringA", 4, a, b, c, d)
  88. #define WritePrivateProfileStringW(a, b, c, d) (UINT) AhCall("KERNEL32.DLL", "WritePrivateProfileStringW", 4, a, b, c, d)
  89. #define WritePrivateProfileStructA(a, b, c, d, e) (DWORD) AhCall("KERNEL32.DLL", "WritePrivateProfileStructA", 5, a, b, c, d, e)
  90. #define WritePrivateProfileStructW(a, b, c, d, e) (DWORD) AhCall("KERNEL32.DLL", "WritePrivateProfileStructW", 5, a, b, c, d, e)
  91. #define GetEnvironmentVariableA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetEnvironmentVariableA", 3, a, b, c)
  92. #define GetEnvironmentVariableW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetEnvironmentVariableW", 3, a, b, c)
  93. #define ExpandEnvironmentStringsA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "ExpandEnvironmentStringsA", 3, a, b, c)
  94. #define ExpandEnvironmentStringsW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "ExpandEnvironmentStringsW", 3, a, b, c)
  95. #define GetWindowsDirectoryA(a, b) (UINT) AhCall("Kernel32.dll", "GetWindowsDirectoryA", 2, a, b)
  96. #define GetWindowsDirectoryW(a, b) (UINT) AhCall("Kernel32.dll", "GetWindowsDirectoryW", 2, a, b)
  97. #define GetSystemDirectoryA(a, b) (UINT) AhCall("Kernel32.dll", "GetSystemDirectoryA", 2, a, b)
  98. #define GetSystemDirectoryW(a, b) (UINT) AhCall("Kernel32.dll", "GetSystemDirectoryW", 2, a, b)
  99. #define GetFullPathNameA(a, b, c, d) (DWORD) AhCall("KERNEL32.DLL", "GetFullPathNameA", 4, a, b, c, d)
  100. #define GetFullPathNameW(a, b, c, d) (DWORD) AhCall("KERNEL32.DLL", "GetFullPathNameW", 4, a, b, c, d)
  101. #define GetShortPathNameA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetShortPathNameA", 3, a, b, c)
  102. #define GetShortPathNameW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetShortPathNameW", 3, a, b, c)
  103. #define SHGetFolderPathA(a, b, c, d, e) (HRESULT) AhCall("SHELL32.DLL", "SHGetFolderPathA", 5, a, b, c, d, e)
  104. #define SHGetFolderPathW(a, b, c, d, e) (HRESULT) AhCall("SHELL32.DLL", "SHGetFolderPathW", 5, a, b, c, d, e)
  105. #define SHGetSpecialFolderPathA(a, b, c, d) (BOOL) AhCall( "SHELL32.DLL", "SHGetSpecialFolderPathA", 4, a, b, c, d)
  106. #define SHGetSpecialFolderPathW(a, b, c, d) (BOOL) AhCall( "SHELL32.DLL", "SHGetSpecialFolderPathW", 4, a, b, c, d)
  107. #define SHGetFolderLocation(a, b, c, d, e) (HRESULT) AhCall("SHELL32.DLL", "SHGetFolderLocation", 5, a, b, c, d, e)
  108. #define GetCurrentDirectoryA(a, b) (DWORD) AhCall( "KERNEL32.DLL", "GetCurrentDirectoryA", 2, a, b)
  109. #define GetCurrentDirectoryW(a, b) (DWORD) AhCall( "KERNEL32.DLL", "GetCurrentDirectoryW", 2, a, b)
  110. #ifndef _WIN64
  111. #define GetWindowLongA(a, b) (LONG) AhCall("USER32.DLL", "GetWindowLongA", 2, a, b)
  112. #define GetWindowLongW(a, b) (LONG) AhCall("USER32.DLL", "GetWindowLongW", 2, a, b)
  113. #define SetWindowLongA(a, b, c) (LONG) AhCall("USER32.DLL", "SetWindowLongA", 3, a, b, c)
  114. #define SetWindowLongW(a, b, c) (LONG) AhCall("USER32.DLL", "SetWindowLongW", 3, a, b, c)
  115. #else //use 64 bit calls
  116. #define GetWindowLongA(a, b) (LONG_PTR) AhCall("USER32.DLL", "GetWindowLongPtrA", 2, a, b)
  117. #define GetWindowLongW(a, b) (LONG_PTR) AhCall("USER32.DLL", "GetWindowLongPtrW", 2, a, b)
  118. #define SetWindowLongA(a, b, c) (LONG_PTR) AhCall("USER32.DLL", "SetWindowLongPtrA", 3, a, b, c)
  119. #define SetWindowLongW(a, b, c) (LONG_PTR) AhCall("USER32.DLL", "SetWindowLongPtrW", 3, a, b, c)
  120. #endif
  121. #define GetDriveTypeA( a ) (UINT) AhCall("KERNEL32.DLL", "GetDriveTypeA", 1, a)
  122. #define GetDriveTypeW( a ) (UINT) AhCall("KERNEL32.DLL", "GetDriveTypeW", 1, a)
  123. #define CopyFileA(a, b, c ) (BOOL) AhCall("KERNEL32.DLL", "CopyFileA", 3, a, b, c )
  124. #define CopyFileW(a, b, c ) (BOOL) AhCall("KERNEL32.DLL", "CopyFileW", 3, a, b, c )
  125. #define SetFileAttributesA( a, b ) (BOOL) AhCall("KERNEL32.DLL", "SetFileAttributesA", 2, a, b )
  126. #define SetFileAttributesW( a, b ) (BOOL) AhCall("KERNEL32.DLL", "SetFileAttributesW", 2, a, b )
  127. #define RemoveDirectoryA(a) (BOOL) AhCall("KERNEL32.DLL", "RemoveDirectoryA", 1, a)
  128. #define RemoveDirectoryW(a) (BOOL) AhCall("KERNEL32.DLL", "RemoveDirectoryW", 1, a)
  129. #define MoveFileA(a, b) (BOOL) AhCall("KERNEL32.DLL", "MoveFileA", 2, a, b)
  130. #define MoveFileW(a, b) (BOOL) AhCall("KERNEL32.DLL", "MoveFileW", 2, a, b)
  131. #define GetUserNameA(a, b) (BOOL) AhCall("ADVAPI32.DLL", "GetUserNameA", 2, a, b);
  132. #define GetUserNameW(a, b) (BOOL) AhCall("ADVAPI32.DLL", "GetUserNameW", 2, a, b);
  133. #define OpenProcessToken( a, b, c ) (BOOL) AhCall("ADVAPI32.DLL", "OpenProcessToken", 3, a, b, c )
  134. #define GetCurrentProcess() (HANDLE) AhCall("KERNEL32.DLL", "GetCurrentProcess", 0 )
  135. #define LookupPrivilegeValueA( a, b, c ) (BOOL) AhCall("ADVAPI32.DLL", "LookupPrivilegeValueA", 3, a, b, c )
  136. #define LookupPrivilegeValueW( a, b, c ) (BOOL) AhCall("ADVAPI32.DLL", "LookupPrivilegeValueW", 3, a, b, c )
  137. #define AdjustTokenPrivileges( a, b, c, d, e, f)(BOOL) AhCall("ADVAPI32.DLL", "AdjustTokenPrivileges", 6, a, b, c, d, e, f )
  138. #define GetDiskFreeSpaceExA( a, b, c, d ) (BOOL) AhCall("KERNEL32.DLL", "GetDiskFreeSpaceExA", 4, a, b, c, d )
  139. #define lstrcpyA(a, b) (LPTSTR) AhCall("KERNEL32.DLL", "lstrcpy", 2, a, b)
  140. #define mouse_event(a, b, c, d, e) (VOID) AhCall("USER32.DLL", "mouse_event", 5, a, b, c, d, e )
  141. #define SetForegroundWindow(a) (BOOL) AhCall("USER32.DLL", "SetForegroundWindow", 1, a )
  142. #define IsWindow(a) (BOOL) AhCall("USER32.DLL", "IsWindow", 1, a )
  143. #define lstrcmpA(a, b) (int) AhCall("KERNEL32.DLL", "lstrcmpA", 2, a, b)
  144. #define lstrcmpW(a, b) (int) AhCall("KERNEL32.DLL", "lstrcmpW", 2, a, b)
  145. #define CloseHandle(a) (BOOL) AhCall("KERNEL32.DLL", "CloseHandle", 1, a)
  146. #define GetModuleFileNameA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetModuleFileNameA", 3, a, b, c)
  147. #define GetModuleFileNameW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetModuleFileNameW", 3, a, b, c)
  148. #define GetShortPathNameA(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetShortPathNameA", 3, a, b, c)
  149. #define GetShortPathNameW(a, b, c) (DWORD) AhCall("KERNEL32.DLL", "GetShortPathNameW", 3, a, b, c)
  150. #define LocalAlloc(a, b) (HLOCAL) AhCall("KERNEL32.DLL", "LocalAlloc", 2, a, b)
  151. #define LocalFree(a) (HLOCAL) AhCall("KERNEL32.DLL", "LocalFree", 1, a)
  152. #define ShellExecuteA(a, b, c, d, e, f) (HINSTANCE) AhCall("SHELL32.DLL", "ShellExecuteA", 6, a, b ,c ,d ,e ,f)
  153. #define ShellExecuteW(a, b, c, d, e, f) (HINSTANCE) AhCall("SHELL32.DLL", "ShellExecuteW", 6, a, b ,c ,d ,e ,f)
  154. #define IsBadStringPtrA(a, b) (BOOL) AhCall("KERNEL32.DLL", "IsBadStringPtrA", 2, a ,b)
  155. #define IsBadStringPtrW(a, b) (BOOL) AhCall("KERNEL32.DLL", "IsBadStringPtrW", 2, a ,b)
  156. #define GetLogicalDriveStringsA(a, b) (DWORD) AhCall("KERNEL32.DLL", "GetLogicalDriveStringsA",2, a ,b)
  157. #define GetLogicalDriveStringsW(a, b) (DWORD) AhCall("KERNEL32.DLL", "GetLogicalDriveStringsW",2, a ,b)
  158. #define EnterCriticalSection(a) (VOID) AhCall("KERNEL32.DLL", "EnterCriticalSection", 1, a)
  159. #define LeaveCriticalSection(a) (VOID) AhCall("KERNEL32.DLL", "LeaveCriticalSection", 1, a)
  160. #define InitializeCriticalSection(a) (VOID) AhCall("KERNEL32.DLL", "InitializeCriticalSection", 1, a)
  161. #define DeleteCriticalSection(a) (VOID) AhCall("KERNEL32.DLL", "InitializeCriticalSection", 1, a)
  162. #define EnumDisplaySettingsA(a, b, c) (BOOL) AhCall("USER32.DLL", "EnumDisplaySettingsA", 3, a, b, c)
  163. #define EnumDisplaySettingsW(a, b, c) (BOOL) AhCall("USER32.DLL", "EnumDisplaySettingsW", 3, a, b, c)
  164. #define ChangeDisplaySettingsA(a, b) (LONG) AhCall("USER32.DLL", "ChangeDisplaySettingsA", 2, a, b)
  165. #define ChangeDisplaySettingsW(a, b) (LONG) AhCall("USER32.DLL", "ChangeDisplaySettingsA", 2, a, b)
  166. #define ChangeDisplaySettingsExA(a, b, c, d, e) (LONG) AhCall("USER32.DLL", "ChangeDisplaySettingsExA", 5, a, b, c, d, e)
  167. #define ChangeDisplaySettingsExW(a, b, c, d, e) (LONG) AhCall("USER32.DLL", "ChangeDisplaySettingsExW", 5, a, b, c, d, e)
  168. #define SelectObject(a, b) (HGDIOBJ) AhCall("GDI32.DLL", "SelectObject", 2, a, b)
  169. #define BitBlt(a, b, c, d, e, f, g, h, i) (BOOL) AhCall("GDI32.DLL", "BitBlt", 9, a, b, c, d, e, f, g, h, i)
  170. #define StretchBlt(a, b, c, d, e, f, g, h, i, j, k) (BOOL) AhCall("GDI32.DLL", "StretchBlt", 11, a, b, c, d, e, f, g, h, i, j, k)
  171. #define CreateDIBSection(a, b, c, d, e, f) (HBITMAP) AhCall("GDI32.DLL", "CreateDIBSection", 6, a, b, c, d, e, f)
  172. #define CreateCompatibleBitmap(a, b, c) (HBITMAP) AhCall("GDI32.DLL", "CreateCompatibleBitmap", 3, a, b, c)
  173. #define CreateCompatibleDC(a) (HDC) AhCall("GDI32.DLL", "CreateCompatibleDC", 1, a)
  174. #define DeleteObject(a) (BOOL) AhCall("GDI32.DLL", "DeleteObject", 1, a)
  175. #define DeleteDC(a) (BOOL) AhCall("GDI32.DLL", "DeleteDC", 1, a)
  176. #define OpenMutexA(a, b, c) (HANDLE) AhCall("KERNEL32.DLL", "OpenMutexA", 3, a, b, c)
  177. #define GetCurrentThreadId() (DWORD) AhCall("KERNEL32.DLL", "GetCurrentThreadId", 0)
  178. #define CoCreateInstance(a, b, c, d, e) (HRESULT) AhCall("OLE32.DLL", "CoCreateInstance", 5, &(a), b, c, &(d), e)
  179. #define CoInitialize(a) (HRESULT) AhCall("OLE32.DLL", "CoInitialize", 1, a)
  180. #define CoUninitialize() (HRESULT) AhCall("OLE32.DLL", "CoUninitialize", 0)
  181. #endif // _SHIMAH_H_