JnHelperMethod.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. 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. #if _CONTROL_FLOW_GUARD_SHADOW_STACK
  18. extern "C" void __guard_ss_verify_failure();
  19. #endif
  20. namespace IR
  21. {
  22. enum JnHelperMethod
  23. {
  24. #define HELPERCALL(Name, Address, Attributes) Helper##Name,
  25. #include "JnHelperMethodList.h"
  26. #undef HELPERCALL
  27. JnHelperMethodCount
  28. };
  29. class HelperCallOpnd;
  30. // Verify the table is read-only.
  31. void CheckJnHelperTable(intptr_t const *table);
  32. // Return address of the helper which can be intercepted by debugger wrapper.
  33. intptr_t GetMethodAddress(ThreadContextInfo * context, HelperCallOpnd* opnd);
  34. intptr_t GetNonTableMethodAddress(ThreadContextInfo * context, JnHelperMethod helperMethod);
  35. // Returns the original address of the helper, this one is never the intercepted by debugger helper.
  36. intptr_t GetMethodOriginalAddress(ThreadContextInfo * context, JnHelperMethod helperMethod);
  37. #if DBG_DUMP || defined(ENABLE_IR_VIEWER)
  38. char16 const* GetMethodName(JnHelperMethod helperMethod);
  39. #endif
  40. } // namespace IR.
  41. namespace HelperMethodAttributes
  42. {
  43. // [Flags]
  44. enum HelperMethodAttribute : BYTE
  45. {
  46. AttrNone = 0x00,
  47. AttrCanThrow = 0x01, // Can throw non-OOM / non-SO exceptions. Under debugger / Fast F12, these helpers are wrapped with try-catch wrapper.
  48. AttrInVariant = 0x02, // The method is "const" method that can be hoisted.
  49. };
  50. bool CanThrow(IR::JnHelperMethod helper);
  51. bool IsInVariant(IR::JnHelperMethod helper);
  52. } // namespace HelperMethodAttributes.