implemented LoadLibrary and some Rtl stubs

svn path=/trunk/; revision=693
This commit is contained in:
Boudewijn Dekker 1999-10-12 19:45:01 +00:00
parent 348ccdd39f
commit 74031c2379
2 changed files with 174 additions and 0 deletions

View file

@ -0,0 +1,76 @@
#define WIN32_NO_STATUS
#define WIN32_NO_PEHDR
#include <windows.h>
#include <ddk/ntddk.h>
#include <pe.h>
#include <ntdll/ldr.h>
#if 0
typedef struct _DLL
{
PIMAGE_NT_HEADERS Headers;
PVOID BaseAddress;
HANDLE SectionHandle;
struct _DLL* Prev;
struct _DLL* Next;
} DLL, *PDLL;
#endif
HINSTANCE LoadLibraryA( LPCSTR lpLibFileName )
{
HINSTANCE hInst;
int i;
LPSTR lpDllName;
if ( lpLibFileName == NULL )
return NULL;
i = lstrlen(lpLibFileName);
if ( lpLibFileName[i-1] == '.' ) {
lpDllName = HeapAlloc(GetProcessHeap(),0,i+1);
lpstrcpy(lpDllName,lpLibFileName);
lpDllName[i-1] = 0;
}
else if (i > 3 && lpLibFileName[i-3] != '.' ) {
lpDllName = HeapAlloc(GetProcessHeap(),0,i+4);
lpstrcpy(lpDllName,lpLibFileName);
lpstrcat(lpDllName,".dll");
}
else {
lpDllName = HeapAlloc(GetProcessHeap(),0,i+1);
lpstrcpy(lpDllName,lpLibFileName);
}
if ( !NT_SUCCESS(LdrLoadDll(&hInst,lpDllName ))
{
return NULL;
}
return hInst;
}
FARPROC GetProcAddress( HMODULE hModule, LPCSTR lpProcName )
{
FARPROC fnExp;
ULONG Ordinal;
if ( LOWORD(lpProcName )
fnExp = LdrGetExportByOrdinal (hModule,Ordinal);
else
fnExp = LdrGetExportByName (hModule,lpProcName);
return fnExp;
}
WINBOOL FreeLibrary( HMODULE hLibModule )
{
LdrUnloadDll(hLibModule);
return TRUE;
}
HMODULE GetModuleHandle ( LPCTSTR lpModuleName )
{
}

View file

@ -0,0 +1,98 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/kernel32/misc/rtl.c
* PURPOSE:
* PROGRAMMER: Boudewijn Dekker
*/
/* INCLUDES ******************************************************************/
#include <windows.h>
typedef DWORD ( *RtlFillMemoryType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2 );
#undef FillMemory
DWORD
STDCALL
RtlFillMemory (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2
)
{
HINSTANCE hModule;
RtlFillMemoryType FillMemory;
hModule = LoadLibraryA("ntdll.dll");
if ( hModule == NULL )
return -1;
FillMemory = (RtlFillMemoryType)GetProcAddress(hModule, "RtlFillMemory");
if ( FillMemory == NULL )
return -1;
return FillMemory(Unknown0, Unknown1, Unknown2);
}
typedef DWORD ( *RtlMoveMemoryType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2 );
#undef MoveMemory
DWORD
STDCALL
RtlMoveMemory (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2
)
{
HINSTANCE hModule;
RtlMoveMemoryType MoveMemory;
hModule = LoadLibraryA("ntdll.dll");
if ( hModule == NULL )
return -1;
MoveMemory = (RtlMoveMemoryType)GetProcAddress(hModule, "RtlMoveMemory");
if ( MoveMemory == NULL )
return -1;
return MoveMemory(Unknown0, Unknown1, Unknown2);
}
typedef DWORD ( *RtlZeroMemoryType) (DWORD Unknown0, DWORD Unknown1 );
#undef ZeroMemory
DWORD
STDCALL
RtlZeroMemory (
DWORD Unknown0,
DWORD Unknown1
)
{
HINSTANCE hModule;
RtlZeroMemoryType ZeroMemory;
hModule = LoadLibraryA("ntdll.dll");
if ( hModule == NULL )
return -1;
ZeroMemory = (RtlZeroMemoryType)GetProcAddress(hModule, "RtlZeroMemory");
if ( ZeroMemory == NULL )
return -1;
return ZeroMemory(Unknown0, Unknown1);
}
typedef DWORD ( *RtlUnwindType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3 );
#undef Unwind
DWORD
STDCALL
RtlUnwind (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3
)
{
HINSTANCE hModule;
RtlUnwindType Unwind;
hModule = LoadLibraryA("ntdll.dll");
if ( hModule == NULL )
return -1;
Unwind = (RtlUnwindType)GetProcAddress(hModule, "RtlUnwind");
if ( Unwind == NULL )
return -1;
return Unwind(Unknown0, Unknown1, Unknown2, Unknown3);
}