May 14, 2023 08:16 AM
(This post was last modified: May 23, 2023 04:03 AM by Transporter007.)
Hey guys,
Is there any way to execute dll file ? I want to execute dll file even if its reference in console executable cmd app.
How to fix this error:
Regards.
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(May 14, 2023 11:53 AM)HFDone Wrote: DLL is a library https://en.wikipedia.org/wiki/Dynamic-link_library
Yes I know. I want to open and execute that dll through executable file whether its cmd console, or form app, or bat file.
(May 14, 2023 12:40 PM)Transporter007 Wrote: Yes I know. I want to open and execute that dll through executable file whether its cmd console, or form app, or bat file.
You can execute a function contained with the library by importing the dll. You can't "execute" a dll directly.
https://www.c-sharpcorner.com/UploadFile...n-C-Sharp/
(May 14, 2023 01:10 PM)webdev77 Wrote: You can execute a function contained with the library by importing the dll. You can't "execute" a dll directly.
https://www.c-sharpcorner.com/UploadFile...n-C-Sharp/
just for you https://learn.microsoft.com/en-us/window...ls/dllmain
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(May 14, 2023 01:53 PM)HFDone Wrote: just for you https://learn.microsoft.com/en-us/window...ls/dllmain
Not sure why you are quoting me. Calling a DLL from an existing process isn't direct execution.
DO NOT DEAL WITH THIS MEMBER
May 15, 2023 12:51 AM
(This post was last modified: May 15, 2023 12:51 AM by Cl0ser.)
As people before me told you, DLL is a library. If you want to call these, you need to know their signatures.
If you just want to call the entry point (DllMain), just importing it should work (depending on the implementation)
https://learn.microsoft.com/en-us/dotnet...tattribute
May 15, 2023 06:36 AM
(This post was last modified: May 15, 2023 07:43 AM by Transporter007.)
(May 14, 2023 01:10 PM)webdev77 Wrote: You can execute a function contained with the library by importing the dll. You can't "execute" a dll directly.
https://www.c-sharpcorner.com/UploadFile...n-C-Sharp/
Can this method execute the dll aswell ?
Can you tell me how to call that dll file and execute it through windows console or windows form on load.
(May 14, 2023 11:21 PM)phantomman55 Wrote: What's a form app?
Windows Form Application
(May 15, 2023 12:51 AM)Cl0ser Wrote: As people before me told you, DLL is a library. If you want to call these, you need to know their signatures.
If you just want to call the entry point (DllMain), just importing it should work (depending on the implementation)
https://learn.microsoft.com/en-us/dotnet...tattribute
Can this method execute the dll aswell ?
(May 15, 2023 06:36 AM)Transporter007 Wrote: Can this method execute the dll aswell ?
Can you tell me how to call that dll file and execute it through windows console or windows form on load.
DLLs are not executables. You have to call their functions to execute their contents.
It would look something like this. See the link above that I linked you to.
Code [DllImport("MyDLL.dll")]
public static extern int MyFunction(int param1, int param2);
(May 15, 2023 08:11 AM)shatter Wrote: disagree
that, by definition, is an executable
that's how malware is executed directly in memory
Nope. Executables are standalone files that can be run. A DLL is not that.
(May 15, 2023 09:04 AM)shatter Wrote: im not going to sit here and argue that dll doesnt have executable logic
DLLs do have logic that is executable. That's an objective fact. That does not make them an executable. They are very specifically called Dynamic Link Libraries for a reason and not executables.
May 15, 2023 10:33 AM
(This post was last modified: May 15, 2023 10:34 AM by HFDone.)
(May 15, 2023 09:23 AM)webdev77 Wrote: DLLs do have logic that is executable. That's an objective fact. That does not make them an executable. They are very specifically called Dynamic Link Libraries for a reason and not executables.
we talking about using it in code so both need to be load first by their pe format and thats make dll much simple to do by api call.
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(May 15, 2023 11:45 AM)shatter Wrote: what is the title of this thread?
Refer to steps 4 to 6 of the link of my first post in the thread.
May 15, 2023 01:48 PM
(This post was last modified: May 15, 2023 02:04 PM by Transporter007.)
(May 15, 2023 08:02 AM)webdev77 Wrote: DLLs are not executables. You have to call their functions to execute their contents.
It would look something like this. See the link above that I linked you to.
Code [DllImport("MyDLL.dll")]
public static extern int MyFunction(int param1, int param2);
Error:
Code:
DO NOT DEAL WITH THIS MEMBER
May 15, 2023 02:06 PM
(This post was last modified: May 15, 2023 02:07 PM by Cl0ser.)
Code using System;
using System.Runtime.InteropServices;
using System.Threading;
public class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr LoadLibrary(string dllToLoad);
public static void Main()
{
var dllPath = @"C:\path\to\your\dll.dll";
var handle = LoadLibrary(dllPath);
if (handle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
throw new Exception($"Failed to load DLL. Error code: {errorCode}");
}
Console.ReadLine();
}
}
Since you have no clue about the DLL content, this will just load the DLL which will in turn execute the DllMain with attach params.
note that DLL you are trying to load might not even do anything at attach event or the context might be wrong and you will get an error(or not ¯\_(ツ)_/¯ ).
|