133*_*337 7 c c++ security winapi
我尝试实现密码过滤,所以我写了一个简单的密码过滤器.我按照MSDN中的文档进行操作,并确保正确声明了这些函数.我在VS 2010中编译.
LIBRARY myFilt
EXPORTS
InitializeChangeNotify
PasswordFilter
PasswordChangeNotify
Run Code Online (Sandbox Code Playgroud)
#include <windows.h>
#include <stdio.h>
#include <ntsecapi.h>
void writeToLog(const char* szString)
{
FILE* pFile = fopen("c:\\work\\logFile.txt", "a+");
if (NULL == pFile)
{
return;
}
fprintf(pFile, "%s\r\n", szString);
fclose(pFile);
return;
}
// Default DllMain implementation
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
OutputDebugString(L"DllMain");
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
BOOLEAN __stdcall InitializeChangeNotify(void)
{
OutputDebugString(L"InitializeChangeNotify");
writeToLog("InitializeChangeNotify()");
return TRUE;
}
BOOLEAN __stdcall PasswordFilter(
PUNICODE_STRING AccountName,
PUNICODE_STRING FullName,
PUNICODE_STRING Password,
BOOLEAN SetOperation
)
{
OutputDebugString(L"PasswordFilter");
return TRUE;
}
NTSTATUS __stdcall PasswordChangeNotify(
PUNICODE_STRING UserName,
ULONG RelativeId,
PUNICODE_STRING NewPassword
)
{
OutputDebugString(L"PasswordChangeNotify");
writeToLog("PasswordChangeNotify()");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我把myFilt.dll放入%windir%\system32,在注册表中添加"myFilt"到"Notification Packages",重新启动计算机,更改密码,没有任何反应.
我打开了depends.exe,看到函数是正确的:
InitializeChangeNotify
PasswordChangeNotify
PasswordFilter
Run Code Online (Sandbox Code Playgroud)
这个错误在哪里?
谢谢.
\n\n我发现问题了!我将运行时库从多线程调试 DLL (/MDd) 更改为多线程调试 (/MTd),它运行完美!:)
\n\xe2\x80\x93 user1375970 5 月 5 日 10:38
\n
| 归档时间: |
|
| 查看次数: |
2141 次 |
| 最近记录: |