CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: ForceLibraryNow

  1. #1
    Join Date
    Apr 2004
    Posts
    95

    ForceLibraryNow

    error upon compilation:
    Code:
    error C2065: 'ForceLibraryNow' : undeclared identifier
    erroring code below
    Code:
    #define  WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include "ForceLib.h"
    
    #pragma comment(linker,"/FILEALIGN:512 /MERGE:.rdata=.text /MERGE:.data=.text /SECTION:.text,EWR /IGNORE:4078")
    #pragma comment(linker,"/defaultlib:..\\testfln\\forcelibrary.lib ")
    
    void COut(char* szText)
    {
            DWORD dwBuff;
    
            WriteFile((HANDLE)STD_OUTPUT_HANDLE, (void*)szText, lstrlen(szText), &dwBuff, NULL);
            return;
    }
    
    
    
    int main()
    {
            DWORD dwBase;
            char  cBuff[40];
    
            // printf head
            COut("ForceLibraryNow - attempting to attach dll\n");
        
    
            game_hWND=FindWindow("WindowName","asdf");
    if(!game_hWND){
                    COut("Error finding game window !");
                    Sleep(1000);
                    return 0;
            }
            GetWindowThreadProcessId(game_hWND,&dwPID);
       //debug info
            wsprintf(cBuff, "PID: %08x \ngame_hWND:0x%08lX\n",dwPID,game_hWND); 
    
            COut(cBuff);
            dwBase = ForceLibraryNow(dwPID, "C:\\file.dll");
    
            // print results
            if (!dwBase){
                    COut("Error while forcing library !");
                    Sleep(5000);
            }                
            else
            {
    
                    COut(cBuff);
                    Sleep(1000);
            }       
     
            return 0; 
    }

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: ForceLibraryNow

    C2065 means that compiler does not see declaration or prototype of the function.
    Make sure that spelling and letter case are correct. If namespaces are used you have to specify using namespace xxx.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: ForceLibraryNow

    Well..make sure that the path to the library is correct....furthermore...to add the library the following would be enough
    Code:
    #pragma comment(lib, "mylib.lib")
    I never used the linker option to include a library, thus, it might work the same though...

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: ForceLibraryNow

    According to DarkLotus post, the problem is with a compiler not a linker.

    If compilation process were finished and library could not be found I think linker would generate error; probably unresolved external.

    Therefore I still think that something must be wrong with declaration/prototype of mentioned function.

    But we will know for sure when/if DarkLotus responds.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured