Commit in reactos on ELF_support
include/pseh.h+441.1 -> 1.1.16.1
include/pseh/framebased.h+67-81.10.2.1 -> 1.10.2.2
include/pseh/framebased/internal.h+1-11.1 -> 1.1.16.1
include/reactos/exeformat.h+3-21.1.2.3 -> 1.1.2.4
lib/kernel32/process/create.c+3-31.89.2.2 -> 1.89.2.3
w32api/include/ddk/ntifs.h+13-131.7.4.1 -> 1.7.4.2
+131-27
6 modified files
PSEH: some changes unrelated with the branch. Added support for sharing local variables with filter functions and finally functions, and new macros to declare some common forms of filter functions and finally functions. PSEH now officially cool. Still ugly, though

ExeFmt: new prototype for ReadFile callbacks. See my previous commit message for the ELF_support branch.

kernel32: some "PVOID + offset" bugs corrected.

ntifs.h: SECTION_IMAGE_INFORMATION.EntryPoint is an offset, not a pointer. Our kernel32.dll code even knew that and just casted the value to an integer. Made it an ULONG (not ULONG_PTR because executables have an hard size limit of 4GB even on Win64. Win128 may be a problem, though). SECTION_IMAGE_INFORMATION.StackReserve and SECTION_IMAGE_INFORMATION.StackCommit made into ULONG_PTRs because they were almost the only fields in the PE32 headers Microsoft bothered to extend to 64 bits for PE32+, and that has to mean something,

reactos/include
pseh.h 1.1 -> 1.1.16.1
diff -u -r1.1 -r1.1.16.1
--- pseh.h	2 Jun 2004 19:22:06 -0000	1.1
+++ pseh.h	18 Dec 2004 02:58:54 -0000	1.1.16.1
@@ -23,6 +23,50 @@
 #ifndef KJK_PSEH_H_
 #define KJK_PSEH_H_
 
+/* Some useful macros */
+#if defined(__cplusplus)
+# define _SEH_PVOID_CAST(TYPE_, P_) ((TYPE_)(P_))
+#else
+# define _SEH_PVOID_CAST(TYPE_, P_) (P_)
+#endif
+
+#if defined(FIELD_OFFSET)
+# define _SEH_FIELD_OFFSET FIELD_OFFSET
+#else
+# include <stddef.h>
+# define _SEH_FIELD_OFFSET offsetof
+#endif
+
+#if defined(CONTAINING_RECORD)
+# define _SEH_CONTAINING_RECORD CONTAINING_RECORD
+#else
+# define _SEH_CONTAINING_RECORD(ADDR_, TYPE_, FIELD_) \
+ ((TYPE_ *)(((char *)(ADDR_)) - _SEH_FIELD_OFFSET(TYPE_, FIELD_)))
+#endif
+
+#if defined(__CONCAT)
+# define _SEH_CONCAT __CONCAT
+#else
+# define _SEH_CONCAT1(X_, Y_) X_ ## Y_
+# define _SEH_CONCAT(X_, Y_) _SEH_CONCAT1(X_, Y_)
+#endif
+
+/* Locals sharing support */
+#define _SEH_LOCALS_TYPENAME(BASENAME_) \
+ struct _SEH_CONCAT(_SEHLocalsTag, BASENAME_)
+
+#define _SEH_DEFINE_LOCALS(BASENAME_) \
+ _SEH_LOCALS_TYPENAME(BASENAME_)
+
+#define _SEH_DECLARE_LOCALS(BASENAME_) \
+ _SEH_LOCALS_TYPENAME(BASENAME_) _SEHLocals; \
+ _SEH_LOCALS_TYPENAME(BASENAME_) * _SEHPLocals; \
+ _SEHPLocals = &_SEHLocals;
+
+/* Dummy locals */
+static _SEH_LOCALS_TYPENAME(_SEHDummyLocals) { int Dummy_; } _SEHLocals;
+static void __inline _SEHDummyLocalsUser(void) { (void)_SEHLocals; }
+
 /* TODO: <pseh/native.h> to wrap native SEH implementations */
 #include <pseh/framebased.h>
 

