ReactOS 0.4.16-dev-306-g647d351
noexecute.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <pseh/pseh.h>
Include dependency graph for noexecute.c:

Go to the source code of this file.

Functions

int test (int x)
 
void execute (char *message, int(*func)(int))
 
int main (void)
 

Variables

char data [100]
 

Function Documentation

◆ execute()

void execute ( char message,
int(*)(int func 
)

Definition at line 13 of file noexecute.c.

14{
15 ULONG status = 0;
17
18 printf("%s ... ", message);
19
21 {
22 result = func(1);
23 }
25 {
27 }
29 if (status == 0)
30 {
31 printf("OK.\n");
32 }
33 else
34 {
35 printf("Error, status=%lx.\n", status);
36 }
37}
#define _SEH_TRY
Definition: framebased.h:244
#define _SEH_HANDLE
Definition: framebased.h:370
#define _SEH_GetExceptionCode()
Definition: framebased.h:158
#define _SEH_END
Definition: framebased.h:358
#define printf
Definition: freeldr.h:97
GLenum func
Definition: glext.h:6028
GLuint64EXT * result
Definition: glext.h:11304
Definition: tftpd.h:60
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59

Referenced by add_file_data(), and main().

◆ main()

int main ( void  )

Definition at line 41 of file noexecute.c.

42{
43 unsigned char stack[100];
44 void* heap;
45 ULONG protection;
46
47 printf("NoExecute\n");
48
49 execute("Executing within the code segment", test);
50 memcpy(data, test, 100);
51 execute("Executing within the data segment", (int(*)(int))data);
52 memcpy(stack, test, 100);
53 execute("Executing on stack segment", (int(*)(int))stack);
55 memcpy(heap, test, 100);
56 execute("Executing on the heap with protection PAGE_READWRITE", (int(*)(int))heap);
57 VirtualProtect(heap, 100, PAGE_EXECUTE, &protection);
58 execute("Executing on the heap with protection PAGE_EXECUTE", (int(*)(int))heap);
59
60 return 0;
61}
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void execute(char *message, int(*func)(int))
Definition: noexecute.c:13
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define PAGE_EXECUTE
Definition: nt_native.h:1306
#define MEM_COMMIT
Definition: nt_native.h:1313
#define test
Definition: rosglue.h:37
static HANDLE heap
Definition: heap.c:65
Definition: format.c:80
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135

◆ test()

int test ( int  x)

Definition at line 8 of file noexecute.c.

9{
10 return x+1;
11}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Variable Documentation

◆ data

char data[100]

Definition at line 39 of file noexecute.c.