Added a new module named TMP under the dlls directory in the Wine

32 Views Asked by At

Based on wine9.0 and debian11 / OpenGL renderer string: NVDIA GeForce GT 730/PCIe/SSE2.

I have added a new module named TMP under the dlls directory in the Wine source code. The compilation and installation processes seem to be successful, and the tmp.dll and tmp.so files are generated. Then, I created two files user32.c and win32u.c in the dlls/tmp/ directory.

Contents of user32.c file:

    BOOLEAN WINAPI founction_A(){
     return TRUE;
    }

Contents of win32u.c file:

    #if 0
    #pragma makedep unix
    #endif
    __attribute__((visibility ("default"))) BOOL WINAPI founction_B(){
     return TRUE;
    }

Contents of main.c file:

void *__wine_syscall_dispatcher = NULL;
static unixlib_handle_t nfs_handle;
#ifdef _WIN64
#define SYSCALL_ENTRY(id,name,args) __ASM_SYSCALL_FUNC( id + 0x2000, name )
ALL_SYSCALLS64
#else
#define SYSCALL_ENTRY(id,name,args) __ASM_SYSCALL_FUNC( id + 0x2000, name, args )
DEFINE_SYSCALL_HELPER32()
ALL_SYSCALLS32
#endif
#undef SYSCALL_ENTRY

BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved )
{
    HMODULE ntdll;
    void **dispatcher_ptr;
    const UNICODE_STRING ntdll_name = RTL_CONSTANT_STRING( L"ntdll.dll" );
    switch (reason)
    {
    case DLL_THREAD_ATTACH:
    case DLL_PROCESS_ATTACH:
        TRACE("NFS DllMain DLL_THREAD_ATTACH %d \n", __LINE__, reason);
        LdrDisableThreadCalloutsForDll( inst );
        if (__wine_syscall_dispatcher) break;  /* already set through Wow64Transition */
        LdrGetDllHandle( NULL, 0, &ntdll_name, &ntdll );
        dispatcher_ptr = RtlFindExportedRoutineByName( ntdll, "__wine_syscall_dispatcher" );
        __wine_syscall_dispatcher = *dispatcher_ptr ;
        if (!NtQueryVirtualMemory( GetCurrentProcess(), inst, MemoryWineUnixFuncs,
                                   &nfs_handle, sizeof(nfs_handle), NULL ))
            __wine_unix_call( nfs_handle, 0, NULL );
        break;
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            TRACE( "[%d]======>reason:%d \n", __LINE__, reason);
            break;
    }
    return TRUE;
}

Contents of tmp.spec file:

@ stdcall founction_A()
@ stdcall -syscall  founction_B()

Contents of dlls/tmp/Makefile.in file:

    MODULE   =  tmp.dll
    UNIXLIB  = tmp.so
    IMPORTLIB = tmp
    SOURCES = \
     main.c \
     user32.c \
     win32u.c \

I added a reference to tmp in dlls/user32/Makefile.in:

IMPORTS   = $(PNG_PE_LIBS) gdi32 sechost advapi32 kernelbase win32u tmp

Then, in dlls/user32/win.c, I called founction_A.

I also added a reference to tmp in dlls/win32u/Makefile.in:

IMPORTS   = ntdll winecrt0 tmp
UNIX_LIBS    =  -ltmp $(CARBON_LIBS) $(APPKIT_LIBS) $(PTHREAD_LIBS) -lm

Then, in dlls/win32u/windows.c, I called founction_B.

After executing configure.ac and running tools/make_specfile, I generated ALL_SYSCALLS32 successfully. However, When launching an application with the compiled Wine, Wine automatically copies the tmp.DLL file to the drive C/windows/system32 and drive In c/windows/syswow64. Everything looks great.

But various strange issues occur. For example, when starting Foxmail, I receive the following error message:

0034:fixme:font:opentype_enum_font_names handle name format 1
0034:fixme:font:opentype_enum_font_names handle name format 1
0034:fixme:font:opentype_enum_font_names handle name format 1
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0074:fixme:font:opentype_enum_font_names handle name format 1
0074:fixme:font:opentype_enum_font_names handle name format 1
0074:fixme:font:opentype_enum_font_names handle name format 1
002c:fixme:font:opentype_enum_font_names handle name format 1
002c:fixme:font:opentype_enum_font_names handle name format 1
002c:fixme:font:opentype_enum_font_names handle name format 1
0024:err:module:loader_init "comctl32.dll" failed to initialize, aborting
0024:err:module:loader_init Initializing dlls for L"C:\\Foxmail 7.2\\Foxmail.exe" failed, status c0000005

How can I resolve this?

0

There are 0 best solutions below