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.

261 lines
9.6 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Certain calls are dynamically linked so that the user-mode
  4. // DLL can be used on Win9x and NT4.
  5. //
  6. // Copyright (C) Microsoft Corporation, 2000-2001.
  7. //
  8. //----------------------------------------------------------------------------
  9. #ifndef __DLLIMP_H__
  10. #define __DLLIMP_H__
  11. #include <security.h>
  12. #include <schannel.h>
  13. #include <tlhelp32.h>
  14. struct DYNAMIC_CALL_NAME
  15. {
  16. PCSTR Name;
  17. BOOL Required;
  18. };
  19. struct DYNAMIC_CALLS_DESC
  20. {
  21. PCSTR DllName;
  22. ULONG Count;
  23. DYNAMIC_CALL_NAME* Names;
  24. FARPROC* Procs;
  25. HINSTANCE Dll;
  26. BOOL Initialized;
  27. };
  28. // Calls from ntdll.dll.
  29. typedef struct _NTDLL_CALLS
  30. {
  31. HANDLE (NTAPI* CsrGetProcessId)
  32. (VOID);
  33. VOID (NTAPI* DbgBreakPoint)
  34. (VOID);
  35. ULONG (__cdecl* DbgPrint)
  36. (PCH Format, ...);
  37. ULONG (NTAPI* DbgPrompt)
  38. (PCH Prompt, PCH Response, ULONG MaximumResponseLength);
  39. NTSTATUS (NTAPI* DbgUiConvertStateChangeStructure)
  40. (IN PDBGUI_WAIT_STATE_CHANGE StateChange,
  41. OUT struct _DEBUG_EVENT *DebugEvent);
  42. HANDLE (NTAPI* DbgUiGetThreadDebugObject)
  43. (VOID);
  44. NTSTATUS (NTAPI* DbgUiIssueRemoteBreakin)
  45. (IN HANDLE Process);
  46. VOID (NTAPI* DbgUiSetThreadDebugObject)
  47. (IN HANDLE DebugObject);
  48. NTSTATUS (NTAPI* NtAllocateVirtualMemory)
  49. (IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress,
  50. IN ULONG_PTR ZeroBits, IN OUT PSIZE_T RegionSize,
  51. IN ULONG AllocationType, IN ULONG Protect);
  52. NTSTATUS (NTAPI* NtClose)
  53. (IN HANDLE Handle);
  54. NTSTATUS (NTAPI* NtCreateDebugObject)
  55. (OUT PHANDLE DebugObjectHandle, IN ACCESS_MASK DesiredAccess,
  56. IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG Flags);
  57. NTSTATUS (NTAPI* NtDebugActiveProcess)
  58. (IN HANDLE ProcessHandle, IN HANDLE DebugObjectHandle);
  59. NTSTATUS (NTAPI* NtDebugContinue)
  60. (IN HANDLE DebugObjectHandle, IN PCLIENT_ID ClientId,
  61. IN NTSTATUS ContinueStatus);
  62. NTSTATUS (NTAPI* NtFreeVirtualMemory)
  63. (IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress,
  64. IN OUT PSIZE_T RegionSize, IN ULONG FreeType);
  65. NTSTATUS (NTAPI* NtOpenProcess)
  66. (OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess,
  67. IN POBJECT_ATTRIBUTES ObjectAttributes,
  68. IN PCLIENT_ID ClientId OPTIONAL);
  69. NTSTATUS (NTAPI* NtOpenThread)
  70. (OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess,
  71. IN POBJECT_ATTRIBUTES ObjectAttributes,
  72. IN PCLIENT_ID ClientId OPTIONAL);
  73. NTSTATUS (NTAPI* NtQueryInformationProcess)
  74. (IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass,
  75. OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength,
  76. OUT PULONG ReturnLength OPTIONAL);
  77. NTSTATUS (NTAPI* NtQueryInformationThread)
  78. (IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass,
  79. OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength,
  80. OUT PULONG ReturnLength OPTIONAL);
  81. NTSTATUS (NTAPI* NtQueryObject)
  82. (IN HANDLE Handle, IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
  83. OUT PVOID ObjectInformation, IN ULONG Length,
  84. OUT PULONG ReturnLength OPTIONAL);
  85. NTSTATUS (NTAPI* NtQuerySystemInformation)
  86. (IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
  87. OUT PVOID SystemInformation, IN ULONG SystemInformationLength,
  88. OUT PULONG ReturnLength OPTIONAL);
  89. NTSTATUS (NTAPI* NtRemoveProcessDebug)
  90. (IN HANDLE ProcessHandle, IN HANDLE DebugObjectHandle);
  91. NTSTATUS (NTAPI* NtSetInformationDebugObject)
  92. (IN HANDLE DebugObjectHandle,
  93. IN DEBUGOBJECTINFOCLASS DebugObjectInformationClass,
  94. IN PVOID DebugInformation, IN ULONG DebugInformationLength,
  95. OUT PULONG ReturnLength OPTIONAL);
  96. NTSTATUS (NTAPI* NtSetInformationProcess)
  97. (IN HANDLE ProcessHandle,
  98. IN PROCESSINFOCLASS ProcessInformationClass,
  99. IN PVOID ProcessInformation, IN ULONG ProcessInformationLength);
  100. NTSTATUS (NTAPI* NtSystemDebugControl)
  101. (IN SYSDBG_COMMAND Command, IN PVOID InputBuffer,
  102. IN ULONG InputBufferLength, OUT PVOID OutputBuffer,
  103. IN ULONG OutputBufferLength, OUT PULONG ReturnLength);
  104. NTSTATUS (NTAPI* NtWaitForDebugEvent)
  105. (IN HANDLE DebugObjectHandle, IN BOOLEAN Alertable,
  106. IN PLARGE_INTEGER Timeout OPTIONAL,
  107. OUT PDBGUI_WAIT_STATE_CHANGE WaitStateChange);
  108. BOOLEAN (NTAPI* RtlFreeHeap)
  109. (IN PVOID HeapHandle, IN ULONG Flags, IN PVOID BaseAddress);
  110. PLIST_ENTRY (NTAPI* RtlGetFunctionTableListHead)
  111. (VOID);
  112. BOOLEAN (NTAPI* RtlTryEnterCriticalSection)
  113. (PRTL_CRITICAL_SECTION CriticalSection);
  114. NTSTATUS (NTAPI* RtlUnicodeStringToAnsiString)
  115. (PANSI_STRING DestinationString, PCUNICODE_STRING SourceString,
  116. BOOLEAN AllocateDestinationString);
  117. } NTDLL_CALLS;
  118. extern NTDLL_CALLS g_NtDllCalls;
  119. extern DYNAMIC_CALLS_DESC g_NtDllCallsDesc;
  120. // Calls from kernel32.dll.
  121. typedef struct _KERNEL32_CALLS
  122. {
  123. HANDLE (WINAPI* CreateToolhelp32Snapshot)
  124. (DWORD dwFlags, DWORD th32ProcessID);
  125. BOOL (WINAPI* DebugActiveProcessStop)
  126. (DWORD ProcessId);
  127. VOID (WINAPI* DebugBreak)
  128. (VOID);
  129. BOOL (WINAPI* DebugBreakProcess)
  130. (HANDLE Process);
  131. BOOL (WINAPI* DebugSetProcessKillOnExit)
  132. (BOOL KillOnExit);
  133. BOOL (WINAPI* Module32First)
  134. (HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  135. BOOL (WINAPI* Module32Next)
  136. (HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  137. BOOL (WINAPI* Process32First)
  138. (HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  139. BOOL (WINAPI* Process32Next)
  140. (HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  141. BOOL (WINAPI* Thread32First)
  142. (HANDLE hSnapshot, LPTHREADENTRY32 lpte);
  143. BOOL (WINAPI* Thread32Next)
  144. (HANDLE hSnapshot, LPTHREADENTRY32 lpte);
  145. } KERNEL32_CALLS;
  146. extern KERNEL32_CALLS g_Kernel32Calls;
  147. extern DYNAMIC_CALLS_DESC g_Kernel32CallsDesc;
  148. // Calls from user32.dll.
  149. typedef struct _USER32_CALLS
  150. {
  151. void (WINAPI* PrivateKDBreakPoint)
  152. (void);
  153. } USER32_CALLS;
  154. extern USER32_CALLS g_User32Calls;
  155. extern DYNAMIC_CALLS_DESC g_User32CallsDesc;
  156. // Calls from ole32.dll.
  157. typedef struct _OLE32_CALLS
  158. {
  159. HRESULT (STDAPICALLTYPE* CLSIDFromString)
  160. (IN LPOLESTR lpsz, OUT LPCLSID pclsid);
  161. HRESULT (STDAPICALLTYPE* CoCreateInstance)
  162. (IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
  163. IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv);
  164. HRESULT (STDAPICALLTYPE* CoInitializeEx)
  165. (void * pvReserved, DWORD dwCoInit);
  166. void (STDAPICALLTYPE* CoUninitialize)
  167. (void);
  168. } OLE32_CALLS;
  169. extern OLE32_CALLS g_Ole32Calls;
  170. extern DYNAMIC_CALLS_DESC g_Ole32CallsDesc;
  171. // Calls from oleaut32.dll.
  172. typedef struct _OLEAUT32_CALLS
  173. {
  174. void (STDAPICALLTYPE* SysFreeString)
  175. (BSTR Str);
  176. } OLEAUT32_CALLS;
  177. extern OLEAUT32_CALLS g_OleAut32Calls;
  178. extern DYNAMIC_CALLS_DESC g_OleAut32CallsDesc;
  179. // Calls from security.dll.
  180. extern SecurityFunctionTable g_SecurityFunc;
  181. // Calls from crypt32.dll.
  182. typedef struct _CRYPT32_CALLS
  183. {
  184. PCCERT_CONTEXT (WINAPI* CertFindCertificateInStore)
  185. (IN HCERTSTORE hCertStore,
  186. IN DWORD dwCertEncodingType,
  187. IN DWORD dwFindFlags,
  188. IN DWORD dwFindType,
  189. IN const void *pvFindPara,
  190. IN PCCERT_CONTEXT pPrevCertContext);
  191. PCCERT_CHAIN_CONTEXT (WINAPI* CertFindChainInStore)
  192. (IN HCERTSTORE hCertStore,
  193. IN DWORD dwCertEncodingType,
  194. IN DWORD dwFindFlags,
  195. IN DWORD dwFindType,
  196. IN const void *pvFindPara,
  197. IN PCCERT_CHAIN_CONTEXT pPrevChainContext);
  198. VOID (WINAPI* CertFreeCertificateChain)
  199. (IN PCCERT_CHAIN_CONTEXT pChainContext);
  200. BOOL (WINAPI* CertFreeCertificateContext)
  201. (IN PCCERT_CONTEXT pCertContext);
  202. BOOL (WINAPI* CertGetCertificateChain)
  203. (IN OPTIONAL HCERTCHAINENGINE hChainEngine,
  204. IN PCCERT_CONTEXT pCertContext,
  205. IN OPTIONAL LPFILETIME pTime,
  206. IN OPTIONAL HCERTSTORE hAdditionalStore,
  207. IN PCERT_CHAIN_PARA pChainPara,
  208. IN DWORD dwFlags,
  209. IN LPVOID pvReserved,
  210. OUT PCCERT_CHAIN_CONTEXT* ppChainContext);
  211. HCERTSTORE (WINAPI* CertOpenStore)
  212. (IN LPCSTR lpszStoreProvider,
  213. IN DWORD dwEncodingType,
  214. IN HCRYPTPROV hCryptProv,
  215. IN DWORD dwFlags,
  216. IN const void *pvPara);
  217. HCERTSTORE (WINAPI* CertOpenSystemStoreA)
  218. (HCRYPTPROV hProv,
  219. LPCSTR szSubsystemProtocol);
  220. BOOL (WINAPI* CertVerifyCertificateChainPolicy)
  221. (IN LPCSTR pszPolicyOID,
  222. IN PCCERT_CHAIN_CONTEXT pChainContext,
  223. IN PCERT_CHAIN_POLICY_PARA pPolicyPara,
  224. IN OUT PCERT_CHAIN_POLICY_STATUS pPolicyStatus);
  225. } CRYPT32_CALLS;
  226. extern CRYPT32_CALLS g_Crypt32Calls;
  227. extern DYNAMIC_CALLS_DESC g_Crypt32CallsDesc;
  228. // Calls from advapi32.dll.
  229. typedef struct _ADVAPI32_CALLS
  230. {
  231. BOOL (WINAPI* EnumServicesStatusExA)
  232. (SC_HANDLE hSCManager,
  233. SC_ENUM_TYPE InfoLevel,
  234. DWORD dwServiceType,
  235. DWORD dwServiceState,
  236. LPBYTE lpServices,
  237. DWORD cbBufSize,
  238. LPDWORD pcbBytesNeeded,
  239. LPDWORD lpServicesReturned,
  240. LPDWORD lpResumeHandle,
  241. LPCSTR pszGroupName);
  242. SC_HANDLE (WINAPI* OpenSCManagerA)
  243. (LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess);
  244. } ADVAPI32_CALLS;
  245. extern ADVAPI32_CALLS g_Advapi32Calls;
  246. extern DYNAMIC_CALLS_DESC g_Advapi32CallsDesc;
  247. HRESULT InitDynamicCalls(DYNAMIC_CALLS_DESC* Desc);
  248. #endif // #ifndef __DLLIMP_H__