Create GetInMemoryModulePathFromLoaderLoadModule.cpp

This commit is contained in:
vxunderground
2022-07-14 22:59:21 -05:00
committed by GitHub
parent eabd6cb4b4
commit b1b24fa209
@@ -0,0 +1,26 @@
DWORD GetInMemoryModulePathFromLoaderLoadModuleA(DWORD nBufferLength, PCHAR lpBuffer)
{
PPEB Peb = GetPeb();
PLDR_MODULE Module = NULL;
Module = (PLDR_MODULE)((PBYTE)Peb->LoaderData->InMemoryOrderModuleList.Flink - 16);
if (nBufferLength < Module->FullDllName.Length)
return ERROR_FAILURE_RETURN;
return (DWORD)WCharStringToCharString(lpBuffer, Module->FullDllName.Buffer, Module->FullDllName.MaximumLength);
}
DWORD GetInMemoryModulePathFromLoaderLoadModuleW(DWORD nBufferLength, PWCHAR lpBuffer)
{
PPEB Peb = GetPeb();
PLDR_MODULE Module = NULL;
Module = (PLDR_MODULE)((PBYTE)Peb->LoaderData->InMemoryOrderModuleList.Flink - 16);
if(nBufferLength < Module->FullDllName.Length)
return ERROR_FAILURE_RETURN;
if (StringCopyW(lpBuffer, Module->FullDllName.Buffer) == NULL)
return ERROR_FAILURE_RETURN;
return Module->FullDllName.Length;
}