From aa848073409e10826850ef7abd557efeaa76d53d Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sat, 14 Sep 2024 12:55:12 -0400 Subject: [PATCH] Reformat + unify line endings --- src/config.c | 10 +- src/exdispport.h | 868 +++++++++++++++++----------------- src/hooks/hooks.c | 2 +- src/hooks/kernel32/inject.c | 4 +- src/hooks/ole32/web_browser.c | 368 +++++++------- src/hooks/ole32/web_browser.h | 8 +- src/hooks/wininet/netredir.c | 201 ++++---- 7 files changed, 736 insertions(+), 725 deletions(-) diff --git a/src/config.c b/src/config.c index 31e3041..8768e38 100644 --- a/src/config.c +++ b/src/config.c @@ -86,13 +86,13 @@ void ReadJsonPatchAddressMap(LPSTR *json, LPCSTR key) { void ReadJsonBypassSelfSignedCertificate(LPSTR *json, LPCSTR key) { LPCSTR value = JsonReadString(json); - Config.bBypassSelfSignedCertificate = FALSE; + Config.bBypassSelfSignedCertificate = FALSE; - if (value == NULL || value == "") - return; + if (value == NULL || value == "") + return; - if (_stricmp(value, "TRUE") == 0) - Config.bBypassSelfSignedCertificate = TRUE; + if (_stricmp(value, "TRUE") == 0) + Config.bBypassSelfSignedCertificate = TRUE; } void ReadJsonConfigMap(LPSTR *json, LPCSTR key) { diff --git a/src/exdispport.h b/src/exdispport.h index 3d0bd9a..071a819 100644 --- a/src/exdispport.h +++ b/src/exdispport.h @@ -1,435 +1,435 @@ -#pragma once - -// IWebBrowser 1 and 2 -#ifdef __MINGW32__ -#ifndef __IWebBrowser2_FWD_DEFINED__ -#define __IWebBrowser2_FWD_DEFINED__ -typedef struct IWebBrowser2 IWebBrowser2; - -#endif /* __IWebBrowser2_FWD_DEFINED__ */ - -typedef /* [v1_enum] */ - enum tagREADYSTATE { - READYSTATE_UNINITIALIZED = 0, - READYSTATE_LOADING = 1, - READYSTATE_LOADED = 2, - READYSTATE_INTERACTIVE = 3, - READYSTATE_COMPLETE = 4 - } READYSTATE; - -typedef enum OLECMDF { - OLECMDF_SUPPORTED = 0x1, - OLECMDF_ENABLED = 0x2, - OLECMDF_LATCHED = 0x4, - OLECMDF_NINCHED = 0x8, - OLECMDF_INVISIBLE = 0x10, - OLECMDF_DEFHIDEONCTXTMENU = 0x20 -} OLECMDF; - -typedef enum OLECMDID { - OLECMDID_OPEN = 1, - OLECMDID_NEW = 2, - OLECMDID_SAVE = 3, - OLECMDID_SAVEAS = 4, - OLECMDID_SAVECOPYAS = 5, - OLECMDID_PRINT = 6, - OLECMDID_PRINTPREVIEW = 7, - OLECMDID_PAGESETUP = 8, - OLECMDID_SPELL = 9, - OLECMDID_PROPERTIES = 10, - OLECMDID_CUT = 11, - OLECMDID_COPY = 12, - OLECMDID_PASTE = 13, - OLECMDID_PASTESPECIAL = 14, - OLECMDID_UNDO = 15, - OLECMDID_REDO = 16, - OLECMDID_SELECTALL = 17, - OLECMDID_CLEARSELECTION = 18, - OLECMDID_ZOOM = 19, - OLECMDID_GETZOOMRANGE = 20, - OLECMDID_UPDATECOMMANDS = 21, - OLECMDID_REFRESH = 22, - OLECMDID_STOP = 23, - OLECMDID_HIDETOOLBARS = 24, - OLECMDID_SETPROGRESSMAX = 25, - OLECMDID_SETPROGRESSPOS = 26, - OLECMDID_SETPROGRESSTEXT = 27, - OLECMDID_SETTITLE = 28, - OLECMDID_SETDOWNLOADSTATE = 29, - OLECMDID_STOPDOWNLOAD = 30, - OLECMDID_ONTOOLBARACTIVATED = 31, - OLECMDID_FIND = 32, - OLECMDID_DELETE = 33, - OLECMDID_HTTPEQUIV = 34, - OLECMDID_HTTPEQUIV_DONE = 35, - OLECMDID_ENABLE_INTERACTION = 36, - OLECMDID_ONUNLOAD = 37, - OLECMDID_PROPERTYBAG2 = 38, - OLECMDID_PREREFRESH = 39, - OLECMDID_SHOWSCRIPTERROR = 40, - OLECMDID_SHOWMESSAGE = 41, - OLECMDID_SHOWFIND = 42, - OLECMDID_SHOWPAGESETUP = 43, - OLECMDID_SHOWPRINT = 44, - OLECMDID_CLOSE = 45, - OLECMDID_ALLOWUILESSSAVEAS = 46, - OLECMDID_DONTDOWNLOADCSS = 47, - OLECMDID_UPDATEPAGESTATUS = 48, - OLECMDID_PRINT2 = 49, - OLECMDID_PRINTPREVIEW2 = 50, - OLECMDID_SETPRINTTEMPLATE = 51, - OLECMDID_GETPRINTTEMPLATE = 52, - OLECMDID_PAGEACTIONBLOCKED = 55, - OLECMDID_PAGEACTIONUIQUERY = 56, - OLECMDID_FOCUSVIEWCONTROLS = 57, - OLECMDID_FOCUSVIEWCONTROLSQUERY = 58, - OLECMDID_SHOWPAGEACTIONMENU = 59, - OLECMDID_ADDTRAVELENTRY = 60, - OLECMDID_UPDATETRAVELENTRY = 61, - OLECMDID_UPDATEBACKFORWARDSTATE = 62, - OLECMDID_OPTICAL_ZOOM = 63, - OLECMDID_OPTICAL_GETZOOMRANGE = 64, - OLECMDID_WINDOWSTATECHANGED = 65, - OLECMDID_ACTIVEXINSTALLSCOPE = 66, - OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67, - OLECMDID_SHOWTASKDLG = 68, - OLECMDID_POPSTATEEVENT = 69, - OLECMDID_VIEWPORT_MODE = 70, - OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71, - OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72, - OLECMDID_USER_OPTICAL_ZOOM = 73, - OLECMDID_PAGEAVAILABLE = 74, - OLECMDID_GETUSERSCALABLE = 75, - OLECMDID_UPDATE_CARET = 76, - OLECMDID_ENABLE_VISIBILITY = 77, - OLECMDID_MEDIA_PLAYBACK = 78, - OLECMDID_SETFAVICON = 79, - OLECMDID_SET_HOST_FULLSCREENMODE = 80, - OLECMDID_EXITFULLSCREEN = 81, - OLECMDID_SCROLLCOMPLETE = 82, - OLECMDID_ONBEFOREUNLOAD = 83, - OLECMDID_SHOWMESSAGE_BLOCKABLE = 84, - OLECMDID_SHOWTASKDLG_BLOCKABLE = 85 -} OLECMDID; - -typedef enum OLECMDEXECOPT { - OLECMDEXECOPT_DODEFAULT = 0, - OLECMDEXECOPT_PROMPTUSER = 1, - OLECMDEXECOPT_DONTPROMPTUSER = 2, - OLECMDEXECOPT_SHOWHELP = 3 -} OLECMDEXECOPT; - -typedef struct IWebBrowser2Vtbl { - - BEGIN_INTERFACE - - HRESULT(STDCALL *QueryInterface) - (__RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG(STDCALL *AddRef)(__RPC__in IWebBrowser2 *This); - - ULONG(STDCALL *Release)(__RPC__in IWebBrowser2 *This); - - HRESULT(STDCALL *GetTypeInfoCount) - (__RPC__in IWebBrowser2 *This, - /* [out] */ __RPC__out UINT *pctinfo); - - HRESULT(STDCALL *GetTypeInfo) - (__RPC__in IWebBrowser2 *This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo); - - HRESULT(STDCALL *GetIDsOfNames) - (__RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in REFIID riid, - /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, - /* [range][in] */ __RPC__in_range(0, 16384) UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId); - - /* [local] */ HRESULT(STDCALL *Invoke)(IWebBrowser2 *This, - /* [annotation][in] */ - _In_ DISPID dispIdMember, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][in] */ - _In_ LCID lcid, - /* [annotation][in] */ - _In_ WORD wFlags, - /* [annotation][out][in] */ - _In_ DISPPARAMS *pDispParams, - /* [annotation][out] */ - _Out_opt_ VARIANT *pVarResult, - /* [annotation][out] */ - _Out_opt_ EXCEPINFO *pExcepInfo, - /* [annotation][out] */ - _Out_opt_ UINT *puArgErr); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoBack)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoForward)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoHome)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoSearch)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Navigate)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in BSTR URL, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *Flags, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *TargetFrameName, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *PostData, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *Headers); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Refresh)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Refresh2)( - __RPC__in IWebBrowser2 *This, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *Level); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Stop)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Application)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Parent)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Container)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Document)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_TopLevelContainer)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Type)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *Type); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Left)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out long *pl); - - /* [propput][id] */ HRESULT(STDCALL *put_Left)(__RPC__in IWebBrowser2 *This, - /* [in] */ long Left); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Top)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out long *pl); - - /* [propput][id] */ HRESULT(STDCALL *put_Top)(__RPC__in IWebBrowser2 *This, - /* [in] */ long Top); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Width)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out long *pl); - - /* [propput][id] */ HRESULT(STDCALL *put_Width)(__RPC__in IWebBrowser2 *This, - /* [in] */ long Width); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Height)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out long *pl); - - /* [propput][id] */ HRESULT(STDCALL *put_Height)(__RPC__in IWebBrowser2 *This, - /* [in] */ long Height); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_LocationName)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *LocationName); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_LocationURL)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *LocationURL); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Busy)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Quit)(__RPC__in IWebBrowser2 *This); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ClientToWindow)( - __RPC__in IWebBrowser2 *This, - /* [out][in] */ __RPC__inout int *pcx, - /* [out][in] */ __RPC__inout int *pcy); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *PutProperty)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in BSTR Property, - /* [in] */ VARIANT vtValue); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GetProperty)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in BSTR Property, - /* [retval][out] */ __RPC__out VARIANT *pvtValue); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Name)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *Name); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_HWND)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out SHANDLE_PTR *pHWND); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_FullName)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *FullName); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Path)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *Path); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Visible)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Visible)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL Value); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_StatusBar)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_StatusBar)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL Value); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_StatusText)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__deref_out_opt BSTR *StatusText); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_StatusText)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in BSTR StatusText); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_ToolBar)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out int *Value); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_ToolBar)( - __RPC__in IWebBrowser2 *This, - /* [in] */ int Value); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_MenuBar)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_MenuBar)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL Value); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_FullScreen)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbFullScreen); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_FullScreen)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bFullScreen); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Navigate2)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in VARIANT *URL, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *Flags, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *TargetFrameName, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *PostData, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *Headers); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *QueryStatusWB)( - __RPC__in IWebBrowser2 *This, - /* [in] */ OLECMDID cmdID, - /* [retval][out] */ __RPC__out OLECMDF *pcmdf); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ExecWB)( - __RPC__in IWebBrowser2 *This, - /* [in] */ OLECMDID cmdID, - /* [in] */ OLECMDEXECOPT cmdexecopt, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvaIn, - /* [unique][optional][out][in] */ __RPC__inout_opt VARIANT *pvaOut); - - /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ShowBrowserBar)( - __RPC__in IWebBrowser2 *This, - /* [in] */ __RPC__in VARIANT *pvaClsid, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvarShow, - /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvarSize); - - /* [bindable][propget][id] */ HRESULT(STDCALL *get_ReadyState)( - __RPC__in IWebBrowser2 *This, - /* [out][retval] */ __RPC__out READYSTATE *plReadyState); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Offline)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbOffline); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Offline)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bOffline); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Silent)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbSilent); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Silent)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bSilent); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_RegisterAsBrowser)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_RegisterAsBrowser)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bRegister); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_RegisterAsDropTarget)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_RegisterAsDropTarget)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bRegister); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_TheaterMode)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_TheaterMode)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL bRegister); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_AddressBar)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_AddressBar)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL Value); - - /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Resizable)( - __RPC__in IWebBrowser2 *This, - /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); - - /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Resizable)( - __RPC__in IWebBrowser2 *This, - /* [in] */ VARIANT_BOOL Value); - - END_INTERFACE -} IWebBrowser2Vtbl; - -struct IWebBrowser2 { - CONST_VTBL struct IWebBrowser2Vtbl *lpVtbl; -}; -#else -#include +#pragma once + +// IWebBrowser 1 and 2 +#ifdef __MINGW32__ +#ifndef __IWebBrowser2_FWD_DEFINED__ +#define __IWebBrowser2_FWD_DEFINED__ +typedef struct IWebBrowser2 IWebBrowser2; + +#endif /* __IWebBrowser2_FWD_DEFINED__ */ + +typedef /* [v1_enum] */ + enum tagREADYSTATE { + READYSTATE_UNINITIALIZED = 0, + READYSTATE_LOADING = 1, + READYSTATE_LOADED = 2, + READYSTATE_INTERACTIVE = 3, + READYSTATE_COMPLETE = 4 + } READYSTATE; + +typedef enum OLECMDF { + OLECMDF_SUPPORTED = 0x1, + OLECMDF_ENABLED = 0x2, + OLECMDF_LATCHED = 0x4, + OLECMDF_NINCHED = 0x8, + OLECMDF_INVISIBLE = 0x10, + OLECMDF_DEFHIDEONCTXTMENU = 0x20 +} OLECMDF; + +typedef enum OLECMDID { + OLECMDID_OPEN = 1, + OLECMDID_NEW = 2, + OLECMDID_SAVE = 3, + OLECMDID_SAVEAS = 4, + OLECMDID_SAVECOPYAS = 5, + OLECMDID_PRINT = 6, + OLECMDID_PRINTPREVIEW = 7, + OLECMDID_PAGESETUP = 8, + OLECMDID_SPELL = 9, + OLECMDID_PROPERTIES = 10, + OLECMDID_CUT = 11, + OLECMDID_COPY = 12, + OLECMDID_PASTE = 13, + OLECMDID_PASTESPECIAL = 14, + OLECMDID_UNDO = 15, + OLECMDID_REDO = 16, + OLECMDID_SELECTALL = 17, + OLECMDID_CLEARSELECTION = 18, + OLECMDID_ZOOM = 19, + OLECMDID_GETZOOMRANGE = 20, + OLECMDID_UPDATECOMMANDS = 21, + OLECMDID_REFRESH = 22, + OLECMDID_STOP = 23, + OLECMDID_HIDETOOLBARS = 24, + OLECMDID_SETPROGRESSMAX = 25, + OLECMDID_SETPROGRESSPOS = 26, + OLECMDID_SETPROGRESSTEXT = 27, + OLECMDID_SETTITLE = 28, + OLECMDID_SETDOWNLOADSTATE = 29, + OLECMDID_STOPDOWNLOAD = 30, + OLECMDID_ONTOOLBARACTIVATED = 31, + OLECMDID_FIND = 32, + OLECMDID_DELETE = 33, + OLECMDID_HTTPEQUIV = 34, + OLECMDID_HTTPEQUIV_DONE = 35, + OLECMDID_ENABLE_INTERACTION = 36, + OLECMDID_ONUNLOAD = 37, + OLECMDID_PROPERTYBAG2 = 38, + OLECMDID_PREREFRESH = 39, + OLECMDID_SHOWSCRIPTERROR = 40, + OLECMDID_SHOWMESSAGE = 41, + OLECMDID_SHOWFIND = 42, + OLECMDID_SHOWPAGESETUP = 43, + OLECMDID_SHOWPRINT = 44, + OLECMDID_CLOSE = 45, + OLECMDID_ALLOWUILESSSAVEAS = 46, + OLECMDID_DONTDOWNLOADCSS = 47, + OLECMDID_UPDATEPAGESTATUS = 48, + OLECMDID_PRINT2 = 49, + OLECMDID_PRINTPREVIEW2 = 50, + OLECMDID_SETPRINTTEMPLATE = 51, + OLECMDID_GETPRINTTEMPLATE = 52, + OLECMDID_PAGEACTIONBLOCKED = 55, + OLECMDID_PAGEACTIONUIQUERY = 56, + OLECMDID_FOCUSVIEWCONTROLS = 57, + OLECMDID_FOCUSVIEWCONTROLSQUERY = 58, + OLECMDID_SHOWPAGEACTIONMENU = 59, + OLECMDID_ADDTRAVELENTRY = 60, + OLECMDID_UPDATETRAVELENTRY = 61, + OLECMDID_UPDATEBACKFORWARDSTATE = 62, + OLECMDID_OPTICAL_ZOOM = 63, + OLECMDID_OPTICAL_GETZOOMRANGE = 64, + OLECMDID_WINDOWSTATECHANGED = 65, + OLECMDID_ACTIVEXINSTALLSCOPE = 66, + OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67, + OLECMDID_SHOWTASKDLG = 68, + OLECMDID_POPSTATEEVENT = 69, + OLECMDID_VIEWPORT_MODE = 70, + OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71, + OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72, + OLECMDID_USER_OPTICAL_ZOOM = 73, + OLECMDID_PAGEAVAILABLE = 74, + OLECMDID_GETUSERSCALABLE = 75, + OLECMDID_UPDATE_CARET = 76, + OLECMDID_ENABLE_VISIBILITY = 77, + OLECMDID_MEDIA_PLAYBACK = 78, + OLECMDID_SETFAVICON = 79, + OLECMDID_SET_HOST_FULLSCREENMODE = 80, + OLECMDID_EXITFULLSCREEN = 81, + OLECMDID_SCROLLCOMPLETE = 82, + OLECMDID_ONBEFOREUNLOAD = 83, + OLECMDID_SHOWMESSAGE_BLOCKABLE = 84, + OLECMDID_SHOWTASKDLG_BLOCKABLE = 85 +} OLECMDID; + +typedef enum OLECMDEXECOPT { + OLECMDEXECOPT_DODEFAULT = 0, + OLECMDEXECOPT_PROMPTUSER = 1, + OLECMDEXECOPT_DONTPROMPTUSER = 2, + OLECMDEXECOPT_SHOWHELP = 3 +} OLECMDEXECOPT; + +typedef struct IWebBrowser2Vtbl { + + BEGIN_INTERFACE + + HRESULT(STDCALL *QueryInterface) + (__RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG(STDCALL *AddRef)(__RPC__in IWebBrowser2 *This); + + ULONG(STDCALL *Release)(__RPC__in IWebBrowser2 *This); + + HRESULT(STDCALL *GetTypeInfoCount) + (__RPC__in IWebBrowser2 *This, + /* [out] */ __RPC__out UINT *pctinfo); + + HRESULT(STDCALL *GetTypeInfo) + (__RPC__in IWebBrowser2 *This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo); + + HRESULT(STDCALL *GetIDsOfNames) + (__RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in REFIID riid, + /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, + /* [range][in] */ __RPC__in_range(0, 16384) UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId); + + /* [local] */ HRESULT(STDCALL *Invoke)(IWebBrowser2 *This, + /* [annotation][in] */ + _In_ DISPID dispIdMember, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][in] */ + _In_ LCID lcid, + /* [annotation][in] */ + _In_ WORD wFlags, + /* [annotation][out][in] */ + _In_ DISPPARAMS *pDispParams, + /* [annotation][out] */ + _Out_opt_ VARIANT *pVarResult, + /* [annotation][out] */ + _Out_opt_ EXCEPINFO *pExcepInfo, + /* [annotation][out] */ + _Out_opt_ UINT *puArgErr); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoBack)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoForward)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoHome)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GoSearch)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Navigate)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in BSTR URL, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *Flags, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *TargetFrameName, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *PostData, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *Headers); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Refresh)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Refresh2)( + __RPC__in IWebBrowser2 *This, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *Level); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Stop)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Application)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Parent)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Container)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Document)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt IDispatch **ppDisp); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_TopLevelContainer)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Type)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *Type); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Left)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out long *pl); + + /* [propput][id] */ HRESULT(STDCALL *put_Left)(__RPC__in IWebBrowser2 *This, + /* [in] */ long Left); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Top)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out long *pl); + + /* [propput][id] */ HRESULT(STDCALL *put_Top)(__RPC__in IWebBrowser2 *This, + /* [in] */ long Top); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Width)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out long *pl); + + /* [propput][id] */ HRESULT(STDCALL *put_Width)(__RPC__in IWebBrowser2 *This, + /* [in] */ long Width); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Height)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out long *pl); + + /* [propput][id] */ HRESULT(STDCALL *put_Height)(__RPC__in IWebBrowser2 *This, + /* [in] */ long Height); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_LocationName)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *LocationName); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_LocationURL)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *LocationURL); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Busy)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Quit)(__RPC__in IWebBrowser2 *This); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ClientToWindow)( + __RPC__in IWebBrowser2 *This, + /* [out][in] */ __RPC__inout int *pcx, + /* [out][in] */ __RPC__inout int *pcy); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *PutProperty)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in BSTR Property, + /* [in] */ VARIANT vtValue); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *GetProperty)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in BSTR Property, + /* [retval][out] */ __RPC__out VARIANT *pvtValue); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Name)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *Name); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_HWND)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out SHANDLE_PTR *pHWND); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_FullName)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *FullName); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Path)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *Path); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Visible)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Visible)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL Value); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_StatusBar)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pBool); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_StatusBar)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL Value); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_StatusText)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__deref_out_opt BSTR *StatusText); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_StatusText)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in BSTR StatusText); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_ToolBar)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out int *Value); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_ToolBar)( + __RPC__in IWebBrowser2 *This, + /* [in] */ int Value); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_MenuBar)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_MenuBar)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL Value); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_FullScreen)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbFullScreen); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_FullScreen)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bFullScreen); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *Navigate2)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in VARIANT *URL, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *Flags, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *TargetFrameName, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *PostData, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *Headers); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *QueryStatusWB)( + __RPC__in IWebBrowser2 *This, + /* [in] */ OLECMDID cmdID, + /* [retval][out] */ __RPC__out OLECMDF *pcmdf); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ExecWB)( + __RPC__in IWebBrowser2 *This, + /* [in] */ OLECMDID cmdID, + /* [in] */ OLECMDEXECOPT cmdexecopt, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvaIn, + /* [unique][optional][out][in] */ __RPC__inout_opt VARIANT *pvaOut); + + /* [helpcontext][helpstring][id] */ HRESULT(STDCALL *ShowBrowserBar)( + __RPC__in IWebBrowser2 *This, + /* [in] */ __RPC__in VARIANT *pvaClsid, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvarShow, + /* [unique][optional][in] */ __RPC__in_opt VARIANT *pvarSize); + + /* [bindable][propget][id] */ HRESULT(STDCALL *get_ReadyState)( + __RPC__in IWebBrowser2 *This, + /* [out][retval] */ __RPC__out READYSTATE *plReadyState); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Offline)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbOffline); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Offline)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bOffline); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Silent)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbSilent); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Silent)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bSilent); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_RegisterAsBrowser)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_RegisterAsBrowser)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bRegister); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_RegisterAsDropTarget)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_RegisterAsDropTarget)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bRegister); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_TheaterMode)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *pbRegister); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_TheaterMode)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL bRegister); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_AddressBar)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_AddressBar)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL Value); + + /* [helpcontext][helpstring][propget][id] */ HRESULT(STDCALL *get_Resizable)( + __RPC__in IWebBrowser2 *This, + /* [retval][out] */ __RPC__out VARIANT_BOOL *Value); + + /* [helpcontext][helpstring][propput][id] */ HRESULT(STDCALL *put_Resizable)( + __RPC__in IWebBrowser2 *This, + /* [in] */ VARIANT_BOOL Value); + + END_INTERFACE +} IWebBrowser2Vtbl; + +struct IWebBrowser2 { + CONST_VTBL struct IWebBrowser2Vtbl *lpVtbl; +}; +#else +#include #endif \ No newline at end of file diff --git a/src/hooks/hooks.c b/src/hooks/hooks.c index 5210abc..9cdb09f 100644 --- a/src/hooks/hooks.c +++ b/src/hooks/hooks.c @@ -19,10 +19,10 @@ #include "comctl32/dynamic_patch.h" #include "kernel32/inject.h" #include "msvcr100/msvcr100.h" +#include "ole32/web_browser.h" #include "user32/window.h" #include "wininet/netredir.h" #include "ws2_32/redir.h" -#include "ole32/web_browser.h" VOID InitHooks() { InitInjectHook(); diff --git a/src/hooks/kernel32/inject.c b/src/hooks/kernel32/inject.c index e838536..b239b3f 100644 --- a/src/hooks/kernel32/inject.c +++ b/src/hooks/kernel32/inject.c @@ -66,7 +66,9 @@ static BOOL STDCALL CreateProcessAHook(LPCSTR lpApplicationName, LPSTR lpCommand lpProcessInformation->hProcess = hGameguardFakeHandle; return TRUE; } - return pCreateProcessA(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation); + return pCreateProcessA(lpApplicationName, lpCommandLine, lpProcessAttributes, + lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, + lpCurrentDirectory, lpStartupInfo, lpProcessInformation); } static BOOL STDCALL GetExitCodeProcessHook(HANDLE hProcess, LPDWORD lpExitCode) { diff --git a/src/hooks/ole32/web_browser.c b/src/hooks/ole32/web_browser.c index d458770..9d58a51 100644 --- a/src/hooks/ole32/web_browser.c +++ b/src/hooks/ole32/web_browser.c @@ -1,177 +1,191 @@ -#include "web_browser.h" -#include "../../config.h" -#include "../../patch.h" - -static HMODULE hOle32Module = NULL; -static HMODULE hOleAut32Module = NULL; -static PFNCOGETCLASSOBJECTPROC pCoGetClassObject = NULL; -static PFNCOCREATEINSTANCEPROC pCoCreateInstance = NULL; -static PFNINVOKEPROC pInvoke = NULL; -static PFNNAVIGATEPROC pNavigate = NULL; -static PFNSYSALLOCSTRINGLENPROC pSysAllocStringLen = NULL; -static PFNSYSFREESTRINGPROC pSysFreeString = NULL; - -// {00000112-0000-0000-C000-000000000046} -const IID kIID_IObject = {0x112, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; -// {00020400-0000-0000-C000-000000000046} -const IID kIID_IDispatch = {0x20400, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; -// {00000001-0000-0000-C000-000000000046} -const IID kIID_IClassFactory = {0x1, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; -// {8856F961-340A-11D0-A96B-00C04FD705A2} -const IID kIID_MicrosoftWebBrowser = {0x8856F961, 0x340A, 0x11D0, {0xA9, 0x6B, 0, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}}; -// {D30C1661-CDAF-11d0-8A3E-00C04FC9E26E} -const IID kIID_IWebBrowser2 = {0xD30C1661, 0xCDAF, 0x11D0, {0x8A, 0x3E, 0, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}}; - -BSTR RewriteURLW(BSTR urlw) { - - int len_urlw = lstrlenW(urlw); - int len = WideCharToMultiByte(CP_ACP, 0, urlw, len_urlw, NULL, 0, NULL, NULL); - - PCHAR url = AllocMem(len + 1); - - WideCharToMultiByte(CP_ACP, 0, urlw, len_urlw, url, len, NULL, NULL); - - url[len] = '\0'; - - LPCSTR newURLA = RewriteURL(url); - - FreeMem(url); - - if (newURLA != NULL) { - - len = lstrlenA(newURLA); - - len_urlw = MultiByteToWideChar(CP_ACP, 0, newURLA, len, NULL, 0); - - BSTR newURLBSTR = pSysAllocStringLen(NULL, len_urlw); - - MultiByteToWideChar(CP_ACP, 0, newURLA, len, newURLBSTR, len_urlw); - - FreeMem((HLOCAL)newURLA); - - return newURLBSTR; - } - - return NULL; -} - -HRESULT InvokeHook(IDispatch *This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { - - BSTR newURL = NULL; - - for (unsigned int i = 0u; i < pDispParams->cArgs; i++) { - - if (pDispParams->rgvarg[i].vt == VT_BSTR) { - - newURL = RewriteURLW(pDispParams->rgvarg[i].bstrVal); - if (newURL != NULL) { - Log("IDispatch->Invoke(%S -> %S)\r\n", pDispParams->rgvarg[i].bstrVal, newURL); - pSysFreeString(pDispParams->rgvarg[i].bstrVal); - pDispParams->rgvarg[i].bstrVal = newURL; - } else { - Log("IDispatch->Invoke(%S) // (no rewrite rules matched)\r\n", pDispParams->rgvarg[i].bstrVal); - } - } - } - - return pInvoke(This, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); -} - -HRESULT STDCALL NavigateHook(IWebBrowser2 *This, BSTR URL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers) { - - BSTR newURL = NULL; - - newURL = RewriteURLW(URL); - if (newURL != NULL) { - Log("IWebBrowser2->Navigate(%S -> %S)\r\n", URL, newURL); - URL = newURL; - } else { - Log("IWebBrowser2->Navigate(%S) // (no rewrite rules matched)\r\n", URL); - } - - HRESULT hResult = pNavigate(This, URL, Flags, TargetFrameName, PostData, Headers); - - if (newURL != NULL) - pSysFreeString(newURL); - - return hResult; -} - -HRESULT STDCALL CoGetClassObjectHook(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, REFIID riid, LPVOID *ppv) { - - static void *g_pInvoke = NULL; - - HRESULT ret = pCoGetClassObject(rclsid, dwClsContext, pvReserved, riid, ppv); - - if (ret >= 0) { - - if (memcmp(rclsid, &kIID_MicrosoftWebBrowser, sizeof(IID)) == 0) { - - IClassFactory *obj = (IClassFactory*)*ppv; - - IDispatch *iDispatch1 = NULL; - IDispatch *iDispatch2 = NULL; - - HRESULT ret2 = obj->lpVtbl->CreateInstance(obj, NULL, &kIID_IObject, (LPVOID*)&iDispatch1); - - if (ret2 < 0) { - Log("CreateInstance failed. %d\r\n", ret2); - return ret; - } - - ret2 = iDispatch1->lpVtbl->QueryInterface(iDispatch1, &kIID_IDispatch, (LPVOID*)&iDispatch2); - - if (ret2 < 0) { - Log("QueryInterface failed. %d\r\n", ret2); - return ret; - } - - if (g_pInvoke != iDispatch2->lpVtbl->Invoke) { - g_pInvoke = iDispatch2->lpVtbl->Invoke; - pInvoke = HookFunc(g_pInvoke, InvokeHook); - Log("Install InvokeHook(0x%08p): 0x%08p -> 0x%08p\r\n", g_pInvoke, InvokeHook, pInvoke); - } - } - } - - return ret; -} - -HRESULT STDCALL CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv) { - - static void *g_pNavigate = NULL; - - HRESULT ret = pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); - - if (ret >= 0) { - - if (memcmp(rclsid, &kIID_MicrosoftWebBrowser, sizeof(IID)) == 0) { - - IUnknown *obj = *ppv; - IWebBrowser2 *webbrowser2 = NULL; - - HRESULT ret2 = obj->lpVtbl->QueryInterface(obj, &kIID_IWebBrowser2, (LPVOID*)&webbrowser2); - if (ret2 < 0) { - Log("QueryInterface failed. %d\r\n", ret2); - return ret; - } - - if (g_pNavigate != webbrowser2->lpVtbl->Navigate) { - g_pNavigate = webbrowser2->lpVtbl->Navigate; - pNavigate = HookFunc(g_pNavigate, NavigateHook); - Log("Install NavigateHook(0x%08p): 0x%08p -> 0x%08p\r\n", g_pNavigate, NavigateHook, pNavigate); - } - } - } - - return ret; -} - -void InitWebBrowserHook() { - hOle32Module = LoadLib("ole32"); - hOleAut32Module = LoadLib("oleaut32"); - pSysAllocStringLen = GetProc(hOleAut32Module, "SysAllocStringLen"); - pSysFreeString = GetProc(hOleAut32Module, "SysFreeString"); - pCoGetClassObject = HookProc(hOle32Module, "CoGetClassObject", CoGetClassObjectHook); - pCoCreateInstance = HookProc(hOle32Module, "CoCreateInstance", CoCreateInstanceHook); -} +#include "web_browser.h" +#include "../../config.h" +#include "../../patch.h" + +static HMODULE hOle32Module = NULL; +static HMODULE hOleAut32Module = NULL; +static PFNCOGETCLASSOBJECTPROC pCoGetClassObject = NULL; +static PFNCOCREATEINSTANCEPROC pCoCreateInstance = NULL; +static PFNINVOKEPROC pInvoke = NULL; +static PFNNAVIGATEPROC pNavigate = NULL; +static PFNSYSALLOCSTRINGLENPROC pSysAllocStringLen = NULL; +static PFNSYSFREESTRINGPROC pSysFreeString = NULL; + +// {00000112-0000-0000-C000-000000000046} +const IID kIID_IObject = {0x112, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; +// {00020400-0000-0000-C000-000000000046} +const IID kIID_IDispatch = {0x20400, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; +// {00000001-0000-0000-C000-000000000046} +const IID kIID_IClassFactory = {0x1, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}}; +// {8856F961-340A-11D0-A96B-00C04FD705A2} +const IID kIID_MicrosoftWebBrowser = { + 0x8856F961, 0x340A, 0x11D0, {0xA9, 0x6B, 0, 0xC0, 0x4F, 0xD7, 0x05, 0xA2}}; +// {D30C1661-CDAF-11d0-8A3E-00C04FC9E26E} +const IID kIID_IWebBrowser2 = { + 0xD30C1661, 0xCDAF, 0x11D0, {0x8A, 0x3E, 0, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E}}; + +BSTR RewriteURLW(BSTR urlw) { + + int len_urlw = lstrlenW(urlw); + int len = WideCharToMultiByte(CP_ACP, 0, urlw, len_urlw, NULL, 0, NULL, NULL); + + PCHAR url = AllocMem(len + 1); + + WideCharToMultiByte(CP_ACP, 0, urlw, len_urlw, url, len, NULL, NULL); + + url[len] = '\0'; + + LPCSTR newURLA = RewriteURL(url); + + FreeMem(url); + + if (newURLA != NULL) { + + len = lstrlenA(newURLA); + + len_urlw = MultiByteToWideChar(CP_ACP, 0, newURLA, len, NULL, 0); + + BSTR newURLBSTR = pSysAllocStringLen(NULL, len_urlw); + + MultiByteToWideChar(CP_ACP, 0, newURLA, len, newURLBSTR, len_urlw); + + FreeMem((HLOCAL)newURLA); + + return newURLBSTR; + } + + return NULL; +} + +HRESULT InvokeHook(IDispatch *This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, + UINT *puArgErr) { + + BSTR newURL = NULL; + + for (unsigned int i = 0u; i < pDispParams->cArgs; i++) { + + if (pDispParams->rgvarg[i].vt == VT_BSTR) { + + newURL = RewriteURLW(pDispParams->rgvarg[i].bstrVal); + if (newURL != NULL) { + Log("IDispatch->Invoke(%S -> %S)\r\n", pDispParams->rgvarg[i].bstrVal, newURL); + pSysFreeString(pDispParams->rgvarg[i].bstrVal); + pDispParams->rgvarg[i].bstrVal = newURL; + } else { + Log("IDispatch->Invoke(%S) // (no rewrite rules matched)\r\n", + pDispParams->rgvarg[i].bstrVal); + } + } + } + + return pInvoke(This, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, + puArgErr); +} + +HRESULT STDCALL NavigateHook(IWebBrowser2 *This, BSTR URL, VARIANT *Flags, VARIANT *TargetFrameName, + VARIANT *PostData, VARIANT *Headers) { + + BSTR newURL = NULL; + + newURL = RewriteURLW(URL); + if (newURL != NULL) { + Log("IWebBrowser2->Navigate(%S -> %S)\r\n", URL, newURL); + URL = newURL; + } else { + Log("IWebBrowser2->Navigate(%S) // (no rewrite rules matched)\r\n", URL); + } + + HRESULT hResult = pNavigate(This, URL, Flags, TargetFrameName, PostData, Headers); + + if (newURL != NULL) + pSysFreeString(newURL); + + return hResult; +} + +HRESULT STDCALL CoGetClassObjectHook(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, + REFIID riid, LPVOID *ppv) { + + static void *g_pInvoke = NULL; + + HRESULT ret = pCoGetClassObject(rclsid, dwClsContext, pvReserved, riid, ppv); + + if (ret >= 0) { + + if (memcmp(rclsid, &kIID_MicrosoftWebBrowser, sizeof(IID)) == 0) { + + IClassFactory *obj = (IClassFactory *)*ppv; + + IDispatch *iDispatch1 = NULL; + IDispatch *iDispatch2 = NULL; + + HRESULT ret2 = + obj->lpVtbl->CreateInstance(obj, NULL, &kIID_IObject, (LPVOID *)&iDispatch1); + + if (ret2 < 0) { + Log("CreateInstance failed. %d\r\n", ret2); + return ret; + } + + ret2 = iDispatch1->lpVtbl->QueryInterface(iDispatch1, &kIID_IDispatch, + (LPVOID *)&iDispatch2); + + if (ret2 < 0) { + Log("QueryInterface failed. %d\r\n", ret2); + return ret; + } + + if (g_pInvoke != iDispatch2->lpVtbl->Invoke) { + g_pInvoke = iDispatch2->lpVtbl->Invoke; + pInvoke = HookFunc(g_pInvoke, InvokeHook); + Log("Install InvokeHook(0x%08p): 0x%08p -> 0x%08p\r\n", g_pInvoke, InvokeHook, + pInvoke); + } + } + } + + return ret; +} + +HRESULT STDCALL CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, + REFIID riid, LPVOID *ppv) { + + static void *g_pNavigate = NULL; + + HRESULT ret = pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); + + if (ret >= 0) { + + if (memcmp(rclsid, &kIID_MicrosoftWebBrowser, sizeof(IID)) == 0) { + + IUnknown *obj = *ppv; + IWebBrowser2 *webbrowser2 = NULL; + + HRESULT ret2 = + obj->lpVtbl->QueryInterface(obj, &kIID_IWebBrowser2, (LPVOID *)&webbrowser2); + if (ret2 < 0) { + Log("QueryInterface failed. %d\r\n", ret2); + return ret; + } + + if (g_pNavigate != webbrowser2->lpVtbl->Navigate) { + g_pNavigate = webbrowser2->lpVtbl->Navigate; + pNavigate = HookFunc(g_pNavigate, NavigateHook); + Log("Install NavigateHook(0x%08p): 0x%08p -> 0x%08p\r\n", g_pNavigate, NavigateHook, + pNavigate); + } + } + } + + return ret; +} + +void InitWebBrowserHook() { + hOle32Module = LoadLib("ole32"); + hOleAut32Module = LoadLib("oleaut32"); + pSysAllocStringLen = GetProc(hOleAut32Module, "SysAllocStringLen"); + pSysFreeString = GetProc(hOleAut32Module, "SysFreeString"); + pCoGetClassObject = HookProc(hOle32Module, "CoGetClassObject", CoGetClassObjectHook); + pCoCreateInstance = HookProc(hOle32Module, "CoCreateInstance", CoCreateInstanceHook); +} diff --git a/src/hooks/ole32/web_browser.h b/src/hooks/ole32/web_browser.h index dfd517c..1241610 100644 --- a/src/hooks/ole32/web_browser.h +++ b/src/hooks/ole32/web_browser.h @@ -1,5 +1,5 @@ -#pragma once - -#include "../../common.h" - +#pragma once + +#include "../../common.h" + void InitWebBrowserHook(); \ No newline at end of file diff --git a/src/hooks/wininet/netredir.c b/src/hooks/wininet/netredir.c index 63fbc65..06f8b95 100644 --- a/src/hooks/wininet/netredir.c +++ b/src/hooks/wininet/netredir.c @@ -689,7 +689,7 @@ BOOL STDCALL HttpSendRequestACertificateInvalidRedirect(HINTERNET hRequest, LPCS DWORD dwHeadersLength, LPVOID lpOptional, DWORD dwOptionalLength) { - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); if (inet_ctx == NULL) return FALSE; @@ -701,8 +701,8 @@ BOOL STDCALL HttpSendRequestACertificateInvalidRedirect(HINTERNET hRequest, LPCS DWORD statusCode = 0; DWORD dwStatusCodeLength = sizeof(statusCode); ret2 = pHttpQueryInfoA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), - HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, - &statusCode, &dwStatusCodeLength, NULL); + HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &statusCode, + &dwStatusCodeLength, NULL); if (ret2 == FALSE) { Log("HttpQueryInfoA(1). failed Error: %d\r\n", LastErr()); return FALSE; @@ -815,9 +815,8 @@ BOOL STDCALL HttpSendRequestACertificateInvalidRedirect(HINTERNET hRequest, LPCS url_cpsa.dwHostNameLength + PortLength(url_cpsa.nPort)); inet_ctx->hNewRequest = pHttpOpenRequestA( - inet_ctx->hNewConnect, inet_ctx->lpszMethod, - lpszNewObjectName, HTTP_VERSIONA, NULL, - inet_ctx->rgpszAcceptTypes, newFlags, inet_ctx->dwContext); + inet_ctx->hNewConnect, inet_ctx->lpszMethod, lpszNewObjectName, HTTP_VERSIONA, NULL, + inet_ctx->rgpszAcceptTypes, newFlags, inet_ctx->dwContext); if (url != NULL) FreeMem((HLOCAL)url); @@ -888,8 +887,8 @@ BOOL STDCALL HttpSendRequestACertificateInvalidRedirect(HINTERNET hRequest, LPCS (Config.bBypassSelfSignedCertificate == TRUE && (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { - ret2 = HttpSendRequestACertificateInvalidRedirect(hRequest, lpszHeaders, dwHeadersLength, - lpOptional, dwOptionalLength); + ret2 = HttpSendRequestACertificateInvalidRedirect( + hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); } else Log("HttpSendRequestA(2). failed Error: %d\r\n", error); @@ -908,30 +907,30 @@ BOOL STDCALL HttpSendRequestAHook(HINTERNET hRequest, LPCSTR lpszHeaders, DWORD BOOL bRet = FALSE; - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - if (inet_ctx == NULL) - bRet = pHttpSendRequestA(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); - else { + if (inet_ctx == NULL) + bRet = + pHttpSendRequestA(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); + else { - bRet = pHttpSendRequestA( - (inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), lpszHeaders, - dwHeadersLength, lpOptional, dwOptionalLength); + bRet = pHttpSendRequestA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), + lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); - if (bRet == TRUE) - return bRet; + if (bRet == TRUE) + return bRet; - DWORD error = LastErr(); + DWORD error = LastErr(); - if (error == ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION || - (Config.bBypassSelfSignedCertificate == TRUE && - (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || - error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { + if (error == ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION || + (Config.bBypassSelfSignedCertificate == TRUE && + (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || + error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { - bRet = HttpSendRequestACertificateInvalidRedirect( - hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); - } - } + bRet = HttpSendRequestACertificateInvalidRedirect( + hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength); + } + } return bRet; } @@ -941,22 +940,22 @@ BOOL STDCALL HttpSendRequestExAHook(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBu DWORD_PTR dwContext) { BOOL bRet = FALSE; - - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - if (inet_ctx == NULL) - bRet = pHttpSendRequestExA(hRequest, lpBuffersIn, lpBuffersOut, dwFlags, dwContext); - else { + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - bRet = pHttpSendRequestExA( - (inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), lpBuffersIn, - lpBuffersOut, dwFlags, dwContext); + if (inet_ctx == NULL) + bRet = pHttpSendRequestExA(hRequest, lpBuffersIn, lpBuffersOut, dwFlags, dwContext); + else { + + bRet = + pHttpSendRequestExA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), + lpBuffersIn, lpBuffersOut, dwFlags, dwContext); - if (bRet == FALSE) - return bRet; + if (bRet == FALSE) + return bRet; - inet_ctx->lpBuffersIn = lpBuffersIn; - } + inet_ctx->lpBuffersIn = lpBuffersIn; + } return bRet; } @@ -965,7 +964,7 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext) { - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); if (inet_ctx == NULL) return FALSE; @@ -977,8 +976,8 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, DWORD statusCode = 0; DWORD dwStatusCodeLength = sizeof(statusCode); ret2 = pHttpQueryInfoA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), - HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, - &statusCode, &dwStatusCodeLength, NULL); + HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &statusCode, + &dwStatusCodeLength, NULL); if (ret2 == FALSE) { Log("HttpQueryInfoA(1). failed Error: %d\r\n", LastErr()); return FALSE; @@ -1064,7 +1063,7 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, } inet_ctx->hNewConnect = pInternetConnectA(inet_ctx->hOpen, lpszHostName, url_cpsa.nPort, NULL, - NULL, INTERNET_SERVICE_HTTP, dwFlags, dwContext); + NULL, INTERNET_SERVICE_HTTP, dwFlags, dwContext); if (lpszHostName != NULL) FreeMem((HLOCAL)lpszHostName); @@ -1091,8 +1090,7 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, inet_ctx->hNewRequest = pHttpOpenRequestA(inet_ctx->hNewConnect, inet_ctx->lpszMethod, lpszNewObjectName, - HTTP_VERSIONA, NULL, - inet_ctx->rgpszAcceptTypes, newFlags, dwContext); + HTTP_VERSIONA, NULL, inet_ctx->rgpszAcceptTypes, newFlags, dwContext); if (url != NULL) FreeMem((HLOCAL)url); @@ -1168,8 +1166,7 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, DWORD dwNumbetOfBytesWritten = 0; ret2 = pInternetWriteFile(inet_ctx->hNewRequest, inet_ctx->lpFileBuffer, - inet_ctx->dwNumberOfBytesToWrite, - &dwNumbetOfBytesWritten); + inet_ctx->dwNumberOfBytesToWrite, &dwNumbetOfBytesWritten); if (ret2 == FALSE && LastErr() != ERROR_INSUFFICIENT_BUFFER) { Log("InternetWriteFile. failed Error: %d\r\n", LastErr()); @@ -1190,8 +1187,8 @@ BOOL STDCALL HttpEndRequestACertificateInvalidRedirect(HINTERNET hRequest, (Config.bBypassSelfSignedCertificate == TRUE && (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { - ret2 = - HttpEndRequestACertificateInvalidRedirect(hRequest, lpBuffersOut, dwFlags, dwContext); + ret2 = HttpEndRequestACertificateInvalidRedirect(hRequest, lpBuffersOut, dwFlags, + dwContext); } else Log("HttpEndRequestA(2). failed Error: %d\r\n", error); @@ -1209,31 +1206,30 @@ BOOL STDCALL HttpEndRequestAHook(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffe DWORD dwFlags, DWORD_PTR dwContext) { BOOL bRet = FALSE; - - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - if (inet_ctx == NULL) - bRet = pHttpEndRequestA(hRequest, lpBuffersOut, dwFlags, dwContext); - else { + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + + if (inet_ctx == NULL) + bRet = pHttpEndRequestA(hRequest, lpBuffersOut, dwFlags, dwContext); + else { - bRet = - pHttpEndRequestA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), - lpBuffersOut, dwFlags, dwContext); + bRet = pHttpEndRequestA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), + lpBuffersOut, dwFlags, dwContext); - if (bRet == TRUE) - return bRet; + if (bRet == TRUE) + return bRet; - DWORD error = LastErr(); + DWORD error = LastErr(); - if (error == ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION || - (Config.bBypassSelfSignedCertificate == TRUE && - (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || - error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { + if (error == ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION || + (Config.bBypassSelfSignedCertificate == TRUE && + (error == ERROR_INTERNET_SEC_CERT_DATE_INVALID || + error == ERROR_INTERNET_SEC_CERT_CN_INVALID || error == ERROR_INTERNET_INVALID_CA))) { - bRet = HttpEndRequestACertificateInvalidRedirect(hRequest, lpBuffersOut, - dwFlags, dwContext); - } - } + bRet = HttpEndRequestACertificateInvalidRedirect(hRequest, lpBuffersOut, dwFlags, + dwContext); + } + } return bRet; } @@ -1242,26 +1238,26 @@ BOOL STDCALL HttpAddRequestHeadersAHook(HINTERNET hRequest, LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwModifiers) { BOOL bRet = FALSE; - - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - if (inet_ctx == NULL) - bRet = pHttpAddRequestHeadersA(hRequest, lpszHeaders, dwHeadersLength, dwModifiers); - else { + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + + if (inet_ctx == NULL) + bRet = pHttpAddRequestHeadersA(hRequest, lpszHeaders, dwHeadersLength, dwModifiers); + else { - bRet = pHttpAddRequestHeadersA( - (inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), lpszHeaders, - dwHeadersLength, dwModifiers); + bRet = pHttpAddRequestHeadersA( + (inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), lpszHeaders, + dwHeadersLength, dwModifiers); - if (bRet == FALSE || inet_ctx->nHeaders >= MAX_HTTP_HEADER) - return bRet; + if (bRet == FALSE || inet_ctx->nHeaders >= MAX_HTTP_HEADER) + return bRet; - http_header *pHeader = &inet_ctx->vHeaders[inet_ctx->nHeaders++]; + http_header *pHeader = &inet_ctx->vHeaders[inet_ctx->nHeaders++]; - pHeader->lpszHeaders = lpszHeaders; - pHeader->dwHeaderLength = dwHeadersLength; - pHeader->dwModifiers = dwModifiers; - } + pHeader->lpszHeaders = lpszHeaders; + pHeader->dwHeaderLength = dwHeadersLength; + pHeader->dwModifiers = dwModifiers; + } return bRet; } @@ -1271,14 +1267,13 @@ BOOL STDCALL HttpQueryInfoAHook(HINTERNET hRequest, DWORD dwInfoLevel, LPVOID lp BOOL bRet = FALSE; - internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); + internet_ctx *inet_ctx = findInetCtxByRequest(hRequest); - if (inet_ctx == NULL) + if (inet_ctx == NULL) bRet = pHttpQueryInfoA(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex); else - bRet = - pHttpQueryInfoA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), - dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex); + bRet = pHttpQueryInfoA((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hRequest), + dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex); return bRet; } @@ -1288,11 +1283,10 @@ BOOL STDCALL InternetQueryDataAvailableHook(HINTERNET hFile, LPDWORD lpdwNumberO BOOL bRet = FALSE; - internet_ctx *inet_ctx = findInetCtxByRequest(hFile); + internet_ctx *inet_ctx = findInetCtxByRequest(hFile); - if (inet_ctx == NULL) - bRet = - pInternetQueryDataAvailable(hFile, lpdwNumberOfBytesAvailable, dwFlags, dwContext); + if (inet_ctx == NULL) + bRet = pInternetQueryDataAvailable(hFile, lpdwNumberOfBytesAvailable, dwFlags, dwContext); else bRet = pInternetQueryDataAvailable( (inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hFile), @@ -1306,21 +1300,22 @@ BOOL STDCALL InternetWriteFileHook(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNu BOOL bRet = FALSE; - internet_ctx *inet_ctx = findInetCtxByRequest(hFile); + internet_ctx *inet_ctx = findInetCtxByRequest(hFile); - if (inet_ctx == NULL) - bRet = pInternetWriteFile(hFile, lpBuffer, dwNumberOfBytesToWrite, lpdwNumberOfBytesWritten); - else { + if (inet_ctx == NULL) bRet = - pInternetWriteFile((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hFile), - lpBuffer, dwNumberOfBytesToWrite, lpdwNumberOfBytesWritten); + pInternetWriteFile(hFile, lpBuffer, dwNumberOfBytesToWrite, lpdwNumberOfBytesWritten); + else { + bRet = pInternetWriteFile((inet_ctx->hNewRequest != NULL ? inet_ctx->hNewRequest : hFile), + lpBuffer, dwNumberOfBytesToWrite, lpdwNumberOfBytesWritten); - if (bRet == FALSE || (inet_ctx->lpFileBuffer != NULL && inet_ctx->dwNumberOfBytesToWrite > 0u)) - return bRet; + if (bRet == FALSE || + (inet_ctx->lpFileBuffer != NULL && inet_ctx->dwNumberOfBytesToWrite > 0u)) + return bRet; - inet_ctx->lpFileBuffer = lpBuffer; - inet_ctx->dwNumberOfBytesToWrite = dwNumberOfBytesToWrite; - } + inet_ctx->lpFileBuffer = lpBuffer; + inet_ctx->dwNumberOfBytesToWrite = dwNumberOfBytesToWrite; + } return bRet; } @@ -1372,7 +1367,7 @@ VOID InitNetRedirHook() { pHttpEndRequestA = HookProc(hWinINet, "HttpEndRequestA", HttpEndRequestAHook); pHttpAddRequestHeadersA = HookProc(hWinINet, "HttpAddRequestHeadersA", HttpAddRequestHeadersAHook); - pHttpQueryInfoA = HookProc(hWinINet, "HttpQueryInfoA", HttpQueryInfoAHook); + pHttpQueryInfoA = HookProc(hWinINet, "HttpQueryInfoA", HttpQueryInfoAHook); pHttpSendRequestExA = HookProc(hWinINet, "HttpSendRequestExA", HttpSendRequestExAHook); pInternetCloseHandle = HookProc(hWinINet, "InternetCloseHandle", InternetCloseHandleHook); pInternetQueryDataAvailable =