Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't eject a dll, event match case. #20

Closed
ghggn opened this issue Sep 20, 2023 · 11 comments · Fixed by #25
Closed

can't eject a dll, event match case. #20

ghggn opened this issue Sep 20, 2023 · 11 comments · Fixed by #25
Assignees
Labels

Comments

@ghggn
Copy link

ghggn commented Sep 20, 2023

oepn an app(wechat.exe), and it's dll list show like this(windows Resource Monitor)
Snipaste_2023-09-20_18-17-04
then i inject a dll into this app by pid
Snipaste_2023-09-20_18-18-05
it success and in windows Resource Monitor we can find it .
Snipaste_2023-09-20_18-18-14
but
i cant eject this dll anymore .
Snipaste_2023-09-20_18-18-57

@nefarius
Copy link
Owner

Try just the dll name, without the path.

@ghggn
Copy link
Author

ghggn commented Sep 20, 2023

i already do that , you can see the last pic , i use dll name only and full path . there has two command and all failed .

@nefarius
Copy link
Owner

Ah, correct. Odd, I'll see if I can reproduce and fix 🤞

@ghggn
Copy link
Author

ghggn commented Sep 20, 2023

I eject a dll which injected by another process, that is ListaryHook64.dll in the above screenshot, and I can successfully eject it.
I also modified the source code to output the name and path of the dll when ejecting, and there is no wxhelper in list.
This is the link of wxhelper source code, if you are interested, maybe it will make help for solve the problem!
https://github.com/ttttupup/wxhelper

@nefarius nefarius added the bug label Sep 22, 2023
@nefarius nefarius self-assigned this Sep 22, 2023
@nefarius
Copy link
Owner

@ghggn does it work with an earlier version? Like v1.1.12?

@ghggn
Copy link
Author

ghggn commented Sep 28, 2023

it not work too

@nefarius
Copy link
Owner

@ghggn please try the latest master build.

@ghggn
Copy link
Author

ghggn commented Oct 12, 2023

still not work

@nefarius
Copy link
Owner

OK thx for the feedback, will continue investigating.

@nefarius
Copy link
Owner

still not work

I recommend you step through here with the debugger and see what kind of strings you're getting back in the comparison.

@bot-1450
Copy link
Contributor

bot-1450 commented Oct 13, 2023

Well I think ghggn tried the latest release (which hasn't been updated yet) rather than building the latest code. The latest code not only fails eject but also inject. I studied it a little. It is really difficult to setup the software mentioned. Never mind, finally reproduced.

The different behaviors root from that we use snapshot CreateToolhelp32Snapshot/Module32FirstW/Module32NextW (which was used by EjectLib before the most recent commits) to enumerate the modules, while Performance Monitor uses EnumProcessModulesEx directly. Also it uses GetModuleBaseNameW/GetModuleFileNameExW instead of szModule/szExePath to retrieve certain names.

I will fix this and make new PR later.

BTW, I happen to notice GetModuleFileNameExW says:

Retrieves the fully qualified path for the file containing the specified module.

So, when someone tries to use a relative path, since we simply append it rather than qualifying it, the comparison fails. (For example comparing A\..\B.dll against B.dll will fail doubtlessly.)

// Convert path to loader to path to module
std::tstring ModulePath(&LoaderPath[0]);
ModulePath = ModulePath.substr(0, ModulePath.rfind( _T("\\") ) + 1);
ModulePath.append(ModuleName);

After turning Tool Help Library (tlhelp32) into Process Status API (psapi) this should also be fixed together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants