Make hInstance local, it doesn't need to be global

This commit is contained in:
Silent 2017-04-27 22:15:40 +02:00
parent 6bcd33ea54
commit d767bf9766

View File

@ -6,7 +6,6 @@
#include <stdio.h> #include <stdio.h>
#include <Shlwapi.h> #include <Shlwapi.h>
#include <ShlObj.h> #include <ShlObj.h>
#include <cstdint>
#define _MEMORY_NO_CRT #define _MEMORY_NO_CRT
#include "MemoryMgr.h" #include "MemoryMgr.h"
@ -186,9 +185,9 @@ VOID WINAPI GetStartupInfoA_Hook(LPSTARTUPINFOA lpStartupInfo)
pOrgGetStartupInfoA(lpStartupInfo); pOrgGetStartupInfoA(lpStartupInfo);
} }
static HINSTANCE hInstance;
void PatchIAT() void PatchIAT()
{ {
HINSTANCE hInstance = GetModuleHandle(nullptr);
IMAGE_NT_HEADERS* ntHeader = (IMAGE_NT_HEADERS*)((DWORD)hInstance + ((IMAGE_DOS_HEADER*)hInstance)->e_lfanew); IMAGE_NT_HEADERS* ntHeader = (IMAGE_NT_HEADERS*)((DWORD)hInstance + ((IMAGE_DOS_HEADER*)hInstance)->e_lfanew);
// Give _rwcseg proper access rights // Give _rwcseg proper access rights
@ -260,7 +259,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
DisableThreadLibraryCalls(hinstDLL); DisableThreadLibraryCalls(hinstDLL);
hInstance = GetModuleHandle(nullptr);
PatchIAT(); PatchIAT();
} }