Changeset 59404 in vbox
- Timestamp:
- Jan 19, 2016 10:10:39 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105110
- Location:
- trunk
- Files:
-
- 6 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/VBox-5.0 merged: 104938,104943,104950,104952-104953,104987-104988,104990
- Property svn:mergeinfo changed
-
trunk/Config.kmk
r59389 r59404 1915 1915 # VBoxDef2LazyLoad (lazy dynamic library loader assembly generator) 1916 1916 VBOX_DEF_2_LAZY_LOAD ?= $(PATH_OBJ)/VBoxDef2LazyLoad/VBoxDef2LazyLoad$(HOSTSUFF_EXE) 1917 1918 # VBoxCheckImports (checks what we imports from on windows) 1919 VBOX_CHECK_IMPORTS ?= $(PATH_OBJ)/VBoxCheckImports/VBoxCheckImports$(HOSTSUFF_EXE) 1917 1920 1918 1921 # GNU tar if present. -
trunk/include/iprt/initterm.h
r57942 r59404 57 57 /** The caller ensures that the argument bector is UTF-8. */ 58 58 #define RTR3INIT_FLAGS_UTF8_ARGV RT_BIT(3) 59 /** Indicates that this is a standalone application without any additional 60 * shared libraries in the application directory. Mainly windows loader mess. */ 61 #define RTR3INIT_FLAGS_STANDALONE_APP RT_BIT(4) 59 62 /** @} */ 60 63 -
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/VBox-5.0/src/VBox (added) merged: 104938,104943,104950,104987-104988,104990
- Property svn:mergeinfo changed
-
trunk/src/VBox/Installer/win/Stub/Makefile.kmk
r56299 r59404 38 38 VBoxStub_LIBS = \ 39 39 $(VBOX_LIB_RUNTIME_STATIC) \ 40 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Msi.lib 40 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib 41 VBoxStub_LDFLAGS = \ 42 -DelayLoad:comctl32.dll 43 VBoxStub_POST_CMDS = $(VBOX_CHECK_IMPORTS) --image $(out) ntdll.dll kernel32.dll 44 VBoxStub_LNK_DEPS = $(VBOX_CHECK_IMPORTS) 41 45 42 46 VBoxStub.cpp_DEFS += VBOX_SVN_REV=$(VBOX_SVN_REV) … … 48 52 49 53 VBoxStub_SOURCES += VBoxStubCertUtil.cpp 50 VBoxStub_LIBS += crypt32.lib51 54 VBoxStub.cpp_DEPS += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h 52 55 VBoxStub.cpp_INCS += $(VBoxStub_0_OUTDIR) … … 76 79 $(APPEND) -t $@ 'APP_MANIFEST RT_MANIFEST "$(subst /,\\,$(VBOX_STUB_MANIFEST_FILE))"' 77 80 81 # Dynamic import no. 1: MSI.DLL 82 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm 83 $$(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm: $(PATH_SUB_CURRENT)/msi.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@) 84 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@) 85 $(QUIET)$(RM) -f -- "$@" 86 $(VBOX_DEF_2_LAZY_LOAD) --system --library MSI.DLL --output "$@" $(filter %.def, $^) 87 88 # Dynamic import no. 2: CRYPTO32.DLL 89 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm 90 $$(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm: $(PATH_SUB_CURRENT)/crypt32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@) 91 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@) 92 $(QUIET)$(RM) -f -- "$@" 93 $(VBOX_DEF_2_LAZY_LOAD) --system --library CRYPT32.DLL --output "$@" $(filter %.def, $^) 94 95 # Dynamic import no. 3: WS2_32.DLL 96 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm 97 $$(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm: $(PATH_SUB_CURRENT)/ws2_32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@) 98 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@) 99 $(QUIET)$(RM) -f -- "$@" 100 $(VBOX_DEF_2_LAZY_LOAD) --system --library WS2_32.DLL --output "$@" $(filter %.def, $^) 101 102 # Dynamic import no. 4: USER32.DLL 103 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm 104 $$(VBoxStub_0_OUTDIR)/User32LazyLoad.asm: $(PATH_SUB_CURRENT)/user32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@) 105 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@) 106 $(QUIET)$(RM) -f -- "$@" 107 $(VBOX_DEF_2_LAZY_LOAD) --system --library USER32.DLL --output "$@" $(filter %.def, $^) 108 109 # Dynamic import no. 5: SHELL32.DLL 110 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm 111 $$(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm: $(PATH_SUB_CURRENT)/shell32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@) 112 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@) 113 $(QUIET)$(RM) -f -- "$@" 114 $(VBOX_DEF_2_LAZY_LOAD) --system --library SHELL32.DLL --output "$@" $(filter %.def, $^) 115 78 116 79 117 endif # x86 only -
trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp
r58556 r59404 802 802 int argc = __argc; 803 803 804 /* Check if we're already running and jump out if so. */ 805 /* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */ 804 /* 805 * Init IPRT. This is _always_ the very first thing we do. 806 */ 807 int vrc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_STANDALONE_APP); 808 if (RT_FAILURE(vrc)) 809 return RTMsgInitFailure(vrc); 810 811 /* 812 * Check if we're already running and jump out if so. 813 * 814 * Note! Do not use a global namespace ("Global\\") for mutex name here, 815 * will blow up NT4 compatibility! 816 */ 806 817 HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, "VBoxStubInstaller"); 807 818 if ( hMutexAppRunning != NULL … … 812 823 hMutexAppRunning = NULL; 813 824 return RTEXITCODE_FAILURE; 814 }815 816 /* Init IPRT. */817 int vrc = RTR3InitExe(argc, &argv, 0);818 if (RT_FAILURE(vrc))819 {820 /* Close the mutex for this application instance. */821 CloseHandle(hMutexAppRunning);822 hMutexAppRunning = NULL;823 return RTMsgInitFailure(vrc);824 825 } 825 826 -
trunk/src/VBox/Runtime/r3/init.cpp
r57926 r59404 148 148 DECLHIDDEN(int) rtR3InitNativeFirst(uint32_t fFlags) { return VINF_SUCCESS; } 149 149 DECLHIDDEN(int) rtR3InitNativeFinal(uint32_t fFlags) { return VINF_SUCCESS; } 150 DECLHIDDEN(void) rtR3InitNativeObtrusive( void) { }150 DECLHIDDEN(void) rtR3InitNativeObtrusive(uint32_t fFlags) { } 151 151 #endif 152 152 … … 556 556 | RTR3INIT_FLAGS_SUPLIB 557 557 | RTR3INIT_FLAGS_UNOBTRUSIVE 558 | RTR3INIT_FLAGS_UTF8_ARGV))); 558 | RTR3INIT_FLAGS_UTF8_ARGV 559 | RTR3INIT_FLAGS_STANDALONE_APP))); 559 560 Assert(!(fFlags & RTR3INIT_FLAGS_DLL) || cArgs == 0); 560 561 … … 577 578 } 578 579 #endif 580 g_fInitFlags |= fFlags & RTR3INIT_FLAGS_UTF8_ARGV; 579 581 580 582 if ( !(fFlags & RTR3INIT_FLAGS_UNOBTRUSIVE) … … 582 584 { 583 585 g_fInitFlags &= ~RTR3INIT_FLAGS_UNOBTRUSIVE; 584 rtR3InitNativeObtrusive(); 586 g_fInitFlags |= fFlags & RTR3INIT_FLAGS_STANDALONE_APP; 587 rtR3InitNativeObtrusive(g_fInitFlags | fFlags); 585 588 rtThreadReInitObtrusive(); 586 589 } 590 else 591 Assert(!(fFlags & RTR3INIT_FLAGS_STANDALONE_APP) || (g_fInitFlags & RTR3INIT_FLAGS_STANDALONE_APP)); 587 592 588 593 int rc = VINF_SUCCESS; -
trunk/src/VBox/Runtime/r3/init.h
r56290 r59404 33 33 DECLHIDDEN(int) rtR3InitNativeFirst(uint32_t fFlags); 34 34 DECLHIDDEN(int) rtR3InitNativeFinal(uint32_t fFlags); 35 DECLHIDDEN(void) rtR3InitNativeObtrusive( void);35 DECLHIDDEN(void) rtR3InitNativeObtrusive(uint32_t fFlags); 36 36 37 37 #endif -
trunk/src/VBox/Runtime/r3/win/init-win.cpp
r58952 r59404 250 250 251 251 252 static int rtR3InitNativeObtrusiveWorker( void)252 static int rtR3InitNativeObtrusiveWorker(uint32_t fFlags) 253 253 { 254 254 /* … … 264 264 * current directory. 265 265 * - The second trick is W7 w/ KB2533623 and W8+, it restrict the DLL 266 * searching to the application directory and the System32 directory. 266 * searching to the application directory (except when 267 * RTR3INIT_FLAGS_STANDALONE_APP is given) and the System32 directory. 267 268 */ 268 269 int rc = VINF_SUCCESS; … … 278 279 } 279 280 280 /** @bugref{6861} Observed GUI issues on Vista (32-bit and 64-bit). */ 281 if (g_enmWinVer > kRTWinOSType_VISTA) 281 /** @bugref{6861} Observed GUI issues on Vista (32-bit and 64-bit) when using 282 * SetDefaultDllDirectories. 283 * @bugref{8194} Try use SetDefaultDllDirectories on Vista for standalone apps 284 * despite potential GUI issues. */ 285 if ( g_enmWinVer > kRTWinOSType_VISTA 286 || (fFlags & RTR3INIT_FLAGS_STANDALONE_APP)) 282 287 { 283 288 typedef BOOL(WINAPI *PFNSETDEFAULTDLLDIRECTORIES)(DWORD); … … 286 291 if (pfnSetDefDllDirs) 287 292 { 288 if (pfnSetDefDllDirs(LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32)) 289 g_enmWinLdrProt = RTR3WINLDRPROT_SAFE; 293 DWORD fDllDirs = LOAD_LIBRARY_SEARCH_SYSTEM32; 294 if (!(fFlags & RTR3INIT_FLAGS_STANDALONE_APP)) 295 fDllDirs |= LOAD_LIBRARY_SEARCH_APPLICATION_DIR; 296 if (pfnSetDefDllDirs(fDllDirs)) 297 g_enmWinLdrProt = fDllDirs & LOAD_LIBRARY_SEARCH_APPLICATION_DIR ? RTR3WINLDRPROT_SAFE : RTR3WINLDRPROT_SAFER; 290 298 else if (RT_SUCCESS(rc)) 291 299 rc = VERR_INTERNAL_ERROR_4; … … 313 321 int rc = VINF_SUCCESS; 314 322 if (!(fFlags & RTR3INIT_FLAGS_UNOBTRUSIVE)) 315 rc = rtR3InitNativeObtrusiveWorker( );323 rc = rtR3InitNativeObtrusiveWorker(fFlags); 316 324 317 325 /* … … 327 335 328 336 329 DECLHIDDEN(void) rtR3InitNativeObtrusive( void)330 { 331 rtR3InitNativeObtrusiveWorker( );337 DECLHIDDEN(void) rtR3InitNativeObtrusive(uint32_t fFlags) 338 { 339 rtR3InitNativeObtrusiveWorker(fFlags); 332 340 } 333 341 -
trunk/src/VBox/Runtime/r3/win/internal-r3-win.h
r58949 r59404 85 85 RTR3WINLDRPROT_NONE, 86 86 RTR3WINLDRPROT_NO_CWD, 87 RTR3WINLDRPROT_SAFE 87 RTR3WINLDRPROT_SAFE, 88 RTR3WINLDRPROT_SAFER 88 89 } RTR3WINLDRPROT; 89 90 -
trunk/src/VBox/Storage/testcase/vbox-img.cpp
r57415 r59404 1778 1778 int exitcode = 0; 1779 1779 1780 int rc = RTR3InitExe(argc, &argv, 0);1780 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_STANDALONE_APP); 1781 1781 if (RT_FAILURE(rc)) 1782 1782 return RTMsgInitFailure(rc); -
trunk/src/bldprogs/Makefile.kmk
r58716 r59404 68 68 VBoxPeSetVersion_SOURCES = VBoxPeSetVersion.cpp 69 69 70 BLDPROGS.win += VBoxCheckImports 71 VBoxCheckImports_TEMPLATE = VBoxBldProg 72 VBoxCheckImports_SOURCES = VBoxCheckImports.cpp 73 70 74 BLDPROGS += VBoxDef2LazyLoad 71 75 VBoxDef2LazyLoad_TEMPLATE = VBoxBldProg -
trunk/src/bldprogs/VBoxDef2LazyLoad.cpp
r57353 r59404 35 35 { 36 36 struct MYEXPORT *pNext; 37 /** Pointer to unmangled name for stdcall (after szName), NULL if not. */ 38 char *pszUnstdcallName; 39 /** Pointer to the exported name. */ 40 char const *pszExportedNm; 41 unsigned uOrdinal; 37 42 bool fNoName; 38 unsigned uOrdinal;39 43 char szName[1]; 40 44 } MYEXPORT; … … 54 58 static bool g_fIgnoreData = true; 55 59 static bool g_fWithExplictLoadFunction = false; 60 static bool g_fSystemLibrary = false; 56 61 /** @} */ 57 62 … … 176 181 } 177 182 178 bool fNoName = true;183 bool fNoName = false; 179 184 unsigned uOrdinal = ~0U; 180 185 if (*psz == '@') … … 196 201 if (WORD_CMP(psz, cch, "NONAME")) 197 202 { 198 #if 0199 203 fNoName = true; 200 204 psz = leftStrip(psz + cch); 201 #else202 fprintf(stderr, "%s:%u: error: NONAME export not implemented.\n", pszInput, iLine);203 return RTEXITCODE_FAILURE;204 #endif205 205 } 206 206 } … … 228 228 229 229 /* 230 * Check for stdcall mangling. 231 */ 232 size_t cbExp = sizeof(MYEXPORT) + cchName; 233 unsigned cchStdcall = 0; 234 if (cchName > 3 && *pchName == '_' && isdigit(pchName[cchName - 1])) 235 { 236 if (cchName > 3 && pchName[cchName - 2] == '@') 237 cchStdcall = 2; 238 else if (cchName > 4 && pchName[cchName - 3] == '@' && isdigit(pchName[cchName - 2])) 239 cchStdcall = 3; 240 if (cchStdcall) 241 cbExp += cchName - 1 - cchStdcall; 242 } 243 244 /* 230 245 * Add the export. 231 246 */ 232 PMYEXPORT pExp = (PMYEXPORT)malloc(sizeof(*pExp) + cchName); 247 248 PMYEXPORT pExp = (PMYEXPORT)malloc(cbExp); 233 249 if (!pExp) 234 250 { … … 238 254 memcpy(pExp->szName, pchName, cchName); 239 255 pExp->szName[cchName] = '\0'; 240 pExp->uOrdinal = uOrdinal; 241 pExp->fNoName = fNoName; 242 pExp->pNext = NULL; 243 *g_ppExpNext = pExp; 244 g_ppExpNext = &pExp->pNext; 256 if (!cchStdcall) 257 { 258 pExp->pszUnstdcallName = NULL; 259 pExp->pszExportedNm = pExp->szName; 260 } 261 else 262 { 263 pExp->pszUnstdcallName = &pExp->szName[cchName + 1]; 264 memcpy(pExp->pszUnstdcallName, pchName + 1, cchName - 1 - cchStdcall); 265 pExp->pszUnstdcallName[cchName - 1 - cchStdcall] = '\0'; 266 pExp->pszExportedNm = pExp->pszUnstdcallName; 267 } 268 pExp->uOrdinal = uOrdinal; 269 pExp->fNoName = fNoName; 270 pExp->pNext = NULL; 271 *g_ppExpNext = pExp; 272 g_ppExpNext = &pExp->pNext; 245 273 } 246 274 } … … 322 350 "BEGINCODE\n"); 323 351 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 324 fprintf(pOutput, 325 "BEGINPROC %s\n" 326 " jmp RTCCPTR_PRE [g_pfn%s xWrtRIP]\n" 327 "ENDPROC %s\n", 328 pExp->szName, 329 pExp->szName, 330 pExp->szName); 352 if (!pExp->pszUnstdcallName) 353 fprintf(pOutput, 354 "BEGINPROC %s\n" 355 " jmp RTCCPTR_PRE [g_pfn%s xWrtRIP]\n" 356 "ENDPROC %s\n", 357 pExp->szName, pExp->szName, pExp->szName); 358 else 359 fprintf(pOutput, 360 "%%ifdef RT_ARCH_X86\n" 361 "global %s\n" 362 "%s:\n" 363 " jmp RTCCPTR_PRE [g_pfn%s xWrtRIP]\n" 364 "%%else\n" 365 "BEGINPROC %s\n" 366 " jmp RTCCPTR_PRE [g_pfn%s xWrtRIP]\n" 367 "ENDPROC %s\n" 368 "%%endif\n", 369 pExp->szName, pExp->szName, pExp->pszUnstdcallName, 370 pExp->pszUnstdcallName, pExp->pszUnstdcallName, pExp->pszUnstdcallName); 371 331 372 fprintf(pOutput, 332 373 "\n" … … 348 389 "__imp_%s:\n" 349 390 "%%endif\n" 350 "g_pfn%s RTCCPTR_DEF ___LazyLoad___%s\n", 391 "g_pfn%s RTCCPTR_DEF ___LazyLoad___%s\n" 392 "\n", 351 393 pExp->szName, 352 394 pExp->szName, 353 pExp-> szName,354 pExp-> szName);395 pExp->pszExportedNm, 396 pExp->pszExportedNm); 355 397 fprintf(pOutput, 356 398 "RTCCPTR_DEF 0 ; Terminator entry for traversal.\n" … … 369 411 ";\n" 370 412 "BEGINCODE\n" 371 "g_szLibrary db '%s',0\n" 413 "g_szLibrary: db '%s',0\n" 414 "\n" 372 415 "g_szzNames:\n", 373 416 g_pszLibrary); 374 417 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 375 fprintf(pOutput, "g_sz%s: db '%s',0\n", pExp->szName, pExp->szName); 418 if (!pExp->fNoName) 419 fprintf(pOutput, " g_sz%s:\n db '%s',0\n", pExp->pszExportedNm, pExp->pszExportedNm); 420 else 421 fprintf(pOutput, " g_sz%s:\n db '#%u',0\n", pExp->pszExportedNm, pExp->uOrdinal); 376 422 fprintf(pOutput, 377 423 "g_EndOfNames: db 0\n" 424 "\n" 425 "g_szFailLoadFmt: db 'Lazy loader failed to load \"%%s\": %%Rrc', 10, 0\n" 426 "g_szFailResolveFmt: db 'Lazy loader failed to resolve symbol \"%%s\" in \"%%s\": %%Rrc', 10, 0\n" 378 427 "\n" 379 428 "\n"); … … 388 437 "BEGINCODE\n"); 389 438 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 390 fprintf(pOutput, 391 "___LazyLoad___%s:\n" 392 /* "int3\n" */ 393 "%%ifdef RT_ARCH_AMD64\n" 394 " lea rax, [g_sz%s wrt rip]\n" 395 " lea r10, [g_pfn%s wrt rip]\n" 396 "%%elifdef RT_ARCH_X86\n" 397 " push g_sz%s\n" 398 " push g_pfn%s\n" 399 "%%else\n" 400 " %%error \"Unsupported architecture\"\n" 401 "%%endif\n" 402 " call LazyLoadResolver\n" 403 "%%ifdef RT_ARCH_X86\n" 404 " add esp, 8h\n" 405 "%%endif\n" 406 " jmp NAME(%s)\n" 407 "\n" 408 , 409 pExp->szName, 410 pExp->szName, 411 pExp->szName, 412 pExp->szName, 413 pExp->szName, 414 pExp->szName); 439 { 440 if (!pExp->fNoName) 441 fprintf(pOutput, 442 "___LazyLoad___%s:\n" 443 /* "int3\n" */ 444 "%%ifdef RT_ARCH_AMD64\n" 445 " lea rax, [g_sz%s wrt rip]\n" 446 " lea r10, [g_pfn%s wrt rip]\n" 447 " call LazyLoadResolver\n" 448 "%%elifdef RT_ARCH_X86\n" 449 " push g_sz%s\n" 450 " push g_pfn%s\n" 451 " call LazyLoadResolver\n" 452 " add esp, 8h\n" 453 "%%else\n" 454 " %%error \"Unsupported architecture\"\n" 455 "%%endif\n" 456 , 457 pExp->pszExportedNm, 458 pExp->pszExportedNm, 459 pExp->pszExportedNm, 460 pExp->pszExportedNm, 461 pExp->pszExportedNm); 462 else 463 fprintf(pOutput, 464 "___LazyLoad___%s:\n" 465 /* "int3\n" */ 466 "%%ifdef RT_ARCH_AMD64\n" 467 " mov eax, %u\n" 468 " lea r10, [g_pfn%s wrt rip]\n" 469 " call LazyLoadResolver\n" 470 "%%elifdef RT_ARCH_X86\n" 471 " push %u\n" 472 " push g_pfn%s\n" 473 " call LazyLoadResolver\n" 474 " add esp, 8h\n" 475 "%%else\n" 476 " %%error \"Unsupported architecture\"\n" 477 "%%endif\n" 478 , 479 pExp->pszExportedNm, 480 pExp->uOrdinal, 481 pExp->pszExportedNm, 482 pExp->uOrdinal, 483 pExp->pszExportedNm); 484 if (!pExp->pszUnstdcallName) 485 fprintf(pOutput, " jmp NAME(%s)\n", pExp->szName); 486 else 487 fprintf(pOutput, 488 "%%ifdef RT_ARCH_X86\n" 489 " jmp %s\n" 490 "%%else\n" 491 " jmp NAME(%s)\n" 492 "%%endif\n" 493 , 494 pExp->szName, pExp->szName); 495 fprintf(pOutput, "\n"); 496 } 415 497 fprintf(pOutput, 416 498 "\n" … … 437 519 * saved all necessary registers. 438 520 */ 439 fprintf(pOutput, 440 ";\n" 441 ";SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod,\n" 442 "; uint32_t fFlags, PRTERRINFO pErrInfo);\n" 443 ";\n" 444 "EXTERN_IMP2 SUPR3HardenedLdrLoadAppPriv\n" 445 "BEGINCODE\n" 446 "\n" 447 "LazyLoading:\n" 448 " mov xCX, [g_hMod xWrtRIP]\n" 449 " or xCX, xCX\n" 450 " jnz .return\n" 451 "\n" 452 "%%ifdef ASM_CALL64_GCC\n" 453 " xor rcx, rcx ; pErrInfo\n" 454 " xor rdx, rdx ; fFlags (local load)\n" 455 " lea rsi, [g_hMod wrt rip] ; phLdrMod\n" 456 " lea rdi, [g_szLibrary wrt rip] ; pszFilename\n" 457 " sub rsp, 08h\n" 458 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 459 " add rsp, 08h\n" 460 "\n" 461 "%%elifdef ASM_CALL64_MSC\n" 462 " xor r9, r9 ; pErrInfo\n" 463 " xor r8, r8 ; fFlags (local load)\n" 464 " lea rdx, [g_hMod wrt rip] ; phLdrMod\n" 465 " lea rcx, [g_szLibrary wrt rip] ; pszFilename\n" 466 " sub rsp, 28h\n" 467 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 468 " add rsp, 28h\n" 469 "\n" 470 "%%elifdef RT_ARCH_X86\n" 471 " sub xSP, 0ch\n" 472 " push 0 ; pErrInfo\n" 473 " push 0 ; fFlags (local load)\n" 474 " push g_hMod ; phLdrMod\n" 475 " push g_szLibrary ; pszFilename\n" 476 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 477 " add esp, 1ch\n" 478 "%%else\n" 479 " %%error \"Unsupported architecture\"\n" 480 "%%endif\n" 521 if (!g_fSystemLibrary) 522 fprintf(pOutput, 523 ";\n" 524 ";SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod,\n" 525 "; uint32_t fFlags, PRTERRINFO pErrInfo);\n" 526 ";\n" 527 "EXTERN_IMP2 SUPR3HardenedLdrLoadAppPriv\n" 528 "%%ifdef IN_RT_R3\n" 529 "extern NAME(RTAssertMsg2Weak)\n" 530 "%%else\n" 531 "EXTERN_IMP2 RTAssertMsg2Weak\n" 532 "%%endif\n" 533 "BEGINCODE\n" 534 "\n" 535 "LazyLoading:\n" 536 " mov xCX, [g_hMod xWrtRIP]\n" 537 " or xCX, xCX\n" 538 " jnz .return\n" 539 "\n" 540 "%%ifdef ASM_CALL64_GCC\n" 541 " xor rcx, rcx ; pErrInfo\n" 542 " xor rdx, rdx ; fFlags (local load)\n" 543 " lea rsi, [g_hMod wrt rip] ; phLdrMod\n" 544 " lea rdi, [g_szLibrary wrt rip] ; pszFilename\n" 545 " sub rsp, 08h\n" 546 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 547 " add rsp, 08h\n" 548 "\n" 549 "%%elifdef ASM_CALL64_MSC\n" 550 " xor r9, r9 ; pErrInfo\n" 551 " xor r8, r8 ; fFlags (local load)\n" 552 " lea rdx, [g_hMod wrt rip] ; phLdrMod\n" 553 " lea rcx, [g_szLibrary wrt rip] ; pszFilename\n" 554 " sub rsp, 28h\n" 555 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 556 " add rsp, 28h\n" 557 "\n" 558 "%%elifdef RT_ARCH_X86\n" 559 " sub xSP, 0ch\n" 560 " push 0 ; pErrInfo\n" 561 " push 0 ; fFlags (local load)\n" 562 " push g_hMod ; phLdrMod\n" 563 " push g_szLibrary ; pszFilename\n" 564 " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n" 565 " add esp, 1ch\n" 566 "%%else\n" 567 " %%error \"Unsupported architecture\"\n" 568 "%%endif\n"); 569 else 570 fprintf(pOutput, 571 ";\n" 572 "; RTDECL(int) RTLdrLoadSystem(const char *pszFilename, bool fNoUnload, PRTLDRMOD phLdrMod);\n" 573 ";\n" 574 "%%ifdef IN_RT_R3\n" 575 "extern NAME(RTLdrLoadSystem)\n" 576 "extern NAME(RTAssertMsg2Weak)\n" 577 "%%else\n" 578 "EXTERN_IMP2 RTLdrLoadSystem\n" 579 "EXTERN_IMP2 RTAssertMsg2Weak\n" 580 "%%endif\n" 581 "BEGINCODE\n" 582 "\n" 583 "LazyLoading:\n" 584 " mov xCX, [g_hMod xWrtRIP]\n" 585 " or xCX, xCX\n" 586 " jnz .return\n" 587 "\n" 588 "%%ifdef ASM_CALL64_GCC\n" 589 " lea rdx, [g_hMod wrt rip] ; phLdrMod\n" 590 " mov esi, 1 ; fNoUnload=true\n" 591 " lea rdi, [g_szLibrary wrt rip] ; pszFilename\n" 592 " sub rsp, 08h\n" 593 " %%ifdef IN_RT_R3\n" 594 " call NAME(RTLdrLoadSystem)\n" 595 " %%else\n" 596 " call IMP2(RTLdrLoadSystem)\n" 597 " %%endif\n" 598 " add rsp, 08h\n" 599 "\n" 600 "%%elifdef ASM_CALL64_MSC\n" 601 " lea r8, [g_hMod wrt rip] ; phLdrMod\n" 602 " mov edx, 1 ; fNoUnload=true\n" 603 " lea rcx, [g_szLibrary wrt rip] ; pszFilename\n" 604 " sub rsp, 28h\n" 605 " %%ifdef IN_RT_R3\n" 606 " call NAME(RTLdrLoadSystem)\n" 607 " %%else\n" 608 " call IMP2(RTLdrLoadSystem)\n" 609 " %%endif\n" 610 " add rsp, 28h\n" 611 "\n" 612 "%%elifdef RT_ARCH_X86\n" 613 " push g_hMod ; phLdrMod\n" 614 " push 1 ; fNoUnload=true\n" 615 " push g_szLibrary ; pszFilename\n" 616 " %%ifdef IN_RT_R3\n" 617 " call NAME(RTLdrLoadSystem)\n" 618 " %%else\n" 619 " call IMP2(RTLdrLoadSystem)\n" 620 " %%endif\n" 621 " add esp, 0ch\n" 622 "%%else\n" 623 " %%error \"Unsupported architecture\"\n" 624 "%%endif\n"); 625 fprintf(pOutput, 481 626 " or eax, eax\n" 482 " jz .loadok\n" 483 ".badload:\n" 484 " int3\n" 485 " jmp .badload\n" 486 ".loadok:\n" 627 " jnz .badload\n" 487 628 " mov xCX, [g_hMod xWrtRIP]\n" 488 629 ".return:\n" 489 630 " ret\n" 631 "\n" 632 ".badload:\n" 633 "%%ifdef ASM_CALL64_GCC\n" 634 " mov edx, eax\n" 635 " lea rsi, [g_szLibrary wrt rip]\n" 636 " lea rdi, [g_szFailLoadFmt wrt rip]\n" 637 " sub rsp, 08h\n" 638 "%%elifdef ASM_CALL64_MSC\n" 639 " mov r8d, eax\n" 640 " lea rdx, [g_szLibrary wrt rip]\n" 641 " lea rcx, [g_szFailLoadFmt wrt rip]\n" 642 " sub rsp, 28h\n" 643 "%%elifdef RT_ARCH_X86\n" 644 " push eax\n" 645 " push g_szLibrary\n" 646 " push g_szFailLoadFmt\n" 647 "%%endif\n" 648 "%%ifdef IN_RT_R3\n" 649 " call NAME(RTAssertMsg2Weak)\n" 650 "%%else\n" 651 " call IMP2(RTAssertMsg2Weak)\n" 652 "%%endif\n" 653 ".badloadloop:\n" 654 " int3\n" 655 " jmp .badloadloop\n" 490 656 "LazyLoading_End:\n" 491 657 "\n" … … 497 663 ";RTDECL(int) RTLdrGetSymbol(RTLDRMOD hLdrMod, const char *pszSymbol, void **ppvValue);\n" 498 664 ";\n" 665 "%%ifdef IN_RT_R3\n" 666 "extern NAME(RTLdrGetSymbol)\n" 667 "%%else\n" 499 668 "EXTERN_IMP2 RTLdrGetSymbol\n" 669 "%%endif\n" 500 670 "BEGINCODE\n" 501 671 "LazyLoadResolver:\n" … … 531 701 " mov r8, r14 ; ppvValue\n" 532 702 " %%endif\n" 703 " %%ifdef IN_RT_R3\n" 704 " call NAME(RTLdrGetSymbol)\n" 705 " %%else\n" 533 706 " call IMP2(RTLdrGetSymbol)\n" 707 " %%endif\n" 534 708 " or eax, eax\n" 535 " jz .symok\n" 536 ".badsym:\n" 537 " int3\n" 538 " jmp .badsym\n" 539 ".symok:\n" 709 " jnz .badsym\n" 540 710 "\n" 541 711 " mov rsp, r12\n" … … 562 732 "\n" 563 733 ".loaded:\n" 564 " mov eax, [ebp + 4] ; value addr\n" 565 " push eax\n" 566 " mov edx, [ebp + 8] ; symbol name\n" 567 " push edx\n" 568 " call LazyLoading ; returns handle in ecx\n" 569 " mov ecx, [g_hMod]\n" 734 " call LazyLoading ; returns handle in ecx\n" 735 " push dword [ebp + 8] ; value addr\n" 736 " push dword [ebp + 12] ; symbol name\n" 737 " push ecx\n" 738 " %%ifdef IN_RT_R3\n" 739 " call NAME(RTLdrGetSymbol)\n" 740 " %%else\n" 570 741 " call IMP2(RTLdrGetSymbol)\n" 742 " %%endif\n" 571 743 " or eax, eax\n" 572 " jz .symok\n" 573 ".badsym:\n" 574 " int3\n" 575 " jmp .badsym\n" 576 ".symok:\n" 744 " jnz .badsym\n" 577 745 " lea esp, [ebp - 0ch]\n" 578 746 " pop edx\n" … … 584 752 "%%endif\n" 585 753 " ret\n" 754 "\n" 755 ".badsym:\n" 756 "%%ifdef ASM_CALL64_GCC\n" 757 " mov ecx, eax\n" 758 " lea rdx, [g_szLibrary wrt rip]\n" 759 " mov rsi, r15\n" 760 " lea rdi, [g_szFailResolveFmt wrt rip]\n" 761 " sub rsp, 08h\n" 762 "%%elifdef ASM_CALL64_MSC\n" 763 " mov r9d, eax\n" 764 " mov r8, r15\n" 765 " lea rdx, [g_szLibrary wrt rip]\n" 766 " lea rcx, [g_szFailResolveFmt wrt rip]\n" 767 " sub rsp, 28h\n" 768 "%%elifdef RT_ARCH_X86\n" 769 " push eax\n" 770 " push dword [ebp + 12]\n" 771 " push g_szLibrary\n" 772 " push g_szFailResolveFmt\n" 773 "%%endif\n" 774 "%%ifdef IN_RT_R3\n" 775 " call NAME(RTAssertMsg2Weak)\n" 776 "%%else\n" 777 " call IMP2(RTAssertMsg2Weak)\n" 778 "%%endif\n" 779 ".badsymloop:\n" 780 " int3\n" 781 " jmp .badsymloop\n" 782 "\n" 586 783 "LazyLoadResolver_End:\n" 587 784 "\n" … … 597 794 if (g_fWithExplictLoadFunction) 598 795 { 796 if (g_fSystemLibrary) /* Lazy bird. */ 797 { 798 fprintf(stderr, "error: cannot use --system with --explicit-load-function, sorry\n"); 799 return RTEXITCODE_FAILURE; 800 } 801 599 802 int cchLibBaseName = (int)(strchr(g_pszLibrary, '.') ? strchr(g_pszLibrary, '.') - g_pszLibrary : strlen(g_pszLibrary)); 600 803 fprintf(pOutput, … … 835 1038 else if (!strcmp(psz, "--no-explicit-load-function")) 836 1039 g_fWithExplictLoadFunction = false; 1040 else if (!strcmp(psz, "--system")) 1041 g_fSystemLibrary = true; 837 1042 /** @todo Support different load methods so this can be used on system libs and 838 1043 * such if we like. */
Note:
See TracChangeset
for help on using the changeset viewer.