Commit da23da39 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl.exe: Allocate pool memory from an executable heap.

parent 6a6081fc
...@@ -78,6 +78,8 @@ static DWORD request_thread; ...@@ -78,6 +78,8 @@ static DWORD request_thread;
/* tid of the client thread */ /* tid of the client thread */
static DWORD client_tid; static DWORD client_tid;
static HANDLE ntoskrnl_heap;
struct wine_driver struct wine_driver
{ {
DRIVER_OBJECT driver_obj; DRIVER_OBJECT driver_obj;
...@@ -1998,7 +2000,7 @@ PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size ) ...@@ -1998,7 +2000,7 @@ PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size )
PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag ) PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag )
{ {
/* FIXME: handle page alignment constraints */ /* FIXME: handle page alignment constraints */
void *ret = HeapAlloc( GetProcessHeap(), 0, size ); void *ret = HeapAlloc( ntoskrnl_heap, 0, size );
TRACE( "%lu pool %u -> %p\n", size, type, ret ); TRACE( "%lu pool %u -> %p\n", size, type, ret );
return ret; return ret;
} }
...@@ -2040,7 +2042,7 @@ void WINAPI ExFreePool( void *ptr ) ...@@ -2040,7 +2042,7 @@ void WINAPI ExFreePool( void *ptr )
void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag ) void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
{ {
TRACE( "%p\n", ptr ); TRACE( "%p\n", ptr );
HeapFree( GetProcessHeap(), 0, ptr ); HeapFree( ntoskrnl_heap, 0, ptr );
} }
static void initialize_lookaside_list( GENERAL_LOOKASIDE *lookaside, PALLOCATE_FUNCTION allocate, PFREE_FUNCTION free, static void initialize_lookaside_list( GENERAL_LOOKASIDE *lookaside, PALLOCATE_FUNCTION allocate, PFREE_FUNCTION free,
...@@ -3067,9 +3069,11 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) ...@@ -3067,9 +3069,11 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
#endif #endif
KeQueryTickCount( &count ); /* initialize the global KeTickCount */ KeQueryTickCount( &count ); /* initialize the global KeTickCount */
NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber; NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber;
ntoskrnl_heap = HeapCreate( HEAP_CREATE_ENABLE_EXECUTE, 0, 0 );
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (reserved) break; if (reserved) break;
HeapDestroy( ntoskrnl_heap );
RtlRemoveVectoredExceptionHandler( handler ); RtlRemoveVectoredExceptionHandler( handler );
break; break;
} }
......
...@@ -1685,6 +1685,26 @@ static void WINAPI main_test_task(DEVICE_OBJECT *device, void *context) ...@@ -1685,6 +1685,26 @@ static void WINAPI main_test_task(DEVICE_OBJECT *device, void *context)
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
} }
#if defined(__i386__) || defined(__x86_64__)
static void test_executable_pool(void)
{
static const unsigned char bytes[] =
{ 0xb8, 0xef, 0xbe, 0xad, 0xde, 0xc3 }; /* mov $0xdeadbeef,%eax ; ret */
static const ULONG tag = 0x74736574; /* test */
int (*func)(void);
int ret;
func = ExAllocatePoolWithTag(NonPagedPool, sizeof(bytes), tag);
ok(!!func, "Got NULL memory.\n");
memcpy(func, bytes, sizeof(bytes));
ret = func();
ok(ret == 0xdeadbeef, "Got %#x.\n", ret);
ExFreePoolWithTag(func, tag);
}
#endif
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack) static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
{ {
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
...@@ -1735,6 +1755,9 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st ...@@ -1735,6 +1755,9 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
test_lookup_thread(); test_lookup_thread();
test_IoAttachDeviceToDeviceStack(); test_IoAttachDeviceToDeviceStack();
test_object_name(); test_object_name();
#if defined(__i386__) || defined(__x86_64__)
test_executable_pool();
#endif
if (main_test_work_item) return STATUS_UNEXPECTED_IO_ERROR; if (main_test_work_item) return STATUS_UNEXPECTED_IO_ERROR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment