Merge branch 'master' of github.com:awakecoding/FreeRDP into egfx

This commit is contained in:
Marc-André Moreau 2014-06-23 11:55:27 -04:00
commit c156006195
34 changed files with 910 additions and 677 deletions

View File

@ -76,11 +76,11 @@ if(ANDROID OR IOS)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
endif(ANDROID OR IOS)
include(GetGitRevisionDescription)
git_describe(GIT_REVISION --match "[0-9]*" --abbrev=4 --tags --always)
if(ANDROID OR IOS)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
endif(ANDROID OR IOS)
git_describe(GIT_REVISION --match "[0-9]*" --abbrev=4 --tags --always)
message(STATUS "Git Revision ${GIT_REVISION}")
# Turn on solution folders (2.8.4+)

View File

@ -83,8 +83,8 @@ static BOOL rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s)
static BOOL rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context, wStream* s)
{
UINT16 timestamp = 0;
BYTE confirmBlockNum = 0;
UINT16 timestamp;
BYTE confirmBlockNum;
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
@ -92,6 +92,9 @@ static BOOL rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context, wStream
Stream_Read_UINT16(s, timestamp);
Stream_Read_UINT8(s, confirmBlockNum);
Stream_Seek_UINT8(s);
IFCALL(context->ConfirmBlock, context, confirmBlockNum, timestamp);
return TRUE;
}
@ -192,37 +195,41 @@ static void* rdpsnd_server_thread(void* arg)
UINT16 BodySize;
HANDLE events[8];
HANDLE ChannelEvent;
DWORD BytesReturned;
DWORD bytesReturned;
RdpsndServerContext* context;
BOOL doRun;
BOOL waitingHeader;
DWORD expectedBytes;
context = (RdpsndServerContext *)arg;
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
bytesReturned = 0;
s = Stream_New(NULL, 4096);
if (!s)
return NULL;
if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer, &BytesReturned))
if (!WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer, &bytesReturned) || (bytesReturned != sizeof(HANDLE)))
{
if (BytesReturned == sizeof(HANDLE))
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
WTSFreeMemory(buffer);
fprintf(stderr, "%s: error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%d)\n",
__FUNCTION__, bytesReturned);
return NULL;
}
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
WTSFreeMemory(buffer);
nCount = 0;
if (ChannelEvent)
events[nCount++] = ChannelEvent;
events[nCount++] = ChannelEvent;
events[nCount++] = context->priv->StopEvent;
if (!rdpsnd_server_send_formats(context, s))
goto out;
doRun = TRUE;
waitingHeader = TRUE;
expectedBytes = 4;
while (doRun)
{
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
@ -230,31 +237,34 @@ static void* rdpsnd_server_thread(void* arg)
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
break;
Stream_SetPosition(s, 0);
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned))
if (!WTSVirtualChannelRead(ChannelEvent, 0, (PCHAR)Stream_Pointer(s), expectedBytes, &bytesReturned))
{
if (!BytesReturned)
break;
fprintf(stderr, "%s: channel connection closed\n", __FUNCTION__);
break;
}
expectedBytes -= bytesReturned;
Stream_Seek(s, bytesReturned);
Stream_EnsureRemainingCapacity(s, BytesReturned);
if (expectedBytes)
continue;
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned))
break;
Stream_SetPosition(s, 0);
if (waitingHeader)
{
/* header case */
Stream_Read_UINT8(s, msgType);
Stream_Seek_UINT8(s); /* bPad */
Stream_Read_UINT16(s, BodySize);
expectedBytes = BodySize;
waitingHeader = FALSE;
Stream_SetPosition(s, 0);
Stream_EnsureCapacity(s, BodySize);
if (expectedBytes)
continue;
}
if (Stream_GetRemainingLength(s) < 4)
break;
Stream_Read_UINT8(s, msgType);
Stream_Seek_UINT8(s); /* bPad */
Stream_Read_UINT16(s, BodySize);
if (Stream_GetRemainingLength(s) < BodySize)
break;
/* when here we have the header + the body */
switch (msgType)
{
case SNDC_WAVECONFIRM:
@ -277,6 +287,10 @@ static void* rdpsnd_server_thread(void* arg)
fprintf(stderr, "%s: UNKOWN MESSAGE TYPE!! (%#0X)\n\n", __FUNCTION__, msgType);
break;
}
expectedBytes = 4;
waitingHeader = TRUE;
Stream_SetPosition(s, 0);
}
out:
@ -353,7 +367,7 @@ static BOOL rdpsnd_server_select_format(RdpsndServerContext* context, int client
return TRUE;
}
static BOOL rdpsnd_server_send_audio_pdu(RdpsndServerContext* context)
static BOOL rdpsnd_server_send_audio_pdu(RdpsndServerContext* context, UINT16 wTimestamp)
{
int size;
BYTE* src;
@ -418,7 +432,7 @@ static BOOL rdpsnd_server_send_audio_pdu(RdpsndServerContext* context)
Stream_Write_UINT8(s, 0); /* bPad */
Stream_Write_UINT16(s, size + fill_size + 8); /* BodySize */
Stream_Write_UINT16(s, 0); /* wTimeStamp */
Stream_Write_UINT16(s, wTimestamp); /* wTimeStamp */
Stream_Write_UINT16(s, context->selected_client_format); /* wFormatNo */
Stream_Write_UINT8(s, context->block_no); /* cBlockNo */
Stream_Seek(s, 3); /* bPad */
@ -445,7 +459,7 @@ out:
return status;
}
static BOOL rdpsnd_server_send_samples(RdpsndServerContext* context, const void* buf, int nframes)
static BOOL rdpsnd_server_send_samples(RdpsndServerContext* context, const void* buf, int nframes, UINT16 wTimestamp)
{
int cframes;
int cframesize;
@ -466,7 +480,7 @@ static BOOL rdpsnd_server_send_samples(RdpsndServerContext* context, const void*
if (context->priv->out_pending_frames >= context->priv->out_frames)
{
if (!rdpsnd_server_send_audio_pdu(context))
if (!rdpsnd_server_send_audio_pdu(context, wTimestamp))
return FALSE;
}
}
@ -510,7 +524,7 @@ static BOOL rdpsnd_server_close(RdpsndServerContext* context)
if (context->priv->out_pending_frames > 0)
{
if (!rdpsnd_server_send_audio_pdu(context))
if (!rdpsnd_server_send_audio_pdu(context, 0))
return FALSE;
}

View File

@ -8,6 +8,7 @@ libs/armeabi*
AndroidManifest.xml
local.properties
!.project
appcompat_v7
FreeRDPCore/project.properties
FreeRDPCore/src/com/freerdp/freerdpcore/utils/BuildConfiguration.java

View File

@ -42,6 +42,11 @@ if(ANDROID_BUILD_JAVA)
endif()
endif(ANDROID_BUILD_JAVA)
set(ANDROID_COMMAND "${ANDROID_SDK}/tools/android")
if(NOT EXISTS ${ANDROID_COMMAND})
message(FATAL_ERROR "android not found but required to build android java")
endif()
if(ANDROID_BUILD_JAVA_DEBUG)
set(ANDROID_BUILD_TYPE "debug")
else()
@ -56,5 +61,11 @@ else()
set(NDK_DEBUG "0")
endif()
set(APPCOMPAT_DIR "${CMAKE_CURRENT_BINARY_DIR}/appcompat_v7")
add_custom_target(copy_appcompat ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${ANDROID_SDK}/extras/android/support/v7/appcompat ${APPCOMPAT_DIR}
COMMAND ${ANDROID_COMMAND} update lib-project -p ${APPCOMPAT_DIR}
)
add_subdirectory(FreeRDPCore)
add_subdirectory(aFreeRDP)

View File

@ -65,7 +65,7 @@
android:windowSoftInputMode="stateHidden">
</activity>
<activity android:name=".presentation.SessionActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:theme="@style/Theme.AppCompat"
android:configChanges="orientation|keyboardHidden|keyboard"
android:windowSoftInputMode="adjustResize">
</activity>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

View File

@ -13,3 +13,4 @@
# Project target.
target=android-@ANDROID_APP_TARGET_SDK@
android.library=true
android.library.reference.1=../appcompat_v7

View File

@ -18,7 +18,6 @@
android:paddingRight="6dip"
android:paddingTop="7dip"
android:paddingBottom="16dip"
android:background="@drawable/search_plate"
android:gravity="center_vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">
@ -36,8 +35,6 @@
android:singleLine="true"
android:ellipsize="end"
android:inputType="text"
android:textColor="?android:attr/textColorPrimary"
android:textColorHint="?android:attr/textColorHint"
android:drawableLeft="@drawable/icon_edittext_search"
android:drawableRight="@drawable/icon_edittext_clear"
/>

View File

@ -4,14 +4,17 @@
<item android:id="@+id/bookmark_connect"
android:title="@string/menu_connect"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/bookmark_edit"
android:title="@string/menu_edit"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/bookmark_delete"
android:title="@string/menu_delete"
android:showAsAction="ifRoom"
/>
</menu>

View File

@ -4,21 +4,21 @@
<item android:id="@+id/newBookmark"
android:icon="@drawable/icon_menu_add"
android:title="@string/menu_new_bookmark"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/appSettings"
android:icon="@drawable/icon_menu_settings"
android:title="@string/menu_app_settings"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/help"
android:icon="@drawable/icon_menu_help"
android:title="@string/menu_help"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/about"
android:icon="@drawable/icon_menu_about"
android:title="@string/menu_about"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/exit"
android:icon="@drawable/icon_menu_exit"
android:title="@string/menu_exit"
/>
</menu>

View File

@ -5,22 +5,27 @@
<item android:id="@+id/session_touch_pointer"
android:title="@string/pointer"
android:icon="@drawable/icon_zoom_in"
android:showAsAction="ifRoom"
/>
-->
<item android:id="@+id/session_touch_pointer"
android:title="@string/menu_touch_pointer"
android:icon="@drawable/icon_menu_touch_pointer"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/session_sys_keyboard"
android:title="@string/menu_sys_keyboard"
android:icon="@drawable/icon_menu_sys_keyboard"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/session_ext_keyboard"
android:title="@string/menu_ext_keyboard"
android:icon="@drawable/icon_menu_ext_keyboard"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/session_disconnect"
android:title="@string/menu_disconnect"
android:icon="@drawable/icon_menu_disconnect"
android:showAsAction="ifRoom"
/>
</menu>

View File

@ -23,7 +23,7 @@
<string name="menu_ext_keyboard">Funcion teclado</string>
<string name="menu_touch_pointer">Puntero Tactil</string>
<string name="menu_home">Inicio</string>
<string name="menu_disconnect">desconectart</string>
<string name="menu_disconnect">Desconectart</string>
<!-- List section headers -->
<string name="section_bookmarks">Conexión Manual</string>
<string name="section_active_sessions">Sesiones Activas</string>
@ -197,4 +197,6 @@
<string name="dlg_msg_exit">Esta seguro que desea salir del programa?</string>
<string name="dlg_title_clear_cert_cache">Borrar Certificados?</string>
<string name="dlg_msg_clear_cert_cache">Esta seguro que desea borrar todos los certificados?</string>
<string name="debug_level">Debug Level</string>
<string name="settings_debug">Debug Settings</string>
</resources>

View File

@ -196,4 +196,6 @@
<string name="dlg_msg_exit">"Êtes-vous sûr de vouloir quitter l'application?"</string>
<string name="dlg_title_clear_cert_cache">"Êtes-vous sûrs de vouloir supprimer les certificats?"</string>
<string name="dlg_msg_clear_cert_cache">"Êtes-vous sûr de vouloir supprimer tous les certificats mis en cache?"</string>
<string name="debug_level">Debug Level</string>
<string name="settings_debug">Debug Settings</string>
</resources>

View File

@ -197,4 +197,6 @@
<string name="dlg_msg_exit">Weet u zeker dat u de applicatie wilt sluiten?</string>
<string name="dlg_title_clear_cert_cache">Verwijder certificaten?</string>
<string name="dlg_msg_clear_cert_cache">Weet u zeker dat u al uw cache certificaten wilt verwijderen?</string>
<string name="debug_level">Debug Level</string>
<string name="settings_debug">Debug Settings</string>
</resources>

View File

@ -23,7 +23,7 @@
<string name="menu_ext_keyboard">Function Keys</string>
<string name="menu_touch_pointer">Touch Pointer</string>
<string name="menu_home">home</string>
<string name="menu_disconnect">disconnect</string>
<string name="menu_disconnect">Disconnect</string>
<!-- List section headers -->
<string name="section_bookmarks">Manual Connections</string>
<string name="section_active_sessions">Active Sessions</string>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="Theme.Settings" parent="android:Theme.Light">
<style name="Theme.Settings" parent="@style/Theme.AppCompat">
<item name="android:listSeparatorTextViewStyle">@style/SettingsCategory</item>
</style>
<style name="Theme.Main" parent="android:Theme.Light">
<style name="Theme.Main" parent="@style/Theme.AppCompat">
</style>
<style name="SettingsCategory">
<item name="android:layout_width">match_parent</item>

View File

@ -363,10 +363,6 @@ public class HomeActivity extends Activity
Intent helpIntent = new Intent(this, HelpActivity.class);
startActivity(helpIntent);
}
else if (itemId == R.id.exit)
{
finish();
}
else if (itemId == R.id.about)
{
Intent aboutIntent = new Intent(this, AboutActivity.class);

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

View File

@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -63,7 +63,7 @@ BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int va
file->ScreenModeId = value;
else if (_stricmp(name, "span monitors") == 0)
file->SpanMonitors = value;
else if (_stricmp(name, "smartsizing") == 0)
else if (_stricmp(name, "smart sizing") == 0)
file->SmartSizing = value;
else if (_stricmp(name, "enablesuperpan") == 0)
file->EnableSuperSpan = value;

View File

@ -27,7 +27,7 @@ option(ANDROID_BUILD_JAVA "Automatically android java code - build type depends
option(ANDROID_BUILD_JAVA_DEBUG "Create a android debug package" ${JAVA_DEBUG_DEFAULT})
set(ANDROID_APP_VERSION 3 CACHE STRING "Application version")
set(ANDROID_APP_TARGET_SDK 11 CACHE STRING "Application target android SDK")
set(ANDROID_APP_TARGET_SDK 14 CACHE STRING "Application target android SDK")
set(ANDROID_APP_MIN_SDK 9 CACHE STRING "Application minimum android SDK requirement")
set(ANDROID_APP_GOOGLE_TARGET_SDK "16" CACHE STRING "Application target google SDK")

View File

@ -32,7 +32,8 @@ typedef int (*psRdpsndStop)(RdpsndServerContext* context);
typedef BOOL (*psRdpsndServerInitialize)(RdpsndServerContext* context);
typedef BOOL (*psRdpsndServerSelectFormat)(RdpsndServerContext* context, int client_format_index);
typedef BOOL (*psRdpsndServerSendSamples)(RdpsndServerContext* context, const void* buf, int nframes);
typedef BOOL (*psRdpsndServerSendSamples)(RdpsndServerContext* context, const void* buf, int nframes, UINT16 wTimestamp);
typedef BOOL (*psRdpsndServerConfirmBlock)(RdpsndServerContext* context, BYTE confirmBlockNum, UINT16 wtimestamp);
typedef BOOL (*psRdpsndServerSetVolume)(RdpsndServerContext* context, int left, int right);
typedef BOOL (*psRdpsndServerClose)(RdpsndServerContext* context);
@ -82,6 +83,10 @@ struct _rdpsnd_server_context
* nframes * src_format.nBitsPerSample * src_format.nChannels / 8
*/
psRdpsndServerSendSamples SendSamples;
/**
* Called when block confirm is received from the client
*/
psRdpsndServerConfirmBlock ConfirmBlock;
/**
* Set the volume level of the client. Valid range is between 0 and 0xFFFF.
*/

View File

@ -197,7 +197,8 @@ void mf_peer_rdpsnd_input_callback (void *inUserD
return ;
}
rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData, inBuffer->mAudioDataByteSize/4);
rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData,
inBuffer->mAudioDataByteSize/4, (UINT16)(GetTickCount() & 0xffff));
status = AudioQueueEnqueueBuffer(
rState->queue,

View File

@ -162,8 +162,8 @@ DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam)
//FIXME: frames = bytes/(bytespersample * channels)
context->rdpsnd->SendSamples(context->rdpsnd, pbCaptureData, dwCaptureLength/4);
context->rdpsnd->SendSamples(context->rdpsnd, pbCaptureData2, dwCaptureLength2/4);
context->rdpsnd->SendSamples(context->rdpsnd, pbCaptureData, dwCaptureLength/4, (UINT16)(beg & 0xffff));
context->rdpsnd->SendSamples(context->rdpsnd, pbCaptureData2, dwCaptureLength2/4, (UINT16)(beg & 0xffff));
hr = capBuf->lpVtbl->Unlock(capBuf, pbCaptureData, dwCaptureLength, pbCaptureData2, dwCaptureLength2);