reactos/include/pseh
framebased.h 1.10.2.1 -> 1.10.2.2
diff -u -r1.10.2.1 -r1.10.2.2
--- framebased.h	8 Dec 2004 20:01:39 -0000	1.10.2.1
+++ framebased.h	18 Dec 2004 02:58:55 -0000	1.10.2.2
@@ -72,21 +72,66 @@
  _SEHLongJmp(myframe->SEH_JmpBuf, 1);
 }
 
+/* SHARED LOCALS */
+/* Access the locals for the current frame */
+#define _SEH_ACCESS_LOCALS(LOCALS_) \
+ _SEH_LOCALS_TYPENAME(LOCALS_) * _SEHPLocals; \
+ _SEHPLocals = \
+  _SEH_PVOID_CAST \
+  ( \
+   _SEH_LOCALS_TYPENAME(LOCALS_) *, \
+   _SEH_CONTAINING_RECORD(_SEHPortableFrame, _SEHFrame_t, SEH_Header) \
+    ->SEH_Locals \
+  );
+
+/* Access local variable VAR_ */
+#define _SEH_VAR(VAR_) _SEHPLocals->VAR_
+
+/* FILTER FUNCTIONS */
+/* Declares a filter function's prototype */
 #define _SEH_FILTER(NAME_) \
- int __stdcall NAME_ \
+ long __stdcall NAME_ \
  ( \
   struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \
   struct __SEHPortableFrame * _SEHPortableFrame \
  )
 
+/* Declares a static filter */
 #define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2))
 
+/* Declares a PSEH filter wrapping a regular filter function */
+#define _SEH_WRAP_FILTER(WRAPPER_, NAME_) \
+ static __inline _SEH_FILTER(WRAPPER_) \
+ { \
+  return (NAME_)(_SEHExceptionPointers); \
+ }
+
+/* FINALLY FUNCTIONS */
+/* Declares a finally function's prototype */
 #define _SEH_FINALLY(NAME_) \
  void __stdcall NAME_ \
  ( \
   struct __SEHPortableFrame * _SEHPortableFrame \
  )
 
