Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Exportierte Funktion aus Exe mit GetProcAddress (https://www.delphipraxis.net/198996-exportierte-funktion-aus-exe-mit-getprocaddress.html)

Fritzew 18. Dez 2018 09:37

AW: Exportierte Funktion aus Exe mit GetProcAddress
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hier mal ein kleiner Test

eigentlich müsste 2 mal eine messagebox kommen.
Schau es Dir mal im Debugger an.....

Neutral General 18. Dez 2018 09:59

AW: Exportierte Funktion aus Exe mit GetProcAddress
 
Habs hinbekommen.
Auch wenn das in der Windows Unit auf den ersten Blick so aussieht:
Delphi-Quellcode:
// Winapi.Windows
function GetProcAddress(hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall; overload;
function GetProcAddress(hModule: HMODULE; lpProcName: LPCWSTR): FARPROC; stdcall; overload;
GetProcAddress gibt es (original) nicht im WideString-Format:
Delphi-Quellcode:
// Winapi.Windows
function GetProcAddress(hModule: HMODULE; lpProcName: LPCSTR): FARPROC; external kernel32 name 'GetProcAddress';
function GetProcAddress(hModule: HMODULE; lpProcName: LPCWSTR): FARPROC;
begin
  if ULONG_PTR(lpProcName) shr 16 = 0 then // IS_INTRESOURCE
    Result := GetProcAddress(hModule, LPCSTR(lpProcName))
  else
    Result := GetProcAddress(hModule, LPCSTR(TMarshal.AsAnsi(lpProcName)));
end;
Musste also meine eigene Definition von PChar auf PAnsiChar ändern und jetzt klappt es.

Zacherl 18. Dez 2018 11:44

AW: Exportierte Funktion aus Exe mit GetProcAddress
 
Du solltest darauf achten, dass eine .reloc Section für deine .exe generiert wird, sonst bekommst du Probleme, wenn Adresse 00400000 schon belegt ist.

Neutral General 18. Dez 2018 11:47

AW: Exportierte Funktion aus Exe mit GetProcAddress
 
Wieso? Ich gehe doch nicht hartkodiert auf $400000.
GetModuleHandle(nil) sollte mir doch die Basisadresse der exe liefern egal wo sie liegt oder nicht?

Zacherl 18. Dez 2018 15:27

AW: Exportierte Funktion aus Exe mit GetProcAddress
 
Achso nevermind, du lädst die .exe ja gar nicht selbst. Passt schon :P


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:18 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz