我嘗試實現密碼過濾器,所以我寫了一個簡單的密碼過濾器。 我遵循MSDN中的文檔,並確保函數聲明正確。 我編譯VS 2010無法實現密碼過濾器
DEF文件:
LIBRARY myFilt
EXPORTS
InitializeChangeNotify
PasswordFilter
PasswordChangeNotify
.cpp文件:
#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;
}
我把myFilt.dll在%windir%\system32
,加上「myFilt 「到」通知包「在註冊表中,重新啓動計算機,更改密碼,並沒有任何反應。
我打開Depends.exe分析,發現該功能是正確的:
InitializeChangeNotify
PasswordChangeNotify
PasswordFilter
在哪裏?錯
謝謝。
您是否真的將'myFile'添加到註冊表項中,而不是'myFilt'?因爲這是你的DLL的名字......而且,你忘了在'PasswordFilter'中調用'writeToLog'嗎? –
您可以嘗試Process Monitor來查找Windows是否嘗試加載過濾器以及之後會發生什麼情況。 – sharptooth
是的。我添加myFilt,而不是myFile XD ..我運行進程監視器,並看到文件scecli.dll打開..(這個dll寫在Notification Packages(第一個)) – 1337