• Welcome to PlanetSquires Forums.
 

QueryFullProcessImageName

Started by jermy, August 02, 2017, 11:28:55 AM

Previous topic - Next topic

jermy

Why i cant use QueryFullProcessImageName?

My FF_AppStart

#Define WIN32_WINNT = 0x0600
#Include Once "win/WinBase.bi"


Form1


'Declare Function QueryFullProcessImageName Lib "kernel32.dll" Alias "QueryFullProcessImageNameA" (ByVal ProcessHandle as HANDLE, ByVal  ProcessFlags as DWORD, ByVal Exename as LPSTR, ByVal BufferLength as PDWORD) as WINBOOL

'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     as Long, _      ' index in Control Array
                                   hWndForm         as HWnd, _      ' handle of Form
                                   hWndControl      as HWnd, _      ' handle of Control
                                   idButtonControl  as Long   _     ' identifier of button
                                   ) as Long
Dim Ret as Long

   'Ret = QueryFullProcessImageName(0, 0, 0, 0)

Dim hProcess as HANDLE

   'hProcess = OpenProcess(0, 0, 0)


   Function = 0   ' change according to your needs
End Function


If you comment out hProcess = OpenProcess(0, 0, 0) the program compile's with Ret = QueryFullProcessImageName(0, 0, 0, 0) it wont.
The compiler says 'The error 41: Variable not declared , QueryFullProcessImageName ...
I forgot to add something?.

José Roca

#Define WIN32_WINNT = 0x0600 must be #Define WIN32_WINNT = &h0602.

jermy

Strange the error wont go away, the compiler still says  'error 41: Variable not declared, QueryFullProcessImageName

José Roca

#3
Probably it is being ignored because WinBase.bi has already been included. The equate must be placed before any other include, e.g. before "windows.bi", that already includes WinBase.bi.

BTW it must be #Define WIN32_WINNT &h0602, without the equal sign.

jermy


This is my FF_AppStart file

#Lang "FB"

#Include Once "windows.bi"
#Include Once "win/commctrl.bi"  ' needed for WinXP Theme support
#Include Once "win/commdlg.bi"
#Include Once "win/richedit.bi"

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------

'#Define Unicode
#Define WIN32_WINNT &h0602
#Include Once "win/winsock2.bi"
#Include Once "win/Iphlpapi.bi"
#Include Once "win/WinBase.bi"     


And the calling code in a module file 'exefrompid.inc'

'Declare Function QueryFullProcessImageName Lib "kernel32.dll" Alias "QueryFullProcessImageNameA" (ByVal ProcessHandle as HANDLE, ByVal ProcessFlags as DWORD, ByVal Exename as LPSTR, ByVal BufferLength as PDWORD) as WINBOOL


Function ProcessPathByPID(ByVal PID as Long) as String

If PID = 0 Then ProcessPathByPID = "[System Idle Process]": Exit Function
  If PID = 4 Then ProcessPathByPID = "[System Process]": Exit Function
                                       
                                    '   Const PROCESS_QUERY_LIMITED_INFORMATION = &H1000
Dim hProcess as HANDLE
    hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, PID)
' hProcess = OpenProcess(0, 0, 0)
If hProcess = 0 Then
    GetApiErrorInfo(GetLastError), "hProcess1  " & PID
    ProcessPathByPID = "[Unknown Process]": Exit Function
End If
 
Dim i as Integer: i = 1024
Dim Exename as String : Exename = Space(i)
Dim Buf as Long: Buf = 1024
                                   ' Const PROCESS_NAME_NATIVE = &H1   'The name should use the native system path format.
                                   ' 0                                 'The name should use the Win32 path format.
     
Dim Ret as Long
    Ret = QueryFullProcessImageName(hProcess, 0, Exename, @Buf)
If Ret = 0 Then
    GetApiErrorInfo(GetLastError), "hProcess2  " & PID
    Ret = CloseHandle(@hProcess)
    ProcessPathByPID = "[Unknown Process]": Exit Function
Else
    ProcessPathByPID = Trim$(Exename)
'    ProcessPathByPID = Left$(Exename, i)
    Ret = CloseHandle(@hProcess)
