From d767bf9766120b091b08911d6eda256f67a5ffbf Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 27 Apr 2017 22:15:40 +0200 Subject: [PATCH] Make hInstance local, it doesn't need to be global --- DDraw/dllmain.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp index d2e4cfc..0ef18f8 100644 --- a/DDraw/dllmain.cpp +++ b/DDraw/dllmain.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #define _MEMORY_NO_CRT #include "MemoryMgr.h" @@ -186,9 +185,9 @@ VOID WINAPI GetStartupInfoA_Hook(LPSTARTUPINFOA lpStartupInfo) pOrgGetStartupInfoA(lpStartupInfo); } -static HINSTANCE hInstance; void PatchIAT() { + HINSTANCE hInstance = GetModuleHandle(nullptr); IMAGE_NT_HEADERS* ntHeader = (IMAGE_NT_HEADERS*)((DWORD)hInstance + ((IMAGE_DOS_HEADER*)hInstance)->e_lfanew); // Give _rwcseg proper access rights @@ -260,7 +259,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { DisableThreadLibraryCalls(hinstDLL); - hInstance = GetModuleHandle(nullptr); PatchIAT(); }