V
Vincent RICHOMME
Hi,
I would like to use a hashtable to associate a windows unicode string
(define as a ulong *) to a list.
So first I try this :
typedef std::list<FunctionInfo> FuncList;
FuncList g_FuncList;
typedef std::map<LPWSTR, FuncList> ModuleList;
ModuleList g_ModuleList;
void Hook_API( LPWSTR p_wszModuleName,
LPWSTR p_wszFunctionName,
PROC p_pfnNewProc
)
{
ModuleList::iterator l_it;
l_it = g_ModuleList.find( (LPWSTR)p_wszModuleName );
if (l_it == g_ModuleList.end() ){
...
}
}
when I try this if I call three times my function with the same
parameter (L"coredll.dll" for instance) I will have
three keys in my hashtable
Hook_API(L"coredll.dll", "func1", NULL);
Hook_API(L"coredll.dll", "func2", NULL);
Hook_API(L"coredll.dll", "func3", NULL);
So I should have only one key in my hash table (coredll.dll) but it's
not the case
I think it's because map considers LPWSTR as a pointer and not as a
string. So LPWSTR is always different since address is different.
Maybe I should use std::string but in this case how to do with unicode
string.
I would like to use a hashtable to associate a windows unicode string
(define as a ulong *) to a list.
So first I try this :
typedef std::list<FunctionInfo> FuncList;
FuncList g_FuncList;
typedef std::map<LPWSTR, FuncList> ModuleList;
ModuleList g_ModuleList;
void Hook_API( LPWSTR p_wszModuleName,
LPWSTR p_wszFunctionName,
PROC p_pfnNewProc
)
{
ModuleList::iterator l_it;
l_it = g_ModuleList.find( (LPWSTR)p_wszModuleName );
if (l_it == g_ModuleList.end() ){
...
}
}
when I try this if I call three times my function with the same
parameter (L"coredll.dll" for instance) I will have
three keys in my hashtable
Hook_API(L"coredll.dll", "func1", NULL);
Hook_API(L"coredll.dll", "func2", NULL);
Hook_API(L"coredll.dll", "func3", NULL);
So I should have only one key in my hash table (coredll.dll) but it's
not the case
I think it's because map considers LPWSTR as a pointer and not as a
string. So LPWSTR is always different since address is different.
Maybe I should use std::string but in this case how to do with unicode
string.