Skip to content

Commit

Permalink
in/out specifications, added a few helpers in module.c, added wow64st…
Browse files Browse the repository at this point in the history
…dcall by darthton
  • Loading branch information
Synestraa committed Mar 2, 2017
1 parent 8af0dd0 commit 9305c65
Show file tree
Hide file tree
Showing 20 changed files with 708 additions and 1,393 deletions.
8 changes: 4 additions & 4 deletions Current/Build/Include/highcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ static HIGHCALL_STATUS InitializeModules(VOID)
}

/* Load anything we need from ntdll while we're at it. */
if (HcStringCompareContentW(L"ntdll.dll", pLdrDataTableEntry->FullModuleName.Buffer))
if (HcStringCompareW(L"ntdll.dll", pLdrDataTableEntry->FullModuleName.Buffer))
{
HcGlobal.HandleNtdll = (HMODULE)pLdrDataTableEntry->InInitializationOrderLinks.Flink;
}
else if (HcStringCompareContentW(L"user32.dll", pLdrDataTableEntry->FullModuleName.Buffer))
else if (HcStringCompareW(L"user32.dll", pLdrDataTableEntry->FullModuleName.Buffer))
{
HcGlobal.HandleUser32 = (HMODULE)pLdrDataTableEntry->InInitializationOrderLinks.Flink;
}
else if (HcStringCompareContentW(L"kernel32.dll", pLdrDataTableEntry->FullModuleName.Buffer))
else if (HcStringCompareW(L"kernel32.dll", pLdrDataTableEntry->FullModuleName.Buffer))
{
HcGlobal.HandleKernel32 = (HMODULE)pLdrDataTableEntry->InInitializationOrderLinks.Flink;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ static VOID InitializeSecurity(VOID)
if (NT_SUCCESS(Status))
{
HcTokenIsElevated(hToken, &(HcGlobal.IsElevated));
HcObjectClose(hToken);
HcObjectClose(&hToken);
}
}

Expand Down
318 changes: 175 additions & 143 deletions Current/Build/Include/highcall.h

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Current/Current.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@
<ClInclude Include="public\wintype.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="private\wow64\wow64stdcall.asm">
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</UseSafeExceptionHandlers>
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='DYNAMIC_DEBUG|Win32'">true</UseSafeExceptionHandlers>
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='DYNAMIC_RELEASE|Win32'">true</UseSafeExceptionHandlers>
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</UseSafeExceptionHandlers>
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">2</CallingConvention>
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='DYNAMIC_DEBUG|Win32'">2</CallingConvention>
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='DYNAMIC_RELEASE|Win32'">2</CallingConvention>
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">2</CallingConvention>
</MASM>
<MASM Include="private\sys\asm\AcceptConnectPort.asm">
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</UseSafeExceptionHandlers>
<UseSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='DYNAMIC_DEBUG|x64'">false</UseSafeExceptionHandlers>
Expand Down
1 change: 1 addition & 0 deletions Current/Current.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@
<MASM Include="private\sys\asm\Wow64WriteVirtualMemory64.asm">
<Filter>private\sys\asm</Filter>
</MASM>
<MASM Include="private\wow64\wow64stdcall.asm" />
</ItemGroup>
<ItemGroup>
<Filter Include="private">
Expand Down
2 changes: 0 additions & 2 deletions Current/private/kernel/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "../sys/syscall.h"

#define WAIT_IO_COMPLETION 0xC0

DECL_EXTERN_API(VOID, Sleep, CONST IN DWORD dwMilliseconds)
{
LARGE_INTEGER Time;
Expand Down
12 changes: 6 additions & 6 deletions Current/private/kernel/construct.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <highcall.h>

DECL_EXTERN_API(PHC_MODULE_INFORMATIONW, InitializeModuleInformationW, DWORD tNameSize, DWORD tPathSize)
DECL_EXTERN_API(PHC_MODULE_INFORMATIONW, InitializeModuleInformationW, CONST IN DWORD tNameSize, CONST IN DWORD tPathSize)
{
PHC_MODULE_INFORMATIONW obj = HcAlloc(sizeof(*obj));

Expand All @@ -10,14 +10,14 @@ DECL_EXTERN_API(PHC_MODULE_INFORMATIONW, InitializeModuleInformationW, DWORD tNa
return obj;
}

DECL_EXTERN_API(VOID, DestroyModuleInformationW, PHC_MODULE_INFORMATIONW o)
DECL_EXTERN_API(VOID, DestroyModuleInformationW, IN PHC_MODULE_INFORMATIONW o)
{
HcFree(o->Name);
HcFree(o->Path);
HcFree(o);
}

DECL_EXTERN_API(PHC_PROCESS_INFORMATION_EXW, InitializeProcessInformationExW, DWORD tNameSize)
DECL_EXTERN_API(PHC_PROCESS_INFORMATION_EXW, InitializeProcessInformationExW, CONST IN DWORD tNameSize)
{
PHC_PROCESS_INFORMATION_EXW obj = HcAlloc(sizeof(*obj));

Expand All @@ -27,14 +27,14 @@ DECL_EXTERN_API(PHC_PROCESS_INFORMATION_EXW, InitializeProcessInformationExW, DW
return obj;
}

DECL_EXTERN_API(VOID, DestroyProcessInformationExW, PHC_PROCESS_INFORMATION_EXW o)
DECL_EXTERN_API(VOID, DestroyProcessInformationExW, IN PHC_PROCESS_INFORMATION_EXW o)
{
HcFree(o->Name);
HcDestroyModuleInformationW(o->MainModule);
HcFree(o);
}

DECL_EXTERN_API(PHC_PROCESS_INFORMATIONW, InitializeProcessInformationW, DWORD tNameSize)
DECL_EXTERN_API(PHC_PROCESS_INFORMATIONW, InitializeProcessInformationW, CONST IN DWORD tNameSize)
{
PHC_PROCESS_INFORMATIONW obj;

Expand All @@ -44,7 +44,7 @@ DECL_EXTERN_API(PHC_PROCESS_INFORMATIONW, InitializeProcessInformationW, DWORD t
return obj;
}

DECL_EXTERN_API(VOID, DestroyProcessInformationW, PHC_PROCESS_INFORMATIONW o)
DECL_EXTERN_API(VOID, DestroyProcessInformationW, IN PHC_PROCESS_INFORMATIONW o)
{
HcFree(o->Name);
HcFree(o);
Expand Down
11 changes: 7 additions & 4 deletions Current/private/kernel/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@ DECL_EXTERN_API(DWORD, ErrorStatusToDos, IN NTSTATUS Status)
return HcErrorStatusTranslate(Status);
}

DECL_EXTERN_API(VOID, ErrorSetDosError, IN DWORD dwErrCode)
DECL_EXTERN_API(VOID, ErrorSetDosError, CONST IN DWORD dwErrCode)
{
/* Check if the error is already set before setting it. */
if (NtCurrentTeb()->LastErrorValue != dwErrCode) NtCurrentTeb()->LastErrorValue = dwErrCode;
if (NtCurrentTeb()->LastErrorValue != dwErrCode)
{
NtCurrentTeb()->LastErrorValue = dwErrCode;
}
}

DECL_EXTERN_API(DWORD, ErrorGetDosError, VOID)
DECL_EXTERN_API(DWORD, ErrorGetDosError)
{
/* Return the current value */
return NtCurrentTeb()->LastErrorValue;
}
DECL_EXTERN_API(DWORD, ErrorSetNtStatus, IN NTSTATUS Status)
DECL_EXTERN_API(DWORD, ErrorSetNtStatus, CONST IN NTSTATUS Status)
{
DWORD dwErrCode;
PTEB Teb = NtCurrentTeb();
Expand Down
Loading

0 comments on commit 9305c65

Please sign in to comment.