Unable to implement password filter

I am trying to implement a password filter, so I am writing a simple password filter. I followed the document on MSDN and made sure that the functions were declared correctly. I am compiling in VS 2010.


.def file:

LIBRARY myFilt EXPORTS InitializeChangeNotify PasswordFilter PasswordChangeNotify 

.cpp file:

 #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; } 

I put myFilt.dll in %windir%\system32 , add "myFilt" to the "Notification Packages" in the registry, restart the computer, change the password and nothing happens.

I opened the depend.exe file and saw that the functions are correct:

 InitializeChangeNotify PasswordChangeNotify PasswordFilter 

Where is the mistake?

Thanks.

+6
source share
2 answers

I found a problem! I changed the runtime library from a multi-threaded Debug DLL (/ MDd) to a multi-threaded Debug (/ MTd) and it works fine! :)

- user1375970 May 5 at 10:38

+1
source

Notification Packages Specifies dynamic link libraries (DLLs) that are loaded or invoked when setting or changing passwords. To specify multiple files, list the file names one above the other by pressing ENTER between each file name.

over another!

0
source

Source: https://habr.com/ru/post/914958/


All Articles