aboutsummaryrefslogtreecommitdiff
path: root/subhook_unix.c
diff options
context:
space:
mode:
authorZeex <zeex@rocketmail.com>2018-09-03 20:08:52 +0600
committerZeex <zeex@rocketmail.com>2018-09-03 20:10:28 +0600
commit12b527d6426276681536d685520daf0318fbcf13 (patch)
tree861508e36ddd0de4be235d3b82ea76b4018f43b9 /subhook_unix.c
parent504fce580e9300c3400c3275fabda72b39a363e2 (diff)
downloadsubhook-12b527d6426276681536d685520daf0318fbcf13.zip
subhook-12b527d6426276681536d685520daf0318fbcf13.tar.gz
subhook-12b527d6426276681536d685520daf0318fbcf13.tar.bz2
Clean up and improve comments
* Replace SUBHOOK_BITS equality comparisons with SUBHOOK_X86_64 macro definition checks (less error-prone) * Improve comments in subhook_disasm() and remove unused variable (address_size) * Update copyright year across all files
Diffstat (limited to 'subhook_unix.c')
-rw-r--r--subhook_unix.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/subhook_unix.c b/subhook_unix.c
index e074f20..1c5260d 100644
--- a/subhook_unix.c
+++ b/subhook_unix.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015 Zeex
+/* Copyright (c) 2012-2018 Zeex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,9 +33,9 @@ void *subhook_unprotect(void *address, size_t size) {
pagesize = sysconf(_SC_PAGESIZE);
address = (void *)((long)address & ~(pagesize - 1));
- if (mprotect(address, size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
+ if (mprotect(address, size, PROT_READ | PROT_WRITE | PROT_EXEC) == 0) {
+ return address;
+ } else {
return NULL;
}
-
- return address;
}