Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the IE plugin source. Time to get cooking! #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Internet Explorer/Dev - IE Addon/INSTRUCTIONS FOR BUILDING.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
IMPORTANT: For a trouble-free build, the following steps are important.

1. Go to the Start menu and find Visual Studio 2008.
2. Right-click and choose "Run as Administrator".
3. Find the SharingTime.sln file and load it.

During the build process, the ST.dll file will have been registered in the
Release directory. If you copy it to the C:\Program Files\SharingTime\core
directory, the registry will still cause the file in the Release directory
to be loaded. To fix this, perform the following steps after copying ST.dll
to the C:\Program Files\SharingTime\core directory:

1. Go to Start - Accessories.
2. Right-click on Command Prompt and choose "Run as Administrator".
3. Change to the C:\Program Files\SharingTime\core directory.
4. Run the following command > regsvr32 ST.dll

32 changes: 32 additions & 0 deletions Internet Explorer/Dev - IE Addon/SharingTime.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ST", "SharingTime\ST.vcproj", "{25C59666-682B-40FC-9413-EB63FB376E6E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
FHCRelease|Win32 = FHCRelease|Win32
FHCRelease|x64 = FHCRelease|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{25C59666-682B-40FC-9413-EB63FB376E6E}.Debug|Win32.ActiveCfg = Debug|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.Debug|Win32.Build.0 = Debug|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.Debug|x64.ActiveCfg = Debug|x64
{25C59666-682B-40FC-9413-EB63FB376E6E}.Debug|x64.Build.0 = Debug|x64
{25C59666-682B-40FC-9413-EB63FB376E6E}.FHCRelease|Win32.ActiveCfg = FHCRelease|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.FHCRelease|Win32.Build.0 = FHCRelease|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.FHCRelease|x64.ActiveCfg = FHCRelease|x64
{25C59666-682B-40FC-9413-EB63FB376E6E}.FHCRelease|x64.Build.0 = FHCRelease|x64
{25C59666-682B-40FC-9413-EB63FB376E6E}.Release|Win32.ActiveCfg = Release|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.Release|Win32.Build.0 = Release|Win32
{25C59666-682B-40FC-9413-EB63FB376E6E}.Release|x64.ActiveCfg = Release|x64
{25C59666-682B-40FC-9413-EB63FB376E6E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#include "stdafx.h"
#include "BrowserRefreshDetector.h"
#include <DispEx.h>
#include <exdispid.h>

/*static*/ SyncMap<DWORD, BrowserRefreshDetector*, true> BrowserRefreshDetector::DetectorByThread;
/*static*/ char BrowserRefreshDetector::DocumentRefreshMark[] = "STI_Refresh";

BrowserRefreshDetector::BrowserRefreshDetector():
nDownloadsCount(0),
idTimer(0)
{
MyDebug(_T("Create"));
}

BrowserRefreshDetector::~BrowserRefreshDetector(void)
{
MyDebug(_T("Destroy"));
KillDetectTimer();
}

void BrowserRefreshDetector::SetDetectTimer()
{
MyDebug(_T("SetTimer"));

DetectorByThread[GetCurrentThreadId()] = this;
KillTimer(NULL, idTimer);
idTimer = SetTimer(NULL, 0, 500, &BrowserRefreshDetector::RefreshDetectorTimerProc);
}

void BrowserRefreshDetector::KillDetectTimer()
{
MyDebug(_T("KillTimer"));
KillTimer(NULL, idTimer);
}

void BrowserRefreshDetector::ProcessDownloadBegin(bool bNeedDelay)
{
MyDebug(_T("DownloadBegin"));
nDownloadsCount++;
}

void BrowserRefreshDetector::ProcessDownloadEnd(bool bNeedDelay)
{
MyDebug(_T("DownloadEnd"));
if(--nDownloadsCount < 0)
nDownloadsCount = 0;

if(!bNeedDelay && !nDownloadsCount)
{
SetDetectTimer();
}
}

void BrowserRefreshDetector::EmulateDocumentComplete()
{
MyDebug(_T("EmulateDocumentComplete"));
BSTR bsLoc;
GetBrowser()->get_LocationURL(&bsLoc);
CString sURL = (TCHAR*)_bstr_t(bsLoc, false);
_variant_t varURL((LPCTSTR)sURL);
OnDocumentComplete_doIt(GetBrowser(), &varURL, false);
}

bool BrowserRefreshDetector::IsBrowserBusy()
{
return nDownloadsCount > 0;
}

VOID CALLBACK BrowserRefreshDetector::RefreshDetectorTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
{
MyDebug(_T("OnTimer"));
BrowserRefreshDetector *pThis = DetectorByThread[GetCurrentThreadId()];
pThis->DetectRefresh();
}

READYSTATE BrowserRefreshDetector::GetReadyState()
{
READYSTATE bstate;
GetBrowser()->get_ReadyState(&bstate);
return bstate;
}

bool BrowserRefreshDetector::CheckDocumentSignature()
{
try {

CComPtr<IDispatch> pDispDoc;
GetBrowser()->get_Document(&pDispDoc);
CComQIPtr<IHTMLDocument2> pDoc2 = pDispDoc;
if(pDoc2)
{
CComPtr<IHTMLWindow2> ptrHTMLWnd2;
pDoc2->get_parentWindow(&ptrHTMLWnd2);

// ptrHTMLWnd2 is pointer to IHTMLWindow2
CComQIPtr<IDispatchEx> ptrDispEx = ptrHTMLWnd2;
DISPID dispid = DISPID_UNKNOWN;

// Create new property
CComBSTR bstrProp(DocumentRefreshMark);
HRESULT hr = ptrDispEx->GetDispID(bstrProp,
fdexNameCaseSensitive | fdexNameEnsure, &dispid);
ATLASSERT(SUCCEEDED(hr) && dispid != DISPID_UNKNOWN);

_variant_t vProp;

// put my object into new property
CComDispatchDriver ptrDispDrv = ptrDispEx;
ptrDispDrv.GetProperty(dispid, &vProp);

bool bRes = (vProp.vt != VT_EMPTY);
MyDebug(_T("CheckDocumentSignature, res=%d"), bRes);
return bRes;
}

} catch(...) {};

MyDebug(_T("CheckDocumentSignature, no document or crash"));

return false;
}

void BrowserRefreshDetector::SignDocument()
{
MyDebug(_T("Sign Document"));

try {

CComPtr<IDispatch> pDispDoc;
GetBrowser()->get_Document(&pDispDoc);
CComQIPtr<IHTMLDocument2> pDoc2 = pDispDoc;
if(pDoc2)
{
CComPtr<IHTMLWindow2> ptrHTMLWnd2;
pDoc2->get_parentWindow(&ptrHTMLWnd2);

// ptrHTMLWnd2 is pointer to IHTMLWindow2
CComQIPtr<IDispatchEx> ptrDispEx = ptrHTMLWnd2;
DISPID dispid = DISPID_UNKNOWN;

// Create new property
CComBSTR bstrProp(DocumentRefreshMark);
HRESULT hr = ptrDispEx->GetDispID(bstrProp,
fdexNameCaseSensitive | fdexNameEnsure, &dispid);
ATLASSERT(SUCCEEDED(hr) && dispid != DISPID_UNKNOWN);

// put my object into new property
CComVariant varInstProp(true);
CComDispatchDriver ptrDispDrv = ptrDispEx;
hr = ptrDispDrv.PutProperty(dispid, &varInstProp);
}

} catch(...) {};
}

void BrowserRefreshDetector::DetectRefresh()
{
READYSTATE rs = GetReadyState();
MyDebug(_T("DetectRefresh, %d"), rs);

switch(rs)
{
case READYSTATE_COMPLETE:
//case READYSTATE_INTERACTIVE:
break;
default:
return;
}

KillDetectTimer();

if(CheckDocumentSignature())
return;

SignDocument();
EmulateDocumentComplete();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include "SyncMap.h"

class BrowserRefreshDetector
{
static char DocumentRefreshMark[];
static SyncMap<DWORD, BrowserRefreshDetector*, true> DetectorByThread;
static VOID CALLBACK RefreshDetectorTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);

UINT_PTR idTimer;
bool CheckDocumentSignature();
READYSTATE GetReadyState();
void EmulateDocumentComplete();
void DetectRefresh();
void SetDetectTimer();
void KillDetectTimer();

public:

int nDownloadsCount;

BrowserRefreshDetector();
~BrowserRefreshDetector(void);

void ProcessDownloadBegin(bool bNeedDelay);
void ProcessDownloadEnd(bool bNeedDelay);
bool IsBrowserBusy();
void SignDocument();

virtual HRESULT OnDocumentComplete_doIt(IDispatch *pDisp, VARIANT *URL, bool realOne) = 0;
virtual IWebBrowser2* GetBrowser() = 0;
};
5 changes: 5 additions & 0 deletions Internet Explorer/Dev - IE Addon/SharingTime/Configuration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef FHC
#define SCRIPT_INJECTION_URL _T("https://secure.sharingtime.com/fj?v=%d.%d.%d&b=ie")
#else
#define SCRIPT_INJECTION_URL _T("https://secure.sharingtime.com/j?v=%d.%d.%d&b=ie")
#endif
44 changes: 44 additions & 0 deletions Internet Explorer/Dev - IE Addon/SharingTime/IPCTraceMacros.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "stdafx.h"
#include "IPCTraceMacros.h"
#include <stdarg.h>
#include <tchar.H>
#include <stdio.h>

#define IPCTRACE(message) \
{ \
HWND hReceiver = ::FindWindow(NULL, _T("IPCTrace")); \
if (hReceiver) \
{ \
COPYDATASTRUCT cds; \
ZeroMemory(&cds, sizeof(COPYDATASTRUCT)); \
cds.dwData = 0x00007a69;\
cds.cbData = strlen(message) + sizeof(CHAR); \
cds.lpData = message; \
::SendMessage(hReceiver, WM_COPYDATA, NULL, (LPARAM) &cds); \
} \
}
//cds.dwData = 0x00031337; \

#define BUFFERSIZE 0x800

void OutputDebugStringFormat( LPCTSTR lpszFormat, ... )
{
try {
USES_CONVERSION;
TCHAR lpszBuffer[BUFFERSIZE]={0};
va_list fmtList;

va_start( fmtList, lpszFormat );
_vstprintf( lpszBuffer, lpszFormat, fmtList );
va_end( fmtList );
lpszBuffer[BUFFERSIZE-1] = 0;

#ifdef UNICODE
IPCTRACE(W2A(lpszBuffer));
#else
IPCTRACE(lpszBuffer);
#endif
} catch (...) {
IPCTRACE("[[ERROR WHILE IPCTRACING]]");
}
}
12 changes: 12 additions & 0 deletions Internet Explorer/Dev - IE Addon/SharingTime/IPCTraceMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include <tchar.H>

void OutputDebugStringFormat( LPCTSTR, ... );

#ifndef NDEBUG
#define MyDebug OutputDebugStringFormat
#else
#define MyDebug __noop
#endif

#define RealDebug OutputDebugStringFormat
56 changes: 56 additions & 0 deletions Internet Explorer/Dev - IE Addon/SharingTime/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
========================================================================
ACTIVE TEMPLATE LIBRARY : ST Project Overview
========================================================================

AppWizard has created this ST project for you to use as the starting point for
writing your Dynamic Link Library (DLL).

This file contains a summary of what you will find in each of the files that
make up your project.

ST.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

ST.idl
This file contains the IDL definitions of the type library, the interfaces
and co-classes defined in your project.
This file will be processed by the MIDL compiler to generate:
C++ interface definitions and GUID declarations (ST.h)
GUID definitions (ST_i.c)
A type library (ST.tlb)
Marshaling code (ST_p.c and dlldata.c)

ST.h
This file contains the C++ interface definitions and GUID declarations of the
items defined in ST.idl. It will be regenerated by MIDL during compilation.

ST.cpp
This file contains the object map and the implementation of your DLL's exports.

ST.rc
This is a listing of all of the Microsoft Windows resources that the
program uses.

ST.def
This module-definition file provides the linker with information about the exports
required by your DLL. It contains exports for:
DllGetClassObject
DllCanUnloadNow
DllRegisterServer
DllUnregisterServer

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named ST.pch and a precompiled types file named StdAfx.obj.

Resource.h
This is the standard header file that defines resource IDs.


/////////////////////////////////////////////////////////////////////////////
Loading