PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/mordor/runtime_linking.h

http://github.com/mozy/mordor
C Header | 59 lines | 52 code | 6 blank | 1 comment | 1 complexity | b818f79f1a1b460f14232a49f850025f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #ifndef __MORDOR_RUNTIME_LINKING_H__
  2. #define __MORDOR_RUNTIME_LINKING_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include <dbghelp.h>
  5. #include <IPHlpApi.h>
  6. #include <lm.h>
  7. #include <winhttp.h>
  8. #include <winsock2.h>
  9. #include <ws2tcpip.h>
  10. #define MORDOR_RUNTIME_LINK_DECLARATION(Name, ReturnType, CallingConvention, ArgTypes) \
  11. typedef ReturnType (CallingConvention * LPFN_##Name) ArgTypes; \
  12. extern LPFN_##Name p##Name;
  13. #define MORDOR_RUNTIME_LINK_DEFINITION(Name, ReturnType, CallingConvention, ArgTypes, Args, Library)\
  14. static ReturnType CallingConvention Name##NotImpl ArgTypes; \
  15. static ReturnType CallingConvention Name##Thunk ArgTypes \
  16. { \
  17. HINSTANCE hInstance = LoadLibraryW(Library); \
  18. p##Name = (LPFN_##Name)GetProcAddress(hInstance, #Name); \
  19. if (!p##Name) \
  20. p##Name = &Name##NotImpl; \
  21. return p##Name Args; \
  22. } \
  23. LPFN_##Name p##Name = &Name##Thunk; \
  24. static ReturnType CallingConvention Name##NotImpl ArgTypes
  25. namespace Mordor {
  26. MORDOR_RUNTIME_LINK_DECLARATION(CancelIoEx, BOOL, WINAPI, (HANDLE, LPOVERLAPPED));
  27. MORDOR_RUNTIME_LINK_DECLARATION(ConvertFiberToThread, BOOL, WINAPI, (VOID));
  28. MORDOR_RUNTIME_LINK_DECLARATION(CreateFiberEx, LPVOID, WINAPI, (SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID));
  29. MORDOR_RUNTIME_LINK_DECLARATION(FindFirstStreamW, HANDLE, WINAPI, (LPCWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD));
  30. MORDOR_RUNTIME_LINK_DECLARATION(FindNextStreamW, BOOL, APIENTRY, (HANDLE, LPVOID));
  31. MORDOR_RUNTIME_LINK_DECLARATION(FlsAlloc, DWORD, WINAPI, (PFLS_CALLBACK_FUNCTION));
  32. MORDOR_RUNTIME_LINK_DECLARATION(FlsFree, BOOL, WINAPI, (DWORD));
  33. MORDOR_RUNTIME_LINK_DECLARATION(FlsGetValue, PVOID, WINAPI, (DWORD));
  34. MORDOR_RUNTIME_LINK_DECLARATION(FlsSetValue, BOOL, WINAPI, (DWORD, PVOID));
  35. MORDOR_RUNTIME_LINK_DECLARATION(FreeAddrInfoW, VOID, WSAAPI, (PADDRINFOW));
  36. MORDOR_RUNTIME_LINK_DECLARATION(GetAdaptersAddresses, ULONG, WINAPI, (ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG));
  37. MORDOR_RUNTIME_LINK_DECLARATION(GetAddrInfoW, INT, WSAAPI, (PCWSTR, PCWSTR, const ADDRINFOW *, PADDRINFOW *));
  38. MORDOR_RUNTIME_LINK_DECLARATION(GetQueuedCompletionStatusEx, BOOL, WINAPI, (HANDLE, LPOVERLAPPED_ENTRY, ULONG, PULONG, DWORD, BOOL));
  39. MORDOR_RUNTIME_LINK_DECLARATION(IsThreadAFiber, BOOL, WINAPI, (VOID));
  40. MORDOR_RUNTIME_LINK_DECLARATION(RtlCaptureStackBackTrace, WORD, NTAPI, (DWORD, DWORD, PVOID *, PDWORD));
  41. MORDOR_RUNTIME_LINK_DECLARATION(RtlNtStatusToDosError, ULONG, NTAPI, (NTSTATUS));
  42. MORDOR_RUNTIME_LINK_DECLARATION(SetFileCompletionNotificationModes, BOOL, WINAPI, (HANDLE, UCHAR));
  43. MORDOR_RUNTIME_LINK_DECLARATION(SymFromAddr, BOOL, __stdcall, (HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO));
  44. MORDOR_RUNTIME_LINK_DECLARATION(SymGetLineFromAddr64, BOOL, __stdcall, (HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64));
  45. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpCloseHandle, BOOL, WINAPI, (HINTERNET));
  46. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpGetDefaultProxyConfiguration, BOOL, WINAPI, (WINHTTP_PROXY_INFO *));
  47. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpGetIEProxyConfigForCurrentUser, BOOL, WINAPI, (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *));
  48. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpGetProxyForUrl, BOOL, WINAPI, (HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS *, WINHTTP_PROXY_INFO *));
  49. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpDetectAutoProxyConfigUrl, BOOL, WINAPI, (DWORD, LPWSTR *));
  50. MORDOR_RUNTIME_LINK_DECLARATION(WinHttpOpen, HINTERNET, WINAPI, (LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD));
  51. MORDOR_RUNTIME_LINK_DECLARATION(inet_pton, INT, WSAAPI, (INT, PCSTR, PVOID));
  52. }
  53. #endif