Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Other DLLs & Dependancies
    primarykey
    data
    text
    <p>I have a program that uses a DLL to encrypt files. I want to write a program that makes use of the DLL so that I too can encrypt the files with the same algorithm. However, I'm new to using DLLs so I'm running into issues.</p> <p>I've done some research and got something that almost works, but I think the DLL I'm trying to use has other dependencies and I don't know how to properly load them too.</p> <p>Here is my code right now:</p> <pre><code>#include "stdafx.h" #include &lt;conio.h&gt; // Header file containing getch() prototype #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;windows.h&gt; using namespace std; typedef string(*CRYPT)(string); int _tmain(int argc, _TCHAR* argv[]) { CRYPT encrypt; HMODULE hMod; // handle to loaded library module BOOL bRes; // BOOL to check if DLL was successfully unloaded // returns a handle to the DLL, otherwise NULL hMod = LoadLibraryA("ChangedName.dll"); if (hMod == NULL) { cout &lt;&lt; "NULL" &lt;&lt; endl; system("PAUSE"); return 1; } // returns the address of the DLL functions, otherwise NULL encrypt = (CRYPT)GetProcAddress(hMod, "Encrypt"); // function call string enc = (encrypt)("this is a string"); cout &lt;&lt; "Encrypted: " &lt;&lt; enc &lt;&lt; endl; cout &lt;&lt; "Press a key to exit" &lt;&lt; endl; _getch(); bRes = FreeLibrary(hMod); return 0; } </code></pre> <p>When ran, I get:</p> <pre><code>'Project1.exe' (Win32): Loaded 'C:\Users\REMOVED\Documents\Visual Studio 2013\Projects\Project1\Debug\Project1.exe'. Symbols loaded. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Users\REMOVED\Documents\Visual Studio 2013\Projects\Project1\Debug\L2TowerUtils.dll'. Module was built without symbols. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mscoree.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll'. Cannot find or open the PDB file. 'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file. First-chance exception at 0x00000000 in Project1.exe: 0xC0000005: Access violation executing location 0x00000000. Unhandled exception at 0x7791BDA1 in Project1.exe: 0xC0000005: Access violation executing location 0x00000000. </code></pre> <p>The error occurs on <code>string enc = (encrypt)("this is a string");</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload