Título: Caption De Un Label
Publicado por: ZiroViI en 23 Octubre 2012, 16:05 pm
Buenas Gente!! Tengo una Duda.. es Posible Capturar el Label.caption de una aplicacion creada en vb6 ...??
yo uso la api FindWindowEx para Enviar Pulsaciones a button y otra coass... pero no se como acceder con lo labels..
Muchas Gracias!!
Título: Re: Caption De Un Label
Publicado por: seba123neo en 23 Octubre 2012, 17:27 pm
los labels son controles llamados "windowless" no son ventanas, solo se pintan, y si tratas de enumerarlos con alguna api tampoco lo hace ya que no tienen Hwnd.
pero me acuerdo que hace mucho habia publicado algo donde se podian ver, no me aucerdo, si lo encuentro lo pongo.
PD: aca esta:
Handle de un Label (http://foro.elhacker.net/programacion_vb/handle_de_un_label-t238112.0.html)
saludos.
Título: Re: Caption De Un Label
Publicado por: ZiroViI en 23 Octubre 2012, 21:23 pm
Muchas GrAcias!! no lo pude hacer Andar :P y entiendo Nada de ese codigo xD Me Tira Error Despues de esta Liena ... va no tira erro en esa linea... perro hast ahi Es donde Sale El MsgBox... si lo pongo mas abajo Salta El error Run time... Public Sub GetFormLabels(hwnd As Long) Dim sClass As String Dim lRet As Long Dim pid As Long Dim lFormCaptionHeapAddress As Long Dim lpMem As Long Dim lLenMBI As Long Dim lBytesRead As Long Dim mbi As MEMORY_BASIC_INFORMATION 'Make sure we are working with a VB Form hWnd sClass = Space(256) lRet = GetClassName(hwnd, sClass, 255) sClass = Left(sClass, lRet) If Not sClass = "ThunderRT6FormDC" Then MsgBox "Solo funciona compilado a .exe", vbInformation Exit Sub End If 'Now get the internal heap address of the form caption. All that we need can be found in this heap (hopefully!) 'This is done with a little undocumented SendMessage magic lFormCaptionHeapAddress = SendMessage(hwnd, VBM_WINDOWTITLEADDR, ByVal 0&, ByVal 0&) 'Get a handle on the process with required access lRet = GetWindowThreadProcessId(hwnd, pid) If pid = 0 Then MsgBox "No se pudo obtener el PID", vbExclamation Exit Sub End If hProcess = OpenProcess(PROCESS_READ_WRITE_QUERY, False, pid) 'Get the Heap at the caption point lLenMBI = Len(mbi) lpMem = lFormCaptionHeapAddress mbi.AllocationBase = lpMem mbi.BaseAddress = lpMem lRet = VirtualQueryEx(hProcess, ByVal lpMem, mbi, lLenMBI) If lRet <> lLenMBI Then GoTo Finished 'Now go back and get the entire heap lBaseAddress = mbi.AllocationBase lpMem = lBaseAddress mbi.BaseAddress = lBaseAddress mbi.RegionSize = 0 lRet = VirtualQueryEx(hProcess, ByVal lpMem, mbi, lLenMBI) If lRet <> lLenMBI Then GoTo Finished
'A couple of sanity checks, just to be safe If Not ((mbi.lType = MEM_PRIVATE) And (mbi.State = MEM_COMMIT) And mbi.RegionSize > 0) Then MsgBox "Unexpected Heap Type, State, or Size." GoTo Finished End If 'Allocate a buffer and read it in ReDim abBuffer(mbi.AllocationBase To mbi.AllocationBase + mbi.RegionSize - 1) ReadProcessMemory hProcess, ByVal mbi.BaseAddress, abBuffer(LBound(abBuffer)), mbi.RegionSize, lBytesRead
'So far, so good. Things get messy from here. We have to 'do some manual parsing of the buffer to get what we are after. To 'make things easier, I'll will get every label on every form in the 'exe. Otherwise, you will need to first find the form that is 'reference the caption. Then find every label between it and the next 'form. MSGBOX " HASTA AK LEE " Dim iCnt As Integer Dim al() As Long 'Print all of the label captions If EnumVBObjectPtrs("VB.Label", 44, al) > 0 Then For iCnt = LBound(al) To UBound(al) MsgBox "Hit at: " & al(iCnt) + 44 & vbNewLine & "Object At: " & al(iCnt) & vbNewLine & "Texto Del Label: " & GetLabelCaption(al(iCnt)) & vbNewLine & "Nombre del Label: " & GetLabelName(al(iCnt)), vbInformation Next iCnt End If
Finished: CloseHandle hProcess abBuffer() = "" End Sub y desp tira un error... run-time error 9 : subscript out of eange
|