[mingw] use delay loading for DLLs that are subject to side loading

* This reverts much of commits f6ac559f4d and 1947266837
  so that we call the Windows APIs directly again, while ensuring that, by the time we load the DLLs,
  sideloading mitigation has already been applied by the application.
* This is a continuation of #1877, and should help prevent re-introducing side-loading issues when we
  link against new libraries, as well as allow us to drop some of the manual DLL hooking we've been
  doing to prevent it, to clean up the code.
* Note that this is a bit more complex than what the stackoverflow post suggests, because we need to
  create delayloaded libs for both 32-bit and 64-bit, which use a different calling convention and
  therefore need to use different .def files. So there's a lot of gymkhana involved, with Makefiles
  and whatnot, to get us there.
* Also simplify the use of CM_Get_DevNode_Registry_PropertyA() in dev.c since recent versions of
  MinGW now have support for it.
* Also fix 2 small issues in net.c (potential overflow) and format.c (memory leak).
This commit is contained in:
Pete Batard 2022-04-12 11:09:29 +01:00
parent 3528ca773d
commit e7b66e7e4c
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
27 changed files with 597 additions and 68 deletions

View file

@ -607,11 +607,11 @@ HANDLE DownloadSignedFileThreaded(const char* url, const char* file, HWND hProgr
return CreateThread(NULL, 0, DownloadSignedFileThread, &args, 0, NULL);
}
static __inline uint64_t to_uint64_t(uint16_t x[4]) {
static __inline uint64_t to_uint64_t(uint16_t x[3]) {
int i;
uint64_t ret = 0;
for (i=0; i<3; i++)
ret = (ret<<16) + x[i];
for (i = 0; i < 3; i++)
ret = (ret << 16) + x[i];
return ret;
}