Is it possible to check the strong name of a .NET application that is already running separately from your own application execution process?
EDIT: for clarification, a solution that does not require a hard coded path to the executing assembly would be the most ideal solution.
EDIT # 2: Is there a way to do this without using reflection?
Does this give you what you are looking for?
Process[] processlist = Process.GetProcesses(); foreach(Process theprocess in processlist) { string strongName = "N/A"; try { strongName = Assembly.ReflectionOnlyLoadFrom(theprocess.MainModule.FileName).FullName; } catch { // System process? } Console.WriteLine("Process: {0} ID: {1} Strong Name: {2}", theprocess.ProcessName, theprocess.Id, strongName); }
Without reflection:
, . , PE, .
:
public static bool IsStrongNamed(string assemblyPath) { try { Assembly a = Assembly.ReflectionOnlyLoadFrom(assemblyPath); byte[] publicKey = a.GetName().GetPublicKey(); return publicKey.Length > 0; } catch { return false; } } public static bool GetStrongName(string assemblyPath) { try { Assembly a = Assembly.ReflectionOnlyLoadFrom(assemblyPath); return a.FullName; } catch { return string.Empty; } }
, , - AssemblyName.
Process.GetProcesses().Where(p => p.ProcessName = nameUWant); //maybe single or default?
Process.Modules dll exes, . , , . ( name).
AssemblyName.GetAssemblyName().GetPublicKeyToken() != null
. ,
" " exe:
using System.Diagnostics; if (Process.GetProcessesByName("whatever.exe").Length > 0) { //do something }
Source: https://habr.com/ru/post/1734378/More articles:How to enable the zoom in / out option in UIWebView? - iphonehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1734374/passing-strings-to-c-functions-with-sas-proc-proto&usg=ALkJrhi8Hb1e-jQLta5x0S77bWyn2QuNiwSpeed: how to analyze / analyze "Directives / Content" stored in a variable? - javaGWT Maven and Eclipse - eclipseHow can I clear this CSS code? making it shorter or removes unnecessary parts (CSS perfectionist needed) - cssСоздание внутренних и внешних интерфейсов для скрытия класса/информации - c++Can I extract members of a structure or public class using a template? - c ++Qt client for Facebook - restthe document type does not allow the use of the element "img" / "font" here - validationрегулярное выражение (регулярное выражение) NOT, содержащее строку - regexAll Articles