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

View File

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