So, habe mir aus den genannten Infos mal was zusammengestrickt, was auf den ersten Blick zu funktionieren scheint:
Code:
class function TNXEnviroment.IsConsoleApp(const FileName: string): Boolean;
var
Stream: TFilestream;
Signature: DWORD;
PE_HEADER: IMAGE_FILE_HEADER;
OPT_HEADER: IMAGE_OPTIONAL_HEADER;
DOS_HEADER: IMAGE_DOS_HEADER;
begin
Result := False;
if SysUtils.FileExists(FileName) then
try
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone);
try
Stream.Read(DOS_HEADER, SizeOf(DOS_HEADER));
if DOS_HEADER.e_magic <> IMAGE_DOS_SIGNATURE then // check for MZ
Exit;
Stream.Seek(DOS_HEADER._lfanew, soFromBeginning);
Stream.Read(Signature, SizeOf(Signature));
if Signature <> IMAGE_NT_SIGNATURE then
Exit;
Stream.Read(PE_HEADER, SizeOf(PE_HEADER));
if PE_HEADER.SizeOfOptionalHeader > 0 then
begin
Stream.Read(OPT_HEADER, SizeOf(OPT_HEADER));
Result := OPT_HEADER.Subsystem = 3;
end;
finally
Stream.Free;
end;
except
{ catch all errors }
end;
end;
Damit dürfte ich erstmal weiterkommen.
Vielen Dank für die Tipps,
Marc