Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using GetModuleFileName in get_process_name() with NULL module handle [CORE2345] #2769

Closed
firebird-automations opened this issue Feb 26, 2009 · 6 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Zoltán Török (torokze)

Duplicates CORE1814

The Firebird::PathName get_process_name() (in src\common\utils.cpp) on Windows platform could lead into the following situation:

You have a plugin based software. The plugins placed into a directory below the main executable.
Just like this:

c:\program files\software - where the main executable resides
c:\program files\software\plugins - where the plugin modules (dll-s) resides

If one of the plugins uses the Firebird embeded version the client library (fbembed as fbclient.dll) placed into the plugin directory (c:\program files\software\plugins)
After the plugin loads the client library the GetModuleFileName(NULL, ....) gets back the main executable path. This is wrong because the fb located in the plugins directory.
The embeded fb client looks for all the necessary files (aliases.conf, firebird.conf, firebird.msg, UDF dir) in the main executable dir not where the actual client library resides.

Example:
c:\program files\software\main.exe - where the main executable resides

c:\program files\software\plugins - where the plugin modules (dll-s) resides
c:\program files\software\plugins\myplugin.dll (depends on firebird)
c:\program files\software\plugins\fbclient.dll
c:\program files\software\plugins\firebird.conf
c:\program files\software\plugins\firebird.msg
c:\program files\software\plugins\aliases.conf
...
c:\program files\software\plugins\udf

The GetModuleFileName(NULL, ....) returns c:\program files\software\main.exe not the c:\program files\software\plugins\myplugin.dll

@firebird-automations
Copy link
Collaborator Author

Modified by: Zoltán Török (torokze)

description: The Firebird::PathName get_process_name() on Windows platform could lead into the following situation:

You have a plugin based software. The plugins placed into a directory below the main executable.
Just like this:

c:\program files\software - where the main executable resides
c:\program files\software\plugins - where the plugin modules (dll-s) resides

If one of the plugins uses the Firebird embeded version the client library (fbembed as fbclient.dll) placed into the plugin directory (c:\program files\software\plugins)
After the plugin loads the client library the GetModuleFileName(NULL, ....) gets back the main executable path. This is wrong because the fb located in the plugins directory.
The embeded fb client looks for all the necessary files (aliases.conf, firebird.conf, firebird.msg, UDF dir) in the main executable dir not where the actual client library resides.

Example:
c:\program files\software\main.exe - where the main executable resides

c:\program files\software\plugins - where the plugin modules (dll-s) resides
c:\program files\software\plugins\myplugin.dll (depends on firebird)
c:\program files\software\plugins\fbclient.dll
c:\program files\software\plugins\firebird.conf
c:\program files\software\plugins\firebird.msg
c:\program files\software\plugins\aliases.conf
...
c:\program files\software\plugins\udf

The GetModuleFileName(NULL, ....) returns c:\program files\software\main.exe not the c:\program files\software\plugins\fbclient.dll

=>

The Firebird::PathName get_process_name() (in src\common\utils.cpp) on Windows platform could lead into the following situation:

You have a plugin based software. The plugins placed into a directory below the main executable.
Just like this:

c:\program files\software - where the main executable resides
c:\program files\software\plugins - where the plugin modules (dll-s) resides

If one of the plugins uses the Firebird embeded version the client library (fbembed as fbclient.dll) placed into the plugin directory (c:\program files\software\plugins)
After the plugin loads the client library the GetModuleFileName(NULL, ....) gets back the main executable path. This is wrong because the fb located in the plugins directory.
The embeded fb client looks for all the necessary files (aliases.conf, firebird.conf, firebird.msg, UDF dir) in the main executable dir not where the actual client library resides.

Example:
c:\program files\software\main.exe - where the main executable resides

c:\program files\software\plugins - where the plugin modules (dll-s) resides
c:\program files\software\plugins\myplugin.dll (depends on firebird)
c:\program files\software\plugins\fbclient.dll
c:\program files\software\plugins\firebird.conf
c:\program files\software\plugins\firebird.msg
c:\program files\software\plugins\aliases.conf
...
c:\program files\software\plugins\udf

The GetModuleFileName(NULL, ....) returns c:\program files\software\main.exe not the c:\program files\software\plugins\fbclient.dll

@firebird-automations
Copy link
Collaborator Author

Modified by: Zoltán Török (torokze)

description: The Firebird::PathName get_process_name() (in src\common\utils.cpp) on Windows platform could lead into the following situation:

You have a plugin based software. The plugins placed into a directory below the main executable.
Just like this:

c:\program files\software - where the main executable resides
c:\program files\software\plugins - where the plugin modules (dll-s) resides

If one of the plugins uses the Firebird embeded version the client library (fbembed as fbclient.dll) placed into the plugin directory (c:\program files\software\plugins)
After the plugin loads the client library the GetModuleFileName(NULL, ....) gets back the main executable path. This is wrong because the fb located in the plugins directory.
The embeded fb client looks for all the necessary files (aliases.conf, firebird.conf, firebird.msg, UDF dir) in the main executable dir not where the actual client library resides.

Example:
c:\program files\software\main.exe - where the main executable resides

c:\program files\software\plugins - where the plugin modules (dll-s) resides
c:\program files\software\plugins\myplugin.dll (depends on firebird)
c:\program files\software\plugins\fbclient.dll
c:\program files\software\plugins\firebird.conf
c:\program files\software\plugins\firebird.msg
c:\program files\software\plugins\aliases.conf
...
c:\program files\software\plugins\udf

The GetModuleFileName(NULL, ....) returns c:\program files\software\main.exe not the c:\program files\software\plugins\fbclient.dll

=>

The Firebird::PathName get_process_name() (in src\common\utils.cpp) on Windows platform could lead into the following situation:

You have a plugin based software. The plugins placed into a directory below the main executable.
Just like this:

c:\program files\software - where the main executable resides
c:\program files\software\plugins - where the plugin modules (dll-s) resides

If one of the plugins uses the Firebird embeded version the client library (fbembed as fbclient.dll) placed into the plugin directory (c:\program files\software\plugins)
After the plugin loads the client library the GetModuleFileName(NULL, ....) gets back the main executable path. This is wrong because the fb located in the plugins directory.
The embeded fb client looks for all the necessary files (aliases.conf, firebird.conf, firebird.msg, UDF dir) in the main executable dir not where the actual client library resides.

Example:
c:\program files\software\main.exe - where the main executable resides

c:\program files\software\plugins - where the plugin modules (dll-s) resides
c:\program files\software\plugins\myplugin.dll (depends on firebird)
c:\program files\software\plugins\fbclient.dll
c:\program files\software\plugins\firebird.conf
c:\program files\software\plugins\firebird.msg
c:\program files\software\plugins\aliases.conf
...
c:\program files\software\plugins\udf

The GetModuleFileName(NULL, ....) returns c:\program files\software\main.exe not the c:\program files\software\plugins\myplugin.dll

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue duplicates CORE1814 [ CORE1814 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Duplicate [ 3 ]

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants