Conversation
Changes: 1) Created a new "injectdll" package 2) Formatted all *.py modules from the package 3) Refactoring CMakeLists.txt (fixed some paths to source files) 4) Created setup.py to generate Wheel on local computer (includes: build cmake for DLL (dotnet, hooks), copy to package directory after build) 5) Fixed license text
Changes: 1) New README 2) Cmake build for 32 and 64-bit platform
| description='A set of Python modules to inject DLls into applications for the Microsoft Windows', | ||
| keywords="windows gui .net inject testing test desktop dll wpf", | ||
| url="https://github.com/pywinauto/injected", | ||
| author='Mark Mc Mahon and Contributors', |
There was a problem hiding this comment.
Mark didn't participate in injectdll development, but I need to carefully review the code one more time to check if there is some code written by him a long time ago.
There was a problem hiding this comment.
Suggest use "(C) 2018-2023 Vasily Ryabov and NNSU (Lobachevsky University) students" instead current version.
There was a problem hiding this comment.
It's for file headers. Of course author field should omit (C) and years.
| self.dll_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), | ||
| 'backends', backend_name, | ||
| 'bin', 'x{}'.format("64" if is64bitprocess(self.pid) else "86"), | ||
| '../libs', backend_name, |
There was a problem hiding this comment.
It's better to use os.path.dirname(...) than using ../ which may be platform specific.
There was a problem hiding this comment.
Ok, will be fixed in next commits
| ## Development | ||
|
|
||
| 1. Clone repository: <https://github.com/pywinauto/injected.git> | ||
| 2. Create new features or improve exiting (for the injectdll package) |
There was a problem hiding this comment.
typo: exiting -> existing, but I would completely remove all "Development" steps or write "Issues and pull requests are welcome!"
There was a problem hiding this comment.
Ok, will be fixed in next commits
| author='Mark Mc Mahon and Contributors', | ||
| author_email='pywinauto@yandex.ru', | ||
| long_description=""" | ||
| It allows to inject DLls into applications for the Microsoft Windows. |
There was a problem hiding this comment.
DLls -> DLLs, or even suggest this:
This package can inject pre-built dynamic library into the target process and get some data from the application or do some actions (it depends on a used backend/library).
There was a problem hiding this comment.
Ok, will be fixed in next commits
|
|
||
| ## How to use | ||
|
|
||
| python.exe example_injector.py \<Process name\> \<path to dll\> |
There was a problem hiding this comment.
The script example_injector.py was removed
| @@ -0,0 +1,14 @@ | |||
| include injectdll/libs/dotnet/x86/bootstrap.dll | |||
There was a problem hiding this comment.
You can also remove *.dll files in this folder: https://github.com/pywinauto/injected/tree/master/backends/dotnet/bin
These files will not be needed after the injectdll wheels is available.
There was a problem hiding this comment.
Ok, It will be removed.
There was a problem hiding this comment.
I'm not sure about this point. Is this manifest not used for building wheels by setup.py?
There was a problem hiding this comment.
This manifest is OK, I meant that the pre-built DLLs in the bin folders will no longer be needed after merging this PR and having wheels.
| endif() | ||
|
|
||
| set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.0") | ||
| set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8") |
There was a problem hiding this comment.
Why did you increase the target .NET version?
In this case a subset of programs built with .NET Framework versions 4.0-4.8 will not be supported by this backend.
There was a problem hiding this comment.
While debugging, I couldn't use .NET Target Framework v4.0 (I already have v 4.8. and .NET doesn't let me roll back the Framework version).
It will be fixed in the next commits.
| return self._pipes[pid] | ||
|
|
||
| def _create_pipe(self, pid): | ||
| pipe_name = 'process_{}'.format(pid) |
There was a problem hiding this comment.
If you want to change the name of pipe, you also need to change it on the backend side here:
injected/backends/dotnet/src/wpf/Main.cs
Line 16 in a7eee0e
Note: prefix
pywinauto_ looks better for me, because it is less ambiguous and avoids possible conflicts with other applications (for example, some other process may want to create pipe with name process_{PID})
There was a problem hiding this comment.
@vasily-v-ryabov suggested removing all mention of the pywinauto project.
Maybe I should use injectdll_ instead, what do you think?
There was a problem hiding this comment.
As I remember, I suggested using 2 PIDs in a pipe name: Python process and target process. Also I'd suggest adding a text param for the part of the name. For example, pywinauto will name this pipe "pywinauto_{py_pid}_{target_pid}", other lib or app can assign another text part of the name. It should make the pipe name 100% unique.
There was a problem hiding this comment.
The most important thing is to specify the same pipe name on the client and server sides, otherwise this code will not work :)
| reply = json.loads(reply) | ||
|
|
||
| reply_code = reply['status_code'] | ||
| reply_message = reply['message'] |
There was a problem hiding this comment.
The message is optional field of JSON reply, so this code can raise a KeyError
There was a problem hiding this comment.
It will be fixed in the next commits.
| subprocess.check_call(['cmake', '-B ' + build_dir, '-S ' + cmake_dir, '-A ' + arch]) | ||
| subprocess.check_call(['cmake', '--build', build_dir]) |
There was a problem hiding this comment.
CMake build DLLs in Debug mode here. I think it will be better to build it in Release (or RelWithDebInfo?) mode.
There was a problem hiding this comment.
It will be fixed in the next commits.
|
All these commits were merged in PR #10. Closing this one. |
Hello Team!
Injected has been redesigned to become a separate PyPi package.
Check out the following changes: