>>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. <<
I think this PasswordFilter() will be called by OS ?
anyway below a small/uncompleted/not tested sample
-Uwe
#INCLUDE "win32api.inc"
TYPE UNICODE_STRING
Length AS WORD ' BYTE Counter
MaximumLength AS WORD ' BYTE Counter
Buffer AS ASCIIZ PTR ' is a word ptr to WCHAR (UNICODE)
END TYPE
FUNCTION PwF(Password AS UNICODE_STRING) AS LONG
LOCAL bComplex AS LONG
LOCAL cchPassword AS DWORD
LOCAL CharType AS WORD PTR
CharType = HeapAlloc(GetProcessHeap(), 0, Password.Length)
IF CharType = %NULL THEN
FUNCTION = 0
EXIT FUNCTION
END IF
cchPassword = Password.Length / 2 ' sizeof(WCHAR)
IF ISTRUE GetStringTypeW(%CT_CTYPE1, [email protected], cchPassword, @CharType) THEN
REM LOOP JOB HERE
ZeroMemory(@CharType, Password.Length)
END IF
HeapFree(GetProcessHeap(), 0, @CharType)
FUNCTION = bComplex
END FUNCTION
Announcement
Collapse
No announcement yet.
Help Converting C++ DLL to PB - Data Types Issue
Collapse
X
-
-
How to Declare Function
Thanks Chris! Interesting.. how should I declare the function in PowerBasic to be compatible with the C++ Function.
Leave a comment:
-
presumably the first fn is looking for unicode ( 2 bytes per charcater) zero-terminated strings and you are giving it ASCII (1 byte per character) PB strings which are not zero terminated. Maybe this confuses it.
Leave a comment:
-
Help Converting C++ DLL to PB - Data Types Issue
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.
Tags: None
Leave a comment: