mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
implemented LoadLibray and FreeLibrary
svn path=/trunk/; revision=710
This commit is contained in:
parent
8690858184
commit
a66a6e5dba
5 changed files with 94 additions and 111 deletions
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.26 1999/10/02 20:20:42 ariadne Exp $
|
||||
# $Id: makefile,v 1.27 1999/10/17 18:18:43 ariadne Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -25,14 +25,14 @@ all: $(DLLTARGET)
|
|||
SYNCH_OBJECTS = synch/critical.o synch/event.o synch/wait.o synch/intrlck.o synch/timer.o
|
||||
|
||||
MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o \
|
||||
misc/console.o misc/time.o misc/stubs.o
|
||||
misc/console.o misc/time.o misc/stubs.o misc/rtl.o misc/ldr.o
|
||||
|
||||
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
|
||||
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
|
||||
file/create.o file/find.o file/copy.o file/pipe.o \
|
||||
file/move.o file/lock.o file/rw.o file/delete.o
|
||||
|
||||
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o mem/section.o mem/isbad.o
|
||||
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o mem/section.o mem/isbad.o mem/procmem.o
|
||||
|
||||
NLS_OBJECTS = nls/codepage.o nls/cpmisc.o nls/cptable.o\
|
||||
nls/cp37.o nls/cp437.o nls/cp500.o nls/cp737.o nls/cp775.o nls/cp850.o nls/cp852.o nls/cp855.o nls/cp857.o\
|
||||
|
|
64
reactos/lib/kernel32/mem/procmem.c
Normal file
64
reactos/lib/kernel32/mem/procmem.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: lib/kernel32/mem/procmem.c
|
||||
* PURPOSE:
|
||||
* PROGRAMMER: Boudewijn Dekker
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
WINBOOL
|
||||
STDCALL
|
||||
ReadProcessMemory (
|
||||
HANDLE hProcess,
|
||||
LPCVOID lpBaseAddress,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead
|
||||
)
|
||||
{
|
||||
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NtReadVirtualMemory( hProcess, (PVOID)lpBaseAddress,lpBuffer, nSize,
|
||||
(PULONG)lpNumberOfBytesRead
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
WriteProcessMemory (
|
||||
HANDLE hProcess,
|
||||
LPVOID lpBaseAddress,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesWritten
|
||||
)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NtWriteVirtualMemory( hProcess, lpBaseAddress,lpBuffer, nSize,
|
||||
(PULONG)lpNumberOfBytesWritten
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -4,16 +4,7 @@
|
|||
#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 )
|
||||
{
|
||||
|
@ -28,20 +19,20 @@ HINSTANCE LoadLibraryA( LPCSTR lpLibFileName )
|
|||
i = lstrlen(lpLibFileName);
|
||||
if ( lpLibFileName[i-1] == '.' ) {
|
||||
lpDllName = HeapAlloc(GetProcessHeap(),0,i+1);
|
||||
lpstrcpy(lpDllName,lpLibFileName);
|
||||
lstrcpy(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");
|
||||
lstrcpy(lpDllName,lpLibFileName);
|
||||
lstrcat(lpDllName,".dll");
|
||||
}
|
||||
else {
|
||||
lpDllName = HeapAlloc(GetProcessHeap(),0,i+1);
|
||||
lpstrcpy(lpDllName,lpLibFileName);
|
||||
lstrcpy(lpDllName,lpLibFileName);
|
||||
}
|
||||
|
||||
if ( !NT_SUCCESS(LdrLoadDll(&hInst,lpDllName ))
|
||||
if ( !NT_SUCCESS(LdrLoadDll((PDLL *)&hInst,lpDllName )))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -54,12 +45,11 @@ FARPROC GetProcAddress( HMODULE hModule, LPCSTR lpProcName )
|
|||
{
|
||||
|
||||
FARPROC fnExp;
|
||||
ULONG Ordinal;
|
||||
|
||||
if ( LOWORD(lpProcName )
|
||||
fnExp = LdrGetExportByOrdinal (hModule,Ordinal);
|
||||
if ( HIWORD(lpProcName ) != 0 )
|
||||
fnExp = LdrGetExportByName (hModule,(LPSTR)lpProcName);
|
||||
else
|
||||
fnExp = LdrGetExportByName (hModule,lpProcName);
|
||||
fnExp = LdrGetExportByOrdinal (hModule,(ULONG)lpProcName);
|
||||
|
||||
return fnExp;
|
||||
}
|
||||
|
@ -70,7 +60,20 @@ WINBOOL FreeLibrary( HMODULE hLibModule )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
HMODULE GetModuleHandle ( LPCTSTR lpModuleName )
|
||||
VOID
|
||||
STDCALL
|
||||
FreeLibraryAndExitThread(
|
||||
HMODULE hLibModule,
|
||||
DWORD dwExitCode
|
||||
)
|
||||
{
|
||||
|
||||
if ( FreeLibrary(hLibModule) )
|
||||
ExitThread(dwExitCode);
|
||||
return;
|
||||
}
|
||||
|
||||
HMODULE GetModuleHandleA ( LPCSTR lpModuleName )
|
||||
{
|
||||
return LoadLibraryA(lpModuleName);
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef DWORD ( *RtlFillMemoryType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2 );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: stubs.c,v 1.7 1999/10/07 23:45:07 ekohl Exp $
|
||||
/* $Id: stubs.c,v 1.8 1999/10/17 18:18:44 ariadne Exp $
|
||||
*
|
||||
* KERNEL32.DLL stubs (unimplemented functions)
|
||||
* Remove from this file, if you implement them.
|
||||
|
@ -1059,15 +1059,7 @@ FormatMessageA (
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
FreeLibraryAndExitThread (
|
||||
HMODULE hLibModule,
|
||||
DWORD dwExitCode
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
WINBOOL
|
||||
|
@ -3176,19 +3168,7 @@ RaiseException (
|
|||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
ReadProcessMemory (
|
||||
HANDLE hProcess,
|
||||
LPCVOID lpBaseAddress,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
WINBOOL
|
||||
|
@ -3258,56 +3238,6 @@ ReleaseSemaphore (
|
|||
}
|
||||
|
||||
|
||||
/* FIXME: KERNEL32.RtlFillMemory == NTDLL.RtlFillMemory */
|
||||
DWORD
|
||||
STDCALL
|
||||
RtlFillMemory (
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1,
|
||||
DWORD Unknown2
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: KERNEL32.RtlMoveMemory == NTDLL.RtlMoveMemory */
|
||||
DWORD
|
||||
STDCALL
|
||||
RtlMoveMemory (
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1,
|
||||
DWORD Unknown2
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: KERNEL32.RtlUnwind == NTDLL.RtlUnwind */
|
||||
DWORD
|
||||
STDCALL
|
||||
RtlUnwind (
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1,
|
||||
DWORD Unknown2,
|
||||
DWORD Unknown3
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: KERNEL32.RtlZeroMemory == NTDLL.RtlZeroMemory */
|
||||
DWORD
|
||||
STDCALL
|
||||
RtlZeroMemory (
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
|
@ -4089,19 +4019,6 @@ WritePrivateProfileStructW (
|
|||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
WriteProcessMemory (
|
||||
HANDLE hProcess,
|
||||
LPVOID lpBaseAddress,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesWritten
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
|
|
Loading…
Reference in a new issue