mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Fixed ctypes_generation about some bugs on py3
This commit is contained in:
@@ -33,10 +33,14 @@ HANDLE WINAPI CreateFileW(
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Flags is directly dereferenced if non-null on windows 10
|
||||
Let's assert it's a PVOID for now on
|
||||
|
||||
*/
|
||||
NTSTATUS WINAPI LdrLoadDll(
|
||||
__in_opt LPCWSTR PathToFile,
|
||||
__in_opt ULONG Flags,
|
||||
__in_opt PVOID Flags,
|
||||
_In_ PUNICODE_STRING ModuleFileName,
|
||||
_Out_ PHANDLE ModuleHandle
|
||||
);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import sys
|
||||
import ctypes
|
||||
from .flag import Flag
|
||||
|
||||
is_py3 = (sys.version_info.major >= 3)
|
||||
|
||||
class NtStatusException(WindowsError):
|
||||
ALL_STATUS = {}
|
||||
def __init__(self , code):
|
||||
@@ -11,8 +14,12 @@ class NtStatusException(WindowsError):
|
||||
self.code = x[0]
|
||||
self.name = x[1]
|
||||
self.descr = x[2]
|
||||
x = ctypes.c_long(x[0]).value, x[1], x[2]
|
||||
return super(NtStatusException, self).__init__(*x)
|
||||
code_as_long = ctypes.c_long(x[0]).value
|
||||
if is_py3:
|
||||
vals = code_as_long, x[1], x[2], code_as_long
|
||||
else:
|
||||
vals = code_as_long, x[1], x[2]
|
||||
return super(NtStatusException, self).__init__(*vals)
|
||||
|
||||
def __str__(self):
|
||||
return "{e.name}(0x{e.code:x}): {e.descr}".format(e=self)
|
||||
|
||||
@@ -20,6 +20,11 @@ class _LSA_UNICODE_STRING(INITIAL_LSA_UNICODE_STRING):
|
||||
utf16_len = len(s) * 2
|
||||
return cls(utf16_len, utf16_len, ctypes.cast(PWSTR(s), PVOID))
|
||||
|
||||
@classmethod
|
||||
def from_size(cls, size):
|
||||
buffer = ctypes.create_string_buffer(size)
|
||||
return cls(size, size, ctypes.cast(buffer, PVOID))
|
||||
|
||||
def __repr__(self):
|
||||
return """<{0} "{1}" at {2}>""".format(type(self).__name__, self.str, hex(id(self)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user