diff --git a/reactos/lib/kernel32/misc/ldr.c b/reactos/lib/kernel32/misc/ldr.c new file mode 100644 index 00000000000..0f84e9fad5b --- /dev/null +++ b/reactos/lib/kernel32/misc/ldr.c @@ -0,0 +1,76 @@ +#define WIN32_NO_STATUS +#define WIN32_NO_PEHDR +#include +#include +#include +#include +#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 ) +{ +} \ No newline at end of file diff --git a/reactos/lib/kernel32/misc/rtl.c b/reactos/lib/kernel32/misc/rtl.c new file mode 100644 index 00000000000..31f3a5d22a3 --- /dev/null +++ b/reactos/lib/kernel32/misc/rtl.c @@ -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 + +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); +} \ No newline at end of file