From 014706ea0167cecaeae4d48f469c60cc69a3aa78 Mon Sep 17 00:00:00 2001 From: tongzeyu <499601364@qq.com> Date: Fri, 14 Nov 2014 12:56:20 +0800 Subject: [PATCH] Update system_dll.py GetMappedFileNameA may call fail --- system_dll.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system_dll.py b/system_dll.py index f3970f0..e9395f4 100644 --- a/system_dll.py +++ b/system_dll.py @@ -92,8 +92,9 @@ def __init__ (self, handle, base): if file_ptr: # query for the filename of the mapped file. filename = create_string_buffer(2048) - psapi.GetMappedFileNameA(kernel32.GetCurrentProcess(), file_ptr, byref(filename), 2048) - + filename_length = psapi.GetMappedFileNameA(kernel32.GetCurrentProcess(), file_ptr, byref(filename), 2048) + if filename_length == 0: + return # store the full path. this is kind of ghetto, but i didn't want to mess with QueryDosDevice() etc ... self.path = os.sep + filename.value.split(os.sep, 3)[3] @@ -115,4 +116,4 @@ def __del__ (self): Close the handle. ''' - kernel32.CloseHandle(self.handle) \ No newline at end of file + kernel32.CloseHandle(self.handle)