Browse Source

* fixed win64 compilation

git-svn-id: trunk@6829 -
florian 18 years ago
parent
commit
44752f5559
2 changed files with 72 additions and 27 deletions
  1. 41 12
      packages/base/winunits/jwanative.pas
  2. 31 15
      packages/base/winunits/jwawinnt.pas

+ 41 - 12
packages/base/winunits/jwanative.pas

@@ -3959,7 +3959,7 @@ function  NtContinue(
 function  ZwContinue(Context: PCONTEXT; TestAlert: BOOLEAN): NTSTATUS; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtCreateChannel(
@@ -4523,7 +4523,7 @@ function  NtIsSystemResumeAutomatic(): BOOLEAN; stdcall; {$IFNDEF RTDL}external
 function  ZwIsSystemResumeAutomatic(): BOOLEAN; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtListenChannel(
@@ -4683,7 +4683,7 @@ function  ZwNotifyChangeMultipleKeys(KeyHandle: HANDLE; Flags: ULONG; KeyObjectA
     WatchSubtree: BOOLEAN; Buffer: PVOID; BufferLength: ULONG; Asynchronous: BOOLEAN): NTSTATUS; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtOpenChannel(
@@ -5453,7 +5453,7 @@ function  NtReplyWaitReplyPort(
 function  ZwReplyWaitReplyPort(PortHandle: HANDLE; ReplyMessage: PPORT_MESSAGE): NTSTATUS; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtReplyWaitSendChannel(
@@ -5569,7 +5569,7 @@ function  ZwSecureConnectPort(PortHandle: PHANDLE; PortName: PUNICODE_STRING; Se
     ConnectData: PVOID; ConnectDataLength: PULONG): NTSTATUS; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtSendWaitReplyChannel(
@@ -5581,7 +5581,7 @@ function  NtSendWaitReplyChannel(
 function  ZwSendWaitReplyChannel(x: PVOID; y: PVOID; z: PVOID; z2: PVOID): NTSTATUS; stdcall; {$IFNDEF RTDL}external ntdll;{$ENDIF}
 
 // Returns STATUS_NOT_IMPLEMENTED. Only MS knows the intention behind this.
-// 
+//
 // !!!DO NOT USE!!!
 // Compatibility: NT4, W2K
 function  NtSetContextChannel(
@@ -8173,26 +8173,44 @@ end;
 
 // Own function to retrieve the process's heap handle
 
-function NtpGetProcessHeap(): HANDLE; 
+function NtpGetProcessHeap(): HANDLE;
 asm
+{$ifdef cpu386}
   mov   EAX, FS:[018h]            // EAX now holds the TEB address
   mov   EAX, [EAX+030h]           // TEB+$30 holds the PEB address
-  mov   EAX, DWORD PTR [EAX+018h] // PEB+$30 holds the ProcessHeap's handle
+  mov   EAX, DWORD PTR [EAX+24] // PEB+$30 holds the ProcessHeap's handle
+{$endif cpu386}
+{$ifdef cpux86_64}
+  mov   RAX, GS:[48]              // EAX now holds the TEB address
+  mov   RAX, [RAX+060h]           // TEB+$30 holds the PEB address
+  mov   RAX, DWORD PTR [RAX+48]   // PEB+$30 holds the ProcessHeap's handle
+{$endif cpux86_64}
 end;
 
 // Own function to retrieve the thread environment block (TEB) pointer
 
 function NtpCurrentTeb(): PTEB;
 asm
-  mov   EAX, FS:[018h]
+{$ifdef cpu386}
+  mov   EAX, FS:[24]
+{$endif cpu386}
+{$ifdef cpux86_64}
+  mov   RAX, GS:[48]
+{$endif cpux86_64}
 end;
 
 // Own function to retrieve the process environment block (PEB) pointer
 
 function RtlpGetCurrentPeb(): PPEB;
 asm
-  mov   EAX, FS:[018h]
+{$ifdef cpu386}
+  mov   EAX, FS:[24]
   mov   EAX, [EAX+030h]
+{$endif cpu386}
+{$ifdef cpux86_64}
+  mov   RAX, GS:[24]
+  mov   RAX, [RAX+060h]
+{$endif cpux86_64}
 end;
 
 (* Own function to swap bytes in 16bit values
@@ -8202,6 +8220,9 @@ end;
 
 function RtlUshortByteSwap(Source: USHORT): USHORT;
 asm
+{$ifdef cpux86_64}
+  mov   CX, AX
+{$endif cpux86_64}
   rol   AX, 08h
 end;
 
@@ -8212,8 +8233,10 @@ end;
 
 function RtlUlongByteSwap(Source: ULONG): ULONG;
 asm
-  // This is not written as mnemonics to be compatible with D4!
-  db    0Fh, 0C8h       // "bswap EAX" can only be executed on 486+!!!
+{$ifdef cpux86_64}
+  mov   ECX, EAX
+{$endif cpux86_64}
+  bswap EAX
 (*
 // Does the same but perhaps slower ...
                         // Source = $11223344
@@ -8230,12 +8253,18 @@ end;
 
 function RtlUlonglongByteSwap(Source: ULONGLONG): ULONGLONG;
 asm
+{$ifdef cpu386}
   mov   EAX, [ESP+0Ch]  // Get the high part of the ULONGLONG into EAX
   mov   EDX, [ESP+08h]  // Get the low part of the ULONGLONG into EDX
   // This is not written as mnemonics to be compatible with D4!
   db    0Fh, 0C8h       // "bswap EAX" can only be executed on 486+!!!
   db    0Fh, 0CAh       // "bswap EDX" can only be executed on 486+!!!
   // High part returns in EDX, low part in EAX
+{$endif cpu386}
+{$ifdef cpux86_64}
+  MOV   RCX,RAX
+  BSWAP EAX
+{$endif cpux86_64}
 end;
 
 // Resembles the RtlValidateUnicodeString() function available from Windows XP

+ 31 - 15
packages/base/winunits/jwawinnt.pas

@@ -959,7 +959,7 @@ type
   PACCESS_MASK = ^ACCESS_MASK;
   {$EXTERNALSYM PACCESS_MASK}
   TAccessMask = ACCESS_MASK;
-  PAccessMask = PACCESS_MASK;  
+  PAccessMask = PACCESS_MASK;
 
 ////////////////////////////////////////////////////////////////////////
 //                                                                    //
@@ -1916,7 +1916,7 @@ type
   PACCESS_ALLOWED_CALLBACK_ACE = ^ACCESS_ALLOWED_CALLBACK_ACE;
   {$EXTERNALSYM PACCESS_ALLOWED_CALLBACK_ACE}
   TAccessAllowedCallBackAce = ACCESS_ALLOWED_CALLBACK_ACE;
-  PAccessAllowedCallBackAce = PACCESS_ALLOWED_CALLBACK_ACE;  
+  PAccessAllowedCallBackAce = PACCESS_ALLOWED_CALLBACK_ACE;
 
   _ACCESS_DENIED_CALLBACK_ACE = record
     Header: ACE_HEADER;
@@ -2815,7 +2815,7 @@ type
   PTOKEN_ORIGIN = ^TOKEN_ORIGIN;
   {$EXTERNALSYM PTOKEN_ORIGIN}
   TTokenOrigin = TOKEN_ORIGIN;
-  PTokenOrigin = PTOKEN_ORIGIN;  
+  PTokenOrigin = PTOKEN_ORIGIN;
 
 //
 // Security Tracking Mode
@@ -2881,7 +2881,7 @@ type
   PSECURITY_INFORMATION = ^SECURITY_INFORMATION;
   {$EXTERNALSYM PSECURITY_INFORMATION}
   TSecurityInformation = SECURITY_INFORMATION;
-  PSecurityInformation = PSECURITY_INFORMATION;  
+  PSecurityInformation = PSECURITY_INFORMATION;
 
 const
   OWNER_SECURITY_INFORMATION = $00000001;
@@ -3179,7 +3179,7 @@ type
   PQUOTA_LIMITS_EX = ^QUOTA_LIMITS_EX;
   {$EXTERNALSYM PQUOTA_LIMITS_EX}
   TQuotaLimitsEx = QUOTA_LIMITS_EX;
-  PQuotaLimitsEx = PQUOTA_LIMITS_EX;  
+  PQuotaLimitsEx = PQUOTA_LIMITS_EX;
 
   PIO_COUNTERS = ^IO_COUNTERS;
   {$EXTERNALSYM PIO_COUNTERS}
@@ -3333,7 +3333,7 @@ type
   PJOBOBJECT_JOBSET_INFORMATION = ^JOBOBJECT_JOBSET_INFORMATION;
   {$EXTERNALSYM PJOBOBJECT_JOBSET_INFORMATION}
   TJobObjectSetInformation = JOBOBJECT_JOBSET_INFORMATION;
-  PJobObjectSetInformation = PJOBOBJECT_JOBSET_INFORMATION;  
+  PJobObjectSetInformation = PJOBOBJECT_JOBSET_INFORMATION;
 
 const
   JOB_OBJECT_TERMINATE_AT_END_OF_JOB = 0;
@@ -3545,7 +3545,7 @@ type
   {$EXTERNALSYM SYSTEM_LOGICAL_PROCESSOR_INFORMATION}
   PSYSTEM_LOGICAL_PROCESSOR_INFORMATION = ^SYSTEM_LOGICAL_PROCESSOR_INFORMATION;
   TSystemLogicalProcessorInformation = SYSTEM_LOGICAL_PROCESSOR_INFORMATION;
-  PSystemLogicalProcessorInformation = PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;  
+  PSystemLogicalProcessorInformation = PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
 
 const
   PROCESSOR_INTEL_386     = 386;
@@ -5155,7 +5155,7 @@ type
 
 function IMAGE_FIRST_SECTION(NtHeader: PImageNtHeaders): PImageSectionHeader;
 {$EXTERNALSYM IMAGE_FIRST_SECTION}
-  
+
 const
   IMAGE_SIZEOF_SECTION_HEADER = 40;
   {$EXTERNALSYM IMAGE_SIZEOF_SECTION_HEADER}
@@ -7165,7 +7165,7 @@ type
   PSLIST_ENTRY = PSINGLE_LIST_ENTRY;
   {$EXTERNALSYM PSLIST_ENTRY}
   TSListEntry = SLIST_ENTRY;
-  PSListEntry = PSLIST_ENTRY;  
+  PSListEntry = PSLIST_ENTRY;
 
 type
   _SLIST_HEADER = record
@@ -7183,7 +7183,7 @@ type
   PSLIST_HEADER = ^SLIST_HEADER;
   {$EXTERNALSYM PSLIST_HEADER}
   TSListHeader = SLIST_HEADER;
-  PSListHeader = PSLIST_HEADER;  
+  PSListHeader = PSLIST_HEADER;
 
 procedure RtlInitializeSListHead(ListHead: PSLIST_HEADER); stdcall;
 {$EXTERNALSYM RtlInitializeSListHead}
@@ -7646,8 +7646,8 @@ type
 
     //
     // Filled by verifier provider DLL
-    // 
-    
+    //
+
     ProviderNtdllHeapFreeCallback: RTL_VERIFIER_NTDLLHEAPFREE_CALLBACK;
   end;
   {$EXTERNALSYM _RTL_VERIFIER_PROVIDER_DESCRIPTOR}
@@ -8996,18 +8996,34 @@ end;
 
 function NtCurrentTeb: PNT_TIB;
 asm
-        MOV     EAX, FS:[0]
+{$ifdef cpu386}
+        MOV     EAX, FS:[24]
+{$endif cpu386}
+{$ifdef cpux86_64}
+        movq     RAX, GS:[48]
+{$endif cpux86_64}
 end;
 
 function GetFiberData: PVOID;
 asm
-        MOV     EAX, FS:[$10]
+{$ifdef cpu386}
+        MOV     EAX, FS:[16]
         MOV     EAX, [EAX]
+{$endif cpu386}
+{$ifdef cpux86_64}
+        MOV     RAX, GS:[32]
+        MOV     RAX, [RAX]
+{$endif cpux86_64}
 end;
 
 function GetCurrentFiber: PVOID;
 asm
-        MOV     EAX, FS:[$10]
+{$ifdef cpu386}
+        MOV     EAX, FS:[16]
+{$endif cpu386}
+{$ifdef cpux86_64}
+        MOV     RAX, GS:[32]
+{$endif cpux86_64}
 end;
 
 {$IFNDEF JWA_INCLUDEMODE}