site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=OyvRg37YIBv0qXFqtRk55oy/3l60Gthv/9PNg3CuCxT/NZ6VcGlIOEiijPR1TFL2XswhqUmf8xpg76HPBysqb1HBTzxmwlHfJ+pfQ+l4n6RkfmsmnrGobftjiY/SeGkLB649qWQrwQKXidDh/2gSu6zq4+VeWWTXgmPpajdhP3I= ; Hi Alex, I had a similar need for an underlying Win32 function (IsBadReadPtr and it's bretheren). I ended up poaching some ideas from the MoreIsBetter stack backtrace code. I bet there's another more [efficient, elegant, effective, etc] way to accomplish this, but hey, it seems to work. cheers, Brendan Creane Boolean memIsValid(vm_address_t addr, size_t numOfBytes) { vm_address_t dstPtr = (vm_address_t)malloc(numOfBytes); mach_port_t thisTask = mach_task_self(); vm_size_t sizeRead = numOfBytes; int err; err = vm_read_overwrite(thisTask, addr, numOfBytes, dstPtr, &sizeRead); if (err == noErr && sizeRead != numOfBytes) err = -1; return (err == noErr); }
Hi All, On the PC (Visual Studio), there is a call for testing valid memory AfxIsValidAddress( ) - "Tests any memory address to ensure that it is contained entirely within the program's memory space." This function also takes a read/write parameter. Is there a similar function on MacOSX/Xcode?
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com