Skip to content

Commit

Permalink
[KERNELBASE] Get loader.c building
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Nov 1, 2024
1 parent c75aea3 commit b860ca1
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 4 deletions.
1 change: 1 addition & 0 deletions dll/win32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ add_subdirectory(itss)
add_subdirectory(jscript)
add_subdirectory(jsproxy)
add_subdirectory(kernel32)
add_subdirectory(KernelBase)
add_subdirectory(loadperf)
add_subdirectory(lpk)
add_subdirectory(lsasrv)
Expand Down
19 changes: 18 additions & 1 deletion dll/win32/KernelBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,21 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
add_definitions(-D_WIN32_WINNT=0x601 -DWINVER=0x601)

add_subdirectory(wine)
add_subdirectory(wine)

spec2def(KernelBase.dll KernelBase.spec ADD_IMPORTLIB)

list(APPEND SOURCE
DllMain.c)

add_library(KernelBase MODULE
${SOURCE}
wine/KernelBase.rc
${CMAKE_CURRENT_BINARY_DIR}/KernelBase_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/KernelBase.def)

target_link_libraries(KernelBase kernelbase_static)
set_module_type(KernelBase win32dll ENTRYPOINT DllMain)
add_importlibs(KernelBase ntdll ntdll_vista)
add_dependencies(KernelBase psdk)
add_cd_file(TARGET KernelBase DESTINATION reactos/system32 FOR all)
19 changes: 19 additions & 0 deletions dll/win32/KernelBase/DllMain.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

/* PSDK/NDK Headers */
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winreg.h>
#include <wincon.h>
#include <winuser.h>

BOOL
WINAPI
DllMain(HANDLE hDll,
DWORD dwReason,
LPVOID lpReserved)
{

return TRUE;
}
Empty file.
20 changes: 19 additions & 1 deletion dll/win32/KernelBase/wine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
add_definitions(-D__WINESRC__ -D_KERNEL32_ -DWINVER=0x601 -D_WIN32_WINNT=0x601)
add_definitions(
-D__WINESRC__
-D_WINE
-D__ROS_LONG64__
-D_KERNELBASE_)

# TODO:
remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
add_definitions(-D_WIN32_WINNT=0x601 -DWINVER=0x601)

include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)

list(APPEND SOURCE_STATIC
#console.c #looks like ReactOS console.c is nothing like wine.
loader.c
)

add_library(kernelbase_static ${SOURCE_STATIC})
target_link_libraries(kernelbase_static ${PSEH_LIB})
add_dependencies(kernelbase_static psdk)
13 changes: 13 additions & 0 deletions dll/win32/KernelBase/wine/hacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

//TODO: everything here belongs somewhere, to save time put them here.

#define RESOURCE_ENUM_LN 0x0001
#define RESOURCE_ENUM_MUI 0x0002
#define RESOURCE_ENUM_MUI_SYSTEM 0x0004
#define RESOURCE_ENUM_VALIDATE 0x0008


NTSYSAPI NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings(DWORD,HANDLE,const WCHAR*,const WCHAR*,WCHAR*,SIZE_T,SIZE_T*);
NTSYSAPI NTSTATUS WINAPI LdrSetDefaultDllDirectories(ULONG);
NTSYSAPI NTSTATUS WINAPI LdrRemoveDllDirectory(void*);
4 changes: 4 additions & 0 deletions dll/win32/KernelBase/wine/kernelbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "windef.h"
#include "winbase.h"

#ifdef __REACTOS__
#include "hacks.h"
#endif

struct pseudo_console
{
HANDLE signal;
Expand Down
14 changes: 12 additions & 2 deletions dll/win32/KernelBase/wine/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "ddk/ntddk.h"
#include "kernelbase.h"
#include "wine/list.h"
#include "wine/asm.h"
Expand Down Expand Up @@ -60,6 +59,7 @@ static CRITICAL_SECTION exclusive_datafile_list_section = { &critsect_debug, -1,
* Modules
***********************************************************************/

#ifndef __REACTOS__ // Let use the reactos implementation of this

/******************************************************************
* get_proc_address
Expand Down Expand Up @@ -492,12 +492,19 @@ FARPROC WINAPI DECLSPEC_HOTPATCH GetProcAddress( HMODULE module, LPCSTR function

#endif /* __x86_64__ */

#endif

/***********************************************************************
* IsApiSetImplemented (kernelbase.@)
*/
BOOL WINAPI IsApiSetImplemented( LPCSTR name )
{
#ifdef __REACTOS__
return TRUE;
/*
* ReactOS always has API sets on.
*/
#else
UNICODE_STRING str;
NTSTATUS status;
BOOLEAN in_schema, present;
Expand All @@ -506,8 +513,10 @@ BOOL WINAPI IsApiSetImplemented( LPCSTR name )
status = ApiSetQueryApiSetPresenceEx( &str, &in_schema, &present );
RtlFreeUnicodeString( &str );
return !status && present;
#endif
}

#ifndef __REACTOS__

/***********************************************************************
* LoadLibraryA (kernelbase.@)
Expand Down Expand Up @@ -566,6 +575,7 @@ HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW( LPCWSTR name, HANDLE file, DWOR
return module;
}

#endif

/***********************************************************************
* LoadPackagedLibrary (kernelbase.@)
Expand Down Expand Up @@ -1260,4 +1270,4 @@ void WINAPI DECLSPEC_HOTPATCH ReleaseActCtx( HANDLE context )
BOOL WINAPI DECLSPEC_HOTPATCH ZombifyActCtx( HANDLE context )
{
return set_ntstatus( RtlZombifyActivationContext( context ));
}
}
8 changes: 8 additions & 0 deletions sdk/include/psdk/libloaderapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ extern "C" {

typedef void *DLL_DIRECTORY_COOKIE, **PDLL_DIRECTORY_COOKIE;

#ifdef __REACTOS__
DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory(const WCHAR *);
BOOL WINAPI RemoveDllDirectory(DLL_DIRECTORY_COOKIE);
BOOL WINAPI SetDefaultDllDirectories(DWORD);
INT WINAPI FindStringOrdinal(DWORD, const WCHAR *, INT, const WCHAR *, INT, BOOL);
#else
WINBASEAPI DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory(const WCHAR *);
WINBASEAPI BOOL WINAPI RemoveDllDirectory(DLL_DIRECTORY_COOKIE);
WINBASEAPI BOOL WINAPI SetDefaultDllDirectories(DWORD);
WINBASEAPI INT WINAPI FindStringOrdinal(DWORD, const WCHAR *, INT, const WCHAR *, INT, BOOL);
#endif

#ifdef __cplusplus
}
Expand Down

0 comments on commit b860ca1

Please sign in to comment.