mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Add com sample + update readme/todo
This commit is contained in:
@@ -129,9 +129,41 @@ To extract/play with even more information about the system, PythonForWindows is
|
||||
(u'"C:\\Python27\\python.exe"', 227)
|
||||
```
|
||||
|
||||
### Registry
|
||||
|
||||
The project also contains some wrapping classes around `_winreg` for simpler use.
|
||||
|
||||
```python
|
||||
>>> import windows
|
||||
>>> from windows.generated_def import KEY_WRITE, KEY_READ, REG_QWORD
|
||||
>>> registry = windows.system.registry
|
||||
>>> cuuser_software = registry(r'HKEY_CURRENT_USER\Software')
|
||||
>>> cuuser_software
|
||||
<PyHKey "HKEY_CURRENT_USER\Software">
|
||||
>>> cuuser_software.sam
|
||||
KEY_READ(0x20019L)
|
||||
# Explore subkeys
|
||||
>>> cuuser_software.subkeys[:3]
|
||||
[<PyHKey "HKEY_CURRENT_USER\Software\7-Zip">, <PyHKey "HKEY_CURRENT_USER\Software\AppDataLow">, <PyHKey "HKEY_CURRENT_USER\Software\Audacity">]
|
||||
>>> tstkey = registry('HKEY_CURRENT_USER\TestKey', KEY_WRITE | KEY_READ)
|
||||
# Get / Set individual value
|
||||
>>> tstkey["VALUE"] = 'a_value_for_my_key'
|
||||
>>> tstkey["VALUE"]
|
||||
KeyValue(name='VALUE', value=u'a_value_for_my_key', type=1)
|
||||
>>> tstkey["MYQWORD"] = (123456789987654321, REG_QWORD) # Default is REG_DWORD for int/long
|
||||
>>> tstkey["MYQWORD"]
|
||||
KeyValue(name='MYQWORD', value=123456789987654321L, type=11)
|
||||
# Explore Values
|
||||
>>> tstkey.values
|
||||
[KeyValue(name='MYQWORD', value=123456789987654321L, type=11), KeyValue(name='VALUE', value=u'a_value_for_my_key', type=1)]
|
||||
|
||||
|
||||
|
||||
```
|
||||
### Other stuff (see doc / samples)
|
||||
|
||||
- Registry
|
||||
- Debugger
|
||||
- LocalDebugger (VEH based)
|
||||
- Network
|
||||
- Services
|
||||
- COM
|
||||
|
||||
@@ -20,7 +20,6 @@ TODO:
|
||||
- Add test for debugger with breakpoint that add another breakpoint on trigger
|
||||
|
||||
- Some test/doc on windows.system.handles
|
||||
- Some test/doc on debugger and MemBP
|
||||
|
||||
- registry
|
||||
- test !
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import sys
|
||||
import os.path
|
||||
import pprint
|
||||
sys.path.append(os.path.abspath(__file__ + "\..\.."))
|
||||
|
||||
import windows
|
||||
import windows.generated_def as gdef
|
||||
from windows.generated_def import interfaces
|
||||
|
||||
# This code is a simple version of the firewall code in windows.winoject.network
|
||||
print("Initialisation of COM")
|
||||
windows.com.init()
|
||||
print("Creating INetFwPolicy2 variable")
|
||||
firewall = interfaces.INetFwPolicy2()
|
||||
print("{0} (value = {1})".format(firewall, firewall.value))
|
||||
print("")
|
||||
|
||||
print("Generating CLSID")
|
||||
NetFwPolicy2CLSID = windows.com.IID.from_string("E2B3C97F-6AE1-41AC-817A-F6F92166D7DD")
|
||||
print(NetFwPolicy2CLSID)
|
||||
print("")
|
||||
|
||||
print("Creating COM instance")
|
||||
windows.com.create_instance(NetFwPolicy2CLSID, firewall)
|
||||
print("{0} (value = 0x{1:0})".format(firewall, firewall.value))
|
||||
print("")
|
||||
|
||||
print("Checking for enabled profiles")
|
||||
for profile in [gdef.NET_FW_PROFILE2_DOMAIN, gdef.NET_FW_PROFILE2_PRIVATE, gdef.NET_FW_PROFILE2_PUBLIC]:
|
||||
enabled = gdef.VARIANT_BOOL()
|
||||
firewall.get_FirewallEnabled(profile, enabled)
|
||||
print(" * {0} -> {1}".format(profile, enabled.value))
|
||||
@@ -11,7 +11,6 @@ import windows.native_exec.simple_x86 as x86
|
||||
from windows.generated_def.winstructs import *
|
||||
|
||||
|
||||
|
||||
class MyDebugger(windows.debug.Debugger):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MyDebugger, self).__init__(*args, **kwargs)
|
||||
@@ -41,6 +40,7 @@ class SingleStepOnWrite(windows.debug.MemoryBreakpoint):
|
||||
dbg.single_step_counter = 4
|
||||
return dbg.single_step()
|
||||
|
||||
|
||||
calc = windows.test.pop_calc_32(dwCreationFlags=DEBUG_PROCESS)
|
||||
d = MyDebugger(calc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user