Skip to content

Commit 21e259f

Browse files
committed
Update some doc/samples for new module/features
1 parent db44087 commit 21e259f

8 files changed

Lines changed: 93 additions & 14 deletions

File tree

docs/source/conf.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import sys
1616
import os
17+
import sphinx
18+
import docutils
1719

1820
# If extensions (or modules to document with autodoc) are in another directory,
1921
# add these directories to sys.path here. If the directory is relative to the
@@ -45,6 +47,7 @@
4547
]
4648

4749
autodoc_default_flags = ['inherited-members']
50+
# autodoc_member_order = "groupwise"
4851
todo_include_todos = True
4952

5053
# Add any paths that contain templates here, relative to this directory.
@@ -375,5 +378,30 @@ def get_rst(app, what, name, obj, options, lines):
375378
def get_rst2(app, what, name, obj, options, signature, return_annotation):
376379
pass
377380

381+
382+
# Test code to handle :class:`gdef.STRUCTURE_NAME`
383+
# demo of custom xref for not-found structures
384+
# Test was for ref to 'SECURITY_DESCRIPTOR_CONTROL' in SecurityDescriptor.control
385+
def miss_ref(app, env, node, contnode):
386+
# import pdb;pdb.set_trace()
387+
if not node["reftype"] == "class":
388+
return
389+
print(node, node["reftype"], node["reftarget"], contnode)
390+
# import pdb;pdb.set_trace()
391+
392+
if "SECURITY_DESCRIPTOR_CONTROL" not in node["reftarget"]:
393+
return
394+
395+
res = docutils.nodes.reference("", "")
396+
py_domain = env.domains["py"]
397+
full_name = "windows.generated_def.winstructs.{0}".format(node["reftarget"].rsplit(".", 1)[-1])
398+
t = [x for x in py_domain.get_objects() if full_name == x[0]][0]
399+
res["refdocname"] = node["refdoc"]
400+
res.append(contnode)
401+
uri = app.builder.get_relative_uri(node["refdoc"], t[3])
402+
res['refuri'] = "{0}#{1}".format(uri, t[0])
403+
return res
404+
378405
def setup(app):
379406
app.add_stylesheet('css/mbasic.css') # may also be an URL
407+
# app.connect('missing-reference', miss_ref)

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You can install PythonForWindows using the ``setup.py`` at the root of the proje
3535
python setup.py install
3636

3737
In its current state the project only support Python2 and
38-
``setup.py`` will raise an :class:`NotImplementedError` is launched from python3.
38+
``setup.py`` will raise an :class:`NotImplementedError` if launched from python3.
3939

4040

4141
.. warning::
@@ -54,6 +54,7 @@ Documentation
5454
winobject.rst
5555
native_exec.rst
5656
winproxy.rst
57+
security.rst
5758
pipe.rst
5859
utils.rst
5960
wintrust.rst

docs/source/process.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ WinThread
5050
:show-inheritance:
5151
:inherited-members:
5252

53-
Token
54-
'''''
55-
56-
.. autoclass:: Token
57-
:members:
58-
:inherited-members:
5953

6054

6155
PEB Exploration

docs/source/sample.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ Output
6767
.. literalinclude:: samples_output\process_iat_hook.txt
6868

6969

70+
.. _token_sample:
71+
72+
Token
73+
"""""
74+
75+
.. literalinclude:: ..\..\samples\token\token_demo.py
76+
77+
Output
78+
79+
.. literalinclude:: samples_output\token_token_demo.txt
80+
81+
7082
.. _sample_system:
7183

7284

@@ -226,6 +238,17 @@ Output
226238

227239
.. literalinclude:: samples_output\debug_debugger_print_LdrLoaddll.txt
228240

241+
.. _sample_debugger_on_setup:
242+
243+
on_setup
244+
~~~~~~~~
245+
246+
.. literalinclude:: ..\..\samples\debug\debugger_on_setup.py
247+
248+
249+
Output
250+
251+
.. literalinclude:: samples_output\debug_debugger_on_setup.txt
229252

230253

231254
Single stepping
@@ -523,3 +546,28 @@ Output
523546

524547
.. literalinclude:: samples_output\pipe_child_send_object.txt
525548

549+
550+
.. _sample_security:
551+
552+
:mod:`windows.security`
553+
"""""""""""""""""""""""
554+
555+
Security Descriptor
556+
'''''''''''''''''''
557+
558+
.. literalinclude:: ..\..\samples\security\security_descriptor.py
559+
560+
Output
561+
562+
.. literalinclude:: samples_output\security_security_descriptor.txt
563+
564+
.. _sample_security_sacl:
565+
566+
Query SACL
567+
''''''''''
568+
569+
.. literalinclude:: ..\..\samples\security\query_sacl.py
570+
571+
Output
572+
573+
.. literalinclude:: samples_output\security_query_sacl.txt

docs/source/security.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
1313
.. module:: windows.security
1414

15+
This module give access to :class:`SecurityDescriptor` and related structures (``Acl`` & ``Ace``).
16+
17+
.. note::
18+
19+
See sample :ref:`sample_security`
20+
1521

1622
SecurityDescriptor
1723
""""""""""""""""""
@@ -218,36 +224,36 @@ SystemProcessTrustLabelACE
218224

219225

220226
Ace common base
221-
"""""""""""""""
227+
'''''''''''''''
222228

223229
These classes are internals and here for completness sake.
224230
You should not need to instanciate/use them directly.
225231

226232
AceHeader
227-
'''''''''
233+
~~~~~~~~~
228234

229235
.. autoclass:: AceHeader
230236

231237
AceBase
232-
'''''''
238+
~~~~~~~
233239

234240
.. autoclass:: AceBase
235241

236242

237243
MaskAndSidACE
238-
'''''''''''''
244+
~~~~~~~~~~~~~
239245

240246
.. autoclass:: MaskAndSidACE
241247

242248

243249
CallbackACE
244-
'''''''''''
250+
~~~~~~~~~~~
245251

246252
.. autoclass:: CallbackACE
247253

248254

249255
ObjectRelatedACE
250-
''''''''''''''''
256+
~~~~~~~~~~~~~~~~
251257

252258
.. autoclass:: ObjectRelatedACE
253259

docs/source/windows.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The submodules that you might use by themself are:
1616
* :mod:`windows.native_exec`
1717
* :mod:`windows.winproxy`
1818
* :mod:`windows.wintrust`
19+
* :mod:`windows.security`
1920
* :mod:`windows.crypto`
2021
* :mod:`windows.utils`
2122
* :mod:`windows.debug`

docs/source/winobject.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This sections describes them by group of relation.
1010
:maxdepth: 3
1111

1212
process.rst
13+
token.rst
1314
exception.rst
1415
registry.rst
1516
network.rst

windows/security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class SecurityDescriptor(gdef.PSECURITY_DESCRIPTOR):
597597
598598
To query the SACL enable the ``SeSecurityPrivilege`` and use the parameter ``query_sacl=True`` on the functions expecting a ``flags``
599599
600-
see SACL sample
600+
see :ref:`Query SACL sample <sample_security_sacl>`
601601
"""
602602

603603
_close_function = winproxy.LocalFree

0 commit comments

Comments
 (0)