Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Souhardya authored Dec 30, 2021
1 parent a747c36 commit 389bbb1
Show file tree
Hide file tree
Showing 86 changed files with 7,629 additions and 0 deletions.
513 changes: 513 additions & 0 deletions HookPorts/Dispatch_NTDLL.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions HookPorts/Dispatch_NTDLL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int Dispatch_NTDLL_Start(void);
75 changes: 75 additions & 0 deletions HookPorts/Dispatch_NTDLL_LdrLoadDll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <windows.h>
#include <ntsecapi.h>

#include "./Dispatch_NTDLL_LdrLoadDll.h"
#include "../Common/DebugLog.h"
#include "./HookHelp.h"



//
//Global
//
__pfnLdrLoadDll pfnLdrLoadDll = NULL;



//
//Dispatch_NTDLL_LdrLoadDll Functions
//
NTSTATUS
NTAPI
OnLdrLoadDll(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL,
IN PUNICODE_STRING ModuleFileName,
OUT PHANDLE ModuleHandle )
{
NTSTATUS nRet;

DWORD dwRetAddr = 0;
__asm
{
mov eax, [ebp+4];
sub eax, 5;
mov dwRetAddr, eax;
}
if( IsBypassCaller(dwRetAddr) )
{
nRet = pfnLdrLoadDll(
PathToFile,
Flags,
ModuleFileName,
ModuleHandle
);
}

nRet = pfnLdrLoadDll(
PathToFile,
Flags,
ModuleFileName,
ModuleHandle
);

// __try
// {
//#ifdef Dbg
// WCHAR szDebugString[512] = {0};
// wsprintf(
// szDebugString,
// L"PathToFile=[%s]\r\nBuffer of ModuleFileName=[%s]",
// PathToFile,
// ModuleFileName->Buffer);
// DebugLog(DbgInfo,szDebugString);
//#endif
//
//#ifdef Dbg
// DebugLog(DbgInfo,L"Called");
//#endif
// }
// __except(EXCEPTION_EXECUTE_HANDLER)
// {
// }

return nRet;
}
18 changes: 18 additions & 0 deletions HookPorts/Dispatch_NTDLL_LdrLoadDll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

typedef NTSTATUS (NTAPI * __pfnLdrLoadDll)
(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL,
IN PUNICODE_STRING ModuleFileName,
OUT PHANDLE ModuleHandle );

extern __pfnLdrLoadDll pfnLdrLoadDll;

NTSTATUS
NTAPI
OnLdrLoadDll(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL,
IN PUNICODE_STRING ModuleFileName,
OUT PHANDLE ModuleHandle );
52 changes: 52 additions & 0 deletions HookPorts/Dispatch_NTDLL_LdrUnloadDll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <windows.h>
#include <ntsecapi.h>

#include "./Dispatch_NTDLL_LdrUnloadDll.h"
#include "../Common/DebugLog.h"
#include "./HookHelp.h"



//
//Global
//
__pfnLdrUnloadDll pfnLdrUnloadDll = NULL;



//
//Dispatch_NTDLL_LdrUnloadDll Functions
//
NTSTATUS
NTAPI
OnLdrUnloadDll(
IN HANDLE ModuleHandle )
{
NTSTATUS nRet;

DWORD dwRetAddr = 0;
__asm
{
mov eax, [ebp+4];
sub eax, 5;
mov dwRetAddr, eax;
}
if( IsBypassCaller(dwRetAddr) )
{
nRet = pfnLdrUnloadDll(
ModuleHandle
);

return nRet;
}

nRet = pfnLdrUnloadDll(
ModuleHandle
);

//#ifdef Dbg
// DebugLog(DbgInfo,L"Called");
//#endif

return nRet;
}
11 changes: 11 additions & 0 deletions HookPorts/Dispatch_NTDLL_LdrUnloadDll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

typedef NTSTATUS (NTAPI * __pfnLdrUnloadDll)
( IN HANDLE ModuleHandle );

extern __pfnLdrUnloadDll pfnLdrUnloadDll;

NTSTATUS
NTAPI
OnLdrUnloadDll(
IN HANDLE ModuleHandle );
Loading

0 comments on commit 389bbb1

Please sign in to comment.