implement generic I/O async request object to replace file-specific async requests, refactor lwIP network stack to dispatch requests through IRPs with cancellation support, add cancellation polling to lwIP accept and receive operations using LwipSocketWaitRecvNetbuf and LwipSocketWaitAccept, introduce NetSubmitSocketIrp for routing socket operations via device IRPs, track network IRP statistics with SYS_NET_IRP_STATS, add process module lock spinlock and reference counting for process modules, implement dynamic module loading and unloading via user module handles, add POSIX dynamic loader APIs including dlopen, dlsym, dlerror, and dlclose, introduce PosixStart entry point for posix applications, add new native smoke tests for net IRPs.

This commit is contained in:
maksw committed 2026-06-27 10:37:53 +02:00
1 parent ed3d065abd
commit 1f5477cf66
32 files changed
+3713 -551

No files matched your search

+39 -8
View File
@@ -1102,15 +1102,27 @@ __declspec(dllexport) HANDLE GetModuleHandleW(const unsigned short* lpModuleName
return lpModuleName ? NULL : WIN32_HMODULE_EXE;
}
// Loads library A.
// Loads a user-mode DLL through the native module loader.
__declspec(dllexport) HANDLE LoadLibraryA(const char* lpLibFileName) {
if (KiIsWin32DllNameA(lpLibFileName)) return WIN32_HMODULE_WIN32;
gLastError = 2; // ERROR_FILE_NOT_FOUND
return NULL;
if (!lpLibFileName) { gLastError = 87; return NULL; }
uint32_t handle = 0;
SYS_LOAD_MODULE_REQUEST req;
memset(&req, 0, sizeof(req));
req.Size = sizeof(req);
req.Path = SysSvFromCstr(lpLibFileName);
req.ModuleHandleOut = &handle;
uint32_t status = SysLoadModule(&req);
if (status != STATUS_SUCCESS) {
gLastError = 126;
return NULL;
}
return (HANDLE)(uintptr_t)handle;
}
// Minimal GetProcAddress for code that probes kernel32 functions already present
// in this win32.dll image. Full dynamic DLL loading remains a kernel-loader job.
// GetProcAddress handles both built-in win32 exports and native module handles.
__declspec(dllexport) BOOL FreeLibrary(HANDLE hLibModule);
__declspec(dllexport) void Sleep(DWORD dwMilliseconds);
__declspec(dllexport) BOOL GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
@@ -1129,7 +1141,7 @@ __declspec(dllexport) BOOL SetConsoleCursorPosition(HANDLE hConsoleOutput,
COORD dwCursorPosition);
// Returns proc Address.
__declspec(dllexport) void* GetProcAddress(HANDLE hModule, const char* lpProcName) {
if (hModule != WIN32_HMODULE_WIN32 || !lpProcName) { gLastError = 127; return NULL; }
if (!hModule || !lpProcName) { gLastError = 127; return NULL; }
// Ordinal probes are represented as small integer pointers. Do not treat
// them as strings while debugging misses.
@@ -1139,6 +1151,19 @@ __declspec(dllexport) void* GetProcAddress(HANDLE hModule, const char* lpProcNam
return NULL;
}
if (hModule != WIN32_HMODULE_WIN32) {
uintptr_t address = 0;
SYS_GET_MODULE_EXPORT_REQUEST req;
memset(&req, 0, sizeof(req));
req.Size = sizeof(req);
req.ModuleHandle = (uint32_t)(uintptr_t)hModule;
req.Name = SysSvFromCstr(lpProcName);
req.AddressOut = &address;
uint32_t status = SysGetModuleExport(&req);
if (status != STATUS_SUCCESS || !address) { gLastError = 127; return NULL; }
return (void*)address;
}
#define GP(name) if (strcmp(lpProcName, #name) == 0) return (void*)&name
GP(GetLastError); GP(SetLastError); GP(LoadLibraryA); GP(GetProcAddress);
GP(FreeLibrary); GP(VirtualAlloc); GP(VirtualFree); GP(VirtualProtect);
@@ -1154,9 +1179,15 @@ __declspec(dllexport) void* GetProcAddress(HANDLE hModule, const char* lpProcNam
return NULL;
}
// Releases library.
// Releases one native module handle returned by LoadLibraryA.
__declspec(dllexport) BOOL FreeLibrary(HANDLE hLibModule) {
(void)hLibModule;
if (!hLibModule || hLibModule == WIN32_HMODULE_WIN32 || hLibModule == WIN32_HMODULE_EXE)
return TRUE;
uint32_t status = SysUnloadModule((uint32_t)(uintptr_t)hLibModule);
if (status != STATUS_SUCCESS) {
gLastError = 126;
return FALSE;
}
return TRUE;
}