Skip to content

Commit 476b206

Browse files
committed
Added option to query download status, small fixes in manual mapping and regular injection (peh header faking)
1 parent ef3bfd6 commit 476b206

File tree

9 files changed

+217
-142
lines changed

9 files changed

+217
-142
lines changed

GH Injector Library/Download Manager.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
DownloadManager::DownloadManager()
66
{
7-
m_hInterruptEvent = nullptr;
7+
m_hInterruptEvent = nullptr;
8+
m_fProgress = 0.0f;
89
}
910

1011
DownloadManager::~DownloadManager()
@@ -91,8 +92,6 @@ HRESULT __stdcall DownloadManager::OnObjectAvailable(const IID & riid, IUnknown
9192

9293
HRESULT __stdcall DownloadManager::OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
9394
{
94-
UNREFERENCED_PARAMETER(ulProgress);
95-
UNREFERENCED_PARAMETER(ulProgressMax);
9695
UNREFERENCED_PARAMETER(ulStatusCode);
9796
UNREFERENCED_PARAMETER(szStatusText);
9897

@@ -101,6 +100,11 @@ HRESULT __stdcall DownloadManager::OnProgress(ULONG ulProgress, ULONG ulProgress
101100
return E_ABORT;
102101
}
103102

103+
if (ulProgressMax)
104+
{
105+
m_fProgress = (float)ulProgress / ulProgressMax;
106+
}
107+
104108
return S_OK;
105109
}
106110

@@ -112,4 +116,9 @@ BOOL DownloadManager::SetInterruptEvent(HANDLE hInterrupt)
112116
}
113117

114118
return DuplicateHandle(GetCurrentProcess(), hInterrupt, GetCurrentProcess(), &m_hInterruptEvent, NULL, FALSE, DUPLICATE_SAME_ACCESS);
115-
}
119+
}
120+
121+
float DownloadManager::GetDownloadProgress()
122+
{
123+
return m_fProgress;
124+
}

GH Injector Library/Download Manager.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
#pragma once
66

7-
#include <windows.h>
7+
#include "pch.h"
88

99
class DownloadManager : public IBindStatusCallback
1010
{
11-
HANDLE m_hInterruptEvent;
11+
HANDLE m_hInterruptEvent;
12+
float m_fProgress;
1213

1314
public:
1415

@@ -39,4 +40,6 @@ class DownloadManager : public IBindStatusCallback
3940
HRESULT __stdcall OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText);
4041

4142
BOOL SetInterruptEvent(HANDLE hInterrupt);
43+
44+
float GetDownloadProgress();
4245
};

GH Injector Library/Injection Generic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ DWORD __declspec(code_seg(".inj_sec$1")) __stdcall InjectionShell(INJECTION_DATA
181181
LDRP_PATH_SEARCH_CONTEXT ctx{ 0 };
182182
ctx.OriginalFullDllName = pData->ModuleFileName.szBuffer;
183183

184+
LDRP_LOAD_CONTEXT_FLAGS ctx_flags{ 0 };
185+
186+
184187
LDR_DATA_TABLE_ENTRY * entry = nullptr;
185188

186189
pData->LastError = (DWORD)f->LdrpLoadDll(&pData->ModuleFileName, &ctx, { 0 }, &entry);
@@ -206,8 +209,7 @@ DWORD __declspec(code_seg(".inj_sec$1")) __stdcall InjectionShell(INJECTION_DATA
206209
if (!(pData->Flags & (INJ_UNLINK_FROM_PEB | INJ_FAKE_HEADER | INJ_ERASE_HEADER)))
207210
{
208211
return INJ_ERR_SUCCESS;
209-
}
210-
212+
}
211213

212214
PEB * pPEB = nullptr;
213215
LDR_DATA_TABLE_ENTRY * pEntry = nullptr;

0 commit comments

Comments
 (0)