Menu

DLL will not load

rookie
2007-09-05
2012-09-26
  • rookie

    rookie - 2007-09-05

    Big three

    1) Dev version = 4.9.9.2

    2)firstdll.c file
    ////////////////////////////////////////////////////////////////////////////////////////
    / Replace "dll.h" with the name of your header /

    include "firstdll.h"

    include <windows.h>

    include <stdio.h>

    include <stdlib.h>

    DLLIMPORT void HelloWorld ()
    {
    MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
    }

    BOOL APIENTRY DllMain (HINSTANCE hInst / Library instance handle. / ,
    DWORD reason / Reason this function is being called. / ,
    LPVOID reserved / Not used. / )
    {
    switch (reason)
    {
    case DLL_PROCESS_ATTACH:
    break;

      case DLL_PROCESS_DETACH:
        break;
    
      case DLL_THREAD_ATTACH:
        break;
    
      case DLL_THREAD_DETACH:
        break;
    }
    
    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
    

    }/////////////////////////////////////////////////////////////////////////////////////////
    firstdll.h file
    ????????????????????????????????????????????????????????????????????????????????????????

    ifndef DLL_H

    define DLL_H

    if BUILDING_DLL

    define DLLIMPORT __declspec (dllexport)

    else / Not BUILDING_DLL /

    define DLLIMPORT __declspec (dllimport)

    endif / Not BUILDING_DLL /

    DLLIMPORT void HelloWorld (void);

    endif / DLL_H /

    ??????????????????????????????????????????????????????????????????????????????????????????????

    3)Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Makefile.win"
    Executing make...
    make.exe -f "C:\Dev-Cpp\Makefile.win" all
    dllwrap.exe --output-def libClassInstaller.def --implib libClassInstaller.a firstdll.o -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" --no-export-all-symbols --add-stdcall-alias -o ClassInstaller.dll

    dllwrap.exe: no export definition file provided.
    Creating one, but that may not be what you want

    Execution terminated
    Compilation successful

    My question is as follows?
    I'm trying to make the setupAPI system within windows load this file and have been completely unsuccessful. After looking at the PE file generated with PE browse professional some of the contents of the optional header is not what I would have expected. The output from PE browse professional of the optional header is shown below. The entry concerning me is (+0x44) Subsystem: 0x0003 (console subsystem required), when I need it to be 0x1 or 0x2. Can you please tell me what I'm doing wrong, it's only a sample Dll generated template from Dev C++.

    Structure for Optional Header
    (+0x00) Magic: 0x010B
    (+0x02) MajorLinkerVersion: 0x02
    (+0x03) MinorLinkerVersion: 0x38
    (+0x04) SizeOfCode: 0x00000C00
    (+0x08) SizeOfInitializedData: 0x00001E00
    (+0x0C) SizeOfUninitializedData: 0x00000200
    (+0x10) AddressOfEntryPoint: 0x00001000
    (+0x14) BaseOfCode: 0x00001000
    (+0x18) BaseOfData: 0x00002000
    (+0x1C) ImageBase: 0x69800000
    (+0x20) SectionAlignment: 0x00001000
    (+0x24) FileAlignment: 0x00000200
    (+0x28) MajorOperatingSystemVersion: 0x0004
    (+0x2A) MinorOperatingSystemVersion: 0x0000
    (+0x2C) MajorImageVersion: 0x0001
    (+0x2E) MinorImageVersion: 0x0000
    (+0x30) MajorSubsystemVersion: 0x0004
    (+0x32) MinorSubsystemVersion: 0x0000
    (+0x34) Reserved1: 0x00000000
    (+0x38) SizeOfImage: 0x00008000
    (+0x3C) SizeOfHeaders: 0x00000400
    (+0x40) CheckSum: 0x00009420
    (+0x44) Subsystem: 0x0003
    (+0x46) DllCharacteristics: 0x0000
    (+0x48) SizeOfStackReserve: 0x00200000
    (+0x4C) SizeOfStackCommit: 0x00001000
    (+0x50) SizeOfHeapReserve: 0x00100000
    (+0x54) SizeOfHeapCommit: 0x00001000
    (+0x58) LoaderFlags: 0x00000000
    (+0x5C) NumberOfRvaAndSizes: 0x00000010
    DataDirectory[0] - IMAGE_DIRECTORY_ENTRY_EXPORT
    (+0x60) VirtualAddress: 0x00005000
    (+0x64) Size: 0x00000154
    DataDirectory[1] - IMAGE_DIRECTORY_ENTRY_IMPORT
    (+0x68) VirtualAddress: 0x00006000
    (+0x6C) Size: 0x00000304
    DataDirectory[2] - IMAGE_DIRECTORY_ENTRY_RESOURCE
    (+0x70) VirtualAddress: 0x00000000
    (+0x74) Size: 0x00000000
    DataDirectory[3] - IMAGE_DIRECTORY_ENTRY_EXCEPTION
    (+0x78) VirtualAddress: 0x00000000
    (+0x7C) Size: 0x00000000
    DataDirectory[4] - IMAGE_DIRECTORY_ENTRY_SECURITY
    (+0x80) VirtualAddress: 0x00000000
    (+0x84) Size: 0x00000000
    DataDirectory[5] - IMAGE_DIRECTORY_ENTRY_BASERELOC
    (+0x88) VirtualAddress: 0x00007000
    (+0x8C) Size: 0x000002E8
    DataDirectory[6] - IMAGE_DIRECTORY_ENTRY_DEBUG
    (+0x90) VirtualAddress: 0x00000000
    (+0x94) Size: 0x00000000
    DataDirectory[7] - IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
    (+0x98) VirtualAddress: 0x00000000
    (+0x9C) Size: 0x00000000
    DataDirectory[8] - IMAGE_DIRECTORY_ENTRY_GLOBALPTR
    (+0xA0) VirtualAddress: 0x00000000
    (+0xA4) Size: 0x00000000
    DataDirectory[9] - IMAGE_DIRECTORY_ENTRY_TLS
    (+0xA8) VirtualAddress: 0x00000000
    (+0xAC) Size: 0x00000000
    DataDirectory[10] - IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG
    (+0xB0) VirtualAddress: 0x00000000
    (+0xB4) Size: 0x00000000
    DataDirectory[11] - IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
    (+0xB8) VirtualAddress: 0x00000000
    (+0xBC) Size: 0x00000000
    DataDirectory[12] - IMAGE_DIRECTORY_ENTRY_IAT
    (+0xC0) VirtualAddress: 0x00000000
    (+0xC4) Size: 0x00000000
    DataDirectory[13] - IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT
    (+0xC8) VirtualAddress: 0x00000000
    (+0xCC) Size: 0x00000000
    DataDirectory[14] - IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR (aka IMAGE_COR20_HEADER)
    (+0xD0) VirtualAddress: 0x00000000
    (+0xD4) Size: 0x00000000
    DataDirectory[15]
    (+0xD8) VirtualAddress: 0x00000000
    (+0xDC) Size: 0x00000000

     
    • Jim Pattee

      Jim Pattee - 2007-09-05

      <I'm trying to make the setupAPI system within windows load this file>

      Exactly how are you trying to load and execute the dll file? Your compile has successfully created the dll. You need another program to load and execute it. The program that executes the dll should link to the file libClassInstaller.a created by the dll compile. When you do this, the dll will automatically be loaded when the calling program is loaded. You can verify that the dll is loaded by displaying a message in "case DLL_PROCESS_ATTACH:"

       
    • Soma

      Soma - 2007-09-05

      Exactly how are you failing?

      What Win32::SetupAPI functions are you using?

      Soma

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.