Enable atom functions

Don't load NOLOAD sections
Print additional debugging information about module loading

svn path=/trunk/; revision=1749
This commit is contained in:
David Welch 2001-03-30 17:26:42 +00:00
parent 381057612c
commit d135a77c67
4 changed files with 180 additions and 416 deletions

View file

@ -1,4 +1,4 @@
/* $Id: atom.c,v 1.10 2001/03/26 20:46:52 dwelch Exp $
/* $Id: atom.c,v 1.11 2001/03/30 17:26:42 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -26,9 +26,12 @@
* csrss.exe.
*/
#if 0
#define iswlower(c) (c >= L'a' && c <= L'z')
#if 1
static ATOMTABLE GlobalAtomTable;
static ATOMTABLE LocalAtomTable;
/* internal functions */
ATOM GLDeleteAtom(ATOMTABLE *at, ATOM nAtom);
@ -45,58 +48,41 @@ int unicode2ansi( char *ansi,const WCHAR *uni, int s);
int ansi2unicode( WCHAR *uni,const char *ansi, int s);
ATOM
STDCALL
GlobalDeleteAtom(
ATOM nAtom
)
ATOM STDCALL
GlobalDeleteAtom(ATOM nAtom)
{
return GLDeleteAtom(&GlobalAtomTable, nAtom);
return GLDeleteAtom(&GlobalAtomTable, nAtom);
}
BOOL
STDCALL
InitAtomTable(
DWORD nSize
)
BOOL STDCALL
InitAtomTable(DWORD nSize)
{
// nSize should be a prime number
/* nSize should be a prime number */
if ( nSize < 4 || nSize >= 512 )
{
nSize = 37;
}
if ( (GetCurrentPeb()->LocalAtomTable).lpDrvData == NULL )
{
(GetCurrentPeb()->LocalAtomTable).lpDrvData =
HeapAlloc(
GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(nSize * sizeof (ATOMENTRY))
);
}
return TRUE;
if ( nSize < 4 || nSize >= 512 )
{
nSize = 37;
}
if (LocalAtomTable.lpDrvData == NULL)
{
LocalAtomTable.lpDrvData =
RtlAllocateHeap(GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(nSize * sizeof (ATOMENTRY)));
}
return TRUE;
}
ATOM
STDCALL
DeleteAtom(
ATOM nAtom
)
ATOM STDCALL
DeleteAtom(ATOM nAtom)
{
return GLDeleteAtom(
& GetCurrentPeb()->LocalAtomTable,
nAtom
);
return GLDeleteAtom(&LocalAtomTable, nAtom);
}
ATOM STDCALL
GlobalAddAtomA(LPCSTR lpString)
{
@ -104,193 +90,141 @@ GlobalAddAtomA(LPCSTR lpString)
WCHAR* lpBuffer;
ATOM atom;
lpBuffer = (WCHAR *) HeapAlloc(GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(BufLen * sizeof (WCHAR)));
lpBuffer =
(WCHAR *) RtlAllocateHeap(GetProcessHeap(),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(BufLen * sizeof (WCHAR)));
ansi2unicode(lpBuffer, lpString, BufLen);
atom = AWGLAddAtom(&GlobalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(), 0, lpBuffer);
RtlFreeHeap(GetProcessHeap(), 0, lpBuffer);
return(atom);
}
ATOM
STDCALL
GlobalAddAtomW(
LPCWSTR lpString
)
ATOM STDCALL
GlobalAddAtomW(LPCWSTR lpString)
{
return AWGLAddAtom(&GlobalAtomTable, lpString);
return AWGLAddAtom(&GlobalAtomTable, lpString);
}
ATOM
STDCALL
GlobalFindAtomA(
LPCSTR lpString
)
ATOM STDCALL
GlobalFindAtomA(LPCSTR lpString)
{
ATOM a;
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR));
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(),0,lpBuffer);
return a;
ATOM a;
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR *)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR));
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
RtlFreeHeap(GetProcessHeap(),0,lpBuffer);
return a;
}
ATOM
STDCALL
GlobalFindAtomW(
const WCHAR *lpString
)
ATOM STDCALL
GlobalFindAtomW(const WCHAR *lpString)
{
return AWGLFindAtom(&GlobalAtomTable, lpString);
return AWGLFindAtom(&GlobalAtomTable, lpString);
}
UINT
STDCALL
GlobalGetAtomNameA(
ATOM nAtom,
char *lpBuffer,
int nSize
)
UINT STDCALL
GlobalGetAtomNameA(ATOM nAtom,
char *lpBuffer,
int nSize)
{
WCHAR *lpUnicode = (WCHAR *)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *sizeof(WCHAR));
UINT x = AWGLGetAtomName(&GlobalAtomTable,nAtom, lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
RtlFreeHeap(GetProcessHeap(),0,lpUnicode);
return x;
}
UINT STDCALL
GlobalGetAtomNameW(ATOM nAtom,
WCHAR * lpBuffer,
int nSize)
{
WCHAR *lpUnicode = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *sizeof(WCHAR));
UINT x = AWGLGetAtomName(&GlobalAtomTable,nAtom, lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
HeapFree(GetProcessHeap(),0,lpUnicode);
return x;
return AWGLGetAtomName(&GlobalAtomTable, nAtom, lpBuffer, nSize);
}
UINT
STDCALL
GlobalGetAtomNameW(
ATOM nAtom,
WCHAR * lpBuffer,
int nSize
)
ATOM STDCALL
AddAtomA(const char *lpString)
{
return AWGLGetAtomName(&GlobalAtomTable, nAtom, lpBuffer, nSize);
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR*)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLAddAtom(&LocalAtomTable, lpBuffer);
RtlFreeHeap(GetProcessHeap(),0,lpBuffer);
return a;
}
ATOM
STDCALL
AddAtomA(
const char *lpString
)
ATOM STDCALL
AddAtomW(const WCHAR * lpString)
{
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLAddAtom(&GetCurrentPeb()->LocalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(),0,lpBuffer);
return a;
return AWGLAddAtom(&LocalAtomTable, lpString);
}
ATOM
STDCALL
AddAtomW(
const WCHAR * lpString
)
ATOM STDCALL
FindAtomA(const char *lpString)
{
return AWGLAddAtom(&GetCurrentPeb()->LocalAtomTable, lpString);
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR *)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&LocalAtomTable, lpBuffer);
RtlFreeHeap(GetProcessHeap(),0,lpBuffer);
return a;
}
ATOM
STDCALL
FindAtomA(
const char *lpString
)
ATOM STDCALL
FindAtomW(const WCHAR * lpString)
{
UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
ATOM a;
ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GetCurrentPeb()->LocalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(),0,lpBuffer);
return a;
return AWGLFindAtom(&LocalAtomTable, lpString);
}
ATOM
STDCALL
FindAtomW(
const WCHAR * lpString
)
UINT STDCALL
GetAtomNameA(ATOM nAtom,
char *lpBuffer,
int nSize)
{
return AWGLFindAtom(&GetCurrentPeb()->LocalAtomTable, lpString);
LPWSTR lpUnicode = (WCHAR *)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *2);
UINT x = AWGLGetAtomName(&GlobalAtomTable, nAtom,lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
RtlFreeHeap(GetProcessHeap(),0,lpUnicode);
return x;
}
UINT
STDCALL
GetAtomNameA(
ATOM nAtom,
char *lpBuffer,
int nSize
)
UINT STDCALL
GetAtomNameW(ATOM nAtom,
WCHAR * lpBuffer,
int nSize)
{
LPWSTR lpUnicode = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *2);
UINT x = AWGLGetAtomName(&GlobalAtomTable, nAtom,lpUnicode,nSize);
unicode2ansi(lpBuffer,lpUnicode,nSize);
HeapFree(GetProcessHeap(),0,lpUnicode);
return x;
}
UINT
STDCALL
GetAtomNameW(
ATOM nAtom,
WCHAR * lpBuffer,
int nSize
)
{
return AWGLGetAtomName(&GetCurrentPeb()->LocalAtomTable,nAtom,lpBuffer, nSize);
return AWGLGetAtomName(&LocalAtomTable,nAtom,lpBuffer, nSize);
}
ATOM
GLDeleteAtom(
ATOMTABLE *at, ATOM nAtom
)
GLDeleteAtom(ATOMTABLE *at, ATOM nAtom)
{
ATOMENTRY *lp;
/* a free slot has q == 0 && refcnt == 0 */
if((lp = GetAtomPointer(at,nAtom - ATOMBASE))) {
if(lp->idsize)
lp->refcnt--;
if(lp->refcnt == 0) {
HeapFree(GetProcessHeap(),0,at->AtomTable);
at->AtomTable = NULL;
HeapFree(GetProcessHeap(),0,at->AtomData);
at->AtomData = NULL;
return lp->q = 0;
}
}
return nAtom;
ATOMENTRY *lp;
/* a free slot has q == 0 && refcnt == 0 */
if((lp = GetAtomPointer(at,nAtom - ATOMBASE))) {
if(lp->idsize)
lp->refcnt--;
if(lp->refcnt == 0) {
RtlFreeHeap(GetProcessHeap(),0,at->AtomTable);
at->AtomTable = NULL;
RtlFreeHeap(GetProcessHeap(),0,at->AtomData);
at->AtomData = NULL;
return lp->q = 0;
}
}
return nAtom;
}
@ -347,7 +281,7 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
/* so expand or create the table */
if(at->AtomTable == 0)
{
at->AtomTable = (ATOMENTRY *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(ATOMENTRY));
at->AtomTable = (ATOMENTRY *) RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(ATOMENTRY));
at->TableSize = 1;
lp = at->AtomTable;
index = 0;
@ -355,7 +289,7 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
else
{
at->TableSize++;
at->AtomTable = (ATOMENTRY *) HeapReAlloc(GetProcessHeap(),0,
at->AtomTable = (ATOMENTRY *) RtlReAllocateHeap(GetProcessHeap(),0,
(LPVOID) at->AtomTable,
at->TableSize * sizeof(ATOMENTRY));
lp = &at->AtomTable[at->TableSize - 1];
@ -372,11 +306,11 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
newlen = at->DataSize + atomlen;
if(at->AtomData == 0) {
at->AtomData = (WCHAR *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,newlen*2);
at->AtomData = (WCHAR *) RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,newlen*2);
lp->idx = 0;
} else {
at->AtomData = (WCHAR *) HeapReAlloc(GetProcessHeap(),0,at->AtomData,newlen*2);
at->AtomData = (WCHAR *) RtlReAllocateHeap(GetProcessHeap(),0,at->AtomData,newlen*2);
lp->idx = at->DataSize;
}

View file

@ -1,31 +1,10 @@
/* $Id: stubs.c,v 1.24 2001/02/10 22:01:50 ea Exp $
/* $Id: stubs.c,v 1.25 2001/03/30 17:26:42 dwelch Exp $
*
* KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them.
*/
#include <windows.h>
ATOM
STDCALL
AddAtomA (
LPCSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
ATOM
STDCALL
AddAtomW (
LPCWSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
BOOL
STDCALL
AddConsoleAliasA (
@ -400,18 +379,6 @@ CreateVirtualBuffer (
return 0;
}
ATOM
STDCALL
DeleteAtom (
ATOM nAtom
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
WINBOOL
STDCALL
DisconnectNamedPipe (
@ -747,29 +714,6 @@ ExtendVirtualBuffer (
return FALSE;
}
ATOM
STDCALL
FindAtomW (
LPCWSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
ATOM
STDCALL
FindAtomA (
LPCSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
WINBOOL
STDCALL
FindCloseChangeNotification (
@ -902,34 +846,6 @@ GetACP (VOID)
return 0;
}
UINT
STDCALL
GetAtomNameW (
ATOM nAtom,
LPWSTR lpBuffer,
int nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
UINT
STDCALL
GetAtomNameA (
ATOM nAtom,
LPSTR lpBuffer,
int nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
WINBOOL
STDCALL
GetBinaryTypeW (
@ -2075,28 +1991,6 @@ GetVDMCurrentDirectories (
return 0;
}
ATOM
STDCALL
GlobalAddAtomW (
LPCWSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
ATOM
STDCALL
GlobalAddAtomA (
LPCSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
/*
HGLOBAL
STDCALL
@ -2120,40 +2014,6 @@ GlobalCompact (
return 0;
}
ATOM
STDCALL
GlobalDeleteAtom (
ATOM nAtom
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
ATOM
STDCALL
GlobalFindAtomW (
LPCWSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
ATOM
STDCALL
GlobalFindAtomA (
LPCSTR lpString
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
VOID
STDCALL
GlobalFix (
@ -2187,32 +2047,6 @@ GlobalFree (
}
*/
UINT
STDCALL
GlobalGetAtomNameA (
ATOM nAtom,
LPSTR lpBuffer,
int nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
UINT
STDCALL
GlobalGetAtomNameW (
ATOM nAtom,
LPWSTR lpBuffer,
int nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HGLOBAL
STDCALL
GlobalHandle (
@ -2394,18 +2228,6 @@ HeapWalk (
return FALSE;
}
WINBOOL
STDCALL
InitAtomTable (
DWORD nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
DWORD
STDCALL
InvalidateConsoleDIBits (

View file

@ -56,51 +56,7 @@ _multiboot_entry:
/*
* This must be PIC because we haven't set up paging yet
*/
movl $(startup_pagedirectory - 0xc0000000 + 0x200000), %edx
movl %edx, %cr3
/*
* Enable paging
*/
movl %cr0, %edx
orl $0x80000000, %edx
movl %edx, %cr0
/*
* Do an absolute jump because we now want to execute at 0xc0000000
*/
movl $.l2, %edx
jmp *%edx
.l2:
/*
* Load the GDTR and IDTR with new tables located above
* 0xc0000000
*/
lgdt _gdt_descr
lidt _idt_descr
/*
* Reload the data segment registers
*/
movl $KERNEL_DS, %edx
movl %edx, %ds
movl %edx, %es
movl %edx, %fs
movl %edx, %gs
movl %edx, %ss
/*
* Load the initial ring0 stack
*/
movl $_init_stack_top, %esp
/*
* Initialize EFLAGS
*/
pushl $0
popfl
/*
* Gcc expects this at all times
*/
@ -115,9 +71,59 @@ _multiboot_entry:
subl $__bss_start__, %ecx
shr $2, %ecx
movl $__bss_start__, %edi
subl $0xc0000000, %edi
addl $0x200000, %edi
rep
stosl
/*
* Set up the PDBR
*/
movl $(startup_pagedirectory - 0xc0000000 + 0x200000), %eax
movl %eax, %cr3
/*
* Enable paging
*/
movl %cr0, %eax
orl $0x80000000, %eax
movl %eax, %cr0
/*
* Do an absolute jump because we now want to execute at 0xc0000000
*/
movl $.l2, %eax
jmp *%eax
.l2:
/*
* Load the GDTR and IDTR with new tables located above
* 0xc0000000
*/
lgdt _gdt_descr
lidt _idt_descr
/*
* Reload the data segment registers
*/
movl $KERNEL_DS, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
/*
* Load the initial ring0 stack
*/
movl $_init_stack_top, %esp
/*
* Initialize EFLAGS
*/
pushl $0
popfl
/*
* Call the main ring0 initialization
*/

View file

@ -1,4 +1,4 @@
/* $Id: loader.c,v 1.70 2001/03/27 21:43:43 dwelch Exp $
/* $Id: loader.c,v 1.71 2001/03/30 17:26:42 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -421,12 +421,13 @@ LdrProcessDriver(PVOID ModuleLoadBase, PCHAR FileName)
RtlFreeUnicodeString(&ModuleName);
if (ModuleObject == NULL)
{
return STATUS_UNSUCCESSFUL;
DPRINT1("Driver load was unsuccessful\n");
return(STATUS_UNSUCCESSFUL);
}
/* FIXME: should we dereference the ModuleObject here? */
return IoInitializeDriver(ModuleObject->EntryPoint);
return(IoInitializeDriver(ModuleObject->EntryPoint));
}
PMODULE_OBJECT
@ -441,6 +442,7 @@ LdrProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING ModuleName)
return LdrPEProcessModule(ModuleLoadBase, ModuleName);
}
DPRINT1("Module wasn't PE\n");
return 0;
}