diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e5d96325..b40e367c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,6 +160,8 @@ add_subdirectory(libfreerdp-channels) add_subdirectory(libfreerdp-locale) add_subdirectory(libfreerdp-core) +add_subdirectory(libwinpr-rpc) + if(NOT WIN32) add_subdirectory(channels) endif() diff --git a/include/winpr/midl.h b/include/winpr/midl.h new file mode 100644 index 000000000..75a87eb38 --- /dev/null +++ b/include/winpr/midl.h @@ -0,0 +1,28 @@ +/** + * WinPR: Windows Portable Runtime + * Microsoft Remote Procedure Call (MSRPC) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_RPC_MIDL_H +#define WINPR_RPC_MIDL_H + +#include + +WINPR_API void* MIDL_user_allocate(size_t cBytes); +WINPR_API void MIDL_user_free(void* p); + +#endif /* WINPR_RPC_MIDL_H */ diff --git a/libfreerdp-core/ndr.h b/include/winpr/ndr.h similarity index 97% rename from libfreerdp-core/ndr.h rename to include/winpr/ndr.h index f5fe77264..ed2446500 100644 --- a/libfreerdp-core/ndr.h +++ b/include/winpr/ndr.h @@ -1,5 +1,5 @@ /** - * FreeRDP: A Remote Desktop Protocol Implementation + * WinPR: Windows Portable Runtime * Network Data Representation (NDR) * * Copyright 2012 Marc-Andre Moreau @@ -17,17 +17,13 @@ * limitations under the License. */ -#ifndef FREERDP_CORE_NDR_H -#define FREERDP_CORE_NDR_H - -#include "rpc.h" +#ifndef WINPR_RPC_NDR_H +#define WINPR_RPC_NDR_H #include "config.h" -#include +#include #include -#include -#include #define __RPC_WIN32__ 1 #define TARGET_IS_NT50_OR_LATER 1 @@ -526,9 +522,6 @@ typedef enum _NDR_PHASE #define NdrFcLong(s) (byte)(s & 0xFF), (byte)((s & 0x0000FF00) >> 8), \ (byte)((s & 0x00FF0000) >> 16), (byte)(s >> 24) -CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...); +WINPR_API CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...); -void* MIDL_user_allocate(size_t cBytes); -void MIDL_user_free(void* p); - -#endif /* FREERDP_CORE_NDR_H */ +#endif /* WINPR_RPC_NDR_H */ diff --git a/include/winpr/rpc.h b/include/winpr/rpc.h new file mode 100644 index 000000000..5feadbecd --- /dev/null +++ b/include/winpr/rpc.h @@ -0,0 +1,46 @@ +/** + * WinPR: Windows Portable Runtime + * Microsoft Remote Procedure Call (MSRPC) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_RPC_H +#define WINPR_RPC_H + +#include +#include + +#define RPC_VAR_ENTRY __cdecl +#define WINPR_API FREERDP_API + +typedef long RPC_STATUS; + +typedef void* I_RPC_HANDLE; +typedef I_RPC_HANDLE RPC_BINDING_HANDLE; +typedef RPC_BINDING_HANDLE handle_t; + +typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE; +typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_SERIALIZE; + +typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE; +typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; + +void RpcRaiseException(RPC_STATUS exception); + +#include +#include + +#endif /* WINPR_RPC_H */ diff --git a/libfreerdp-core/CMakeLists.txt b/libfreerdp-core/CMakeLists.txt index 3bc768469..6aa6da49e 100644 --- a/libfreerdp-core/CMakeLists.txt +++ b/libfreerdp-core/CMakeLists.txt @@ -41,8 +41,6 @@ set(LIBFREERDP_CORE_SRCS rpc.h rts.c rts.h - ndr.c - ndr.h input.c input.h license.c @@ -111,5 +109,7 @@ target_link_libraries(freerdp-core freerdp-sspi) target_link_libraries(freerdp-core freerdp-locale) target_link_libraries(freerdp-core ${OPENSSL_LIBRARIES}) +target_link_libraries(freerdp-core winpr-rpc) + install(TARGETS freerdp-core DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/libfreerdp-core/rpc.c b/libfreerdp-core/rpc.c index 6933b8682..760b4db4e 100644 --- a/libfreerdp-core/rpc.c +++ b/libfreerdp-core/rpc.c @@ -29,11 +29,6 @@ #include "rpc.h" -void RpcRaiseException(RPC_STATUS exception) -{ - printf("RpcRaiseException: 0x%08X\n", exception); -} - #define NTLM_PACKAGE_NAME _T("NTLM") boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, char* domain, char* password) diff --git a/libfreerdp-core/rpc.h b/libfreerdp-core/rpc.h index a829c6f09..40acbca4e 100644 --- a/libfreerdp-core/rpc.h +++ b/libfreerdp-core/rpc.h @@ -42,8 +42,6 @@ typedef struct rdp_ntlm_http rdpNtlmHttp; #include #include -typedef long RPC_STATUS; - struct _rpc_pdu_header { uint8 rpc_vers; @@ -666,8 +664,6 @@ struct rdp_rpc RpcVirtualConnection* VirtualConnection; }; -void RpcRaiseException(RPC_STATUS exception); - boolean ntlm_authenticate(rdpNtlm* ntlm); boolean ntlm_client_init(rdpNtlm* ntlm, boolean confidentiality, char* user, char* domain, char* password); diff --git a/libfreerdp-core/tsg.c b/libfreerdp-core/tsg.c index 536e4a358..ffb7a7222 100644 --- a/libfreerdp-core/tsg.c +++ b/libfreerdp-core/tsg.c @@ -29,7 +29,7 @@ #include #include -#include "ndr.h" +#include #include "tsg.h" diff --git a/libfreerdp-core/tsg.h b/libfreerdp-core/tsg.h index 115969f7e..9c270ae7a 100644 --- a/libfreerdp-core/tsg.h +++ b/libfreerdp-core/tsg.h @@ -23,8 +23,10 @@ typedef struct rdp_tsg rdpTsg; -#include "transport.h" #include "rpc.h" +#include "transport.h" + +#include #include #include @@ -43,16 +45,6 @@ struct rdp_tsg uint8 ChannelContext[16]; }; -typedef void* I_RPC_HANDLE; -typedef I_RPC_HANDLE RPC_BINDING_HANDLE; -typedef RPC_BINDING_HANDLE handle_t; - -typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE; -typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_SERIALIZE; - -typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE; -typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; - typedef wchar_t* RESOURCENAME; #define MAX_RESOURCE_NAMES 50 diff --git a/libwinpr-rpc/CMakeLists.txt b/libwinpr-rpc/CMakeLists.txt new file mode 100644 index 000000000..5d7a9b343 --- /dev/null +++ b/libwinpr-rpc/CMakeLists.txt @@ -0,0 +1,40 @@ +# WinPR: Windows Portable Runtime +# libwinpr-rpc cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(WINPR_RPC_SRCS + rpc.c + ndr.c + midl.c) + +add_library(winpr-rpc ${WINPR_RPC_SRCS}) + +include_directories(${OPENSSL_INCLUDE_DIR}) +include_directories(${ZLIB_INCLUDE_DIRS}) + +set_target_properties(winpr-rpc PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + +if(WIN32) + target_link_libraries(winpr-rpc ws2_32) +else() + target_link_libraries(winpr-rpc ${ZLIB_LIBRARIES}) +endif() + +target_link_libraries(winpr-rpc ${OPENSSL_LIBRARIES}) + +install(TARGETS winpr-rpc DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/libwinpr-rpc/midl.c b/libwinpr-rpc/midl.c new file mode 100644 index 000000000..bdd5bde5e --- /dev/null +++ b/libwinpr-rpc/midl.c @@ -0,0 +1,33 @@ +/** + * WinPR: Windows Portable Runtime + * Microsoft Remote Procedure Call (MSRPC) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +void* MIDL_user_allocate(size_t cBytes) +{ + return (malloc(cBytes)); +} + +void MIDL_user_free(void* p) +{ + free(p); +} diff --git a/libfreerdp-core/ndr.c b/libwinpr-rpc/ndr.c similarity index 99% rename from libfreerdp-core/ndr.c rename to libwinpr-rpc/ndr.c index 8e05dea6f..b3c8f85b4 100644 --- a/libfreerdp-core/ndr.c +++ b/libwinpr-rpc/ndr.c @@ -1,5 +1,5 @@ /** - * FreeRDP: A Remote Desktop Protocol Implementation + * WinPR: Windows Portable Runtime * Network Data Representation (NDR) * * Copyright 2012 Marc-Andre Moreau @@ -17,9 +17,7 @@ * limitations under the License. */ -#include - -#include "ndr.h" +#include /** * MSRPC NDR Types Technical Overview: @@ -1976,13 +1974,3 @@ CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRIN return client_call_return; } - -void* MIDL_user_allocate(size_t cBytes) -{ - return (xmalloc(cBytes)); -} - -void MIDL_user_free(void* p) -{ - xfree(p); -} diff --git a/libwinpr-rpc/rpc.c b/libwinpr-rpc/rpc.c new file mode 100644 index 000000000..4200bb395 --- /dev/null +++ b/libwinpr-rpc/rpc.c @@ -0,0 +1,27 @@ +/** + * WinPR: Windows Portable Runtime + * Microsoft Remote Procedure Call (MSRPC) + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +void RpcRaiseException(RPC_STATUS exception) +{ + printf("RpcRaiseException: 0x%08X\n", exception); +}