<html><head></head><body><div class="ydp69322a25yahoo-style-wrap" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 13px;"><div><div><span style="color: rgb(38, 40, 42);">On Wednesday, June 5, 2019, 10:44:25 AM GMT+3, Alexandre Julliard <julliard@winehq.org> wrote:</span><br></div></div></div><div id="ydpf41f1443yahoo_quoted_0507841007" class="ydpf41f1443yahoo_quoted"><div style="font-size: 13px; color: rgb(38, 40, 42);">
                <div style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div>
                <div style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div>
                <div style=""><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Tarmo Pikaro <<a shape="rect" href="mailto:tapika@yahoo.com" rel="nofollow" target="_blank">tapika@yahoo.com</a>> writes:<br clear="none"><br clear="none">>> Other stuff like missing WideCharToMultiByte can be<br clear="none">>> addressed by providing the missing functions in your own separate object<br clear="none">>> file, without changing the source.<br clear="none">><br clear="none">> I've scanned quite many unicode libraries and concluded of bringing up cutf library alive - that is basically a replacement for<br clear="none">> WideCharToMultiByte & windows api - uses less call arguments, but can achieve stuff.<br clear="none">> <br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>My point is that you can write a simple WideCharToMultiByte wrapper on<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>top of your cutf library, and then you don't need to patch dbghelp at<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>all, only to link it against your wrapper.<div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">I think wrapping can go in either direction, but you must admit that writing:</div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span><br></span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>len = utf8zestimate(searchPath);</span><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span><br></span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>is shorter than:</span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span><br></span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>len = MultiByteToWideChar(CP_ACP, 0, searchPath, -1, NULL, 0);</span><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">by 6-1 = 5 parameters, </div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">and this form:</div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>utf8ztowchar(searchPath, sp, len);</span><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span><br></span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>is also shorter than:</span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span><br></span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><span>MultiByteToWideChar(CP_ACP, 0, searchPath, -1, sp, len);</span></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br clear="none">by 6 - 3 = 3 parameters.<br><br>What I'm afraid is usage of active code page (CP_ACP), which might be run-time configured via some locale command.</div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">I have tried to search some documentation on active PE structures, but could not find any - suspect it's relatively ancient </div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">structures without decent documentation. Made once upon a time as ascii, and never were designed from unicode perspective.</div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107"><br></div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">Btw - windows C++ provides such classes as CA2W(), CW2A() - it can give even shorter form - </div><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd87107">wondering if dbghelp can be upgraded to C++ ? (pros / cons?)<br><br><br clear="none">> I would like to head into direction of having only one compilation instead of multiple -<br clear="none">> <a shape="rect" href="https://www.reddit.com/r/cpp/comments/bjgt0j/make_portable_dll_without_second_compilation/" rel="nofollow" target="_blank">https://www.reddit.com/r/cpp/comments/bjgt0j/make_portable_dll_without_second_compilation/</a><br clear="none">><br clear="none">> basically replace .so & .dll file format with one centralized file format, which can be run on multiple platforms. (e.g. linux and windows)<br clear="none">><br clear="none">> Please don't tell me it will be a long way to get there, I know that - but there already exists prototypes<br clear="none">> who managed to make this happen. I think wine's dbghelp is good place to start from, but<br clear="none">> we might indeed require native compilers support, need to locate good guys for this job.</div><br clear="none"><br clear="none">> The file format is not the interesting part, it's easy to do a PE loader<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>on Linux, or an ELF loader on Windows. You could probably also write a<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>PE<->ELF converter without too much trouble.<br clear="none"><br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>The thing is once you have loaded the binary, it's going to call APIs,<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>and these are completely different between platforms. So you need either<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>an abstraction layer to wrap all the APIs, or something like Wine to<br clear="none"><span><span style="color: rgb(38, 40, 42); font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> </span></span>make the APIs compatible. That's where the real work is.<br clear="none"><br>Yes, but I would like to start from basics - enable functionality initially, and worry about which dll</div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">exports and what later on. I think we could have even our own (application) specific "standard" API.<br><br>Btw - I have tried to load from wine / LoadLibrary linux shared object, but could not. Tried something like this:</div><div dir="ltr" style=""><br><br><div style=""><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    void stackCallbacker()</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    {</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        printf("%s", g3::internal::stackdump().c_str());</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    }</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif"><br></font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    typedef void(*func)(void);</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    typedef void(*fcallFunc)(func);</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif"><br></font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif"><br></font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    int main(int argc, char **argv)</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">    {</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        //HMODULE h = LoadLibraryA("dll.dll");</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        const char* dllName = "dll";</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        //const char* dllName = "/mnt/c/Prototyping/dbghelp2_dev2/bin/Release_x86/dll.so";</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        HMODULE h = LoadLibraryA(dllName);</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        if (h == 0)</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        {</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">            printf("Failed to load '%s'\n", dllName);</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">            return 0;</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        }</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif"><br></font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        fcallFunc fc;</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        *((FARPROC*)&fc) = GetProcAddress(h, "DoTestCall");</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif"><br></font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        printf("Calling dll -> DoTestCall ...\n");</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        fc(stackCallbacker);</font></div><div style=""><font face="courier new, courier, monaco, monospace, sans-serif">        printf("call ok.");</font></div><div style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div></div>But wine refuses to load dll.so by relative or absolute path. Does wine supports this ?<br><br><br clear="none">-- <br clear="none">Alexandre Julliard<br clear="none"><a shape="rect" href="mailto:julliard@winehq.org" rel="nofollow" target="_blank" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">julliard@winehq.org</a><div class="ydpf41f1443yqt2338532283" id="ydpf41f1443yqtfd94024" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br clear="none"></div></div></div>
            </div>
        </div></body></html>