gpt4 book ai didi

c++ - 无法实现密码过滤器

转载 作者:可可西里 更新时间:2023-11-01 18:39:44 31 4
gpt4 key购买 nike

我尝试实现密码过滤器,所以我写了一个简单的密码过滤器。我遵循了 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里,在注册表的“Notification Packages”中添加“myFilt”,重启电脑,修改密码,没有任何反应。

我打开 depends.exe 发现功能是正确的:

InitializeChangeNotify
PasswordChangeNotify
PasswordFilter

哪里错了??

谢谢。

最佳答案

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

– user1375970 May 5 at 10:38

关于c++ - 无法实现密码过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10460693/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com