Skip to content

Commit

Permalink
added many api sets manually
Browse files Browse the repository at this point in the history
  • Loading branch information
zodiacon committed Aug 12, 2019
1 parent af705ee commit c7d471d
Show file tree
Hide file tree
Showing 10 changed files with 1,707 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ApiSetView/ApiSetView.rc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ IDI_ARROW ICON "res\\arrow.ico"

IDI_CIRCLE ICON "res\\circle.ico"

IDI_ARROW2 ICON "res\\arrow2.ico"


/////////////////////////////////////////////////////////////////////////////
//
Expand Down
2 changes: 2 additions & 0 deletions ApiSetView/ApiSetView.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@
<ItemGroup>
<Image Include="res\ApiSetView.ico" />
<Image Include="res\arrow.ico" />
<Image Include="res\arrow2.ico" />
<Image Include="res\circle.ico" />
<Image Include="res\toolbar.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="res\ApiSets.ini" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
4 changes: 4 additions & 0 deletions ApiSetView/ApiSetView.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@
<Image Include="res\circle.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\arrow2.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="res\ApiSets.ini" />
</ItemGroup>
</Project>
9 changes: 6 additions & 3 deletions ApiSetView/ApiSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool ApiSets::IsFileExists(const wchar_t* name) const {
return _files.find(name) != _files.end();
}

const std::vector<std::string>& ApiSets::GetFunctionsByApiSet(const std::string& apiset) const {
const std::vector<std::string>& ApiSets::GetFunctionsByApiSet(const CString& apiset) const {
static const std::vector<std::string> _empty;

auto it = _manualApiSets.find(apiset);
Expand Down Expand Up @@ -124,17 +124,20 @@ bool ApiSets::ParseApiSetsResource(UINT id) {
if (text[0] == 13) {
// end of api set
if (!name.empty()) {
_manualApiSets.insert({ name, functions });
_manualApiSets.insert({ CString(name.c_str()), functions });

functions.clear();
name.clear();
text += 2;
size -= 2;
}
}

if (EOF == sscanf_s(text, "%127s", buffer, 127))
break;
auto len = (int)::strlen(buffer);
auto len = (uint32_t)::strlen(buffer);
if (len == 0) {

}
else if (buffer[0] == '[') {
// api set name
Expand Down
4 changes: 2 additions & 2 deletions ApiSetView/ApiSets.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiSets {

const std::vector<ApiSetEntry>& GetApiSets() const;
bool IsFileExists(const wchar_t* name) const;
const std::vector<std::string>& GetFunctionsByApiSet(const std::string& apiset) const;
const std::vector<std::string>& GetFunctionsByApiSet(const CString& apiset) const;

private:
struct LessNoCase {
Expand All @@ -30,7 +30,7 @@ class ApiSets {

private:
std::vector<ApiSetEntry> _entries;
std::map<std::string, std::vector<std::string>> _manualApiSets;
std::map<CString, std::vector<std::string>> _manualApiSets;
FileSet _files;
};

37 changes: 27 additions & 10 deletions ApiSetView/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/

m_Images.Create(16, 16, ILC_COLOR32 | ILC_COLOR, 2, 2);
m_Images.AddIcon(AtlLoadIcon(IDI_ARROW));
m_Images.AddIcon(AtlLoadIcon(IDI_ARROW2));
m_Images.AddIcon(AtlLoadIcon(IDI_CIRCLE));
m_ApiSetList.SetImageList(m_Images, LVSIL_SMALL);

Expand Down Expand Up @@ -242,7 +243,12 @@ LRESULT CMainFrame::OnGetDispInfo(int, LPNMHDR hdr, BOOL&) {
}
}
if (lv->item.mask & LVIF_IMAGE) {
item.iImage = m_ApiSets.IsFileExists(data.Name + L".dll") ? 0 : 1;
int image = 2;
if (m_ApiSets.IsFileExists(data.Name + L".dll"))
image = 0;
else if (!m_ApiSets.GetFunctionsByApiSet(data.Name + L".dll").empty())
image = 1;
item.iImage = image;
}
break;
}
Expand All @@ -258,7 +264,8 @@ LRESULT CMainFrame::OnGetDispInfo(int, LPNMHDR hdr, BOOL&) {
break;

case 1: // ordinal
::StringCchPrintf(item.pszText, item.cchTextMax, L"%d", data.Ordinal);
if(data.Ordinal)
::StringCchPrintf(item.pszText, item.cchTextMax, L"%d", data.Ordinal);
break;

case 2: // undecorated name
Expand Down Expand Up @@ -301,20 +308,30 @@ LRESULT CMainFrame::OnItemChanged(int, LPNMHDR hdr, BOOL&) {
ClearSort(IDC_EXPORTS);

m_ApiSetExportList.SetItemCount(0);
if (m_ApiSets.IsFileExists(item.Name + L".dll")) {
PEParser parser(ApiSetDir + item.Name + L".dll");
CString fullname = item.Name + L".dll";
if (m_ApiSets.IsFileExists(fullname)) {
PEParser parser(ApiSetDir + fullname);
if (parser.IsValidPE()) {
m_ApiSetExports = parser.GetExports();
const auto count = static_cast<int>(m_ApiSetExports.size());
m_ApiSetExportList.SetItemCount(count);
m_ApiSetExportList.EnableWindow(TRUE);
m_ApiSetExportList.RedrawItems(0, count);
ClearSort(IDC_APISETEXPORTS);
}
}
else {
m_ApiSetExportList.EnableWindow(FALSE);
const auto& functions = m_ApiSets.GetFunctionsByApiSet(fullname);
m_ApiSetExports.clear();
for (const auto& f : functions) {
ExportedSymbol symbol;
symbol.Ordinal = 0;
symbol.Name = f;
m_ApiSetExports.push_back(symbol);
}
if(m_ApiSetExports.empty())
m_ApiSetExportList.EnableWindow(FALSE);
}
const auto count = static_cast<int>(m_ApiSetExports.size());
m_ApiSetExportList.SetItemCount(count);
m_ApiSetExportList.EnableWindow(TRUE);
m_ApiSetExportList.RedrawItems(0, count);
ClearSort(IDC_APISETEXPORTS);

m_ExportList.LockWindowUpdate(FALSE);
}
Expand Down
Loading

0 comments on commit c7d471d

Please sign in to comment.