小编133*_*337的帖子

无法实现密码过滤

我尝试实现密码过滤,所以我写了一个简单的密码过滤器.我按照MSDN中的文档进行操作,并确保正确声明了这些函数.我在VS 2010中编译.


.def文件:

LIBRARY myFilt
EXPORTS
   InitializeChangeNotify
   PasswordFilter
   PasswordChangeNotify
Run Code Online (Sandbox Code Playgroud)

.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;
} …
Run Code Online (Sandbox Code Playgroud)

c c++ security winapi

7
推荐指数
1
解决办法
2141
查看次数

Unmangle C++ DLL函数名称

我有一个导出3功能的DLL:

.h文件

extern "C"
{
__declspec(dllexport) BOOLEAN __stdcall InitializeChangeNotify(void);
__declspec(dllexport) BOOLEAN __stdcall PasswordFilter(LPCWSTR AccountName,LPCWSTR FullName,LPCWSTR Password,BOOLEAN SetOperation);
__declspec(dllexport) NTSTATUS __stdcall PasswordChangeNotify(LPCWSTR UserName,ULONG RelativeId,LPCWSTR NewPassword);
}
Run Code Online (Sandbox Code Playgroud)

.c文件

extern "C"
{
    __declspec(dllexport) BOOLEAN __stdcall InitializeChangeNotify(void)
{
    writeToLog("InitializeChangeNotify()");
    return TRUE;
}

__declspec(dllexport) BOOLEAN __stdcall PasswordFilter(LPCWSTR AccountName,LPCWSTR FullName,LPCWSTR Password,BOOLEAN SetOperation)
{
    writeToLog("PasswordFilter()");
    return TRUE;
}

__declspec(dllexport) NTSTATUS __stdcall PasswordChangeNotify(LPCWSTR UserName,ULONG RelativeId,LPCWSTR NewPassword)
{
    writeToLog("PasswordChangeNotify()");
    return 0;
}
}
Run Code Online (Sandbox Code Playgroud)

我在VS 2010中编译.

我看到函数名称取决于:_InitializeChangeNotify@0, _PasswordChangeNotify@12.如何取消功能?

c

0
推荐指数
1
解决办法
1805
查看次数

标签 统计

c ×2

c++ ×1

security ×1

winapi ×1