|
101
|
Programación / .NET (C#, VB.NET, ASP) / Re: Obtener Informacion acerca del modulo correspondiente al StartAdress del Thread.
|
en: 18 Junio 2022, 19:43 pm
|
Que demonios!! Funciona.  Gracias por tomarte el tiempo en esto .
Ayer lo logre de esta manera, Primero me descargue el codigo del ProcessHacker y me puse a analizarlo. Al final, tome todo el proyecto del PH y lo puse en 1 API : https://github.com/DestroyerDarkNess/Xylon.PH , Despues facilmente use el codigo del PH al final asi quedo : https://github.com/DestroyerDarkNess/ProcessThreadInfo Private WithEvents _threadP As ThreadProvider = Nothing Private Sub buttonWalk_Click(sender As Object, e As EventArgs) Handles buttonWalk.Click Dim processEx As Process = System.Diagnostics.Process.GetProcessById(TextBox1.Text) listViewCallStack.Items.Clear() _threadP = New ThreadProvider(processEx.Id) _threadP.LoadKernelSymbols() _threadP.Run() End Sub Private Sub _threadP_BeforeUpdate() Handles _threadP.BeforeUpdate listViewCallStack.Items.Clear() End Sub Private Sub _threadP_ResolveSybol(sender As Object, e As ThreadProvider.ResolveSybolData) Handles _threadP.ResolveSybol Me.BeginInvoke(Sub() Debug. WriteLine("TID: " & e. TID & " StartAdress: " & e. ResolveInfo. Symbol) Dim ItemN As New ListViewItem ItemN.Text = e.TID ItemN.SubItems.Add(e.ResolveInfo.Symbol) listViewCallStack.Items.Add(ItemN) End Sub) End Sub Private Sub _threadP_Error(ex As Exception) Handles _threadP.[Error] MsgBox(ex.Message) End Sub
Bueno espero que este post ayude a alguien mas que pase por esta duda. Gracias @RayR
|
|
|
103
|
Programación / .NET (C#, VB.NET, ASP) / Re: Obtener Informacion acerca del modulo correspondiente al StartAdress del Thread.
|
en: 15 Junio 2022, 23:26 pm
|
Hola, De tanto buscar encontre este codigo Fuente : https://github.com/itsmeny/Process_Thread_Info basicamente todo lo que necesito pero , hay un pequeño detalle , no funciona, o al menos a mi no me funciona, el error esta en la funcion del dbghelp SymFromAddr . No se si son los parametros correctos , de verdad no se por que me da el error. Coloco la funcion importante : public static String GetThreadStartAddress(IntPtr hProc, uint threadId) { IntPtr hThread = IntPtr.Zero; GCHandle handle = default(GCHandle); try { hThread = DbgHelpNative.OpenThread(DbgHelpNative.ThreadAccess.QUERY_INFORMATION, false, threadId); if (hThread == IntPtr.Zero) { throw new Win32Exception ("OpenThread failed"); } var threadAddress = new IntPtr [1]; handle = GCHandle.Alloc(threadAddress, GCHandleType.Pinned); var result = NtQueryInformationThread(hThread, ThreadInfomationClass.threadquerysetwin32startaddress, handle.AddrOfPinnedObject(), IntPtr.Size, IntPtr.Zero); if (result != 0) { throw new Win32Exception (string.Format("NtQueryInformationThread failed; NTSTATUS = {0:X8}", result )); } DbgHelpNative.SymSetOptions(DbgHelpNative.Options.SYMOPT_UNDNAME | DbgHelpNative.Options.SYMOPT_DEFERRED_LOADS); if (!DbgHelpNative.SymInitialize(hProc, null, true)) { throw new Win32Exception ("SymInitialize failed"); } DbgHelpNative .SYMBOL_INFO symbolInfo = new DbgHelpNative .SYMBOL_INFO(); symbolInfo .SizeOfStruct = (uint)Marshal .SizeOf(typeof(DbgHelpNative .SYMBOL_INFO)) - 1024; symbolInfo.MaxNameLen = 1024; ulong displacement; if (!DbgHelpNative.SymFromAddr(hProc, (ulong)threadAddress[0], out displacement, ref symbolInfo)) { throw new Win32Exception ("SymFromAddr failed"); } return symbolInfo.Name; //return threadAddress[0]; } finally { if (hThread != IntPtr.Zero) { DbgHelpNative.CloseHandle(hThread); } if (handle.IsAllocated) { handle.Free(); } } }
Falla justo aqui : if (!DbgHelpNative.SymFromAddr(hProc, (ulong)threadAddress[0], out displacement, ref symbolInfo)) { throw new Win32Exception ("SymFromAddr failed"); }
No se que podria estar mal, alguna Idea ?
|
|
|
104
|
Programación / .NET (C#, VB.NET, ASP) / Re: Obtener Informacion acerca del modulo correspondiente al StartAdress del Thread.
|
en: 14 Junio 2022, 00:59 am
|
Más o menos, aunque la función devuelve un simple entero, y alguno de los parámetros no es del todo exacto. En C# sería algo así: [DllImport("ntdll.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern int NtQueryInformationThread(IntPtr ThreadHandle, ThreadInfoClass ThreadInformationClass, IntPtr ThreadInformation, int ThreadInformationLength, IntPtr ReturnLength);
Para conseguir el StartAddress no importa si el enum está incompleto, ya que el único valor que necesitas es 9 (ThreadQuerySetWin32StartAddress). Por lo demás, y aunque no lo he probado, no veo por qué no habría de funcionar. Ya lo hice, pero para nada, esto obtiene el StartAdress. Lo mismo que yo obtengo en el codigo que puse al principio. Pero no obtiene El startAdress en la forma que quiero, (ModuleName+Offset adress)
como por ejemplo : CodeSmart.exe+0xb426eeSigo necesitando ayuda. se agradece cualquier sugerencia.
|
|
|
105
|
Programación / .NET (C#, VB.NET, ASP) / Re: Obtener Informacion acerca del modulo correspondiente al StartAdress del Thread.
|
en: 9 Junio 2022, 01:32 am
|
Si , exactamente lo estaba haciendo asi, hasta que no pude encontrar el equivalente a NtQueryInformationThread en .net. basado en lo que busque de c++ , el pinvoke deberia ser asi : <DllImport("ntdll.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> Public Shared Function NtQueryInformationThread(ByVal ThreadHandle As IntPtr, ByVal ThreadInformationClass As ThreadInfoClass, ByRef ThreadInformation As IntPtr, ByVal ThreadInformationLength As IntPtr, ByVal ReturnLength As IntPtr) As IntPtr End Function Public Enum ThreadInfoClass ThreadBasicInformation ThreadTimes ThreadPriority ThreadBasePriority ThreadAffinityMask ThreadImpersonationToken ThreadDescriptorTableEntry ThreadEnableAlignmentFaultFixup ThreadEventPair_Reusable ThreadQuerySetWin32StartAddress ThreadZeroTlsCell ThreadPerformanceCount ThreadAmILastThread ThreadIdealProcessor ThreadPriorityBoost ThreadSetTlsArrayAddress ThreadIsIoPending ThreadHideFromDebugger MaxThreadInfoClass End Enum
'Deberia' , esto lo hice basado en la documentacion de c++ , y el ThreadInfoClass me parece que esta incompleto. si funciona , es un milagro. Elektro se te estraña ...
|
|
|
106
|
Programación / .NET (C#, VB.NET, ASP) / Obtener Informacion acerca del modulo correspondiente al StartAdress del Thread.
|
en: 8 Junio 2022, 19:13 pm
|
Hola, tengo una duda que no he resuelto todavia. y es como obtener esta info :
Bien, Por mi cuenta he podido obtener, esos campos, pero en el campo StartAdress , no se como obtener ese tipo de informacion (Modulename + Adress) . Esto es lo que tengo hasta ahora : Dim processEx As Process = System.Diagnostics.Process.GetProcessById(4080) For Each pT As ProcessThread In processEx.Threads Dim TID As IntPtr = pT.Id Dim StarAdress As IntPtr = pT.StartAddress ' aqui , por lo que investigue , se tiene que buscar la informacion de los simbolos o algo asi ' Usando la API dbghelp.dll ' Pero no hacer como hacerlo , tambien lei sobre otras cosas. como por ejemplo NtQueryInformationThread o algo asi Next
Como ven la informacion que obtengo de StartAdress, es del tipo intptr . no string . Esta es la informacion que he encontrado hasta ahora : Getting module name from thread informationHow to retrieve starting address of a thread in windows? Pero no entiendo ni pito. Ayudaa.... Gracias de antemano.
|
|
|
107
|
Programación / Desarrollo Web / Formatear texto de attribute style
|
en: 27 Mayo 2022, 01:35 am
|
Sere directo, Como obtengo la URL que esta en el atributo syle ? <i class="img _1-yc profpic" aria-label="Salvador Osvaldo, profile picture" role="img" style="background:#d8dce6 url('https\3a //scontent.fccs3-1.fna.fbcdn.net/v/t1.18169-1/29595233_969571103219620_8305830866261244835_n.jpg?stp\3d cp0_dst-jpg_e15_p130x130_q65\26 _nc_cat\3d 104\26 ccb\3d 1-7\26 _nc_sid\3d dbb9e7\26 efg\3d eyJpIjoidCJ9\26 _nc_ohc\3d 1dIsFQh3mkQAX8oTG8h\26 _nc_ht\3d scontent.fccs3-1.fna\26 oh\3d 00_AT92esrjGvAgYGVFpvL_HJrY2PDttjbn1-LyuPAQ4M2YLA\26 oe\3d 62B3ED5D') no-repeat center;background-size:100% 100%;-webkit-background-size:100% 100%;width:126px;height:126px"></i>
Tengo que decodificar o algo ? , que tengo q hacer? Gracias de antemano.
|
|
|
109
|
Programación / .NET (C#, VB.NET, ASP) / Re: C# no se puede convertir implícitamente el tipo 'int' en 'object[]'
|
en: 13 Mayo 2022, 18:05 pm
|
Hola necesito ayuda con algo un proyecto de C#, y es que la app me manda un error de que no se puede convertir implícitamente el tipo 'int' en 'object[]' lo interesante es que le doy a continuar y la app hace lo que yo quiero que haga osea funciona bien, basicamente es un error que sale para joder un poco xd, quiero que no salga más, necesito ayuda como hago que no me ponga eso y de hecho si hubiera alguna forma de que nunca salga un error de esos seria mucho mejor xd, incluso si la app tiene un error de verdad, que se crashee o que haga lo que haga pero que no ponga esos errores  En vb.net para la conversión de tipos usas : TryCast o Directcast , En C# debes usar (int) en tu variable .Mira aqui : https://www.geeksforgeeks.org/c-sharp-type-casting/#:~:text=Type%20conversion%20happens%20when%20we%20assign%20the%20value,long%20variable.%20The%20two%20data%20types%20are%20compatible.
|
|
|
|
|
|
|