Skip to content
Permalink
Browse files

Fix #193 (use RtlMoveMemory instead of msvcrt.memcpy)

  • Loading branch information
akx authored and bitprophet committed Oct 25, 2013
1 parent 698adf1 commit d8738b1b0f10e2f70ac69c3e3dbf10e496c8a67f
Showing with 6 additions and 6 deletions.
  1. +6 −6 paramiko/_winapi.py
@@ -81,9 +81,6 @@ def handle_nonzero_success(result):
raise WindowsError()


#####################
# jaraco.windows.mmap

CreateFileMapping = ctypes.windll.kernel32.CreateFileMappingW
CreateFileMapping.argtypes = [
ctypes.wintypes.HANDLE,
@@ -130,15 +127,18 @@ def seek(self, pos):
self.pos = pos

def write(self, msg):
ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
self.pos += len(msg)
n = len(msg)
if self.pos + n >= self.length: # A little safety.
raise ValueError("Refusing to write %d bytes" % n)
ctypes.windll.kernel32.RtlMoveMemory(self.view + self.pos, msg, n)
self.pos += n

def read(self, n):
"""
Read n bytes from mapped view.
"""
out = ctypes.create_string_buffer(n)
ctypes.windll.msvcrt.memcpy(out, self.view + self.pos, n)
ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n)
self.pos += n
return out.raw

0 comments on commit d8738b1

Please sign in to comment.
You can’t perform that action at this time.