fixed WCHAR constants, use endian safe definitions
This commit is contained in:
parent
28e5167435
commit
9575f386cd
@ -117,7 +117,8 @@ static WCHAR* drive_file_combine_fullpath(const WCHAR* base_path, const WCHAR* p
|
||||
goto fail;
|
||||
|
||||
/* Ensure the path does not contain sequences like '..' */
|
||||
const WCHAR dotdot[] = { '.', '.', '\0' };
|
||||
WCHAR dotdotbuffer[6] = { 0 };
|
||||
const WCHAR* dotdot = InitializeConstWCharFromUtf8("..", dotdotbuffer, ARRAYSIZE(dotdotbuffer));
|
||||
if (_wcsstr(&fullpath[base_path_length], dotdot))
|
||||
{
|
||||
char abuffer[MAX_PATH] = { 0 };
|
||||
|
@ -439,13 +439,14 @@ static UINT drive_process_irp_set_information(DRIVE_DEVICE* drive, IRP* irp)
|
||||
*/
|
||||
static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* irp)
|
||||
{
|
||||
UINT32 FsInformationClass;
|
||||
UINT32 FsInformationClass = 0;
|
||||
wStream* output = NULL;
|
||||
DWORD lpSectorsPerCluster;
|
||||
DWORD lpBytesPerSector;
|
||||
DWORD lpNumberOfFreeClusters;
|
||||
DWORD lpTotalNumberOfClusters;
|
||||
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
||||
DWORD lpSectorsPerCluster = 0;
|
||||
DWORD lpBytesPerSector = 0;
|
||||
DWORD lpNumberOfFreeClusters = 0;
|
||||
DWORD lpTotalNumberOfClusters = 0;
|
||||
WIN32_FILE_ATTRIBUTE_DATA wfad = { 0 };
|
||||
WCHAR LabelBuffer[32] = { 0 };
|
||||
|
||||
if (!drive || !irp)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
@ -464,8 +465,10 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
case FileFsVolumeInformation:
|
||||
{
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
|
||||
const WCHAR volumeLabel[] = { 'F', 'R', 'E', 'E', 'R', 'D', 'P', '\0' };
|
||||
const size_t length = 17ul + sizeof(volumeLabel);
|
||||
const WCHAR* volumeLabel =
|
||||
InitializeConstWCharFromUtf8("FREERDP", LabelBuffer, ARRAYSIZE(LabelBuffer));
|
||||
const size_t volumeLabelLen = (_wcslen(volumeLabel) + 1) * sizeof(WCHAR);
|
||||
const size_t length = 17ul + volumeLabelLen;
|
||||
|
||||
Stream_Write_UINT32(output, length); /* Length */
|
||||
|
||||
@ -480,10 +483,10 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
Stream_Write_UINT32(output,
|
||||
wfad.ftCreationTime.dwHighDateTime); /* VolumeCreationTime */
|
||||
Stream_Write_UINT32(output, lpNumberOfFreeClusters & 0xffff); /* VolumeSerialNumber */
|
||||
Stream_Write_UINT32(output, sizeof(volumeLabel)); /* VolumeLabelLength */
|
||||
Stream_Write_UINT32(output, volumeLabelLen); /* VolumeLabelLength */
|
||||
Stream_Write_UINT8(output, 0); /* SupportsObjects */
|
||||
/* Reserved(1), MUST NOT be added! */
|
||||
Stream_Write(output, volumeLabel, sizeof(volumeLabel)); /* VolumeLabel (Unicode) */
|
||||
Stream_Write(output, volumeLabel, volumeLabelLen); /* VolumeLabel (Unicode) */
|
||||
}
|
||||
break;
|
||||
|
||||
@ -506,8 +509,10 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
case FileFsAttributeInformation:
|
||||
{
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
|
||||
const WCHAR diskType[] = { 'F', 'A', 'T', '3', '2', '\0' };
|
||||
const size_t length = 12ul + sizeof(diskType);
|
||||
const WCHAR* diskType =
|
||||
InitializeConstWCharFromUtf8("FAT32", LabelBuffer, ARRAYSIZE(LabelBuffer));
|
||||
const size_t diskTypeLen = (wcslen(diskType) + 1) * sizeof(WCHAR);
|
||||
const size_t length = 12ul + diskTypeLen;
|
||||
Stream_Write_UINT32(output, length); /* Length */
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(output, length))
|
||||
@ -519,8 +524,8 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
Stream_Write_UINT32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES |
|
||||
FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
|
||||
Stream_Write_UINT32(output, MAX_PATH); /* MaximumComponentNameLength */
|
||||
Stream_Write_UINT32(output, sizeof(diskType)); /* FileSystemNameLength */
|
||||
Stream_Write(output, diskType, sizeof(diskType)); /* FileSystemName (Unicode) */
|
||||
Stream_Write_UINT32(output, diskTypeLen); /* FileSystemNameLength */
|
||||
Stream_Write(output, diskType, diskTypeLen); /* FileSystemName (Unicode) */
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2230,11 +2230,13 @@ static BOOL add_directory(CliprdrLocalStream* stream, const char* path)
|
||||
|
||||
BOOL rc = FALSE;
|
||||
char* next = NULL;
|
||||
|
||||
WCHAR dotbuffer[6] = { 0 };
|
||||
WCHAR dotdotbuffer[6] = { 0 };
|
||||
const WCHAR* dot = InitializeConstWCharFromUtf8(".", dotbuffer, ARRAYSIZE(dotbuffer));
|
||||
const WCHAR* dotdot = InitializeConstWCharFromUtf8("..", dotdotbuffer, ARRAYSIZE(dotdotbuffer));
|
||||
do
|
||||
{
|
||||
const WCHAR dot[] = { '.', '\0' };
|
||||
const WCHAR dotdot[] = { '.', '.', '\0' };
|
||||
|
||||
if (_wcscmp(FindFileData.cFileName, dot) == 0)
|
||||
continue;
|
||||
if (_wcscmp(FindFileData.cFileName, dotdot) == 0)
|
||||
|
@ -37,10 +37,21 @@
|
||||
#define MAX_CACHE_ITEM_SIZE 4096
|
||||
#define MAX_CACHE_ITEM_VALUES 4096
|
||||
|
||||
static CHAR g_ReaderNameA[] = { 'F', 'r', 'e', 'e', 'R', 'D', 'P', ' ', 'E',
|
||||
'm', 'u', 'l', 'a', 't', 'o', 'r', '\0', '\0' };
|
||||
static WCHAR g_ReaderNameW[] = { 'F', 'r', 'e', 'e', 'R', 'D', 'P', ' ', 'E',
|
||||
'm', 'u', 'l', 'a', 't', 'o', 'r', '\0', '\0' };
|
||||
static const CHAR g_ReaderNameA[] = { 'F', 'r', 'e', 'e', 'R', 'D', 'P', ' ', 'E',
|
||||
'm', 'u', 'l', 'a', 't', 'o', 'r', '\0', '\0' };
|
||||
static INIT_ONCE g_ReaderNameWGuard = INIT_ONCE_STATIC_INIT;
|
||||
static WCHAR g_ReaderNameW[32] = { 0 };
|
||||
static size_t g_ReaderNameWLen = 0;
|
||||
|
||||
static BOOL CALLBACK g_ReaderNameWInit(PINIT_ONCE InitOnce, PVOID Parameter, PVOID* Context)
|
||||
{
|
||||
WINPR_UNUSED(InitOnce);
|
||||
WINPR_UNUSED(Parameter);
|
||||
WINPR_UNUSED(Context);
|
||||
InitializeConstWCharFromUtf8(g_ReaderNameA, g_ReaderNameW, ARRAYSIZE(g_ReaderNameW));
|
||||
g_ReaderNameWLen = _wcsnlen(g_ReaderNameW, ARRAYSIZE(g_ReaderNameW) - 2) + 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct smartcard_emulation_context
|
||||
{
|
||||
@ -116,6 +127,7 @@ static BOOL scard_status_transition(SCardContext* context)
|
||||
memcpy(reader->rgbAtr, ATR, sizeof(ATR));
|
||||
}
|
||||
{
|
||||
InitOnceExecuteOnce(&g_ReaderNameWGuard, g_ReaderNameWInit, NULL, NULL);
|
||||
SCARD_READERSTATEW* reader = &context->readerStateW[0];
|
||||
reader->szReader = g_ReaderNameW;
|
||||
reader->dwEventState = SCARD_STATE_PRESENT;
|
||||
@ -574,6 +586,7 @@ LONG WINAPI Emulate_SCardListReadersW(SmartcardEmulationContext* smartcard, SCAR
|
||||
|
||||
WINPR_UNUSED(mszGroups); /* Not required */
|
||||
|
||||
InitOnceExecuteOnce(&g_ReaderNameWGuard, g_ReaderNameWInit, NULL, NULL);
|
||||
if (SCARD_S_SUCCESS == status)
|
||||
{
|
||||
SCardContext* value = HashTable_GetItemValue(smartcard->contexts, (const void*)hContext);
|
||||
@ -585,11 +598,11 @@ LONG WINAPI Emulate_SCardListReadersW(SmartcardEmulationContext* smartcard, SCAR
|
||||
|
||||
/* Return length only */
|
||||
if (!mszReaders)
|
||||
*pcchReaders = ARRAYSIZE(g_ReaderNameW);
|
||||
*pcchReaders = g_ReaderNameWLen;
|
||||
else
|
||||
{
|
||||
*pcchReaders = scard_copy_strings(value, mszReaders, *pcchReaders, g_ReaderNameW,
|
||||
sizeof(g_ReaderNameW)) /
|
||||
g_ReaderNameWLen * sizeof(WCHAR)) /
|
||||
sizeof(WCHAR);
|
||||
}
|
||||
}
|
||||
|
@ -200,8 +200,10 @@ static BOOL add_directory_entry_to_list(wClipboard* clipboard, const WCHAR* loca
|
||||
WCHAR* remote_name = NULL;
|
||||
WCHAR* remote_base_name = NULL;
|
||||
|
||||
const WCHAR dot[2] = { '.', '\0' };
|
||||
const WCHAR dotdot[3] = { '.', '.', '\0' };
|
||||
WCHAR dotbuffer[6] = { 0 };
|
||||
WCHAR dotdotbuffer[6] = { 0 };
|
||||
const WCHAR* dot = InitializeConstWCharFromUtf8(".", dotbuffer, ARRAYSIZE(dotbuffer));
|
||||
const WCHAR* dotdot = InitializeConstWCharFromUtf8("..", dotdotbuffer, ARRAYSIZE(dotdotbuffer));
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(local_dir_name);
|
||||
@ -274,7 +276,8 @@ static BOOL add_directory_contents_to_list(wClipboard* clipboard, const WCHAR* l
|
||||
const WCHAR* remote_name, wArrayList* files)
|
||||
{
|
||||
BOOL result = FALSE;
|
||||
const WCHAR wildcard[] = { '/', '*', '\0' };
|
||||
const WCHAR* wildcard = "/\0*\0\0\0";
|
||||
const size_t wildcardLen = 3;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(local_name);
|
||||
@ -282,12 +285,12 @@ static BOOL add_directory_contents_to_list(wClipboard* clipboard, const WCHAR* l
|
||||
WINPR_ASSERT(files);
|
||||
|
||||
size_t len = _wcslen(local_name);
|
||||
WCHAR* namebuf = calloc(len + ARRAYSIZE(wildcard), sizeof(WCHAR));
|
||||
WCHAR* namebuf = calloc(len + wildcardLen, sizeof(WCHAR));
|
||||
if (!namebuf)
|
||||
return FALSE;
|
||||
|
||||
_wcsncat(namebuf, local_name, len);
|
||||
_wcsncat(namebuf, wildcard, ARRAYSIZE(wildcard));
|
||||
_wcsncat(namebuf, wildcard, wildcardLen);
|
||||
|
||||
result = do_add_directory_contents_to_list(clipboard, local_name, remote_name, namebuf, files);
|
||||
|
||||
|
@ -3,29 +3,29 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
static WCHAR testStringW[] = { 'T', 'h', 'e', ' ', 'q', 'u', 'i', 'c', 'k', ' ', 'b',
|
||||
'r', 'o', 'w', 'n', ' ', 'f', 'o', 'x', ' ', 'j', 'u',
|
||||
'm', 'p', 's', ' ', 'o', 'v', 'e', 'r', ' ', 't', 'h',
|
||||
'e', ' ', 'l', 'a', 'z', 'y', ' ', 'd', 'o', 'g', '\0' };
|
||||
static const CHAR testStringA[] = { 'T', 'h', 'e', ' ', 'q', 'u', 'i', 'c', 'k', ' ', 'b',
|
||||
'r', 'o', 'w', 'n', ' ', 'f', 'o', 'x', ' ', 'j', 'u',
|
||||
'm', 'p', 's', ' ', 'o', 'v', 'e', 'r', ' ', 't', 'h',
|
||||
'e', ' ', 'l', 'a', 'z', 'y', ' ', 'd', 'o', 'g', '\0' };
|
||||
|
||||
#define testStringW_Length ((sizeof(testStringW) / sizeof(WCHAR)) - 1)
|
||||
#define testStringA_Length ((sizeof(testStringA) / sizeof(CHAR)) - 1)
|
||||
|
||||
static WCHAR testToken1W[] = { 'q', 'u', 'i', 'c', 'k', '\0' };
|
||||
static WCHAR testToken2W[] = { 'b', 'r', 'o', 'w', 'n', '\0' };
|
||||
static WCHAR testToken3W[] = { 'f', 'o', 'x', '\0' };
|
||||
static const CHAR testToken1A[] = { 'q', 'u', 'i', 'c', 'k', '\0' };
|
||||
static const CHAR testToken2A[] = { 'b', 'r', 'o', 'w', 'n', '\0' };
|
||||
static const CHAR testToken3A[] = { 'f', 'o', 'x', '\0' };
|
||||
|
||||
#define testToken1W_Length ((sizeof(testToken1W) / sizeof(WCHAR)) - 1)
|
||||
#define testToken2W_Length ((sizeof(testToken2W) / sizeof(WCHAR)) - 1)
|
||||
#define testToken3W_Length ((sizeof(testToken3W) / sizeof(WCHAR)) - 1)
|
||||
#define testToken1A_Length ((sizeof(testToken1A) / sizeof(CHAR)) - 1)
|
||||
#define testToken2A_Length ((sizeof(testToken2A) / sizeof(CHAR)) - 1)
|
||||
#define testToken3A_Length ((sizeof(testToken3A) / sizeof(CHAR)) - 1)
|
||||
|
||||
static WCHAR testTokensW[] = { 'q', 'u', 'i', 'c', 'k', '\r', '\n', 'b', 'r', 'o',
|
||||
'w', 'n', '\r', '\n', 'f', 'o', 'x', '\r', '\n', '\0' };
|
||||
static const CHAR testTokensA[] = { 'q', 'u', 'i', 'c', 'k', '\r', '\n', 'b', 'r', 'o',
|
||||
'w', 'n', '\r', '\n', 'f', 'o', 'x', '\r', '\n', '\0' };
|
||||
|
||||
#define testTokensW_Length ((sizeof(testTokensW) / sizeof(WCHAR)) - 1)
|
||||
#define testTokensA_Length ((sizeof(testTokensA) / sizeof(CHAR)) - 1)
|
||||
|
||||
static WCHAR testDelimiter[] = { '\r', '\n', '\0' };
|
||||
static const CHAR testDelimiterA[] = { '\r', '\n', '\0' };
|
||||
|
||||
#define testDelimiter_Length ((sizeof(testDelimiter) / sizeof(WCHAR)) - 1)
|
||||
#define testDelimiterA_Length ((sizeof(testDelimiter) / sizeof(CHAR)) - 1)
|
||||
|
||||
struct url_test_pair
|
||||
{
|
||||
@ -92,7 +92,9 @@ int TestString(int argc, char* argv[])
|
||||
return -1;
|
||||
|
||||
/* _wcslen */
|
||||
|
||||
WCHAR testStringW[ARRAYSIZE(testStringA)] = { 0 };
|
||||
ConvertUtf8NToWChar(testStringA, ARRAYSIZE(testStringA), testStringW, ARRAYSIZE(testStringW));
|
||||
const size_t testStringW_Length = testStringA_Length;
|
||||
length = _wcslen(testStringW);
|
||||
|
||||
if (length != testStringW_Length)
|
||||
@ -103,8 +105,15 @@ int TestString(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* _wcschr */
|
||||
union
|
||||
{
|
||||
char c[2];
|
||||
WCHAR w;
|
||||
} search;
|
||||
search.c[0] = 'r';
|
||||
search.c[1] = '\0';
|
||||
|
||||
p = _wcschr(testStringW, 'r');
|
||||
p = _wcschr(testStringW, search.w);
|
||||
pos = (p - testStringW);
|
||||
|
||||
if (pos != 11)
|
||||
@ -113,7 +122,7 @@ int TestString(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = _wcschr(&testStringW[pos + 1], 'r');
|
||||
p = _wcschr(&testStringW[pos + 1], search.w);
|
||||
pos = (p - testStringW);
|
||||
|
||||
if (pos != 29)
|
||||
@ -122,7 +131,7 @@ int TestString(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = _wcschr(&testStringW[pos + 1], 'r');
|
||||
p = _wcschr(&testStringW[pos + 1], search.w);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
@ -132,32 +141,42 @@ int TestString(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* wcstok_s */
|
||||
WCHAR testDelimiterW[ARRAYSIZE(testDelimiterA)] = { 0 };
|
||||
WCHAR testTokensW[ARRAYSIZE(testTokensA)] = { 0 };
|
||||
ConvertUtf8NToWChar(testTokensA, ARRAYSIZE(testTokensA), testTokensW, ARRAYSIZE(testTokensW));
|
||||
ConvertUtf8NToWChar(testDelimiterA, ARRAYSIZE(testDelimiterA), testDelimiterW,
|
||||
ARRAYSIZE(testDelimiterW));
|
||||
p = wcstok_s(testTokensW, testDelimiterW, &context);
|
||||
|
||||
p = wcstok_s(testTokensW, testDelimiter, &context);
|
||||
|
||||
WCHAR testToken1W[ARRAYSIZE(testToken1A)] = { 0 };
|
||||
ConvertUtf8NToWChar(testToken1A, ARRAYSIZE(testToken1A), testToken1W, ARRAYSIZE(testToken1W));
|
||||
if (memcmp(p, testToken1W, sizeof(testToken1W)) != 0)
|
||||
{
|
||||
printf("wcstok_s error: token #1 mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = wcstok_s(NULL, testDelimiter, &context);
|
||||
p = wcstok_s(NULL, testDelimiterW, &context);
|
||||
|
||||
WCHAR testToken2W[ARRAYSIZE(testToken2A)] = { 0 };
|
||||
ConvertUtf8NToWChar(testToken2A, ARRAYSIZE(testToken2A), testToken2W, ARRAYSIZE(testToken2W));
|
||||
if (memcmp(p, testToken2W, sizeof(testToken2W)) != 0)
|
||||
{
|
||||
printf("wcstok_s error: token #2 mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = wcstok_s(NULL, testDelimiter, &context);
|
||||
p = wcstok_s(NULL, testDelimiterW, &context);
|
||||
|
||||
WCHAR testToken3W[ARRAYSIZE(testToken3A)] = { 0 };
|
||||
ConvertUtf8NToWChar(testToken3A, ARRAYSIZE(testToken3A), testToken3W, ARRAYSIZE(testToken3W));
|
||||
if (memcmp(p, testToken3W, sizeof(testToken3W)) != 0)
|
||||
{
|
||||
printf("wcstok_s error: token #3 mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = wcstok_s(NULL, testDelimiter, &context);
|
||||
p = wcstok_s(NULL, testDelimiterW, &context);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
|
@ -60,18 +60,28 @@ fail:
|
||||
|
||||
static BOOL test_DsMakeSpnW(void)
|
||||
{
|
||||
WCHAR testServiceClass[] = { 'H', 'T', 'T', 'P', '\0' };
|
||||
WCHAR testServiceName[] = { 'L', 'A', 'B', '1', '-', 'W', '2', 'K', '8', 'R', '2',
|
||||
'-', 'G', 'W', '.', 'l', 'a', 'b', '1', '.', 'a', 'w',
|
||||
'a', 'k', 'e', '.', 'l', 'o', 'c', 'a', 'l', '\0' };
|
||||
WCHAR testSpn[] = { 'H', 'T', 'T', 'P', '/', 'L', 'A', 'B', '1', '-', 'W', '2', 'K',
|
||||
'8', 'R', '2', '-', 'G', 'W', '.', 'l', 'a', 'b', '1', '.', 'a',
|
||||
'w', 'a', 'k', 'e', '.', 'l', 'o', 'c', 'a', 'l', '\0' };
|
||||
const CHAR ctestServiceClass[] = { 'H', 'T', 'T', 'P', '\0' };
|
||||
const CHAR ctestServiceName[] = { 'L', 'A', 'B', '1', '-', 'W', '2', 'K', '8', 'R', '2',
|
||||
'-', 'G', 'W', '.', 'l', 'a', 'b', '1', '.', 'a', 'w',
|
||||
'a', 'k', 'e', '.', 'l', 'o', 'c', 'a', 'l', '\0' };
|
||||
const CHAR ctestSpn[] = { 'H', 'T', 'T', 'P', '/', 'L', 'A', 'B', '1', '-', 'W', '2', 'K',
|
||||
'8', 'R', '2', '-', 'G', 'W', '.', 'l', 'a', 'b', '1', '.', 'a',
|
||||
'w', 'a', 'k', 'e', '.', 'l', 'o', 'c', 'a', 'l', '\0' };
|
||||
WCHAR testServiceClass[ARRAYSIZE(ctestServiceClass)] = { 0 };
|
||||
WCHAR testServiceName[ARRAYSIZE(ctestServiceName)] = { 0 };
|
||||
WCHAR testSpn[ARRAYSIZE(ctestSpn)] = { 0 };
|
||||
|
||||
BOOL rc = FALSE;
|
||||
WCHAR Spn[100] = { 0 };
|
||||
DWORD status;
|
||||
DWORD SpnLength = -1;
|
||||
|
||||
ConvertUtf8NToWChar(ctestServiceClass, ARRAYSIZE(ctestServiceClass), testServiceClass,
|
||||
ARRAYSIZE(testServiceClass));
|
||||
ConvertUtf8NToWChar(ctestServiceName, ARRAYSIZE(ctestServiceName), testServiceName,
|
||||
ARRAYSIZE(testServiceName));
|
||||
ConvertUtf8NToWChar(ctestSpn, ARRAYSIZE(ctestSpn), testSpn, ARRAYSIZE(testSpn));
|
||||
|
||||
status = DsMakeSpnW(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
|
||||
|
||||
if (status != ERROR_INVALID_PARAMETER)
|
||||
|
@ -12,11 +12,10 @@ int TestFileDeleteFile(int argc, char* argv[])
|
||||
char validA[] = "/tmp/valid-test-file-XXXXXX";
|
||||
char validW[] = "/tmp/valid-test-file-XXXXXX";
|
||||
WCHAR* validWW = NULL;
|
||||
const char* invalidA = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
const WCHAR invalidW[] = { '/', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x',
|
||||
'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x',
|
||||
'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x',
|
||||
'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', '\0' };
|
||||
const char invalidA[] = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
WCHAR invalidW[sizeof(invalidA)] = { 0 };
|
||||
|
||||
ConvertUtf8NToWChar(invalidA, ARRAYSIZE(invalidA), invalidW, ARRAYSIZE(invalidW));
|
||||
|
||||
WINPR_UNUSED(argc);
|
||||
WINPR_UNUSED(argv);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <winpr/windows.h>
|
||||
|
||||
static const CHAR testFile1A[] = "TestFile1A";
|
||||
static const WCHAR testFile1W[] = { 'T', 'e', 's', 't', 'F', 'i', 'l', 'e', '1', 'W', '\0' };
|
||||
|
||||
static BOOL create_layout_files(size_t level, const char* BasePath, wArrayList* files)
|
||||
{
|
||||
@ -262,6 +261,8 @@ fail:
|
||||
|
||||
static int TestFileFindFirstFileW(const char* str)
|
||||
{
|
||||
WCHAR buffer[32] = { 0 };
|
||||
const WCHAR* testFile1W = InitializeConstWCharFromUtf8("TestFile1W", buffer, ARRAYSIZE(buffer));
|
||||
int rc = -1;
|
||||
if (!str)
|
||||
return -1;
|
||||
|
@ -914,41 +914,38 @@ char PathGetSeparatorA(unsigned long dwFlags)
|
||||
|
||||
WCHAR PathGetSeparatorW(unsigned long dwFlags)
|
||||
{
|
||||
WCHAR separator = PATH_SEPARATOR_CHR;
|
||||
union
|
||||
{
|
||||
WCHAR w;
|
||||
char c[2];
|
||||
} cnv;
|
||||
|
||||
cnv.c[0] = PATH_SEPARATOR_CHR;
|
||||
cnv.c[1] = '\0';
|
||||
|
||||
if (!dwFlags)
|
||||
dwFlags = PATH_STYLE_NATIVE;
|
||||
|
||||
if (dwFlags == PATH_STYLE_WINDOWS)
|
||||
separator = PATH_SEPARATOR_CHR;
|
||||
cnv.c[0] = PATH_SEPARATOR_CHR;
|
||||
else if (dwFlags == PATH_STYLE_UNIX)
|
||||
separator = PATH_SEPARATOR_CHR;
|
||||
cnv.c[0] = PATH_SEPARATOR_CHR;
|
||||
else if (dwFlags == PATH_STYLE_NATIVE)
|
||||
separator = PATH_SEPARATOR_CHR;
|
||||
cnv.c[0] = PATH_SEPARATOR_CHR;
|
||||
|
||||
return separator;
|
||||
return cnv.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* PathGetSharedLibraryExtension
|
||||
*/
|
||||
|
||||
static const CHAR SharedLibraryExtensionDllA[] = "dll";
|
||||
static const CHAR SharedLibraryExtensionSoA[] = "so";
|
||||
static const CHAR SharedLibraryExtensionDylibA[] = "dylib";
|
||||
|
||||
static const WCHAR SharedLibraryExtensionDllW[] = { 'd', 'l', 'l', '\0' };
|
||||
static const WCHAR SharedLibraryExtensionSoW[] = { 's', 'o', '\0' };
|
||||
static const WCHAR SharedLibraryExtensionDylibW[] = { 'd', 'y', 'l', 'i', 'b', '\0' };
|
||||
|
||||
static const CHAR SharedLibraryExtensionDotDllA[] = ".dll";
|
||||
static const CHAR SharedLibraryExtensionDotSoA[] = ".so";
|
||||
static const CHAR SharedLibraryExtensionDotDylibA[] = ".dylib";
|
||||
|
||||
static const WCHAR SharedLibraryExtensionDotDllW[] = { '.', 'd', 'l', 'l', '\0' };
|
||||
static const WCHAR SharedLibraryExtensionDotSoW[] = { '.', 's', 'o', '\0' };
|
||||
static const WCHAR SharedLibraryExtensionDotDylibW[] = { '.', 'd', 'y', 'l', 'i', 'b', '\0' };
|
||||
|
||||
PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags)
|
||||
{
|
||||
if (dwFlags & PATH_SHARED_LIB_EXT_EXPLICIT)
|
||||
@ -1009,6 +1006,20 @@ PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags)
|
||||
|
||||
PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags)
|
||||
{
|
||||
WCHAR buffer[6][16] = { 0 };
|
||||
const WCHAR* SharedLibraryExtensionDotDllW = InitializeConstWCharFromUtf8(
|
||||
SharedLibraryExtensionDotDllA, buffer[0], ARRAYSIZE(buffer[0]));
|
||||
const WCHAR* SharedLibraryExtensionDotSoW =
|
||||
InitializeConstWCharFromUtf8(SharedLibraryExtensionDotSoA, buffer[1], ARRAYSIZE(buffer[1]));
|
||||
const WCHAR* SharedLibraryExtensionDotDylibW = InitializeConstWCharFromUtf8(
|
||||
SharedLibraryExtensionDotDylibA, buffer[2], ARRAYSIZE(buffer[2]));
|
||||
const WCHAR* SharedLibraryExtensionDllW =
|
||||
InitializeConstWCharFromUtf8(SharedLibraryExtensionDllA, buffer[3], ARRAYSIZE(buffer[3]));
|
||||
const WCHAR* SharedLibraryExtensionSoW =
|
||||
InitializeConstWCharFromUtf8(SharedLibraryExtensionSoA, buffer[4], ARRAYSIZE(buffer[4]));
|
||||
const WCHAR* SharedLibraryExtensionDylibW =
|
||||
InitializeConstWCharFromUtf8(SharedLibraryExtensionDylibA, buffer[5], ARRAYSIZE(buffer[5]));
|
||||
|
||||
if (dwFlags & PATH_SHARED_LIB_EXT_EXPLICIT)
|
||||
{
|
||||
if (dwFlags & PATH_SHARED_LIB_EXT_WITH_DOT)
|
||||
@ -1121,7 +1132,8 @@ BOOL winpr_RemoveDirectory_RecursiveW(LPCWSTR lpPathName)
|
||||
return FALSE;
|
||||
_wcsncat(path_slash, lpPathName, pathnamelen);
|
||||
|
||||
const WCHAR star[] = { '*', '\0' };
|
||||
WCHAR starbuffer[8] = { 0 };
|
||||
const WCHAR* star = InitializeConstWCharFromUtf8("*", starbuffer, ARRAYSIZE(starbuffer));
|
||||
const HRESULT hr = NativePathCchAppendW(path_slash, path_slash_len, star);
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
@ -300,18 +300,23 @@ const SecPkgInfoA CREDSSP_SecPkgInfoA = {
|
||||
"Microsoft CredSSP Security Provider" /* Comment */
|
||||
};
|
||||
|
||||
static WCHAR CREDSSP_SecPkgInfoW_Name[] = { 'C', 'R', 'E', 'D', 'S', 'S', 'P', '\0' };
|
||||
|
||||
static WCHAR CREDSSP_SecPkgInfoW_Comment[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't',
|
||||
' ', 'C', 'r', 'e', 'd', 'S', 'S', 'P', ' ',
|
||||
'S', 'e', 'c', 'u', 'r', 'i', 't', 'y', ' ',
|
||||
'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r', '\0' };
|
||||
static WCHAR CREDSSP_SecPkgInfoW_NameBuffer[128] = { 0 };
|
||||
static WCHAR CREDSSP_SecPkgInfoW_CommentBuffer[128] = { 0 };
|
||||
|
||||
const SecPkgInfoW CREDSSP_SecPkgInfoW = {
|
||||
0x000110733, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0xFFFF, /* wRPCID */
|
||||
0x000090A8, /* cbMaxToken */
|
||||
CREDSSP_SecPkgInfoW_Name, /* Name */
|
||||
CREDSSP_SecPkgInfoW_Comment /* Comment */
|
||||
0x000110733, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0xFFFF, /* wRPCID */
|
||||
0x000090A8, /* cbMaxToken */
|
||||
CREDSSP_SecPkgInfoW_NameBuffer, /* Name */
|
||||
CREDSSP_SecPkgInfoW_CommentBuffer /* Comment */
|
||||
};
|
||||
|
||||
BOOL CREDSSP_init(void)
|
||||
{
|
||||
InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Name, CREDSSP_SecPkgInfoW_NameBuffer,
|
||||
ARRAYSIZE(CREDSSP_SecPkgInfoW_NameBuffer));
|
||||
InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Comment, CREDSSP_SecPkgInfoW_CommentBuffer,
|
||||
ARRAYSIZE(CREDSSP_SecPkgInfoW_CommentBuffer));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -37,4 +37,6 @@ extern const SecPkgInfoW CREDSSP_SecPkgInfoW;
|
||||
extern const SecurityFunctionTableA CREDSSP_SecurityFunctionTableA;
|
||||
extern const SecurityFunctionTableW CREDSSP_SecurityFunctionTableW;
|
||||
|
||||
BOOL CREDSSP_init(void);
|
||||
|
||||
#endif /* WINPR_SSPI_CREDSSP_PRIVATE_H */
|
||||
|
@ -69,19 +69,16 @@ const SecPkgInfoA KERBEROS_SecPkgInfoA = {
|
||||
"Kerberos Security Package" /* Comment */
|
||||
};
|
||||
|
||||
static WCHAR KERBEROS_SecPkgInfoW_Name[] = { 'K', 'e', 'r', 'b', 'e', 'r', 'o', 's', '\0' };
|
||||
|
||||
static WCHAR KERBEROS_SecPkgInfoW_Comment[] = { 'K', 'e', 'r', 'b', 'e', 'r', 'o', 's', ' ',
|
||||
'S', 'e', 'c', 'u', 'r', 'i', 't', 'y', ' ',
|
||||
'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0' };
|
||||
static WCHAR KERBEROS_SecPkgInfoW_NameBuffer[32] = { 0 };
|
||||
static WCHAR KERBEROS_SecPkgInfoW_CommentBuffer[32] = { 0 };
|
||||
|
||||
const SecPkgInfoW KERBEROS_SecPkgInfoW = {
|
||||
0x000F3BBF, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x0010, /* wRPCID */
|
||||
0x0000BB80, /* cbMaxToken : 48k bytes maximum for Windows Server 2012 */
|
||||
KERBEROS_SecPkgInfoW_Name, /* Name */
|
||||
KERBEROS_SecPkgInfoW_Comment /* Comment */
|
||||
0x000F3BBF, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x0010, /* wRPCID */
|
||||
0x0000BB80, /* cbMaxToken : 48k bytes maximum for Windows Server 2012 */
|
||||
KERBEROS_SecPkgInfoW_NameBuffer, /* Name */
|
||||
KERBEROS_SecPkgInfoW_CommentBuffer /* Comment */
|
||||
};
|
||||
|
||||
#ifdef WITH_KRB5
|
||||
@ -1825,3 +1822,12 @@ const SecurityFunctionTableW KERBEROS_SecurityFunctionTableW = {
|
||||
kerberos_SetContextAttributesW, /* SetContextAttributes */
|
||||
kerberos_SetCredentialsAttributesW, /* SetCredentialsAttributes */
|
||||
};
|
||||
|
||||
BOOL KERBEROS_init(void)
|
||||
{
|
||||
InitializeConstWCharFromUtf8(KERBEROS_SecPkgInfoA.Name, KERBEROS_SecPkgInfoW_NameBuffer,
|
||||
ARRAYSIZE(KERBEROS_SecPkgInfoW_NameBuffer));
|
||||
InitializeConstWCharFromUtf8(KERBEROS_SecPkgInfoA.Comment, KERBEROS_SecPkgInfoW_CommentBuffer,
|
||||
ARRAYSIZE(KERBEROS_SecPkgInfoW_CommentBuffer));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -34,4 +34,6 @@ extern const SecPkgInfoW KERBEROS_SecPkgInfoW;
|
||||
extern const SecurityFunctionTableA KERBEROS_SecurityFunctionTableA;
|
||||
extern const SecurityFunctionTableW KERBEROS_SecurityFunctionTableW;
|
||||
|
||||
BOOL KERBEROS_init(void);
|
||||
|
||||
#endif /* WINPR_SSPI_KERBEROS_PRIVATE_H */
|
||||
|
@ -1398,31 +1398,26 @@ const SecPkgInfoA NTLM_SecPkgInfoA = {
|
||||
"NTLM Security Package" /* Comment */
|
||||
};
|
||||
|
||||
static WCHAR NTLM_SecPkgInfoW_Name[] = { 'N', 'T', 'L', 'M', '\0' };
|
||||
|
||||
static WCHAR NTLM_SecPkgInfoW_Comment[] = {
|
||||
'N', 'T', 'L', 'M', ' ', 'S', 'e', 'c', 'u', 'r', 'i',
|
||||
't', 'y', ' ', 'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0'
|
||||
};
|
||||
static WCHAR NTLM_SecPkgInfoW_NameBuffer[32] = { 0 };
|
||||
static WCHAR NTLM_SecPkgInfoW_CommentBuffer[32] = { 0 };
|
||||
|
||||
const SecPkgInfoW NTLM_SecPkgInfoW = {
|
||||
0x00082B37, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000A, /* wRPCID */
|
||||
0x00000B48, /* cbMaxToken */
|
||||
NTLM_SecPkgInfoW_Name, /* Name */
|
||||
NTLM_SecPkgInfoW_Comment /* Comment */
|
||||
0x00082B37, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000A, /* wRPCID */
|
||||
0x00000B48, /* cbMaxToken */
|
||||
NTLM_SecPkgInfoW_NameBuffer, /* Name */
|
||||
NTLM_SecPkgInfoW_CommentBuffer /* Comment */
|
||||
};
|
||||
|
||||
char* ntlm_negotiate_flags_string(char* buffer, size_t size, UINT32 flags)
|
||||
{
|
||||
int x;
|
||||
if (!buffer || (size == 0))
|
||||
return buffer;
|
||||
|
||||
_snprintf(buffer, size, "[0x%08" PRIx32 "] ", flags);
|
||||
|
||||
for (x = 0; x < 31; x++)
|
||||
for (int x = 0; x < 31; x++)
|
||||
{
|
||||
const UINT32 mask = 1 << x;
|
||||
size_t len = strnlen(buffer, size);
|
||||
@ -1521,3 +1516,13 @@ BOOL ntlm_reset_cipher_state(PSecHandle phContext)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NTLM_init(void)
|
||||
{
|
||||
InitializeConstWCharFromUtf8(NTLM_SecPkgInfoA.Name, NTLM_SecPkgInfoW_NameBuffer,
|
||||
ARRAYSIZE(NTLM_SecPkgInfoW_NameBuffer));
|
||||
InitializeConstWCharFromUtf8(NTLM_SecPkgInfoA.Comment, NTLM_SecPkgInfoW_CommentBuffer,
|
||||
ARRAYSIZE(NTLM_SecPkgInfoW_CommentBuffer));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -296,4 +296,6 @@ SECURITY_STATUS ntlm_computeMicValue(NTLM_CONTEXT* ntlm, SecBuffer* micvalue);
|
||||
#define WITH_DEBUG_NTLM
|
||||
#endif
|
||||
|
||||
BOOL NTLM_init(void);
|
||||
|
||||
#endif /* WINPR_SSPI_NTLM_PRIVATE_H */
|
||||
|
@ -73,19 +73,16 @@ const SecPkgInfoA NEGOTIATE_SecPkgInfoA = {
|
||||
"Microsoft Package Negotiator" /* Comment */
|
||||
};
|
||||
|
||||
static WCHAR NEGOTIATE_SecPkgInfoW_Name[] = { 'N', 'e', 'g', 'o', 't', 'i', 'a', 't', 'e', '\0' };
|
||||
|
||||
static WCHAR NEGOTIATE_SecPkgInfoW_Comment[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', ' ',
|
||||
'P', 'a', 'c', 'k', 'a', 'g', 'e', ' ', 'N', 'e',
|
||||
'g', 'o', 't', 'i', 'a', 't', 'o', 'r', '\0' };
|
||||
static WCHAR NEGOTIATE_SecPkgInfoW_NameBuffer[32] = { 0 };
|
||||
static WCHAR NEGOTIATE_SecPkgInfoW_CommentBuffer[32] = { 0 };
|
||||
|
||||
const SecPkgInfoW NEGOTIATE_SecPkgInfoW = {
|
||||
0x00083BB3, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x0009, /* wRPCID */
|
||||
0x00002FE0, /* cbMaxToken */
|
||||
NEGOTIATE_SecPkgInfoW_Name, /* Name */
|
||||
NEGOTIATE_SecPkgInfoW_Comment /* Comment */
|
||||
0x00083BB3, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x0009, /* wRPCID */
|
||||
0x00002FE0, /* cbMaxToken */
|
||||
NEGOTIATE_SecPkgInfoW_NameBuffer, /* Name */
|
||||
NEGOTIATE_SecPkgInfoW_CommentBuffer /* Comment */
|
||||
};
|
||||
|
||||
static const WinPrAsn1_OID spnego_OID = { 6, (BYTE*)"\x2b\x06\x01\x05\x05\x02" };
|
||||
@ -1642,3 +1639,13 @@ const SecurityFunctionTableW NEGOTIATE_SecurityFunctionTableW = {
|
||||
negotiate_SetContextAttributesW, /* SetContextAttributes */
|
||||
negotiate_SetCredentialsAttributesW, /* SetCredentialsAttributes */
|
||||
};
|
||||
|
||||
BOOL NEGOTIATE_init(void)
|
||||
{
|
||||
InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Name, NEGOTIATE_SecPkgInfoW_NameBuffer,
|
||||
ARRAYSIZE(NEGOTIATE_SecPkgInfoW_NameBuffer));
|
||||
InitializeConstWCharFromUtf8(NEGOTIATE_SecPkgInfoA.Comment, NEGOTIATE_SecPkgInfoW_CommentBuffer,
|
||||
ARRAYSIZE(NEGOTIATE_SecPkgInfoW_CommentBuffer));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -52,4 +52,6 @@ extern const SecPkgInfoW NEGOTIATE_SecPkgInfoW;
|
||||
extern const SecurityFunctionTableA NEGOTIATE_SecurityFunctionTableA;
|
||||
extern const SecurityFunctionTableW NEGOTIATE_SecurityFunctionTableW;
|
||||
|
||||
BOOL NEGOTIATE_init(void);
|
||||
|
||||
#endif /* WINPR_SSPI_NEGOTIATE_PRIVATE_H */
|
||||
|
@ -445,17 +445,23 @@ const SecPkgInfoA SCHANNEL_SecPkgInfoA = {
|
||||
"Schannel Security Package" /* Comment */
|
||||
};
|
||||
|
||||
static WCHAR SCHANNEL_SecPkgInfoW_Name[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', '\0' };
|
||||
|
||||
static WCHAR SCHANNEL_SecPkgInfoW_Comment[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', ' ',
|
||||
'S', 'e', 'c', 'u', 'r', 'i', 't', 'y', ' ',
|
||||
'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0' };
|
||||
static WCHAR SCHANNEL_SecPkgInfoW_NameBuffer[32] = { 0 };
|
||||
static WCHAR SCHANNEL_SecPkgInfoW_CommentBuffer[32] = { 0 };
|
||||
|
||||
const SecPkgInfoW SCHANNEL_SecPkgInfoW = {
|
||||
0x000107B3, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000E, /* wRPCID */
|
||||
SCHANNEL_CB_MAX_TOKEN, /* cbMaxToken */
|
||||
SCHANNEL_SecPkgInfoW_Name, /* Name */
|
||||
SCHANNEL_SecPkgInfoW_Comment /* Comment */
|
||||
0x000107B3, /* fCapabilities */
|
||||
1, /* wVersion */
|
||||
0x000E, /* wRPCID */
|
||||
SCHANNEL_CB_MAX_TOKEN, /* cbMaxToken */
|
||||
SCHANNEL_SecPkgInfoW_NameBuffer, /* Name */
|
||||
SCHANNEL_SecPkgInfoW_CommentBuffer /* Comment */
|
||||
};
|
||||
|
||||
BOOL SCHANNEL_init(void)
|
||||
{
|
||||
InitializeConstWCharFromUtf8(SCHANNEL_SecPkgInfoA.Name, SCHANNEL_SecPkgInfoW_NameBuffer,
|
||||
ARRAYSIZE(SCHANNEL_SecPkgInfoW_NameBuffer));
|
||||
InitializeConstWCharFromUtf8(SCHANNEL_SecPkgInfoA.Comment, SCHANNEL_SecPkgInfoW_CommentBuffer,
|
||||
ARRAYSIZE(SCHANNEL_SecPkgInfoW_CommentBuffer));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -48,4 +48,6 @@ extern const SecPkgInfoW SCHANNEL_SecPkgInfoW;
|
||||
extern const SecurityFunctionTableA SCHANNEL_SecurityFunctionTableA;
|
||||
extern const SecurityFunctionTableW SCHANNEL_SecurityFunctionTableW;
|
||||
|
||||
BOOL SCHANNEL_init(void);
|
||||
|
||||
#endif /* WINPR_SSPI_SCHANNEL_PRIVATE_H */
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
/* Authentication Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa374731/ */
|
||||
|
||||
#include "NTLM/ntlm.h"
|
||||
#include "NTLM/ntlm_export.h"
|
||||
#include "CredSSP/credssp.h"
|
||||
#include "Kerberos/kerberos.h"
|
||||
@ -73,18 +74,14 @@ static const SecurityFunctionTableA_NAME SecurityFunctionTableA_NAME_LIST[] = {
|
||||
{ "Schannel", &SCHANNEL_SecurityFunctionTableA }
|
||||
};
|
||||
|
||||
static const WCHAR _NTLM_NAME_W[] = { 'N', 'T', 'L', 'M', '\0' };
|
||||
static const WCHAR _KERBEROS_NAME_W[] = { 'K', 'e', 'r', 'b', 'e', 'r', 'o', 's', '\0' };
|
||||
static const WCHAR _NEGOTIATE_NAME_W[] = { 'N', 'e', 'g', 'o', 't', 'i', 'a', 't', 'e', '\0' };
|
||||
static const WCHAR _CREDSSP_NAME_W[] = { 'C', 'r', 'e', 'd', 'S', 'S', 'P', '\0' };
|
||||
static const WCHAR _SCHANNEL_NAME_W[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', '\0' };
|
||||
static WCHAR BUFFER_NAME_LIST_W[5][32] = { 0 };
|
||||
|
||||
static const SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME_LIST[] = {
|
||||
{ _NTLM_NAME_W, &NTLM_SecurityFunctionTableW },
|
||||
{ _KERBEROS_NAME_W, &KERBEROS_SecurityFunctionTableW },
|
||||
{ _NEGOTIATE_NAME_W, &NEGOTIATE_SecurityFunctionTableW },
|
||||
{ _CREDSSP_NAME_W, &CREDSSP_SecurityFunctionTableW },
|
||||
{ _SCHANNEL_NAME_W, &SCHANNEL_SecurityFunctionTableW }
|
||||
{ BUFFER_NAME_LIST_W[0], &NTLM_SecurityFunctionTableW },
|
||||
{ BUFFER_NAME_LIST_W[1], &KERBEROS_SecurityFunctionTableW },
|
||||
{ BUFFER_NAME_LIST_W[2], &NEGOTIATE_SecurityFunctionTableW },
|
||||
{ BUFFER_NAME_LIST_W[3], &CREDSSP_SecurityFunctionTableW },
|
||||
{ BUFFER_NAME_LIST_W[4], &SCHANNEL_SecurityFunctionTableW }
|
||||
};
|
||||
|
||||
#define SecHandle_LOWER_MAX 0xFFFFFFFF
|
||||
@ -949,11 +946,33 @@ PSecBuffer sspi_FindSecBuffer(PSecBufferDesc pMessage, ULONG BufferType)
|
||||
return pSecBuffer;
|
||||
}
|
||||
|
||||
static BOOL WINPR_init(void)
|
||||
{
|
||||
|
||||
for (size_t x = 0; x < ARRAYSIZE(SecurityFunctionTableA_NAME_LIST); x++)
|
||||
{
|
||||
const SecurityFunctionTableA_NAME* const cur = &SecurityFunctionTableA_NAME_LIST[x];
|
||||
InitializeConstWCharFromUtf8(cur->Name, BUFFER_NAME_LIST_W[x],
|
||||
ARRAYSIZE(BUFFER_NAME_LIST_W[x]));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK sspi_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID* Context)
|
||||
{
|
||||
winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT);
|
||||
sspi_ContextBufferAllocTableNew();
|
||||
return TRUE;
|
||||
if (!SCHANNEL_init())
|
||||
return FALSE;
|
||||
if (!KERBEROS_init())
|
||||
return FALSE;
|
||||
if (!NTLM_init())
|
||||
return FALSE;
|
||||
if (!CREDSSP_init())
|
||||
return FALSE;
|
||||
if (!NEGOTIATE_init())
|
||||
return FALSE;
|
||||
return WINPR_init();
|
||||
}
|
||||
|
||||
void sspi_GlobalInit(void)
|
||||
|
Loading…
Reference in New Issue
Block a user