阅读:815回复:1
WDM的问题
各位大虾:
为什么通过databuffer=ExAllocatePoolWithTag()分配的内存,我将databuffer上传给应用程序,但这个地址(databuffer)应用程序却不能访问?有什么办法分配一块内存,然后通过RtlCopyMemory考入数据,并将地址传给应用程序,应用程序能够访问? |
|
沙发#
发布于:2003-12-18 17:20
用这个函数有一些注意点, 不知你有没有注意到,~_~
摘自MSDN: PVOID ExAllocatePoolWithTag( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag ); Parameters PoolType Specifies the type of pool memory to allocate. See POOL_TYPE for a description of the available pool memory types. NumberOfBytes Specifies the number of bytes to allocate. Tag Specifies a string, delimited by single quote marks, with up to four characters. The string is usually specified in reversed order. Include wdm.h or ntddk.h Return Value ExAllocatePoolWithTag returns NULL if there is insufficient memory in the free pool to satisfy the request. Otherwise the routine returns a pointer to the allocated memory. Comments A call to this routine is equivalent to calling ExAllocatePool, except that ExAllocatePoolWithTag inserts a caller-supplied tag before the allocation. This tag appears in any crash dump of the system that occurs. During driver development on a checked build of the system, this routine can be useful for debugging system crashes. Calling this routine, rather than ExAllocatePool, inserts the caller-supplied tag into a crash dump of pool memory. The Tag passed to this routine is more readable if its bytes are reversed when this routine is called. For example, if a caller passes \'Fred\' as a Tag, it would appear as \'derF\' if pool is dumped or when tracking pool usage in the debugger. Callers of ExAllocatePoolWithTag, like callers of ExAllocatePool, can be running at IRQL DISPATCH_LEVEL only if the requested PoolType is one of the NonPagedXxx. Otherwise, callers must be running at IRQL < DISPATCH_LEVEL |
|