mirror of
https://github.com/python/cpython.git
synced 2025-11-20 10:57:44 +00:00
bpo-38622: Add missing audit events for ctypes module (GH-17158)
This commit is contained in:
parent
476e76f7cf
commit
00923c6399
5 changed files with 106 additions and 7 deletions
|
|
@ -1526,6 +1526,12 @@ object is available:
|
|||
``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name``
|
||||
(the symbol's name as a string or integer).
|
||||
|
||||
.. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader
|
||||
|
||||
In cases when only the library handle is available rather than the object,
|
||||
accessing a function raises an auditing event ``ctypes.dlsym/handle`` with
|
||||
arguments ``handle`` (the raw library handle) and ``name``.
|
||||
|
||||
.. _ctypes-foreign-functions:
|
||||
|
||||
Foreign functions
|
||||
|
|
@ -1611,6 +1617,19 @@ They are instances of a private class:
|
|||
passed arguments.
|
||||
|
||||
|
||||
.. audit-event:: ctypes.seh_exception code foreign-functions
|
||||
|
||||
On Windows, when a foreign function call raises a system exception (for
|
||||
example, due to an access violation), it will be captured and replaced with
|
||||
a suitable Python exception. Further, an auditing event
|
||||
``ctypes.seh_exception`` with argument ``code`` will be raised, allowing an
|
||||
audit hook to replace the exception with its own.
|
||||
|
||||
.. audit-event:: ctypes.call_function func_pointer,arguments ctype-foreign-functions
|
||||
|
||||
Some ways to invoke foreign function calls may raise an auditing event
|
||||
``ctypes.call_function`` with arguments ``function pointer`` and ``arguments``.
|
||||
|
||||
.. _ctypes-function-prototypes:
|
||||
|
||||
Function prototypes
|
||||
|
|
@ -1802,6 +1821,8 @@ Utility functions
|
|||
Returns the address of the memory buffer as integer. *obj* must be an
|
||||
instance of a ctypes type.
|
||||
|
||||
.. audit-event:: ctypes.addressof obj ctypes.addressof
|
||||
|
||||
|
||||
.. function:: alignment(obj_or_type)
|
||||
|
||||
|
|
@ -1844,6 +1865,7 @@ Utility functions
|
|||
termination character. An integer can be passed as second argument which allows
|
||||
specifying the size of the array if the length of the bytes should not be used.
|
||||
|
||||
.. audit-event:: ctypes.create_string_buffer init,size ctypes.create_string_buffer
|
||||
|
||||
|
||||
.. function:: create_unicode_buffer(init_or_size, size=None)
|
||||
|
|
@ -1860,6 +1882,7 @@ Utility functions
|
|||
allows specifying the size of the array if the length of the string should not
|
||||
be used.
|
||||
|
||||
.. audit-event:: ctypes.create_unicode_buffer init,size ctypes.create_unicode_buffer
|
||||
|
||||
|
||||
.. function:: DllCanUnloadNow()
|
||||
|
|
@ -1917,11 +1940,15 @@ Utility functions
|
|||
Returns the current value of the ctypes-private copy of the system
|
||||
:data:`errno` variable in the calling thread.
|
||||
|
||||
.. audit-event:: ctypes.get_errno "" ctypes.get_errno
|
||||
|
||||
.. function:: get_last_error()
|
||||
|
||||
Windows only: returns the current value of the ctypes-private copy of the system
|
||||
:data:`LastError` variable in the calling thread.
|
||||
|
||||
.. audit-event:: ctypes.get_last_error "" ctypes.get_last_error
|
||||
|
||||
.. function:: memmove(dst, src, count)
|
||||
|
||||
Same as the standard C memmove library function: copies *count* bytes from
|
||||
|
|
@ -1965,6 +1992,7 @@ Utility functions
|
|||
Set the current value of the ctypes-private copy of the system :data:`errno`
|
||||
variable in the calling thread to *value* and return the previous value.
|
||||
|
||||
.. audit-event:: ctypes.set_errno errno ctypes.set_errno
|
||||
|
||||
|
||||
.. function:: set_last_error(value)
|
||||
|
|
@ -1973,6 +2001,7 @@ Utility functions
|
|||
:data:`LastError` variable in the calling thread to *value* and return the
|
||||
previous value.
|
||||
|
||||
.. audit-event:: ctypes.set_last_error error ctypes.set_last_error
|
||||
|
||||
|
||||
.. function:: sizeof(obj_or_type)
|
||||
|
|
@ -1987,6 +2016,8 @@ Utility functions
|
|||
object. If size is specified, it is used as size, otherwise the string is assumed
|
||||
to be zero-terminated.
|
||||
|
||||
.. audit-event:: ctypes.string_at address,size ctypes.string_at
|
||||
|
||||
|
||||
.. function:: WinError(code=None, descr=None)
|
||||
|
||||
|
|
@ -2007,6 +2038,8 @@ Utility functions
|
|||
characters of the string, otherwise the string is assumed to be
|
||||
zero-terminated.
|
||||
|
||||
.. audit-event:: ctypes.wstring_at address,size ctypes.wstring_at
|
||||
|
||||
|
||||
.. _ctypes-data-types:
|
||||
|
||||
|
|
@ -2034,6 +2067,7 @@ Data types
|
|||
source buffer in bytes; the default is zero. If the source buffer is not
|
||||
large enough a :exc:`ValueError` is raised.
|
||||
|
||||
.. audit-event:: ctypes.cdata/buffer pointer,size,offset ctypes._CData.from_buffer
|
||||
|
||||
.. method:: _CData.from_buffer_copy(source[, offset])
|
||||
|
||||
|
|
@ -2043,6 +2077,8 @@ Data types
|
|||
is zero. If the source buffer is not large enough a :exc:`ValueError` is
|
||||
raised.
|
||||
|
||||
.. audit-event:: ctypes.cdata/buffer pointer,size,offset ctypes._CData.from_buffer_copy
|
||||
|
||||
.. method:: from_address(address)
|
||||
|
||||
This method returns a ctypes type instance using the memory specified by
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue