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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -26,9 +26,12 @@
* csrss.exe. * csrss.exe.
*/ */
#if 0 #define iswlower(c) (c >= L'a' && c <= L'z')
#if 1
static ATOMTABLE GlobalAtomTable; static ATOMTABLE GlobalAtomTable;
static ATOMTABLE LocalAtomTable;
/* internal functions */ /* internal functions */
ATOM GLDeleteAtom(ATOMTABLE *at, ATOM nAtom); 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); int ansi2unicode( WCHAR *uni,const char *ansi, int s);
ATOM ATOM STDCALL
STDCALL GlobalDeleteAtom(ATOM nAtom)
GlobalDeleteAtom(
ATOM nAtom
)
{ {
return GLDeleteAtom(&GlobalAtomTable, nAtom); return GLDeleteAtom(&GlobalAtomTable, nAtom);
} }
BOOL BOOL STDCALL
STDCALL InitAtomTable(DWORD nSize)
InitAtomTable(
DWORD nSize
)
{ {
// nSize should be a prime number /* nSize should be a prime number */
if ( nSize < 4 || nSize >= 512 ) if ( nSize < 4 || nSize >= 512 )
{ {
nSize = 37; nSize = 37;
} }
if ( (GetCurrentPeb()->LocalAtomTable).lpDrvData == NULL ) if (LocalAtomTable.lpDrvData == NULL)
{ {
(GetCurrentPeb()->LocalAtomTable).lpDrvData = LocalAtomTable.lpDrvData =
HeapAlloc( RtlAllocateHeap(GetProcessHeap(),
GetProcessHeap(), (HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY), (nSize * sizeof (ATOMENTRY)));
(nSize * sizeof (ATOMENTRY)) }
);
} return TRUE;
return TRUE;
} }
ATOM ATOM STDCALL
STDCALL DeleteAtom(ATOM nAtom)
DeleteAtom(
ATOM nAtom
)
{ {
return GLDeleteAtom( return GLDeleteAtom(&LocalAtomTable, nAtom);
& GetCurrentPeb()->LocalAtomTable,
nAtom
);
} }
ATOM STDCALL ATOM STDCALL
GlobalAddAtomA(LPCSTR lpString) GlobalAddAtomA(LPCSTR lpString)
{ {
@ -104,193 +90,141 @@ GlobalAddAtomA(LPCSTR lpString)
WCHAR* lpBuffer; WCHAR* lpBuffer;
ATOM atom; ATOM atom;
lpBuffer = (WCHAR *) HeapAlloc(GetProcessHeap(), lpBuffer =
(HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY), (WCHAR *) RtlAllocateHeap(GetProcessHeap(),
(BufLen * sizeof (WCHAR))); (HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY),
(BufLen * sizeof (WCHAR)));
ansi2unicode(lpBuffer, lpString, BufLen); ansi2unicode(lpBuffer, lpString, BufLen);
atom = AWGLAddAtom(&GlobalAtomTable, lpBuffer); atom = AWGLAddAtom(&GlobalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(), 0, lpBuffer); RtlFreeHeap(GetProcessHeap(), 0, lpBuffer);
return(atom); return(atom);
} }
ATOM STDCALL
GlobalAddAtomW(LPCWSTR lpString)
ATOM
STDCALL
GlobalAddAtomW(
LPCWSTR lpString
)
{ {
return AWGLAddAtom(&GlobalAtomTable, lpString); return AWGLAddAtom(&GlobalAtomTable, lpString);
} }
ATOM ATOM STDCALL
STDCALL GlobalFindAtomA(LPCSTR lpString)
GlobalFindAtomA(
LPCSTR lpString
)
{ {
ATOM a; ATOM a;
UINT BufLen = strlen(lpString); UINT BufLen = strlen(lpString);
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR)); WCHAR *lpBuffer = (WCHAR *)RtlAllocateHeap(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR));
ansi2unicode(lpBuffer, lpString,BufLen); ansi2unicode(lpBuffer, lpString,BufLen);
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer); a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
HeapFree(GetProcessHeap(),0,lpBuffer); RtlFreeHeap(GetProcessHeap(),0,lpBuffer);
return a; return a;
} }
ATOM ATOM STDCALL
STDCALL GlobalFindAtomW(const WCHAR *lpString)
GlobalFindAtomW(
const WCHAR *lpString
)
{ {
return AWGLFindAtom(&GlobalAtomTable, lpString); return AWGLFindAtom(&GlobalAtomTable, lpString);
} }
UINT UINT STDCALL
STDCALL GlobalGetAtomNameA(ATOM nAtom,
GlobalGetAtomNameA( char *lpBuffer,
ATOM nAtom, int nSize)
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)
{ {
return AWGLGetAtomName(&GlobalAtomTable, nAtom, lpBuffer, 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;
} }
UINT ATOM STDCALL
STDCALL AddAtomA(const char *lpString)
GlobalGetAtomNameW(
ATOM nAtom,
WCHAR * lpBuffer,
int nSize
)
{ {
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 ATOM STDCALL
STDCALL AddAtomW(const WCHAR * lpString)
AddAtomA(
const char *lpString
)
{ {
UINT BufLen = strlen(lpString); return AWGLAddAtom(&LocalAtomTable, 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;
} }
ATOM STDCALL
ATOM FindAtomA(const char *lpString)
STDCALL
AddAtomW(
const WCHAR * 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
FindAtomW(const WCHAR * lpString)
ATOM
STDCALL
FindAtomA(
const char *lpString
)
{ {
UINT BufLen = strlen(lpString); return AWGLFindAtom(&LocalAtomTable, 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;
} }
UINT STDCALL
ATOM GetAtomNameA(ATOM nAtom,
STDCALL char *lpBuffer,
FindAtomW( int nSize)
const WCHAR * lpString
)
{ {
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
GetAtomNameW(ATOM nAtom,
UINT WCHAR * lpBuffer,
STDCALL int nSize)
GetAtomNameA(
ATOM nAtom,
char *lpBuffer,
int nSize
)
{ {
LPWSTR lpUnicode = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *2); return AWGLGetAtomName(&LocalAtomTable,nAtom,lpBuffer, nSize);
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);
} }
ATOM ATOM
GLDeleteAtom( GLDeleteAtom(ATOMTABLE *at, ATOM nAtom)
ATOMTABLE *at, ATOM nAtom
)
{ {
ATOMENTRY *lp;
ATOMENTRY *lp;
/* a free slot has q == 0 && refcnt == 0 */
/* a free slot has q == 0 && refcnt == 0 */ if((lp = GetAtomPointer(at,nAtom - ATOMBASE))) {
if((lp = GetAtomPointer(at,nAtom - ATOMBASE))) { if(lp->idsize)
if(lp->idsize) lp->refcnt--;
lp->refcnt--;
if(lp->refcnt == 0) {
if(lp->refcnt == 0) { RtlFreeHeap(GetProcessHeap(),0,at->AtomTable);
HeapFree(GetProcessHeap(),0,at->AtomTable); at->AtomTable = NULL;
at->AtomTable = NULL; RtlFreeHeap(GetProcessHeap(),0,at->AtomData);
HeapFree(GetProcessHeap(),0,at->AtomData); at->AtomData = NULL;
at->AtomData = NULL; return lp->q = 0;
return lp->q = 0; }
} }
} return nAtom;
return nAtom;
} }
@ -347,7 +281,7 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
/* so expand or create the table */ /* so expand or create the table */
if(at->AtomTable == 0) 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; at->TableSize = 1;
lp = at->AtomTable; lp = at->AtomTable;
index = 0; index = 0;
@ -355,7 +289,7 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
else else
{ {
at->TableSize++; at->TableSize++;
at->AtomTable = (ATOMENTRY *) HeapReAlloc(GetProcessHeap(),0, at->AtomTable = (ATOMENTRY *) RtlReAllocateHeap(GetProcessHeap(),0,
(LPVOID) at->AtomTable, (LPVOID) at->AtomTable,
at->TableSize * sizeof(ATOMENTRY)); at->TableSize * sizeof(ATOMENTRY));
lp = &at->AtomTable[at->TableSize - 1]; lp = &at->AtomTable[at->TableSize - 1];
@ -372,11 +306,11 @@ AWGLAddAtom(ATOMTABLE *at, const WCHAR *lpString)
newlen = at->DataSize + atomlen; newlen = at->DataSize + atomlen;
if(at->AtomData == 0) { 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; lp->idx = 0;
} else { } 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; 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) * KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them. * Remove from this file, if you implement them.
*/ */
#include <windows.h> #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 BOOL
STDCALL STDCALL
AddConsoleAliasA ( AddConsoleAliasA (
@ -400,18 +379,6 @@ CreateVirtualBuffer (
return 0; return 0;
} }
ATOM
STDCALL
DeleteAtom (
ATOM nAtom
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
WINBOOL WINBOOL
STDCALL STDCALL
DisconnectNamedPipe ( DisconnectNamedPipe (
@ -747,29 +714,6 @@ ExtendVirtualBuffer (
return FALSE; 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 WINBOOL
STDCALL STDCALL
FindCloseChangeNotification ( FindCloseChangeNotification (
@ -902,34 +846,6 @@ GetACP (VOID)
return 0; 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 WINBOOL
STDCALL STDCALL
GetBinaryTypeW ( GetBinaryTypeW (
@ -2075,28 +1991,6 @@ GetVDMCurrentDirectories (
return 0; 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 HGLOBAL
STDCALL STDCALL
@ -2120,40 +2014,6 @@ GlobalCompact (
return 0; 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 VOID
STDCALL STDCALL
GlobalFix ( 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 HGLOBAL
STDCALL STDCALL
GlobalHandle ( GlobalHandle (
@ -2394,18 +2228,6 @@ HeapWalk (
return FALSE; return FALSE;
} }
WINBOOL
STDCALL
InitAtomTable (
DWORD nSize
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
DWORD DWORD
STDCALL STDCALL
InvalidateConsoleDIBits ( InvalidateConsoleDIBits (

View file

@ -56,51 +56,7 @@ _multiboot_entry:
/* /*
* This must be PIC because we haven't set up paging yet * 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 * Gcc expects this at all times
*/ */
@ -115,9 +71,59 @@ _multiboot_entry:
subl $__bss_start__, %ecx subl $__bss_start__, %ecx
shr $2, %ecx shr $2, %ecx
movl $__bss_start__, %edi movl $__bss_start__, %edi
subl $0xc0000000, %edi
addl $0x200000, %edi
rep rep
stosl 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 * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -421,12 +421,13 @@ LdrProcessDriver(PVOID ModuleLoadBase, PCHAR FileName)
RtlFreeUnicodeString(&ModuleName); RtlFreeUnicodeString(&ModuleName);
if (ModuleObject == NULL) if (ModuleObject == NULL)
{ {
return STATUS_UNSUCCESSFUL; DPRINT1("Driver load was unsuccessful\n");
return(STATUS_UNSUCCESSFUL);
} }
/* FIXME: should we dereference the ModuleObject here? */ /* FIXME: should we dereference the ModuleObject here? */
return IoInitializeDriver(ModuleObject->EntryPoint); return(IoInitializeDriver(ModuleObject->EntryPoint));
} }
PMODULE_OBJECT PMODULE_OBJECT
@ -441,6 +442,7 @@ LdrProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING ModuleName)
return LdrPEProcessModule(ModuleLoadBase, ModuleName); return LdrPEProcessModule(ModuleLoadBase, ModuleName);
} }
DPRINT1("Module wasn't PE\n");
return 0; return 0;
} }