Skip to content

Commit bedfefe

Browse files
Jonathan MooreJonathan Moore
authored andcommitted
Initial Commit
1 parent bc09776 commit bedfefe

943 files changed

Lines changed: 902183 additions & 77 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*++
2+
3+
Copyright (c) 1997-2000 Microsoft Corporation
4+
5+
Module Name:
6+
7+
NtdllTracer.h
8+
9+
Abstract:
10+
11+
This file contains structures and functions definitions used in Ntdll
12+
events tracing
13+
14+
15+
--*/
16+
17+
#ifndef _NTDLL_WMI_TRACE_
18+
#define _NTDLL_WMI_TRACE_
19+
20+
#define MEMORY_FROM_LOOKASIDE 1 //Activity from LookAside
21+
#define MEMORY_FROM_LOWFRAG 2 //Activity from Low Frag Heap
22+
#define MEMORY_FROM_MAINPATH 3 //Activity from Main Code Path
23+
#define MEMORY_FROM_SLOWPATH 4 //Activity from Slow Code Path
24+
25+
#define LOG_LOOKASIDE 0x00000001 //Bit for LookAside trace
26+
27+
#define FAILED_TLSINDEX -1
28+
#define MAX_PID 10
29+
30+
#ifndef UserSharedData
31+
#define UserSharedData USER_SHARED_DATA
32+
#endif
33+
34+
#define IN_TRACING 0x00000001 // Flag to see if this thread is tracing.
35+
extern BOOLEAN bNtdllTrace;
36+
37+
#define IsCritSecLogging(CriticalSection) ((USER_SHARED_DATA->TraceLogging & ENABLECRITSECTRACE) \
38+
&&(bNtdllTrace || GlobalCounter != (USER_SHARED_DATA->TraceLogging >> 16)) \
39+
&&((HandleToUlong(NtCurrentTeb()->EtwTraceData) & IN_TRACING) != IN_TRACING))
40+
41+
extern
42+
ULONG GlobalCounter;
43+
44+
#define IsHeapLogging(HeapHandle) (USER_SHARED_DATA->TraceLogging & ENABLEHEAPTRACE &&\
45+
(bNtdllTrace || GlobalCounter != (USER_SHARED_DATA->TraceLogging >> 16))&& \
46+
((HandleToUlong(NtCurrentTeb()->EtwTraceData) & IN_TRACING) != IN_TRACING))
47+
48+
//
49+
// When calling from deep inside heap allocation routines, we do not want to
50+
// be initializing ETW process heap since that gets into recursive behaviour.
51+
//
52+
53+
#define IsDeepHeapLogging(HeapHandle) (USER_SHARED_DATA->TraceLogging & ENABLEHEAPTRACE &&\
54+
(bNtdllTrace || GlobalCounter != (USER_SHARED_DATA->TraceLogging >> 16))&& \
55+
(EtwpProcessHeap != NULL) && \
56+
((HandleToUlong(NtCurrentTeb()->EtwTraceData) & IN_TRACING) != IN_TRACING))
57+
58+
59+
typedef struct _THREAD_LOCAL_DATA THREAD_LOCAL_DATA, *PTHREAD_LOCAL_DATA, **PPTHREAD_LOCAL_DATA;
60+
61+
typedef struct _THREAD_LOCAL_DATA {
62+
63+
PTHREAD_LOCAL_DATA FLink; //Forward Link
64+
PTHREAD_LOCAL_DATA BLink; //Backward Link
65+
PWMI_BUFFER_HEADER pBuffer; //Pointer to thread buffer info.
66+
LONG ReferenceCount;
67+
68+
} THREAD_LOCAL_DATA, *PTHREAD_LOCAL_DATA, **PPTHREAD_LOCAL_DATA;
69+
70+
extern
71+
PVOID EtwpProcessHeap;
72+
73+
#ifndef EtwpGetCycleCount
74+
75+
__int64
76+
EtwpGetCycleCount();
77+
78+
#endif // EtwpGetCycleCount
79+
80+
void
81+
ReleaseBufferLocation(PTHREAD_LOCAL_DATA pThreadLocalData);
82+
83+
NTSTATUS
84+
AcquireBufferLocation(PVOID *pEvent, PPTHREAD_LOCAL_DATA pThreadLocalData, PUSHORT ReqSize);
85+
86+
typedef struct _NTDLL_EVENT_COMMON {
87+
88+
PVOID Handle; //Handle of Heap
89+
90+
}NTDLL_EVENT_COMMON, *PNTDLL_EVENT_COMMON;
91+
92+
93+
typedef struct _NTDLL_EVENT_HANDLES {
94+
95+
RTL_CRITICAL_SECTION CriticalSection; //Critical section
96+
ULONG dwTlsIndex; //TLS Index
97+
TRACEHANDLE hRegistrationHandle; //Registration Handle used for Unregistration.
98+
TRACEHANDLE hLoggerHandle; //Handle to Trace Logger
99+
PTHREAD_LOCAL_DATA pThreadListHead; //Link List that contains all threads info invovled in tracing.
100+
101+
}NTDLL_EVENT_HANDLES, *PNTDLL_EVENT_HANDLES, **PPNTDLL_EVENT_HANDLES;
102+
103+
extern LONG TraceLevel;
104+
extern PNTDLL_EVENT_HANDLES NtdllTraceHandles;
105+
extern RTL_CRITICAL_SECTION UMLogCritSect;
106+
extern RTL_CRITICAL_SECTION PMCritSect;
107+
extern RTL_CRITICAL_SECTION LoaderLock;
108+
109+
#endif //_NTDLL_WMI_TRACE_
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
#
4+
# You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt).
5+
# If you do not agree to the terms, do not use the code.
6+
#
7+
8+
kernel = wrk$(machine)
9+
10+
asobjs=
11+
ccobjs=
12+
ccarchobjs=
13+
14+
default: kernelexp kernellib kernelexe
15+
16+
nodefault=1
17+
!include $(ntos)\BUILD\makefile.build
18+
19+
linklibpath = -LIBPATH:$(topobj) -LIBPATH:PREBUILT\$(targ)
20+
ntoswrklib = ntoswrk.lib
21+
ntosarchlib = ntosarch.lib
22+
bootlibs = bootvid.lib sdbapint.lib kdcom.lib
23+
24+
fullkernel = EXE\$(kernel)
25+
26+
# kernel link definitions
27+
LINKFLAGS = -IGNORE:4087,4001,4010,4037,4039,4065,4070,4078,4087,4089,4221,4198 -WX -NODEFAULTLIB -machine:$(machine) $(linklibpath)
28+
LINK = link.exe -nologo
29+
LINKEDIT = link.exe -edit -nologo
30+
31+
LIB = $(LIB) $(linklibpath)
32+
33+
!if "$(targ)" == "i386"
34+
archlinkopts = -safeseh -functionpadmin:5 -debugtype:cv,fixup -STACK:0x40000,0x2000 -align:0x1000
35+
hotpatch = -stub:PREBUILT\i386\stub512.com
36+
entrypoint = KiSystemStartup@4
37+
!else
38+
archlinkopts = -functionpadmin:6 -debugtype:cv,fixup,pdata -STACK:0x80000,0x2000
39+
hotpatch = PREBUILT\amd64\hotpatch.obj
40+
LINKFLAGS = -IGNORE:4108,4088,4218,4218,4235 $(LINKFLAGS)
41+
LIBFLAGS = -IGNORE:4108,4088,4218,4218,4235 $(LIBFLAGS)
42+
entrypoint = KiSystemStartup
43+
!endif
44+
45+
ntosmerge = -merge:PAGECONST=PAGE -merge:INITCONST=INIT -merge:INITDATA=INIT -merge:PAGELKCONST=PAGELK \
46+
-merge:PAGEVRFY_CONST=PAGEVRFY -MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -merge:.rdata=.text
47+
48+
ntosversion = -release -version:5.2 -osversion:5.2 -subsystem:native,5.02
49+
50+
ntoslinkopts = $(ntosversion) $(ntosmerge) -SECTION:INIT,d -OPT:REF -OPT:ICF -INCREMENTAL:NO \
51+
-FULLBUILD -debug $(archlinkopts) -opt:nowin98 -pdbcompress -driver
52+
53+
kernelexp:
54+
copy ..\init\ntoskrnl.src+..\init\$(targ)def.src $(OBJ)\$(kernel).pp
55+
$(CC) $(CFLAGS0) -EP $(OBJ)\$(kernel).pp > $(fullkernel).def
56+
-del $(OBJ)\$(kernel).pp
57+
$(LIB) $(LIBFLAGS) -IGNORE:4001 $(OBJ)\*.lib $(ntoswrklib) -def:$(fullkernel).def -out:$(fullkernel).lib
58+
59+
kernellib:
60+
$(LIB) $(fullkernel).lib $(ntosarchlib) -out:$(fullkernel).lib
61+
62+
kernelexe:
63+
$(LINK) $(LINKFLAGS) $(ntoslinkopts) -out:$(fullkernel).exe -map:$(fullkernel).map -pdb:$(fullkernel).pdb -entry:$(entrypoint) \
64+
$(hotpatch) PREBUILT\$(targ)\ntoskrnl.res $(OBJ)\ntkrnlmp.obj $(OBJ)\*.lib $(ntoswrklib) hal.lib $(fullkernel).exp $(bootlibs)
65+
$(LINKEDIT) -section:.rsrc,!d $(fullkernel).exe
66+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
#
4+
# You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt).
5+
# If you do not agree to the terms, do not use the code.
6+
#
7+
8+
!if !defined(ntos) || !defined(pub) || !defined(module) || !defined(topobj) || !defined(targ) || ("$(targ)" != "i386" && "$(targ)" != "amd64")
9+
!ERROR Usage: nmake ntos=ntosdir pub=pubdir module=ntossubdir targ=[i386|amd64]
10+
!endif
11+
12+
!if "$(targ)" == "i386"
13+
targdefs = -D_X86_=1 -Di386=1 -DSTD_CALL -DFPO=0
14+
targaopts = -safeseh -coff -Zm
15+
targcopts = -Gm- -Gz -GX- -G6 -Ze -Gi- -QIfdiv- -Z7 -Oxs -Oy-
16+
targlopts =
17+
machine = x86
18+
archml = ml
19+
!else
20+
targdefs = -D_WIN64 -D_AMD64_ -DAMD64
21+
targaopts =
22+
targcopts = -Wp64 -Oxt -EHs-c- /Oxt -Gs12288 -GL- -MT -U_MT
23+
targlopts = -IGNORE:4108,4088,4218,4218,4235
24+
machine = amd64
25+
archml = ml64
26+
!endif
27+
28+
tempdir = $(topobj)\temp
29+
ipub = $(pub)\internal
30+
baseinc = $(ntos)\..\inc
31+
32+
incs = -I..\$(targ) -I. -I$(ntos)\$(module) -I$(ntos)\inc -I$(pub)\ddk\inc -I$(ipub)\ds\inc -I$(ipub)\sdktools\inc \
33+
-I$(baseinc) -I$(ipub)\base\inc -I$(pub)\sdk\inc -I$(pub)\sdk\inc\crt -I$(pub)\halkit\inc
34+
35+
defs = $(targdefs) -DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1 \
36+
-D_WIN32_WINNT=0x0502 -DWINVER=0x0502 -D_WIN32_IE=0x0603 -DWIN32_LEAN_AND_MEAN=1 -DDBG=0 -DDEVL=1 \
37+
-D__BUILDMACHINE__=WRK1.2(university) -DNDEBUG -D_NTSYSTEM_ -DNT_SMT -DNTOS_KERNEL_RUNTIME=1
38+
39+
aopts = -Cx -Zi $(targaopts)
40+
copts = -Zl -Zp8 -Gy -cbstring -W3 -WX -GR- -GF -GS $(targcopts)
41+
compilerwarnings = -FI$(ntos)\BUILD\WARNING.h
42+
43+
AS = $(archml).exe -nologo
44+
AFLAGS = $(aopts) $(incs) -Foobj$(targ)\ $(defs) $(specialaflags)
45+
46+
CC = cl.exe -nologo
47+
CFLAGS0 = $(copts) $(incs) -Foobj$(targ)\ $(defs) $(specialcflags)
48+
CFLAGS = $(CFLAGS0) $(compilerwarnings)
49+
50+
LIBFLAGS = $(targlopts) -IGNORE:4010,4037,4039,4065,4070,4078,4087,4089,4221,4198 -WX -nodefaultlib -machine:$(machine)
51+
LIB = lib.exe -nologo
52+
53+
OBJ = obj$(targ)
54+
55+
!ifndef nodefault
56+
default: build $(localtargets)
57+
!endif
58+
59+
# assembly files
60+
{..\$(targ)\}.asm{$(OBJ)\}.obj::
61+
$(AS) $(AFLAGS) -c $<
62+
63+
# arch-specific C files
64+
{..\$(targ)\}.c{$(OBJ)\}.obj::
65+
$(CC) $(CFLAGS) -c $<
66+
67+
# C files
68+
{..\}.c{$(OBJ)\}.obj::
69+
$(CC) $(CFLAGS) -c $<
70+
71+
# library
72+
$(topobj)\$(library).lib: $(asobjs) $(ccarchobjs) $(ccobjs)
73+
@echo linking $(library).lib
74+
$(LIB) $(LIBFLAGS) -out:$@ $**
75+
76+
# pseudo targets
77+
build: $(topobj)\$(library).lib
78+
79+
clean: clean0 $(localclean)
80+
81+
clean0:
82+
-del $(asobjs) $(ccarchobjs) $(ccobjs) $(extraobjs)
83+
Binary file not shown.
14.3 KB
Binary file not shown.
Binary file not shown.
2.99 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)