summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-01-19 03:42:10 +0000
committermidipix <writeonce@midipix.org>2017-01-19 00:44:22 -0500
commit365987ac7436574fe47040cd67602b71112d76ce (patch)
treeda6410a4624470edfce0b2062dca1fbba9c84347
parentfea9cb6e139992bdc7ced59e64623815db15434f (diff)
downloadntapi-365987ac7436574fe47040cd67602b71112d76ce.tar.bz2
ntapi-365987ac7436574fe47040cd67602b71112d76ce.tar.xz
__ntapi_tt_get_runtime_data(): simplify logic, check align. at page boundary.
-rw-r--r--src/process/ntapi_tt_get_runtime_data.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/process/ntapi_tt_get_runtime_data.c b/src/process/ntapi_tt_get_runtime_data.c
index 60cdf17..bda6f7e 100644
--- a/src/process/ntapi_tt_get_runtime_data.c
+++ b/src/process/ntapi_tt_get_runtime_data.c
@@ -28,7 +28,8 @@ int32_t __stdcall __ntapi_tt_get_runtime_data(
int32_t status;
nt_process_parameters * process_params;
wchar16_t * addrarg;
- nt_runtime_data buffer;
+ uintptr_t address;
+ uintptr_t buffer;
nt_runtime_data * prtdata;
ntapi_internals * __internals;
@@ -42,34 +43,39 @@ int32_t __stdcall __ntapi_tt_get_runtime_data(
}
if (!(wargv = wargv ? wargv : __internals->ntapi_img_sec_bss->argv_envp_array))
- return NT_STATUS_INVALID_PARAMETER_2;
+ return NT_STATUS_INVALID_PARAMETER;
if (!wargv[1] || !wargv[2])
return NT_STATUS_MORE_PROCESSING_REQUIRED;
/* integral process? */
- if ((wargv[1][0] == '-') && (wargv[1][1] == 'r') && (wargv[1][2] == 0))
- addrarg = wargv[2];
- else
- return NT_STATUS_INVALID_PARAMETER;
+ addrarg = ((wargv[1][0] == '-') && (wargv[1][1] == 'r') && (wargv[1][2] == 0))
+ ? wargv[2] : 0;
+ /* top-level framework process? */
if (!addrarg || wargv[3])
- status = NT_STATUS_INVALID_PARAMETER_MIX;
+ return NT_STATUS_MORE_PROCESSING_REQUIRED;
/* obtain pointer to data block */
if ((status = __ntapi->tt_hex_utf16_to_uintptr(
- addrarg,
- (uintptr_t *)&prtdata)))
+ addrarg,&address)))
return status;
+ /* invalid pointer? */
+ if (address & 0xFFF)
+ return NT_STATUS_MORE_PROCESSING_REQUIRED;
+
+ /* address is aligned at page boundary */
if ((status = __ntapi->zw_read_virtual_memory(
NT_CURRENT_PROCESS_HANDLE,
- prtdata,
+ (void *)address,
(char *)&buffer,
- sizeof(buffer),0)))
+ sizeof(buffer),
+ 0)))
return status;
/* update state */
+ prtdata = (nt_runtime_data *)address;
prtdata->flags |= NT_RUNTIME_DATA_INTEGRAL_PROCESS;
/* avoid confusion :-) */