shortproc.asm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ; Copyright (c) 2011, Google Inc.
  2. ; All rights reserved.
  3. ;
  4. ; Redistribution and use in source and binary forms, with or without
  5. ; modification, are permitted provided that the following conditions are
  6. ; met:
  7. ;
  8. ; * Redistributions of source code must retain the above copyright
  9. ; notice, this list of conditions and the following disclaimer.
  10. ; * Redistributions in binary form must reproduce the above
  11. ; copyright notice, this list of conditions and the following disclaimer
  12. ; in the documentation and/or other materials provided with the
  13. ; distribution.
  14. ; * Neither the name of Google Inc. nor the names of its
  15. ; contributors may be used to endorse or promote products derived from
  16. ; this software without specific prior written permission.
  17. ;
  18. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. ;
  30. ; ---
  31. ; Author: Scott Francis
  32. ;
  33. ; Unit tests for PreamblePatcher
  34. .MODEL small
  35. .CODE
  36. TooShortFunction PROC
  37. ret
  38. TooShortFunction ENDP
  39. JumpShortCondFunction PROC
  40. test cl, 1
  41. jnz jumpspot
  42. int 3
  43. int 3
  44. int 3
  45. int 3
  46. int 3
  47. int 3
  48. int 3
  49. int 3
  50. int 3
  51. int 3
  52. int 3
  53. int 3
  54. int 3
  55. int 3
  56. int 3
  57. int 3
  58. int 3
  59. int 3
  60. int 3
  61. int 3
  62. int 3
  63. int 3
  64. int 3
  65. int 3
  66. int 3
  67. int 3
  68. int 3
  69. int 3
  70. jumpspot:
  71. nop
  72. nop
  73. nop
  74. nop
  75. mov rax, 1
  76. ret
  77. JumpShortCondFunction ENDP
  78. JumpNearCondFunction PROC
  79. test cl, 1
  80. jnz jumpspot
  81. mov rdx, 0ffff1111H
  82. mov rdx, 0ffff1111H
  83. mov rdx, 0ffff1111H
  84. mov rdx, 0ffff1111H
  85. mov rdx, 0ffff1111H
  86. mov rdx, 0ffff1111H
  87. mov rdx, 0ffff1111H
  88. mov rdx, 0ffff1111H
  89. mov rdx, 0ffff1111H
  90. mov rdx, 0ffff1111H
  91. mov rdx, 0ffff1111H
  92. mov rdx, 0ffff1111H
  93. mov rdx, 0ffff1111H
  94. mov rdx, 0ffff1111H
  95. mov rdx, 0ffff1111H
  96. mov rdx, 0ffff1111H
  97. mov rdx, 0ffff1111H
  98. mov rdx, 0ffff1111H
  99. mov rdx, 0ffff1111H
  100. mov rdx, 0ffff1111H
  101. jumpspot:
  102. nop
  103. nop
  104. mov rax, 1
  105. ret
  106. JumpNearCondFunction ENDP
  107. JumpAbsoluteFunction PROC
  108. test cl, 1
  109. jmp jumpspot
  110. mov rdx, 0ffff1111H
  111. mov rdx, 0ffff1111H
  112. mov rdx, 0ffff1111H
  113. mov rdx, 0ffff1111H
  114. mov rdx, 0ffff1111H
  115. mov rdx, 0ffff1111H
  116. mov rdx, 0ffff1111H
  117. mov rdx, 0ffff1111H
  118. mov rdx, 0ffff1111H
  119. mov rdx, 0ffff1111H
  120. mov rdx, 0ffff1111H
  121. mov rdx, 0ffff1111H
  122. mov rdx, 0ffff1111H
  123. mov rdx, 0ffff1111H
  124. mov rdx, 0ffff1111H
  125. mov rdx, 0ffff1111H
  126. mov rdx, 0ffff1111H
  127. mov rdx, 0ffff1111H
  128. mov rdx, 0ffff1111H
  129. mov rdx, 0ffff1111H
  130. mov rdx, 0ffff1111H
  131. mov rdx, 0ffff1111H
  132. mov rdx, 0ffff1111H
  133. mov rdx, 0ffff1111H
  134. mov rdx, 0ffff1111H
  135. mov rdx, 0ffff1111H
  136. mov rdx, 0ffff1111H
  137. jumpspot:
  138. nop
  139. nop
  140. mov rax, 1
  141. ret
  142. JumpAbsoluteFunction ENDP
  143. CallNearRelativeFunction PROC
  144. test cl, 1
  145. call TooShortFunction
  146. mov rdx, 0ffff1111H
  147. mov rdx, 0ffff1111H
  148. mov rdx, 0ffff1111H
  149. mov rdx, 0ffff1111H
  150. mov rdx, 0ffff1111H
  151. mov rdx, 0ffff1111H
  152. mov rdx, 0ffff1111H
  153. mov rdx, 0ffff1111H
  154. mov rdx, 0ffff1111H
  155. mov rdx, 0ffff1111H
  156. nop
  157. nop
  158. nop
  159. ret
  160. CallNearRelativeFunction ENDP
  161. END