-
Notifications
You must be signed in to change notification settings - Fork 10
feat: get_library_path #2
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,5 @@ | |
|
|
||
| #include <windows.h> | ||
|
|
||
| #include <psapi.h> | ||
| #include <shellapi.h> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,18 @@ const std::filesystem::path& library_dir() | |
| return s_library_dir_cache; | ||
| } | ||
|
|
||
| std::filesystem::path get_library_path(void* addr) | ||
| { | ||
| WCHAR path_buf[MAX_PATH + 5]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为啥是 + 5 另外要初始化一下
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 随便加的, 其实应该是+0或者+1( |
||
| DWORD path_len = GetMappedFileNameW(GetCurrentProcess(), addr, path_buf, MAX_PATH); | ||
|
|
||
| if (path_len == 0) { | ||
| return {}; | ||
| } | ||
|
|
||
| return { path_buf }; | ||
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong. |
||
| } | ||
|
|
||
| void init_library_dir(HINSTANCE hinstDLL) | ||
| { | ||
| WCHAR buffer[MAX_PATH] = { 0 }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该想想名字了,这俩函数光看名字不知道有啥区别