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

Questions about Wine on Linux
Post Reply
xuanwenchao
Newbie
Newbie
Posts: 2
Joined: Tue Jun 20, 2023 2:00 am

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

Post by xuanwenchao »

base 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:

Code: Select all

    BOOLEAN WINAPI founction_A(){
     return TRUE;
    }
Contents of win32u.c file:

Code: Select all

    #if 0
    #pragma makedep unix
    #endif
    __attribute__((visibility ("default"))) BOOL WINAPI founction_B(){
     return TRUE;
    }
Contents of main.c file:

Code: Select all

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:

Code: Select all

@ stdcall founction_A()
@ stdcall -syscall  founction_B()
Contents of dlls/tmp/Makefile.in file:

Code: Select all

    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:

Code: Select all

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:

Code: Select all

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

please help me, thanks so much.

how to resolve this issue.

same question in Stackoverflow:
https://stackoverflow.com/questions/779 ... n-the-wine
Post Reply