Skip to content

Commit 2094ab4

Browse files
committed
Fix some docstring + re-add windows.test.pop_proc_[32|64] + fix all samples + few doc adapt
1 parent c7fef87 commit 2094ab4

21 files changed

+78
-78
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ You can find some examples of code in the [samples directory][SAMPLE_DIR] or [on
1414

1515
Parts of PythonForWindows are used in the [LKD project][LKD_GITHUB].
1616

17+
If you have any issue, question, suggestion do not hesitate to contact me.
18+
I am always glad to have feedbacks from people using this project.
19+
1720
## Overview
1821

1922
### Processes / Threads
@@ -102,7 +105,7 @@ So the features is present (See [online documentation][ONLINE_IATHOOK] about IAT
102105
### Winproxy
103106

104107
A wrapper around some Windows functions. Arguments name and order are the same,
105-
but some have default values and the functions raise exception on call error (I don't like 'if' around all my call).
108+
but some have default values and the functions raise exception on call error (I don't like `if` around all my call).
106109

107110
```python
108111
>>> import windows
@@ -150,8 +153,8 @@ windows.winproxy.Kernel32Error: VirtualAlloc: [Error 8] Not enough storage is av
150153

151154
### Native execution
152155

153-
To make the barrier between `native` and `Python` code,
154-
PythonForWindows allows you to create native function callable from Python (thanks `ctypes`) and also embed
156+
To make the barrier between `native` and `Python` code thinner,
157+
PythonForWindows allows you to create native function callable from Python (thanks to `ctypes`) and also embed
155158
a simple x86/x64 assembler.
156159

157160
```python

ctypes_generation/definitions/winstruct.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,6 @@ typedef enum _SID_NAME_USE {
489489
SidTypeLabel = 10
490490
} SID_NAME_USE, *PSID_NAME_USE;
491491

492-
typedef enum NET_FW_PROFILE_TYPE2_ {
493-
NET_FW_PROFILE2_DOMAIN = 0x1,
494-
NET_FW_PROFILE2_PRIVATE = 0x2,
495-
NET_FW_PROFILE2_PUBLIC = 0x4,
496-
NET_FW_PROFILE2_ALL = 0x7fffffff
497-
} NET_FW_PROFILE_TYPE2;
498-
499492
typedef enum NET_FW_ACTION_ {
500493
NET_FW_ACTION_BLOCK = 0,
501494
NET_FW_ACTION_ALLOW = 1,
@@ -508,13 +501,6 @@ typedef enum NET_FW_MODIFY_STATE_ {
508501
NET_FW_MODIFY_STATE_INBOUND_BLOCKED = 2
509502
} NET_FW_MODIFY_STATE;
510503

511-
typedef enum NET_FW_RULE_DIRECTION_ {
512-
NET_FW_RULE_DIR_IN = 1,
513-
NET_FW_RULE_DIR_OUT = 2 ,
514-
NET_FW_RULE_DIR_MAX = 3
515-
} NET_FW_RULE_DIRECTION;
516-
517-
518504

519505
typedef enum tag_WBEMSTATUS {
520506
WBEM_NO_ERROR = 0,

ctypes_generation/generate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def generate(self):
252252
return ctypes_code
253253

254254
def generate_doc(self, target_file):
255-
all_lines = [".. currentmodule:: windows.generated_def\n"
255+
all_lines = [".. currentmodule:: windows.generated_def\n\n"
256256
"Windef\n"
257257
"------\n"]
258258
all_lines += [".. autodata:: {windef.name}\n".format(windef=windef) for windef in self.parse()]
@@ -356,7 +356,7 @@ def append_input_file(self, filename):
356356
self.check_dependances()
357357

358358
def generate_doc(self, target_file):
359-
all_lines = [".. currentmodule:: windows.generated_def\n"
359+
all_lines = [".. currentmodule:: windows.generated_def\n\n"
360360
"Winstructs\n"
361361
"----------\n"]
362362
struct_separator = "'"
@@ -494,7 +494,7 @@ def generate(self):
494494
return ctypes_code
495495

496496
def generate_doc(self, target_file):
497-
all_lines = [".. currentmodule:: windows.generated_def\n"
497+
all_lines = [".. currentmodule:: windows.generated_def\n\n"
498498
"Ntstatus\n"
499499
"--------\n"]
500500
all_lines += [".. autodata:: {nstatus_name}\n".format(nstatus_name=nstatus[1]) for nstatus in self.parse()]

docs/source/testing.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

samples/crypto/certificate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,23 @@
6767
print("Not found :(")
6868

6969
## Extract certificates of a PE file
70+
## This code is not a fixed API and the current state of my tests
7071

7172
print ("")
7273
print ("== PE Analysis ==")
7374
TARGET_FILE = r"C:\windows\system32\ntdll.dll"
7475
print("Target sha1 = <{0}>".format(hashlib.sha1(open(TARGET_FILE, "rb").read()).hexdigest()))
7576
cryptobj = windows.crypto.CryptObject(TARGET_FILE)
7677
print("Analysing {0}".format(cryptobj))
77-
print("File has {0} signer(s):".format(cryptobj.nb_signer))
78-
for i, signer in ((i, cryptobj.get_signer_data(i)) for i in range(cryptobj.nb_signer)):
78+
print("File has {0} signer(s):".format(cryptobj.crypt_msg.nb_signer))
79+
for i, signer in enumerate(cryptobj.crypt_msg.signers):
7980
print("Signer {0}:".format(i))
8081
print(" * Issuer: {0!r}".format(windows.crypto.ECRYPT_DATA_BLOB(signer.Issuer.cbData, signer.Issuer.pbData).data))
8182
print(" * HashAlgorithme: {0}".format(signer.HashAlgorithm.pszObjId))
82-
cert = cryptobj.get_signer_certificate(i)
83+
cert = cryptobj.cert_store.find(signer.Issuer, signer.SerialNumber)
8384
print(" * Certificate: {0}".format(cert))
8485

8586
print("")
86-
print("File embdeds {0} certificate(s):".format(cryptobj.nb_cert))
87-
for i, certificate in ((i, cryptobj.get_cert(i)) for i in range(cryptobj.nb_cert)):
87+
print("File embdeds {0} certificate(s):".format(cryptobj.crypt_msg.nb_cert))
88+
for i, certificate in enumerate(cryptobj.crypt_msg.certs):
8889
print(" * {0}) {1}".format(i, certificate))

samples/debug/attach.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ def follow_create_file(pid):
2525

2626
if __name__ == "__main__":
2727
# Create a non-debugged process safe to debug
28-
calc = windows.test.pop_calc_32(dwCreationFlags=0)
28+
calc = windows.test.pop_proc_32(dwCreationFlags=0)
2929
# Give ovnly the PID to follow_create_file
3030
follow_create_file(calc.pid)

samples/debug/debug_functionbp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def ret_trigger(self, dbg, exc):
4242
self.COUNTER -= 1
4343

4444
if __name__ == "__main__":
45-
calc = windows.test.pop_calc_32(dwCreationFlags=DEBUG_PROCESS)
45+
calc = windows.test.pop_proc_32(dwCreationFlags=DEBUG_PROCESS)
4646
d = windows.debug.Debugger(calc)
4747
d.add_bp(FollowNtCreateFile())
4848
d.loop()

samples/debug/debugger_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ def on_rip(self, rip_info):
7171
pass
7272

7373

74-
calc = windows.test.pop_calc_32(dwCreationFlags=DEBUG_PROCESS)
74+
calc = windows.test.pop_proc_32(dwCreationFlags=DEBUG_PROCESS)
7575
d = MyDebugger(calc)
7676
d.loop()

samples/debug/debugger_membp_singlestep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def trigger(self, dbg, exc):
4343
return dbg.single_step()
4444

4545

46-
calc = windows.test.pop_calc_32(dwCreationFlags=DEBUG_PROCESS)
46+
calc = windows.test.pop_proc_32(dwCreationFlags=DEBUG_PROCESS)
4747
d = MyDebugger(calc)
4848

4949
code = calc.virtual_alloc(0x1000)

samples/debug/debugger_print_LdrLoaddll.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def trigger(self, dbg, exc):
3939
dbg.current_process.exit()
4040

4141

42-
calc = windows.test.pop_calc_32(dwCreationFlags=DEBUG_PROCESS)
42+
calc = windows.test.pop_proc_32(dwCreationFlags=DEBUG_PROCESS)
4343
d = MyDebugger(calc)
4444
d.add_bp(PrintUnicodeString("ntdll!LdrLoadDll", argument_position=2))
4545
d.loop()

0 commit comments

Comments
 (0)