Page 1 of 1
Get ProgramFilename() info for the .exe, not .dll
Posted: Tue Feb 05, 2019 11:16 pm
by Mike Yurgalavage
If you use ProgramFilename() as a call from a .dll, the .dll and it's directory are the output.
For instance if the program is Test.exe and the .dll in it has the name display.dll, then if a function in the .dll calls ProgramFilename() from within the Test.exe, the output will show display.dll
C:\display.dll
I need it to display the name of the .exe
C:\Test.exe
Is there a call or command that shows the name and path of the running program, even if the command is called from within a .dll of that program?
Is there quick windows api hack for this? NameOfRunningProgam() !???
Re: Get ProgramFilename() info for the .exe, not .dll
Posted: Tue Feb 05, 2019 11:23 pm
by Mike Yurgalavage
Another way to ask this, is there a command that can be called from within a .dll to give the path and name of the .exe that the .dll is currently being used in?
Re: Get ProgramFilename() info for the .exe, not .dll
Posted: Wed Feb 06, 2019 4:46 pm
by JHPJHP
Hi Mike Yurgalavage,
Windows Services & Other Stuff
-
\Other_Stuff\ProcessStuff\CallingProcess\...
Run the executable and the DLL will report the calling process (path \ executable).
Re: Get ProgramFilename() info for the .exe, not .dll
Posted: Thu Feb 14, 2019 12:20 am
by Mike Yurgalavage
JHPJHP wrote:Hi Mike Yurgalavage,
Windows Services & Other Stuff
-
\Other_Stuff\ProcessStuff\CallingProcess\...
Run the executable and the DLL will report the calling process (path \ executable).
Thanks for reply, got it sorted!
For those interested,
Code: Select all
;-GRAB EXE NAME AND DIRECTORY
;{
OpenWindow(1,-1000,-1000,0,0,"")
buffer.s{512}
max.q = Len(buffer)-2
window_h.q
window_name.s
process_id.q
process_h.q
This_application_name.s
OpenLibrary(1,"kernel32.dll")
K32GetModuleFileNameExW_ = GetFunction(1,"K32GetModuleFileNameExW")
window_h = WindowID(1);GetForegroundWindow_()
If window_h <> 0
String_length.q = GetWindowText_(window_h,@buffer,max)
window_name = PeekS(@buffer,String_length)
GetWindowThreadProcessId_(window_h,@process_id)
If process_id <> 0
process_h = OpenProcess_(#PROCESS_QUERY_INFORMATION|#PROCESS_VM_READ , #False, process_id)
If process_h <> 0
String_length = CallFunctionFast(K32GetModuleFileNameExW_ ,process_h, 0, @buffer, max)
This_application_name = PeekS(@buffer,String_length)
EndIf
EndIf
EndIf
CloseLibrary(1)
CloseWindow(1)
best,
Mike