Skip to Main Content
Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals
book

Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals

by James C Foster
April 2005
Intermediate to advanced content levelIntermediate to advanced
700 pages
20h 39m
English
Syngress
Content preview from Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals
37 h = CreateThread(NULL, 0, thread_entry_point, NULL, 0, NULL);
38 if(h == NULL)
39 {
40 printf("CreateThread() failed.\r\n");
41 return(1);
42 }
43
44
while(1)
45 {
46 EnterCriticalSection(&lock);
47
48
++g_val;
49 printf("thread 1 , g_val: %d\n", g_val);
50
51
LeaveCriticalSection(&lock);
52
53
Sleep(1000);
54 }
55
56
DeleteCriticalSection(&lock);
57
58
return(0);
59 }
Example Execution
Let’s look at the thread4.c output.
Output
C:\Documents and Settings\Mike\
My Documents\Visual Studio Projects\thread4\Debug>thread4.exe
thread 1 , g_val: 1
thread 2 , g_val: 2
thread 1 , g_val: 3
thread 2 , g_val: 4
Analysis
At line 7, the windows.h header file is included.This header file is required for
the CreateThread and CriticalSection family of functions.
At line 11, the lock variable is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

32/64-Bit 80x86 Assembly Language Architecture

32/64-Bit 80x86 Assembly Language Architecture

James Leiterman

Publisher Resources

ISBN: 9781597490054