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

file: Add Shortcut metadata parsing on Windows #8143

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove dependency from unicode PR
  • Loading branch information
Smjert committed Nov 1, 2023
commit a40a5a0cde5e388f84e7c36cb1d64fb3d6cf2bbe
13 changes: 8 additions & 5 deletions osquery/tables/utility/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
}

constexpr auto max_chars = INFOTIPSIZE > MAX_PATH ? INFOTIPSIZE : MAX_PATH;
WCHAR buffer[max_chars]{};
WCHAR buffer[max_chars + 1]{};

WIN32_FIND_DATA target_data{};
hres = shell_link->GetPath(&buffer[0], max_chars, &target_data, 0);
Expand All @@ -130,9 +130,12 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {

LnkData link_data;

link_data.target_path = wstringToString(buffer, max_chars);
link_data.target_path = wstringToString(buffer);

auto type_name_length =
wcsnlen(file_info.szTypeName, ARRAYSIZE(file_info.szTypeName));
link_data.target_type =
wstringToString(file_info.szTypeName, ARRAYSIZE(file_info.szTypeName));
wstringToString(std::wstring(file_info.szTypeName, type_name_length));

fs::path target_path = link_data.target_path;
link_data.target_location = target_path.parent_path().filename().string();
Expand All @@ -144,7 +147,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

link_data.start_in = wstringToString(buffer, max_chars);
link_data.start_in = wstringToString(buffer);

std::memset(buffer, 0, sizeof(buffer));
hres = shell_link->GetDescription(buffer, max_chars);
Expand All @@ -153,7 +156,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

link_data.comment = wstringToString(buffer, max_chars);
link_data.comment = wstringToString(buffer);

int show_cmd = 0;
hres = shell_link->GetShowCmd(&show_cmd);
Expand Down
Loading