2012-08-18 22:34:24 +04:00
|
|
|
/**
|
2012-10-09 06:31:40 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* FreeRDP Windows Server
|
|
|
|
*
|
|
|
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-08-24 00:35:54 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-18 22:34:24 +04:00
|
|
|
#include <stdlib.h>
|
2012-08-24 00:35:54 +04:00
|
|
|
|
2012-08-18 22:34:24 +04:00
|
|
|
#include <winpr/tchar.h>
|
|
|
|
#include <winpr/windows.h>
|
|
|
|
|
|
|
|
#include "wf_info.h"
|
2012-09-07 20:01:36 +04:00
|
|
|
#include "wf_update.h"
|
2012-08-18 22:34:24 +04:00
|
|
|
#include "wf_mirage.h"
|
2012-09-18 22:07:38 +04:00
|
|
|
#include "wf_dxgi.h"
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-09-03 01:09:36 +04:00
|
|
|
static wfInfo* wfInfoInstance = NULL;
|
2012-11-01 06:10:27 +04:00
|
|
|
static int _IDcount = 0;
|
2012-09-03 01:09:36 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
int wf_info_lock(wfInfo* wfi)
|
2012-08-29 03:28:04 +04:00
|
|
|
{
|
|
|
|
DWORD dRes;
|
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
dRes = WaitForSingleObject(wfi->mutex, INFINITE);
|
2012-08-29 03:28:04 +04:00
|
|
|
|
2012-09-03 01:09:36 +04:00
|
|
|
switch (dRes)
|
2012-08-29 03:28:04 +04:00
|
|
|
{
|
2012-10-09 06:31:40 +04:00
|
|
|
case WAIT_ABANDONED:
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT_FAILED:
|
|
|
|
printf("wf_info_lock failed with 0x%08X\n", GetLastError());
|
|
|
|
return -1;
|
|
|
|
break;
|
2012-09-03 02:04:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds)
|
|
|
|
{
|
|
|
|
DWORD dRes;
|
|
|
|
|
|
|
|
dRes = WaitForSingleObject(wfi->mutex, dwMilliseconds);
|
2012-09-03 01:09:36 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
switch (dRes)
|
|
|
|
{
|
2012-10-09 06:31:40 +04:00
|
|
|
case WAIT_ABANDONED:
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT_FAILED:
|
|
|
|
printf("wf_info_try_lock failed with 0x%08X\n", GetLastError());
|
|
|
|
return -1;
|
|
|
|
break;
|
2012-08-29 03:28:04 +04:00
|
|
|
}
|
2012-09-03 01:09:36 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
return -1;
|
2012-08-29 03:28:04 +04:00
|
|
|
}
|
|
|
|
|
2012-09-03 01:09:36 +04:00
|
|
|
int wf_info_unlock(wfInfo* wfi)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2013-02-27 04:25:48 +04:00
|
|
|
|
2012-09-03 01:09:36 +04:00
|
|
|
if (ReleaseMutex(wfi->mutex) == 0)
|
2012-09-03 02:04:41 +04:00
|
|
|
{
|
|
|
|
printf("wf_info_unlock failed with 0x%08X\n", GetLastError());
|
|
|
|
return -1;
|
|
|
|
}
|
2012-09-03 01:09:36 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
return TRUE;
|
2012-08-29 03:28:04 +04:00
|
|
|
}
|
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
wfInfo* wf_info_init()
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2012-09-03 02:04:41 +04:00
|
|
|
wfInfo* wfi;
|
|
|
|
|
2012-10-09 06:31:40 +04:00
|
|
|
/*
|
2012-09-18 22:07:38 +04:00
|
|
|
OSVERSIONINFOEX osvi;
|
|
|
|
SYSTEM_INFO si;
|
|
|
|
BOOL bOsVersionInfoEx;
|
2012-09-19 03:00:03 +04:00
|
|
|
*/
|
2012-09-18 22:07:38 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
wfi = (wfInfo*) malloc(sizeof(wfInfo));
|
|
|
|
ZeroMemory(wfi, sizeof(wfInfo));
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-09-03 02:04:41 +04:00
|
|
|
if (wfi != NULL)
|
|
|
|
{
|
2012-09-07 20:01:36 +04:00
|
|
|
HKEY hKey;
|
|
|
|
LONG status;
|
|
|
|
DWORD dwType;
|
|
|
|
DWORD dwSize;
|
|
|
|
DWORD dwValue;
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
wfi->mutex = CreateMutex(NULL, FALSE, NULL);
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
if (wfi->mutex == NULL)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
|
|
|
_tprintf(_T("CreateMutex error: %d\n"), GetLastError());
|
|
|
|
}
|
2012-09-03 08:51:02 +04:00
|
|
|
|
2013-02-27 04:25:48 +04:00
|
|
|
//wfi->updateEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
//printf("updateEvent created\n");
|
2012-09-08 00:48:30 +04:00
|
|
|
|
|
|
|
wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL);
|
2012-09-06 04:03:07 +04:00
|
|
|
|
2012-09-07 20:01:36 +04:00
|
|
|
wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL);
|
|
|
|
|
|
|
|
if (!wfi->updateThread)
|
|
|
|
{
|
|
|
|
_tprintf(_T("Failed to create update thread\n"));
|
|
|
|
}
|
|
|
|
|
2012-10-07 00:25:11 +04:00
|
|
|
wfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * WF_INFO_MAXPEERS);
|
2012-10-07 00:57:58 +04:00
|
|
|
memset(wfi->peers, 0, sizeof(freerdp_peer*) * WF_INFO_MAXPEERS);
|
2012-09-07 20:01:36 +04:00
|
|
|
|
2012-10-05 23:25:30 +04:00
|
|
|
//Set FPS
|
2012-10-07 00:25:11 +04:00
|
|
|
wfi->framesPerSecond = WF_INFO_DEFAULT_FPS;
|
2012-09-07 20:01:36 +04:00
|
|
|
|
|
|
|
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
|
2012-10-05 23:25:30 +04:00
|
|
|
wfi->framesPerSecond = dwValue;
|
2012-09-07 20:01:36 +04:00
|
|
|
}
|
2012-10-05 23:25:30 +04:00
|
|
|
RegCloseKey(hKey);
|
2012-09-07 20:01:36 +04:00
|
|
|
|
2012-10-05 23:25:30 +04:00
|
|
|
//Set input toggle
|
|
|
|
wfi->input_disabled = FALSE;
|
|
|
|
|
|
|
|
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (RegQueryValueEx(hKey, _T("DisableInput"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (dwValue != 0)
|
|
|
|
wfi->input_disabled = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 20:01:36 +04:00
|
|
|
RegCloseKey(hKey);
|
2012-09-18 22:07:38 +04:00
|
|
|
|
|
|
|
//detect windows version
|
2012-09-19 03:00:03 +04:00
|
|
|
/*
|
2012-09-18 22:07:38 +04:00
|
|
|
ZeroMemory(&si, sizeof(SYSTEM_INFO));
|
|
|
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
|
|
|
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
|
|
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi);
|
|
|
|
|
|
|
|
wfi->win8 = FALSE;
|
|
|
|
if(bOsVersionInfoEx != 0 )
|
|
|
|
{
|
2012-10-09 06:31:40 +04:00
|
|
|
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
|
|
|
|
osvi.dwMajorVersion > 4 )
|
|
|
|
{
|
|
|
|
if ( osvi.dwMajorVersion == 6 &&
|
|
|
|
osvi.dwMinorVersion == 2)
|
|
|
|
{
|
|
|
|
wfi->win8 = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2012-09-18 22:07:38 +04:00
|
|
|
}
|
2012-09-19 03:00:03 +04:00
|
|
|
*/
|
2012-08-18 22:34:24 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
return wfi;
|
2012-08-18 22:34:24 +04:00
|
|
|
}
|
|
|
|
|
2012-09-03 01:09:36 +04:00
|
|
|
wfInfo* wf_info_get_instance()
|
|
|
|
{
|
|
|
|
if (wfInfoInstance == NULL)
|
2012-09-03 02:04:41 +04:00
|
|
|
wfInfoInstance = wf_info_init();
|
2012-09-03 01:09:36 +04:00
|
|
|
|
|
|
|
return wfInfoInstance;
|
|
|
|
}
|
|
|
|
|
2012-09-06 04:03:07 +04:00
|
|
|
void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2012-09-03 03:54:17 +04:00
|
|
|
if (wf_info_lock(wfi) > 0)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2012-10-07 00:57:58 +04:00
|
|
|
int i;
|
|
|
|
int peerId;
|
2012-10-08 23:46:01 +04:00
|
|
|
if (wfi->peerCount == WF_INFO_MAXPEERS)
|
|
|
|
{
|
|
|
|
context->socketClose = TRUE;
|
|
|
|
wf_info_unlock(wfi);
|
|
|
|
return;
|
|
|
|
}
|
2012-10-07 00:57:58 +04:00
|
|
|
|
2012-09-06 04:03:07 +04:00
|
|
|
context->info = wfi;
|
2012-09-08 00:48:30 +04:00
|
|
|
context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-11-01 06:10:27 +04:00
|
|
|
//get the offset of the top left corner of selected screen
|
|
|
|
EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0);
|
|
|
|
_IDcount = 0;
|
|
|
|
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
2012-09-20 08:22:13 +04:00
|
|
|
if (wfi->peerCount == 0)
|
2012-09-18 22:07:38 +04:00
|
|
|
wf_dxgi_init(wfi);
|
2012-09-20 08:22:13 +04:00
|
|
|
#else
|
2013-03-13 01:56:45 +04:00
|
|
|
if (wf_mirror_driver_activate(wfi) == FALSE)
|
|
|
|
{
|
|
|
|
context->socketClose = TRUE;
|
|
|
|
wf_info_unlock(wfi);
|
|
|
|
return;
|
|
|
|
}
|
2012-09-19 03:00:03 +04:00
|
|
|
#endif
|
2012-10-07 00:57:58 +04:00
|
|
|
//look trhough the array of peers until an empty slot
|
|
|
|
for(i=0; i<WF_INFO_MAXPEERS; ++i)
|
|
|
|
{
|
|
|
|
//empty index will be our peer id
|
|
|
|
if (wfi->peers[i] == NULL)
|
|
|
|
{
|
|
|
|
peerId = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-09-17 05:05:51 +04:00
|
|
|
|
2012-10-07 00:57:58 +04:00
|
|
|
wfi->peers[peerId] = ((rdpContext*) context)->peer;
|
|
|
|
wfi->peers[peerId]->pId = peerId;
|
|
|
|
wfi->peerCount++;
|
|
|
|
printf("Registering Peer: id=%d #=%d\n", peerId, wfi->peerCount);
|
2012-08-18 22:34:24 +04:00
|
|
|
|
2012-09-03 03:54:17 +04:00
|
|
|
wf_info_unlock(wfi);
|
2012-10-06 07:25:18 +04:00
|
|
|
|
2012-10-09 06:31:40 +04:00
|
|
|
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT);
|
2012-08-18 22:34:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 04:03:07 +04:00
|
|
|
void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2012-09-03 03:54:17 +04:00
|
|
|
if (wf_info_lock(wfi) > 0)
|
2012-08-18 22:34:24 +04:00
|
|
|
{
|
2012-10-07 00:57:58 +04:00
|
|
|
int peerId;
|
|
|
|
|
|
|
|
peerId = ((rdpContext*) context)->peer->pId;
|
|
|
|
wfi->peers[peerId] = NULL;
|
|
|
|
wfi->peerCount--;
|
2012-09-17 05:05:51 +04:00
|
|
|
CloseHandle(context->updateEvent);
|
|
|
|
|
2012-10-07 01:09:53 +04:00
|
|
|
printf("Unregistering Peer: id=%d, #=%d\n", peerId, wfi->peerCount);
|
2012-08-19 00:42:17 +04:00
|
|
|
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
2012-09-20 08:22:13 +04:00
|
|
|
if (wfi->peerCount == 0)
|
2012-09-18 22:07:38 +04:00
|
|
|
wf_dxgi_cleanup(wfi);
|
2012-09-19 03:00:03 +04:00
|
|
|
#endif
|
2012-09-18 22:07:38 +04:00
|
|
|
|
2012-09-03 03:54:17 +04:00
|
|
|
wf_info_unlock(wfi);
|
2012-10-06 07:25:18 +04:00
|
|
|
|
2012-10-09 06:31:40 +04:00
|
|
|
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT);
|
2012-09-03 03:54:17 +04:00
|
|
|
}
|
2012-08-19 01:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
BOOL wf_info_have_updates(wfInfo* wfi)
|
2012-08-19 01:49:52 +04:00
|
|
|
{
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
|
|
|
if(wfi->framesWaiting == 0)
|
|
|
|
return FALSE;
|
|
|
|
#else
|
|
|
|
if (wfi->nextUpdate == wfi->lastUpdate)
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
2012-08-30 23:50:46 +04:00
|
|
|
return TRUE;
|
2012-08-19 01:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
void wf_info_update_changes(wfInfo* wfi)
|
2012-08-19 01:49:52 +04:00
|
|
|
{
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
2012-10-18 02:39:04 +04:00
|
|
|
wf_dxgi_nextFrame(wfi, wfi->framesPerSecond * 1000);
|
2012-09-19 03:00:03 +04:00
|
|
|
#else
|
|
|
|
GETCHANGESBUF* buf;
|
2012-08-19 01:49:52 +04:00
|
|
|
|
2012-09-19 03:00:03 +04:00
|
|
|
buf = (GETCHANGESBUF*) wfi->changeBuffer;
|
|
|
|
wfi->nextUpdate = buf->buffer->counter;
|
|
|
|
#endif
|
2012-08-19 01:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
void wf_info_find_invalid_region(wfInfo* wfi)
|
2012-08-19 01:49:52 +04:00
|
|
|
{
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
|
|
|
wf_dxgi_getInvalidRegion(&wfi->invalid);
|
|
|
|
#else
|
|
|
|
int i;
|
|
|
|
GETCHANGESBUF* buf;
|
2012-08-20 21:47:44 +04:00
|
|
|
|
2012-09-19 03:00:03 +04:00
|
|
|
buf = (GETCHANGESBUF*) wfi->changeBuffer;
|
|
|
|
|
|
|
|
for (i = wfi->lastUpdate; i != wfi->nextUpdate; i = (i + 1) % MAXCHANGES_BUF)
|
|
|
|
{
|
2012-11-02 01:51:48 +04:00
|
|
|
LPRECT lpR = &buf->buffer->pointrect[i].rect;
|
|
|
|
|
|
|
|
//need to make sure we only get updates from the selected screen
|
|
|
|
if ( (lpR->left >= wfi->servscreen_xoffset) &&
|
|
|
|
(lpR->right <= (wfi->servscreen_xoffset + wfi->servscreen_width) ) &&
|
|
|
|
(lpR->top >= wfi->servscreen_yoffset) &&
|
|
|
|
(lpR->bottom <= (wfi->servscreen_yoffset + wfi->servscreen_height) ) )
|
|
|
|
{
|
|
|
|
UnionRect(&wfi->invalid, &wfi->invalid, lpR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2012-08-19 01:49:52 +04:00
|
|
|
}
|
2012-09-19 03:00:03 +04:00
|
|
|
#endif
|
2012-08-19 01:49:52 +04:00
|
|
|
|
2012-09-03 03:54:17 +04:00
|
|
|
if (wfi->invalid.left < 0)
|
2012-09-20 08:22:13 +04:00
|
|
|
wfi->invalid.left = 0;
|
2012-08-19 03:46:42 +04:00
|
|
|
|
2012-09-03 03:54:17 +04:00
|
|
|
if (wfi->invalid.top < 0)
|
|
|
|
wfi->invalid.top = 0;
|
2012-08-24 01:10:22 +04:00
|
|
|
|
2012-11-01 01:24:14 +04:00
|
|
|
if (wfi->invalid.right >= wfi->servscreen_width)
|
|
|
|
wfi->invalid.right = wfi->servscreen_width - 1;
|
2012-08-24 01:10:22 +04:00
|
|
|
|
2012-11-01 01:24:14 +04:00
|
|
|
if (wfi->invalid.bottom >= wfi->servscreen_height)
|
|
|
|
wfi->invalid.bottom = wfi->servscreen_height - 1;
|
2012-11-02 01:51:48 +04:00
|
|
|
|
|
|
|
//printf("invalid region: (%d, %d), (%d, %d)\n", wfi->invalid.left, wfi->invalid.top, wfi->invalid.right, wfi->invalid.bottom);
|
2012-08-20 22:36:59 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
void wf_info_clear_invalid_region(wfInfo* wfi)
|
2012-08-20 22:36:59 +04:00
|
|
|
{
|
2012-08-24 01:10:22 +04:00
|
|
|
wfi->lastUpdate = wfi->nextUpdate;
|
2012-09-03 03:54:17 +04:00
|
|
|
SetRectEmpty(&wfi->invalid);
|
2012-08-20 22:36:59 +04:00
|
|
|
}
|
|
|
|
|
2012-09-17 05:50:15 +04:00
|
|
|
void wf_info_invalidate_full_screen(wfInfo* wfi)
|
|
|
|
{
|
2012-11-01 01:24:14 +04:00
|
|
|
SetRect(&wfi->invalid, 0, 0, wfi->servscreen_width, wfi->servscreen_height);
|
2012-09-17 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-24 01:10:22 +04:00
|
|
|
BOOL wf_info_have_invalid_region(wfInfo* wfi)
|
2012-08-20 22:36:59 +04:00
|
|
|
{
|
2012-09-03 03:54:17 +04:00
|
|
|
return IsRectEmpty(&wfi->invalid);
|
2012-08-21 02:19:17 +04:00
|
|
|
}
|
2012-09-18 22:07:38 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, BYTE** pBits, int* pitch)
|
2012-09-18 22:07:38 +04:00
|
|
|
{
|
2012-09-19 01:25:20 +04:00
|
|
|
*width = (wfi->invalid.right - wfi->invalid.left);
|
|
|
|
*height = (wfi->invalid.bottom - wfi->invalid.top);
|
|
|
|
|
2012-09-19 03:00:03 +04:00
|
|
|
#ifdef WITH_WIN8
|
|
|
|
wf_dxgi_getPixelData(wfi, pBits, pitch, &wfi->invalid);
|
|
|
|
#else
|
2012-09-18 22:07:38 +04:00
|
|
|
{
|
2012-09-20 00:16:24 +04:00
|
|
|
long offset;
|
|
|
|
GETCHANGESBUF* changes;
|
|
|
|
changes = (GETCHANGESBUF*) wfi->changeBuffer;
|
2012-09-18 22:07:38 +04:00
|
|
|
|
2012-09-20 00:16:24 +04:00
|
|
|
*width += 1;
|
|
|
|
*height += 1;
|
2012-09-19 01:25:20 +04:00
|
|
|
|
2012-11-02 01:51:48 +04:00
|
|
|
offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->virtscreen_width * 4);
|
2012-10-09 11:01:37 +04:00
|
|
|
*pBits = ((BYTE*) (changes->Userbuffer)) + offset;
|
2012-11-02 01:12:05 +04:00
|
|
|
*pitch = wfi->virtscreen_width * 4;
|
2012-09-18 22:07:38 +04:00
|
|
|
}
|
2012-09-19 03:00:03 +04:00
|
|
|
#endif
|
2012-09-20 00:16:24 +04:00
|
|
|
}
|
2012-11-01 06:10:27 +04:00
|
|
|
|
|
|
|
BOOL CALLBACK wf_info_monEnumCB(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
|
|
|
{
|
|
|
|
wfInfo * wfi;
|
|
|
|
|
|
|
|
wfi = wf_info_get_instance();
|
|
|
|
|
|
|
|
if(_IDcount == wfi->screenID)
|
|
|
|
{
|
|
|
|
wfi->servscreen_xoffset = lprcMonitor->left;
|
|
|
|
wfi->servscreen_yoffset = lprcMonitor->top;
|
|
|
|
}
|
2012-11-01 06:17:40 +04:00
|
|
|
|
|
|
|
_IDcount++;
|
2012-11-01 06:10:27 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|