python / python/cpython

[winreg] support options and opened disposition in CreateKeyEx and OpenKey[Ex]

Đang mở
#95,461 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

3.13 OS-windows type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

winreg.CreateKeyEx() should support the dwOptions and lpdwDisposition parameters of RegCreateKeyExW(), and winreg.OpenKey[Ex]() should support the ulOptions parameter of RegOpenKeyExW(). Also, the REG_LINK data type should be handled as a null-terminated Unicode string instead of as binary data.

The lpdwDisposition parameter can be supported indirectly by a new create_only parameter. If create_only is true and the opened disposition is REG_OPENED_EXISTING_KEY, close the handle and raise FileExistsError.

The dwOptions and ulOptions parameters can be supported as a new options parameter. Currently ulOptions is supported as a parameter named reserved, but RegOpenKeyExW() has been documented to support it since 2015. Unofficially, RegOpenKeyExW() first implemented support for REG_OPTION_OPEN_LINK in NT 4.0 (1996). The misnamed reserved parameter has to be retained for compatibility, but options should override it.

For example:

CreateKeyEx(key, sub_key, reserved=0, access=KEY_WRITE, options=0, create_only=False)
OpenKeyEx(key, sub_key, reserved=0, access=KEY_READ, options=0)

RegCreateKeyExW() supports the following options:

  • REG_OPTION_VOLATILE: create a dynamic key in memory that's never persisted to a hive file. This is useful for keys that should always be newly created for each session (e.g. "HKCU\Volatile Environment") or for test cases that shouldn't permanently modify a hive.
  • REG_OPTION_CREATE_LINK: create a key symbolic link. The NT target path has to be set as a REG_LINK value named "SymbolicLinkValue". The registry API supports creating and modifying symbolic links, but deleting a symbolic link requires NTAPI NtDeleteKey(KeyHandle).
  • REG_OPTION_OPEN_LINK: open a symbolic link to modify its target path or to delete it via NtDeleteKey().
  • REG_OPTION_BACKUP_RESTORE: use backup semantics. If "SeBackupPrivilege" is enabled for the thread or process, then the open is granted read access and system security (SACL) access. If "SeRestorePrivilege" is enabled, then the open is granted write access, delete access, security access, and system security access. All access is granted if both privileges are enabled. If neither privilege is enabled, the call fails with access denied.
  • REG_OPTION_DONT_VIRTUALIZE: disable open, read, and write virtualization for non-admin, interactive logons in legacy 32-bit processes. This isn't relevant to a 32-bit "python[w].exe" process or any 32-bit application that has a "requestedExecutionLevel" in its manifest.

RegOpenKeyExW() supports the following options:

  • REG_OPTION_OPEN_LINK
  • REG_OPTION_BACKUP_RESTORE
  • REG_OPTION_DONT_VIRTUALIZE
Linked PRs
  • gh-129903

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ các điểm vào winreg.CreateKeyEx(), winreg.OpenKey() và winreg.OpenKeyEx() và so sánh các tham số của chúng với RegCreateKeyExW() và RegOpenKeyExW(). Xác nhận các tùy chọn được yêu cầu, hành vi của create_only và cách xử lý Unicode của REG_LINK, sau đó chạy các bài kiểm thử winreg liên quan để xác minh các trường hợp khóa mới, khóa hiện có và liên kết tượng trưng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
operating-systems
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.