I don't mean to copy an arbitrary large chunk, but to do the regex on where the pointer points. I guess you can't do that directly in Perl either (I got C on the brain from reading XS).
The module doesn't leak because the GlobalLock function isn't used, so there is no need to unlock either. I was thinking (before reading the code) that you must call GlobalLock, copy the data, then unlock, then return your copy. So returning the original pointer would be either a stale reference or a leak. Under the assumption that the handle is represented simply as a pointer to shared memory, that's not a problem. However, I don't like to make assumptions not in (or contrary to) the documentation.