Skip to content
Browse files

Remove the WRITE_INSTRUCTIONS api

  • Loading branch information...
1 parent 404078a commit 2ec6e748221170a325d43a448373eb0f89d9ea34 @ice799 committed Apr 26, 2010
Showing with 3 additions and 16 deletions.
  1. +3 −3 ext/x86_gen.c
  2. +0 −13 ext/x86_gen.h
View
6 ext/x86_gen.c
@@ -27,14 +27,14 @@ arch_insert_st1_tramp(void *start, void *trampee, void *tramp)
assert(tramp != NULL);
int32_t fn_addr = 0;
+ int32_t offset = 0;
struct st1_base *check = start;
if (check->call == 0xe8) {
fn_addr = check->displacement;
if ((trampee - (void *)(check + 1)) == fn_addr) {
- WRITE_INSTRUCTIONS(&check->displacement,
- sizeof(*check),
- (check->displacement = (tramp - (void *)(check + 1))));
+ offset = tramp - (void *)(check + 1);
+ copy_instructions(&check->displacement, &offset, sizeof(offset));
return 0;
}
}
View
13 ext/x86_gen.h
@@ -75,17 +75,4 @@ copy_instructions(void *dest, void *src, size_t count)
*/
return;
}
-
-/*
- * WRITE_INSTRUCTIONS - page align start, recalculate len to take into account
- * alignment, set the read/write permissions and execute the code stmt.
- */
-#define WRITE_INSTRUCTIONS(start, len, stmt) do { \
- void *aligned_addr = page_align((void *)start); \
- int count = ((void *)start) - aligned_addr + len; \
- mprotect(aligned_addr, count, PROT_READ | PROT_WRITE | PROT_EXEC); \
- stmt; \
- mprotect(aligned_addr, count, PROT_READ | PROT_EXEC); \
-} while (0)
-
#endif

0 comments on commit 2ec6e74

Please sign in to comment.
Something went wrong with that request. Please try again.