Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame^] | 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 |
|
| 35 | .MODEL small
|
| 36 |
|
| 37 | .CODE
|
| 38 |
|
| 39 | TooShortFunction PROC
|
| 40 | ret
|
| 41 | TooShortFunction ENDP
|
| 42 |
|
| 43 | JumpShortCondFunction PROC
|
| 44 | test cl, 1
|
| 45 | jnz jumpspot
|
| 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 | int 3
|
| 71 | int 3
|
| 72 | int 3
|
| 73 | int 3
|
| 74 | jumpspot:
|
| 75 | nop
|
| 76 | nop
|
| 77 | nop
|
| 78 | nop
|
| 79 | mov rax, 1
|
| 80 | ret
|
| 81 | JumpShortCondFunction ENDP
|
| 82 |
|
| 83 | JumpNearCondFunction PROC
|
| 84 | test cl, 1
|
| 85 | jnz jumpspot
|
| 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 | mov rdx, 0ffff1111H
|
| 102 | mov rdx, 0ffff1111H
|
| 103 | mov rdx, 0ffff1111H
|
| 104 | mov rdx, 0ffff1111H
|
| 105 | mov rdx, 0ffff1111H
|
| 106 | jumpspot:
|
| 107 | nop
|
| 108 | nop
|
| 109 | mov rax, 1
|
| 110 | ret
|
| 111 | JumpNearCondFunction ENDP
|
| 112 |
|
| 113 | JumpAbsoluteFunction PROC
|
| 114 | test cl, 1
|
| 115 | jmp jumpspot
|
| 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 | mov rdx, 0ffff1111H
|
| 138 | mov rdx, 0ffff1111H
|
| 139 | mov rdx, 0ffff1111H
|
| 140 | mov rdx, 0ffff1111H
|
| 141 | mov rdx, 0ffff1111H
|
| 142 | mov rdx, 0ffff1111H
|
| 143 | jumpspot:
|
| 144 | nop
|
| 145 | nop
|
| 146 | mov rax, 1
|
| 147 | ret
|
| 148 | JumpAbsoluteFunction ENDP
|
| 149 |
|
| 150 | CallNearRelativeFunction PROC
|
| 151 | test cl, 1
|
| 152 | call TooShortFunction
|
| 153 | mov rdx, 0ffff1111H
|
| 154 | mov rdx, 0ffff1111H
|
| 155 | mov rdx, 0ffff1111H
|
| 156 | mov rdx, 0ffff1111H
|
| 157 | mov rdx, 0ffff1111H
|
| 158 | mov rdx, 0ffff1111H
|
| 159 | mov rdx, 0ffff1111H
|
| 160 | mov rdx, 0ffff1111H
|
| 161 | mov rdx, 0ffff1111H
|
| 162 | mov rdx, 0ffff1111H
|
| 163 | nop
|
| 164 | nop
|
| 165 | nop
|
| 166 | ret
|
| 167 | CallNearRelativeFunction ENDP
|
| 168 |
|
| 169 | END
|