[RPCRT4][CRT]

- Do not omit the last argument to VirtualProtect, it will cause the function to fail

svn path=/trunk/; revision=63636
This commit is contained in:
Thomas Faber 2014-06-23 20:39:49 +00:00
parent 63861e09a4
commit f5c9dd0ad6
3 changed files with 6 additions and 3 deletions

View file

@ -175,13 +175,14 @@ static const struct thunk *allocate_block( unsigned int num )
{
unsigned int i;
struct thunk *prev, *block;
DWORD oldprot;
block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
if (!block) return NULL;
for (i = 0; i < BLOCK_SIZE; i++) init_thunk( &block[i], BLOCK_SIZE * num + i + 3 );
VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, NULL );
VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot );
prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
if (prev) /* someone beat us to it */
{

View file

@ -176,6 +176,7 @@ static const vtbl_method_t *allocate_block( unsigned int num )
{
unsigned int i;
vtbl_method_t *prev, *block;
DWORD oldprot;
block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
@ -186,7 +187,7 @@ static const vtbl_method_t *allocate_block( unsigned int num )
memcpy( &block[i], opcodes, sizeof(opcodes) );
block[i].offset = (BLOCK_SIZE * num + i + 3) * sizeof(void *);
}
VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, NULL );
VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot );
prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
if (prev) /* someone beat us to it */
{

View file

@ -38,7 +38,8 @@ void _chkesp_failed(void)
int CDECL _resetstkoflw(void)
{
int stack_addr;
DWORD oldprot;
/* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
return VirtualProtect( &stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, NULL );
return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
}