kenn Posted February 26, 2006 Share Posted February 26, 2006 ;read root node text of AutoIt Help file treeview control ;define constants dim $TVM_GETNEXTITEM = 0x110a, $TVGN_ROOT = 0, $TVM_GETITEM = 0x110c, $TVE_TOGGLE = 3, $TVM_EXPAND = 0x1102, $TVIF_TEXT = 1 ;get handle of AutoIt Help File window $h_AutoItHelpWin = WinGetHandle('AutoIt Help') ;get handle of treeview control $h_treeview = ControlGetHandle($h_AutoItHelpWin, '', 'SysTreeView321') ;get handle of root node $h_item = SendMessage($h_treeview, $TVM_GETNEXTITEM, $TVGN_ROOT, 0) ;all handles obtained above are correct since the next statement ; collapses or expands the root node SendMessage($h_treeview, $TVM_EXPAND, $TVE_TOGGLE, $h_item) ;make struct to store root node text $text = DllStructCreate('char[260]') ;make struct required by TVM_GETITEM $tv_item = DllStructCreate('int[10]') DllStructSetData($tv_item, 1, $TVIF_TEXT, 1) DllStructSetData($tv_item, 1, $h_item, 2) DllStructSetData($tv_item, 1, DllStructGetPtr($text), 5) DllStructSetData($tv_item, 1, 260, 6) ;try to get root node text ;this is where program crashes with message: ;Hh This program has performed an illegal operation and will be ; shut down SendMessage($h_treeview, $TVM_GETITEM, 0, DllStructGetPtr($tv_item)) MsgBox(0, DllStructGetData($text, 1), '') func SendMessage($hwnd, $uMsg, $wParam, $lParam) local $result = DllCall('user32.dll', 'int', 'SendMessage', 'int', $hwnd, 'int', $uMsg, 'int', $wParam, 'int', $lParam) return $result[0] endfunc Link to comment Share on other sites More sharing options...
cppman Posted February 26, 2006 Share Posted February 26, 2006 um... whats the problem? Miva OS Project Link to comment Share on other sites More sharing options...
kenn Posted February 26, 2006 Author Share Posted February 26, 2006 um... whats the problem?HH.exe (the program that displays .chm files) crashes at the point where TVM_GETITEM is used, at least on my win98 computer it crashes! Doesn't it crash on your computer? Link to comment Share on other sites More sharing options...
cppman Posted February 26, 2006 Share Posted February 26, 2006 It does'nt even open on my computer... i don't have win98, i have xp. Miva OS Project Link to comment Share on other sites More sharing options...
kenn Posted February 27, 2006 Author Share Posted February 27, 2006 It does'nt even open on my computer... i don't have win98, i have xp.AutoIt3.chm must be open BEFORE you run the program; I guess I wasn't clear about that! Link to comment Share on other sites More sharing options...
kenn Posted February 27, 2006 Author Share Posted February 27, 2006 ;Read root node text from AutoIt Help File (non-rigorous, proof of concept example) ;define constants dim $TV_FIRST = 0x1100, $TVM_GETNEXTITEM = $TV_FIRST + 10, $TVGN_ROOT = 0, $TVM_GETITEM = $TV_FIRST + 12, $TVIF_TEXT = 1, $process_All_Access = 0x001f0fff ;get handle of AutoIt Help File window $h_AutoItHelpWin = WinGetHandle('AutoIt Help') if $h_AutoItHelpWin = '' then MsgBox(16, 'AutoIt Help must be running!', '') exit endif ;get handle of treeview control $h_treeview = ControlGetHandle($h_AutoItHelpWin, '', 'SysTreeView321') ;get handle of root node $h_item = SendMessage($h_treeview, $TVM_GETNEXTITEM, $TVGN_ROOT, 0) ;get handle of AutoIt Help process $hproc = DllCall('kernel32.dll', 'int', 'OpenProcess', 'int', $process_All_Access, 'int', 0, 'int', WinGetProcess('AutoIt Help')) $hproc = $hproc[0] ;create structure required by TVM_GETITEM $tvitem = DllStructCreate('int[6]') DllStructSetData($tvitem, 1, $TVIF_TEXT, 1) DllStructSetData($tvitem, 1, $h_item, 2) DllStructSetData($tvitem, 1, 0x1000000 + 0x3d + 24, 5) DllStructSetData($tvitem, 1, 0xd8 - 0x3d - 24, 6) ;copy $tvitem structure into AutoIt Help address space!!! ;This is what was missing before WriteProcessMemory(0x1000000 + 0x3d, DllStructGetPtr($tvitem), 24) ;get root node text SendMessage($h_treeview, $TVM_GETITEM, 0, 0x1000000 + 0x3d) $text = DllStructCreate('char[' & 0xd8 - 0x3d - 24 & ']') ReadProcessMemory(0x1000000 + 0x3d + 24, DllStructGetPtr($text), 0xd8 - 0x3d - 24) MsgBox(48, DllStructGetData($text, 1), '') exit func ReadProcessMemory($ad, $toAd, $cnt) DllCall('kernel32.dll', 'int', 'ReadProcessMemory', 'int', $hproc, 'int', $ad, 'int', $toAd, 'int', $cnt, 'int', 0) endfunc func WriteProcessMemory($ad, $fromAd, $cnt) DllCall('kernel32.dll', 'int', 'WriteProcessMemory', 'int', $hproc, 'int', $ad, 'int', $fromAd, 'int', $cnt, 'int', 0) endfunc func SendMessage($hwnd, $uMsg, $wParam, $lParam) local $result = DllCall('user32.dll', 'int', 'SendMessage', 'int', $hwnd, 'int', $uMsg, 'int', $wParam, 'int', $lParam) return $result[0] endfunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now