FpDbg: ifdef all windows specific code

git-svn-id: trunk@42897 -
This commit is contained in:
martin 2013-09-20 09:36:28 +00:00
parent 0c327b42bc
commit 16fc76f1ab
2 changed files with 21 additions and 2 deletions

View File

@ -38,8 +38,9 @@ unit FpDbgLoader;
interface interface
uses uses
LCLType,
{$ifdef windows} {$ifdef windows}
Windows, Windows, // After LCLType
{$endif} {$endif}
Classes, SysUtils, FpDbgPETypes; Classes, SysUtils, FpDbgPETypes;
@ -216,11 +217,13 @@ end;
constructor TDbgWinPEImageLoader.Create(const AFileName: String); constructor TDbgWinPEImageLoader.Create(const AFileName: String);
begin begin
{$ifdef windows}
FFileHandle := CreateFile(PChar(AFileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); FFileHandle := CreateFile(PChar(AFileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if FFileHandle = INVALID_HANDLE_VALUE if FFileHandle = INVALID_HANDLE_VALUE
then begin then begin
WriteLN('Cannot open file: ', AFileName); WriteLN('Cannot open file: ', AFileName);
end; end;
{$endif}
inherited Create; inherited Create;
end; end;
@ -236,12 +239,14 @@ end;
procedure TDbgWinPEImageLoader.DoCleanup; procedure TDbgWinPEImageLoader.DoCleanup;
begin begin
{$ifdef windows}
if FModulePtr <> nil if FModulePtr <> nil
then UnmapViewOfFile(FModulePtr); then UnmapViewOfFile(FModulePtr);
if FMapHandle <> 0 if FMapHandle <> 0
then CloseHandle(FMapHandle); then CloseHandle(FMapHandle);
if FFileHandle <> INVALID_HANDLE_VALUE if FFileHandle <> INVALID_HANDLE_VALUE
then CloseHandle(FFileHandle); then CloseHandle(FFileHandle);
{$endif}
FFileHandle := INVALID_HANDLE_VALUE; FFileHandle := INVALID_HANDLE_VALUE;
FMapHandle := 0; FMapHandle := 0;
@ -254,6 +259,7 @@ var
begin begin
Result := False; Result := False;
{$ifdef windows}
try try
FMapHandle := CreateFileMapping(FFileHandle, nil, PAGE_READONLY{ or SEC_IMAGE}, 0, 0, nil); FMapHandle := CreateFileMapping(FFileHandle, nil, PAGE_READONLY{ or SEC_IMAGE}, 0, 0, nil);
if FMapHandle = 0 if FMapHandle = 0
@ -287,6 +293,7 @@ begin
DoCleanup; DoCleanup;
end; end;
end; end;
{$endif}
end; end;
procedure TDbgWinPEImageLoader.UnloadData; procedure TDbgWinPEImageLoader.UnloadData;

View File

@ -23,14 +23,26 @@
unit FpDbgPETypes; unit FpDbgPETypes;
{$mode objfpc}{$H+}{$inline on} {$mode objfpc}{$H+}{$inline on}
interface interface
{$ifdef windows}
uses uses
Windows; Windows;
{$endif}
// //
// Image Format // Image Format
// //
{$IFNDEF windows}
type
SHORT = smallint;
LONG = longint;
ULONGLONG = qword; // used in AMD64 CONTEXT
GUID = system.tguid;
CLSID = GUID;
{$endif}
const const
{$ifdef ENDIAN_LITTLE} {$ifdef ENDIAN_LITTLE}