From: notaz Date: Tue, 7 Jan 2014 23:52:03 +0000 (+0200) Subject: deal with all non-reg-arg funcs X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46411e6ce8749031ba7b19b9fd20c2a8c6968b22;p=ia32rtools.git deal with all non-reg-arg funcs --- diff --git a/stdc.hlist b/stdc.hlist index 07de794..68e111b 100644 --- a/stdc.hlist +++ b/stdc.hlist @@ -5,7 +5,7 @@ void* __cdecl malloc (size_t); void* __cdecl realloc (void*, size_t); void __cdecl free (void*); void __cdecl abort (void); -void __cdecl exit (int); +DECLSPEC_NORETURN void __cdecl exit (int); int __cdecl atexit (void (__cdecl *)(void)); int __cdecl system (const char*); char* __cdecl getenv (const char*); @@ -185,5 +185,8 @@ int __cdecl _mbsnicmp (const unsigned char*, const unsigned char*, size_t); int __cdecl _mbsnbcmp (const unsigned char*, const unsigned char*, size_t); int __cdecl _mbsnbicmp (const unsigned char*, const unsigned char*, size_t); +void * __cdecl signal (int, void *); +int __cdecl raise (int); + void* __cdecl memcpy_0 (void*, const void*, size_t); diff --git a/tools/protoparse.h b/tools/protoparse.h index 113f3b9..b49c216 100644 --- a/tools/protoparse.h +++ b/tools/protoparse.h @@ -149,6 +149,7 @@ static const char *known_ptr_types[] = { "PHKEY", "PLONG", "PMEMORY_BASIC_INFORMATION", + "PUINT", "PVOID", "PCVOID", "DLGPROC", diff --git a/tools/translate.c b/tools/translate.c index 3bf8d75..4a0c10e 100644 --- a/tools/translate.c +++ b/tools/translate.c @@ -1403,6 +1403,8 @@ static void stack_frame_access(struct parsed_op *po, ferr(po, "bp_arg arg%d/w offset %d and type '%s' is too small\n", i + 1, offset, g_func_pp->arg[i].type.name); } + if (popr->is_ptr && popr->lmod != OPLM_DWORD) + ferr(po, "bp_arg arg%d: non-dword ptr access\n", i + 1); } else { @@ -2202,7 +2204,7 @@ static int scan_for_reg_clear(int i, int reg) static int scan_for_esp_adjust(int i, int opcnt, int *adj) { struct parsed_op *po; - int i_first = i; + int first_pop = -1; *adj = 0; for (; i < opcnt; i++) { @@ -2219,10 +2221,16 @@ static int scan_for_esp_adjust(int i, int opcnt, int *adj) ferr(&ops[i], "unaligned esp adjust: %x\n", *adj); return i; } - else if (po->op == OP_PUSH) + else if (po->op == OP_PUSH) { + if (first_pop == -1) + first_pop = -2; // none *adj -= lmod_bytes(po, po->operand[0].lmod); - else if (po->op == OP_POP) + } + else if (po->op == OP_POP) { + if (first_pop == -1) + first_pop = i; *adj += lmod_bytes(po, po->operand[0].lmod); + } else if (po->flags & (OPF_JMP|OPF_TAIL)) { if (po->op != OP_CALL) break; @@ -2232,12 +2240,12 @@ static int scan_for_esp_adjust(int i, int opcnt, int *adj) } } - if (*adj == 4 && ops[i_first].op == OP_POP - && ops[i_first].operand[0].type == OPT_REG - && ops[i_first].operand[0].reg == xCX) + if (*adj == 4 && first_pop >= 0 && ops[first_pop].op == OP_POP + && ops[first_pop].operand[0].type == OPT_REG + && ops[first_pop].operand[0].reg == xCX) { // probably 'pop ecx' was used.. - return i_first; + return first_pop; } return -1; @@ -2308,9 +2316,9 @@ static const struct parsed_proto *try_recover_pp( pp = g_func_pp->arg[arg].fptr; if (pp == NULL) - ferr(po, "icall: arg%d is not a fptr?\n", arg + 1); + ferr(po, "icall sa: arg%d is not a fptr?\n", arg + 1); if (pp->argc_reg != 0) - ferr(po, "icall: reg arg in arg-call unhandled yet\n"); + ferr(po, "icall sa: reg arg in arg-call unhandled yet\n"); } else if (opr->type == OPT_OFFSET || opr->type == OPT_LABEL) { pp = proto_parse(g_fhdr, opr->name); @@ -2339,12 +2347,8 @@ static void scan_for_call_type(int i, struct parsed_opr *opr, lr = &g_label_refs[i]; for (; lr != NULL; lr = lr->next) scan_for_call_type(lr->i, opr, magic, pp_found); - if (i > 0) { - if (LAST_OP(i - 1)) - return; - scan_for_call_type(i - 1, opr, magic, pp_found); - } - return; + if (i > 0 && LAST_OP(i - 1)) + return; } i--; @@ -2380,7 +2384,8 @@ static void scan_for_call_type(int i, struct parsed_opr *opr, return; pp = g_func_pp->arg[i].fptr; if (pp == NULL) - ferr(po, "icall: arg%d is not a fptr?\n", i + 1); + ferr(po, "icall: arg%d (%s) is not a fptr?\n", + i + 1, g_func_pp->arg[i].reg); if (pp->argc_reg != 0) ferr(po, "icall: reg arg in arg-call unhandled yet\n"); } @@ -2776,6 +2781,8 @@ static void gen_func(FILE *fout, FILE *fhdr, const char *funcn, int opcnt) if (po->op == OP_CALL) { if (po->operand[0].type == OPT_LABEL) { tmpname = opr_name(po, 0); + if (IS_START(tmpname, "loc_")) + ferr(po, "call to loc_*\n"); pp_c = proto_parse(fhdr, tmpname); if (pp_c == NULL) ferr(po, "proto_parse failed for call '%s'\n", tmpname); diff --git a/win32.hlist b/win32.hlist index 6569fed..e95aaa4 100644 --- a/win32.hlist +++ b/win32.hlist @@ -444,6 +444,54 @@ WINUSERAPI UINT WINAPI RealGetWindowClassA(HWND,LPSTR,UINT); WINUSERAPI UINT WINAPI RealGetWindowClassW(HWND,LPWSTR,UINT); WINUSERAPI UINT WINAPI SetTimer(HWND,UINT,UINT,TIMERPROC); WINUSERAPI WORD WINAPI GetWindowWord(HWND,int); +DWORD WINAPI GetFileVersionInfoSizeA(LPCSTR,PDWORD); +DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR,PDWORD); +BOOL WINAPI GetFileVersionInfoA(LPCSTR,DWORD,DWORD,PVOID); +BOOL WINAPI GetFileVersionInfoW(LPCWSTR,DWORD,DWORD,PVOID); +DWORD WINAPI VerLanguageNameA(DWORD,LPSTR,DWORD); +DWORD WINAPI VerLanguageNameW(DWORD,LPWSTR,DWORD); +BOOL WINAPI VerQueryValueA(const LPVOID,LPSTR,LPVOID*,PUINT); +BOOL WINAPI VerQueryValueW(const LPVOID,LPWSTR,LPVOID*,PUINT); + +LPWSTR * WINAPI CommandLineToArgvW(LPCWSTR,int*); +void WINAPI DragAcceptFiles(HWND,BOOL); +void WINAPI DragFinish(HDROP); +UINT WINAPI DragQueryFileA(HDROP,UINT,LPSTR,UINT); +UINT WINAPI DragQueryFileW(HDROP,UINT,LPWSTR,UINT); +BOOL WINAPI DragQueryPoint(HDROP,LPPOINT); +HICON WINAPI DuplicateIcon(HINSTANCE,HICON); +HICON WINAPI ExtractAssociatedIconA(HINSTANCE,LPCSTR,PWORD); +HICON WINAPI ExtractAssociatedIconW(HINSTANCE,LPCWSTR,PWORD); +HICON WINAPI ExtractIconA(HINSTANCE,LPCSTR,UINT); +HICON WINAPI ExtractIconW(HINSTANCE,LPCWSTR,UINT); +UINT WINAPI ExtractIconExA(LPCSTR,int,HICON*,HICON*,UINT); +UINT WINAPI ExtractIconExW(LPCWSTR,int,HICON*,HICON*,UINT); +HINSTANCE WINAPI FindExecutableA(LPCSTR,LPCSTR,LPSTR); +HINSTANCE WINAPI FindExecutableW(LPCWSTR,LPCWSTR,LPWSTR); +UINT WINAPI SHAppBarMessage(DWORD,PAPPBARDATA); +BOOL WINAPI Shell_NotifyIconA(DWORD,PNOTIFYICONDATAA); +BOOL WINAPI Shell_NotifyIconW(DWORD,PNOTIFYICONDATAW); +int WINAPI ShellAboutA(HWND,LPCSTR,LPCSTR,HICON); +int WINAPI ShellAboutW(HWND,LPCWSTR,LPCWSTR,HICON); +HINSTANCE WINAPI ShellExecuteA(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,INT); +HINSTANCE WINAPI ShellExecuteW(HWND,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,INT); +BOOL WINAPI ShellExecuteExA(LPSHELLEXECUTEINFOA); +BOOL WINAPI ShellExecuteExW(LPSHELLEXECUTEINFOW); +int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA); +int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW); +void WINAPI SHFreeNameMappings(HANDLE); +DWORD WINAPI SHGetFileInfoA(LPCSTR,DWORD,SHFILEINFOA*,UINT,UINT); +DWORD WINAPI SHGetFileInfoW(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT); +HRESULT WINAPI SHQueryRecycleBinA(LPCSTR, LPSHQUERYRBINFO); +HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR, LPSHQUERYRBINFO); +HRESULT WINAPI SHEmptyRecycleBinA(HWND,LPCSTR,DWORD); +HRESULT WINAPI SHEmptyRecycleBinW(HWND,LPCWSTR,DWORD); + +HRESULT WINAPI SHGetSpecialFolderLocation(HWND,int,LPITEMIDLIST*); +HRESULT WINAPI SHGetFolderPathA(HWND,int,HANDLE,DWORD,LPSTR); +HRESULT WINAPI SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR); +BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST,LPSTR); +BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST,LPWSTR); WINBASEAPI LPSTR WINAPI lstrcatA(LPSTR,LPCSTR); WINBASEAPI LPWSTR WINAPI lstrcatW(LPWSTR,LPCWSTR); @@ -463,3 +511,6 @@ LONG WINAPI ImmGetCompositionStringA(HIMC,DWORD,PVOID,DWORD); HIMC WINAPI ImmGetContext(HWND); BOOL WINAPI ImmSetCompositionStringA(HIMC,DWORD,PCVOID,DWORD,PCVOID,DWORD); BOOL WINAPI ImmReleaseContext(HWND,HIMC); + +unsigned long __cdecl _beginthreadex (void *, unsigned int, unsigned int (__stdcall *) (void *), void*, unsigned int, unsigned int*); +void __cdecl _endthreadex (unsigned int);