JnHelperMethod.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. extern "C"
  7. {
  8. #ifdef _M_IX86
  9. DECLSPEC_CHPE_GUEST void __cdecl _chkstk(int);
  10. #else
  11. void __cdecl __chkstk(int);
  12. #endif
  13. }
  14. #ifdef _CONTROL_FLOW_GUARD
  15. extern "C" PVOID __guard_check_icall_fptr;
  16. #endif
  17. namespace IR
  18. {
  19. enum JnHelperMethod
  20. {
  21. #define HELPERCALL(Name, Address, Attributes) Helper##Name,
  22. #include "JnHelperMethodList.h"
  23. #undef HELPERCALL
  24. JnHelperMethodCount
  25. };
  26. class HelperCallOpnd;
  27. // Verify the table is read-only.
  28. void CheckJnHelperTable(intptr_t const *table);
  29. // Return address of the helper which can be intercepted by debugger wrapper.
  30. intptr_t GetMethodAddress(ThreadContextInfo * context, HelperCallOpnd* opnd);
  31. intptr_t GetNonTableMethodAddress(ThreadContextInfo * context, JnHelperMethod helperMethod);
  32. // Returns the original address of the helper, this one is never the intercepted by debugger helper.
  33. intptr_t GetMethodOriginalAddress(ThreadContextInfo * context, JnHelperMethod helperMethod);
  34. #if DBG_DUMP || defined(ENABLE_IR_VIEWER)
  35. char16 const* GetMethodName(JnHelperMethod helperMethod);
  36. #endif
  37. } // namespace IR.
  38. namespace HelperMethodAttributes
  39. {
  40. // [Flags]
  41. enum HelperMethodAttribute : BYTE
  42. {
  43. AttrNone = 0x00,
  44. AttrCanThrow = 0x01, // Can throw non-OOM / non-SO exceptions. Under debugger / Fast F12, these helpers are wrapped with try-catch wrapper.
  45. AttrInVariant = 0x02, // The method is "const" method that can be hoisted.
  46. };
  47. bool CanThrow(IR::JnHelperMethod helper);
  48. bool IsInVariant(IR::JnHelperMethod helper);
  49. } // namespace HelperMethodAttributes.