Add ProcessDllImportEx2 which gives more info back to caller.
This commit is contained in:
parent
4b310a0fe3
commit
76e377efa5
@ -10,6 +10,7 @@ procedure RegisterDLLRuntimeEx(Caller: TPSExec; AddDllProcImport, RegisterUnload
|
||||
|
||||
function ProcessDllImport(Caller: TPSExec; P: TPSExternalProcRec): Boolean;
|
||||
function ProcessDllImportEx(Caller: TPSExec; P: TPSExternalProcRec; ForceDelayLoad: Boolean): Boolean;
|
||||
function ProcessDllImportEx2(Caller: TPSExec; P: TPSExternalProcRec; ForceDelayLoad: Boolean; var DelayLoad: Boolean; var ErrorCode: LongInt): Boolean;
|
||||
procedure UnloadDLL(Caller: TPSExec; const sname: tbtstring);
|
||||
function UnloadProc(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
|
||||
|
||||
@ -73,7 +74,7 @@ begin
|
||||
Dispose(p);
|
||||
end;
|
||||
|
||||
function LoadDll(Caller: TPSExec; P: TPSExternalProcRec): Boolean;
|
||||
function LoadDll(Caller: TPSExec; P: TPSExternalProcRec; var ErrorCode: LongInt): Boolean;
|
||||
var
|
||||
s, s2, s3: tbtstring;
|
||||
h, i: Longint;
|
||||
@ -102,6 +103,7 @@ begin
|
||||
begin
|
||||
// don't pass an empty filename to LoadLibrary, just treat it as uncallable
|
||||
p.Ext2 := Pointer(1);
|
||||
ErrorCode := ERROR_MOD_NOT_FOUND;
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
@ -132,6 +134,7 @@ begin
|
||||
if dllhandle = 0 then
|
||||
begin
|
||||
p.Ext2 := Pointer(1);
|
||||
ErrorCode := GetLastError;
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
@ -150,6 +153,7 @@ begin
|
||||
if p.Ext1 = nil then
|
||||
begin
|
||||
p.Ext2 := Pointer(1);
|
||||
ErrorCode := GetLastError;
|
||||
Result := false;
|
||||
exit;
|
||||
end;
|
||||
@ -166,6 +170,7 @@ var
|
||||
CurrStack: Cardinal;
|
||||
cc: TPSCallingConvention;
|
||||
s: tbtstring;
|
||||
Dummy: LongInt;
|
||||
begin
|
||||
if p.Ext2 <> nil then // error
|
||||
begin
|
||||
@ -174,7 +179,7 @@ begin
|
||||
end;
|
||||
if p.Ext1 = nil then
|
||||
begin
|
||||
if not LoadDll(Caller, P) then
|
||||
if not LoadDll(Caller, P, Dummy) then
|
||||
begin
|
||||
Result := false;
|
||||
exit;
|
||||
@ -225,7 +230,14 @@ end;
|
||||
|
||||
function ProcessDllImportEx(Caller: TPSExec; P: TPSExternalProcRec; ForceDelayLoad: Boolean): Boolean;
|
||||
var
|
||||
DelayLoad: Boolean;
|
||||
Dummy1: Boolean;
|
||||
Dummy2: LongInt;
|
||||
begin
|
||||
Result := ProcessDllImportEx2(Caller, P, ForceDelayLoad, Dummy1, Dummy2);
|
||||
end;
|
||||
|
||||
function ProcessDllImportEx2(Caller: TPSExec; P: TPSExternalProcRec; ForceDelayLoad: Boolean; var DelayLoad: Boolean; var ErrorCode: LongInt): Boolean;
|
||||
var
|
||||
s: tbtstring;
|
||||
begin
|
||||
if not ForceDelayLoad then begin
|
||||
@ -241,7 +253,7 @@ begin
|
||||
Result := True;
|
||||
end else begin
|
||||
p.ProcPtr := DllProc;
|
||||
Result := LoadDll(Caller, p);
|
||||
Result := LoadDll(Caller, p, ErrorCode);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user