I need some converting a C++ DLL to PowerBASIC. The C++ Source Code from the DLL:
BOOL
NTAPI
PasswordFilter(
PUNICODE_STRING UserName,
PUNICODE_STRING FullName,
PUNICODE_STRING Password,
BOOL SetOperation
)
/*++
{
BOOL bComplex = FALSE; // assume the password in not complex enough
DWORD cchPassword;
PWORD CharType;
DWORD i;
DWORD dwNum = 0;
DWORD dwUpper = 0;
DWORD dwLower = 0;
//
// check if the password is complex enough for our liking by
// checking that at least two of the four character types are
// present.
//
CharType = HeapAlloc(GetProcessHeap(), 0, Password->Length);
if (CharType == NULL) return FALSE;
cchPassword = Password->Length / sizeof(WCHAR);
if (GetStringTypeW(
CT_CTYPE1,
Password->Buffer,
cchPassword,
CharType
))
{
for (i = 0 ; i < cchPassword ; i++)
{
//
// keep track of what type of characters we have encountered
//
if (CharType[i] & C1_DIGIT)
{
dwNum = 1;
continue;
}
if (CharType[i] & C1_UPPER)
{
dwUpper = 1;
continue;
}
if (CharType[i] & C1_LOWER)
{
dwLower = 1;
continue;
}
if (!(CharType[i] & (C1_ALPHA | C1_DIGIT) ))
{
//
// any other character types make the password complex
//
dwNum = 2;
break;
}
} // for
//
// Indicate whether we encountered enough password complexity
//
if ( (dwNum + dwUpper + dwLower) >= 2 )
bComplex = TRUE;
ZeroMemory( CharType, Password->Length );
} // if
HeapFree(GetProcessHeap(), 0, CharType);
return bComplex;
}
BOOL
NTAPI
InitializeChangeNotify(
void
)
{
#ifdef DEBUG
OutputDebugString( TEXT("Initialize Change Notify called!\n") );
#endif
//
// initialize any critical sections associated with password change
// events, etc.
//
return TRUE;
}
My attempt at setting up the functions in PB:
FUNCTION PasswordFilter ALIAS "PasswordFilter" (UserName AS STRING,FullName AS STRING,P AS STRING,setoperation AS INTEGER) EXPORT AS INTEGER
END FUNCTION
FUNCTION InitializeChangeNotify ALIAS "InitializeChangeNotify" () EXPORT AS INTEGER
END FUNCTION
I think I am not declaring the data types and string pointers correctly as the DLL does not respond to the functions from the C++ executatable which calls it.
Any help would be GREATLY appreciated
.
BOOL
NTAPI
PasswordFilter(
PUNICODE_STRING UserName,
PUNICODE_STRING FullName,
PUNICODE_STRING Password,
BOOL SetOperation
)
/*++
{
BOOL bComplex = FALSE; // assume the password in not complex enough
DWORD cchPassword;
PWORD CharType;
DWORD i;
DWORD dwNum = 0;
DWORD dwUpper = 0;
DWORD dwLower = 0;
//
// check if the password is complex enough for our liking by
// checking that at least two of the four character types are
// present.
//
CharType = HeapAlloc(GetProcessHeap(), 0, Password->Length);
if (CharType == NULL) return FALSE;
cchPassword = Password->Length / sizeof(WCHAR);
if (GetStringTypeW(
CT_CTYPE1,
Password->Buffer,
cchPassword,
CharType
))
{
for (i = 0 ; i < cchPassword ; i++)
{
//
// keep track of what type of characters we have encountered
//
if (CharType[i] & C1_DIGIT)
{
dwNum = 1;
continue;
}
if (CharType[i] & C1_UPPER)
{
dwUpper = 1;
continue;
}
if (CharType[i] & C1_LOWER)
{
dwLower = 1;
continue;
}
if (!(CharType[i] & (C1_ALPHA | C1_DIGIT) ))
{
//
// any other character types make the password complex
//
dwNum = 2;
break;
}
} // for
//
// Indicate whether we encountered enough password complexity
//
if ( (dwNum + dwUpper + dwLower) >= 2 )
bComplex = TRUE;
ZeroMemory( CharType, Password->Length );
} // if
HeapFree(GetProcessHeap(), 0, CharType);
return bComplex;
}
BOOL
NTAPI
InitializeChangeNotify(
void
)
{
#ifdef DEBUG
OutputDebugString( TEXT("Initialize Change Notify called!\n") );
#endif
//
// initialize any critical sections associated with password change
// events, etc.
//
return TRUE;
}
My attempt at setting up the functions in PB:
FUNCTION PasswordFilter ALIAS "PasswordFilter" (UserName AS STRING,FullName AS STRING,P AS STRING,setoperation AS INTEGER) EXPORT AS INTEGER
END FUNCTION
FUNCTION InitializeChangeNotify ALIAS "InitializeChangeNotify" () EXPORT AS INTEGER
END FUNCTION
I think I am not declaring the data types and string pointers correctly as the DLL does not respond to the functions from the C++ executatable which calls it.
Any help would be GREATLY appreciated

Comment