mirror of https://github.com/decompals/wibo.git
Properly implement GetCurrentProcessID, GetCurrentThreadId (#35)
This commit is contained in:
parent
7d08a2bdca
commit
e83af50b10
|
@ -108,17 +108,29 @@ namespace kernel32 {
|
||||||
wibo::lastError = dwErrCode;
|
wibo::lastError = dwErrCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @brief returns a pseudo handle to the current process
|
||||||
void *WIN_FUNC GetCurrentProcess() {
|
void *WIN_FUNC GetCurrentProcess() {
|
||||||
|
// pseudo handle is always returned, and is -1 (a special constant)
|
||||||
return (void *) 0xFFFFFFFF;
|
return (void *) 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WIN_FUNC GetCurrentProcessId() {
|
// @brief DWORD (unsigned int) returns a process identifier of the calling process.
|
||||||
DEBUG_LOG("GetCurrentProcessId\n");
|
unsigned int WIN_FUNC GetCurrentProcessId() {
|
||||||
return 1;
|
uint32_t pid = getpid();
|
||||||
|
DEBUG_LOG("Current processID is: %d\n", pid);
|
||||||
|
|
||||||
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int WIN_FUNC GetCurrentThreadId() {
|
unsigned int WIN_FUNC GetCurrentThreadId() {
|
||||||
return 1001; // a handy placeholder
|
pthread_t thread_id;
|
||||||
|
thread_id = pthread_self();
|
||||||
|
DEBUG_LOG("Current thread ID is: %lu\n", thread_id);
|
||||||
|
|
||||||
|
// Cast thread_id to unsigned int to fit a DWORD
|
||||||
|
unsigned int u_thread_id = (unsigned int) thread_id;
|
||||||
|
|
||||||
|
return u_thread_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN_FUNC ExitProcess(unsigned int uExitCode) {
|
void WIN_FUNC ExitProcess(unsigned int uExitCode) {
|
||||||
|
@ -438,6 +450,14 @@ namespace kernel32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetShortPathNameA: Retrieves the short path form of the specified path
|
||||||
|
*
|
||||||
|
* @param[in] lpszLongPath The path string
|
||||||
|
* @param[out] lpszShortPath A pointer to a buffer to receive
|
||||||
|
* @param[in] cchBuffer The size of the buffer that lpszShortPath points to
|
||||||
|
* @return unsigned int
|
||||||
|
*/
|
||||||
unsigned int WIN_FUNC GetShortPathNameA(const char* lpszLongPath, char* lpszShortPath, unsigned int cchBuffer) {
|
unsigned int WIN_FUNC GetShortPathNameA(const char* lpszLongPath, char* lpszShortPath, unsigned int cchBuffer) {
|
||||||
DEBUG_LOG("GetShortPathNameA(%s)...\n",lpszShortPath);
|
DEBUG_LOG("GetShortPathNameA(%s)...\n",lpszShortPath);
|
||||||
std::filesystem::path absPath = std::filesystem::absolute(files::pathFromWindows(lpszLongPath));
|
std::filesystem::path absPath = std::filesystem::absolute(files::pathFromWindows(lpszLongPath));
|
||||||
|
|
4
main.cpp
4
main.cpp
|
@ -102,6 +102,7 @@ struct UNICODE_STRING {
|
||||||
uint16_t *Buffer;
|
uint16_t *Buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Run Time Library (RTL)
|
||||||
struct RTL_USER_PROCESS_PARAMETERS {
|
struct RTL_USER_PROCESS_PARAMETERS {
|
||||||
char Reserved1[16];
|
char Reserved1[16];
|
||||||
void *Reserved2[10];
|
void *Reserved2[10];
|
||||||
|
@ -109,6 +110,7 @@ struct RTL_USER_PROCESS_PARAMETERS {
|
||||||
UNICODE_STRING CommandLine;
|
UNICODE_STRING CommandLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Windows Process Environment Block (PEB)
|
||||||
struct PEB {
|
struct PEB {
|
||||||
char Reserved1[2];
|
char Reserved1[2];
|
||||||
char BeingDebugged;
|
char BeingDebugged;
|
||||||
|
@ -124,7 +126,7 @@ struct PEB {
|
||||||
unsigned int SessionId;
|
unsigned int SessionId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Windows Thread Information Block
|
// Windows Thread Information Block (TIB)
|
||||||
struct TIB {
|
struct TIB {
|
||||||
/* 0x00 */ void *sehFrame;
|
/* 0x00 */ void *sehFrame;
|
||||||
/* 0x04 */ void *stackBase;
|
/* 0x04 */ void *stackBase;
|
||||||
|
|
Loading…
Reference in New Issue