ReactOS 0.4.15-dev-7924-g5949c20
ntoskrnl.c File Reference
#include <apitest.h>
#include <strsafe.h>
Include dependency graph for ntoskrnl.c:

Go to the source code of this file.

Classes

struct  KnownSections
 

Macros

#define IFX(x)
 

Typedefs

typedef struct KnownSections KnownSections
 

Functions

static charChr2Str (DWORD value)
 
 START_TEST (ntoskrnl_SectionFlags)
 

Variables

static struct KnownSections g_Sections []
 

Macro Definition Documentation

◆ IFX

#define IFX (   x)
Value:
if( value & IMAGE_SCN_##x )\
{\
if(buf[0]) { StringCchCatA(buf, _countof(buf), "|" ); }\
StringCchCatA(buf, _countof(buf), #x );\
value &= ~(IMAGE_SCN_##x);\
}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
Definition: pdh_main.c:94

Typedef Documentation

◆ KnownSections

Function Documentation

◆ Chr2Str()

static char * Chr2Str ( DWORD  value)
static

Definition at line 52 of file ntoskrnl.c.

53{
54 static char buf[512];
55 buf[0] = '\0';
56#define IFX(x) if( value & IMAGE_SCN_##x )\
57 {\
58 if(buf[0]) { StringCchCatA(buf, _countof(buf), "|" ); }\
59 StringCchCatA(buf, _countof(buf), #x );\
60 value &= ~(IMAGE_SCN_##x);\
61 }
62 IFX(TYPE_NO_PAD);
63 IFX(CNT_CODE);
64 IFX(CNT_INITIALIZED_DATA);
65 IFX(CNT_UNINITIALIZED_DATA);
66 IFX(LNK_OTHER);
67 IFX(LNK_INFO);
68 IFX(LNK_REMOVE);
69 IFX(LNK_COMDAT);
70 //IFX(NO_DEFER_SPEC_EXC);
71 //IFX(GPREL);
72 IFX(MEM_FARDATA);
73 IFX(MEM_PURGEABLE);
74 IFX(MEM_16BIT);
75 IFX(MEM_LOCKED);
76 IFX(MEM_PRELOAD);
77 IFX(ALIGN_1BYTES);
78 IFX(ALIGN_2BYTES);
79 IFX(ALIGN_4BYTES);
80 IFX(ALIGN_8BYTES);
81 IFX(ALIGN_16BYTES);
82 IFX(ALIGN_32BYTES);
83 IFX(ALIGN_64BYTES);
84 //IFX(ALIGN_128BYTES);
85 //IFX(ALIGN_256BYTES);
86 //IFX(ALIGN_512BYTES);
87 //IFX(ALIGN_1024BYTES);
88 //IFX(ALIGN_2048BYTES);
89 //IFX(ALIGN_4096BYTES);
90 //IFX(ALIGN_8192BYTES);
91 IFX(LNK_NRELOC_OVFL);
92 IFX(MEM_DISCARDABLE);
93 IFX(MEM_NOT_CACHED);
94 IFX(MEM_NOT_PAGED);
95 IFX(MEM_SHARED);
96 IFX(MEM_EXECUTE);
99 if( value )
100 {
102 }
103 return buf;
104}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define IFX(x)
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
#define MEM_READ
Definition: ws2san.h:35
#define MEM_WRITE
Definition: ws2san.h:36

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( ntoskrnl_SectionFlags  )

Definition at line 107 of file ntoskrnl.c.

108{
109 char buf[MAX_PATH];
110 HMODULE mod;
112 StringCchCatA(buf, _countof(buf), "\\ntoskrnl.exe");
113
115 if( mod != NULL )
116 {
117 // we have to take into account that a datafile is not returned at the exact address it's loaded at.
118 PIMAGE_DOS_HEADER dos = (PIMAGE_DOS_HEADER)(((size_t)mod) & (~0xf));
120 PIMAGE_SECTION_HEADER firstSection;
121 WORD numSections, n;
122
124 {
125 skip("Couldn't find ntoskrnl.exe dos header\n");
127 return;
128 }
131 {
132 skip("Couldn't find ntoskrnl.exe nt header\n");
134 return;
135 }
136 firstSection = IMAGE_FIRST_SECTION(nt);
137 numSections = nt->FileHeader.NumberOfSections;
138 for( n = 0; n < numSections; ++n )
139 {
140 PIMAGE_SECTION_HEADER section = firstSection + n;
141 char name[9] = {0};
142 size_t i;
144
145 for( i = 0; g_Sections[i].Name; ++i )
146 {
147 if( !_strnicmp(name, g_Sections[i].Name, 8) )
148 {
149 if( g_Sections[i].Required )
150 {
151 DWORD Flags = g_Sections[i].Required & section->Characteristics;
153 "Missing required Characteristics on %s: %s\n",
155 }
156 if( g_Sections[i].Disallowed )
157 {
158 DWORD Flags = g_Sections[i].Disallowed & section->Characteristics;
159 ok(!Flags, "Disallowed section Characteristics on %s: %s\n",
160 name, Chr2Str(section->Characteristics));
161 }
162 break;
163 }
164 }
165 }
167 }
168 else
169 {
170 skip("Couldn't load ntoskrnl.exe as datafile\n");
171 }
172}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define FreeLibrary(x)
Definition: compat.h:748
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define MAX_PATH
Definition: compat.h:34
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
unsigned long DWORD
Definition: ntddk_ex.h:95
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static int mod
Definition: i386-dis.c:1288
static struct KnownSections g_Sections[]
Definition: ntoskrnl.c:18
static char * Chr2Str(DWORD value)
Definition: ntoskrnl.c:52
IMAGE_NT_HEADERS nt
Definition: module.c:50
IMAGE_DOS_HEADER dos
Definition: module.c:49
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN _Inout_ PMM_REQUIRED_RESOURCES Required
Definition: newmm.h:210
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
BYTE * PBYTE
Definition: pedump.c:66
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:230
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
Definition: name.c:39
Definition: parser.c:56
const char * PCSTR
Definition: typedefs.h:52
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Variable Documentation

◆ g_Sections

struct KnownSections g_Sections[]
static

Definition at line 18 of file ntoskrnl.c.

Referenced by START_TEST().