-NEWS for captive-0.1
+NEWS for captive-0.2
+--------------------
+
+* Implemented cdecl/stdcall/fastcall function calling types
+
+
+NEWS for captive-0.1 (2002-10-31)
--------------------
* Project build framework done
<a href="http://www.acronis.com/products/osselector/">Acronis OS Selector</a>:
proprietary; $45
+Q: Do you differentiate cdecl/stdcall/fastcall functions?
+A: W32 uses
+ <a href="http://msdn.microsoft.com/library/en-us/vclang/html/_core_argument_passing_and_naming_conventions.asp"
+ >three different types of function calls</a>.
+ captive is completely compiled with the GNU standard function calls "cdecl"
+ - _even_ the functions from reactos source files with different design
+ function call type are all compiled as GNU standard "cdecl" ones and thus
+ the whole project uses one unified call type. There is always one 'relaying'
+ function generated inside libcaptive/ke/exports.c file named
+ functionname_calltype (such as functionname_fastcall etc.).
+
+ Realying function are generated as:<dl>
+ <dt>cdecl</dt><dd>No relaying function generated, just a simple #define.
+ You won't see this function in the gdb backtrace.
+ We cannot generate it by C code as we do not know the number of its arguments.
+ We require the host OS GCC feature "__attribute__((__cdecl__))"
+ although it should be the default function call.
+ </dd>
+ <dt>stdcall</dt><dd>Relaying stub generated, all arguments passed.
+ We require the host OS GCC feature "__attribute__((__stdcall__))".
+ </dd>
+ <dt>fastcall</dt><dd>W32 puts first two arguments to ECX and EDX.
+ GCC puts the arguments in the order EAX, EDX, ECX, ...
+ Although GCC can change this order by "-mreg-alloc=REGS" commandline
+ option such option is not supported by stock GNU/Linux GCC compilers.
+ Therefore we pretend an unused first argument and swap the order of
+ second vs. third function argument to get the right parameter pass.
+ We require the host OS GCC feature "__attribute__((__regparm__(3)))".
+ We require the host OS GCC feature "__attribute__((__stdcall__))".
+ </dl>
+ 32-bit return value in EAX is always passed back although it may be vain.
+ Please see the documentation of "captivesym.pl" for more information.
Eric Kohl, reactos developer:
..." and ReactOS cannot run on Linux!"
#include "captive/client.h" /* self */
#include "captive/ldr.h"
+#include "captive/ldr_exports.h"
#include "captive/unicode.h"
#include "captive/file.h"
#include <glib/gtypes.h>
* a positive number if the @result > %0.
* The returned number need not be equal to the result!!!!
*/
-LONG /* FASTCALL */ InterlockedIncrement(PLONG Addend)
+LONG InterlockedIncrement(PLONG Addend)
{
/* TODO:thread; really? */
return ++*Addend;
* a positive number if the @result > %0.
* The returned number need not be equal to the result!!!!
*/
-LONG /* FASTCALL */ InterlockedDecrement(PLONG Subend)
+LONG InterlockedDecrement(PLONG Subend)
{
/* TODO:thread; really? */
return --*Subend;
*
* Returns: Current CPU IRQ level. libcaptive always returns %PASSIVE_LEVEL.
*/
-KIRQL STDCALL KeGetCurrentIrql(VOID)
+KIRQL KeGetCurrentIrql(VOID)
{
/* TODO:thread */
/* reactos/hal/halx86/irql.c/CurrentIrql is initialized to HIGH_LEVEL */
* Acquires a spinlock. Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now. #GMutex would be needed otherwise.
*/
-VOID STDCALL KeAcquireSpinLock(PKSPIN_LOCK SpinLock,PKIRQL OldIrql)
+VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock,PKIRQL OldIrql)
{
/* TODO:thread */
/* reactos/hal/halx86/irql.c/CurrentIrql is initialized to HIGH_LEVEL */
* Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now. #GMutex would be needed otherwise.
*/
-VOID STDCALL KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock)
+VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock)
{
/* TODO:thread */
}
* Releases a spinlock. Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now. #GMutex would be needed otherwise.
*/
-VOID STDCALL KeReleaseSpinLock(PKSPIN_LOCK SpinLock,KIRQL NewIrql)
+VOID KeReleaseSpinLock(PKSPIN_LOCK SpinLock,KIRQL NewIrql)
{
/* TODO:thread */
}
* Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now. #GMutex would be needed otherwise.
*/
-VOID STDCALL KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock)
+VOID KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock)
{
/* TODO:thread */
}
client.h \
file.h \
ldr.h \
+ ldr_exports.h \
macros.h \
mm.h \
ps_reactos.h \
G_BEGIN_DECLS
-/**
- * captive_kernel_exports:
- *
- * Export all libcaptive symbols to reactos. It is done by *.def files used
- * by dlltool(1) of Mingw32 compiler suite. We use native host OS compiler and
- * we also have just a limited set of functions over reactos itself.
- * We use our captive_ModuleList_add_builtin() to simulate PE headers exporting
- * our symbols; this export simulation is invocated from this function.
- *
- * This function is generated automatically from #exports.captivesym file
- * by #captivesym.pl script.
- *
- * Multiple calls of this function are forbidden.
- *
- * Returns: %TRUE if the export was successful.
- */
-gboolean captive_kernel_exports(void);
-
-
NTSTATUS captive_LdrpLoadAndCallImage(PMODULE_OBJECT *ModuleObjectp,PUNICODE_STRING ModuleName,
PDRIVER_OBJECT DriverEntry_DriverObject,PUNICODE_STRING DriverEntry_RegistryPath);
-gboolean captive_ModuleList_add_builtin(const gchar *FullName_utf8,...);
/* LdrLoadModule() declared in reactos includes */
/* reactos/ntoskrnl/ldr/loader.c file-scope global declaration: */
--- /dev/null
+/* $Id$
+ * Include file for reactos ldr/ (loader) to be used from ke/exports.c of libcaptive
+ * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _CAPTIVE_LDR_EXPORTS_H
+#define _CAPTIVE_LDR_EXPORTS_H 1
+
+
+#include <glib/gtypes.h>
+/* NEVER include any captive/reactos include file as we are included
+ * from libcaptive/ke/exports.c which conflicts on any export symbol declaration.
+ */
+
+
+G_BEGIN_DECLS
+
+/**
+ * captive_kernel_exports:
+ *
+ * Export all libcaptive symbols to reactos. It is done by *.def files used
+ * by dlltool(1) of Mingw32 compiler suite. We use native host OS compiler and
+ * we also have just a limited set of functions over reactos itself.
+ * We use our captive_ModuleList_add_builtin() to simulate PE headers exporting
+ * our symbols; this export simulation is invocated from this function.
+ *
+ * This function is generated automatically from #exports.captivesym file
+ * by #captivesym.pl script.
+ *
+ * Multiple calls of this function are forbidden.
+ *
+ * Returns: %TRUE if the export was successful.
+ */
+gboolean captive_kernel_exports(void);
+
+
+gboolean captive_ModuleList_add_builtin(const gchar *FullName_utf8,...);
+
+G_END_DECLS
+
+
+#endif /* _CAPTIVE_LDR_EXPORTS_H */
#undef FASTCALL
#endif
+/* It gets defined to __attribute__((stdcall)) by "base.h" and "ntos/types.h". */
+#ifdef REACTOS_COMPAT
+#define STDCALL
+#else
+#undef STDCALL
+#endif
+
+/* It gets defined to __attribute__((cdecl)) by "base.h" and "ntos/types.h"; should not hurt. */
+#ifdef REACTOS_COMPAT
+#define CDECL
+#else
+#undef CDECL
+#endif
+
#ifdef REACTOS_COMPAT
#define wcscpy captive_reactos_wcscpy
#else
CLEANFILES+=exports.c
libke_la_SOURCES+=exports.c
-exports.c: exports.captivesym captivesym.pl
- perl captivesym.pl $< >$@
+# FIXME: a difference between "ntoskrnl/ntoskrnl.def" vs. "ntoskrnl/ntoskrnl.edf"?
+exports.c: exports.captivesym captivesym.pl $(top_srcdir)/reactos/ntoskrnl/ntoskrnl.def
+ perl captivesym.pl $(top_srcdir)/reactos/ntoskrnl/ntoskrnl.def $< >$@
*
* Report fatal kernel bug. This call never returns.
*/
-VOID STDCALL KeBugCheck(ULONG BugCheckCode)
+VOID KeBugCheck(ULONG BugCheckCode)
{
/* FIXME: Search for BugCheckCode's message text
* by in RT_MESSAGETABLE as done by reactos/ntoskrnl/ke/bug.c/KeBugCheckEx()
* Initalizes a kernel event. Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now.
*/
-VOID STDCALL KeInitializeEvent(PKEVENT Event,EVENT_TYPE Type,BOOLEAN State)
+VOID KeInitializeEvent(PKEVENT Event,EVENT_TYPE Type,BOOLEAN State)
{
/* TODO:thread */
}
ntoskrnl.exe IoUnregisterFileSystem undef
ntoskrnl.exe ExDeleteResourceLite undef
ntoskrnl.exe IoFreeWorkItem undef
-ntoskrnl.exe MmQuerySystemSize "reactos/ddk/mmfuncs.h"
-ntoskrnl.exe IoAllocateWorkItem "reactos/ddk/iofuncs.h"
-ntoskrnl.exe KeInitializeEvent "reactos/ddk/kefuncs.h"
-ntoskrnl.exe ExInitializeResourceLite "reactos/ddk/exfuncs.h"
+ntoskrnl.exe MmQuerySystemSize
+ntoskrnl.exe IoAllocateWorkItem
+ntoskrnl.exe KeInitializeEvent
+ntoskrnl.exe ExInitializeResourceLite
ntoskrnl.exe FsRtlCopyRead undef
-ntoskrnl.exe ObfReferenceObject "reactos/ddk/obfuncs.h"
-ntoskrnl.exe IoRegisterFileSystem "reactos/ddk/iofuncs.h"
-ntoskrnl.exe IoRegisterShutdownNotification "reactos/ddk/iofuncs.h"
-ntoskrnl.exe IoCreateDevice "reactos/ddk/iofuncs.h"
-ntoskrnl.exe RtlInitUnicodeString "reactos/ddk/rtl.h"
+ntoskrnl.exe ObfReferenceObject
+ntoskrnl.exe IoRegisterFileSystem
+ntoskrnl.exe IoRegisterShutdownNotification
+ntoskrnl.exe IoCreateDevice
+ntoskrnl.exe RtlInitUnicodeString
ntoskrnl.exe FsRtlNotifyVolumeEvent undef
ntoskrnl.exe IoRemoveShareAccess undef
ntoskrnl.exe IoReleaseVpbSpinLock undef
* Initalizes a semaphore. Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now.
*/
-VOID STDCALL KeInitializeSemaphore(PKSEMAPHORE Semaphore,LONG Count,LONG Limit)
+VOID KeInitializeSemaphore(PKSEMAPHORE Semaphore,LONG Count,LONG Limit)
{
/* TODO:thread */
Semaphore->Limit=Limit;
* Initalizes a spinlock. Currently libcaptive doesn't use multithreading
* and thus this function is a NOP now. #GMutex would be needed otherwise.
*/
-VOID STDCALL KeInitializeSpinLock(PKSPIN_LOCK SpinLock)
+VOID KeInitializeSpinLock(PKSPIN_LOCK SpinLock)
{
/* TODO:thread */
}
*
* Returns: %$(top_srcdir)/src/libcaptive/mm/mminit.c/CAPTIVE_SYSTEM_SIZE.
*/
-MM_SYSTEM_SIZE STDCALL MmQuerySystemSize(VOID)
+MM_SYSTEM_SIZE MmQuerySystemSize(VOID)
{
return CAPTIVE_SYSTEM_SIZE;
}
* Returns: Memory block base if successfuly allocated. %NULL otherwise.
* The allocated memory block is not cleared.
*/
-PVOID STDCALL ExAllocatePoolWithTag(ULONG PoolType,ULONG NumberOfBytes,ULONG Tag)
+PVOID ExAllocatePoolWithTag(ULONG PoolType,ULONG NumberOfBytes,ULONG Tag)
{
if (!NumberOfBytes)
return NULL;
* Returns: Memory block base if successfuly allocated. %NULL otherwise.
* The allocated memory block is not cleared.
*/
-PVOID STDCALL ExAllocatePool(POOL_TYPE PoolType,ULONG NumberOfBytes)
+PVOID ExAllocatePool(POOL_TYPE PoolType,ULONG NumberOfBytes)
{
return ExAllocatePoolWithTag(PoolType,NumberOfBytes,
0); /* Tag; reactos uses TAG_NONE ('None') but it is not documented for W32 */
* allocated by a previous ExAllocatePool() or ExAllocatePoolWithTag() call.
* You can no longer assume anything about this base address / memory block.
*/
-VOID STDCALL ExFreePool(IN PVOID Block)
+VOID ExFreePool(IN PVOID Block)
{
g_return_if_fail(Block!=NULL);
*
* Returns: Allocated address space if the allocation was successful.
*/
-PVOID STDCALL MmAllocateSection(IN ULONG Length)
+PVOID MmAllocateSection(IN ULONG Length)
{
int mmap_prot=captive_flProtect_to_mmap_prot(PAGE_READWRITE);
PVOID r;