wfreerdp-server: added experimental monitor proc
This commit is contained in:
parent
343825221c
commit
67b1d4e607
@ -232,29 +232,58 @@ BOOL wf_update_mirror_drv(wfPeerContext* context)
|
||||
return rturn;
|
||||
}
|
||||
|
||||
int wf_mirage_step4(wfPeerContext* context)
|
||||
|
||||
BOOL wf_map_mirror_mem(wfPeerContext* context)
|
||||
{
|
||||
int status;
|
||||
|
||||
printf("\n\nCreating a device context...\n");
|
||||
_tprintf(_T("\n\nCreating a device context...\n"));
|
||||
|
||||
context->driverDC = CreateDC(context->deviceName, NULL, NULL, NULL);
|
||||
|
||||
if (context->driverDC == NULL)
|
||||
{
|
||||
printf("Could not create device driver context!\n");
|
||||
return -1;
|
||||
_tprintf(_T("Could not create device driver context!\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
context->changeBuffer = malloc(sizeof(GETCHANGESBUF));
|
||||
|
||||
printf("\n\nConnecting to driver...\n");
|
||||
_tprintf(_T("\n\nConnecting to driver...\n"));
|
||||
status = ExtEscape(context->driverDC, dmf_esc_usm_pipe_map, 0, 0, sizeof(GETCHANGESBUF), (LPSTR) context->changeBuffer);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
printf("Failed to map shared memory from the driver! Code %d\n", status);
|
||||
_tprintf(_T("Failed to map shared memory from the driver! Code %d\n"), status);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Unmap the shared memory and release the DC
|
||||
*/
|
||||
BOOL wf_mirror_cleanup(wfPeerContext* context)
|
||||
{
|
||||
int iResult;
|
||||
|
||||
_tprintf(_T("\n\nCleaning up...\nDisconnecting driver...\n"));
|
||||
iResult = ExtEscape(context->driverDC, dmf_esc_usm_pipe_unmap, sizeof(context->changeBuffer), (LPSTR) context->changeBuffer, 0, 0);
|
||||
|
||||
if(iResult <= 0)
|
||||
{
|
||||
_tprintf(_T("Failed to unmap shared memory from the driver! Code %d\n"), iResult);
|
||||
}
|
||||
|
||||
_tprintf(_T("Releasing DC\n"));
|
||||
if(context->driverDC != NULL)
|
||||
{
|
||||
iResult = DeleteDC(context->driverDC);
|
||||
if(iResult == 0)
|
||||
{
|
||||
_tprintf(_T("Failed to release DC!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
free(context->changeBuffer);
|
||||
}
|
@ -203,6 +203,7 @@ typedef struct
|
||||
BOOL wf_check_disp_devices(wfPeerContext* context);
|
||||
BOOL wf_disp_device_set_attatch(wfPeerContext* context, DWORD val);
|
||||
BOOL wf_update_mirror_drv(wfPeerContext* context);
|
||||
int wf_mirage_step4(wfPeerContext* context);
|
||||
BOOL wf_map_mirror_mem(wfPeerContext* context);
|
||||
BOOL wf_mirror_cleanup(wfPeerContext* context);
|
||||
|
||||
#endif /* WF_MIRAGE_H */
|
||||
|
@ -16,8 +16,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <freerdp/listener.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
|
||||
#include "wf_mirage.h"
|
||||
|
||||
@ -28,14 +30,31 @@ void wf_peer_context_new(freerdp_peer* client, wfPeerContext* context)
|
||||
wf_check_disp_devices(context);
|
||||
wf_disp_device_set_attatch(context, 1);
|
||||
wf_update_mirror_drv(context);
|
||||
wf_mirage_step4(context);
|
||||
wf_map_mirror_mem(context);
|
||||
}
|
||||
|
||||
void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context)
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
wf_mirror_cleanup(context);
|
||||
wf_disp_device_set_attatch(context, 0);
|
||||
wf_update_mirror_drv(context);
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD WINAPI wf_peer_mirror_monitor(LPVOID lpParam)
|
||||
{
|
||||
wfPeerContext* context;
|
||||
CHANGES_BUF* buf;
|
||||
|
||||
context = (wfPeerContext*) lpParam;
|
||||
buf = (CHANGES_BUF*)context->changeBuffer;
|
||||
|
||||
while(1)
|
||||
{
|
||||
_tprintf(_T("Count = %d\n"), buf->counter);
|
||||
freerdp_usleep(1000000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +64,11 @@ void wf_peer_init(freerdp_peer* client)
|
||||
client->ContextNew = (psPeerContextNew) wf_peer_context_new;
|
||||
client->ContextFree = (psPeerContextFree) wf_peer_context_free;
|
||||
freerdp_peer_context_new(client);
|
||||
|
||||
_tprintf(_T("Trying to create a monitor thread...\n"));
|
||||
|
||||
if (CreateThread(NULL, 0, wf_peer_mirror_monitor, client->context, 0, NULL) != 0)
|
||||
_tprintf(_T("Created!\n"));
|
||||
}
|
||||
|
||||
boolean wf_peer_post_connect(freerdp_peer* client)
|
||||
|
Loading…
x
Reference in New Issue
Block a user