Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "windows.h"
- #include "stdio.h"
- #include "conio.h"
- #include "stdint.h"
- BYTE asmOfNopFunction[2] =
- {
- 0x90,
- 0xC3
- };
- int main()
- {
- const int NUMBER_OF_MEANINGS = 5;
- const int NUMBER_OF_THREADS = 1000;
- float createThreadTimings[NUMBER_OF_MEANINGS];
- HANDLE threadHandles[NUMBER_OF_THREADS];
- int64_t qpf, start, stop;
- QueryPerformanceFrequency((LARGE_INTEGER*)&qpf);
- SetLastError(10101);
- for(int currentMeaningOfSuspendedThreads = 0; currentMeaningOfSuspendedThreads < NUMBER_OF_MEANINGS; currentMeaningOfSuspendedThreads++)
- {
- QueryPerformanceCounter((LARGE_INTEGER*)&start);
- for(int currentThread = 0; currentThread < NUMBER_OF_THREADS; currentThread++)
- {
- threadHandles[currentThread] = CreateThread(0, 8, &asmOfNopFunction, 0, CREATE_SUSPENDED, 0);
- printf("thr%i-handle%i\n", currentThread, threadHandles[currentThread]);
- TerminateThread(threadHandles[currentThread], 0);
- }
- QueryPerformanceCounter((LARGE_INTEGER*)&stop);
- createThreadTimings[currentMeaningOfSuspendedThreads] = (stop - start) / (float)qpf;
- }
- int j = GetLastError();
- SetLastError(10102);
- for(int currentMeaningOfWorkingThreads = 0; currentMeaningOfWorkingThreads < NUMBER_OF_MEANINGS; currentMeaningOfWorkingThreads++)
- {
- for(int currentThread = 0; currentThread < NUMBER_OF_THREADS; currentThread++)
- {
- threadHandles[currentThread] = CreateThread(0, 0, &asmOfNopFunction, 0, CREATE_SUSPENDED, 0);
- printf("thr%i-handle%i\n", currentThread, threadHandles[currentThread]);
- TerminateThread(threadHandles[currentThread], 0);
- }
- }
- printf("Last error is %i", j);
- printf("Last error is %i", GetLastError());
- ((void(*)())asmOfNopFunction)();
- getch();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement