Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ProcessThreads.c « winapi « peloader - github.com/taviso/loadlibrary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 594f40522dcf324fdf5a9f22c9f891499e50d47a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <search.h>
#include <assert.h>
#include <unistd.h>

#include "winnt_types.h"
#include "pe_linker.h"
#include "ntoskernel.h"
#include "log.h"
#include "winexports.h"
#include "util.h"
#include "winstrings.h"

static PVOID WINAPI CreateThreadpoolTimer(PVOID pfnti, PVOID pv, PVOID pcbe)
{
    // DebugLog("%p, %p, %p", pfnti, pv, pcbe);
    return (PVOID) 'POOL';
}

static VOID WINAPI InitializeSRWLock(PVOID SRWLock)
{
    DebugLog("%p", SRWLock);
}

static VOID WINAPI SetThreadpoolTimer(PVOID pti, PVOID pftDueTime, DWORD msPeriod, DWORD msWindowLength)
{
    DebugLog("%p, %p, %u, %u", pti, pftDueTime, msPeriod, msWindowLength);
}

static VOID WINAPI WaitForThreadpoolTimerCallbacks(PVOID pti, BOOL fCancelPendingCallbacks)
{
    DebugLog("%p, %u", pti, fCancelPendingCallbacks);
}

static VOID WINAPI CloseThreadpoolTimer(PVOID pti)
{
    DebugLog("%p", pti);
}

static LONG InterlockedDecrement(PULONG Addend)
{
    DebugLog("%p", Addend);
    return --*Addend;
}

static LONG InterlockedIncrement(PULONG Addend)
{
    DebugLog("%p", Addend);
    return ++*Addend;
}

static LONG InterlockedCompareExchange(PULONG Destination, LONG Exchange, LONG Comparand)
{
    DebugLog("%p", Destination);
    if (*Destination == Comparand) {
        *Destination = Exchange;
    }
    return *Destination;
}

static HANDLE WINAPI CreateSemaphoreW(PVOID lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, PWCHAR lpName)
{
    char *name;
#ifndef NDEBUG
    name = CreateAnsiFromWide(lpName);
#else
    name = NULL;
#endif
    DebugLog("%p, %u, %u, %p [%s]", lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName, name);
    free(name);
    return (HANDLE) 'SEMA';
}

static HANDLE WINAPI GetCurrentProcess(VOID)
{
    return (HANDLE) -1;
}

static HANDLE WINAPI GetCurrentThread(VOID)
{
    return (HANDLE) -1;
}

static DWORD WINAPI GetCurrentThreadId(VOID)
{
    return getpid();
}

static DWORD WINAPI GetCurrentProcessId(VOID)
{
    return getpid();
}

static BOOL WINAPI RegisterWaitForSingleObject(PHANDLE phNewWaitObject, HANDLE hObject, PVOID Callback, PVOID Context, ULONG dwMilliseconds, ULONG dwFlags)
{
    DebugLog("");
    return TRUE;
}

static VOID WINAPI AcquireSRWLockExclusive(PVOID SRWLock)
{
    DebugLog("%p", SRWLock);
}

static VOID WINAPI ReleaseSRWLockExclusive(PVOID SRWLock)
{
    DebugLog("%p", SRWLock);
}

static HANDLE WINAPI CreateMutexW(PVOID lpMutexAttributes, BOOL bInitialOwner, PWCHAR lpName)
{
    DebugLog("%p, %u, %p");
    return INVALID_HANDLE_VALUE;
}

static DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
{
    DebugLog("%p, %u", hHandle, dwMilliseconds);
    return -1;
}

static ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status)
{
    DebugLog("%#x", Status);
    return Status;
}

static BOOL WINAPI CreateTimerQueueTimer(PHANDLE phNewTimer,
                                         HANDLE TimerQueue,
                                         PVOID Callback,
                                         PVOID Parameter,
                                         DWORD DueTime,
                                         DWORD Period,
                                         ULONG Flags)
{
    DebugLog("");
    return TRUE;
}

static BOOL WINAPI GetThreadTimes(HANDLE hThread,
                                  PFILETIME lpCreationTime,
                                  PFILETIME lpExitTime,
                                  PFILETIME lpKernelTime,
                                  PFILETIME lpUserTime)
{
    DebugLog("");
    return TRUE;
}

static ULONG WINAPI RtlNtStatusToDosError(NTSTATUS Status)
{
    DebugLog("%#x", Status);
    return 5;
}

static BOOL WINAPI SetThreadToken(PHANDLE Thread, HANDLE Token)
{
    DebugLog("");
    return FALSE;
}

static BOOL WINAPI ProcessIdToSessionId(DWORD dwProcessId, DWORD *pSessionId)
{
    DebugLog("");
    return FALSE;
}

DECLARE_CRT_EXPORT("RtlNtStatusToDosError", RtlNtStatusToDosError);
DECLARE_CRT_EXPORT("GetThreadTimes", GetThreadTimes);
DECLARE_CRT_EXPORT("GetCurrentThread", GetCurrentThread);
DECLARE_CRT_EXPORT("CreateTimerQueueTimer", CreateTimerQueueTimer);
DECLARE_CRT_EXPORT("RegisterWaitForSingleObject", RegisterWaitForSingleObject);
DECLARE_CRT_EXPORT("WaitForSingleObject", WaitForSingleObject);
DECLARE_CRT_EXPORT("GetCurrentProcess", GetCurrentProcess);
DECLARE_CRT_EXPORT("LsaNtStatusToWinError", LsaNtStatusToWinError);
DECLARE_CRT_EXPORT("SetThreadToken", SetThreadToken);
DECLARE_CRT_EXPORT("InterlockedDecrement", InterlockedDecrement);
DECLARE_CRT_EXPORT("InterlockedIncrement", InterlockedIncrement);
DECLARE_CRT_EXPORT("InterlockedCompareExchange", InterlockedCompareExchange);
DECLARE_CRT_EXPORT("CreateSemaphoreW", CreateSemaphoreW);
DECLARE_CRT_EXPORT("AcquireSRWLockExclusive", AcquireSRWLockExclusive);
DECLARE_CRT_EXPORT("InitializeSRWLock", InitializeSRWLock);
DECLARE_CRT_EXPORT("ReleaseSRWLockExclusive", ReleaseSRWLockExclusive);
DECLARE_CRT_EXPORT("SetThreadpoolTimer", SetThreadpoolTimer);
DECLARE_CRT_EXPORT("WaitForThreadpoolTimerCallbacks", WaitForThreadpoolTimerCallbacks);
DECLARE_CRT_EXPORT("GetCurrentThreadId", GetCurrentThreadId);
DECLARE_CRT_EXPORT("GetCurrentProcessId", GetCurrentProcessId);
DECLARE_CRT_EXPORT("ProcessIdToSessionId", ProcessIdToSessionId);