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
void unprotect_buf(char *buffer, size_t buffer_len)
{
char *end_p = buffer+buffer_len, previous = 0x11;
while (buffer < end_p)
{
char current = *buffer;
*buffer ^= previous;
previous = current;
*buffer -= 25;
*buffer ^= 0x87;
++buffer;
}
char *unprotect_buffer(char *buffer, size_t buffer_len)
{
char *p = buffer, *end_p = p+buffer_len-1, previous = 0x11;
while (p < end_p)
{
char current = *p;
*p ^= previous;
previous = current;
*p -= 25;
*p ^= 0x87;
++p;
}
return(buffer);
}
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
//Note, can only be called once per execution
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)
}