Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


asyncselect.cpp File Reference

#include "lspdef.h"
#include <windows.h>
#include <strsafe.h>

Include dependency graph for asyncselect.cpp:

Go to the source code of this file.


Defines

#define STRSAFE_NO_DEPRECATE
#define PROVIDER_CLASS   TEXT("Layered WS2 Provider 0x%08x")
#define PROVIDER_CLASS_CHAR_LEN   32
#define MAX_ASYNC_RETRIES   7
#define ASYNC_TIMEOUT   500

Functions

int StopAsyncWindowManager ()
HWND GetWorkerWindow ()

Define Documentation

#define ASYNC_TIMEOUT   500

Definition at line 54 of file asyncselect.cpp.

#define MAX_ASYNC_RETRIES   7

Definition at line 53 of file asyncselect.cpp.

#define PROVIDER_CLASS   TEXT("Layered WS2 Provider 0x%08x")

Definition at line 42 of file asyncselect.cpp.

#define PROVIDER_CLASS_CHAR_LEN   32

Definition at line 43 of file asyncselect.cpp.

#define STRSAFE_NO_DEPRECATE

Definition at line 33 of file asyncselect.cpp.


Function Documentation

HWND GetWorkerWindow (  ) 

Definition at line 142 of file asyncselect.cpp.

00144 {
00145     HANDLE  ReadyEvent = NULL;
00146     int     rc;
00147 
00148     EnterCriticalSection( &gCriticalSection );
00149     if ( NULL == WorkerThreadHandle ) 
00150     {
00151         // Create an event which the worker thread will signal when its ready
00152         ReadyEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
00153         if ( NULL == ReadyEvent )
00154         {
00155             dbgprint("GetWorkerWindow: CreateEvent failed: %d", GetLastError() );
00156             goto cleanup;
00157         }
00158 
00159         // Create the asyn window message thread
00160         WorkerThreadHandle = CreateThread(
00161                 NULL, 
00162                 0, 
00163                 AsyncMsgHandler, 
00164                 (LPVOID)ReadyEvent, 
00165                 0, 
00166                 NULL
00167                 ); 
00168         if ( NULL == WorkerThreadHandle )
00169         {
00170             dbgprint( "GetWorkerWindow: CreateThread failed: %d", GetLastError() );
00171             goto cleanup;
00172         }
00173 
00174         // Wait for the window to become initialized
00175         rc = WaitForSingleObject( ReadyEvent, INFINITE );
00176         if ( ( WAIT_FAILED == rc ) || ( WAIT_TIMEOUT == rc ) )
00177             dbgprint( "GetWorkerWindow: WaitForSingleObject failed: %d! (error = %d)", 
00178                     rc, GetLastError() );
00179     }
00180 
00181 cleanup:
00182 
00183     if ( NULL != ReadyEvent )
00184     {
00185         // Close the ready event
00186         rc = CloseHandle( ReadyEvent );
00187         if ( 0 == rc )
00188         {
00189             dbgprint("GetWorkerWindow: CloseHandle failed: %d", GetLastError() );
00190         }
00191     }
00192 
00193     LeaveCriticalSection( &gCriticalSection );
00194 
00195     return AsyncWindow;
00196 }

int StopAsyncWindowManager (  ) 

Definition at line 96 of file asyncselect.cpp.

00098 {
00099     int     rc,
00100             code;
00101 
00102     if ( NULL != AsyncWindow )
00103     {
00104         // Post a quit message to the thread
00105         PostMessage( AsyncWindow, WM_DESTROY, 0, 0 );
00106 
00107         // Wait for the thread to cleanup and exit
00108         rc = WaitForSingleObject( WorkerThreadHandle, 10000 );
00109         if ( WAIT_TIMEOUT == rc )
00110         {
00111             dbgprint("StopAsyncWindowManager: Timed out waiting for async thread!");
00112             goto cleanup;
00113         }
00114 
00115         // Retrieve the exit code and display a simple message
00116         rc = GetExitCodeThread( WorkerThreadHandle, (LPDWORD) &code );
00117         if ( 0 == rc )
00118             dbgprint("StopAsyncWindowManager: Unable to retrieve thread exit code: %d",
00119                     GetLastError() );
00120         else if ( 0 != code )
00121             dbgprint("StopAsyncWindowManager: Async window thread exited abnormally!");
00122 
00123 cleanup:
00124 
00125         CloseHandle( WorkerThreadHandle );
00126 
00127         WorkerThreadHandle = NULL;
00128     }
00129 
00130     return 0;
00131 }