Fixed unprotect_buffer().

This commit is contained in:
n-a-c-h 2008-05-27 15:35:03 +00:00
parent b06aeaf9dc
commit 550aebf08c
2 changed files with 14 additions and 13 deletions

View File

@ -16,18 +16,19 @@ int ExecutableValid(const char *executable_filename)
#else #else
void unprotect_buf(char *buffer, size_t buffer_len) char *unprotect_buffer(char *buffer, size_t buffer_len)
{ {
char *end_p = buffer+buffer_len, previous = 0x11; char *p = buffer, *end_p = p+buffer_len-1, previous = 0x11;
while (buffer < end_p) while (p < end_p)
{ {
char current = *buffer; char current = *p;
*buffer ^= previous; *p ^= previous;
previous = current; previous = current;
*buffer -= 25; *p -= 25;
*buffer ^= 0x87; *p ^= 0x87;
++buffer; ++p;
} }
return(buffer);
} }
static uint8_t *memmem(const uint8_t *haystack, size_t haystacklen, const uint8_t *needle, size_t needlelen) static uint8_t *memmem(const uint8_t *haystack, size_t haystacklen, const uint8_t *needle, size_t needlelen)

View File

@ -8,7 +8,7 @@ extern "C" {
//Returns 0 on success, 1 on failure, and <0 when an error occured //Returns 0 on success, 1 on failure, and <0 when an error occured
//Note, can only be called once per execution //Note, can only be called once per execution
int ExecutableValid(const char *executable_filename); int ExecutableValid(const char *executable_filename);
void unprotect_buf(char *buffer, size_t buffer_len) char *unprotect_buffer(char *buffer, size_t buffer_len);
#if defined(__cplusplus) #if defined(__cplusplus)
} }