REQUEST: Port Half-Life SDK Extension DLLs CLEANLY to Windows CE

Assuming either native or by hacks this eventually works, you'd need to re-implement the missing map entities because Opposing Force's game.dll/client.dll is closed source. Some people reverse engineered Counter-Strike's client.dll for Xash3D, maybe OF will be done in the future
Whoa, whoa, whoa guys. Damn I am too busy working on my BF2 mod. I need to keep checking on this thread to see progress. Great work Megavolt, damn man, you are a true hero! Keep up the great work! Hope to finally see this thing compiled correctly!
it's from old SDK, need from new SDK

that still does not work?
I don't think this will handle negative numbers correctly. Also you might want to check for null pointers and bounds on the output string.
you're right

Code:
char *itoa(int value, char *str, int base)
{
    if (!str)
        return NULL;
   
    unsigned int i, val;
   
    if (value < 0 && base == 10)
    {
        i = val = -value;
        *str++;
    }
    else
    {
        i = val = (unsigned int) value;
    }
   
    do
        *str++;
    while ((i /= base));
   
    *str = '\0';
   
    do
        *--str = itoa_lower_digits[val % base];
    while ((val /= base) != 0);
   
    if (value < 0 && base == 10)
        *--str = '-';
   
    return str;
}
It was late so I might have attached the OldSourceCode files, I'm pretty sure I didn't but I'll check in a few minutes and edit this post within a half-hour
profile pic related lol

Edit: @megavolt85 I attached python.cpp instead of player.cpp, but the are from the newer branch. Attached a new zip with player.cpp
test
Cleared most of the errors in hl.dll
newhl.png

Winsock stuff might be a pain
newclient.png
add to util.cpp

Code:
int isalnum(ch)
{
    if(isalpha(ch) || isdigit(ch))
        return 1;
 
    return 0;
}
add to helper.h

Code:
extern int isalnum(int ch);
Compiler complains about the ch parameter for isalnum() for hl.dll, but that's the last one
hl_new2.png

Also complains about it in client.dll, and a few other things. I'm impressed at the rewriting of some of winsock.h, one last error
client_new2.png
socketerror.png
Again thanks a lot, almost done, in less than two days lol
ops
Code:
int isalnum(int ch)
{
    if(isalpha(ch) || isdigit(ch))
        return 1;

    return 0;
}
hm, JOYINFOEX is WIN32 struct
Downloaded HL2 leaked source code from 2003 to poke around, I mentioned the compiler references eng_cdll_int.c in second post, and the strings referencing client.dll
cdll.png
hl_asm.png
^^ Note the double backslash in the "cl_dlls\\client.dll" string ^^

To my surprise, cdll_engine_int.cpp (for source engine but still, source engine is derived from GoldSRC). I'm just going to put a significant excerpt, because having this is pretty illegal
Code:
//-----------------------------------------------------------------------------
// Purpose: Loads the client .dll
//-----------------------------------------------------------------------------
void ClientDLL_Init( void )
{
    char szDllName[512];

    Assert ( !g_ClientDLLModule );

    Q_snprintf( szDllName, sizeof( szDllName ), "bin\\client.dll" );

    COM_ExpandFilename( szDllName );
    COM_FixSlashes(szDllName);  // Otherwise Sys_GetFactory() fails sometimes(on net drives for instance)

    // clear the pic pointers
    g_ClientDLLModule = FileSystem_LoadModule(szDllName);
    if ( g_ClientDLLModule )
    {
        CreateInterfaceFn clientFactory = Sys_GetFactory( g_ClientDLLModule );
        if ( clientFactory )
        {
            g_ClientDLL = (IBaseClientDLL *)clientFactory( CLIENT_DLL_INTERFACE_VERSION, NULL );
            if ( !g_ClientDLL )
            {
                Sys_Error( "Could not get client.dll interface from library %s", szDllName );
            }

            if ( !g_ClientDLL->Init(g_AppSystemFactory, physicsFactory, &g_ClientGlobalVariables ) )
            {
                Sys_Error("Client.dll Init() in library %s failed.", szDllName);
            }

            // Load the prediction interface from the client .dll
            g_pClientSidePrediction = (IPrediction *)clientFactory( VCLIENT_PREDICTION_INTERFACE_VERSION, NULL );
            if ( !g_pClientSidePrediction )
            {
                Sys_Error( "Could not get IPrediction interface from library %s", szDllName );
            }
            g_pClientSidePrediction->Init();

            s_pClientStats = (IClientStats *)clientFactory( INTERFACEVERSION_CLIENTSTATS, NULL );
            if ( !s_pClientStats )
            {
                Sys_Error( "Could not get client stats interface from library %s", szDllName );
            }
            g_EngineStats.InstallClientStats( s_pClientStats );          

            entitylist = ( IClientEntityList  *)clientFactory( VCLIENTENTITYLIST_INTERFACE_VERSION, NULL );
            if ( !entitylist )
            {
                Sys_Error( "Could not get client entity list interface from library %s", szDllName );
            }

            centerprint = ( ICenterPrint * )clientFactory( VCENTERPRINT_INTERFACE_VERSION, NULL );
            if ( !centerprint )
            {
                Sys_Error( "Could not get centerprint interface from library %s", szDllName );
            }

            clientleafsystem = ( IClientLeafSystemEngine *)clientFactory( CLIENTLEAFSYSTEM_INTERFACE_VERSION, NULL );
            if ( !clientleafsystem )
            {
                Sys_Error( "Could not get client leaf system interface from library %s", szDllName );
            }
        }
        else
        {
            Sys_Error( "Could not find factory interface in library %s", szDllName );
        }
    }
    else
    {
        // library failed to load
        Sys_Error( "Could not load library %s", szDllName );
    }

    if ( CommandLine()->FindParm( "-showlogo" ) )
    {
        // Enable Logo
        int i = 1;
        DispatchDirectUserMsg("Logo", 1, (void *)&i);
    }

    ClientDLL_InitRecvTableMgr();
}
Same thing for cmd.c
cmd2.png
String in HLDC binary for cmd function
cmd1.png
The function, and again same string exists in HL2 2003 leak cmd.cpp. It's definitely a fork of the same source as HLDC
Code:
/*
================
Cmd_CheckParm

Returns the position (1 to argc-1) in the command's argument list
where the given parameter apears, or 0 if not present
================
*/

