Skip to content

Commit 930c992

Browse files
committed
Working on improving crypto stuff
1 parent f6e151a commit 930c992

10 files changed

Lines changed: 304 additions & 70 deletions

File tree

ctypes_generation/definitions/winfunc_crypto_wintrust.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,8 @@ BOOL WINAPI CertCompareCertificate(
319319
_In_ PCERT_INFO pCertId1,
320320
_In_ PCERT_INFO pCertId2
321321
);
322+
323+
PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(
324+
_In_ HCERTSTORE hCertStore,
325+
_In_ PCCTL_CONTEXT pPrevCtlContext
326+
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class _CRYPTOAPI_BLOB(_CRYPTOAPI_BLOB):
2+
@classmethod
3+
def from_string(cls, buf):
4+
self = cls()
5+
self.cbData = len(buf)
6+
self.pbData = (BYTE * self.cbData)(*bytearray(buf))
7+
return self
8+
9+
@property
10+
def data(self):
11+
return bytearray(self.pbData[:self.cbData])

ctypes_generation/generate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
dedent = textwrap.dedent
1717

1818

19+
1920
TYPE_EQUIVALENCE = [
2021
# BYTE is defined in ctypes.wintypes as c_byte but who wants
2122
# BYTE to be signed ? (from MSDN: <typedef unsigned char BYTE;>)
@@ -258,8 +259,6 @@ def generate_doc(self, target_file):
258259
with open(target_file, "w") as f:
259260
f.writelines(all_lines)
260261

261-
EXTENDED_STRUCT = ["_GUID", "_RPC_IF_ID"] # TODO: check auto the dir
262-
263262
class StructGenerator(CtypesGenerator):
264263
PARSER = struct_parser.WinStructParser
265264
IMPORT_HEADER = dedent ("""
@@ -723,6 +722,10 @@ class DefGenerator(InitialDefGenerator):
723722
print(SCRIPT_DIR)
724723
from_here = lambda path: pjoin(SCRIPT_DIR, path)
725724

725+
726+
EXTENDED_STRUCT_FILE = glob.glob(pjoin(SCRIPT_DIR, "extended_structs", "*.py"))
727+
EXTENDED_STRUCT = [os.path.basename(filename)[:-len(".py")] for filename in EXTENDED_STRUCT_FILE]
728+
726729
DEFAULT_INTERFACE_TO_IID = from_here("definitions\\interface_to_iid.txt")
727730

728731
# A partial define without the dependance to ntstatus defintion

docs/source/winstructs_generated.rst

Lines changed: 175 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,6 +5480,181 @@ _CRYPTOAPI_BLOB
54805480

54815481
:class:`BYTE`
54825482

5483+
CRYPTCATATTRIBUTE_
5484+
''''''''''''''''''
5485+
.. class:: CRYPTCATATTRIBUTE
5486+
5487+
Alias for :class:`CRYPTCATATTRIBUTE_`
5488+
5489+
.. class:: PCRYPTCATATTRIBUTE
5490+
5491+
Pointer to :class:`CRYPTCATATTRIBUTE_`
5492+
5493+
.. class:: CRYPTCATATTRIBUTE_
5494+
5495+
.. attribute:: cbStruct
5496+
5497+
:class:`DWORD`
5498+
5499+
5500+
.. attribute:: pwszReferenceTag
5501+
5502+
:class:`LPWSTR`
5503+
5504+
5505+
.. attribute:: dwAttrTypeAndAction
5506+
5507+
:class:`DWORD`
5508+
5509+
5510+
.. attribute:: cbValue
5511+
5512+
:class:`DWORD`
5513+
5514+
5515+
.. attribute:: pbValue
5516+
5517+
:class:`BYTE`
5518+
5519+
5520+
.. attribute:: dwReserved
5521+
5522+
:class:`DWORD`
5523+
5524+
_CRYPT_ATTRIBUTE_TYPE_VALUE
5525+
'''''''''''''''''''''''''''
5526+
.. class:: CRYPT_ATTRIBUTE_TYPE_VALUE
5527+
5528+
Alias for :class:`_CRYPT_ATTRIBUTE_TYPE_VALUE`
5529+
5530+
.. class:: PCRYPT_ATTRIBUTE_TYPE_VALUE
5531+
5532+
Pointer to :class:`_CRYPT_ATTRIBUTE_TYPE_VALUE`
5533+
5534+
.. class:: _CRYPT_ATTRIBUTE_TYPE_VALUE
5535+
5536+
.. attribute:: pszObjId
5537+
5538+
:class:`LPSTR`
5539+
5540+
5541+
.. attribute:: Value
5542+
5543+
:class:`CRYPT_OBJID_BLOB`
5544+
5545+
_CRYPT_ALGORITHM_IDENTIFIER
5546+
'''''''''''''''''''''''''''
5547+
.. class:: CRYPT_ALGORITHM_IDENTIFIER
5548+
5549+
Alias for :class:`_CRYPT_ALGORITHM_IDENTIFIER`
5550+
5551+
.. class:: PCRYPT_ALGORITHM_IDENTIFIER
5552+
5553+
Pointer to :class:`_CRYPT_ALGORITHM_IDENTIFIER`
5554+
5555+
.. class:: _CRYPT_ALGORITHM_IDENTIFIER
5556+
5557+
.. attribute:: pszObjId
5558+
5559+
:class:`LPSTR`
5560+
5561+
5562+
.. attribute:: Parameters
5563+
5564+
:class:`CRYPT_OBJID_BLOB`
5565+
5566+
SIP_INDIRECT_DATA_
5567+
''''''''''''''''''
5568+
.. class:: SIP_INDIRECT_DATA
5569+
5570+
Alias for :class:`SIP_INDIRECT_DATA_`
5571+
5572+
.. class:: PSIP_INDIRECT_DATA
5573+
5574+
Pointer to :class:`SIP_INDIRECT_DATA_`
5575+
5576+
.. class:: SIP_INDIRECT_DATA_
5577+
5578+
.. attribute:: Data
5579+
5580+
:class:`CRYPT_ATTRIBUTE_TYPE_VALUE`
5581+
5582+
5583+
.. attribute:: DigestAlgorithm
5584+
5585+
:class:`CRYPT_ALGORITHM_IDENTIFIER`
5586+
5587+
5588+
.. attribute:: Digest
5589+
5590+
:class:`CRYPT_HASH_BLOB`
5591+
5592+
CRYPTCATMEMBER_
5593+
'''''''''''''''
5594+
.. class:: CRYPTCATMEMBER
5595+
5596+
Alias for :class:`CRYPTCATMEMBER_`
5597+
5598+
.. class:: PCRYPTCATMEMBER
5599+
5600+
Pointer to :class:`CRYPTCATMEMBER_`
5601+
5602+
.. class:: CRYPTCATMEMBER_
5603+
5604+
.. attribute:: cbStruct
5605+
5606+
:class:`DWORD`
5607+
5608+
5609+
.. attribute:: pwszReferenceTag
5610+
5611+
:class:`LPWSTR`
5612+
5613+
5614+
.. attribute:: pwszFileName
5615+
5616+
:class:`LPWSTR`
5617+
5618+
5619+
.. attribute:: gSubjectType
5620+
5621+
:class:`GUID`
5622+
5623+
5624+
.. attribute:: fdwMemberFlags
5625+
5626+
:class:`DWORD`
5627+
5628+
5629+
.. attribute:: pIndirectData
5630+
5631+
:class:`SIP_INDIRECT_DATA`
5632+
5633+
5634+
.. attribute:: dwCertVersion
5635+
5636+
:class:`DWORD`
5637+
5638+
5639+
.. attribute:: dwReserved
5640+
5641+
:class:`DWORD`
5642+
5643+
5644+
.. attribute:: hReserved
5645+
5646+
:class:`HANDLE`
5647+
5648+
5649+
.. attribute:: sEncodedIndirectData
5650+
5651+
:class:`CRYPT_ATTR_BLOB`
5652+
5653+
5654+
.. attribute:: sEncodedMemberInfo
5655+
5656+
:class:`CRYPT_ATTR_BLOB`
5657+
54835658
WINTRUST_FILE_INFO_
54845659
'''''''''''''''''''
54855660
.. class:: WINTRUST_FILE_INFO
@@ -5610,27 +5785,6 @@ _CRYPT_ATTRIBUTES
56105785

56115786
:class:`PCRYPT_ATTRIBUTE`
56125787

5613-
_CRYPT_ALGORITHM_IDENTIFIER
5614-
'''''''''''''''''''''''''''
5615-
.. class:: CRYPT_ALGORITHM_IDENTIFIER
5616-
5617-
Alias for :class:`_CRYPT_ALGORITHM_IDENTIFIER`
5618-
5619-
.. class:: PCRYPT_ALGORITHM_IDENTIFIER
5620-
5621-
Pointer to :class:`_CRYPT_ALGORITHM_IDENTIFIER`
5622-
5623-
.. class:: _CRYPT_ALGORITHM_IDENTIFIER
5624-
5625-
.. attribute:: pszObjId
5626-
5627-
:class:`LPSTR`
5628-
5629-
5630-
.. attribute:: Parameters
5631-
5632-
:class:`CRYPT_OBJID_BLOB`
5633-
56345788
_CMSG_SIGNER_INFO
56355789
'''''''''''''''''
56365790
.. class:: CMSG_SIGNER_INFO

0 commit comments

Comments
 (0)