From 2a613a30c4bbcac1e0ac87159a148f2523a760aa Mon Sep 17 00:00:00 2001 From: David Welch Date: Fri, 16 Mar 2001 18:11:24 +0000 Subject: [PATCH] Removed obsolete header files Updated copyright notices svn path=/trunk/; revision=1703 --- reactos/include/ddk/zw.h | 15 +- reactos/include/ddk/zwtypes.h | 10 + reactos/lib/kernel32/process/create.c | 15 +- reactos/ntoskrnl/cc/cacheman.c | 3 +- reactos/ntoskrnl/cc/view.c | 3 +- reactos/ntoskrnl/dbg/dbgctrl.c | 8 +- reactos/ntoskrnl/dbg/errinfo.c | 21 +- reactos/ntoskrnl/dbg/print.c | 21 +- reactos/ntoskrnl/ex/callback.c | 22 +- reactos/ntoskrnl/ex/fmutex.c | 22 +- reactos/ntoskrnl/ex/init.c | 51 +- reactos/ntoskrnl/hal/x86/bios32.c | 2 - reactos/ntoskrnl/hal/x86/bus.c | 3 +- reactos/ntoskrnl/hal/x86/display.c | 3 +- reactos/ntoskrnl/hal/x86/halinit.c | 4 +- reactos/ntoskrnl/hal/x86/misc.c | 4 +- reactos/ntoskrnl/hal/x86/pci.c | 3 +- reactos/ntoskrnl/hal/x86/reboot.c | 4 +- reactos/ntoskrnl/hal/x86/udelay.c | 3 +- reactos/ntoskrnl/include/internal/arch/mm.h | 10 + reactos/ntoskrnl/include/internal/debug.h | 32 - reactos/ntoskrnl/include/internal/dma.h | 267 -- reactos/ntoskrnl/include/internal/hal.h | 10 - .../include/internal/{i386 => hal}/hal.h | 0 reactos/ntoskrnl/include/internal/hal/irq.h | 7 - reactos/ntoskrnl/include/internal/hal/page.h | 59 - .../ntoskrnl/include/internal/hal/segment.h | 343 -- .../include/internal/i386/{mmhal.h => mm.h} | 6 +- .../ntoskrnl/include/internal/i386/segment.h | 6 +- .../include/internal/i386/segment.inc | 6 - reactos/ntoskrnl/include/internal/mm.h | 2 +- reactos/ntoskrnl/include/internal/mmhal.h | 10 - reactos/ntoskrnl/include/internal/ps.h | 1 - reactos/ntoskrnl/include/internal/psmgr.h | 51 - reactos/ntoskrnl/include/internal/types.h | 4 - reactos/ntoskrnl/include/internal/wait.h | 2 - reactos/ntoskrnl/io/mdl.c | 3 +- reactos/ntoskrnl/ke/catch.c | 4 +- reactos/ntoskrnl/ke/i386/bios.c | 2 +- reactos/ntoskrnl/ke/i386/exp.c | 23 +- reactos/ntoskrnl/ke/i386/gdt.c | 2 +- reactos/ntoskrnl/ke/i386/thread.c | 3 +- reactos/ntoskrnl/ke/i386/usercall.c | 4 +- reactos/ntoskrnl/ke/i386/v86m.c | 2 +- reactos/ntoskrnl/ke/kthread.c | 2 +- reactos/ntoskrnl/ke/main.c | 24 +- reactos/ntoskrnl/ldr/loader.c | 3 +- reactos/ntoskrnl/ldr/pedump.c | 3490 ----------------- reactos/ntoskrnl/mm/freelist.c | 1 - reactos/ntoskrnl/mm/i386/page.c | 4 +- reactos/ntoskrnl/mm/kmap.c | 3 +- reactos/ntoskrnl/mm/marea.c | 1 - reactos/ntoskrnl/mm/mdl.c | 3 +- reactos/ntoskrnl/mm/mm.c | 3 +- reactos/ntoskrnl/mm/mminit.c | 3 +- reactos/ntoskrnl/mm/mpw.c | 3 +- reactos/ntoskrnl/mm/npool.c | 3 +- reactos/ntoskrnl/mm/pageop.c | 3 +- reactos/ntoskrnl/mm/pager.c | 3 +- reactos/ntoskrnl/mm/virtual.c | 3 +- reactos/ntoskrnl/ps/create.c | 3 +- reactos/ntoskrnl/ps/debug.c | 4 +- reactos/ntoskrnl/ps/suspend.c | 3 +- reactos/ntoskrnl/ps/thread.c | 3 +- 64 files changed, 246 insertions(+), 4395 deletions(-) create mode 100644 reactos/ntoskrnl/include/internal/arch/mm.h delete mode 100644 reactos/ntoskrnl/include/internal/dma.h delete mode 100644 reactos/ntoskrnl/include/internal/hal.h rename reactos/ntoskrnl/include/internal/{i386 => hal}/hal.h (100%) delete mode 100644 reactos/ntoskrnl/include/internal/hal/irq.h delete mode 100644 reactos/ntoskrnl/include/internal/hal/page.h delete mode 100644 reactos/ntoskrnl/include/internal/hal/segment.h rename reactos/ntoskrnl/include/internal/i386/{mmhal.h => mm.h} (90%) delete mode 100644 reactos/ntoskrnl/include/internal/i386/segment.inc delete mode 100644 reactos/ntoskrnl/include/internal/mmhal.h delete mode 100644 reactos/ntoskrnl/include/internal/psmgr.h delete mode 100644 reactos/ntoskrnl/include/internal/types.h delete mode 100644 reactos/ntoskrnl/include/internal/wait.h delete mode 100644 reactos/ntoskrnl/ldr/pedump.c diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index a020889b9e4..fa836adcca5 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -1,5 +1,5 @@ -/* $Id: zw.h,v 1.41 2001/03/16 16:05:32 dwelch Exp $ +/* $Id: zw.h,v 1.42 2001/03/16 18:11:20 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -5234,12 +5234,13 @@ NtSetSystemPowerState ( /* --- DEBUG SUBSYSTEM --- */ -NTSTATUS -STDCALL -NtSystemDebugControl ( - VOID - ); - +NTSTATUS STDCALL +NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode, + PVOID InputBuffer, + ULONG InputBufferLength, + PVOID OutputBuffer, + ULONG OutputBufferLength, + PULONG ReturnLength); /* --- VIRTUAL DOS MACHINE (VDM) --- */ diff --git a/reactos/include/ddk/zwtypes.h b/reactos/include/ddk/zwtypes.h index 7c81a3c8736..677ec307b8e 100644 --- a/reactos/include/ddk/zwtypes.h +++ b/reactos/include/ddk/zwtypes.h @@ -1,6 +1,16 @@ #ifndef __INCLUDE_DDK_ZWTYPES_H #define __INCLUDE_DDK_ZWTYPES_H +typedef enum _DEBUG_CONTROL_CODE +{ + DebugGetTraceInformation = 1, + DebugSetInternalBreakpoint, + DebugSetSpecialCalls, + DebugClearSpecialCalls, + DebugQuerySpecialCalls, + DebugDbgBreakPoint +} DEBUG_CONTROL_CODE; + typedef enum _KPROFILE_SOURCE { ProfileTime diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index cea638e9476..a2ae19a3a6c 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.36 2001/03/09 14:40:27 dwelch Exp $ +/* $Id: create.c,v 1.37 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -398,6 +398,7 @@ CreateProcessW(LPCWSTR lpApplicationName, ULONG i; ANSI_STRING ProcedureName; UNICODE_STRING CurrentDirectoryW; + SECTION_IMAGE_INFORMATION Sii; DPRINT("CreateProcessW(lpApplicationName '%S', lpCommandLine '%S')\n", lpApplicationName,lpCommandLine); @@ -491,6 +492,15 @@ CreateProcessW(LPCWSTR lpApplicationName, NULL, NULL); + /* + * Get some information about the executable + */ + Status = ZwQuerySection(hSection, + SectionImageInformation, + &Sii, + sizeof(Sii), + &i); + /* * Close the section */ @@ -562,8 +572,7 @@ CreateProcessW(LPCWSTR lpApplicationName, DPRINT("Creating thread for process\n"); hThread = KlCreateFirstThread(hProcess, lpThreadAttributes, -// Headers.OptionalHeader.SizeOfStackReserve, - 0x200000, + Sii.StackReserve, lpStartAddress, dwCreationFlags, &lpProcessInformation->dwThreadId); diff --git a/reactos/ntoskrnl/cc/cacheman.c b/reactos/ntoskrnl/cc/cacheman.c index 395fe890b24..637aa2c1ee7 100644 --- a/reactos/ntoskrnl/cc/cacheman.c +++ b/reactos/ntoskrnl/cc/cacheman.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 @@ -21,6 +21,7 @@ * FILE: ntoskrnl/cc/cacheman.c * PURPOSE: Cache manager * PROGRAMMER: David Welch (welch@cwcom.net) + * PORTABILITY: Checked * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/cc/view.c b/reactos/ntoskrnl/cc/view.c index 33aae491595..f17e283a89f 100644 --- a/reactos/ntoskrnl/cc/view.c +++ b/reactos/ntoskrnl/cc/view.c @@ -16,13 +16,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: view.c,v 1.20 2001/03/13 17:47:47 dwelch Exp $ +/* $Id: view.c,v 1.21 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cc/view.c * PURPOSE: Cache manager * PROGRAMMER: David Welch (welch@mcmail.com) + * PORTABILITY: Checked * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/dbg/dbgctrl.c b/reactos/ntoskrnl/dbg/dbgctrl.c index 8627c2bfbd3..94e1abbc686 100644 --- a/reactos/ntoskrnl/dbg/dbgctrl.c +++ b/reactos/ntoskrnl/dbg/dbgctrl.c @@ -20,6 +20,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/dbgctrl.c * PURPOSE: System debug control + * PORTABILITY: Checked */ /* INCLUDES *****************************************************************/ @@ -31,7 +32,12 @@ /* FUNCTIONS *****************************************************************/ NTSTATUS STDCALL -NtSystemDebugControl(VOID) +NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode, + PVOID InputBuffer, + ULONG InputBufferLength, + PVOID OutputBuffer, + ULONG OutputBufferLength, + PULONG ReturnLength) { UNIMPLEMENTED; } diff --git a/reactos/ntoskrnl/dbg/errinfo.c b/reactos/ntoskrnl/dbg/errinfo.c index 740d29442c0..904c40998c1 100644 --- a/reactos/ntoskrnl/dbg/errinfo.c +++ b/reactos/ntoskrnl/dbg/errinfo.c @@ -1,9 +1,26 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/errinfo.c * PURPOSE: Print information descriptions of error messages - * PROGRAMMER: David Welch (welch@mcmail.com) + * PORTABILITY: Checked * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/dbg/print.c b/reactos/ntoskrnl/dbg/print.c index 19ae2f3d63c..d8c8edb1b1d 100644 --- a/reactos/ntoskrnl/dbg/print.c +++ b/reactos/ntoskrnl/dbg/print.c @@ -1,10 +1,29 @@ -/* $Id: print.c,v 1.11 2000/12/23 02:37:38 dwelch Exp $ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: print.c,v 1.12 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/print.c * PURPOSE: Debug output * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de) + * PORTABILITY: Unchecked * UPDATE HISTORY: * 14/10/99: Created */ diff --git a/reactos/ntoskrnl/ex/callback.c b/reactos/ntoskrnl/ex/callback.c index 4f32255d67f..af3cf3ef848 100644 --- a/reactos/ntoskrnl/ex/callback.c +++ b/reactos/ntoskrnl/ex/callback.c @@ -1,10 +1,28 @@ -/* $Id: callback.c,v 1.5 2000/12/23 02:37:39 dwelch Exp $ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: callback.c,v 1.6 2001/03/16 18:11:21 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/callback.c * PURPOSE: Executive callbacks * PROGRAMMER: David Welch (welch@mcmail.com) + * PORTABILITY: Checked. * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/ex/fmutex.c b/reactos/ntoskrnl/ex/fmutex.c index 1ad02066db7..447ebf3c786 100644 --- a/reactos/ntoskrnl/ex/fmutex.c +++ b/reactos/ntoskrnl/ex/fmutex.c @@ -1,10 +1,28 @@ -/* $Id: fmutex.c,v 1.8 2000/12/23 02:37:39 dwelch Exp $ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: fmutex.c,v 1.9 2001/03/16 18:11:21 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/fmutex.c * PURPOSE: Implements fast mutexes * PROGRAMMER: David Welch (welch@cwcom.net) + * PORTABILITY: Checked. * UPDATE HISTORY: * Created 22/05/98 */ diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index 1bf6a4112a2..dfb89d0c1ab 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -1,9 +1,27 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* * PROJECT: ReactOS kernel * FILE: kernel/ex/init.c * PURPOSE: executive initalization * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de) + * PORTABILITY: Checked. * UPDATE HISTORY: * Created 11/09/99 */ @@ -19,35 +37,30 @@ POBJECT_TYPE EXPORTED ExWindowStationObjectType = NULL; /* FUNCTIONS ****************************************************************/ -VOID ExInit (VOID) +VOID +ExInit (VOID) { ExInitTimeZoneInfo(); ExInitializeWorkerThreads(); } -BOOLEAN -STDCALL -ExIsProcessorFeaturePresent ( - IN ULONG ProcessorFeature - ) +BOOLEAN STDCALL +ExIsProcessorFeaturePresent (IN ULONG ProcessorFeature) { - if (ProcessorFeature >= 32) - return FALSE; - - return FALSE; + if (ProcessorFeature >= 32) + return FALSE; + + return FALSE; } -VOID -STDCALL -ExPostSystemEvent ( - ULONG Unknown1, - ULONG Unknown2, - ULONG Unknown3 - ) +VOID STDCALL +ExPostSystemEvent (ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3) { - /* doesn't do anything */ + /* doesn't do anything */ } /* EOF */ diff --git a/reactos/ntoskrnl/hal/x86/bios32.c b/reactos/ntoskrnl/hal/x86/bios32.c index 9af615ca63d..f972eebabc3 100644 --- a/reactos/ntoskrnl/hal/x86/bios32.c +++ b/reactos/ntoskrnl/hal/x86/bios32.c @@ -16,9 +16,7 @@ #include #include -#include #include -#include /* TYPES ******************************************************************/ diff --git a/reactos/ntoskrnl/hal/x86/bus.c b/reactos/ntoskrnl/hal/x86/bus.c index 13b2d3e7be7..3578f076146 100644 --- a/reactos/ntoskrnl/hal/x86/bus.c +++ b/reactos/ntoskrnl/hal/x86/bus.c @@ -1,4 +1,4 @@ -/* $Id: bus.c,v 1.6 2001/03/07 16:48:41 dwelch Exp $ +/* $Id: bus.c,v 1.7 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -16,7 +16,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/hal/x86/display.c b/reactos/ntoskrnl/hal/x86/display.c index ffadb4cf502..3e2740f0795 100644 --- a/reactos/ntoskrnl/hal/x86/display.c +++ b/reactos/ntoskrnl/hal/x86/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.11 2000/10/08 12:46:31 ekohl Exp $ +/* $Id: display.c,v 1.12 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -10,7 +10,6 @@ */ #include -#include #define SCREEN_SYNCHRONIZATION diff --git a/reactos/ntoskrnl/hal/x86/halinit.c b/reactos/ntoskrnl/hal/x86/halinit.c index bd35484f3f4..a521276af07 100644 --- a/reactos/ntoskrnl/hal/x86/halinit.c +++ b/reactos/ntoskrnl/hal/x86/halinit.c @@ -1,4 +1,4 @@ -/* $Id: halinit.c,v 1.16 2000/10/22 13:27:34 ekohl Exp $ +/* $Id: halinit.c,v 1.17 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,7 +12,7 @@ /* INCLUDES *****************************************************************/ #include -#include +#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/hal/x86/misc.c b/reactos/ntoskrnl/hal/x86/misc.c index 9a32be10dd1..c1ae73b67b7 100644 --- a/reactos/ntoskrnl/hal/x86/misc.c +++ b/reactos/ntoskrnl/hal/x86/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.7 2001/01/14 15:36:55 ekohl Exp $ +/* $Id: misc.c,v 1.8 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -10,7 +10,7 @@ /* INCLUDES *****************************************************************/ #include -#include +#include /* FUNCTIONS ****************************************************************/ diff --git a/reactos/ntoskrnl/hal/x86/pci.c b/reactos/ntoskrnl/hal/x86/pci.c index 0623d883a19..e05ceddafb6 100644 --- a/reactos/ntoskrnl/hal/x86/pci.c +++ b/reactos/ntoskrnl/hal/x86/pci.c @@ -1,4 +1,4 @@ -/* $Id: pci.c,v 1.5 2000/08/17 17:42:53 ekohl Exp $ +/* $Id: pci.c,v 1.6 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -18,7 +18,6 @@ /* INCLUDES ***************************************************************/ #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/hal/x86/reboot.c b/reactos/ntoskrnl/hal/x86/reboot.c index a76cfe27ca1..2e8ccf28195 100644 --- a/reactos/ntoskrnl/hal/x86/reboot.c +++ b/reactos/ntoskrnl/hal/x86/reboot.c @@ -1,4 +1,4 @@ -/* $Id: reboot.c,v 1.6 2000/10/08 12:46:31 ekohl Exp $ +/* $Id: reboot.c,v 1.7 2001/03/16 18:11:21 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -11,7 +11,7 @@ #include -#include +#include static VOID diff --git a/reactos/ntoskrnl/hal/x86/udelay.c b/reactos/ntoskrnl/hal/x86/udelay.c index 42d9e8bac28..9d3b104dbad 100644 --- a/reactos/ntoskrnl/hal/x86/udelay.c +++ b/reactos/ntoskrnl/hal/x86/udelay.c @@ -20,7 +20,7 @@ * MA 02139, USA. * */ -/* $Id: udelay.c,v 1.6 2001/02/20 14:43:46 dwelch Exp $ +/* $Id: udelay.c,v 1.7 2001/03/16 18:11:21 dwelch Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/hal/x86/udelay.c @@ -33,7 +33,6 @@ /* INCLUDES ***************************************************************/ #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/include/internal/arch/mm.h b/reactos/ntoskrnl/include/internal/arch/mm.h new file mode 100644 index 00000000000..a10cbef26eb --- /dev/null +++ b/reactos/ntoskrnl/include/internal/arch/mm.h @@ -0,0 +1,10 @@ +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H +#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H + +#ifdef i386 +#include +#else +#error "Unknown processor" +#endif + +#endif /* __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H */ diff --git a/reactos/ntoskrnl/include/internal/debug.h b/reactos/ntoskrnl/include/internal/debug.h index 51484cd5dad..1a358673d91 100644 --- a/reactos/ntoskrnl/include/internal/debug.h +++ b/reactos/ntoskrnl/include/internal/debug.h @@ -65,36 +65,4 @@ extern unsigned int old_idt_valid; #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x)) #define assert_irql(x) assert(KeGetCurrentIrql()<=(x)) -#define HBP_EXECUTE (0) -#define HBP_WRITE (1) -#define HBP_READWRITE (3) - -#define HBP_BYTE (0) -#define HBP_WORD (1) -#define HBP_DWORD (3) - -/* - * FUNCTION: Sets a hardware breakpoint - * ARGUMENTS: - * i = breakpoint to set (0 to 3) - * addr = linear address to break on - * type = Type of access to break on - * len = length of the variable to watch - * NOTES: - * The variable to watch must be aligned to its length (i.e. a dword - * breakpoint must be aligned to a dword boundary) - * - * A fatal exception will be generated on the access to the variable. - * It is (at the moment) only really useful for catching undefined - * pointers if you know the variable effected but not the buggy - * routine. - * - * FIXME: Extend to call out to kernel debugger on breakpoint - * Add support for I/O breakpoints - * REFERENCES: See the i386 programmer manual for more details - */ -void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type, - unsigned int len); - - #endif /* __INTERNAL_DEBUG */ diff --git a/reactos/ntoskrnl/include/internal/dma.h b/reactos/ntoskrnl/include/internal/dma.h deleted file mode 100644 index 9c0dcea2eb1..00000000000 --- a/reactos/ntoskrnl/include/internal/dma.h +++ /dev/null @@ -1,267 +0,0 @@ -/* $Id: dma.h,v 1.1 2000/06/29 23:35:36 dwelch Exp $ - * linux/include/asm/dma.h: Defines for using and allocating dma channels. - * Written by Hennus Bergman, 1992. - * High DMA channel support & info by Hannu Savolainen - * and John Boyd, Nov. 1992. - */ - -#ifndef _ASM_DMA_H -#define _ASM_DMA_H - -#include /* need byte IO */ - - -#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER -#define dma_outb outb_p -#else -#define dma_outb outb -#endif - -#define dma_inb inb - -/* - * NOTES about DMA transfers: - * - * controller 1: channels 0-3, byte operations, ports 00-1F - * controller 2: channels 4-7, word operations, ports C0-DF - * - * - ALL registers are 8 bits only, regardless of transfer size - * - channel 4 is not used - cascades 1 into 2. - * - channels 0-3 are byte - addresses/counts are for physical bytes - * - channels 5-7 are word - addresses/counts are for physical words - * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries - * - transfer count loaded to registers is 1 less than actual count - * - controller 2 offsets are all even (2x offsets for controller 1) - * - page registers for 5-7 don't use data bit 0, represent 128K pages - * - page registers for 0-3 use bit 0, represent 64K pages - * - * DMA transfers are limited to the lower 16MB of _physical_ memory. - * Note that addresses loaded into registers must be _physical_ addresses, - * not logical addresses (which may differ if paging is active). - * - * Address mapping for channels 0-3: - * - * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses) - * | ... | | ... | | ... | - * | ... | | ... | | ... | - * | ... | | ... | | ... | - * P7 ... P0 A7 ... A0 A7 ... A0 - * | Page | Addr MSB | Addr LSB | (DMA registers) - * - * Address mapping for channels 5-7: - * - * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses) - * | ... | \ \ ... \ \ \ ... \ \ - * | ... | \ \ ... \ \ \ ... \ (not used) - * | ... | \ \ ... \ \ \ ... \ - * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0 - * | Page | Addr MSB | Addr LSB | (DMA registers) - * - * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses - * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at - * the hardware level, so odd-byte transfers aren't possible). - * - * Transfer count (_not # bytes_) is limited to 64K, represented as actual - * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more, - * and up to 128K bytes may be transferred on channels 5-7 in one operation. - * - */ - -#define MAX_DMA_CHANNELS 8 - -/* The maximum address that we can perform a DMA transfer to on this platform */ -#define MAX_DMA_ADDRESS 0x1000000 - -/* 8237 DMA controllers */ -#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ -#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ - -/* DMA controller registers */ -#define DMA1_CMD_REG 0x08 /* command register (w) */ -#define DMA1_STAT_REG 0x08 /* status register (r) */ -#define DMA1_REQ_REG 0x09 /* request register (w) */ -#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ -#define DMA1_MODE_REG 0x0B /* mode register (w) */ -#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ -#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ -#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ -#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ -#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ - -#define DMA2_CMD_REG 0xD0 /* command register (w) */ -#define DMA2_STAT_REG 0xD0 /* status register (r) */ -#define DMA2_REQ_REG 0xD2 /* request register (w) */ -#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ -#define DMA2_MODE_REG 0xD6 /* mode register (w) */ -#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ -#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ -#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ -#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ -#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ - -#define DMA_ADDR_0 0x00 /* DMA address registers */ -#define DMA_ADDR_1 0x02 -#define DMA_ADDR_2 0x04 -#define DMA_ADDR_3 0x06 -#define DMA_ADDR_4 0xC0 -#define DMA_ADDR_5 0xC4 -#define DMA_ADDR_6 0xC8 -#define DMA_ADDR_7 0xCC - -#define DMA_CNT_0 0x01 /* DMA count registers */ -#define DMA_CNT_1 0x03 -#define DMA_CNT_2 0x05 -#define DMA_CNT_3 0x07 -#define DMA_CNT_4 0xC2 -#define DMA_CNT_5 0xC6 -#define DMA_CNT_6 0xCA -#define DMA_CNT_7 0xCE - -#define DMA_PAGE_0 0x87 /* DMA page registers */ -#define DMA_PAGE_1 0x83 -#define DMA_PAGE_2 0x81 -#define DMA_PAGE_3 0x82 -#define DMA_PAGE_5 0x8B -#define DMA_PAGE_6 0x89 -#define DMA_PAGE_7 0x8A - -#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ -#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ -#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ - -/* enable/disable a specific DMA channel */ -static __inline__ void enable_dma(unsigned int dmanr) -{ - if (dmanr<=3) - dma_outb(DMA1_MASK_REG, dmanr); - else - dma_outb(DMA2_MASK_REG, dmanr & 3); -} - -static __inline__ void disable_dma(unsigned int dmanr) -{ - if (dmanr<=3) - dma_outb(DMA1_MASK_REG, dmanr | 4); - else - dma_outb(DMA2_MASK_REG, (dmanr & 3) | 4); -} - -/* Clear the 'DMA Pointer Flip Flop'. - * Write 0 for LSB/MSB, 1 for MSB/LSB access. - * Use this once to initialize the FF to a known state. - * After that, keep track of it. :-) - * --- In order to do that, the DMA routines below should --- - * --- only be used while interrupts are disabled! --- - */ -static __inline__ void clear_dma_ff(unsigned int dmanr) -{ - if (dmanr<=3) - dma_outb(DMA1_CLEAR_FF_REG, 0); - else - dma_outb(DMA2_CLEAR_FF_REG, 0); -} - -/* set mode (above) for a specific DMA channel */ -static __inline__ void set_dma_mode(unsigned int dmanr, char mode) -{ - if (dmanr<=3) - dma_outb(DMA1_MODE_REG, mode | dmanr); - else - dma_outb(DMA2_MODE_REG, mode | (dmanr&3)); -} - -/* Set only the page register bits of the transfer address. - * This is used for successive transfers when we know the contents of - * the lower 16 bits of the DMA current address register, but a 64k boundary - * may have been crossed. - */ -static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) -{ - switch(dmanr) { - case 0: - dma_outb(DMA_PAGE_0, pagenr); - break; - case 1: - dma_outb(DMA_PAGE_1, pagenr); - break; - case 2: - dma_outb(DMA_PAGE_2, pagenr); - break; - case 3: - dma_outb(DMA_PAGE_3, pagenr); - break; - case 5: - dma_outb(DMA_PAGE_5, pagenr & 0xfe); - break; - case 6: - dma_outb(DMA_PAGE_6, pagenr & 0xfe); - break; - case 7: - dma_outb(DMA_PAGE_7, pagenr & 0xfe); - break; - } -} - - -/* Set transfer address & page bits for specific DMA channel. - * Assumes dma flipflop is clear. - */ -static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) -{ - set_dma_page(dmanr, a>>16); - if (dmanr <= 3) { - dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, a & 0xff); - dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, (a>>8) & 0xff ); - } else { - dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE ,(a>>1) & 0xff ); - dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE,(a>>9) & 0xff ); - } -} - - -/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for - * a specific DMA channel. - * You must ensure the parameters are valid. - * NOTE: from a manual: "the number of transfers is one more - * than the initial word count"! This is taken into account. - * Assumes dma flip-flop is clear. - * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. - */ -static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) -{ - count--; - if (dmanr <= 3) { - dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); - dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE ); - } else { - dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); - dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE ); - } -} - - -/* Get DMA residue count. After a DMA transfer, this - * should return zero. Reading this while a DMA transfer is - * still in progress will return unpredictable results. - * If called before the channel has been used, it may return 1. - * Otherwise, it returns the number of _bytes_ left to transfer. - * - * Assumes DMA flip-flop is clear. - */ -static __inline__ int get_dma_residue(unsigned int dmanr) -{ - unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE - : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE; - - /* using short to get 16-bit wrap around */ - unsigned short count; - - count = 1 + dma_inb(io_port); - count += dma_inb(io_port) << 8; - - return (dmanr<=3)? count : (count<<1); -} - - - -#endif /* _ASM_DMA_H */ diff --git a/reactos/ntoskrnl/include/internal/hal.h b/reactos/ntoskrnl/include/internal/hal.h deleted file mode 100644 index 5218b7dd302..00000000000 --- a/reactos/ntoskrnl/include/internal/hal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __INCLUDE_INTERNAL_HAL_H -#define __INCLUDE_INTERNAL_HAL_H - -#ifdef i386 -#include -#else -#error "Unknown processor" -#endif - -#endif diff --git a/reactos/ntoskrnl/include/internal/i386/hal.h b/reactos/ntoskrnl/include/internal/hal/hal.h similarity index 100% rename from reactos/ntoskrnl/include/internal/i386/hal.h rename to reactos/ntoskrnl/include/internal/hal/hal.h diff --git a/reactos/ntoskrnl/include/internal/hal/irq.h b/reactos/ntoskrnl/include/internal/hal/irq.h deleted file mode 100644 index db7ef233785..00000000000 --- a/reactos/ntoskrnl/include/internal/hal/irq.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * PURPOSE: The number of device specific level levels - */ -#define NR_DEVICE_SPECIFIC_LEVELS (16) - - - diff --git a/reactos/ntoskrnl/include/internal/hal/page.h b/reactos/ntoskrnl/include/internal/hal/page.h deleted file mode 100644 index 0c975e935a5..00000000000 --- a/reactos/ntoskrnl/include/internal/hal/page.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Lowlevel memory managment definitions - */ - -#ifndef __INTERNAL_HAL_PAGE_H -#define __INTERNAL_HAL_PAGE_H - -#include - -#define PAGESIZE (4096) - -/* - * Sets a page entry - * vaddr: The virtual address to set the page entry for - * attributes: The access attributes to give the page - * physaddr: The physical address the page should map to - */ -void set_page(unsigned int vaddr, unsigned int attributes, - unsigned int physaddr); - -#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) ) -#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff)) - -/* - * Page access attributes (or these together) - */ -#define PA_READ (1<<0) -#define PA_WRITE ((1<<0)+(1<<1)) -#define PA_EXECUTE PA_READ -#define PA_PCD (1<<4) -#define PA_PWT (1<<3) - -/* - * Page attributes - */ -#define PA_USER (1<<2) -#define PA_SYSTEM (0) - -#define KERNEL_BASE (0xc0000000) - - - -#define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t") - - -/* - * Amount of memory that can be mapped by a page table - */ -#define PAGE_TABLE_SIZE (4*1024*1024) - -#define PAGE_MASK(x) (x&(~0xfff)) -#define VADDR_TO_PT_OFFSET(x) (((x/1024)%4096)) -#define VADDR_TO_PD_OFFSET(x) ((x)/(4*1024*1024)) - -unsigned int* get_page_entry(unsigned int vaddr); - -BOOL is_page_present(unsigned int vaddr); - -#endif /* __INTERNAL_HAL_PAGE_H */ diff --git a/reactos/ntoskrnl/include/internal/hal/segment.h b/reactos/ntoskrnl/include/internal/hal/segment.h deleted file mode 100644 index 32201ddf93f..00000000000 --- a/reactos/ntoskrnl/include/internal/hal/segment.h +++ /dev/null @@ -1,343 +0,0 @@ -#ifndef _ASM_SEGMENT_H -#define _ASM_SEGMENT_H - -#define ZERO_DS 0x18 -#define KERNEL_CS 0x20 -#define KERNEL_DS 0x28 - -#ifndef __ASSEMBLY__ - -/* - * Uh, these should become the main single-value transfer routines.. - * They automatically use the right size if we just have the right - * pointer type.. - */ -#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))) -#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))) - -/* - * This is a silly but good way to make sure that - * the __put_user function is indeed always optimized, - * and that we use the correct sizes.. - */ -extern int bad_user_access_length(void); - -/* - * dummy pointer type structure.. gcc won't try to do something strange - * this way.. - */ -struct __segment_dummy { unsigned long a[100]; }; -#define __sd(x) ((struct __segment_dummy *) (x)) -#define __const_sd(x) ((const struct __segment_dummy *) (x)) - -static inline void __put_user(unsigned long x, void * y, int size) -{ - switch (size) { - case 1: - __asm__ ("movb %b1,%%fs:%0" - :"=m" (*__sd(y)) - :"iq" ((unsigned char) x), "m" (*__sd(y))); - break; - case 2: - __asm__ ("movw %w1,%%fs:%0" - :"=m" (*__sd(y)) - :"ir" ((unsigned short) x), "m" (*__sd(y))); - break; - case 4: - __asm__ ("movl %1,%%fs:%0" - :"=m" (*__sd(y)) - :"ir" (x), "m" (*__sd(y))); - break; - default: - bad_user_access_length(); - } -} - -static inline unsigned long __get_user(const void * y, int size) -{ - unsigned long result; - - switch (size) { - case 1: - __asm__ ("movb %%fs:%1,%b0" - :"=q" (result) - :"m" (*__const_sd(y))); - return (unsigned char) result; - case 2: - __asm__ ("movw %%fs:%1,%w0" - :"=r" (result) - :"m" (*__const_sd(y))); - return (unsigned short) result; - case 4: - __asm__ ("movl %%fs:%1,%0" - :"=r" (result) - :"m" (*__const_sd(y))); - return result; - default: - return bad_user_access_length(); - } -} - -static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n) -{ - __asm__ volatile - (" cld - push %%es - push %%fs - cmpl $3,%0 - pop %%es - jbe 1f - movl %%edi,%%ecx - negl %%ecx - andl $3,%%ecx - subl %%ecx,%0 - rep; movsb - movl %0,%%ecx - shrl $2,%%ecx - rep; movsl - andl $3,%0 - 1: movl %0,%%ecx - rep; movsb - pop %%es" - :"=abd" (n) - :"0" (n),"D" ((long) to),"S" ((long) from) - :"cx","di","si"); -} - -static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n) -{ - switch (n) { - case 0: - return; - case 1: - __put_user(*(const char *) from, (char *) to, 1); - return; - case 2: - __put_user(*(const short *) from, (short *) to, 2); - return; - case 3: - __put_user(*(const short *) from, (short *) to, 2); - __put_user(*(2+(const char *) from), 2+(char *) to, 1); - return; - case 4: - __put_user(*(const int *) from, (int *) to, 4); - return; - case 8: - __put_user(*(const int *) from, (int *) to, 4); - __put_user(*(1+(const int *) from), 1+(int *) to, 4); - return; - case 12: - __put_user(*(const int *) from, (int *) to, 4); - __put_user(*(1+(const int *) from), 1+(int *) to, 4); - __put_user(*(2+(const int *) from), 2+(int *) to, 4); - return; - case 16: - __put_user(*(const int *) from, (int *) to, 4); - __put_user(*(1+(const int *) from), 1+(int *) to, 4); - __put_user(*(2+(const int *) from), 2+(int *) to, 4); - __put_user(*(3+(const int *) from), 3+(int *) to, 4); - return; - } -#define COMMON(x) \ -__asm__("cld\n\t" \ - "push %%es\n\t" \ - "push %%fs\n\t" \ - "pop %%es\n\t" \ - "rep ; movsl\n\t" \ - x \ - "pop %%es" \ - : /* no outputs */ \ - :"c" (n/4),"D" ((long) to),"S" ((long) from) \ - :"cx","di","si") - - switch (n % 4) { - case 0: - COMMON(""); - return; - case 1: - COMMON("movsb\n\t"); - return; - case 2: - COMMON("movsw\n\t"); - return; - case 3: - COMMON("movsw\n\tmovsb\n\t"); - return; - } -#undef COMMON -} - -static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n) -{ - __asm__ volatile - (" cld - cmpl $3,%0 - jbe 1f - movl %%edi,%%ecx - negl %%ecx - andl $3,%%ecx - subl %%ecx,%0 - fs; rep; movsb - movl %0,%%ecx - shrl $2,%%ecx - fs; rep; movsl - andl $3,%0 - 1: movl %0,%%ecx - fs; rep; movsb" - :"=abd" (n) - :"0" (n),"D" ((long) to),"S" ((long) from) - :"cx","di","si", "memory"); -} - -static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n) -{ - switch (n) { - case 0: - return; - case 1: - *(char *)to = __get_user((const char *) from, 1); - return; - case 2: - *(short *)to = __get_user((const short *) from, 2); - return; - case 3: - *(short *) to = __get_user((const short *) from, 2); - *((char *) to + 2) = __get_user(2+(const char *) from, 1); - return; - case 4: - *(int *) to = __get_user((const int *) from, 4); - return; - case 8: - *(int *) to = __get_user((const int *) from, 4); - *(1+(int *) to) = __get_user(1+(const int *) from, 4); - return; - case 12: - *(int *) to = __get_user((const int *) from, 4); - *(1+(int *) to) = __get_user(1+(const int *) from, 4); - *(2+(int *) to) = __get_user(2+(const int *) from, 4); - return; - case 16: - *(int *) to = __get_user((const int *) from, 4); - *(1+(int *) to) = __get_user(1+(const int *) from, 4); - *(2+(int *) to) = __get_user(2+(const int *) from, 4); - *(3+(int *) to) = __get_user(3+(const int *) from, 4); - return; - } -#define COMMON(x) \ -__asm__("cld\n\t" \ - "rep ; fs ; movsl\n\t" \ - x \ - : /* no outputs */ \ - :"c" (n/4),"D" ((long) to),"S" ((long) from) \ - :"cx","di","si","memory") - - switch (n % 4) { - case 0: - COMMON(""); - return; - case 1: - COMMON("fs ; movsb"); - return; - case 2: - COMMON("fs ; movsw"); - return; - case 3: - COMMON("fs ; movsw\n\tfs ; movsb"); - return; - } -#undef COMMON -} - -#define memcpy_fromfs(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy_fromfs((to),(from),(n)) : \ - __generic_memcpy_fromfs((to),(from),(n))) - -#define memcpy_tofs(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy_tofs((to),(from),(n)) : \ - __generic_memcpy_tofs((to),(from),(n))) - -/* - * These are deprecated.. - * - * Use "put_user()" and "get_user()" with the proper pointer types instead. - */ - -#define get_fs_byte(addr) __get_user((const unsigned char *)(addr),1) -#define get_fs_word(addr) __get_user((const unsigned short *)(addr),2) -#define get_fs_long(addr) __get_user((const unsigned int *)(addr),4) - -#define put_fs_byte(x,addr) __put_user((x),(unsigned char *)(addr),1) -#define put_fs_word(x,addr) __put_user((x),(unsigned short *)(addr),2) -#define put_fs_long(x,addr) __put_user((x),(unsigned int *)(addr),4) - -#ifdef WE_REALLY_WANT_TO_USE_A_BROKEN_INTERFACE - -static inline unsigned short get_user_word(const short *addr) -{ - return __get_user(addr, 2); -} - -static inline unsigned char get_user_byte(const char * addr) -{ - return __get_user(addr,1); -} - -static inline unsigned long get_user_long(const int *addr) -{ - return __get_user(addr, 4); -} - -static inline void put_user_byte(char val,char *addr) -{ - __put_user(val, addr, 1); -} - -static inline void put_user_word(short val,short * addr) -{ - __put_user(val, addr, 2); -} - -static inline void put_user_long(unsigned long val,int * addr) -{ - __put_user(val, addr, 4); -} - -#endif - -/* - * Someone who knows GNU asm better than I should double check the following. - * It seems to work, but I don't know if I'm doing something subtly wrong. - * --- TYT, 11/24/91 - * [ nothing wrong here, Linus: I just changed the ax to be any reg ] - */ - -static inline unsigned long get_fs(void) -{ - unsigned long _v; - __asm__("mov %%fs,%w0":"=r" (_v):"0" (0)); - return _v; -} - -static inline unsigned long get_ds(void) -{ - unsigned long _v; - __asm__("mov %%ds,%w0":"=r" (_v):"0" (0)); - return _v; -} - -static inline void set_fs(unsigned long val) -{ - __asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val)); -} - -static inline void set_ds(unsigned long val) -{ - __asm__ __volatile__("mov %w0,%%ds": /* no output */ :"r" (val)); -} - - -#endif /* __ASSEMBLY__ */ - -#endif /* _ASM_SEGMENT_H */ diff --git a/reactos/ntoskrnl/include/internal/i386/mmhal.h b/reactos/ntoskrnl/include/internal/i386/mm.h similarity index 90% rename from reactos/ntoskrnl/include/internal/i386/mmhal.h rename to reactos/ntoskrnl/include/internal/i386/mm.h index 711cc344602..78de226e7dc 100644 --- a/reactos/ntoskrnl/include/internal/i386/mmhal.h +++ b/reactos/ntoskrnl/include/internal/i386/mm.h @@ -2,8 +2,8 @@ * Lowlevel memory managment definitions */ -#ifndef __INTERNAL_HAL_I386_MMHAL_H -#define __INTERNAL_HAL_I386_MMHAL_H +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H +#define __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H struct _EPROCESS; @@ -66,4 +66,4 @@ VOID MmSetPageProtect(struct _EPROCESS* Process, BOOLEAN MmIsPagePresent(struct _EPROCESS* Process, PVOID Address); -#endif /* __INTERNAL_HAL_I386_MMHAL_H */ +#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H */ diff --git a/reactos/ntoskrnl/include/internal/i386/segment.h b/reactos/ntoskrnl/include/internal/i386/segment.h index aec35708d8b..68c81a65111 100644 --- a/reactos/ntoskrnl/include/internal/i386/segment.h +++ b/reactos/ntoskrnl/include/internal/i386/segment.h @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 @@ -43,3 +43,7 @@ #define LDT_SELECTOR (0x48) #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H */ + + + + diff --git a/reactos/ntoskrnl/include/internal/i386/segment.inc b/reactos/ntoskrnl/include/internal/i386/segment.inc deleted file mode 100644 index a39c1e6997a..00000000000 --- a/reactos/ntoskrnl/include/internal/i386/segment.inc +++ /dev/null @@ -1,6 +0,0 @@ -; -; Useful prototypes and definitions -; - -%define KERNEL_DS 028h -%define KERNEL_CS 020h diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 087c90f1aa6..14b48b3561d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -6,7 +6,7 @@ #define __INCLUDE_INTERNAL_MM_H #include -#include +#include /* TYPES *********************************************************************/ diff --git a/reactos/ntoskrnl/include/internal/mmhal.h b/reactos/ntoskrnl/include/internal/mmhal.h deleted file mode 100644 index fbeb3ec1459..00000000000 --- a/reactos/ntoskrnl/include/internal/mmhal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __INCLUDE_INTERNAL_MMHAL_H -#define __INCLUDE_INTERNAL_MMHAL_H - -#ifdef i386 -#include -#else -#error "Unknown processor" -#endif - -#endif /* __INCLUDE_INTERNAL_MMHAL_H */ diff --git a/reactos/ntoskrnl/include/internal/ps.h b/reactos/ntoskrnl/include/internal/ps.h index b976bd636da..8902e3dffb4 100644 --- a/reactos/ntoskrnl/include/internal/ps.h +++ b/reactos/ntoskrnl/include/internal/ps.h @@ -47,7 +47,6 @@ #ifndef __ASM__ -#include #include struct _KTHREAD; diff --git a/reactos/ntoskrnl/include/internal/psmgr.h b/reactos/ntoskrnl/include/internal/psmgr.h deleted file mode 100644 index 94ff7abad37..00000000000 --- a/reactos/ntoskrnl/include/internal/psmgr.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef __INCLUDE_INTERNAL_PSMGR_H -#define __INCLUDE_INTERNAL_PSMGR_H - -#include - -extern HANDLE SystemProcessHandle; - -void PsInitThreadManagment(void); -VOID PsInitIdleThread(VOID); - -/* - * PURPOSE: Thread states - */ -enum -{ - /* - * PURPOSE: Don't touch - */ - THREAD_STATE_INVALID, - - /* - * PURPOSE: Waiting to be dispatched - */ - THREAD_STATE_RUNNABLE, - - /* - * PURPOSE: Currently running - */ - THREAD_STATE_RUNNING, - - /* - * PURPOSE: Doesn't want to run - */ - THREAD_STATE_SUSPENDED, - - /* - * Waiting to be freed - */ - THREAD_STATE_TERMINATED, -}; - -/* - * Functions the HAL must provide - */ - -void HalInitFirstTask(PKTHREAD thread); -BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn, - PVOID StartContext); -void HalTaskSwitch(PKTHREAD thread); - -#endif diff --git a/reactos/ntoskrnl/include/internal/types.h b/reactos/ntoskrnl/include/internal/types.h deleted file mode 100644 index 01f87261442..00000000000 --- a/reactos/ntoskrnl/include/internal/types.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _LINUX_TYPES_H -#define _LINUX_TYPES_H - -#endif diff --git a/reactos/ntoskrnl/include/internal/wait.h b/reactos/ntoskrnl/include/internal/wait.h deleted file mode 100644 index 22d97cbe62d..00000000000 --- a/reactos/ntoskrnl/include/internal/wait.h +++ /dev/null @@ -1,2 +0,0 @@ -extern KSPIN_LOCK DispatcherDatabaseLock; -extern BOOLEAN WaitSet; diff --git a/reactos/ntoskrnl/io/mdl.c b/reactos/ntoskrnl/io/mdl.c index 90558de7ace..f7e07579d23 100644 --- a/reactos/ntoskrnl/io/mdl.c +++ b/reactos/ntoskrnl/io/mdl.c @@ -1,4 +1,4 @@ -/* $Id: mdl.c,v 1.7 2001/03/16 16:05:33 dwelch Exp $ +/* $Id: mdl.c,v 1.8 2001/03/16 18:11:22 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,7 +12,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #include diff --git a/reactos/ntoskrnl/ke/catch.c b/reactos/ntoskrnl/ke/catch.c index b4235c7d3a6..b82fa4a363b 100644 --- a/reactos/ntoskrnl/ke/catch.c +++ b/reactos/ntoskrnl/ke/catch.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: catch.c,v 1.9 2001/02/21 18:17:57 ekohl Exp $ +/* $Id: catch.c,v 1.10 2001/03/16 18:11:22 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel diff --git a/reactos/ntoskrnl/ke/i386/bios.c b/reactos/ntoskrnl/ke/i386/bios.c index dc2a2043e29..76bfce0f9d9 100644 --- a/reactos/ntoskrnl/ke/i386/bios.c +++ b/reactos/ntoskrnl/ke/i386/bios.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index 3edea094e68..38d5fda5f74 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -1,7 +1,24 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* * PROJECT: ReactOS kernel - * FILE: ntoskrnl/hal/x86/exp.c + * FILE: ntoskrnl/ke/i386/exp.c * PURPOSE: Handling exceptions * PROGRAMMER: David Welch (welch@cwcom.net) * REVISION HISTORY: @@ -14,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reactos/ntoskrnl/ke/i386/gdt.c b/reactos/ntoskrnl/ke/i386/gdt.c index ce56df63661..a3b42df9d4d 100644 --- a/reactos/ntoskrnl/ke/i386/gdt.c +++ b/reactos/ntoskrnl/ke/i386/gdt.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 diff --git a/reactos/ntoskrnl/ke/i386/thread.c b/reactos/ntoskrnl/ke/i386/thread.c index b5084641f77..4d769fef208 100644 --- a/reactos/ntoskrnl/ke/i386/thread.c +++ b/reactos/ntoskrnl/ke/i386/thread.c @@ -13,9 +13,8 @@ #include #include #include -#include #include -#include +#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/ke/i386/usercall.c b/reactos/ntoskrnl/ke/i386/usercall.c index 16068ea22e6..d7d64c9fea4 100644 --- a/reactos/ntoskrnl/ke/i386/usercall.c +++ b/reactos/ntoskrnl/ke/i386/usercall.c @@ -1,4 +1,4 @@ -/* $Id: usercall.c,v 1.19 2001/02/06 00:11:19 dwelch Exp $ +/* $Id: usercall.c,v 1.20 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -16,7 +16,7 @@ #include #include #include -#include +#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/ke/i386/v86m.c b/reactos/ntoskrnl/ke/i386/v86m.c index 63f78bec44a..a2205eead37 100644 --- a/reactos/ntoskrnl/ke/i386/v86m.c +++ b/reactos/ntoskrnl/ke/i386/v86m.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 diff --git a/reactos/ntoskrnl/ke/kthread.c b/reactos/ntoskrnl/ke/kthread.c index 3e15e39afec..2cb08f4ae77 100644 --- a/reactos/ntoskrnl/ke/kthread.c +++ b/reactos/ntoskrnl/ke/kthread.c @@ -1,6 +1,6 @@ /* * ReactOS kernel - * Copyright (C) 2000 David Welch + * Copyright (C) 2000 ReactOS Team * * 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 diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index f8642d9b563..b6962615e67 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -1,6 +1,23 @@ -/* $Id: main.c,v 1.79 2001/02/14 02:53:53 dwelch Exp $ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: main.c,v 1.80 2001/03/16 18:11:23 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c * PURPOSE: Initalizes the kernel @@ -19,11 +36,8 @@ #include #include #include -#include #include #include -#include -#include #include #include #include diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 31df17672ce..2270d7d4607 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -1,4 +1,4 @@ -/* $Id: loader.c,v 1.68 2001/03/07 16:48:43 dwelch Exp $ +/* $Id: loader.c,v 1.69 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/ldr/pedump.c b/reactos/ntoskrnl/ldr/pedump.c deleted file mode 100644 index 3c56286c79f..00000000000 --- a/reactos/ntoskrnl/ldr/pedump.c +++ /dev/null @@ -1,3490 +0,0 @@ -// -// -// This program was written by Sang Cho, assistant professor at -// the department of -// computer science and engineering -// chongju university -// this program is based on the program pefile.c -// which is written by Randy Kath(Microsoft Developmer Network Technology Group) -// in june 12, 1993. -// I have investigated P.E. file format as thoroughly as possible, -// but I cannot claim that I am an expert yet, so some of its information -// may give you wrong results. -// -// -// -// language used: djgpp -// date of creation: September 28, 1997 -// -// date of first release: October 15, 1997 -// -// -// you can contact me: e-mail address: sangcho@alpha94.chongju.ac.kr -// hitel id: chokhas -// phone number: (0431) 229-8491 +82-431-229-8491 -// -// real address: Sang Cho -// Computer and Information Engineering -// ChongJu University -// NaeDok-Dong 36 -// ChongJu 360-764 -// South Korea -// -// Copyright (C) 1997. by Sang Cho. -// -// Permission is granted to make and distribute verbatim copies of this -// program provided the copyright notice and this permission notice are -// preserved on all copies. -// -// -// File: pedump.c ( I included header file into source file. ) - -//# include "ccx.h" - -//typedef char CHAR; -//typedef short WCHAR; -//typedef short SHORT; -//typedef long LONG; -//typedef unsigned short USHORT; -//typedef unsigned long DWORD; -//typedef int BOOL; -//typedef unsigned char BYTE; -//typedef unsigned short WORD; -//typedef BYTE *PBYTE; -//typedef WORD *PWORD; -//typedef DWORD *PDWORD; -//typedef void *LPVOID; - -#define VOID void -#define BOOLEAN boolean -#define NULL 0 -#define FALSE 0 -#define TRUE 1 -#define CONST const -#define LOWORD(l) ((WORD)(l)) -#define WINAPI - -// -// Image Format -// - -#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ -#define IMAGE_OS2_SIGNATURE 0x454E // NE -#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE -#define IMAGE_VXD_SIGNATURE 0x454C // LE -#define IMAGE_NT_SIGNATURE 0x00004550 // PE00 - -typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header - WORD e_magic; // Magic number - WORD e_cblp; // Bytes on last page of file - WORD e_cp; // Pages in file - WORD e_crlc; // Relocations - WORD e_cparhdr; // Size of header in paragraphs - WORD e_minalloc; // Minimum extra paragraphs needed - WORD e_maxalloc; // Maximum extra paragraphs needed - WORD e_ss; // Initial (relative) SS value - WORD e_sp; // Initial SP value - WORD e_csum; // Checksum - WORD e_ip; // Initial IP value - WORD e_cs; // Initial (relative) CS value - WORD e_lfarlc; // File address of relocation table - WORD e_ovno; // Overlay number - WORD e_res[4]; // Reserved words - WORD e_oemid; // OEM identifier (for e_oeminfo) - WORD e_oeminfo; // OEM information; e_oemid specific - WORD e_res2[10]; // Reserved words - LONG e_lfanew; // File address of new exe header - } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; - -// -// File header format. -// - - - -typedef struct _IMAGE_FILE_HEADER { - WORD Machine; - WORD NumberOfSections; - DWORD TimeDateStamp; - DWORD PointerToSymbolTable; - DWORD NumberOfSymbols; - WORD SizeOfOptionalHeader; - WORD Characteristics; -} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; - -#define IMAGE_SIZEOF_FILE_HEADER 20 - -#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. -#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). -#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. -#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. -#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. -#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. -#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file -#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 // If Image is on removable media, copy and run from the swap file. -#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 // If Image is on Net, copy and run from the swap file. -#define IMAGE_FILE_SYSTEM 0x1000 // System File. -#define IMAGE_FILE_DLL 0x2000 // File is a DLL. -#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 // File should only be run on a UP machine -#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. - -#define IMAGE_FILE_MACHINE_UNKNOWN 0 -#define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. -#define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0x160 big-endian -#define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian -#define IMAGE_FILE_MACHINE_R10000 0x168 // MIPS little-endian -#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP -#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian - - - -// -// Directory format. -// - -typedef struct _IMAGE_DATA_DIRECTORY { - DWORD VirtualAddress; - DWORD Size; -} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; - -#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 - -// -// Optional header format. -// - -typedef struct _IMAGE_OPTIONAL_HEADER { - // - // Standard fields. - // - - WORD Magic; - BYTE MajorLinkerVersion; - BYTE MinorLinkerVersion; - DWORD SizeOfCode; - DWORD SizeOfInitializedData; - DWORD SizeOfUninitializedData; - DWORD AddressOfEntryPoint; - DWORD BaseOfCode; - DWORD BaseOfData; - - // - // NT additional fields. - // - - DWORD ImageBase; - DWORD SectionAlignment; - DWORD FileAlignment; - WORD MajorOperatingSystemVersion; - WORD MinorOperatingSystemVersion; - WORD MajorImageVersion; - WORD MinorImageVersion; - WORD MajorSubsystemVersion; - WORD MinorSubsystemVersion; - DWORD Win32VersionValue; - DWORD SizeOfImage; - DWORD SizeOfHeaders; - DWORD CheckSum; - WORD Subsystem; - WORD DllCharacteristics; - DWORD SizeOfStackReserve; - DWORD SizeOfStackCommit; - DWORD SizeOfHeapReserve; - DWORD SizeOfHeapCommit; - DWORD LoaderFlags; - DWORD NumberOfRvaAndSizes; - IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; -} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; - - -typedef struct _IMAGE_NT_HEADERS { - DWORD Signature; - IMAGE_FILE_HEADER FileHeader; - IMAGE_OPTIONAL_HEADER OptionalHeader; -} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; - - -// Directory Entries - -#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory -#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory -#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory -#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory -#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory -#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table -#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory -#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String -#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) -#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory -#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory -#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers -#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table - -// -// Section header format. -// - -#define IMAGE_SIZEOF_SHORT_NAME 8 - -typedef struct _IMAGE_SECTION_HEADER { - BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; - union { - DWORD PhysicalAddress; - DWORD VirtualSize; - } Misc; - DWORD VirtualAddress; - DWORD SizeOfRawData; - DWORD PointerToRawData; - DWORD PointerToRelocations; - DWORD PointerToLinenumbers; - WORD NumberOfRelocations; - WORD NumberOfLinenumbers; - DWORD Characteristics; -} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; - -#define IMAGE_SIZEOF_SECTION_HEADER 40 - - -// -// Export Format -// - -typedef struct _IMAGE_EXPORT_DIRECTORY { - DWORD Characteristics; - DWORD TimeDateStamp; - WORD MajorVersion; - WORD MinorVersion; - DWORD Name; - DWORD Base; - DWORD NumberOfFunctions; - DWORD NumberOfNames; - PDWORD *AddressOfFunctions; - PDWORD *AddressOfNames; - PWORD *AddressOfNameOrdinals; -} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; - -// -// Import Format -// - -typedef struct _IMAGE_IMPORT_BY_NAME { - WORD Hint; - BYTE Name[1]; -} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; - -#define IMAGE_ORDINAL_FLAG 0x80000000 -#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) - - -// -// Resource Format. -// - -// -// Resource directory consists of two counts, following by a variable length -// array of directory entries. The first count is the number of entries at -// beginning of the array that have actual names associated with each entry. -// The entries are in ascending order, case insensitive strings. The second -// count is the number of entries that immediately follow the named entries. -// This second count identifies the number of entries that have 16-bit integer -// Ids as their name. These entries are also sorted in ascending order. -// -// This structure allows fast lookup by either name or number, but for any -// given resource entry only one form of lookup is supported, not both. -// This is consistant with the syntax of the .RC file and the .RES file. -// - -// Predefined resource types ... there may be some more, but I don't have -// the information yet. .....sang cho..... - -#define RT_NEWRESOURCE 0x2000 -#define RT_ERROR 0x7fff -#define RT_CURSOR 1 -#define RT_BITMAP 2 -#define RT_ICON 3 -#define RT_MENU 4 -#define RT_DIALOG 5 -#define RT_STRING 6 -#define RT_FONTDIR 7 -#define RT_FONT 8 -#define RT_ACCELERATORS 9 -#define RT_RCDATA 10 -#define RT_MESSAGETABLE 11 -#define RT_GROUP_CURSOR 12 -#define RT_GROUP_ICON 14 -#define RT_VERSION 16 -#define NEWBITMAP (RT_BITMAP|RT_NEWRESOURCE) -#define NEWMENU (RT_MENU|RT_NEWRESOURCE) -#define NEWDIALOG (RT_DIALOG|RT_NEWRESOURCE) - - -typedef struct _IMAGE_RESOURCE_DIRECTORY { - DWORD Characteristics; - DWORD TimeDateStamp; - WORD MajorVersion; - WORD MinorVersion; - WORD NumberOfNamedEntries; - WORD NumberOfIdEntries; -// IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[1]; -} IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY; - -#define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000 -#define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000 - -// -// Each directory contains the 32-bit Name of the entry and an offset, -// relative to the beginning of the resource directory of the data associated -// with this directory entry. If the name of the entry is an actual text -// string instead of an integer Id, then the high order bit of the name field -// is set to one and the low order 31-bits are an offset, relative to the -// beginning of the resource directory of the string, which is of type -// IMAGE_RESOURCE_DIRECTORY_STRING. Otherwise the high bit is clear and the -// low-order 16-bits are the integer Id that identify this resource directory -// entry. If the directory entry is yet another resource directory (i.e. a -// subdirectory), then the high order bit of the offset field will be -// set to indicate this. Otherwise the high bit is clear and the offset -// field points to a resource data entry. -// - -typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { - DWORD Name; - DWORD OffsetToData; -} IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; - -// -// For resource directory entries that have actual string names, the Name -// field of the directory entry points to an object of the following type. -// All of these string objects are stored together after the last resource -// directory entry and before the first resource data object. This minimizes -// the impact of these variable length objects on the alignment of the fixed -// size directory entry objects. -// - -typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING { - WORD Length; - CHAR NameString[ 1 ]; -} IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING; - - -typedef struct _IMAGE_RESOURCE_DIR_STRING_U { - WORD Length; - WCHAR NameString[ 1 ]; -} IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U; - - -// -// Each resource data entry describes a leaf node in the resource directory -// tree. It contains an offset, relative to the beginning of the resource -// directory of the data for the resource, a size field that gives the number -// of bytes of data at that offset, a CodePage that should be used when -// decoding code point values within the resource data. Typically for new -// applications the code page would be the unicode code page. -// - -typedef struct _IMAGE_RESOURCE_DATA_ENTRY { - DWORD OffsetToData; - DWORD Size; - DWORD CodePage; - DWORD Reserved; -} IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY; - - -// Menu Resources ... added by .....sang cho.... - -// Menu resources are composed of a menu header followed by a sequential list -// of menu items. There are two types of menu items: pop-ups and normal menu -// itmes. The MENUITEM SEPARATOR is a special case of a normal menu item with -// an empty name, zero ID, and zero flags. - -typedef struct _IMAGE_MENU_HEADER{ - WORD wVersion; // Currently zero - WORD cbHeaderSize; // Also zero -} IMAGE_MENU_HEADER, *PIMAGE_MENU_HEADER; - -typedef struct _IMAGE_POPUP_MENU_ITEM{ - WORD fItemFlags; - WCHAR szItemText[1]; -} IMAGE_POPUP_MENU_ITEM, *PIMAGE_POPUP_MENU_ITEM; - -typedef struct _IMAGE_NORMAL_MENU_ITEM{ - WORD fItemFlags; - WORD wMenuID; - WCHAR szItemText[1]; -} IMAGE_NORMAL_MENU_ITEM, *PIMAGE_NORMAL_MENU_ITEM; - -#define GRAYED 0x0001 // GRAYED keyword -#define INACTIVE 0x0002 // INACTIVE keyword -#define BITMAP 0x0004 // BITMAP keyword -#define OWNERDRAW 0x0100 // OWNERDRAW keyword -#define CHECKED 0x0008 // CHECKED keyword -#define POPUP 0x0010 // used internally -#define MENUBARBREAK 0x0020 // MENUBARBREAK keyword -#define MENUBREAK 0x0040 // MENUBREAK keyword -#define ENDMENU 0x0080 // used internally - - -// Dialog Box Resources .................. added by sang cho. - -// A dialog box is contained in a single resource and has a header and -// a portion repeated for each control in the dialog box. -// The item DWORD IStyle is a standard window style composed of flags found -// in WINDOWS.H. -// The default style for a dialog box is: -// WS_POPUP | WS_BORDER | WS_SYSMENU -// -// The itme marked "Name or Ordinal" are : -// If the first word is an 0xffff, the next two bytes contain an ordinal ID. -// Otherwise, the first one or more WORDS contain a double-null-terminated string. -// An empty string is represented by a single WORD zero in the first location. -// -// The WORD wPointSize and WCHAR szFontName entries are present if the FONT -// statement was included for the dialog box. This can be detected by checking -// the entry IStyle. If IStyle & DS_SETFONT ( which is 0x40), then these -// entries will be present. - -typedef struct _IMAGE_DIALOG_BOX_HEADER1{ - DWORD IStyle; - DWORD IExtendedStyle; // New for Windows NT - WORD nControls; // Number of Controls - WORD x; - WORD y; - WORD cx; - WORD cy; -// N_OR_O MenuName; // Name or Ordinal ID -// N_OR_O ClassName; // Name or Ordinal ID -// WCHAR szCaption[]; -// WORD wPointSize; // Only here if FONT set for dialog -// WCHAR szFontName[]; // This too -} IMAGE_DIALOG_HEADER, *PIMAGE_DIALOG_HEADER; - -typedef union _NAME_OR_ORDINAL{ // Name or Ordinal ID - struct _ORD_ID{ - WORD flgId; - WORD Id; - } ORD_ID; - WCHAR szName[1]; -} NAME_OR_ORDINAL, *PNAME_OR_ORDINAL; - -// The data for each control starts on a DWORD boundary (which may require -// some padding from the previous control), and its format is as follows: - -typedef struct _IMAGE_CONTROL_DATA{ - DWORD IStyle; - DWORD IExtendedStyle; - WORD x; - WORD y; - WORD cx; - WORD cy; - WORD wId; -// N_OR_O ClassId; -// N_OR_O Text; -// WORD nExtraStuff; -} IMAGE_CONTROL_DATA, *PIMAGE_CONTROL_DATA; - -#define BUTTON 0x80 -#define EDIT 0x81 -#define STATIC 0x82 -#define LISTBOX 0x83 -#define SCROLLBAR 0x84 -#define COMBOBOX 0x85 - -// The various statements used in a dialog script are all mapped to these -// classes along with certain modifying styles. The values for these styles -// can be found in WINDOWS.H. All dialog controls have the default styles -// of WS_CHILD and WS_VISIBLE. A list of the default styles used follows: -// -// Statement Default Class Default Styles -// CONTROL None WS_CHILD|WS_VISIBLE -// LTEXT STATIC ES_LEFT -// RTEXT STATIC ES_RIGHT -// CTEXT STATIC ES_CENTER -// LISTBOX LISTBOX WS_BORDER|LBS_NOTIFY -// CHECKBOX BUTTON BS_CHECKBOX|WS_TABSTOP -// PUSHBUTTON BUTTON BS_PUSHBUTTON|WS_TABSTOP -// GROUPBOX BUTTON BS_GROUPBOX -// DEFPUSHBUTTON BUTTON BS_DFPUSHBUTTON|WS_TABSTOP -// RADIOBUTTON BUTTON BS_RADIOBUTTON -// AUTOCHECKBOX BUTTON BS_AUTOCHECKBOX -// AUTO3STATE BUTTON BS_AUTO3STATE -// AUTORADIOBUTTON BUTTON BS_AUTORADIOBUTTON -// PUSHBOX BUTTON BS_PUSHBOX -// STATE3 BUTTON BS_3STATE -// EDITTEXT EDIT ES_LEFT|WS_BORDER|WS_TABSTOP -// COMBOBOX COMBOBOX None -// ICON STATIC SS_ICON -// SCROLLBAR SCROLLBAR None -/// - -#define WS_OVERLAPPED 0x00000000L -#define WS_POPUP 0x80000000L -#define WS_CHILD 0x40000000L -#define WS_CLIPSIBLINGS 0x04000000L -#define WS_CLIPCHILDREN 0x02000000L -#define WS_VISIBLE 0x10000000L -#define WS_DISABLED 0x08000000L -#define WS_MINIMIZE 0x20000000L -#define WS_MAXIMIZE 0x01000000L -#define WS_CAPTION 0x00C00000L -#define WS_BORDER 0x00800000L -#define WS_DLGFRAME 0x00400000L -#define WS_VSCROLL 0x00200000L -#define WS_HSCROLL 0x00100000L -#define WS_SYSMENU 0x00080000L -#define WS_THICKFRAME 0x00040000L -#define WS_MINIMIZEBOX 0x00020000L -#define WS_MAXIMIZEBOX 0x00010000L -#define WS_GROUP 0x00020000L -#define WS_TABSTOP 0x00010000L - -// other aliases -#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) -#define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU) -#define WS_CHILDWINDOW (WS_CHILD) -#define WS_TILED WS_OVERLAPPED -#define WS_ICONIC WS_MINIMIZE -#define WS_SIZEBOX WS_THICKFRAME -#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW - -#define WS_EX_DLGMODALFRAME 0x00000001L -#define WS_EX_NOPARENTNOTIFY 0x00000004L -#define WS_EX_TOPMOST 0x00000008L -#define WS_EX_ACCEPTFILES 0x00000010L -#define WS_EX_TRANSPARENT 0x00000020L - -#define BS_PUSHBUTTON 0x00000000L -#define BS_DEFPUSHBUTTON 0x00000001L -#define BS_CHECKBOX 0x00000002L -#define BS_AUTOCHECKBOX 0x00000003L -#define BS_RADIOBUTTON 0x00000004L -#define BS_3STATE 0x00000005L -#define BS_AUTO3STATE 0x00000006L -#define BS_GROUPBOX 0x00000007L -#define BS_USERBUTTON 0x00000008L -#define BS_AUTORADIOBUTTON 0x00000009L -#define BS_OWNERDRAW 0x0000000BL -#define BS_LEFTTEXT 0x00000020L - -#define ES_LEFT 0x00000000L -#define ES_CENTER 0x00000001L -#define ES_RIGHT 0x00000002L -#define ES_MULTILINE 0x00000004L -#define ES_UPPERCASE 0x00000008L -#define ES_LOWERCASE 0x00000010L -#define ES_PASSWORD 0x00000020L -#define ES_AUTOVSCROLL 0x00000040L -#define ES_AUTOHSCROLL 0x00000080L -#define ES_NOHIDESEL 0x00000100L -#define ES_OEMCONVERT 0x00000400L -#define ES_READONLY 0x00000800L -#define ES_WANTRETURN 0x00001000L - -#define LBS_NOTIFY 0x0001L -#define LBS_SORT 0x0002L -#define LBS_NOREDRAW 0x0004L -#define LBS_MULTIPLESEL 0x0008L -#define LBS_OWNERDRAWFIXED 0x0010L -#define LBS_OWNERDRAWVARIABLE 0x0020L -#define LBS_HASSTRINGS 0x0040L -#define LBS_USETABSTOPS 0x0080L -#define LBS_NOINTEGRALHEIGHT 0x0100L -#define LBS_MULTICOLUMN 0x0200L -#define LBS_WANTKEYBOARDINPUT 0x0400L -#define LBS_EXTENDEDSEL 0x0800L -#define LBS_DISABLENOSCROLL 0x1000L - -#define SS_LEFT 0x00000000L -#define SS_CENTER 0x00000001L -#define SS_RIGHT 0x00000002L -#define SS_ICON 0x00000003L -#define SS_BLACKRECT 0x00000004L -#define SS_GRAYRECT 0x00000005L -#define SS_WHITERECT 0x00000006L -#define SS_BLACKFRAME 0x00000007L -#define SS_GRAYFRAME 0x00000008L -#define SS_WHITEFRAME 0x00000009L -#define SS_SIMPLE 0x0000000BL -#define SS_LEFTNOWORDWRAP 0x0000000CL -#define SS_BITMAP 0x0000000EL - -// -// Debug Format -// - -typedef struct _IMAGE_DEBUG_DIRECTORY { - DWORD Characteristics; - DWORD TimeDateStamp; - WORD MajorVersion; - WORD MinorVersion; - DWORD Type; - DWORD SizeOfData; - DWORD AddressOfRawData; - DWORD PointerToRawData; -} IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY; - -#define IMAGE_DEBUG_TYPE_UNKNOWN 0 -#define IMAGE_DEBUG_TYPE_COFF 1 -#define IMAGE_DEBUG_TYPE_CODEVIEW 2 -#define IMAGE_DEBUG_TYPE_FPO 3 -#define IMAGE_DEBUG_TYPE_MISC 4 -#define IMAGE_DEBUG_TYPE_EXCEPTION 5 -#define IMAGE_DEBUG_TYPE_FIXUP 6 -#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7 -#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8 - - -typedef struct _IMAGE_DEBUG_MISC { - DWORD DataType; // type of misc data, see defines - DWORD Length; // total length of record, rounded to four - // byte multiple. - BOOLEAN Unicode; // TRUE if data is unicode string - BYTE Reserved[ 3 ]; - BYTE Data[ 1 ]; // Actual data -} IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC; - - -// -// Debugging information can be stripped from an image file and placed -// in a separate .DBG file, whose file name part is the same as the -// image file name part (e.g. symbols for CMD.EXE could be stripped -// and placed in CMD.DBG). This is indicated by the IMAGE_FILE_DEBUG_STRIPPED -// flag in the Characteristics field of the file header. The beginning of -// the .DBG file contains the following structure which captures certain -// information from the image file. This allows a debug to proceed even if -// the original image file is not accessable. This header is followed by -// zero of more IMAGE_SECTION_HEADER structures, followed by zero or more -// IMAGE_DEBUG_DIRECTORY structures. The latter structures and those in -// the image file contain file offsets relative to the beginning of the -// .DBG file. -// -// If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure -// is left in the image file, but not mapped. This allows a debugger to -// compute the name of the .DBG file, from the name of the image in the -// IMAGE_DEBUG_MISC structure. -// - -typedef struct _IMAGE_SEPARATE_DEBUG_HEADER { - WORD Signature; - WORD Flags; - WORD Machine; - WORD Characteristics; - DWORD TimeDateStamp; - DWORD CheckSum; - DWORD ImageBase; - DWORD SizeOfImage; - DWORD NumberOfSections; - DWORD ExportedNamesSize; - DWORD DebugDirectorySize; - DWORD SectionAlignment; - DWORD Reserved[2]; -} IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER; - -#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944 - -#define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000 -#define IMAGE_SEPARATE_DEBUG_MISMATCH 0x8000 // when DBG was updated, the - // old checksum didn't match. - - -// -// End Image Format -// - - -#define SIZE_OF_NT_SIGNATURE sizeof (DWORD) -#define MAXRESOURCENAME 13 - -/* global macros to define header offsets into file */ -/* offset to PE file signature */ -#define NTSIGNATURE(a) ((LPVOID)((BYTE *)a + \ - ((PIMAGE_DOS_HEADER)a)->e_lfanew)) - -/* DOS header identifies the NT PEFile signature dword - the PEFILE header exists just after that dword */ -#define PEFHDROFFSET(a) ((LPVOID)((BYTE *)a + \ - ((PIMAGE_DOS_HEADER)a)->e_lfanew + \ - SIZE_OF_NT_SIGNATURE)) - -/* PE optional header is immediately after PEFile header */ -#define OPTHDROFFSET(a) ((LPVOID)((BYTE *)a + \ - ((PIMAGE_DOS_HEADER)a)->e_lfanew + \ - SIZE_OF_NT_SIGNATURE + \ - sizeof (IMAGE_FILE_HEADER))) - -/* section headers are immediately after PE optional header */ -#define SECHDROFFSET(a) ((LPVOID)((BYTE *)a + \ - ((PIMAGE_DOS_HEADER)a)->e_lfanew + \ - SIZE_OF_NT_SIGNATURE + \ - sizeof (IMAGE_FILE_HEADER) + \ - sizeof (IMAGE_OPTIONAL_HEADER))) - - -typedef struct tagImportDirectory - { - DWORD dwRVAFunctionNameList; - DWORD dwUseless1; - DWORD dwUseless2; - DWORD dwRVAModuleName; - DWORD dwRVAFunctionAddressList; - }IMAGE_IMPORT_MODULE_DIRECTORY, * PIMAGE_IMPORT_MODULE_DIRECTORY; - - -/* global prototypes for functions in pefile.c */ -/* PE file header info */ -BOOL WINAPI GetDosHeader (LPVOID, PIMAGE_DOS_HEADER); -DWORD WINAPI ImageFileType (LPVOID); -BOOL WINAPI GetPEFileHeader (LPVOID, PIMAGE_FILE_HEADER); - -/* PE optional header info */ -BOOL WINAPI GetPEOptionalHeader (LPVOID, PIMAGE_OPTIONAL_HEADER); -LPVOID WINAPI GetModuleEntryPoint (LPVOID); -int WINAPI NumOfSections (LPVOID); -LPVOID WINAPI GetImageBase (LPVOID); -LPVOID WINAPI ImageDirectoryOffset (LPVOID, DWORD); -LPVOID WINAPI ImageDirectorySection (LPVOID, DWORD); - -/* PE section header info */ -//int WINAPI GetSectionNames (LPVOID, HANDLE, char **); -int WINAPI GetSectionNames (LPVOID, char **); -BOOL WINAPI GetSectionHdrByName (LPVOID, PIMAGE_SECTION_HEADER, char *); - -// -// structur to store string tokens -// -typedef struct _Str_P { - char flag; // string_flag '@' or '%' or '#' - char *pos; // starting postion of string - int length; // length of string - BOOL wasString; // if it were stringMode or not -} Str_P; - -/* import section info */ -int WINAPI GetImportModuleNames (LPVOID, char **); -int WINAPI GetImportFunctionNamesByModule (LPVOID, char *, char **); - -// import function name reporting -int WINAPI GetStringLength (char *); -void WINAPI GetPreviousParamString (char *, char *); -void WINAPI TranslateParameters (char **, char **, char **); -BOOL WINAPI StringExpands (char **, char **, char **, Str_P *); -LPVOID WINAPI TranslateFunctionName (char *); - -/* export section info */ -int WINAPI GetExportFunctionNames (LPVOID, char **); - -/* resource section info */ -int WINAPI GetNumberOfResources (LPVOID); -int WINAPI GetListOfResourceTypes (LPVOID, char **); -int WINAPI MenuScan (int *, WORD **); -int WINAPI MenuFill (char **, WORD **); -void WINAPI StrangeMenuFill (char **, WORD **, int); -int WINAPI GetContentsOfMenu (LPVOID, char **); -int WINAPI PrintMenu (int, char **); -int WINAPI PrintStrangeMenu (char **); - -/* debug section info */ -BOOL WINAPI IsDebugInfoStripped (LPVOID); -int WINAPI RetrieveModuleName (LPVOID, char **); -BOOL WINAPI IsDebugFile (LPVOID); -BOOL WINAPI GetSeparateDebugHeader (LPVOID, PIMAGE_SEPARATE_DEBUG_HEADER); - - -/* copy dos header information to structure */ -BOOL WINAPI GetDosHeader ( - LPVOID lpFile, - PIMAGE_DOS_HEADER pHeader) -{ - /* dos header rpresents first structure of bytes in file */ - if (*(USHORT *)lpFile == IMAGE_DOS_SIGNATURE) - bcopy(lpFile, (LPVOID)pHeader, sizeof (IMAGE_DOS_HEADER)); - else - return FALSE; - - return TRUE; -} - - - - -/* return file signature */ -DWORD WINAPI ImageFileType ( - LPVOID lpFile) -{ - /* dos file signature comes first */ - if (*(USHORT *)lpFile == IMAGE_DOS_SIGNATURE) - { - /* determine location of PE File header from dos header */ - if (LOWORD (*(DWORD *)NTSIGNATURE (lpFile)) == IMAGE_OS2_SIGNATURE || - LOWORD (*(DWORD *)NTSIGNATURE (lpFile)) == IMAGE_OS2_SIGNATURE_LE) - return (DWORD)LOWORD(*(DWORD *)NTSIGNATURE (lpFile)); - - else if (*(DWORD *)NTSIGNATURE (lpFile) == IMAGE_NT_SIGNATURE) - return IMAGE_NT_SIGNATURE; - - else - return IMAGE_DOS_SIGNATURE; - } - - else - /* unknown file type */ - return 0; -} - - - - -/* copy file header information to structure */ -BOOL WINAPI GetPEFileHeader ( - LPVOID lpFile, - PIMAGE_FILE_HEADER pHeader) -{ - /* file header follows dos header */ - if (ImageFileType (lpFile) == IMAGE_NT_SIGNATURE) - bcopy(PEFHDROFFSET (lpFile), (LPVOID)pHeader, sizeof (IMAGE_FILE_HEADER)); - else - return FALSE; - - return TRUE; -} - - - - - -/* copy optional header info to structure */ -BOOL WINAPI GetPEOptionalHeader ( - LPVOID lpFile, - PIMAGE_OPTIONAL_HEADER pHeader) -{ - /* optional header follows file header and dos header */ - if (ImageFileType (lpFile) == IMAGE_NT_SIGNATURE) - bcopy (OPTHDROFFSET (lpFile), (LPVOID)pHeader, sizeof (IMAGE_OPTIONAL_HEADER)); - else - return FALSE; - - return TRUE; -} - - - - -/* function returns the entry point for an exe module lpFile must - be a memory mapped file pointer to the beginning of the image file */ -LPVOID WINAPI GetModuleEntryPoint ( - LPVOID lpFile) -{ - PIMAGE_OPTIONAL_HEADER poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile); - - if (poh != NULL) - return (LPVOID)(poh->AddressOfEntryPoint); - else - return NULL; -} - - - - -/* return the total number of sections in the module */ -int WINAPI NumOfSections ( - LPVOID lpFile) -{ - /* number os sections is indicated in file header */ - return ((int)((PIMAGE_FILE_HEADER)PEFHDROFFSET (lpFile))->NumberOfSections); -} - - - - -/* retrieve entry point */ -LPVOID WINAPI GetImageBase ( - LPVOID lpFile) -{ - PIMAGE_OPTIONAL_HEADER poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile); - - if (poh != NULL) - return (LPVOID)(poh->ImageBase); - else - return NULL; -} - - - -// -// This function is written by sang cho -// .. october 5, 1997 -// -/* function returns the actual address of given RVA, lpFile must - be a memory mapped file pointer to the beginning of the image file */ -LPVOID WINAPI GetActualAddress ( - LPVOID lpFile, - DWORD dwRVA) -{ - PIMAGE_OPTIONAL_HEADER poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile); - PIMAGE_SECTION_HEADER psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile); - int nSections = NumOfSections (lpFile); - int i = 0; - - if (dwRVA == NULL) return NULL; - if (dwRVA & 0x80000000) - { - //return (LPVOID)dwRVA; - printf ("\n$$ what is going on $$"); - exit (0); - } - - /* locate section containing image directory */ - while (i++VirtualAddress <= (DWORD)dwRVA && - psh->VirtualAddress + psh->SizeOfRawData > (DWORD)dwRVA) - break; - psh++; - } - - if (i > nSections) - return NULL; - - /* return image import directory offset */ - return (LPVOID)(((int)lpFile + (int)dwRVA - psh->VirtualAddress) + - (int)psh->PointerToRawData); -} - - -// -// This function is modified by sang cho -// -// -/* return offset to specified IMAGE_DIRECTORY entry */ -LPVOID WINAPI ImageDirectoryOffset ( - LPVOID lpFile, - DWORD dwIMAGE_DIRECTORY) -{ - PIMAGE_OPTIONAL_HEADER poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile); - PIMAGE_SECTION_HEADER psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile); - int nSections = NumOfSections (lpFile); - int i = 0; - LPVOID VAImageDir; - - /* must be 0 thru (NumberOfRvaAndSizes-1) */ - if (dwIMAGE_DIRECTORY >= poh->NumberOfRvaAndSizes) - return NULL; - - /* locate specific image directory's relative virtual address */ - VAImageDir = (LPVOID)poh->DataDirectory[dwIMAGE_DIRECTORY].VirtualAddress; - - if (VAImageDir == NULL) return NULL; - /* locate section containing image directory */ - while (i++VirtualAddress <= (DWORD)VAImageDir && - psh->VirtualAddress + psh->SizeOfRawData > (DWORD)VAImageDir) - break; - psh++; - } - - if (i > nSections) - return NULL; - - /* return image import directory offset */ - return (LPVOID)(((int)lpFile + (int)VAImageDir - psh->VirtualAddress) + - (int)psh->PointerToRawData); -} - - -/* function retrieve names of all the sections in the file */ -int WINAPI GetSectionNames ( - LPVOID lpFile, - char **pszSections) -{ - int nSections = NumOfSections (lpFile); - int i, nCnt = 0; - PIMAGE_SECTION_HEADER psh; - char *ps; - - - if (ImageFileType (lpFile) != IMAGE_NT_SIGNATURE || - (psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile)) == NULL) - return 0; - - /* count the number of chars used in the section names */ - for (i=0; iName, szSection)) - { - /* copy data to header */ - bcopy ((LPVOID)psh, (LPVOID)sh, sizeof (IMAGE_SECTION_HEADER)); - return TRUE; - } - else psh++; - } - } - return FALSE; -} - - - -// -// This function is modified by sang cho -// -// -/* get import modules names separated by null terminators, return module count */ -int WINAPI GetImportModuleNames ( - LPVOID lpFile, - char **pszModules) -{ - PIMAGE_IMPORT_MODULE_DIRECTORY pid = (PIMAGE_IMPORT_MODULE_DIRECTORY) - ImageDirectoryOffset (lpFile, IMAGE_DIRECTORY_ENTRY_IMPORT); - // - // sometimes there may be no section for idata or edata - // instead rdata or data section may contain these sections .. - // or even module names or function names are in different section. - // so that's why we need to get actual address of RVAs each time. - // ...................sang cho.................. - // - // PIMAGE_SECTION_HEADER psh = (PIMAGE_SECTION_HEADER) - // ImageDirectorySection (lpFile, IMAGE_DIRECTORY_ENTRY_IMPORT); - // BYTE *pData = (BYTE *)pid; - DWORD *pdw = (DWORD *)pid; - int nCnt = 0, nSize = 0, i; - char *pModule[1024]; /* hardcoded maximum number of modules?? */ - int pidTab[1024]; - char *psz; - - if (pid == NULL) return 0; - - // pData = (BYTE *)((int)lpFile + psh->PointerToRawData - psh->VirtualAddress); - - /* extract all import modules */ - while (pid->dwRVAModuleName) - { - /* allocate temporary buffer for absolute string offsets */ - //pModule[nCnt] = (char *)(pData + pid->dwRVAModuleName); - pModule[nCnt] = (char *)GetActualAddress (lpFile, pid->dwRVAModuleName); - pidTab[nCnt] = (int)pid; - nSize += strlen (pModule[nCnt]) + 1 + 4; - - /* increment to the next import directory entry */ - pid++; - nCnt++; - } - - /* copy all strings to one chunk of memory */ - *pszModules = (char *)calloc(nSize, 1); - piNameBuffSize = nSize; - psz = *pszModules; - for (i=0; iPointerToRawData - psh->VirtualAddress); - - /* find module's pid */ - //while (pid->dwRVAModuleName && - // strcmp (pszModule, (char *)GetActualAddress(lpFile, pid->dwRVAModuleName))) - //pid++; - - pid = (PIMAGE_IMPORT_MODULE_DIRECTORY)(*(DWORD *)pszModule); - - //fprintf(stderr, "\npid=%08X", pid),getch(); - - /* exit if the module is not found */ - if (!pid->dwRVAModuleName) - return 0; - - // I am doing this to get rid of .dll from module name - strcpy (name, pszModule+4); - mnlength = strlen (pszModule+4); - for (i=0; idwRVAFunctionNameList; - - // IMAGE_IMPORT_BY_NAME OR IMAGE_THUNK_DATA - // modified by Sang Cho - - - //fprintf(stderr,"pid = %08X dwFunctionName = %08X name = %s", - //(int)pid-(int)lpFile, dwFunctionName,name),getch(); - - // modified by sang cho 1998.1.24 - - if (dwFunctionName==0) dwFunctionName = pid->dwRVAFunctionAddressList; - - while (dwFunctionName && - *(pdw=(DWORD *)GetActualAddress (lpFile, dwFunctionName)) ) - { - if ((*pdw) & 0x80000000 ) nSize += mnlength + 11 + 1 + 6; - else nSize += strlen ((char *)GetActualAddress (lpFile, *pdw+2)) + 1+6; - dwFunctionName += 4; - nCnt++; - } - - /* allocate memory for function names */ - *pszFunctions = (char *)calloc (nSize, 1); - psz = *pszFunctions; - - // - // I modified this part to store function address (4 bytes), - // ord number (2 bytes), - // and name strings (which was there originally) - // so that's why there are 6 more bytes...... +6, or +4 and +2 etc. - // these informations are used where they are needed. - // ...........sang cho.................. - // - /* copy function names to mempry pointer */ - dwFunctionName = pid->dwRVAFunctionNameList; - // modified by sang cho 1998.1.24 - if (dwFunctionName==0) dwFunctionName = pid->dwRVAFunctionAddressList; - dwFunctionAddress = pid->dwRVAFunctionAddressList; - while (dwFunctionName && - *(pdw=(DWORD *)GetActualAddress (lpFile, dwFunctionName)) ) - { - if ((*pdw) & 0x80000000) - { - *(int *)psz=(int)(*(DWORD *)GetActualAddress (lpFile, dwFunctionAddress)); - psz += 4; - *(short *)psz=*(short *)pdw; - psz += 2; - sprintf(buff, "%s:NoName%04d", name, nnid++); - strcpy (psz, buff); psz += strlen (buff) + 1; - } - else - { - r=*(int *)psz=(int)(*(DWORD *)GetActualAddress (lpFile, dwFunctionAddress)); - psz += 4; - *(short *)psz=(*(short *)GetActualAddress(lpFile, *pdw)); - psz += 2; rr=(int)GetActualAddress(lpFile, *pdw + 2); - strcpy (psz, (char *)rr); - psz += strlen ((char *)GetActualAddress(lpFile, *pdw + 2)) + 1; - - // this one is needed to link import function names to codes.. - k.class=0; k.c_ref= r; k.c_pos=-rr; - MyBtreeInsert(&k); - k.class=0; k.c_ref=-(rr); k.c_pos=(int)pszModule+4; - MyBtreeInsert(&k); - } - dwFunctionName += 4; - dwFunctionAddress += 4; - } - - return nCnt; -} - - - - -// -// This function is written by sang cho -// October 6, 1997 -// -/* get numerically expressed string length */ -int WINAPI GetStringLength ( - char *psz) -{ - if (!isdigit (*psz)) return 0; - if (isdigit (*(psz+1))) return (*psz - '0')*10 + *(psz+1) - '0'; - else return *psz - '0'; -} - - - - -// -// This function is written by sang cho -// October 12, 1997 -// - -/* translate parameter part of condensed name */ -void WINAPI GetPreviousParamString ( - char *xpin, // read-only source - char *xpout) // translated result -{ - int n=0; - char *pin, *pout; - - pin = xpin; - pout = xpout; - - pin--; - if (*pin == ',') pin--; - else { printf ("\n **error PreviousParamString1 char = %c", *pin); exit(0); } - - while (*pin) - { - if (*pin == '>') n++; - else if (*pin == '<') n--; - else if (*pin == ')') n++; - - if (n > 0) - { - if (*pin == '(') n--; - } - else if (strchr (",(", *pin)) break; - pin--; - } - - //printf("\n ----- %s", pin); - if (strchr (",(", *pin)) {pin++;} // printf("\n %s", pin); } - else { printf ("\n **error PreviousParamString2"); exit(0); } - - n = xpin - pin - 1; - strncpy (pout, pin, n); - *(pout + n) = 0; -} - - - - -// -// This function is written by sang cho -// October 10, 1997 -// - -/* translate parameter part of condensed name */ -void WINAPI TranslateParameters ( - char **ppin, // read-only source - char **ppout, // translated result - char **pps) // parameter stack -{ - int i, n; - char c; - char name[128]; - char *pin, *pout, *ps; - - //printf(" %c ", **in); - pin = *ppin; - pout = *ppout; - ps = *pps; - c = *pin; - switch (c) - { - // types processing - case 'b': strcpy (pout, "byte"); pout += 4; pin++; break; - case 'c': strcpy (pout, "char"); pout += 4; pin++; break; - case 'd': strcpy (pout, "double"); pout += 6; pin++; break; - case 'f': strcpy (pout, "float"); pout += 5; pin++; break; - case 'g': strcpy (pout, "long double");pout += 11; pin++; break; - case 'i': strcpy (pout, "int"); pout += 3; pin++; break; - case 'l': strcpy (pout, "long"); pout += 4; pin++; break; - case 's': strcpy (pout, "short"); pout += 5; pin++; break; - case 'v': strcpy (pout, "void"); pout += 4; pin++; break; - // postfix processing - case 'M': - case 'p': - if (*(pin+1) == 'p') { *ps++ = 'p'; pin += 2; } - else { *ps++ = '*'; pin++; } - *ppin = pin; *ppout = pout; *pps = ps; - return; - case 'q': - *pout++ = '('; pin++; - *ps++ = 'q'; - *ppin = pin; *ppout = pout; *pps = ps; - return; - case 'r': - if (*(pin+1) == 'p') { *ps++ = 'r'; pin += 2; } - else { *ps++ = '&'; pin++; } - *ppin = pin; *ppout = pout; *pps = ps; - return; - // repeat processing - case 't': - if (isdigit(*(pin+1))) - { - n = *(pin+1) - '0'; pin++; pin++; - GetPreviousParamString (pout, name); - strcpy (pout, name); pout += strlen (name); - for (i=1; i>"); pout += 11; pin += 4; } - else if (strncmp (pin, "binc", 4) == 0) - { strcpy (pout, "operator ++"); pout += 11; pin += 4; } - else if (strncmp (pin, "bdec", 4) == 0) - { strcpy (pout, "operator --"); pout += 11; pin += 4; } - else if (strncmp (pin, "badd", 4) == 0) - { strcpy (pout, "operator +"); pout += 10; pin += 4; } - else if (strncmp (pin, "brplu", 5) == 0) - { strcpy (pout, "operator +="); pout += 11; pin += 5; } - else if (strncmp (pin, "bdiv", 4) == 0) - { strcpy (pout, "operator /"); pout += 10; pin += 4; } - else if (strncmp (pin, "brdiv", 5) == 0) - { strcpy (pout, "operator /="); pout += 11; pin += 5; } - else if (strncmp (pin, "bmul", 4) == 0) - { strcpy (pout, "operator *"); pout += 10; pin += 4; } - else if (strncmp (pin, "brmul", 5) == 0) - { strcpy (pout, "operator *="); pout += 11; pin += 5; } - else if (strncmp (pin, "basg", 4) == 0) - { strcpy (pout, "operator ="); pout += 10; pin += 4; } - else if (strncmp (pin, "beql", 4) == 0) - { strcpy (pout, "operator =="); pout += 11; pin += 4; } - else if (strncmp (pin, "bneq", 4) == 0) - { strcpy (pout, "operator !="); pout += 11; pin += 4; } - else if (strncmp (pin, "bor", 3) == 0) - { strcpy (pout, "operator |"); pout += 10; pin += 3; } - else if (strncmp (pin, "bror", 4) == 0) - { strcpy (pout, "operator |="); pout += 11; pin += 4; } - else if (strncmp (pin, "bcmp", 4) == 0) - { strcpy (pout, "operator ~"); pout += 10; pin += 4; } - else if (strncmp (pin, "bnot", 4) == 0) - { strcpy (pout, "operator !"); pout += 10; pin += 4; } - else if (strncmp (pin, "band", 4) == 0) - { strcpy (pout, "operator &"); pout += 10; pin += 4; } - else if (strncmp (pin, "brand", 5) == 0) - { strcpy (pout, "operator &="); pout += 11; pin += 5; } - else if (strncmp (pin, "bxor", 4) == 0) - { strcpy (pout, "operator ^"); pout += 10; pin += 4; } - else if (strncmp (pin, "brxor", 5) == 0) - { strcpy (pout, "operator ^="); pout += 11; pin += 5; } - else - { - strcpy (pout, "!$$$!"); pout += 5; - } - *ppin = pin; *ppout = pout; *pps = ps; - return stringMode; -} // end of '$' processing - - - -//---------------------------------------------------------------------- -// structure to store string tokens -//---------------------------------------------------------------------- -//typedef struct _Str_P { -// char flag; // string_flag '@' or '%' or '#' -// char *pos; // starting postion of string -// int length; // length of string -// BOOL wasString; // if it were stringMode or not -//} Str_P; -//---------------------------------------------------------------------- -// -// I think I knocked it down finally. But who knows? -// october 12, 1997 ... sang -// -// well I have to rewrite whole part of TranslateFunctionName.. -// this time I am a little bit more experienced than 5 days ago. -// or am i??? anyway i use stacks instead of recurcive calls -// and i hope this will take care of every symptoms i have experienced.. -// october 10, 1997 .... sang -// It took a lot of time for me to figure out what is all about.... -// but still some prefixes like z (static) -// -- or some types like b (byte) ,g (long double) ,s (short) -- -// -- or postfix like M ( * ) -// -- or $or ( & ) which is pretty wierd. .. added.. october 12 -// -- also $t business is quite tricky too. (templates) -// there may be a lot of things undiscovered yet.... -// I am not so sure my interpretation is correct or not -// If I am wrong please let me know. -// october 8, 1997 .... sang -// -// -// This function is written by sang cho -// October 5, 1997 -// -/* translate condesed import function name */ -LPVOID WINAPI TranslateFunctionName ( - char *psz) -{ - - - int i, j, n; - char c, cc; - - static char buff[512]; // result of translation - - int is=0; - char pStack[32]; // parameter processing stack - Str_P sStack[32]; // String processing stack - Str_P tok; // String token - Str_P c_str; // current string - - int iend=0; - char *endTab[8]; // end of string position check - - char *ps; - char *pin, *pout; - BOOL stringMode=TRUE; - - if (*psz != '@') return psz; - pin = psz; - pout = buff; - ps = pStack; - - //................................................................ - // serious users may need to run the following code. - // so I may need to include some flag options... - // If you want to know about how translation is done, - // you can just revive following line and you can see it. - // october 6, 1997 ... sang cho - //printf ("\n................................... %s", psz); // for debugging... - - //pa = pb = pout; - pin++; - tok.flag = 'A'; tok.pos = pout; tok.length = 0; tok.wasString = stringMode; - sStack[is++] = tok; // initialize sStack with dummy marker - - while (*pin) - { - while (*pin) - { - c = *pin; - - //--------------------------------------------- - // check for the end of number specified string - //--------------------------------------------- - - if (iend>0) - { - for (i=0;i 1) *pout++ = *pin++; - - //------------------------------------------------ - // parameter part processing: '$' met - //------------------------------------------------ - - else // parameter processing - { - if (!isdigit (c)) TranslateParameters (&pin, &pout, &ps); - else // number specified string processing - { - n = GetStringLength (pin); - if (n<10) pin++; else pin += 2; - - // push '#' token - //if (*pin) - //printf("\n push # token .. char = %c", *pin); - //else printf("\n push percent token..next char = NULL"); - tok.flag = '#'; tok.pos = pout; - tok.length = 0; tok.wasString = stringMode; - sStack[is++] = tok; - - // mark end of input string - endTab[iend++] = pin + n; - stringMode = TRUE; - } - } - } // end of inner while loop - // - // beginning of new string or end of string ( quotation mark ) - // - if (c == '%') - { - pin++; // anyway we have to proceed... - tok = sStack[is-1]; // get top of the sStack - if (tok.flag == '%') - { - // pop '%' token and set c_str - //if (*pin) - //printf("\n pop percent token..next char = %c", *pin); - //else printf("\n pop percent token..next char = NULL"); - is--; - c_str = tok; c_str.length = pout - c_str.pos; - if (*(ps-1) == 't') - { - *pout++ = '>'; ps--; - stringMode = tok.wasString; - } - else { printf("\n**some string error3** stack = %c", *(ps-1)); - exit(0); } - } - else if (tok.flag == 'A' || tok.flag == '#') - { - // push '%' token - //if (*pin) - //printf("\n push percent token..next char = %c", *pin); - //else printf("\n push percent token..next char = NULL"); - tok.flag = '%'; tok.pos = pout; tok.length = 0; - tok.wasString = stringMode; - sStack[is++] = tok; - } - else { printf("\n**some string error5**"); exit(0); } - } - // - // sometimes we need string to use as constructor name or destructor name - // - else if (c == '@') // get string from previous marker upto here. - { - pin++; - tok = sStack[is-1]; - c_str.flag = 'S'; - c_str.pos = tok.pos; - c_str.length = pout - tok.pos; - c_str.wasString = stringMode; - *pout++ = ':'; *pout++ = ':'; - } - // - // we need to take care of parameter control sequence - // - else if (c == '$') // need to precess template or parameter part - { - pin++; - if (stringMode) - stringMode = StringExpands (&pin, &pout, &ps, &c_str); - else - { // template parameter mode I guess "$t" - if (is>1) - { - if (*pin == 't') pin++; - else { printf("\nMYGOODNESS1 %c", *pin); exit(0);} - //ps--; - //if (*ps == 't') *pout++ = '>'; - //else { printf("\nMYGOODNESS2"); exit(0);} - *pout++ = ','; //pin++; ..this almost blowed me.... - } - // real parameter mode I guess - // unexpected case is found ... humm what can I do... - else - { - // this is newly found twist.. it really hurts. - if (ps <= pStack) - { if (*pin == 'q') { *ps++ = 'q'; *pout++ = '('; pin++; } - else {printf("\n** I GIVEUP ***"); exit(0);} - continue; - } - ps--; - while (*ps != 'q') - { if (*ps == '*') *pout++ = '*'; - else if (*ps == '&') *pout++ = '&'; - else if (*ps == 'p'){*pout++ = '*'; *pout++ = '*'; } - else if (*ps == 'r'){*pout++ = '*'; *pout++ = '&'; } - else {printf("\n*** SOMETHING IS WRONG1*** char= %c",*pin); - exit(0);} - ps--; - } - *pout++ = ')'; - ps--; - while (*ps != 'q') - { if (*ps == '*') *pout++ = '*'; - else if (*ps == '&') *pout++ = '&'; - else if (*ps == 'p'){*pout++ = '*'; *pout++ = '*'; } - else if (*ps == 'r'){*pout++ = '*'; *pout++ = '&'; } - else {printf("\n*** SOMETHING IS WRONG2***"); exit(0);} - ps--; - } - ps++; *pout++ = ','; - } - } - } // end of '$' processing - } // end of outer while loop - // - // need to process remaining parameter stack - // - while (ps>pStack) - { - ps--; - switch(*ps) - { - case 't': *pout++ = '>'; break; - case 'q': *pout++ = ')'; break; - case 'x': strcpy (pout, " const"); pout += 6; break; - case 'r': strcpy (pout, "*&"); pout += 2; break; - case 'p': strcpy (pout, "**"); pout += 2; break; - case '&': *pout++ = '&'; break; - case '*': *pout++ = '*'; break; - default: strcpy (pout, "!4!"); pout += 3; *pout++ = *ps; - } - } - *pout = 0; - return buff; -} - - - -// -// This function is written by sang cho -// -// -/* get exported function names separated by null terminators, return count of functions */ -int WINAPI GetExportFunctionNames ( - LPVOID lpFile, - char **pszFunctions) -{ - //PIMAGE_SECTION_HEADER psh; - PIMAGE_EXPORT_DIRECTORY ped; - //DWORD dwBase; - DWORD imageBase; //=========================== - char *pfns[8192]={NULL,}; // maximum number of functions - //============================= - char buff[256]; // enough for any string ?? - char *psz; //=============================== - DWORD *pdwAddress; - DWORD *pdw1; - DWORD *pdwNames; - WORD *pwOrd; - int i, nCnt=0, ntmp=0; - int enid=0, ordBase=1; // usally ordBase is 1.... - int enames=0; - - /* get section header and pointer to data directory for .edata section */ - ped = (PIMAGE_EXPORT_DIRECTORY) - ImageDirectoryOffset(lpFile, IMAGE_DIRECTORY_ENTRY_EXPORT); - - if (ped == NULL) return 0; - - // - // sometimes there may be no section for idata or edata - // instead rdata or data section may contain these sections .. - // or even module names or function names are in different section. - // so that's why we need to get actual address each time. - // ...................sang cho.................. - // - //psh = (PIMAGE_SECTION_HEADER) - //ImageDirectorySection(lpFile, IMAGE_DIRECTORY_ENTRY_EXPORT); - - //if (psh == NULL) return 0; - - //dwBase = (DWORD)((int)lpFile + psh->PointerToRawData - psh->VirtualAddress); - - - /* determine the offset of the export function names */ - - pdwAddress = (DWORD *)GetActualAddress (lpFile, (DWORD)ped->AddressOfFunctions); - - imageBase = (DWORD)GetImageBase (lpFile); - - ordBase = ped->Base; - - if (ped->NumberOfNames > 0) - { - pdwNames = (DWORD *) - GetActualAddress (lpFile, (DWORD)ped->AddressOfNames); - pwOrd = (WORD *) - GetActualAddress (lpFile, (DWORD)ped->AddressOfNameOrdinals); - pdw1 = pdwAddress; - - /* figure out how much memory to allocate for all strings */ - for (i=0; i < (int)ped->NumberOfNames; i++) - { - nCnt += strlen ((char *) - GetActualAddress (lpFile, *(DWORD *)pdwNames)) + 1 + 6; - pdwNames++; - } - // get the number of unnamed functions - for (i=0; i < (int)ped->NumberOfFunctions; i++) - if (*pdw1++) ntmp++; - // add memory required to show unnamed functions. - if (ntmp > (int)ped->NumberOfNames) - nCnt += 18*(ntmp - (int)ped->NumberOfNames); - - /* allocate memory for function names */ - *pszFunctions = (char *)calloc (nCnt, 1); - fprintf(stderr,"GetExportFunctionNames base %p size 0x%08x\n",*pszFunctions,nCnt); - memset(*pszFunctions,0,nCnt); - peNameBuffSize=nCnt; - pdwNames = (DWORD *)GetActualAddress (lpFile, (DWORD)ped->AddressOfNames); - - /* copy string pointer to buffer */ - - for (i=0; i < (int)ped->NumberOfNames; i++) - { - pfns[(int)(*pwOrd)+ordBase] = - (char *)GetActualAddress (lpFile, *(DWORD *)pdwNames); - pdwNames++; - pwOrd++; - } - - psz = *pszFunctions; - } - - for (i=ordBase; i < (int)ped->NumberOfFunctions + ordBase; i++) - { - if (*pdwAddress > 0) - { - *(DWORD *)psz = imageBase + *pdwAddress; - psz += 4; - *(WORD *)psz = (WORD)(i); - psz += 2; - if (pfns[i]) - { - strcpy (psz, pfns[i]); - psz += strlen(psz) + 1; - } - else - { - sprintf (buff, "ExpFn%04d()", enid++); - strcpy (psz, buff); - psz += 12; - } - enames++; - } - pdwAddress++; - } - - return enames; - -} - - -/* determine the total number of resources in the section */ -int WINAPI GetNumberOfResources ( - LPVOID lpFile) -{ - PIMAGE_RESOURCE_DIRECTORY prdRoot, prdType; - PIMAGE_RESOURCE_DIRECTORY_ENTRY prde; - int nCnt=0, i; - - - /* get root directory of resource tree */ - if ((prdRoot = (PIMAGE_RESOURCE_DIRECTORY)ImageDirectoryOffset - (lpFile, IMAGE_DIRECTORY_ENTRY_RESOURCE)) == NULL) - return 0; - - /* set pointer to first resource type entry */ - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((DWORD)prdRoot + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - /* loop through all resource directory entry types */ - for (i=0; iNumberOfIdEntries; i++) - { - /* locate directory or each resource type */ - prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)prdRoot + (int)prde->OffsetToData); - - /* mask off most significant bit of the data offset */ - prdType = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)prdType ^ 0x80000000); - - /* increment count of name'd and ID'd resources in directory */ - nCnt += prdType->NumberOfNamedEntries + prdType->NumberOfIdEntries; - - /* increment to next entry */ - prde++; - } - - return nCnt; -} - - - -// -// This function is rewritten by sang cho -// -// -/* name each type of resource in the section */ -int WINAPI GetListOfResourceTypes ( - LPVOID lpFile, - char **pszResTypes) -{ - PIMAGE_RESOURCE_DIRECTORY prdRoot; - PIMAGE_RESOURCE_DIRECTORY_ENTRY prde; - char *pMem; - char buff[32]; - int nCnt, i; - DWORD prdeName; - - - /* get root directory of resource tree */ - if ((prdRoot = (PIMAGE_RESOURCE_DIRECTORY)ImageDirectoryOffset - (lpFile, IMAGE_DIRECTORY_ENTRY_RESOURCE)) == NULL) - return 0; - - /* allocate enuff space to cover all types */ - nCnt = prdRoot->NumberOfIdEntries * (MAXRESOURCENAME + 1); - *pszResTypes = (char *)calloc (nCnt, 1); - if ((pMem = *pszResTypes) == NULL) - return 0; - - /* set pointer to first resource type entry */ - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((DWORD)prdRoot + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - /* loop through all resource directory entry types */ - for (i=0; iNumberOfIdEntries; i++) - { - prdeName=prde->Name; - - //if (LoadString (hDll, prde->Name, pMem, MAXRESOURCENAME)) - // pMem += strlen (pMem) + 1; - // - // modified by ...................................Sang Cho.. - // I can't user M/S provied funcitons here so I have to figure out - // how to do above functions. But I can settle down with the following - // code, which works pretty good for me. - // - if (prdeName== 1){strcpy(pMem, "RT_CURSOR"); pMem+=10;} - else if (prdeName== 2){strcpy(pMem, "RT_BITMAP"); pMem+=10;} - else if (prdeName== 3){strcpy(pMem, "RT_ICON "); pMem+=10;} - else if (prdeName== 4){strcpy(pMem, "RT_MENU "); pMem+=10;} - else if (prdeName== 5){strcpy(pMem, "RT_DIALOG"); pMem+=10;} - else if (prdeName== 6){strcpy(pMem, "RT_STRING"); pMem+=10;} - else if (prdeName== 7){strcpy(pMem, "RT_FONTDIR"); pMem+=11;} - else if (prdeName== 8){strcpy(pMem, "RT_FONT "); pMem+=10;} - else if (prdeName== 9){strcpy(pMem, "RT_ACCELERATORS"); pMem+=16;} - else if (prdeName==10){strcpy(pMem, "RT_RCDATA"); pMem+=10;} - else if (prdeName==11){strcpy(pMem, "RT_MESSAGETABLE"); pMem+=16;} - else if (prdeName==12){strcpy(pMem, "RT_GROUP_CURSOR"); pMem+=16;} - else if (prdeName==14){strcpy(pMem, "RT_GROUP_ICON "); pMem+=16;} - else if (prdeName==16){strcpy(pMem, "RT_VERSION"); pMem+=11;} - else if (prdeName==17){strcpy(pMem, "RT_DLGINCLUDE "); pMem+=16;} - else if (prdeName==19){strcpy(pMem, "RT_PLUGPLAY "); pMem+=16;} - else if (prdeName==20){strcpy(pMem, "RT_VXD "); pMem+=10;} - else if (prdeName==21){strcpy(pMem, "RT_ANICURSOR "); pMem+=16;} - else if (prdeName==22){strcpy(pMem, "RT_ANIICON"); pMem+=11;} - else if (prdeName== 0x2002) - {strcpy(pMem, "RT_NEWBITMAP"); pMem+=13;} - else if (prdeName== 0x2004) - {strcpy(pMem, "RT_NEWMENU"); pMem+=11;} - else if (prdeName== 0x2005) - {strcpy(pMem, "RT_NEWDIALOG"); pMem+=13;} - else if (prdeName== 0x7fff) - {strcpy(pMem, "RT_ERROR "); pMem+=10;} - else {sprintf(buff, "RT_UNKNOWN:%08X", prdeName); - strcpy(pMem, buff); pMem+=20;} - prde++; - } - - return prdRoot->NumberOfIdEntries; -} - - - -// -// This function is written by sang cho -// October 12, 1997 -// -/* copy menu information */ -void WINAPI StrangeMenuFill ( - char **psz, // results - WORD **pMenu, // read-only - int size) -{ - WORD *pwd; - WORD *ptr, *pmax; - - pwd = *pMenu; - pmax = (WORD *)((DWORD)pwd + size); - ptr = (WORD *)(*psz); - - while (pwd < pmax) - { - *ptr++=*pwd++; - } - *psz = (char *)ptr; - *pMenu = pwd; -} - - - -// -// This function is written by sang cho -// October 1, 1997 -// -/* obtain menu information */ -int WINAPI MenuScan ( - int *len, - WORD **pMenu) -{ - int num = 0; - int ndetails; - WORD *pwd; - WORD flag, flag1; - WORD id, ispopup; - - - pwd = *pMenu; - - flag = *pwd; // so difficult to correctly code this so let's try this - pwd++; - (*len) += 2; // flag store - if ((flag & 0x0010) == 0) - { - ispopup = flag; - id = *pwd; - pwd++; - (*len) += 2; // id store - } - else - { - ispopup = flag; - } - - while (*pwd) {(*len)++; pwd++;} - (*len)++; // name and null character - pwd++; // skip double null - if ((flag & 0x0010) == 0) // normal node: done - { - *pMenu = pwd; - return (int)flag; - } - // popup node: need to go on... - while (1) - { - *pMenu = pwd; - flag1 = (WORD)MenuScan (len, pMenu); - pwd = *pMenu; - if (flag1 & 0x0080) break; - } -// fill # of details to num above - //(*len) += 2; - *pMenu = pwd; - return flag; -} - - -// -// This function is written by sang cho -// October 2, 1997 -// -/* copy menu information */ -int WINAPI MenuFill ( - char **psz, - WORD **pMenu) -{ - int num = 0; - int ndetails; - char *ptr, *pTemp; - WORD *pwd; - WORD flag, flag1; - WORD id, ispopup; - - ptr = *psz; - pwd = *pMenu; - //flag = (*(PIMAGE_POPUP_MENU_ITEM *)pwd)->fItemFlags; - flag = *pwd; // so difficult to correctly code this so let's try this - pwd++; - if ((flag & 0x0010) == 0) - { - *(WORD *)ptr = flag; // flag store - ptr += 2; - *(WORD *)ptr = id = *pwd; // id store - ptr += 2; - pwd++; - } - else - { - *(WORD *)ptr = flag; // flag store - ptr += 2; - } - - while (*pwd) // name extract - { - *ptr = *(char *)pwd; - ptr++; pwd++; - } //name and null character - *ptr=0; - ptr++; - pwd++; // skip double null - - if ((flag & 0x0010) == 0) // normal node: done - { - *pMenu = pwd; - *psz = ptr; - return (int)flag; - } - //pTemp = ptr; - //ptr += 2; - // popup node: need to go on... - while (1) - { - //num++; - *pMenu = pwd; - *psz = ptr; - flag1 = (WORD)MenuFill (psz, pMenu); - pwd = *pMenu; - ptr = *psz; - if (flag1 & 0x0080) break; - } -// fill # of details to num above - //*(WORD *)pTemp = (WORD)num; - *pMenu = pwd; - *psz = ptr; - return flag; -} - - -// -//============================================================================== -// The following program is based on preorder-tree-traversal. -// once you understand how to traverse..... -// the rest is pretty straight forward. -// still we need to scan it first and fill it next time. -// and finally we can print it. -// -// This function is written by sang cho -// September 29, 1997 -// revised october 2, 1997 -// revised october 12, 1997 -// .............................................................................. -// ------------------------------------------------------------------------------ -// I use same structure - which is used in P.E. programs - for my reporting. -// So, my structure is as follows: -// # of menu name is stored else where ( in directory I suppose ) -// supermenuname null terminated string, only ascii is considered. -// flag tells : node is a leaf or a internal node. -// popupname null terminated string -// -// flag normal menu flag (leaf node) -// id normal menu id -// name normal menu name -// or or -// flag popup menu flag (internal node) -// popupname popup menu name -// -// flag it may folows -// id normal menu id -// name normal menu name -// or or -// flag popup menu -// popupname popup menu name -// ......... -// it goes on like this, -// but usually, it only goes a few steps,... -// ------------------------------------------------------------------------------ -/* scan menu and copy menu */ -int WINAPI GetContentsOfMenu ( - LPVOID lpFile, - char **pszResTypes) -{ - PIMAGE_RESOURCE_DIRECTORY prdType, prdName, prdLanguage; - PIMAGE_RESOURCE_DIRECTORY_ENTRY prde, prde1; - PIMAGE_RESOURCE_DIR_STRING_U pMenuName; - PIMAGE_RESOURCE_DATA_ENTRY prData; - //PIMAGE_SECTION_HEADER psh = (PIMAGE_SECTION_HEADER) - //ImageDirectorySection (lpFile, IMAGE_DIRECTORY_ENTRY_RESOURCE); - PIMAGE_MENU_HEADER pMenuHeader; - PIMAGE_POPUP_MENU_ITEM pPopup; - PIMAGE_NORMAL_MENU_ITEM pNormal; - char buff[32]; - int nCnt=0, i, j; - int num=0; - int size; - int sLength, nMenus; - WORD flag; - WORD *pwd; - DWORD prdeName; - //DWORD dwBase; obsolete - char *pMem, *pTemp; - BOOL isStrange = FALSE; - - - /* get root directory of resource tree */ - if ((prdType = (PIMAGE_RESOURCE_DIRECTORY)ImageDirectoryOffset - (lpFile, IMAGE_DIRECTORY_ENTRY_RESOURCE)) == NULL) - return 0; - - /* set pointer to first resource type entry */ - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdType + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - for (i=0; iNumberOfIdEntries; i++) - { - if (prde->Name == RT_MENU) break; - prde++; - } - if (prde->Name != RT_MENU) return 0; - - prdName = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000) ); - if (prdName == NULL) return 0; - - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdName + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - // sometimes previous code tells you lots of things hidden underneath - // I wish I could save all the revisions I made ... but again .... sigh. - // october 12, 1997 sang - //dwBase = (DWORD)((int)lpFile + psh->PointerToRawData - psh->VirtualAddress); - - nMenus=prdName->NumberOfNamedEntries + prdName->NumberOfIdEntries; - sLength=0; - - for (i=0; iNumberOfNamedEntries; i++) - { - pMenuName = (PIMAGE_RESOURCE_DIR_STRING_U) - ((DWORD)prdType + (prde->Name ^ 0x80000000)); - sLength += pMenuName->Length + 1; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - pMenuHeader = (PIMAGE_MENU_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - - // - // normally wVersion and cbHeaderSize should be zero - // but if it is not then nothing is known to us... - // so let's do our best ... namely guessing .... and trying .... - // ... and suffering ... - // it gave me many sleepless (not exactly but I like to say this) nights. - // - - // strange case - if (pMenuHeader->wVersion | pMenuHeader->cbHeaderSize) - { - //isStrange = TRUE; - pwd = (WORD *)((DWORD)pMenuHeader + 16); - size = prData->Size; - // expect to return the length needed to report. - // sixteen more bytes to do something - sLength += 16+size; - //StrangeMenuScan (&sLength, &pwd, size); - } - // normal case - else - { - pPopup = (PIMAGE_POPUP_MENU_ITEM) - ((DWORD)pMenuHeader + sizeof (IMAGE_MENU_HEADER)); - while (1) - { - flag = (WORD)MenuScan (&sLength, (WORD **)(&pPopup) ); - if (flag & 0x0080) break; - } - } - prde++; - } - for (i=0; iNumberOfIdEntries; i++) - { - sLength += 12; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - pMenuHeader = (PIMAGE_MENU_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - // strange case - if (pMenuHeader->wVersion | pMenuHeader->cbHeaderSize) - { - pwd = (WORD *)((DWORD)pMenuHeader + 16); - size = prData->Size; - // expect to return the length needed to report. - // sixteen more bytes to do something - sLength += 16+size; - //StrangeMenuScan (&sLength, &pwd, size); - } - // normal case - else - { - pPopup = (PIMAGE_POPUP_MENU_ITEM) - ((DWORD)pMenuHeader + sizeof (IMAGE_MENU_HEADER)); - while (1) - { - flag = (WORD)MenuScan (&sLength, (WORD **)(&pPopup) ); - if (flag & 0x0080) break; - } - } - prde++; - } - // - // allocate memory for menu names - // - *pszResTypes = (char *)calloc (sLength, 1); - - pMem = *pszResTypes; - // - // and start all over again - // - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdName + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - for (i=0; iNumberOfNamedEntries; i++) - { - pMenuName = (PIMAGE_RESOURCE_DIR_STRING_U) - ((DWORD)prdType + (prde->Name ^ 0x80000000)); - - - for (j=0; jLength; j++) - *pMem++ = (char)(pMenuName->NameString[j]); - *pMem = 0; - pMem++; - - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - pMenuHeader = (PIMAGE_MENU_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - // strange case - if (pMenuHeader->wVersion | pMenuHeader->cbHeaderSize) - { - pwd = (WORD *)((DWORD)pMenuHeader); - size = prData->Size; - strcpy (pMem, ":::::::::::"); pMem +=12; - *(int *)pMem = size; pMem += 4; - StrangeMenuFill (&pMem, &pwd, size); - } - // normal case - else - { - pPopup = (PIMAGE_POPUP_MENU_ITEM) - ((DWORD)pMenuHeader + sizeof (IMAGE_MENU_HEADER)); - while (1) - { - flag = (WORD)MenuFill (&pMem, (WORD **)(&pPopup) ); - if (flag & 0x0080) break; - } - } - prde++; - } - for (i=0; iNumberOfIdEntries; i++) - { - - sprintf (buff, "MenuId_%04X", (prde->Name)); - strcpy (pMem, buff); - pMem += strlen (buff) + 1; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - pMenuHeader = (PIMAGE_MENU_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - // strange case - if (pMenuHeader->wVersion | pMenuHeader->cbHeaderSize) - { - pwd = (WORD *)((DWORD)pMenuHeader); - size = prData->Size; - strcpy (pMem, ":::::::::::"); pMem +=12; - *(int *)pMem = size; pMem += 4; - StrangeMenuFill (&pMem, &pwd, size); - } - // normal case - else - { - pPopup = (PIMAGE_POPUP_MENU_ITEM) - ((DWORD)pMenuHeader + sizeof (IMAGE_MENU_HEADER)); - while (1) - { - flag = (WORD)MenuFill (&pMem, (WORD **)(&pPopup) ); - if (flag & 0x0080) break; - } - } - prde++; - } - - return nMenus; -} - - -// -// This function is written by sang cho -// October 12, 1997 -// -/* print contents of menu */ -int WINAPI PrintStrangeMenu ( - char **psz) -{ - - int i, j, l; - int num; - WORD flag1, flag2; - char buff[128]; - char *ptr, *pmax; - - //return dumpMenu (psz, size); - - ptr = *psz; - - if(strncmp (ptr, ":::::::::::", 11) != 0) - { - printf ("\n#### I don't know why!!!"); - dumpMenu (psz, 1024); - exit (0); - } - - ptr += 12; - num = *(int *)ptr; - ptr += 4; - pmax = ptr+num; - - *psz = ptr; - return dumpMenu (psz, num); - - // I will write some code later... - -} - - - - -// -// This function is written by sang cho -// October 2, 1997 -// -/* print contents of menu */ -int WINAPI PrintMenu ( - int indent, - char **psz) -{ - - int i, j, k, l; - WORD id, num; - WORD flag; - char buff[128]; - char *ptr; - - - ptr = *psz; - //num = *(WORD *)ptr; - //ptr += 2; - while (1) - { - flag = *(WORD *)ptr; - if (flag & 0x0010) // flag == popup - { - printf ("\n\n"); - for (j=0; j= pmax) break; - n++; - if (n%4 == 0) printf (" "); - } - n++; if (n%4 == 0) printf (" "); - l = j; - j++; - for (; j<16; j++) - { n++; if (n%4 == 0) printf (" "); else printf (" "); } - printf (" "); - for (k=0; k= pmax) break; - } - - *psz = ptr; - -} - - - - -// -// This function is written by sang cho -// October 13, 1997 -// -/* scan dialog box and copy dialog box */ -int WINAPI GetContentsOfDialog ( - LPVOID lpFile, - char **pszResTypes) -{ - PIMAGE_RESOURCE_DIRECTORY prdType, prdName, prdLanguage; - PIMAGE_RESOURCE_DIRECTORY_ENTRY prde, prde1; - PIMAGE_RESOURCE_DIR_STRING_U pDialogName; - PIMAGE_RESOURCE_DATA_ENTRY prData; - PIMAGE_DIALOG_HEADER pDialogHeader; - PIMAGE_CONTROL_DATA pControlData; - char buff[32]; - int nCnt=0, i, j; - int num=0; - int size; - int sLength, nDialogs; - WORD flag; - WORD *pwd; - DWORD prdeName; - char *pMem, *pTemp; - BOOL isStrange = FALSE; - - - /* get root directory of resource tree */ - if ((prdType = (PIMAGE_RESOURCE_DIRECTORY)ImageDirectoryOffset - (lpFile, IMAGE_DIRECTORY_ENTRY_RESOURCE)) == NULL) - return 0; - - /* set pointer to first resource type entry */ - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdType + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - for (i=0; iNumberOfIdEntries; i++) - { - if (prde->Name == RT_DIALOG) break; - prde++; - } - if (prde->Name != RT_DIALOG) return 0; - - prdName = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000) ); - if (prdName == NULL) return 0; - - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdName + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - - nDialogs=prdName->NumberOfNamedEntries + prdName->NumberOfIdEntries; - sLength=0; - - for (i=0; iNumberOfNamedEntries; i++) - { - pDialogName = (PIMAGE_RESOURCE_DIR_STRING_U) - ((DWORD)prdType + (prde->Name ^ 0x80000000)); - sLength += pDialogName->Length + 1; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - size = prData->Size; - sLength += 4+size; - prde++; - } - for (i=0; iNumberOfIdEntries; i++) - { - sLength += 14; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - size = prData->Size; - sLength += 4+size; - prde++; - } - // - // allocate memory for menu names - // - *pszResTypes = (char *)calloc (sLength, 1); - - pMem = *pszResTypes; - // - // and start all over again - // - prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdName + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - for (i=0; iNumberOfNamedEntries; i++) - { - pDialogName = (PIMAGE_RESOURCE_DIR_STRING_U) - ((DWORD)prdType + (prde->Name ^ 0x80000000)); - - - for (j=0; jLength; j++) - *pMem++ = (char)(pDialogName->NameString[j]); - *pMem = 0; - pMem++; - - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) continue; - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) continue; - - pDialogHeader = (PIMAGE_DIALOG_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - - - - pwd = (WORD *)((DWORD)pDialogHeader); - size = prData->Size; - *(int *)pMem = size; pMem += 4; - StrangeMenuFill (&pMem, &pwd, size); - - prde++; - } - for (i=0; iNumberOfIdEntries; i++) - { - - sprintf (buff, "DialogId_%04X", (prde->Name)); - strcpy (pMem, buff); - pMem += strlen (buff) + 1; - - prdLanguage = (PIMAGE_RESOURCE_DIRECTORY) - ((DWORD)prdType + (prde->OffsetToData ^ 0x80000000)); - if (prdLanguage == NULL) - { printf ("\nprdLanguage = NULL"); exit (0); } - - prde1 = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) - ((DWORD)prdLanguage + sizeof (IMAGE_RESOURCE_DIRECTORY)); - - prData = (PIMAGE_RESOURCE_DATA_ENTRY) - ((DWORD)prdType + prde1->OffsetToData); - if (prData == NULL) - { printf ("\nprData = NULL"); exit (0); } - - pDialogHeader = (PIMAGE_DIALOG_HEADER) - GetActualAddress (lpFile, prData->OffsetToData); - - - pwd = (WORD *)((DWORD)pDialogHeader); - size = prData->Size; - *(int *)pMem = size; pMem += 4; - StrangeMenuFill (&pMem, &pwd, size); - - prde++; - } - - return nDialogs; -} - - -// -// This function is written by sang cho -// October 14, 1997 -// -/* print contents of dialog */ -int WINAPI PrintNameOrOrdinal ( - char **psz) -{ - char *ptr; - - ptr = *psz; - if (*(WORD *)ptr == 0xFFFF) - { ptr += 2; - printf ("%04X", *(WORD *)ptr); - ptr += 2; - } - else - { - printf ("%c", '"'); - while (*(WORD *)ptr) { printf("%c", *ptr); ptr+= 2; } - ptr += 2; - printf ("%c", '"'); - } - *psz = ptr; -} - - -// -// This function is written by sang cho -// October 14, 1997 -// -/* print contents of dialog */ -int WINAPI PrintDialog ( - char **psz) -{ - int i, j, k, l, n, c; - int num, size; - DWORD flag; - WORD class; - char buff[32]; - char *ptr, *pmax; - BOOL isStrange=FALSE; - - ptr = *psz; - size = *(int *)ptr; - ptr += 4; - pmax = ptr+size; - - // IStype of Dialog Header - flag = *(DWORD *)ptr; - // - // check if flag is right or not - // it has been observed that some dialog information is strange - // and extra work is needed to fix that ... so let's try something - // - - if ((flag & 0xFFFF0000) == 0xFFFF0000) - { - flag = *(DWORD *)(ptr+12); - num = *(short *)(ptr+16); - isStrange = TRUE; - ptr += 26; - } - else - { - num = *(short *)(ptr+8); - ptr += 18; - } - printf (", # of Controls=%03d, Caption:%c", num, '"'); - - // Menu name - if (*(WORD *)ptr == 0xFFFF) ptr += 4; // ordinal - else { while (*(WORD *)ptr) ptr += 2; ptr += 2; } // name - - // Class name - if (*(WORD *)ptr == 0xFFFF) ptr += 4; // ordinal - else { while (*(WORD *)ptr) ptr += 2; ptr += 2; } // name - - // Caption - while (*(WORD *)ptr) { printf("%c", *ptr); ptr+= 2; } - ptr += 2; - printf ("%c", '"'); - - // FONT present - if (flag & 0x00000040) - { - if (isStrange) ptr += 6; else ptr += 2; // FONT size - while (*(WORD *)ptr) ptr += 2; // WCHARs - ptr += 2; // double null - } - - // strange case adjust - if (isStrange) ptr += 8; - - // DWORD padding - if ((ptr-*psz) % 4) ptr += 4 - ((ptr-*psz) % 4); - - // start reporting .. finally - for (i=0; i= pmax) break; - n++; - if (n%4 == 0) printf (" "); - } - n++; if (n%4 == 0) printf (" "); - l = j; - j++; - for (; j<16; j++) - { n++; if (n%4 == 0) printf (" "); else printf (" "); } - printf (" "); - for (k=0; k= pmax) break; - } - */ - - *psz = pmax; - -} - - - - - - -/* function indicates whether debug info has been stripped from file */ -BOOL WINAPI IsDebugInfoStripped ( - LPVOID lpFile) -{ - PIMAGE_FILE_HEADER pfh; - - pfh = (PIMAGE_FILE_HEADER)PEFHDROFFSET (lpFile); - - return (pfh->Characteristics & IMAGE_FILE_DEBUG_STRIPPED); -} - - - - -/* retrieve the module name from the debug misc. structure */ -int WINAPI RetrieveModuleName ( - LPVOID lpFile, - char **pszModule) -{ - - PIMAGE_DEBUG_DIRECTORY pdd; - PIMAGE_DEBUG_MISC pdm = NULL; - int nCnt; - - if (!(pdd = (PIMAGE_DEBUG_DIRECTORY)ImageDirectoryOffset (lpFile, IMAGE_DIRECTORY_ENTRY_DEBUG))) - return 0; - - while (pdd->SizeOfData) - { - if (pdd->Type == IMAGE_DEBUG_TYPE_MISC) - { - pdm = (PIMAGE_DEBUG_MISC)((DWORD)pdd->PointerToRawData + (DWORD)lpFile); - *pszModule = (char *)calloc ((nCnt = (strlen (pdm->Data)))+1, 1); - // may need some unicode business here...above - bcopy (pdm->Data, *pszModule, nCnt); - - break; - } - - pdd ++; - } - - if (pdm != NULL) - return nCnt; - else - return 0; -} - - - - - -/* determine if this is a valid debug file */ -BOOL WINAPI IsDebugFile ( - LPVOID lpFile) -{ - PIMAGE_SEPARATE_DEBUG_HEADER psdh; - - psdh = (PIMAGE_SEPARATE_DEBUG_HEADER)lpFile; - - return (psdh->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE); -} - - - - -/* copy separate debug header structure from debug file */ -BOOL WINAPI GetSeparateDebugHeader ( - LPVOID lpFile, - PIMAGE_SEPARATE_DEBUG_HEADER psdh) -{ - PIMAGE_SEPARATE_DEBUG_HEADER pdh; - - pdh = (PIMAGE_SEPARATE_DEBUG_HEADER)lpFile; - - if (pdh->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE) - { - bcopy ((LPVOID)pdh, (LPVOID)psdh, sizeof (IMAGE_SEPARATE_DEBUG_HEADER)); - return TRUE; - } - - return FALSE; -} - - -/* I need to place these data here to keep integrity of codes */ - -LPVOID lpFile; /* pointer to the contents of the input file */ -LPVOID lpMap; /* pointere to the map of codes processed */ -int nSections; // number of sections -int nResources; // number of resources -int nMenus; // number of menus -int nDialogs; // number of dialogs -int nImportedModules; // number of imported modules -int nFunctions; // number of functions in the imported module -int nExportedFunctions; // number of exported funcions -int imageBase; // image base of the file -int entryPoint; // entry point of the file -int imagebaseRVA; /* imagebase + RVA of the code */ -int CodeOffset; /* starting point of code */ -int CodeSize; /* size of code */ -int vCodeOffset; /* starting point of code */ -int vCodeSize; /* size of code */ -int MapSize; /* size of code map */ -int maxRVA; /* the largest RVA of sections */ -int maxRVAsize; /* size of that section */ - -char *piNameBuff; // import module name buffer -char *pfNameBuff; // import functions in the module name buffer -char *peNameBuff; // export function name buffer -char *pmNameBuff; // menu name buffer -char *pdNameBuff; // dialog name buffer -int piNameBuffSize; // import module name buffer -int pfNameBuffSize; // import functions in the module name buffer -int peNameBuffSize; // export function name buffer -int pmNameBuffSize; // menu name buffer -int pdNameBuffSize; // dialog name buffer - -extern Bnode *head; // label data B-Tree header -extern int btn; // label data B-Tree control number - -int AddressCheck(int); - -// -// I tried to immitate the output of w32dasm disassembler. -// which is a pretty good program. -// but I am disappointed with this program and I myself -// am writting a disassembler. -// This PEdump program is a byproduct of that project. -// so enjoy this program and I hope we will have a little more -// knowledge on windows programming world. -// .... sang cho - -#define MAXSECTIONNUMBER 16 -#define MAXNAMESTRNUMBER 40 -int pedump (argc,argv)\ -int argc; char **argv; -{ - DWORD fileType; - - IMAGE_DOS_HEADER dosHdr; - PIMAGE_FILE_HEADER pfh; - PIMAGE_OPTIONAL_HEADER poh; - PIMAGE_SECTION_HEADER psh; - IMAGE_SECTION_HEADER idsh; - IMAGE_SECTION_HEADER shdr [MAXSECTIONNUMBER]; - PIMAGE_IMPORT_MODULE_DIRECTORY pid; - - int i, j, n; - int mnsize; - int nCnt; - int nSize; - - char *pnstr; - char *pst; -// char *piNameBuff; // import module name buffer -// char *pfNameBuff; // import functions in the module name buffer -// char *peNameBuff; // export function name buffer -// char *pmNameBuff; // menu name buffer -// char *pdNameBuff; // dialog name buffer - - unsigned char *p, *q; - _key_ k; - PKEY pk; - - GetDosHeader (lpFile, &dosHdr); - - if (dosHdr.e_magic == IMAGE_DOS_SIGNATURE) - { - if ((dosHdr.e_lfanew > 4096) || (dosHdr.e_lfanew < 64)) - { - printf ("This file is not PE format ... sorry, it looks like DOS format\n"); - exit (0); - } - } - else - { - printf ("This doesn't look like executable file .. sorry, ...\n"); - exit (0); - } - - fileType = ImageFileType (lpFile); - - if (fileType != IMAGE_NT_SIGNATURE) - { - printf ("This file is not PE format ... sorry,\n"); - exit (0); - } - - //===================================== - // now we can really start processing - //===================================== - - pfh = (PIMAGE_FILE_HEADER) PEFHDROFFSET (lpFile); - - poh = (PIMAGE_OPTIONAL_HEADER) OPTHDROFFSET (lpFile); - printf("PIMAGE_OPTIONAL_HEADER:CodeSize 0x%08x\n",poh->SizeOfCode); - printf("PIMAGE_OPTIONAL_HEADER:ImageBase 0x%08x\n",poh->ImageBase); - printf("PIMAGE_OPTIONAL_HEADER:EntryPoint 0x%08x\n",poh->AddressOfEntryPoint); - printf("PIMAGE_OPTIONAL_HEADER:BaseOfCode 0x%08x\n",poh->BaseOfCode); - CodeSize=poh->SizeOfCode; - psh = (PIMAGE_SECTION_HEADER) SECHDROFFSET (lpFile); - - nSections = pfh->NumberOfSections; - - imageBase = poh->ImageBase; - - entryPoint = poh->AddressOfEntryPoint; - - if (psh == NULL) return 0; - - /* store section headers */ - - for (i=0; i < nSections; i++) - { - shdr[i] = *psh++; - } - - // get Code offset and size, Data offset and size - maxRVA = 0; - - for (i=0; i < nSections; i++) - { - if (!strcasecmp(shdr[i].Name,".text")) - { - fprintf(stderr,"Found Code size 0x%08x\n",shdr[i].SizeOfRawData); - if (shdr[i].SizeOfRawData > CodeSize) - CodeSize =shdr[i].SizeOfRawData; - } - else - fprintf(stderr,"Found string '%s'\n",shdr[i].Name); - if (poh->BaseOfCode == shdr[i].VirtualAddress) - { - printf("Code Offset = %08X, Code Size = %08X \n", - shdr[i].PointerToRawData, shdr[i].SizeOfRawData); - CodeOffset = shdr[i].PointerToRawData; - imagebaseRVA = imageBase + shdr[i].VirtualAddress; - } - if (shdr[i].VirtualAddress>maxRVA) - { - maxRVA = shdr[i].VirtualAddress; - maxRVAsize = shdr[i].SizeOfRawData; - } - if (((shdr[i].Characteristics) & 0xC0000040) == 0xC0000040) - //if (poh->BaseOfData == shdr[i].VirtualAddress) - { - printf ("Data Offset = %08X, Data Size = %08X \n", - shdr[i].PointerToRawData, shdr[i].SizeOfRawData); - break; - } - } - for ( ; i < nSections; i++) - { - if (shdr[i].VirtualAddress>maxRVA) - { - maxRVA = shdr[i].VirtualAddress; - maxRVAsize = shdr[i].SizeOfRawData; - } - } - - printf ("\n"); - - printf ("Number of Objects = %04d (dec), Imagebase = %08Xh \n", - nSections, imageBase); - - // object name alignment - for (i=0; i < nSections; i++) - { - for (j=0;j<7;j++) if (shdr[i].Name[j]==0) shdr[i].Name[j]=32; - shdr[i].Name[7]=0; - } - for (i=0; i < nSections; i++) - { - printf ("\n Object%02d: %8s RVA: %08X Offset: %08X Size: %08X Flags: %08X ", - i+1, shdr[i].Name, shdr[i].VirtualAddress, shdr[i].PointerToRawData, - shdr[i].SizeOfRawData, shdr[i].Characteristics); - } - // Get List of Resources - nResources = GetListOfResourceTypes (lpFile, &pnstr); - pst = pnstr; - printf ("\n"); - printf ("\n+++++++++++++++++++ RESOURCE INFORMATION +++++++++++++++++++"); - printf ("\n"); - if (nResources==0) - printf ("\n There are no Resources in This Application.\n"); - else - { - printf ("\nNumber of Resource Types = %4d (decimal)\n", nResources); - for (i=0; i < nResources; i++) - { - printf ("\n Resource Type %03d: %s",i+1, pst); - pst += strlen ((char *)(pst)) + 1; - } - free ((void *)pnstr); - - printf ("\n"); - printf ("\n+++++++++++++++++++ MENU INFORMATION +++++++++++++++++++"); - printf ("\n"); - - nMenus = GetContentsOfMenu (lpFile, &pmNameBuff); - - if (nMenus == 0) - { - printf("\n There are no Menus in This Application."); - } - else - { - pst = pmNameBuff; - printf ("\nNumber of Menus = %4d (decimal)", nMenus); - - //dumpMenu(&pst, 8096); - for (i=0; i < nMenus; i++) - { - // menu ID print - printf ("\n\n%s", pst); - pst += strlen (pst) + 1; - printf ("\n-------------"); - if (strncmp (pst, ":::::::::::", 11) == 0) - { - printf("\n"); - PrintStrangeMenu (&pst); - } - else - { - PrintMenu (6, &pst); - } - //else PrintStrangeMenu(&pst); - } - free ((void *)pmNameBuff); - printf ("\n"); - } - - printf ("\n"); - printf ("\n+++++++++++++++++ DIALOG INFORMATION +++++++++++++++++++"); - printf ("\n"); - - nDialogs = GetContentsOfDialog (lpFile, &pdNameBuff); - - if (nDialogs == 0) - { - printf("\n There are no Dialogs in This Application."); - } - else - { - pst = pdNameBuff; - printf ("\nNumber of Dialogs = %4d (decimal)", nDialogs); - - printf ("\n"); - - for (i=0; i < nDialogs; i++) - { - // Dialog ID print - printf ("\nName: %s", pst); - pst += strlen (pst) + 1; - PrintDialog (&pst); - } - free ((void *)pdNameBuff); - } - printf ("\n"); - } - - printf ("\n+++++++++++++++++++ IMPORTED FUNCTIONS +++++++++++++++++++"); - - nImportedModules = GetImportModuleNames (lpFile, &piNameBuff); - if (nImportedModules == 0) - { - printf("\n There are no imported Functions in This Application.\n"); - } - else - { - pnstr = piNameBuff; - printf ("\nNumber of Imported Modules = %4d (decimal)\n", nImportedModules); - for (i=0; i < nImportedModules; i++) - { - printf ("\n Import Module %03d: %s",i+1, pnstr + 4); - pnstr += strlen ((char *)(pnstr+4)) + 1 + 4; - } - - printf("\n"); - printf("\n+++++++++++++++++++ IMPORT MODULE DETAILS +++++++++++++++++"); - pnstr = piNameBuff; - for (i=0; i < nImportedModules; i++) - { - printf ("\n\n Import Module %03d: %s \n",i+1, pnstr + 4); - nFunctions = GetImportFunctionNamesByModule (lpFile, pnstr, &pfNameBuff); - pnstr += strlen ((char *)(pnstr+4)) + 1 + 4; - pst = pfNameBuff; - for (j=0;j < nFunctions;j++) - { - printf ("\nAddr:%08X hint(%04X) Name: %s", - (*(int *)pst),(*(short *)(pst+4)), - //(pst+6)); - TranslateFunctionName(pst+6)); - pst += strlen ((char *)(pst+6)) + 1 + 6; - } - free ((void *)pfNameBuff); - } - //free ((void *)piNameBuff); - } - - printf("\n"); - printf("\n+++++++++++++++++++ EXPORTED FUNCTIONS +++++++++++++++++++"); - - nExportedFunctions = GetExportFunctionNames (lpFile, &peNameBuff); - printf ("\nNumber of Exported Functions = %4d (decimal)\n", nExportedFunctions); - MapSize = CodeSize + 1; - lpMap = (void *) calloc (MapSize, 1); - printf("lpMap %p max %p\n",imagebaseRVA, - MapSize+1 + imagebaseRVA); - if (nExportedFunctions > 0) - { - pst = peNameBuff; - - for (i=0; i < nExportedFunctions-1; i++) - { - printf ("\nAddr:%08X Ord:%4d (%04Xh) Name: %s", - (*(int *)pst), (*(WORD *)(pst+4)), (*(WORD *)(pst+4)), - //(pst+6)); - TranslateFunctionName(pst+6)); - // this one is needed to link export function names to codes.. - k.class=2048; k.c_ref= *(int *)pst; k.c_pos=0; - if (AddressCheck(k.c_ref)) - { - MyBtreeInsertEx(&k); - p=lpMap+k.c_ref-imagebaseRVA; - if ((p) && (((unsigned int)p -(unsigned int)lpMap) < MapSize)) - { - *p |= 0x60; - k.class=0; k.c_pos=-(int)(pst+6); - MyBtreeInsert(&k); - } - else - fprintf(stderr,"\nerror"); - } - pst += strlen ((char *)(pst+6)) + 6+1; - } - //free ((void *)peNameBuff); - } - // free ((void *)lpFile); -} diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index e97d820af1e..bb1df1f6ca1 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -13,7 +13,6 @@ #include #include -#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index cbcb390f031..ca5ddee7525 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.22 2001/03/08 22:06:02 dwelch Exp $ +/* $Id: page.c,v 1.23 2001/03/16 18:11:24 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/reactos/ntoskrnl/mm/kmap.c b/reactos/ntoskrnl/mm/kmap.c index 7f0b88cc2b5..79bf53a79a2 100644 --- a/reactos/ntoskrnl/mm/kmap.c +++ b/reactos/ntoskrnl/mm/kmap.c @@ -1,4 +1,4 @@ -/* $Id: kmap.c,v 1.7 2001/03/14 23:19:14 dwelch Exp $ +/* $Id: kmap.c,v 1.8 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 61f1438dfa1..dd661a220fc 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/reactos/ntoskrnl/mm/mdl.c b/reactos/ntoskrnl/mm/mdl.c index b42988f1970..cd4be829646 100644 --- a/reactos/ntoskrnl/mm/mdl.c +++ b/reactos/ntoskrnl/mm/mdl.c @@ -1,4 +1,4 @@ -/* $Id: mdl.c,v 1.30 2001/03/13 16:25:54 dwelch Exp $ +/* $Id: mdl.c,v 1.31 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/reactos/ntoskrnl/mm/mm.c b/reactos/ntoskrnl/mm/mm.c index 8af07eaf877..0dd23870ae9 100644 --- a/reactos/ntoskrnl/mm/mm.c +++ b/reactos/ntoskrnl/mm/mm.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: mm.c,v 1.45 2001/03/13 16:25:54 dwelch Exp $ +/* $Id: mm.c,v 1.46 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -36,7 +36,6 @@ #include #include #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 913f0ebb79c..49e66f7ae69 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -1,4 +1,4 @@ -/* $Id: mminit.c,v 1.13 2001/01/17 15:38:03 dwelch Exp $ +/* $Id: mminit.c,v 1.14 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -18,7 +18,6 @@ #include #include #include -#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/mm/mpw.c b/reactos/ntoskrnl/mm/mpw.c index e3da8ec6afa..611220d4e4d 100644 --- a/reactos/ntoskrnl/mm/mpw.c +++ b/reactos/ntoskrnl/mm/mpw.c @@ -1,4 +1,4 @@ -/* $Id: mpw.c,v 1.4 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: mpw.c,v 1.5 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -15,7 +15,6 @@ #include #include #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index 6e5ad051301..fc25af11324 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1,4 +1,4 @@ -/* $Id: npool.c,v 1.42 2001/03/14 23:19:14 dwelch Exp $ +/* $Id: npool.c,v 1.43 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/mm/pageop.c b/reactos/ntoskrnl/mm/pageop.c index 6db3af1e7c1..1bbde335a34 100644 --- a/reactos/ntoskrnl/mm/pageop.c +++ b/reactos/ntoskrnl/mm/pageop.c @@ -1,4 +1,4 @@ -/* $Id: pageop.c,v 1.3 2001/03/13 16:25:54 dwelch Exp $ +/* $Id: pageop.c,v 1.4 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,6 @@ #include #include #include -#include #include #define NDEBUG diff --git a/reactos/ntoskrnl/mm/pager.c b/reactos/ntoskrnl/mm/pager.c index 57756a5db4d..b40bda3e8b2 100644 --- a/reactos/ntoskrnl/mm/pager.c +++ b/reactos/ntoskrnl/mm/pager.c @@ -1,4 +1,4 @@ -/* $Id: pager.c,v 1.6 2001/01/08 02:14:06 dwelch Exp $ +/* $Id: pager.c,v 1.7 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -15,7 +15,6 @@ #include #include #include -#include #define NDEBUG #include diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index 92797f23344..042b74c2631 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -1,4 +1,4 @@ -/* $Id: virtual.c,v 1.43 2001/03/16 16:05:34 dwelch Exp $ +/* $Id: virtual.c,v 1.44 2001/03/16 18:11:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index 7859848927a..dac5e727bc4 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.30 2001/02/02 20:47:14 ekohl Exp $ +/* $Id: create.c,v 1.31 2001/03/16 18:11:24 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/ps/debug.c b/reactos/ntoskrnl/ps/debug.c index 4b393a60114..cdddf14c2f8 100644 --- a/reactos/ntoskrnl/ps/debug.c +++ b/reactos/ntoskrnl/ps/debug.c @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: debug.c,v 1.2 2001/03/14 16:30:08 dwelch Exp $ +/* $Id: debug.c,v 1.3 2001/03/16 18:11:24 dwelch Exp $ * - * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/debug.c * PURPOSE: Thread managment @@ -43,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/reactos/ntoskrnl/ps/suspend.c b/reactos/ntoskrnl/ps/suspend.c index 4c6162c524e..e4ba5f4deb9 100644 --- a/reactos/ntoskrnl/ps/suspend.c +++ b/reactos/ntoskrnl/ps/suspend.c @@ -1,4 +1,4 @@ -/* $Id: suspend.c,v 1.3 2001/02/06 00:11:20 dwelch Exp $ +/* $Id: suspend.c,v 1.4 2001/03/16 18:11:24 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index 6fc8f76bdf1..04720c27e78 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.70 2001/03/07 16:48:45 dwelch Exp $ +/* $Id: thread.c,v 1.71 2001/03/16 18:11:24 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include