End If

'Print ProcessPathByPID

End Function



José Roca

Use


#Lang "FB"

'#Define Unicode
#Define WIN32_WINNT &h0602
#Include Once "windows.bi"
#Include Once "win/commctrl.bi"  ' needed for WinXP Theme support
#Include Once "win/commdlg.bi"
#Include Once "win/richedit.bi"

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------

#Include Once "win/winsock2.bi"
#Include Once "win/Iphlpapi.bi"


You don't need to include WinBase.bi because it is already included by Windows.bi.

jermy

#6
That dident help, the compiler still says  'error 41: Variable not declared, QueryFullProcessImageName

This is my FF_AppStart file

#Lang "FB"

'#Define Unicode
#Define WIN32_WINNT &h0602
#Include Once "windows.bi"
#Include Once "win/commctrl.bi"  ' needed for WinXP Theme support
#Include Once "win/commdlg.bi"
#Include Once "win/richedit.bi"

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------

#Include Once "win/winsock2.bi"
#Include Once "win/Iphlpapi.bi"



And the calling code in Form1


'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     as Long, _      ' index in Control Array
                                   hWndForm         as HWnd, _      ' handle of Form
                                   hWndControl      as HWnd, _      ' handle of Control
                                   idButtonControl  as Long   _     ' identifier of button
                                   ) as Long
Dim Ret as Long

   Ret = QueryFullProcessImageName(0, 0, 0, 0)

Dim hProcess as HANDLE

  ' hProcess = OpenProcess(0, 0, 0)

  '  Ret = GetExtendedTcpTable(0, 0, 0, 0, 0, 0)


   Function = 0   ' change according to your needs
End Function



José Roca

I have checked the WinBase.bi file and that function is wrapped between


#if _WIN32_WINNT = &h0602
declare function LoadPackagedLibrary(byval lpwLibFileName as LPCWSTR, byval Reserved as DWORD) as HMODULE
const PROCESS_NAME_NATIVE = &h00000001
declare function QueryFullProcessImageNameA(byval hProcess as HANDLE, byval dwFlags as DWORD, byval lpExeName as LPSTR, byval lpdwSize as PDWORD) as WINBOOL
declare function QueryFullProcessImageNameW(byval hProcess as HANDLE, byval dwFlags as DWORD, byval lpExeName as LPWSTR, byval lpdwSize as PDWORD) as WINBOOL
#endif


Therefore, it must be #Define _WIN32_WINNT &h0602, with a leading underscore, not #Define WIN32_WINNT &h0602.

jermy

#Define _WIN32_WINNT &h0602

the comlpiler says  error 14: Expected identifier, found 'CERT_NAME_BLOB' in 'certificateNames as CERT_NAME_BLOB ptr'
and error 14: Expected identifier, found 'CRYPT_HASH_BLOB' in 'certBlob as CRYPT_HASH_BLOB'

FF_AppStart file

#Lang "FB"

'#Define Unicode
#Define _WIN32_WINNT &h0602
#Include Once "windows.bi"
#Include Once "win/commctrl.bi"  ' needed for WinXP Theme support
#Include Once "win/commdlg.bi"
#Include Once "win/richedit.bi"

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------
' #Define _WIN32_WINNT &h0602
#Include Once "win/winsock2.bi"
#Include Once "win/Iphlpapi.bi"


That wont compiler, try the attachment i cant get it to work.

José Roca

Wincrypt.bi needs to be included. Use:


'#Define Unicode
#Define _WIN32_WINNT &h0602
#Include Once "windows.bi"
#Include Once "win/commctrl.bi"  ' needed for WinXP Theme support
#Include Once "win/commdlg.bi"
#Include Once "win/richedit.bi"

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------
#Include Once "win/wincrypt.bi"
#Include Once "win/winsock2.bi"
#Include Once "win/Iphlpapi.bi"


PRINT
PRINT "Press any key..."
SLEEP


jermy

Thank you josé,

how did you find out?.

José Roca

Searching. I did a search of the include files for CERT_NAME_BLOB and it is defined in wincrypt.bi.