- Install Visual Studio 2022 (Community edition is fine).
- Select workload: Desktop development with C++.
- In Individual Components, add:
- MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
- Go to
https://download.libsodium.org/libsodium/releases/ - Download the latest MSVC package, for example:
libsodium-1.0.20-stable-msvc.zip
- Extract to
C:\libsodium\ - Verify you have:
C:\libsodium\Win32\Release\v143\static\libsodium.lib C:\libsodium\include\sodium.h
- Use your own path, then update paths in Visual Studio project settings.
Open x86 Native Tools Command Prompt for VS 2022 and run:
cd C:\Users\majst\source\repos\e2e
cl /LD /MT /O2 ^
/I"C:\libsodium\include" ^
e2e.c ^
/link ^
/DEF:e2e.def ^
/MACHINE:X86 ^
C:\libsodium\Win32\Release\v143\static\libsodium.lib ^
advapi32.lib user32.libFlag summary:
/LD- Build a DLL/MT- Static runtime (CRT linked into DLL)/O2- Optimization/I- Include directory for libsodium/DEF- Module definition file/MACHINE:X86- 32-bit target (required for mIRC)
Expected output:
e2e.dll <- copy this to mIRC folder
e2e.lib <- import library (not required by mIRC)
- Open Visual Studio 2022
- Click Create a new project
- Select Dynamic-Link Library (DLL) (C++)
- Project name:
e2e - Location:
C:\Users\majst\source\repos\
- In toolbar, where it says x64, open dropdown
- Click Configuration Manager...
- Active solution platform -> New...
- Select Win32 (x86)
- Copy settings from x64
- Click OK -> Close
- Select Win32 in toolbar dropdown
- In Solution Explorer, right-click Source Files
- Add -> Existing Item
- Add:
e2e.cande2e.def
Right-click project -> Properties -> All Configurations -> Win32
- Additional Include Directories:
C:\libsodium\include
- Runtime Library: Multi-threaded (/MT)
- Additional Dependencies (append):
C:\libsodium\Win32\Release\v143\static\libsodium.lib advapi32.lib
- Module Definition File:
e2e.def
- Target Machine: MachineX86 (/MACHINE:X86)
- Build -> Build Solution (
Ctrl+Shift+B) - DLL output:
C:\Users\majst\source\repos\e2e\Win32\Release\e2e.dll
dumpbin /headers e2e.dll | findstr machineExpected output contains:
machine (x86)
dumpbin /exports e2e.dllYou should see exported functions such as:
ordinal hint RVA name
... Decrypt
... Encrypt
... Test
... Version
dumpbin /dependents e2e.dllIt should not include libsodium.dll (libsodium is statically linked).
copy e2e.dll "C:\Program Files (x86)\mIRC\e2e.dll"Or use your actual mIRC install path.
- Check:
C:\libsodium\include\sodium.h - Check Include Directories in project properties
- Ensure linker includes
libsodium.lib - Verify
.libpath is correct
- DLL is not 32-bit -> verify with
dumpbin /headers - Wrong target platform -> must be Win32, not x64
- Runtime is not statically linked
- Set Runtime Library to
/MT
After a successful build, test in mIRC:
//echo -a $dll(e2e.dll, Test, hello world)
If you see e2e.dll OK - received: hello world, the DLL is loading correctly.