- This topic has 76 replies, 17 voices, and was last updated 1 year ago by attockonian.
-
AuthorPosts
-
November 29, 2014 at 6:21 am #186764ChikeMember
Sorry part of it is my fault, LVM_GETITEM call is a bit different, iItem need to be set.
to gext both text and imagemyItem.mask = LVIF_IMAGE or LVIF_TEXT myItem.iItem = i myItem.iSubItem = 0 ... myItem.pszText = pStrBufferMemory myItem.cchTextMax = StringBufferLength SendMessage(lstviewhwnd, LVM_GETITEM, 0, pMyItemMemory)
To get the image only you don’t need pStrBufferMemory.
Other things:
According to documentantion VirtualAllocEx need to be called with MEM_COMMIT or MEM_RESERVE.
You can save one call too VirtualAllocEx and one to VirtualFreeEx by allocation all tye memory needed at oncepMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem)+StringBufferLength, MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE) pStrBufferMemory = pMyItemMemory+Len(myItem) ... result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
November 29, 2014 at 9:13 am #186763saaminathanMemberHi Chike
Below is the updated code. It returns an empty string. What might be wrong?
Public Function GetSLVSelectedImageItem(ByVal lstviewhwnd As IntPtr) As String Dim result As Integer Dim myItem As LV_ITEMA Dim pHandle As Integer Dim pStrBufferMemory As Integer Dim pMyItemMemory As Integer Dim strBuffer() As Byte Dim index As Integer Dim tmpString As String = String.Empty Dim ProcessID As Integer Dim usernum, itemIndex As Integer Dim i As Short itemIndex = SendMessage(lstviewhwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED) usernum = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0, 0) '********************** 'init the string buffer '********************** ReDim strBuffer(StringBufferLength) '*********************************************************** 'open a handle to the process and allocate the string buffer '*********************************************************** Call GetWindowThreadProcessId(lstviewhwnd, ProcessID) pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID) pStrBufferMemory = VirtualAllocEx(pHandle, 0, StringBufferLength, MEM_COMMIT, PAGE_READWRITE) '************************************************************************************ 'initialize the local LV_ITEM structure 'The myItem.iSubItem member is set to the index of the column that is being retrieved '************************************************************************************ myItem.mask = LVIF_IMAGE Or LVIF_TEXT myItem.iItem = i myItem.iSubItem = 0 '********************************************************** 'write the structure into the remote process's memory space '********************************************************** pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem) + StringBufferLength, MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE) pStrBufferMemory = pMyItemMemory + Len(myItem) '************************************************************* '************************************************************* '************************************************************* ' i = itemIndex '************************************************************* 'send the get the item message and write back the memory space '************************************************************* myItem.pszText = pStrBufferMemory myItem.cchTextMax = StringBufferLength result = SendMessage(lstviewhwnd, LVM_GETITEM, 0, pMyItemMemory) ' result = SendMessage(lstviewhwnd, LVM_GETITEM, i, pMyItemMemory) result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), StringBufferLength, 0) result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) '************************************************** 'turn the byte array into a string and send it back '************************************************** For index = LBound(strBuffer) To UBound(strBuffer) If Chr(strBuffer(index)) = vbNullChar Then Exit For tmpString = tmpString & Chr(strBuffer(index)) Next index tmpString = Trim(tmpString) MsgBox(tmpString) '************************************************** 'deallocate the memory and close the process handle '************************************************** result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE) result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE) result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE) result = CloseHandle(pHandle) If Len(tmpString) > 0 Then GetSLVSelectedImageItem = tmpString Return tmpString End Function
November 29, 2014 at 12:58 pm #186762saaminathanMemberHi Chike,
I got it and have read the flags. Thank you very much.
November 29, 2014 at 2:36 pm #186761AdminAdministratorLol you right Chike we both locos ehheh Hey you guys keep working on this I will be putting a timer on the bot thanks 🙂
November 29, 2014 at 8:53 pm #186760ChikeMemberHi Chike
Below is the updated code. It returns an empty string. What might be wrong?A bit messy code eh?
The WriteProcessMemory was missing, duplicate unneeded call to VirtualAllocEx, i is not needed eitherPublic Function GetSLVSelectedImageItem(ByVal lstviewhwnd As IntPtr) As String Dim result As Integer Dim myItem As LV_ITEMA Dim pHandle As Integer Dim pStrBufferMemory As Integer Dim pMyItemMemory As Integer Dim strBuffer() As Byte Dim index As Integer Dim tmpString As String = String.Empty Dim ProcessID As Integer Dim usernum, itemIndex As Integer itemIndex = SendMessage(lstviewhwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED) usernum = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0, 0) ‘********************** ‘init the string buffer ‘********************** ReDim strBuffer(StringBufferLength) ‘*********************************************************** ‘open a handle to the process and allocate item and string buffer ‘*********************************************************** Call GetWindowThreadProcessId(lstviewhwnd, ProcessID) pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID) pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem) + StringBufferLength, MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE) pStrBufferMemory = pMyItemMemory + Len(myItem) ‘************************************************************************************ ‘initialize the local LV_ITEM structure ‘The myItem.iSubItem member is set to the index of the column that is being retrieved ‘************************************************************************************ myItem.mask = LVIF_IMAGE Or LVIF_TEXT myItem.iItem = itemIndex myItem.iSubItem = 0 myItem.pszText = pStrBufferMemory myItem.cchTextMax = StringBufferLength ‘********************************************************** ‘write the structure into the remote process’s memory space ‘********************************************************** result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) ‘************************************************************* ‘send the get the item message and write back the memory space ‘************************************************************* result = SendMessage(lstviewhwnd, LVM_GETITEM, 0, pMyItemMemory) result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), StringBufferLength, 0) result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) ‘************************************************** ‘turn the byte array into a string and send it back ‘************************************************** For index = LBound(strBuffer) To UBound(strBuffer) If Chr(strBuffer(index)) = vbNullChar Then Exit For tmpString = tmpString & Chr(strBuffer(index)) Next index tmpString = Trim(tmpString) MsgBox(tmpString) ‘************************************************** ‘deallocate the memory and close the process handle ‘************************************************** result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE) result = CloseHandle(pHandle) If Len(tmpString) > 0 Then GetSLVSelectedImageItem = tmpString Return tmpString End Function
November 30, 2014 at 12:35 pm #186759saaminathanMemberHi Chike and Loco
Thank you for all the assistance. I have completed the code to get the mic status. But I get the following exception and nothing resolves it. Please assist.
An unhandled exception of type ‘System.NullReferenceException’ occurred in Paltalk Bot.exe
Additional information: Object reference not set to an instance of an object.
Private Sub GetAllUserList()
Dim i As Integer
Dim NicArray() As String
‘Empty the listbox
ListBox28.Items.Clear()
‘Add nics to a listbox
Dim iHnd As IntPtr = mdlHnd.GetChild(ChatRoomClass, Me.CtrlRoomSelector1.RoomName, NicListID)
If iHnd <> IntPtr.Zero Then
NicArray = mdlSysListView.GetAllSLVItems(iHnd)
If NicArray.Length > 0 Then            <————- This is the line with the exception
For i = 0 To NicArray.Length – 1
ListBox28.Items.Add(NicArray(i))
Next
End If
End If
End SubNovember 30, 2014 at 4:28 pm #186758ChikeMemberNicArray must be Nothing, check mdlSysListView.GetAllSLVItems code.
You have a debugger, use it.November 30, 2014 at 5:49 pm #186757saaminathanMemberHi Chike
I checked the issue and resolved it.. Now everything working perfectly.
November 30, 2014 at 6:22 pm #186756ChikeMemberBTW you can simply ListBox28.Items.AddRange(NicArray) instead of looping and probably get rid of the if too
December 1, 2014 at 6:52 am #186755saaminathanMemberBTW you can simply ListBox28.Items.AddRange(NicArray) instead of looping and probably get rid of the if too
Hi Chike
Thank you for the tip. I have another query. How do i lower hand and how do i get the handle for lowerhand ?
Thank you
December 1, 2014 at 1:05 pm #186754ChikeMemberThere is no handle to lower hand. To lower hand or to reddot/unreddot etc. you need to select the nick send a WM_COMMAND, to the chat window I think. Bounce is more complicated because SendMessage is a blocking call and the bounce dialog need to be OKed, so PostMessage is used instead.
See what command does it, the code for reddot should be there or you can search the forum.
I once posted code(s) to find the commands at runtimeDecember 11, 2014 at 10:01 am #186753saaminathanMemberHi Chike
I have successfully opened a IM window but having difficulty in sending a auto IM message. Below is the code i have generated but ts doesnt send the IM. Please assist. Thank you
In below code, i select a list of names as playername and then open an IM window for their name .
playername = ListBox30.Items(ListBox30.SelectedIndex)
HighlightNic(playername)
PostMessage(FindWindow(mdlPalInfo.ChatRoomClass, CtrlRoomSelector1.RoomName), WM_COMMAND, mdlPalInfo.IMfromRoomCommand, 0)ChatRTB1.Text = gamemsg
imsentchat = GetChild(mdlPalInfo.ChatRoomClass, playername, mdlPalInfo.SendTextUD) <—–[[ The issue is here. The command doesnt get the IM window handle with the playername]]
SendPalTxt(imsentchat, ChatRTB1.Rtf)December 11, 2014 at 5:57 pm #186752ChikeMember@saamiyaar
There is nothing wrong with that line, have you tried to set a breakpoint at that line?
Do you still have the problem if the IM is already open?June 1, 2016 at 3:29 am #186751MytacismMemberCan I ask for the updated source code that has a trivia TIMER on it? Because this version has no trivia timer. Thank you my friend LOCO!
February 15, 2023 at 1:22 pm #199423attockonianMemberFor clarity this would work with the new paltalk (and not the classic one) since its Code VB vb 2010?
-
AuthorPosts
Related
- You must be logged in to reply to this topic.