View File

@ -271,7 +271,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
//Here we are writing the audio data
//not sure if this flag is ever set by the system; msdn is not clear about it
if (!(flags & AUDCLNT_BUFFERFLAGS_SILENT))
context->rdpsnd->SendSamples(context->rdpsnd, pData, packetLength);
context->rdpsnd->SendSamples(context->rdpsnd, pData, packetLength, (UINT16)(GetTickCount() & 0xffff));
hr = pCaptureClient->lpVtbl->ReleaseBuffer(pCaptureClient, numFramesAvailable);
if (FAILED(hr))
@ -313,4 +313,4 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
CoUninitialize();
return 0;
}
}

View File

@ -32,21 +32,29 @@
#ifndef _WIN32
#ifndef _rotl
static INLINE UINT32 _rotl(UINT32 value, int shift) {
return (value << shift) | (value >> (32 - shift));
}
#endif
#ifndef _rotl64
static INLINE UINT64 _rotl64(UINT64 value, int shift) {
return (value << shift) | (value >> (64 - shift));
}
#endif
#ifndef _rotr
static INLINE UINT32 _rotr(UINT32 value, int shift) {
return (value >> shift) | (value << (32 - shift));
}
#endif
#ifndef _rotr64
static INLINE UINT64 _rotr64(UINT64 value, int shift) {
return (value >> shift) | (value << (64 - shift));
}
#endif
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))

