diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 8c5be64ac..4efe3e00b 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -114,7 +114,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE winpr - MODULES winpr-registry winpr-utils winpr-sspi winpr-crt) + MODULES winpr-registry winpr-utils winpr-dsparse winpr-sspi winpr-crt) if(MONOLITHIC_BUILD) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) diff --git a/libfreerdp/core/rpc.c b/libfreerdp/core/rpc.c index 5c5ee3ad2..880ec2231 100644 --- a/libfreerdp/core/rpc.c +++ b/libfreerdp/core/rpc.c @@ -27,6 +27,8 @@ #include #include +#include + #include #include "http.h" @@ -65,6 +67,25 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char* sspi_SetAuthIdentity(&(ntlm->identity), user, domain, password); + if (http) + { + DWORD status; + DWORD SpnLength; + + SpnLength = 0; + status = DsMakeSpn(_T("HTTP"), _T("LAB1-W2K8R2-GW.lab1.awake.local"), NULL, 0, NULL, &SpnLength, NULL); + + if (status != ERROR_BUFFER_OVERFLOW) + { + _tprintf(_T("DsMakeSpn: expected ERROR_BUFFER_OVERFLOW\n")); + return -1; + } + + ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR)); + + status = DsMakeSpn(_T("HTTP"), _T("LAB1-W2K8R2-GW.lab1.awake.local"), NULL, 0, NULL, &SpnLength, ntlm->ServicePrincipalName); + } + status = ntlm->table->QuerySecurityPackageInfo(NTLMSP_NAME, &ntlm->pPackageInfo); if (status != SEC_E_OK) @@ -114,6 +135,38 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char* return TRUE; } +BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCTSTR ServiceClass, char* hostname) +{ + int length; + DWORD status; + DWORD SpnLength; + LPTSTR hostnameX; + +#ifdef UNICODE + length = strlen(hostname); + hostnameX = (LPWSTR) malloc(length * sizeof(TCHAR)); + MultiByteToWideChar(CP_ACP, 0, hostname, length, hostnameX, length); + hostnameX[length] = 0; +#else + hostnameX = hostname; +#endif + + SpnLength = 0; + status = DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, NULL); + + if (status != ERROR_BUFFER_OVERFLOW) + return FALSE; + + ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR)); + + status = DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, ntlm->ServicePrincipalName); + + if (status != ERROR_SUCCESS) + return -1; + + return TRUE; +} + BOOL ntlm_authenticate(rdpNtlm* ntlm) { SECURITY_STATUS status; @@ -135,7 +188,8 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm) status = ntlm->table->InitializeSecurityContext(&ntlm->credentials, (ntlm->haveContext) ? &ntlm->context : NULL, - NULL, ntlm->fContextReq, 0, SECURITY_NATIVE_DREP, + (ntlm->ServicePrincipalName) ? ntlm->ServicePrincipalName : NULL, + ntlm->fContextReq, 0, SECURITY_NATIVE_DREP, (ntlm->haveInputBuffer) ? &ntlm->inputBufferDesc : NULL, 0, &ntlm->context, &ntlm->outputBufferDesc, &ntlm->pfContextAttr, &ntlm->expiration); @@ -243,11 +297,13 @@ BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc) { ntlm_client_init(ntlm, TRUE, settings->username, settings->domain, settings->password); + ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname); } else { ntlm_client_init(ntlm, TRUE, settings->tsg_username, settings->tsg_domain, settings->tsg_password); + ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname); } ntlm_authenticate(ntlm); @@ -292,13 +348,26 @@ BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc) BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc) { STREAM* s; + rdpSettings* settings; int ntlm_token_length; BYTE* ntlm_token_data; HttpResponse* http_response; rdpNtlm* ntlm = rpc->ntlm_http_in->ntlm; - ntlm_client_init(ntlm, TRUE, rpc->settings->username, - rpc->settings->domain, rpc->settings->password); + settings = rpc->settings; + + if (settings->tsg_same_credentials) + { + ntlm_client_init(ntlm, TRUE, settings->username, + settings->domain, settings->password); + ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname); + } + else + { + ntlm_client_init(ntlm, TRUE, settings->tsg_username, + settings->tsg_domain, settings->tsg_password); + ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname); + } ntlm_authenticate(ntlm); diff --git a/libfreerdp/core/rpc.h b/libfreerdp/core/rpc.h index 619ac8119..a166f8451 100644 --- a/libfreerdp/core/rpc.h +++ b/libfreerdp/core/rpc.h @@ -540,6 +540,7 @@ struct rdp_ntlm SecBuffer outputBuffer; BOOL haveContext; BOOL haveInputBuffer; + LPTSTR ServicePrincipalName; SecBufferDesc inputBufferDesc; SecBufferDesc outputBufferDesc; CredHandle credentials; diff --git a/winpr/include/winpr/dsparse.h b/winpr/include/winpr/dsparse.h index 9f5f53cf8..6664eae30 100644 --- a/winpr/include/winpr/dsparse.h +++ b/winpr/include/winpr/dsparse.h @@ -22,14 +22,76 @@ #ifdef _WIN32 +#include #include +#include + #else #include #include #include +typedef enum +{ + DS_NAME_NO_FLAGS = 0x0, + DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1, + DS_NAME_FLAG_EVAL_AT_DC = 0x2, + DS_NAME_FLAG_GCVERIFY = 0x4, + DS_NAME_FLAG_TRUST_REFERRAL = 0x8 +} DS_NAME_FLAGS; + +typedef enum +{ + DS_UNKNOWN_NAME = 0, + DS_FQDN_1779_NAME = 1, + DS_NT4_ACCOUNT_NAME = 2, + DS_DISPLAY_NAME = 3, + DS_UNIQUE_ID_NAME = 6, + DS_CANONICAL_NAME = 7, + DS_USER_PRINCIPAL_NAME = 8, + DS_CANONICAL_NAME_EX = 9, + DS_SERVICE_PRINCIPAL_NAME = 10, + DS_SID_OR_SID_HISTORY_NAME = 11, + DS_DNS_DOMAIN_NAME = 12 +} DS_NAME_FORMAT; + +typedef enum +{ + DS_NAME_NO_ERROR = 0, + DS_NAME_ERROR_RESOLVING = 1, + DS_NAME_ERROR_NOT_FOUND = 2, + DS_NAME_ERROR_NOT_UNIQUE = 3, + DS_NAME_ERROR_NO_MAPPING = 4, + DS_NAME_ERROR_DOMAIN_ONLY = 5, + DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6, + DS_NAME_ERROR_TRUST_REFERRAL = 7 +} DS_NAME_ERROR; + +typedef enum +{ + DS_SPN_DNS_HOST = 0, + DS_SPN_DN_HOST = 1, + DS_SPN_NB_HOST = 2, + DS_SPN_DOMAIN = 3, + DS_SPN_NB_DOMAIN = 4, + DS_SPN_SERVICE = 5 +} DS_SPN_NAME_TYPE; + +typedef struct +{ + DWORD status; + LPTSTR pDomain; + LPTSTR pName; +} DS_NAME_RESULT_ITEM, *PDS_NAME_RESULT_ITEM; + +typedef struct +{ + DWORD cItems; + PDS_NAME_RESULT_ITEM rItems; +} DS_NAME_RESULT, *PDS_NAME_RESULT; + WINPR_API DWORD DsCrackSpnW(LPCWSTR pszSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName, LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName, USHORT* pInstancePort); diff --git a/winpr/include/winpr/midl.h b/winpr/include/winpr/midl.h index 75a87eb38..0f87efe8d 100644 --- a/winpr/include/winpr/midl.h +++ b/winpr/include/winpr/midl.h @@ -22,7 +22,11 @@ #include +#ifndef _WIN32 + WINPR_API void* MIDL_user_allocate(size_t cBytes); WINPR_API void MIDL_user_free(void* p); +#endif + #endif /* WINPR_RPC_MIDL_H */ diff --git a/winpr/include/winpr/ndr.h b/winpr/include/winpr/ndr.h index b26c75b0a..58ce654cb 100644 --- a/winpr/include/winpr/ndr.h +++ b/winpr/include/winpr/ndr.h @@ -23,6 +23,8 @@ #include #include +#ifndef _WIN32 + #define __RPC_WIN32__ 1 #define TARGET_IS_NT50_OR_LATER 1 @@ -525,4 +527,6 @@ typedef void (*NDR_TYPE_FREE_ROUTINE)(PMIDL_STUB_MESSAGE pStubMsg, unsigned char WINPR_API CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...); +#endif + #endif /* WINPR_RPC_NDR_H */ diff --git a/winpr/include/winpr/rpc.h b/winpr/include/winpr/rpc.h index 31257d2ce..248f88e78 100644 --- a/winpr/include/winpr/rpc.h +++ b/winpr/include/winpr/rpc.h @@ -20,6 +20,12 @@ #ifndef WINPR_RPC_H #define WINPR_RPC_H +#ifdef _WIN32 + +#include + +#else + #include #include @@ -42,4 +48,6 @@ typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; void RpcRaiseException(RPC_STATUS exception); +#endif + #endif /* WINPR_RPC_H */ diff --git a/winpr/libwinpr/dsparse/CMakeLists.txt b/winpr/libwinpr/dsparse/CMakeLists.txt index 0775a8633..0cbd4452a 100644 --- a/winpr/libwinpr/dsparse/CMakeLists.txt +++ b/winpr/libwinpr/dsparse/CMakeLists.txt @@ -21,16 +21,29 @@ set(MODULE_PREFIX "WINPR_DSPARSE") set(${MODULE_PREFIX}_SRCS dsparse.c) +if(MSVC AND (NOT MONOLITHIC_BUILD)) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def) +endif() + add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT" MONOLITHIC ${MONOLITHIC_BUILD} SOURCES ${${MODULE_PREFIX}_SRCS}) set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -if(MONOLITHIC_BUILD) +if(WIN32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ntdsapi) +endif() +if(MONOLITHIC_BUILD) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/winpr/libwinpr/dsparse/module.def b/winpr/libwinpr/dsparse/module.def new file mode 100644 index 000000000..683aae863 --- /dev/null +++ b/winpr/libwinpr/dsparse/module.def @@ -0,0 +1,3 @@ +LIBRARY "libwinpr-dsparse" +EXPORTS + diff --git a/winpr/libwinpr/dsparse/test/.gitignore b/winpr/libwinpr/dsparse/test/.gitignore new file mode 100644 index 000000000..38ad7151f --- /dev/null +++ b/winpr/libwinpr/dsparse/test/.gitignore @@ -0,0 +1,2 @@ +TestDs +TestDs.c diff --git a/winpr/libwinpr/dsparse/test/CMakeLists.txt b/winpr/libwinpr/dsparse/test/CMakeLists.txt new file mode 100644 index 000000000..e7efe6513 --- /dev/null +++ b/winpr/libwinpr/dsparse/test/CMakeLists.txt @@ -0,0 +1,31 @@ + +set(MODULE_NAME "TestDsParse") +set(MODULE_PREFIX "TEST_DSPARSE") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestDsMakeSpn.c + TestDsCrackNames.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE winpr + MODULES winpr-dsparse) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName}) +endforeach() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") diff --git a/winpr/libwinpr/dsparse/test/TestDsCrackNames.c b/winpr/libwinpr/dsparse/test/TestDsCrackNames.c new file mode 100644 index 000000000..b2645442f --- /dev/null +++ b/winpr/libwinpr/dsparse/test/TestDsCrackNames.c @@ -0,0 +1,50 @@ + +#include +#include +#include +#include +#include + +//LPCTSTR testName = _T("LAB1\\JohnDoe"); + +int TestDsCrackNames(int argc, char* argv[]) +{ +#if 0 + HANDLE ds; + DWORD status; + PDS_NAME_RESULT pResult; + + status = DsBind(NULL, NULL, &ds); + + if (status != ERROR_SUCCESS) + { + _tprintf(_T("DsBind: expected ERROR_SUCCESS: 0x%08X\n"), status); + return -1; + } + + status = DsCrackNames(ds, DS_NAME_FLAG_SYNTACTICAL_ONLY, DS_NT4_ACCOUNT_NAME, + DS_USER_PRINCIPAL_NAME, 1, &testName, &pResult); + + if (status != ERROR_SUCCESS) + { + _tprintf(_T("DsCrackNames: expected ERROR_SUCCESS\n")); + return -1; + } + + _tprintf(_T("DsCrackNames: pResult->cItems: %d\n"), pResult->cItems); + + _tprintf(_T("DsCrackNames: pResult->rItems[0]: Domain: %s Name: %s Status: 0x%08X\n"), + pResult->rItems[0].pDomain, pResult->rItems[0].pName, pResult->rItems[0].status); + + status = DsUnBind(&ds); + + if (status != ERROR_SUCCESS) + { + _tprintf(_T("DsUnBind: expected ERROR_SUCCESS\n")); + return -1; + } +#endif + + return 0; +} + diff --git a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c new file mode 100644 index 000000000..00e7ecc12 --- /dev/null +++ b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c @@ -0,0 +1,56 @@ + +#include +#include +#include +#include +#include + +LPCTSTR testServiceClass = _T("HTTP"); +LPCTSTR testServiceName = _T("LAB1-W2K8R2-GW.lab1.awake.local"); + +int TestDsMakeSpn(int argc, char* argv[]) +{ + LPTSTR Spn; + DWORD status; + DWORD SpnLength; + + SpnLength = -1; + status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL); + + if (status != ERROR_INVALID_PARAMETER) + { + _tprintf(_T("DsMakeSpn: expected ERROR_INVALID_PARAMETER\n")); + return -1; + } + + SpnLength = 0; + status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL); + + if (status != ERROR_BUFFER_OVERFLOW) + { + _tprintf(_T("DsMakeSpn: expected ERROR_BUFFER_OVERFLOW\n")); + return -1; + } + + if (SpnLength != 37) + { + _tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %d, Expected: %d\n"), SpnLength, 37); + return -1; + } + + /* SpnLength includes null terminator */ + Spn = (LPTSTR) malloc(SpnLength * sizeof(TCHAR)); + + status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, Spn); + + if (status != ERROR_SUCCESS) + { + _tprintf(_T("DsMakeSpn: expected ERROR_SUCCESS\n")); + return -1; + } + + _tprintf(_T("DsMakeSpn: %s\n"), Spn); + + return 0; +} + diff --git a/winpr/libwinpr/dsparse/test/TestDsParse.c b/winpr/libwinpr/dsparse/test/TestDsParse.c new file mode 100644 index 000000000..98a7e63f5 --- /dev/null +++ b/winpr/libwinpr/dsparse/test/TestDsParse.c @@ -0,0 +1,165 @@ +#include +#include +#include +#include + + + + +/* Forward declare test functions. */ +int TestDsMakeSpn(int, char*[]); +int TestDsCrackNames(int, char*[]); + + +/* Create map. */ + +typedef int (*MainFuncPointer)(int , char*[]); +typedef struct +{ + const char* name; + MainFuncPointer func; +} functionMapEntry; + +functionMapEntry cmakeGeneratedFunctionMapEntries[] = { + { + "TestDsMakeSpn", + TestDsMakeSpn + }, + { + "TestDsCrackNames", + TestDsCrackNames + }, + + {0,0} +}; + +/* Allocate and create a lowercased copy of string + (note that it has to be free'd manually) */ + +char* lowercase(const char *string) +{ + char *new_string, *p; + +#ifdef __cplusplus + new_string = static_cast(malloc(sizeof(char) * + static_cast(strlen(string) + 1))); +#else + new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1))); +#endif + + if (!new_string) + { + return 0; + } + strcpy(new_string, string); + p = new_string; + while (*p != 0) + { +#ifdef __cplusplus + *p = static_cast(tolower(*p)); +#else + *p = (char)(tolower(*p)); +#endif + + ++p; + } + return new_string; +} + +int main(int ac, char *av[]) +{ + int i, NumTests, testNum, partial_match; + char *arg, *test_name; + int count; + int testToRun = -1; + + + + for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) + { + } + NumTests = count; + /* If no test name was given */ + /* process command line with user function. */ + if (ac < 2) + { + /* Ask for a test. */ + printf("Available tests:\n"); + for (i =0; i < NumTests; ++i) + { + printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); + } + printf("To run a test, enter the test number: "); + fflush(stdout); + testNum = 0; + if( scanf("%d", &testNum) != 1 ) + { + printf("Couldn't parse that input as a number\n"); + return -1; + } + if (testNum >= NumTests) + { + printf("%3d is an invalid test number.\n", testNum); + return -1; + } + testToRun = testNum; + ac--; + av++; + } + partial_match = 0; + arg = 0; + /* If partial match is requested. */ + if(testToRun == -1 && ac > 1) + { + partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; + } + if (partial_match && ac < 3) + { + printf("-R needs an additional parameter.\n"); + return -1; + } + if(testToRun == -1) + { + arg = lowercase(av[1 + partial_match]); + } + for (i =0; i < NumTests && testToRun == -1; ++i) + { + test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); + if (partial_match && strstr(test_name, arg) != NULL) + { + testToRun = i; + ac -=2; + av += 2; + } + else if (!partial_match && strcmp(test_name, arg) == 0) + { + testToRun = i; + ac--; + av++; + } + free(test_name); + } + if(arg) + { + free(arg); + } + if(testToRun != -1) + { + int result; + + result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); + + return result; + } + + + /* Nothing was run, display the test names. */ + printf("Available tests:\n"); + for (i =0; i < NumTests; ++i) + { + printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); + } + printf("Failed: %s is an invalid test name.\n", av[1]); + + return -1; +} diff --git a/winpr/libwinpr/rpc/ndr.c b/winpr/libwinpr/rpc/ndr.c index d90a2a03b..f10439731 100644 --- a/winpr/libwinpr/rpc/ndr.c +++ b/winpr/libwinpr/rpc/ndr.c @@ -27,6 +27,8 @@ #include +#ifndef _WIN32 + #include "ndr_array.h" #include "ndr_context.h" #include "ndr_pointer.h" @@ -344,3 +346,5 @@ CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRIN return client_call_return; } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_array.c b/winpr/libwinpr/rpc/ndr_array.c index d9c53c5ea..54b1ecc02 100644 --- a/winpr/libwinpr/rpc/ndr_array.c +++ b/winpr/libwinpr/rpc/ndr_array.c @@ -28,6 +28,8 @@ #include "ndr_array.h" +#ifndef _WIN32 + void NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat) { /** @@ -139,3 +141,5 @@ void NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemo printf("warning: NdrComplexArrayBufferSize unimplemented\n"); } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_array.h b/winpr/libwinpr/rpc/ndr_array.h index 3a6bc2d44..e29629717 100644 --- a/winpr/libwinpr/rpc/ndr_array.h +++ b/winpr/libwinpr/rpc/ndr_array.h @@ -22,10 +22,14 @@ #include +#ifndef _WIN32 + void NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrConformantVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_ARRAY_H */ diff --git a/winpr/libwinpr/rpc/ndr_context.c b/winpr/libwinpr/rpc/ndr_context.c index 531840074..88120bdb2 100644 --- a/winpr/libwinpr/rpc/ndr_context.c +++ b/winpr/libwinpr/rpc/ndr_context.c @@ -25,6 +25,9 @@ #include #include + +#ifndef _WIN32 + #include "ndr_context.h" #include "ndr_private.h" @@ -68,3 +71,5 @@ void NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem NdrpIncrementLength(&(pStubMsg->BufferLength), 20); } } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_context.h b/winpr/libwinpr/rpc/ndr_context.h index 7b8770c2a..95b74b290 100644 --- a/winpr/libwinpr/rpc/ndr_context.h +++ b/winpr/libwinpr/rpc/ndr_context.h @@ -22,6 +22,10 @@ #include +#ifndef _WIN32 + void NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_CONTEXT_H */ diff --git a/winpr/libwinpr/rpc/ndr_correlation.c b/winpr/libwinpr/rpc/ndr_correlation.c index 3deb4caca..e048b7bcf 100644 --- a/winpr/libwinpr/rpc/ndr_correlation.c +++ b/winpr/libwinpr/rpc/ndr_correlation.c @@ -25,6 +25,9 @@ #include #include + +#ifndef _WIN32 + #include "ndr_correlation.h" #include "ndr_private.h" @@ -189,3 +192,5 @@ PFORMAT_STRING NdrpComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* p return pFormat; } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_correlation.h b/winpr/libwinpr/rpc/ndr_correlation.h index 01724b408..03f47b88f 100644 --- a/winpr/libwinpr/rpc/ndr_correlation.h +++ b/winpr/libwinpr/rpc/ndr_correlation.h @@ -22,8 +22,12 @@ #include +#ifndef _WIN32 + PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat, ULONG_PTR* pCount); PFORMAT_STRING NdrpComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); PFORMAT_STRING NdrpComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_CORRELATION_H */ diff --git a/winpr/libwinpr/rpc/ndr_pointer.c b/winpr/libwinpr/rpc/ndr_pointer.c index f140776d3..691691d2d 100644 --- a/winpr/libwinpr/rpc/ndr_pointer.c +++ b/winpr/libwinpr/rpc/ndr_pointer.c @@ -25,6 +25,9 @@ #include #include + +#ifndef _WIN32 + #include "ndr_pointer.h" #include "ndr_private.h" @@ -324,3 +327,5 @@ void NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* p { printf("warning: NdrByteCountPointerBufferSize unimplemented\n"); } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_pointer.h b/winpr/libwinpr/rpc/ndr_pointer.h index 676832239..292bafa5c 100644 --- a/winpr/libwinpr/rpc/ndr_pointer.h +++ b/winpr/libwinpr/rpc/ndr_pointer.h @@ -22,6 +22,8 @@ #include +#ifndef _WIN32 + PFORMAT_STRING NdrpSkipPointerLayout(PFORMAT_STRING pFormat); void NdrpPointerBufferSize(unsigned char* pMemory, PFORMAT_STRING pFormat, PMIDL_STUB_MESSAGE pStubMsg); @@ -34,4 +36,6 @@ PFORMAT_STRING NdrpEmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsign void NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_POINTER_H */ diff --git a/winpr/libwinpr/rpc/ndr_private.c b/winpr/libwinpr/rpc/ndr_private.c index db57de23b..f927a1321 100644 --- a/winpr/libwinpr/rpc/ndr_private.c +++ b/winpr/libwinpr/rpc/ndr_private.c @@ -26,6 +26,8 @@ #include +#ifndef _WIN32 + #include "ndr_array.h" #include "ndr_context.h" #include "ndr_pointer.h" @@ -554,3 +556,5 @@ const NDR_TYPE_FREE_ROUTINE pfnFreeRoutines[] = NULL, /* FC_END */ NULL, /* FC_PAD */ }; + +#endif diff --git a/winpr/libwinpr/rpc/ndr_private.h b/winpr/libwinpr/rpc/ndr_private.h index d5eb947b1..a45f36109 100644 --- a/winpr/libwinpr/rpc/ndr_private.h +++ b/winpr/libwinpr/rpc/ndr_private.h @@ -22,6 +22,8 @@ #include +#ifndef _WIN32 + void NdrpAlignLength(unsigned long* length, unsigned int alignment); void NdrpIncrementLength(unsigned long* length, unsigned int size); @@ -39,4 +41,6 @@ extern const char* FC_TYPE_STRINGS[]; #include "ndr_correlation.h" +#endif + #endif /* WINPR_RPC_NDR_PRIVATE_H */ diff --git a/winpr/libwinpr/rpc/ndr_simple.c b/winpr/libwinpr/rpc/ndr_simple.c index d9492c130..46af05478 100644 --- a/winpr/libwinpr/rpc/ndr_simple.c +++ b/winpr/libwinpr/rpc/ndr_simple.c @@ -25,6 +25,9 @@ #include #include + +#ifndef _WIN32 + #include "ndr_simple.h" #include "ndr_private.h" @@ -195,3 +198,5 @@ void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFOR { } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_simple.h b/winpr/libwinpr/rpc/ndr_simple.h index bbd454209..67e387a7d 100644 --- a/winpr/libwinpr/rpc/ndr_simple.h +++ b/winpr/libwinpr/rpc/ndr_simple.h @@ -22,6 +22,8 @@ #include +#ifndef _WIN32 + void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar); void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar); @@ -32,4 +34,6 @@ char NdrGetSimpleTypeBufferSize(unsigned char FormatChar); char NdrGetSimpleTypeMemorySize(unsigned char FormatChar); int NdrGetTypeFlags(unsigned char FormatChar); +#endif + #endif /* WINPR_RPC_NDR_SIMPLE_H */ diff --git a/winpr/libwinpr/rpc/ndr_string.c b/winpr/libwinpr/rpc/ndr_string.c index e5f022df4..40312b06a 100644 --- a/winpr/libwinpr/rpc/ndr_string.c +++ b/winpr/libwinpr/rpc/ndr_string.c @@ -26,6 +26,8 @@ #include +#ifndef _WIN32 + #include "ndr_string.h" void NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat) @@ -37,3 +39,6 @@ void NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char { printf("warning: NdrNonConformantStringBufferSize unimplemented\n"); } + +#endif + diff --git a/winpr/libwinpr/rpc/ndr_string.h b/winpr/libwinpr/rpc/ndr_string.h index cbbd63308..fe91a9313 100644 --- a/winpr/libwinpr/rpc/ndr_string.h +++ b/winpr/libwinpr/rpc/ndr_string.h @@ -22,7 +22,11 @@ #include +#ifndef _WIN32 + void NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_STRING_H */ diff --git a/winpr/libwinpr/rpc/ndr_structure.c b/winpr/libwinpr/rpc/ndr_structure.c index cf0895c30..fa6434677 100644 --- a/winpr/libwinpr/rpc/ndr_structure.c +++ b/winpr/libwinpr/rpc/ndr_structure.c @@ -25,6 +25,9 @@ #include #include + +#ifndef _WIN32 + #include "ndr_private.h" #include "ndr_pointer.h" #include "ndr_structure.h" @@ -315,3 +318,5 @@ void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem pStubMsg->PointerLength = 0; } } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_structure.h b/winpr/libwinpr/rpc/ndr_structure.h index ca60c62fe..f4a02bd0d 100644 --- a/winpr/libwinpr/rpc/ndr_structure.h +++ b/winpr/libwinpr/rpc/ndr_structure.h @@ -22,9 +22,13 @@ #include +#ifndef _WIN32 + void NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_STRUCTURE_H */ diff --git a/winpr/libwinpr/rpc/ndr_union.c b/winpr/libwinpr/rpc/ndr_union.c index be4fab3e2..fbe5be922 100644 --- a/winpr/libwinpr/rpc/ndr_union.c +++ b/winpr/libwinpr/rpc/ndr_union.c @@ -26,6 +26,8 @@ #include +#ifndef _WIN32 + #include "ndr_union.h" void NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat) @@ -37,3 +39,5 @@ void NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned cha { printf("warning: NdrNonEncapsulatedUnionBufferSize unimplemented\n"); } + +#endif diff --git a/winpr/libwinpr/rpc/ndr_union.h b/winpr/libwinpr/rpc/ndr_union.h index 7cd81d05b..5a6e2cd55 100644 --- a/winpr/libwinpr/rpc/ndr_union.h +++ b/winpr/libwinpr/rpc/ndr_union.h @@ -22,7 +22,11 @@ #include +#ifndef _WIN32 + void NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); void NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#endif + #endif /* WINPR_RPC_NDR_UNION_H */ diff --git a/winpr/libwinpr/rpc/rpc.c b/winpr/libwinpr/rpc/rpc.c index 2987cfb54..b6770e0d3 100644 --- a/winpr/libwinpr/rpc/rpc.c +++ b/winpr/libwinpr/rpc/rpc.c @@ -25,7 +25,11 @@ #include +#ifndef _WIN32 + void RpcRaiseException(RPC_STATUS exception) { printf("RpcRaiseException: 0x%08luX\n", exception); } + +#endif