Github
Https://github.com/gongluck/Windows-Core-Program.git
12th. CPP: Defines the entry point for the application. #include "stdafx.h" #include "the 12th Chapter fiber. h" lpvoid G_covert = Nullptr;dword g_index = 0; VOID WINAPI Fiberfun (lpvoid lpfiberparameter) {//fiber parameter LPVoid pfibercurrent = Getcurrentfiber (); BOOL Bres = Isthreadafiber (); LPVOID pcurrentdata = GetFiberData ();//Get parameters passed when creating fiber, pcurrentdata==lpfiberparameter==555//fiber local Storage Bres = Flssetvalue (G_index, (PVOID) 200); PVOID Flsvalue = Flsgetvalue (G_index); SwitchToFiber (G_covert);} VOID Ntapi flsfun (in PVOID lpflsdata) {//flssetvalue How many times, system calls Flsfun how many times//can be actively called Flsfree delete FLS slots//fiber destruction when also called Flsfun}in T apientry wWinMain (_in_ hinstance hinstance, _in_opt_ hinstance hprevinstance, _in_ lpwstr lpCmdLine, _In_ in T ncmdshow) {//convert thread to fiber lpvoid Pfibercovert = Convertthreadtofiberex (nullptr, Fiber_flag_float_switch); G_covert = Pfibercovert; Fiber Local Storage Area G_index = Flsalloc (Flsfun); BOOL Bres = Flssetvalue (G_index, (PVOID) 100); PVOID Flsvalue = Flsgetvalue (G_index); Create fiberLPVOID pfibercreate = Createfiberex (0, 0, Fiber_flag_float_switch, Fiberfun, (LPVOID) 555); Switch fiber SwitchToFiber (pfibercreate); Bres = Flsfree (G_index); Destruction of fiber deletefiber (pfibercreate); The fiber state of the thread is lifted Bres = Convertfibertothread (); System ("pause"); return 0;}
Windows core programming: 12th Fiber