+/* Declares a PSEH finally function wrapping a regular function */
+#define _SEH_WRAP_FINALLY(WRAPPER_, NAME_) \
+ _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ())
+
+#define _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ARGS_) \
+ static __inline _SEH_FINALLY(WRAPPER_) \
+ { \
+  NAME_ ARGS_; \
+ }
+
+#define _SEH_WRAP_FINALLY_LOCALS_ARGS(WRAPPER_, LOCALS_, NAME_, ARGS_) \
+ static __inline _SEH_FINALLY(WRAPPER_) \
+ { \
+  _SEH_ACCESS_LOCALS(LOCALS_); \
+  NAME_ ARGS_; \
+ }
+
+/* SAFE BLOCKS */
 #define _SEH_TRY_FINALLY(FINALLY_) \
  _SEH_TRY_FILTER_FINALLY \
  ( \
@@ -109,22 +154,36 @@
 #define _SEH_TRY \
  _SEH_TRY_HANDLE_FINALLY(NULL)
 
-#define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \
- {                                                                             \
-  static _SEHHandlers_t _SEHHandlers =                                         \
+#ifdef __cplusplus
+# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \
+  const _SEHHandlers_t _SEHHandlers =                                          \
+  {                                                                            \
+   (FILTER_),                                                                  \
+   _SEHCompilerSpecificHandler,                                                \
+   (FINALLY_)                                                                  \
+  };
+#else
+# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \
+  _SEHHandlers_t _SEHHandlers =                                                \
   {                                                                            \
-   (NULL),                                                                     \
+   (0),                                                                        \
    _SEHCompilerSpecificHandler,                                                \
-   (NULL)                                                                      \
+   (0)                                                                         \
   };                                                                           \
-  _SEHHandlers.SH_Filter = FILTER_;                                            \
-  _SEHHandlers.SH_Finally = FINALLY_;                                          \
+  _SEHHandlers.SH_Filter = (FILTER_);                                          \
+  _SEHHandlers.SH_Finally = (FINALLY_);
+#endif
+
+#define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \
+ {                                                                             \
+  _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_);                                    \
                                                                                \
   _SEHFrame_t * _SEHFrame;                                                     \
   volatile _SEHPortableFrame_t * _SEHPortableFrame;                            \
                                                                                \
   _SEHFrame = _alloca(sizeof(_SEHFrame_t));                                    \
   _SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers;                          \
+  _SEHFrame->SEH_Locals = &_SEHLocals;                                         \
                                                                                \
   _SEHPortableFrame = &_SEHFrame->SEH_Header;                                  \
   (void)_SEHPortableFrame;                                                     \

reactos/include/pseh/framebased
internal.h 1.1 -> 1.1.16.1
diff -u -r1.1 -r1.1.16.1
--- internal.h	2 Jun 2004 19:22:06 -0000	1.1
+++ internal.h	18 Dec 2004 02:58:55 -0000	1.1.16.1
@@ -44,7 +44,7 @@
 
 struct __SEHPortableFrame;
 
-typedef int (__stdcall * _SEHFilter_t)
+typedef long (__stdcall * _SEHFilter_t)
 (
  struct _EXCEPTION_POINTERS *,
  struct __SEHPortableFrame *

reactos/include/reactos
exeformat.h 1.1.2.3 -> 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- exeformat.h	13 Dec 2004 05:55:32 -0000	1.1.2.3
+++ exeformat.h	18 Dec 2004 02:58:55 -0000	1.1.2.4
@@ -18,9 +18,10 @@
 typedef NTSTATUS (NTAPI * PEXEFMT_CB_READ_FILE)
 (
  IN PFILE_OBJECT FileObject,
- OUT PVOID Buffer,
- IN ULONG BufferSize,
  IN PLARGE_INTEGER Offset,
+ IN ULONG Length,
+ OUT PVOID * Data,
+ OUT PVOID * AllocBase,
  OUT PULONG ReadSize
 );
 

reactos/lib/kernel32/process
create.c 1.89.2.2 -> 1.89.2.3
diff -u -r1.89.2.2 -r1.89.2.3
--- create.c	13 Dec 2004 16:18:04 -0000	1.89.2.2
+++ create.c	18 Dec 2004 02:58:55 -0000	1.89.2.3
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.89.2.2 2004/12/13 16:18:04 hyperion Exp $
+/* $Id: create.c,v 1.89.2.3 2004/12/18 02:58:55 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -1386,11 +1386,11 @@
     * Create the thread for the kernel
     */
    DPRINT("Creating thread for process (EntryPoint = 0x%.08x)\n",
-    ImageBaseAddress + Sii.EntryPoint);
+    (PVOID)((ULONG_PTR)ImageBaseAddress + Sii.EntryPoint));
    hThread =  KlCreateFirstThread(hProcess,
 				  lpThreadAttributes,
           &Sii,
-          ImageBaseAddress + Sii.EntryPoint,
+          (PVOID)((ULONG_PTR)ImageBaseAddress + Sii.EntryPoint),
 				  dwCreationFlags,
 				  &lpProcessInformation->dwThreadId);
    if (hThread == INVALID_HANDLE_VALUE)

reactos/w32api/include/ddk
ntifs.h 1.7.4.1 -> 1.7.4.2
diff -u -r1.7.4.1 -r1.7.4.2
--- ntifs.h	8 Dec 2004 21:57:43 -0000	1.7.4.1
+++ ntifs.h	18 Dec 2004 02:58:56 -0000	1.7.4.2
@@ -1582,19 +1582,19 @@
 } SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
 
 typedef struct _SECTION_IMAGE_INFORMATION {
-    PVOID   EntryPoint;
-    ULONG   Unknown1;
-    ULONG   StackReserve;
-    ULONG   StackCommit;
-    ULONG   Subsystem;
-    USHORT  MinorSubsystemVersion;
-    USHORT  MajorSubsystemVersion;
-    ULONG   Unknown2;
-    ULONG   Characteristics;
-    USHORT  ImageNumber;
-    BOOLEAN Executable;
-    UCHAR   Unknown3;
-    ULONG   Unknown4[3];
+    ULONG     EntryPoint;
+    ULONG     Unknown1;
+    ULONG_PTR StackReserve;
+    ULONG_PTR StackCommit;
+    ULONG     Subsystem;
+    USHORT    MinorSubsystemVersion;
+    USHORT    MajorSubsystemVersion;
+    ULONG     Unknown2;
+    ULONG     Characteristics;
+    USHORT    ImageNumber;
+    BOOLEAN   Executable;
+    UCHAR     Unknown3;
+    ULONG     Unknown4[3];
 } SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
 
 #if (VER_PRODUCTBUILD >= 2600)
CVSspam 0.2.8