-
Notifications
You must be signed in to change notification settings - Fork 66
Use Standard unordered_multimap
#111
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
Changes from all commits
758f68b
7f445f4
077fd91
11fe56c
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,7 +12,7 @@ extern "C" void DebugOutput(_In_ LPCTSTR lpOutputString, ...); | |
| extern "C" void ErrorOutput(_In_ LPCTSTR lpOutputString, ...); | ||
| extern "C" SIZE_T GetAllocationSize(PVOID Address); | ||
|
|
||
| stdext::hash_multimap<DWORD_PTR, ApiInfo *> ApiReader::apiList; //api look up table | ||
| std::unordered_multimap<DWORD_PTR, ApiInfo *> ApiReader::apiList; //api look up table | ||
| std::map<DWORD_PTR, ImportModuleThunk> * ApiReader::moduleThunkList; //store found apis | ||
|
|
||
| DWORD_PTR ApiReader::minApiAddress = (DWORD_PTR)-1; | ||
|
|
@@ -690,7 +690,7 @@ bool ApiReader::isApiAddressValid(DWORD_PTR virtualAddress) | |
|
|
||
| ApiInfo * ApiReader::getApiByVirtualAddress(DWORD_PTR virtualAddress, bool * isSuspect) | ||
| { | ||
| stdext::hash_multimap<DWORD_PTR, ApiInfo *>::iterator it1, it2; | ||
| std::unordered_multimap<DWORD_PTR, ApiInfo *>::iterator it1, it2; | ||
| size_t c = 0; | ||
| size_t countDuplicates = apiList.count(virtualAddress); | ||
| int countHighPriority = 0; | ||
|
|
@@ -773,7 +773,7 @@ ApiInfo * ApiReader::getApiByVirtualAddress(DWORD_PTR virtualAddress, bool * isS | |
| return (ApiInfo *) 1; | ||
| } | ||
|
|
||
| ApiInfo * ApiReader::getScoredApi(stdext::hash_multimap<DWORD_PTR, ApiInfo *>::iterator it1,size_t countDuplicates, bool hasName, bool hasUnicodeAnsiName, bool hasNoUnderlineInName, bool hasPrioDll,bool hasPrio0Dll,bool hasPrio1Dll, bool hasPrio2Dll, bool firstWin ) | ||
| ApiInfo * ApiReader::getScoredApi(std::unordered_multimap<DWORD_PTR, ApiInfo *>::iterator it1,size_t countDuplicates, bool hasName, bool hasUnicodeAnsiName, bool hasNoUnderlineInName, bool hasPrioDll,bool hasPrio0Dll,bool hasPrio1Dll, bool hasPrio2Dll, bool firstWin ) | ||
| { | ||
| ApiInfo * foundApi = 0; | ||
| ApiInfo * foundMatchingApi = 0; | ||
|
|
@@ -1116,7 +1116,7 @@ void ApiReader::clearAll() | |
| minApiAddress = (DWORD_PTR)-1; | ||
| maxApiAddress = 0; | ||
|
|
||
| for ( stdext::hash_map<DWORD_PTR, ApiInfo *>::iterator it = apiList.begin(); it != apiList.end(); ++it ) | ||
| for ( std::unordered_multimap<DWORD_PTR, ApiInfo *>::iterator it = apiList.begin(); it != apiList.end(); ++it ) | ||
| { | ||
| delete it->second; | ||
| } | ||
|
Comment on lines
+1119
to
1122
Contributor
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.
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. I agree that this would be an improvement and was tempted to perform it, but intentionally refrained from unrelated cleanups in this PR (I even avoided using |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| #include <windows.h> | ||
| #include <map> | ||
| #include <hash_map> | ||
| #include <unordered_map> | ||
| #include "ProcessAccessHelp.h" | ||
| #include "Thunks.h" | ||
|
|
||
|
|
@@ -11,7 +11,7 @@ typedef std::pair<DWORD_PTR, ApiInfo *> API_Pair; | |
| class ApiReader : public ProcessAccessHelp | ||
| { | ||
| public: | ||
| static stdext::hash_multimap<DWORD_PTR, ApiInfo *> apiList; //api look up table | ||
| static std::unordered_multimap<DWORD_PTR, ApiInfo *> apiList; //api look up table | ||
|
Contributor
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. To improve readability and maintainability, consider introducing a type alias for This alias can then be used throughout using ApiList = std::unordered_multimap<DWORD_PTR, ApiInfo *>;
static ApiList apiList; //api look up table
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. This would be a reasonable improvement, but I intentionally refrained from performing unrelated cleanups, beyond fixing the single/multi confusion. |
||
|
|
||
| static std::map<DWORD_PTR, ImportModuleThunk> * moduleThunkList; //store found apis | ||
|
|
||
|
|
@@ -70,6 +70,6 @@ class ApiReader : public ProcessAccessHelp | |
| bool isApiBlacklisted( const char * functionName ); | ||
| bool isWinSxSModule( ModuleInfo * module ); | ||
|
|
||
| ApiInfo * getScoredApi(stdext::hash_map<DWORD_PTR, ApiInfo *>::iterator it1,size_t countDuplicates, bool hasName, bool hasUnicodeAnsiName, bool hasNoUnderlineInName, bool hasPrioDll,bool hasPrio0Dll,bool hasPrio1Dll, bool hasPrio2Dll, bool firstWin ); | ||
| ApiInfo * getScoredApi(std::unordered_multimap<DWORD_PTR, ApiInfo *>::iterator it1,size_t countDuplicates, bool hasName, bool hasUnicodeAnsiName, bool hasNoUnderlineInName, bool hasPrioDll,bool hasPrio0Dll,bool hasPrio1Dll, bool hasPrio2Dll, bool firstWin ); | ||
|
|
||
| }; | ||
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.
The iterator
it2is declared but never used within thegetApiByVirtualAddressfunction. It should be removed to improve code clarity and avoid potential confusion.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.
I confirm that
it2is unused and should be removed (good bot, I didn't notice that). However, I am intentionally refraining from performing unrelated cleanups in this PR.