View File

@ -1017,6 +1017,7 @@ typedef struct _SecPkgContext_AuthPassword SecPkgContext_AuthPassword;
struct _SecPkgContext_AuthNtlmHash
{
int Version;
BYTE NtlmHash[16];
};
typedef struct _SecPkgContext_AuthNtlmHash SecPkgContext_AuthNtlmHash;

View File

@ -333,7 +333,11 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
pipe = (WINPR_PIPE*) Object;
io_status = read(pipe->fd, lpBuffer, nNumberOfBytesToRead);
do
{
io_status = read(pipe->fd, lpBuffer, nNumberOfBytesToRead);
}
while ((io_status < 0) && (errno == EINTR));
if (io_status < 0)
{
@ -364,16 +368,15 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (pipe->clientfd == -1)
return FALSE;
io_status = read(pipe->clientfd, lpBuffer, nNumberOfBytesToRead);
do
{
io_status = read(pipe->clientfd, lpBuffer, nNumberOfBytesToRead);
}
while ((io_status < 0) && (errno == EINTR));
if (io_status == 0)
{
switch (errno)
{
case ECONNRESET:
SetLastError(ERROR_BROKEN_PIPE);
break;
}
SetLastError(ERROR_BROKEN_PIPE);
status = FALSE;
}
else if (io_status < 0)
@ -385,6 +388,9 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
case EWOULDBLOCK:
SetLastError(ERROR_NO_DATA);
break;
default:
SetLastError(ERROR_BROKEN_PIPE);
break;
}
}
@ -480,7 +486,11 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
pipe = (WINPR_PIPE*) Object;
io_status = write(pipe->fd, lpBuffer, nNumberOfBytesToWrite);
do
{
io_status = write(pipe->fd, lpBuffer, nNumberOfBytesToWrite);
}
while ((io_status < 0) && (errno == EINTR));
if ((io_status < 0) && (errno == EWOULDBLOCK))
io_status = 0;
@ -503,7 +513,11 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
if (pipe->clientfd == -1)
return FALSE;
io_status = write(pipe->clientfd, lpBuffer, nNumberOfBytesToWrite);
do
{
io_status = write(pipe->clientfd, lpBuffer, nNumberOfBytesToWrite);
}
while ((io_status < 0) && (errno == EINTR));
if (io_status < 0)
{

View File

@ -168,6 +168,7 @@ NTLM_CONTEXT* ntlm_ContextNew()
context->SendSingleHostData = FALSE;
context->SendWorkstationName = TRUE;
context->NegotiateKeyExchange = TRUE;
context->UseSamFileDatabase = TRUE;
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\WinPR\\NTLM"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
@ -675,6 +676,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, UL
SSPI_CREDENTIALS* credentials;
SecPkgContext_AuthIdentity* AuthIdentity = (SecPkgContext_AuthIdentity*) pBuffer;
context->UseSamFileDatabase = FALSE;
credentials = context->credentials;
ZeroMemory(AuthIdentity, sizeof(SecPkgContext_AuthIdentity));
@ -724,7 +727,10 @@ SECURITY_STATUS SEC_ENTRY ntlm_SetContextAttributesW(PCtxtHandle phContext, ULON
if (cbBuffer < sizeof(SecPkgContext_AuthNtlmHash))
return SEC_E_INVALID_PARAMETER;
CopyMemory(context->NtlmHash, AuthNtlmHash->NtlmHash, 16);
if (AuthNtlmHash->Version == 1)
CopyMemory(context->NtlmHash, AuthNtlmHash->NtlmHash, 16);
else if (AuthNtlmHash->Version == 2)
CopyMemory(context->NtlmV2Hash, AuthNtlmHash->NtlmHash, 16);
return SEC_E_OK;
}

View File

@ -241,6 +241,7 @@ struct _NTLM_CONTEXT
BYTE* SendSealingKey;
BYTE* RecvSealingKey;
UINT32 NegotiateFlags;
BOOL UseSamFileDatabase;
int LmCompatibilityLevel;
int SuppressExtendedProtection;
BOOL SendWorkstationName;

View File

@ -299,6 +299,9 @@ int ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
{
SSPI_CREDENTIALS* credentials = context->credentials;
if (memcmp(context->NtlmV2Hash, NTLM_NULL_BUFFER, 16) != 0)
return 1;
if (memcmp(context->NtlmHash, NTLM_NULL_BUFFER, 16) != 0)
{
NTOWFv2FromHashW(context->NtlmHash,
@ -324,7 +327,7 @@ int ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2, (BYTE*) hash);
}
else
else if (context->UseSamFileDatabase)
{
ntlm_fetch_ntlm_v2_hash(context, hash);
}

View File

@ -66,6 +66,11 @@ static const char* TEST_NTLM_PASSWORD = "P4ss123!";
static const BYTE TEST_NTLM_HASH[16] =
{ 0xd5, 0x92, 0x2a, 0x65, 0xc4, 0xd5, 0xc0, 0x82, 0xca, 0x44, 0x4a, 0xf1, 0xbe, 0x00, 0x01, 0xdb };
//static const char* TEST_NTLM_HASH_V2_STRING = "4c7f706f7dde05a9d1a0f4e7ffe3bfb8";
static const BYTE TEST_NTLM_V2_HASH[16] =
{ 0x4c, 0x7f, 0x70, 0x6f, 0x7d, 0xde, 0x05, 0xa9, 0xd1, 0xa0, 0xf4, 0xe7, 0xff, 0xe3, 0xbf, 0xb8 };
//#define NTLM_PACKAGE_NAME NEGOSSP_NAME
#define NTLM_PACKAGE_NAME NTLMSP_NAME
@ -303,6 +308,7 @@ struct _TEST_NTLM_SERVER
SecBuffer outputBuffer[2];
BOOL haveContext;
BOOL haveInputBuffer;
BOOL UseNtlmV2Hash;
LPTSTR ServicePrincipalName;
SecBufferDesc inputBufferDesc;
SecBufferDesc outputBufferDesc;
@ -318,6 +324,8 @@ int test_ntlm_server_init(TEST_NTLM_SERVER* ntlm)
{
SECURITY_STATUS status;
ntlm->UseNtlmV2Hash = TRUE;
SecInvalidateHandle(&(ntlm->context));
ntlm->table = InitSecurityInterfaceEx(TEST_SSPI_INTERFACE);
@ -422,10 +430,19 @@ int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm)
{
if (strcmp(AuthIdentity.User, TEST_NTLM_USER) == 0)
{
CopyMemory(AuthNtlmHash.NtlmHash, TEST_NTLM_HASH, 16);
if (ntlm->UseNtlmV2Hash)
{
AuthNtlmHash.Version = 2;
CopyMemory(AuthNtlmHash.NtlmHash, TEST_NTLM_V2_HASH, 16);
}
else
{
AuthNtlmHash.Version = 1;
CopyMemory(AuthNtlmHash.NtlmHash, TEST_NTLM_HASH, 16);
}
status = ntlm->table->SetContextAttributes(&ntlm->context,
SECPKG_ATTR_AUTH_NTLM_HASH, &AuthNtlmHash, sizeof(SecPkgContext_AuthNtlmHash));
SECPKG_ATTR_AUTH_NTLM_HASH, &AuthNtlmHash, sizeof(SecPkgContext_AuthNtlmHash));
}
}

View File

@ -47,6 +47,8 @@
int main(int argc, char* argv[])
{
int index = 1;
int format = 0;
int version = 1;
BYTE NtHash[16];
char* User = NULL;
UINT32 UserLength;
@ -93,10 +95,40 @@ int main(int argc, char* argv[])
Password = argv[index];
}
else if (strcmp("-v", argv[index]) == 0)
{
index++;
if (index == argc)
{
printf("missing version\n");
exit(1);
}
version = atoi(argv[index]);
if ((version != 1) && (version != 2))
version = 1;
}
else if (strcmp("-f", argv[index]) == 0)
{
index++;
if (index == argc)
{
printf("missing format\n");
exit(1);
}
if (strcmp("default", argv[index]) == 0)
format = 0;
else if (strcmp("sam", argv[index]) == 0)
format = 1;
}
else if (strcmp("-h", argv[index]) == 0)
{
printf("winpr-hash: NTLM hashing tool\n");
printf("Usage: winpr-hash -u <username> -p <password> [-d <domain>]\n");
printf("Usage: winpr-hash -u <username> -p <password> [-d <domain>] -f <default,sam> -v <1,2>\n");
exit(1);
}
@ -113,22 +145,44 @@ int main(int argc, char* argv[])
PasswordLength = strlen(Password);
DomainLength = (Domain) ? strlen(Domain) : 0;
NTOWFv1A(Password, PasswordLength, NtHash);
if (version == 2)
{
if (!Domain)
{
printf("missing domain\n");
exit(1);
}
printf("%s:", User);
if (DomainLength > 0)
printf("%s:", Domain);
NTOWFv2A(Password, PasswordLength, User, UserLength, Domain, DomainLength, NtHash);
}
else
{
NTOWFv1A(Password, PasswordLength, NtHash);
}
if (format == 0)
{
for (index = 0; index < 16; index++)
printf("%02x", NtHash[index]);
printf("\n");
}
else if (format == 1)
{
printf("%s:", User);
if (DomainLength > 0)
printf("%s:", Domain);
else
printf(":");
printf(":");
printf(":");
for (index = 0; index < 16; index++)
printf("%02x", NtHash[index]);
for (index = 0; index < 16; index++)
printf("%02x", NtHash[index]);
printf(":::");
printf("\n");
printf(":::");
printf("\n");
}
return 0;
}