Click here to Skip to main content
15,909,242 members
Home / Discussions / COM
   

COM

 
GeneralRe: adding visual studio 6 dll to c# app Pin
stonewall_20001-Jul-05 0:08
stonewall_20001-Jul-05 0:08 
General7000vDatabase COM Threads Pin
FJK28-Jun-05 19:25
FJK28-Jun-05 19:25 
GeneralRe: 7000vDatabase COM Threads Pin
rwestgraham1-Jul-05 17:01
rwestgraham1-Jul-05 17:01 
GeneralRe: 7000vDatabase COM Threads Pin
FJK3-Jul-05 18:45
FJK3-Jul-05 18:45 
GeneralXMLDOMDocument across processes Pin
Alex_Y28-Jun-05 6:28
Alex_Y28-Jun-05 6:28 
GeneralRe: XMLDOMDocument across processes Pin
Alex_Y28-Jun-05 9:23
Alex_Y28-Jun-05 9:23 
GeneralRe: XMLDOMDocument across processes Pin
Lim Bio Liong28-Jun-05 14:27
Lim Bio Liong28-Jun-05 14:27 
GeneralBrowser Helper Object - replace HTML page Pin
Tomek.Sergey28-Jun-05 3:04
Tomek.Sergey28-Jun-05 3:04 
Hi!
I have to develop BHO that would enable me to replace HTML page that was downloaded by user into another HTML page (say, to the same but with some tags deleted etc). I decided to use ATL, have read some docs, and here is the problem. In Invoke on dispidMember==DISPID_DOWNLOADCOMPLETE I call OnDocumentComplete :

Code:
<br />
HRESULT CSuperHook::OnDocumentComplete(){<br />
  USES_CONVERSION;<br />
  CComPtr<IDispatch> pDisp;<br />
  HRESULT hr=m_spBrowser->get_Document(&pDisp);<br />
  CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> pHTML;<br />
  pHTML=pDisp;<br />
  if (pHTML){<br />
      hr=pHTML->get_body(&m_body);<br />
      if (FAILED(hr))<br />
          return hr;    <br />
        BSTR strHTML; <br />
      hr=m_body->get_innerHTML(&strHTML); // html page is returned<br />
      hr=Parse(&strHTML,_T("<TR>"),_T("<a href='http://www.codeguru.com/'>Codeguru.com</a>")); // HTML code parsing routine (look below)<br />
      <br />
      hr=m_body->put_innerHTML(strHTML); // changed HTML page is written      <br />
      ::SysFreeString(strHTML);<br />
  }<br />
  return S_OK; <br />
}<br />


Function Parse take source HTML page, replacing text and replaced text as params:

Code:
<br />
HRESULT CSuperHook::Parse(BSTR *source,LPTSTR strSearch,LPTSTR strReplace){  <br />
   USES_CONVERSION;<br />
   int strSourceLen=SysStringLen(*source);<br />
   int strSearchLen=_tcslen(strSearch);<br />
   int strReplaceLen=_tcslen(strReplace);<br />
   LPTSTR strSource = new TCHAR[strSourceLen+1]; <br />
   LPTSTR strNew = new TCHAR[strSourceLen+4000]; <br />
   <br />
   _tcscpy(strSource, OLE2T(*source));<br />
   LPTSTR token,pPrevPos=strSource;<br />
   int posSource=0,posNew=0;<br />
   while ((token=_tcsstr(strSource+posSource,strSearch))!=NULL){     <br />
     _tcsncpy(strNew+posNew,strSource+posSource,token-pPrevPos);<br />
     posSource+=token-pPrevPos+strSearchLen;     <br />
     posNew+=token-pPrevPos;<br />
     _tcsncpy(strNew+posNew,strReplace,strReplaceLen);          <br />
     pPrevPos=token+strSearchLen;<br />
     posNew+=strReplaceLen;     <br />
   }<br />
   token=strSource+_tcslen(strSource);<br />
   _tcsncpy(strNew+posNew,strSource+posSource,token-pPrevPos);<br />
   posNew+=token-pPrevPos;<br />
   strNew[posNew]='\0';<br />
   <br />
   ::SysFreeString(*source);   <br />
   *source=::SysAllocString(T2OLE(strNew));      <br />
   delete [] strSource;<br />
   delete [] strNew;<br />
   return S_OK;   <br />
}<br />


So, now on page load in IE (after the load is over) in a browser window in some places (where there must have been "" tag) we can see the link named "codeguru.com". Clicking on it, we redirect to codeguru.com... It seems as if everithing is right, but source HTML code (IE main menu->Tools->Source) have not been changed ! Why ?
Now, I begin to refresh the page, and after two or three refreshs I have buffer overflow (my firewall says that DEVENV.EXE tries to write something to IE address space). Then an error occures in module strcat.asm....
I cannot understand why does it happen, it seems I free all allocated memory !!!
And maybe somebody knows the way to do this task easer or maybe somebody has some workarounds on subj ?

Thanx for attention !
Generalenum in COM Pin
Logan from Singapore26-Jun-05 22:31
Logan from Singapore26-Jun-05 22:31 
GeneralRe: enum in COM Pin
GuimaSun27-Jun-05 5:42
GuimaSun27-Jun-05 5:42 
GeneralInternet Explorer hooks Pin
Ryan333326-Jun-05 9:52
Ryan333326-Jun-05 9:52 
GeneralWebBrowser Control used as a FileManager Pin
intripoon26-Jun-05 8:39
intripoon26-Jun-05 8:39 
GeneralRe: WebBrowser Control used as a FileManager Pin
intripoon27-Jun-05 5:43
intripoon27-Jun-05 5:43 
GeneralShell extension. Pin
Member 134788323-Jun-05 15:30
Member 134788323-Jun-05 15:30 
GeneralRe: Shell extension. Pin
chenfred29-Jun-05 5:22
chenfred29-Jun-05 5:22 
GeneralTimer with Windowless Control Pin
Shraddhan23-Jun-05 12:42
Shraddhan23-Jun-05 12:42 
GeneralRe: Timer with Windowless Control Pin
Jörgen Sigvardsson26-Jun-05 6:04
Jörgen Sigvardsson26-Jun-05 6:04 
GeneralRe: Timer with Windowless Control Pin
Shraddhan26-Jun-05 12:57
Shraddhan26-Jun-05 12:57 
GeneralRe: Timer with Windowless Control Pin
Jörgen Sigvardsson27-Jun-05 10:18
Jörgen Sigvardsson27-Jun-05 10:18 
Generalchar** to VARIANT Pin
bvais23-Jun-05 11:01
sussbvais23-Jun-05 11:01 
GeneralRe: char** to VARIANT Pin
Lim Bio Liong23-Jun-05 15:12
Lim Bio Liong23-Jun-05 15:12 
GeneralRe: char** to VARIANT Pin
bvais23-Jun-05 18:23
sussbvais23-Jun-05 18:23 
GeneralRe: char** to VARIANT Pin
GuimaSun24-Jun-05 9:26
GuimaSun24-Jun-05 9:26 
GeneralRe: char** to VARIANT Pin
Lim Bio Liong24-Jun-05 23:54
Lim Bio Liong24-Jun-05 23:54 
GeneralRe: char** to VARIANT Pin
Jörgen Sigvardsson25-Jun-05 13:44
Jörgen Sigvardsson25-Jun-05 13:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.