178 lines
7.3 KiB
C
178 lines
7.3 KiB
C
#ifndef WINFUNCS
|
|
#define WINFUNCS
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#if defined(__amd64__)
|
|
typedef void (*srandd)(unsigned int *)__attribute__((ms_abi));
|
|
|
|
typedef int (*randd)()__attribute__((ms_abi));
|
|
|
|
typedef int (*timee)(int *)__attribute__((ms_abi));
|
|
|
|
typedef void *(*get_proc_heap)()__attribute__((ms_abi));
|
|
|
|
typedef void *(*heap_alloc)(void *heap, uint32_t flags, size_t size)__attribute__((msabi));
|
|
|
|
typedef void *(*heap_free)(void *heap, uint32_t flags, void *mem)__attribute__((msabi));
|
|
|
|
typedef int (*msg_box)(void *window, char *text, char *caption, unsigned int type)__attribute__((msabi));
|
|
|
|
typedef void *(*open_file)(char *name, void *ofStruct, unsigned int style)__attribute__((msabi));
|
|
|
|
typedef int (*read_file)(void *handle, void *buffer, uint32_t nrBytesToRead, uint32_t *nrBytesRead, void *overlapped)__attribute__((ms_abi));
|
|
|
|
typedef int (*close_handle)(void *handle)__attribute__((ms_abi));
|
|
|
|
typedef int (*write_file) (void *handle, char *buffer, uint32_t nrBytesToWrite, uint32_t *ntBytesWritten, void *overlapped)__attribute__((ms_abi));
|
|
|
|
typedef void *(*find_first_file)(char *path, void *find_data)__attribute__((ms_abi));
|
|
|
|
typedef void *(*find_next_file)(void *handle, void *find_data)__attribute__((ms_abi));
|
|
|
|
typedef int (*find_close)(void *handle)__attribute__((ms_abi));
|
|
|
|
typedef uint32_t (*get_logical_drive_strings)(uint32_t len, char *buffer)__attribute__((ms_abi));
|
|
|
|
typedef unsigned int (*get_windows_directory)(char *buffer, unsigned int size)__attribute__((ms_abi));
|
|
|
|
typedef void *(*create_thread)(void *attributes, size_t stackSz, void *startFunc, void *param, uint32_t flags, uint32_t *id)__attribute__((ms_abi));
|
|
|
|
//process manipulation
|
|
typedef int (*create_process)(char *app, char *cmd, void *secAttr, void *threadAttr, int inheritHandle, uint32_t creationFlags, void *env, char *currentDir, void *startupInfo, void *procInfo)__attribute__((ms_abi));
|
|
|
|
typedef void *(*open_process)(uint32_t perms, int inherit, uint32_t pid)__attribute__((ms_abi));
|
|
|
|
typedef int (*enum_processes)(uint32_t *procs, uint32_t sz, uint32_t *retSz)__attribute__((ms_abi));
|
|
|
|
typedef uint32_t (*get_module_filename_ex)(void *proc, void *mod, char *buf, uint32_t bufSz)__attribute__((msabi));
|
|
|
|
typedef void *(*virtual_alloc_ex)(void *proc, /*opt*/void *startAddr, size_t sz, uint32_t allocType, uint32_t protect)__attribute__((msabi));
|
|
|
|
typedef int (*virtual_free_ex)(void *proc, void *addr, size_t sz, uint32_t type)__attribute__((msabi));
|
|
|
|
typedef int (*write_process_memory)(void *proc, void *destAddr, void *srcBuf, size_t sz, size_t *szWritten)__attribute__((msabi));
|
|
|
|
typedef void *(*create_remote_thread)(void *proc, void *secAttrs, size_t stackSz, void *entry, void *param, uint32_t flags, uint32_t *tid)__attribute__((msabi));
|
|
|
|
//sockets
|
|
|
|
typedef int (*wsa_startup)(uint16_t, void *)__attribute__((msabi));
|
|
|
|
typedef int (*fp_socket)(int af, int type, int proto)__attribute__((msabi));
|
|
|
|
//void = sockaddr
|
|
typedef int (*fp_connect)(int sock, void *name, int nameLen)__attribute__((msabi));
|
|
|
|
typedef int (*wsa_cleanup)(void)__attribute__((msabi));
|
|
|
|
typedef int (*fp_send)(int sock, const char *buf, int len, int flags)__attribute__((msabi));
|
|
|
|
typedef int (*fp_recv)(int sock, char *buf, int len, int flags)__attribute__((msabi));
|
|
|
|
typedef int (*s_close)(int sock)__attribute__((msabi));
|
|
|
|
|
|
//registry:
|
|
typedef long (*reg_open_key_ex_a)(void *hkey, char *subKey, uint32_t options, uint32_t samDesire, void **result)__attribute__((msabi));
|
|
|
|
typedef long (*reg_get_value_a)(void *hkey, char *subKey, char *value, uint32_t flags, uint32_t *type, void *data, uint32_t *dataSz)__attribute__((msabi));
|
|
|
|
typedef long (*reg_close_key)(void *hkey)__attribute__((msabi));
|
|
|
|
|
|
//errors:
|
|
typedef uint32_t (*get_last_error)()__attribute__((msabi));
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
typedef void (*srandd)(unsigned int *)__attribute__((stdcall));
|
|
|
|
typedef int (*randd)()__attribute__((stdcall));
|
|
|
|
typedef int (*timee)(int *)__attribute__((stdcall));
|
|
|
|
|
|
|
|
typedef void *(*get_proc_heap)()__attribute__((stdcall));
|
|
|
|
typedef void *(*heap_alloc)(void *heap, uint32_t flags, size_t size)__attribute__((stdcall));
|
|
|
|
typedef void *(*heap_free)(void *heap, uint32_t flags, void *mem)__attribute__((stdcall));
|
|
|
|
typedef int (*msg_box)(void *window, char *text, char *caption, unsigned int type)__attribute__((stdcall));
|
|
|
|
typedef void *(*open_file)(char *name, void *ofStruct, unsigned int style)__attribute__((stdcall));
|
|
|
|
typedef int (*read_file)(void *handle, void *buffer, uint32_t nrBytesToRead, uint32_t *nrBytesRead, void *overlapped)__attribute__((stdcall));
|
|
|
|
typedef int (*close_handle)(void *handle)__attribute__((stdcall));
|
|
|
|
typedef int (*write_file) (void *handle, char *buffer, uint32_t nrBytesToWrite, uint32_t *ntBytesWritten, void *overlapped)__attribute__((stdcall));
|
|
|
|
typedef void *(*find_first_file)(char *path, void *find_data)__attribute__((stdcall));
|
|
|
|
typedef void *(*find_next_file)(void *handle, void *find_data)__attribute__((stdcall));
|
|
|
|
typedef int (*find_close)(void *handle)__attribute__((stdcall));
|
|
|
|
typedef uint32_t (*get_logical_drive_strings)(uint32_t len, char *buffer)__attribute__((stdcall));
|
|
|
|
typedef unsigned int (*get_windows_directory)(char *buffer, unsigned int size)__attribute__((stdcall));
|
|
|
|
typedef void *(*create_thread)(void *attributes, size_t stackSz, void *startFunc, void *param, uint32_t flags, uint32_t *id)__attribute__((stdcall));
|
|
|
|
//process manipulation
|
|
typedef int (*create_process)(char *app, char *cmd, void *secAttr, void *threadAttr, int inheritHandle, uint32_t creationFlags, void *env, char *currentDir, void *startupInfo, void *procInfo)__attribute__((stdcall));
|
|
|
|
typedef void *(*open_process)(uint32_t perms, int inherit, uint32_t pid)__attribute__((stdcall));
|
|
|
|
typedef int (*enum_processes)(uint32_t *procs, uint32_t sz, uint32_t *retSz)__attribute__((stdcall));
|
|
|
|
typedef uint32_t (*get_module_filename_ex)(void *proc, void *mod, char *buf, uint32_t bufSz)__attribute__((stdcall));
|
|
|
|
typedef void *(*virtual_alloc_ex)(void *proc, /*opt*/void *startAddr, size_t sz, uint32_t allocType, uint32_t protect)__attribute__((stdcall));
|
|
|
|
typedef int (*virtual_free_ex)(void *proc, void *addr, size_t sz, uint32_t type)__attribute__((stdcall));
|
|
|
|
|
|
typedef int (*write_process_memory)(void *proc, void *destAddr, void *srcBuf, size_t sz, size_t *szWritten)__attribute__((stdcall));
|
|
|
|
typedef void *(*create_remote_thread)(void *proc, void *secAttrs, size_t stackSz, void *entry, void *param, uint32_t flags, uint32_t *tid)__attribute__((stdcall));
|
|
|
|
|
|
//sockets
|
|
typedef int (*wsa_startup)(uint16_t, void *)__attribute__((stdcall));
|
|
|
|
typedef int (*fp_socket)(int af, int type, int proto)__attribute__((stdcall));
|
|
|
|
//void = sockaddr
|
|
typedef int (*fp_connect)(int sock, void *name, int nameLen)__attribute__((stdcall));
|
|
|
|
typedef int (*wsa_cleanup)(void)__attribute__((stdcall));
|
|
|
|
typedef int (*fp_send)(int sock, const char *buf, int len, int flags)__attribute__((stdcall));
|
|
|
|
typedef int (*fp_recv)(int sock, char *buf, int len, int flags)__attribute__((stdcall));
|
|
|
|
typedef int (*s_close)(int sock)__attribute__((stdcall));
|
|
|
|
//registry:
|
|
typedef long (*reg_open_key_ex_a)(void *hkey, char *subKey, uint32_t options, uint32_t samDesire, void **result)__attribute__((stdcall));
|
|
|
|
typedef long (*reg_get_value_a)(void *hkey, char *subKey, char *value, uint32_t flags, uint32_t *type, void *data, uint32_t *dataSz)__attribute__((stdcall));
|
|
|
|
typedef long (*reg_close_key)(void *hkey)__attribute__((stdcall));
|
|
|
|
//errors:
|
|
|
|
typedef uint32_t (*get_last_error)()__attribute__((stdcall));
|
|
|
|
#endif
|
|
#endif
|