int Cmd_CheckParm (char *parm)
{
    int i;
 
    if (!parm)
        Sys_Error ("Cmd_CheckParm: NULL");

    for (i = 1; i < Cmd_Argc (); i++)
        if (! Q_strcasecmp (parm, Cmd_Argv (i)))
            return i;
         
    return 0;
}
I think having these as a reference, even though obviously it's a newer version for the new engine, will help tremendously in creating the hooks/hacks we need to force load this

There's also net_ws.c, which I said awhile ago that it was all the code for the 'connect' commands and such, net_ws.cpp shows I was correct, and that possibly all the Winsock functions for networking is there, there's just no way for Half-Life to 'see' the internet connection

Having this source code from HL2 2003 leak will make re-implementing the networking 100% easier, it's essentially written already. So I don't get assemblergames a big fat C&D by attaching the source, whoever wants to take a look at the full files can get them here
http://hl2-beta.ru/download.php?view.24


---

I found very useful source code for injecting DLLs in Windows CE, called "CE API Spy". But it's for WCE 3.0+, after the above there is still hope in using command line parameters, but if it needs to be injected this will need to be partially re-written for WCE 2.12 (see attached) (it was a bitch to track these sources down, the .zip on the original site was corrupt)
http://www.drdobbs.com/cpp/spy-a-windows-ce-api-interceptor/184405459
--
@Trident6 is this not the best possible situation to be in for what is trying to be achieved? What's your opinion after the above on what we're looking at? We have reference source code for the hl1 engine itself, the engine extensions are about 90% ported, and we have Windows CE at our disposal

I think we're much more close to pulling this off then we think

---

@megavolt85 I just saw your post, typing that took awhile
Unfortunately hl.dll spits a whole bunch of unresolved symbol errors
linker.png

Client.dll is almost there, again I'm impressed with eliminating the Winsock errors
client_new3.png

I say finish client.dll and worry about the linking of both after. Again thanks a ton @megavolt85

You might have some luck with the input stuff by taking a look at the direct input headers, I attached the headers and the WCE\DC help file for directinput
hm, remove in helper.h all words extern
No change
linker2.png
Should I add 'extern' again?
Code:
// Helper.h by MegaVolt85
// Reimplements functions not supported by Windows CE
extern const void *calloc(size_t nmemb, size_t size);
extern const char *itoa(int value, char *str, int base);
extern const int isspace(int character);
extern const int isprint(int ch);
extern const int isalpha(int ch);
extern const int isdigit(int ch);
extern const int isalnum(int ch);
extern const int stricmp(const char *a, const char *b);
extern const int strnicmp(const char *a, const char *b, int n);
I had to remove the definition of isalnum in util.cpp after
linker3.png
Edit: Do you have WCE Dreamcast SDK?
upload util.cpp
Attached for client and hl
both files don't have my function

Original thread: https://assemblergames.com/threads/request-port-half-life-sdk-extension-dlls-cleanly-to-windows-ce.64408/