[Linker Fatal Error] Fatal: Unable to open file 'WINDOWS.OBJ

c++ / delphi package - dll injection and api hooking
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

[Linker Fatal Error] Fatal: Unable to open file 'WINDOWS.OBJ

Post by shadowstar »

C++Builder 6
Uncheck Build with rumtime packages.
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

Code: Select all

#include <madCodeHook.hpp>
#include <madRemote.hpp>

#pragma comment(lib, "madCodeHook_.lib")
#pragma comment(lib, "madRemote_.lib")

...
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You don't need the pragma links. Using that #include is enough. Does the problem still occur when using #include only?
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

madshi wrote:You don't need the pragma links. Using that #include is enough. Does the problem still occur when using #include only?
yes.

I find text "WINDOWS.OBJ" in file madCodeHook.obj, but can't find file "WINDOWS.OBJ" in any directory. I add $(BCB)\Source\Windows.pas to the project, OK, but another error occured:

Code: Select all

[Linker Fatal Error] Fatal: Unable to open file 'SYSTEM.OBJ'
Add System.pas

Code: Select all

[Pascal Error] pasall.tmp(4): Identifier redeclared: 'system'
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Very strange. Could you please try with a brand new project? Does the problem occur there, too?

Are you using the BCB evaluation version?
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

madshi wrote:Very strange. Could you please try with a brand new project? Does the problem occur there, too?

Are you using the BCB evaluation version?
Yes, the problem occur in the brand new project.

I'm using the BCB Enterprise Suite Version 6.0.
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

madshi wrote:You don't need the pragma links. Using that #include is enough. Does the problem still occur when using #include only?
Oh, when using #include only:

Code: Select all

[Linker Error] Unresolved external '__stdcall Madcodehook::AmSystemProcess()' referenced from D:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I've tested it again. With runtime packages you don't need the #pragma stuff. But not using runtime packages you need to add this:

#pragma link "madCodeHook.obj"
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

madshi wrote:I've tested it again. With runtime packages you don't need the #pragma stuff. But not using runtime packages you need to add this:

#pragma link "madCodeHook.obj"

Code: Select all

[Linker Fatal Error] Fatal: Unable to open file 'WINDOWS.OBJ'
Does the problem not occur in your project?
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Which problem do you mean?

Have you noticed that my "pragma" call is different than yours? Please try my pragma call. Using that my BCB5 test project compiles&links just fine.
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

I have used #pragma comment and #pragme link, the error allways occured.

Sorry, I don't have BCB5, could you test it in BCB6?
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'll test it in BCB6 as soon as possible. Right now I don't have access to BCB6, but I should get it soon. For now you can use the madCHook.h file together with the madCHook.dll. It's not as nice as the native Delphi/BCB stuff, but at least it should let you begin working.
shadowstar
Posts: 12
Joined: Fri Jul 09, 2004 2:09 pm
Location: China
Contact:

Post by shadowstar »

Thank you.
:D
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Finally got BCB6 (enterprise edition) now. Created a new project, added a button to the main form. Double clicked it. Added this to the OnClick event:

Code: Select all

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AmSystemProcess();
}
Got this error, of course:

[C++ Error] Unit1.cpp(23): E2268 Call to undefined function 'AmSystemProcess'

Added:

Code: Select all

#include <madCodeHook.hpp>
Compiled and linked fine. Unchecked "runtime packages" from the project options. Recompiled. Got the error:

[Linker Error] Unresolved external '__stdcall Madcodehook::AmSystemProcess()' referenced from C:\DESKTOP\BCB6TEST\UNIT1.OBJ

Added:

Code: Select all

#pragma link "madCodeHook"
Compiled, linked and run fine. So I can't see anything wrong.

Here's the final full code:

Code: Select all

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

#include <madCodeHook.hpp>
#pragma link "madCodeHook"

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AmSystemProcess();
}
//---------------------------------------------------------------------------
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Maybe your library path is too long? Delphi/BCB has a hard limit on how long the library/search path may get. If you have too many components/packages installed with too long paths, Delphi/BCB usually can't find system.pas/obj, anymore. Try to clean up/shorten your library path.
Post Reply