将 WIN32_FIND_DATA 转换为 LPVOID
如何将 WIN32_FIND_DATA 转换为 LPVOID?
我正在尝试挂钩一个函数,但无法将 WIN32_FIND_DATA 转换为 LPVOID
这是我的函数:
/* New FindFirstFileW Function */
HANDLE WINAPI newFindFirstFileExW(__in LPCTSTR lpFileName, __in FINDEX_INFO_LEVELS fInfoLevelId, __out LPVOID lpFindFileData, __in FINDEX_SEARCH_OPS fSearchOp,
__reserved LPVOID lpSearchFilter, __in DWORD dwAdditionalFlags)
{
HANDLE hFind;
WIN32_FIND_DATA findData;
BOOL ret;
hFind = FindFirstFileExW(lpFileName, fInfoLevelId, &findData, fSearchOp, lpSearchFilter, dwAdditionalFlags);
if (hFind == INVALID_HANDLE_VALUE)
return hFind;
// if first file name starts with HIDE_NAME_W skip the file
if (wcsstr(findData.cFileName, HIDE_NAME_W) != 0)
{
ret = true;
do {
ret = FindNextFileW(hFind, &findData);
} while (!ret && wcsstr(findData.cFileName, HIDE_NAME_W) != 0);
if (!ret)
{
SetLastError(ERROR_FILE_NOT_FOUND);
return INVALID_HANDLE_VALUE;
}
}
lpFindFileData = reinterpret_cast<LPVOID>(findData);
return hFind;
}
编辑: 谢谢大家的帮助,现在它可以工作了,我的问题是我忘了更改 被调用的函数..我正在挂钩 FindFirstFileExW 一些其他函数
How can I cast WIN32_FIND_DATA to LPVOID?
I am trying to hook a function but I am unable to cast WIN32_FIND_DATA to LPVOID
this my function:
/* New FindFirstFileW Function */
HANDLE WINAPI newFindFirstFileExW(__in LPCTSTR lpFileName, __in FINDEX_INFO_LEVELS fInfoLevelId, __out LPVOID lpFindFileData, __in FINDEX_SEARCH_OPS fSearchOp,
__reserved LPVOID lpSearchFilter, __in DWORD dwAdditionalFlags)
{
HANDLE hFind;
WIN32_FIND_DATA findData;
BOOL ret;
hFind = FindFirstFileExW(lpFileName, fInfoLevelId, &findData, fSearchOp, lpSearchFilter, dwAdditionalFlags);
if (hFind == INVALID_HANDLE_VALUE)
return hFind;
// if first file name starts with HIDE_NAME_W skip the file
if (wcsstr(findData.cFileName, HIDE_NAME_W) != 0)
{
ret = true;
do {
ret = FindNextFileW(hFind, &findData);
} while (!ret && wcsstr(findData.cFileName, HIDE_NAME_W) != 0);
if (!ret)
{
SetLastError(ERROR_FILE_NOT_FOUND);
return INVALID_HANDLE_VALUE;
}
}
lpFindFileData = reinterpret_cast<LPVOID>(findData);
return hFind;
}
EDIT:
Thank you all for your help its working now my problem was that i forgot to change
the called function.. i was hooking to FindFirstFileExW some other function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将 WIN32_FIND_DATA 复制到内存中的 lpFindFileData。
最后一个返回之前的行应如下所示:
You have to copy the WIN32_FIND_DATA to the memory at lpFindFileData.
The line before the last return should look like this:
lpFindFileData = reinterpret_cast(findData);
findData
在此上下文中不是指针,而是实际的WIN32_FIND_DATA
。请执行以下操作:
lpFindFileData = reinterpret_cast(&findData);
lpFindFileData = reinterpret_cast<LPVOID>(findData);
findData
is not a pointer in this context, it's an actualWIN32_FIND_DATA
.Do this instead:
lpFindFileData = reinterpret_cast<LPVOID>(&findData);