Changeset 1505
- Timestamp:
- 01/13/08 16:40:07 (8 months ago)
- Files:
-
- libemu/trunk/include/emu/Makefile.am (modified) (1 diff)
- libemu/trunk/include/emu/emu_stack.h (added)
- libemu/trunk/include/emu/environment/Makefile.am (modified) (1 diff)
- libemu/trunk/include/emu/environment/emu_profile.h (added)
- libemu/trunk/include/emu/environment/win32/emu_env_w32.h (modified) (2 diffs)
- libemu/trunk/src/Makefile.am (modified) (2 diffs)
- libemu/trunk/src/emu_stack.c (added)
- libemu/trunk/src/environment/emu_profile.c (added)
- libemu/trunk/src/environment/win32/emu_env_w32.c (modified) (2 diffs)
- libemu/trunk/src/environment/win32/env_w32_dll_export_kernel32_hooks.c (modified) (16 diffs)
- libemu/trunk/src/environment/win32/env_w32_dll_export_urlmon_hooks.c (modified) (2 diffs)
- libemu/trunk/src/environment/win32/env_w32_dll_export_ws2_32_hooks.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libemu/trunk/include/emu/Makefile.am
r1315 r1505 25 25 include_HEADERS += emu_shellcode.h 26 26 include_HEADERS += emu_source.h 27 include_HEADERS += emu_stack.h 27 28 include_HEADERS += emu_string.h 28 29 include_HEADERS += emu_track.h libemu/trunk/include/emu/environment/Makefile.am
r1436 r1505 4 4 5 5 SUBDIRS = win32 linux 6 include_HEADERS = emu_profile.h 6 7 libemu/trunk/include/emu/environment/win32/emu_env_w32.h
r1442 r1505 31 31 struct emu_env_w32_dll; 32 32 struct emu_env_w32_dll_export; 33 struct emu_profile; 33 34 34 35 /** … … 51 52 */ 52 53 uint32_t baseaddr; 54 55 struct emu_profile *profile; 53 56 }; 54 57 libemu/trunk/src/Makefile.am
r1436 r1505 24 24 libemu_la_SOURCES += emu_list.c 25 25 libemu_la_SOURCES += emu_queue.c 26 libemu_la_SOURCES += emu_stack.c 26 27 libemu_la_SOURCES += emu_shellcode.c 27 28 libemu_la_SOURCES += emu_source.c … … 78 79 libemu_la_SOURCES += libdasm.c libdasm.h opcode_tables.h 79 80 81 libemu_la_SOURCES += environment/emu_profile.c 80 82 libemu_la_SOURCES += environment/win32/emu_env_w32.c 81 83 libemu_la_SOURCES += environment/win32/emu_env_w32_dll.c libemu/trunk/src/environment/win32/emu_env_w32.c
r1442 r1505 34 34 #include "emu/emu_memory.h" 35 35 #include "emu/emu_hashtable.h" 36 #include "emu/environment/emu_profile.h" 36 37 #include "emu/environment/win32/emu_env_w32.h" 37 38 #include "emu/environment/win32/emu_env_w32_dll.h" … … 151 152 struct emu_env_w32 *env = (struct emu_env_w32 *)malloc(sizeof(struct emu_env_w32)); 152 153 memset(env,0,sizeof(struct emu_env_w32)); 154 env->profile = emu_profile_new(); 153 155 env->emu = e; 154 156 // write TEB and linklist libemu/trunk/src/environment/win32/env_w32_dll_export_kernel32_hooks.c
r1367 r1505 49 49 #include "emu/emu_hashtable.h" 50 50 #include "emu/emu_string.h" 51 #include "emu/environment/emu_profile.h" 51 52 #include "emu/environment/win32/emu_env_w32.h" 52 53 #include "emu/environment/win32/emu_env_w32_dll.h" … … 66 67 POP_DWORD(c, &eip_save); 67 68 69 70 68 71 /* 69 72 BOOL CloseHandle( … … 71 74 ); 72 75 */ 76 emu_profile_function_add(env->profile, "CloseHandle"); 73 77 74 78 uint32_t object; 75 79 POP_DWORD(c, &object); 80 emu_profile_argument_add_int(env->profile, "Handle", "hObject", object); 76 81 77 82 emu_cpu_eip_set(c, eip_save); … … 102 107 ); 103 108 */ 109 emu_profile_function_add(env->profile, "CreateFile"); 104 110 105 111 uint32_t filename; 106 112 POP_DWORD(c, &filename); 113 emu_profile_argument_add_ref(env->profile, "LPCTSTR", "lpFileName", filename); 114 emu_profile_argument_add_string(env->profile, "", "", ""); 115 107 116 108 117 uint32_t desiredaccess; 109 118 POP_DWORD(c, &desiredaccess); 119 emu_profile_argument_add_int(env->profile, "DWORD", "dwDesiredAccess", desiredaccess); 110 120 111 121 uint32_t sharemode; 112 122 POP_DWORD(c, &sharemode); 123 emu_profile_argument_add_int(env->profile, "DWORD", "dwShareMode", sharemode); 113 124 114 125 uint32_t securityattr; 115 126 POP_DWORD(c, &securityattr); 116 117 uint32_t createdisp; 127 emu_profile_argument_add_ref(env->profile, "LPSECURITY_ATTRIBUTES", "lpSecurityAttributes", securityattr); 128 emu_profile_argument_add_int(env->profile, "", "", 0); 129 130 uint32_t createdisp; 118 131 POP_DWORD(c, &createdisp); 132 emu_profile_argument_add_int(env->profile, "DWORD", "dwCreationDisposition", createdisp); 119 133 120 134 uint32_t flagsandattr; 121 135 POP_DWORD(c, &flagsandattr); 136 emu_profile_argument_add_int(env->profile, "DWORD", "dwFlagsAndAttributes", flagsandattr); 122 137 123 138 uint32_t templatefile; 124 139 POP_DWORD(c, &templatefile); 140 emu_profile_argument_add_int(env->profile, "Handle", "hTemplateFile", templatefile); 125 141 126 142 emu_cpu_eip_set(c, eip_save); … … 135 151 136 152 struct emu_cpu *c = emu_cpu_get(env->emu); 153 struct emu_memory *m = emu_memory_get(env->emu); 137 154 138 155 uint32_t eip_save; … … 153 170 );*/ 154 171 155 uint32_t imagename; 156 POP_DWORD(c, &imagename); 157 158 uint32_t cmdline; 159 POP_DWORD(c, &cmdline); 160 161 uint32_t process; 162 POP_DWORD(c, &process); 163 164 uint32_t thread; 165 POP_DWORD(c, &thread); 172 emu_profile_function_add(env->profile, "CreateProcess"); 173 174 uint32_t p_imagename; 175 POP_DWORD(c, &p_imagename); 176 emu_profile_argument_add_ref(env->profile, "LPCWSTR", "pszImageName", p_imagename); 177 emu_profile_argument_add_string(env->profile, "", "", ""); 178 179 uint32_t p_cmdline; 180 POP_DWORD(c, &p_cmdline); 181 emu_profile_argument_add_ref(env->profile, "LPCWSTR", "pszCmdLine", p_cmdline); 182 183 struct emu_string *command = emu_string_new(); 184 emu_memory_read_string(m, p_cmdline, command, 1024); 185 emu_profile_argument_add_string(env->profile, "","", emu_string_char(command)); 186 // emu_string_free(command); 187 188 189 uint32_t p_process; 190 POP_DWORD(c, &p_process); 191 emu_profile_argument_add_ref(env->profile, "LPSECURITY_ATTRIBUTES", "psaProcess", p_process); 192 emu_profile_argument_add_string(env->profile, "", "", ""); 193 194 195 uint32_t p_thread; 196 POP_DWORD(c, &p_thread); 197 emu_profile_argument_add_ref(env->profile, "LPSECURITY_ATTRIBUTES", "psaThread", p_thread); 198 emu_profile_argument_add_string(env->profile, "", "", ""); 199 166 200 167 201 uint32_t inherithandles; 168 202 POP_DWORD(c, &inherithandles); 203 emu_profile_argument_add_int(env->profile, "BOOL", "fInheritHandles", inherithandles); 204 169 205 170 206 uint32_t create; 171 207 POP_DWORD(c, &create); 208 emu_profile_argument_add_int(env->profile, "DWORD", "fdwCreate", create); 172 209 173 210 uint32_t environment; 174 211 POP_DWORD(c, &environment); 212 emu_profile_argument_add_ref(env->profile, "LPVOID", "pvEnvironment", environment); 213 emu_profile_argument_add_string(env->profile, "", "", ""); 214 175 215 176 216 uint32_t cwd; 177 217 POP_DWORD(c, &cwd); 218 emu_profile_argument_add_ref(env->profile, "LPWSTR", "pszCurDir", cwd); 219 emu_profile_argument_add_string(env->profile, "", "", ""); 220 178 221 179 222 uint32_t p_startinfo; 180 223 POP_DWORD(c, &p_startinfo); 224 emu_profile_argument_add_ref(env->profile, "LPSTARTUPINFOW", "psiStartInfo", p_startinfo); 225 226 STARTUPINFO *si = malloc(sizeof(STARTUPINFO)); 227 emu_memory_read_block(m, p_startinfo, si, sizeof(STARTUPINFO)); 228 229 emu_profile_argument_start(env->profile, "", ""); 230 emu_profile_argument_add_int(env->profile, "DWORD", "cb" , si->cb); 231 emu_profile_argument_add_int(env->profile, "LPTSTR", "lpReserved" , (unsigned int)si->lpReserved); 232 emu_profile_argument_add_int(env->profile, "LPTSTR", "lpDesktop" , (unsigned int)si->lpDesktop); 233 emu_profile_argument_add_int(env->profile, "LPTSTR", "lpTitle" , (unsigned int)si->lpTitle); 234 emu_profile_argument_add_int(env->profile, "DWORD", "dwX" , si->dwX); 235 emu_profile_argument_add_int(env->profile, "DWORD", "dwY" , si->dwY); 236 emu_profile_argument_add_int(env->profile, "DWORD", "dwXSize" , si->dwXSize); 237 emu_profile_argument_add_int(env->profile, "DWORD", "dwYSize" , si->dwYSize); 238 emu_profile_argument_add_int(env->profile, "DWORD", "dwXCountChars" , si->dwXCountChars); 239 emu_profile_argument_add_int(env->profile, "DWORD", "dwYCountChars" , si->dwYCountChars); 240 emu_profile_argument_add_int(env->profile, "DWORD", "dwFillAttribute" , si->dwFillAttribute); 241 emu_profile_argument_add_int(env->profile, "DWORD", "dwFlags" , si->dwFlags); 242 emu_profile_argument_add_int(env->profile, "WORD", "wShowWindow" , si->wShowWindow); 243 emu_profile_argument_add_int(env->profile, "WORD", "cbReserved2" , si->cbReserved2); 244 emu_profile_argument_add_int(env->profile, "LPBYTE", "lpReserved2" , (unsigned int)si->lpReserved2); 245 emu_profile_argument_add_int(env->profile, "HANDLE", "hStdInput" , si->hStdInput); 246 emu_profile_argument_add_int(env->profile, "HANDLE", "hStdOutput" , si->hStdOutput); 247 emu_profile_argument_add_int(env->profile, "HANDLE", "hStdError" , si->hStdError); 248 emu_profile_argument_end(env->profile); 249 181 250 182 251 uint32_t p_procinfo; 183 252 POP_DWORD(c, &p_procinfo); 253 emu_profile_argument_add_ref(env->profile, "PROCESS_INFORMATION", "pProcInfo",0x52f74c); 254 255 PROCESS_INFORMATION *pi = malloc(sizeof(PROCESS_INFORMATION)); 256 emu_memory_read_block(m, p_procinfo, pi, sizeof(PROCESS_INFORMATION)); 257 258 emu_profile_argument_start(env->profile, "", ""); 259 emu_profile_argument_add_int(env->profile, "DWORD", "hProcess" ,pi->dwProcessId); 260 emu_profile_argument_add_int(env->profile, "DWORD", "hThread" ,pi->dwThreadId); 261 emu_profile_argument_add_int(env->profile, "HANDLE", "dwProcessId" ,pi->hProcess); 262 emu_profile_argument_add_int(env->profile, "HANDLE", "dwThreadId" ,pi->hThread); 263 emu_profile_argument_end(env->profile); 264 184 265 185 266 … … 187 268 emu_cpu_reg32_set(c, eax, 0); 188 269 189 struct emu_memory *m = emu_memory_get(env->emu); 190 PROCESS_INFORMATION *pi = malloc(sizeof(PROCESS_INFORMATION)); 191 emu_memory_read_block(m, p_procinfo, pi, sizeof(PROCESS_INFORMATION)); 270 192 271 193 272 pi->dwProcessId = 4711; … … 198 277 emu_memory_write_block(m, p_procinfo, pi, sizeof(PROCESS_INFORMATION)); 199 278 200 STARTUPINFO *si = malloc(sizeof(STARTUPINFO));201 emu_memory_read_block(m, p_startinfo, si, sizeof(STARTUPINFO));202 203 printf("CreateProcess(pszImageName=%x, pszCmdLine=%x, psaProcess=%x, psaThread=%x, fInheritHandles=%i, fdwCreate=%i, pvEnvironment=%x, pszCurDir=%x, psiStartInfo=%x, pProcInfo=%x)\n",204 imagename, cmdline, process, thread, inherithandles, create, environment, cwd, p_startinfo, p_procinfo);205 206 printf("PROCESS_INFORMATION\n"207 "{\n"208 "\tHANDLE hProcess=%i;\n"209 "\tHANDLE hThread=%i;\n"210 "\tDWORD dwProcessId=%i;\n"211 "\tDWORD dwThreadId=%i;\n"212 "}\n",213 pi->dwProcessId,214 pi->dwThreadId,215 pi->hProcess,216 pi->hThread);217 218 219 printf("STARTUPINFO {\n"220 "\tDWORD cb=%i;\n"221 "\tLPTSTR lpReserved=0x%08x;\n"222 "\tLPTSTR lpDesktop=0x%08x;\n"223 "\tLPTSTR lpTitle=0x%08x;\n"224 "\tDWORD dwX=%i;\n"225 "\tDWORD dwY=%i;\n"226 "\tDWORD dwXSize=%i;\n"227 "\tDWORD dwYSize=%i;\n"228 "\tDWORD dwXCountChars=%i;\n"229 "\tDWORD dwYCountChars=%i;\n"230 "\tDWORD dwFillAttribute=%i;\n"231 "\tDWORD dwFlags=%i;\n"232 "\tWORD wShowWindow=%i;\n"233 "\tWORD cbReserved2=%i;\n"234 "\tLPBYTE lpReserved2=0x08%x;\n"235 "\tHANDLE hStdInput=%i;\n"236 "\tHANDLE hStdOutput=%i;\n"237 "\tHANDLE hStdError=%i;\n"238 "}\n",239 si->cb,240 (unsigned int)si->lpReserved,241 (unsigned int)si->lpDesktop,242 (unsigned int)si->lpTitle,243 si->dwX,244 si->dwY,245 si->dwXSize,246 si->dwYSize,247 si->dwXCountChars,248 si->dwYCountChars,249 si->dwFillAttribute,250 si->dwFlags,251 si->wShowWindow,252 si->cbReserved2,253 (unsigned int)si->lpReserved2,254 si->hStdInput,255 si->hStdOutput,256 si->hStdError);257 279 258 280 fflush(NULL); 259 281 260 282 #ifdef HAVE_INTERACTIVE_HOOKS 261 // the code is meant to be an example how one could do it 262 pid_t pid; 263 if ((pid = fork()) == 0) 264 { // child 265 266 dup2(si->hStdInput, fileno(stdin)); 267 dup2(si->hStdOutput, fileno(stdout)); 268 dup2(si->hStdError, fileno(stderr)); 269 270 system("/opt/cmd/bin/cmdexe.pl -p winxp -l /opt/cmd/var/log/cmd/"); 271 exit(EXIT_SUCCESS); 272 }else 273 { // parent 274 pi->hProcess = pid; 275 emu_memory_write_block(m, p_procinfo, pi, sizeof(PROCESS_INFORMATION)); 283 if (emu_string_char(command) != NULL && strncasecmp(emu_string_char(command), "cmd", 3) == 0) 284 { 285 286 // the code is meant to be an example how one could do it 287 pid_t pid; 288 if ((pid = fork()) == 0) 289 { // child 290 291 dup2(si->hStdInput, fileno(stdin)); 292 dup2(si->hStdOutput, fileno(stdout)); 293 dup2(si->hStdError, fileno(stderr)); 294 295 system("/opt/cmd/bin/cmdexe.pl -p winxp -l /opt/cmd/var/log/cmd/"); 296 exit(EXIT_SUCCESS); 297 }else 298 { // parent 299 pi->hProcess = pid; 300 emu_memory_write_block(m, p_procinfo, pi, sizeof(PROCESS_INFORMATION)); 301 } 276 302 } 277 303 #endif 278 304 emu_string_free(command); 305 free(pi); 306 free(si); 279 307 emu_cpu_eip_set(c, eip_save); 280 308 return 0; … … 298 326 299 327 */ 328 emu_profile_function_add(env->profile, "DeleteFile"); 300 329 uint32_t filename; 301 330 POP_DWORD(c, &filename); 331 emu_profile_argument_add_ref(env->profile, "LPCTSTR", "lpFileName", filename); 332 emu_profile_argument_add_string(env->profile, "", "", ""); 302 333 303 334 emu_cpu_eip_set(c, eip_save); … … 457 488 int32_t env_w32_hook_GetProcAddress(struct emu_env_w32 *env, struct emu_env_w32_dll_export *ex) 458 489 { 459 printf("Hook me Captain Cook!\n"); 460 printf("%s:%i %s\n",__FILE__,__LINE__,__FUNCTION__); 461 462 struct emu_cpu *c = emu_cpu_get(env->emu); 490 struct emu_cpu *c = emu_cpu_get(env->emu); 491 struct emu_memory *mem = emu_memory_get(env->emu); 463 492 464 493 uint32_t eip_save; … … 471 500 ); 472 501 */ 473 502 emu_profile_function_add(env->profile, "GetProcAddress"); 503 474 504 475 505 uint32_t module;// = emu_cpu_reg32_get(c, esp); 476 506 POP_DWORD(c, &module); 477 478 printf("module ptr is %08x\n", module); 507 emu_profile_argument_add_int(env->profile, "HMODULE", "hModule", module); 508 509 // printf("module ptr is %08x\n", module); 479 510 480 511 uint32_t p_procname; 481 512 POP_DWORD(c, &p_procname); 513 emu_profile_argument_add_ref(env->profile, "LPCSTR", "lpProcName", p_procname); 514 482 515 483 516 struct emu_string *procname = emu_string_new(); 484 struct emu_memory *mem = emu_memory_get(env->emu);485 517 emu_memory_read_string(mem, p_procname, procname, 256); 486 518 emu_profile_argument_add_string(env->profile, "", "", emu_string_char(procname)); 487 519 488 520 printf("procname name is '%s'\n", emu_string_char(procname)); … … 537 569 ); 538 570 */ 571 emu_profile_function_add(env->profile, "GetSystemDirectory"); 572 539 573 uint32_t p_buffer; 540 574 POP_DWORD(c, &p_buffer); 575 emu_profile_argument_add_ref(env->profile, "LPTSTR", "lpBuffer", p_buffer); 576 emu_profile_argument_add_string(env->profile, "", "", ""); 541 577 542 578 uint32_t size; 543 579 POP_DWORD(c, &size); 580 emu_profile_argument_add_int(env->profile, "UINT", "uSize", size); 581 544 582 545 583 emu_memory_write_block(emu_memory_get(env->emu), p_buffer, "c:\\WINDOWS\\system32\x00", 20); … … 658 696 int32_t env_w32_hook_LoadLibrayA(struct emu_env_w32 *env, struct emu_env_w32_dll_export *ex) 659 697 { 660 printf("Hook me Captain Cook!\n"); 661 printf("%s:%i %s\n",__FILE__,__LINE__,__FUNCTION__); 698 699 700 701 struct emu_cpu *c = emu_cpu_get(env->emu); 702 703 uint32_t eip_save; 704 POP_DWORD(c, &eip_save); 662 705 663 706 /* HMODULE WINAPI LoadLibrary(LPCTSTR lpFileName); */ 664 707 665 struct emu_cpu *c = emu_cpu_get(env->emu); 666 667 uint32_t eip_save; 668 POP_DWORD(c, &eip_save); 708 emu_profile_function_add(env->profile, "LoadLibraryA"); 669 709 670 710 uint32_t dllname_ptr;// = emu_cpu_reg32_get(c, esp); 671 672 POP_DWORD(c, &dllname_ptr); 711 POP_DWORD(c, &dllname_ptr); 712 emu_profile_argument_add_ref(env->profile, "LPCTSTR", "lpFileName", dllname_ptr); 713 673 714 674 715 struct emu_string *dllstr = emu_string_new(); … … 676 717 emu_memory_read_string(mem, dllname_ptr, dllstr, 256); 677 718 719 678 720 char *dllname = emu_string_char(dllstr); 721 emu_profile_argument_add_string(env->profile, "", "", dllname); 722 679 723 680 724 int i; … … 827 871 ); 828 872 */ 873 emu_profile_function_add(env->profile, "WaitForSingleObject"); 829 874 830 875 uint32_t handle; 831 876 POP_DWORD(c, &handle); 877 emu_profile_argument_add_int(env->profile, "HANDLE", "hHandle", handle); 832 878 833 879 uint32_t msecs; 834 880 POP_DWORD(c, &msecs); 881 emu_profile_argument_add_int(env->profile, "DWORD", "dwMilliseconds", msecs); 835 882 836 883 printf("WaitForSingleObject(hHandle=%i, dwMilliseconds=%i)\n", handle, msecs); … … 870 917 ); 871 918 */ 872 873 uint32_t cmdline_ptr; 874 POP_DWORD(c, &cmdline_ptr); 919 emu_profile_function_add(env->profile, "WinExec"); 920 921 uint32_t p_cmdline; 922 POP_DWORD(c, &p_cmdline); 923 emu_profile_argument_add_ref(env->profile, "LPCSTR", "lpCmdLine", p_cmdline); 924 925 struct emu_string *cmdstr = emu_string_new(); 926 emu_memory_read_string(emu_memory_get(env->emu), p_cmdline, cmdstr, 256); 927 emu_profile_argument_add_string(env->profile, "", "", emu_string_char(cmdstr)); 928 emu_string_free(cmdstr); 929 875 930 876 931 uint32_t show; 877 932 POP_DWORD(c, &show); 878 879 880 struct emu_string *cmdstr = emu_string_new(); 881 emu_memory_read_string(emu_memory_get(env->emu), cmdline_ptr, cmdstr, 256); 882 printf("WinExec %s\n", emu_string_char(cmdstr)); 883 emu_string_free(cmdstr); 933 emu_profile_argument_add_int(env->profile, "UINT", "uCmdShow", show); 934 935 936 884 937 885 938 emu_cpu_reg32_set(c, eax, 32); libemu/trunk/src/environment/win32/env_w32_dll_export_urlmon_hooks.c
r1367 r1505 41 41 #include "emu/emu_hashtable.h" 42 42 #include "emu/emu_string.h" 43 #include "emu/environment/emu_profile.h" 43 44 #include "emu/environment/win32/emu_env_w32.h" 44 45 #include "emu/environment/win32/emu_env_w32_dll.h" … … 66 67 ); 67 68 */ 69 emu_profile_function_add(env->profile, "URLDownloadToFile"); 70 68 71 uint32_t p_caller; 69 72 POP_DWORD(c, &p_caller); 73 emu_profile_argument_add_ref(env->profile, "LPUNKNOWN", "pCaller", p_caller); 74 emu_profile_argument_add_string(env->profile, "", "", ""); 70 75 71 76 uint32_t p_url; 72 77 POP_DWORD(c, &p_url); 78 emu_profile_argument_add_ref(env->profile, "LPCTSTR", "szURL", p_url); 79 80 struct emu_string *url = emu_string_new(); 81 emu_memory_read_string(c->mem, p_url, url, 512); 82 emu_profile_argument_add_string(env->profile, "", "", emu_string_char(url)); 83 73 84 74 85 uint32_t p_filename; 75 86 POP_DWORD(c, &p_filename); 87 emu_profile_argument_add_ref(env->profile, "LPCTSTR", "szFileName", p_filename); 88 89 struct emu_string *filename = emu_string_new(); 90 emu_memory_read_string(c->mem, p_filename, filename, 512); 91 emu_profile_argument_add_string(env->profile, "", "", emu_string_char(filename)); 76 92 77 93 uint32_t reserved; 78 94 POP_DWORD(c, &reserved); 95 emu_profile_argument_add_int(env->profile, "DWORD", "dwReserved", reserved); 79 96 80 97 uint32_t statuscallbackfn; 81 98 POP_DWORD(c, &statuscallbackfn); 99 emu_profile_argument_add_int(env->profile, "LPBINDSTATUSCALLBACK", "lpfnCB", statuscallbackfn); 82 100 83 101 84 102 85 struct emu_string *url = emu_string_new();86 emu_memory_read_string(c->mem, p_url, url, 512);87 88 struct emu_string *filename = emu_string_new();89 emu_memory_read_string(c->mem, p_filename, filename, 512);90 103 91 104 92 printf(" %s -> %s\n", emu_string_char(url), emu_string_char(filename)); 105 106 // printf(" %s -> %s\n", emu_string_char(url), emu_string_char(filename)); 93 107 94 108 emu_string_free(url); libemu/trunk/src/environment/win32/env_w32_dll_export_ws2_32_hooks.c
r1367 r1505 48 48 #include "emu/emu_hashtable.h" 49 49 #include "emu/emu_string.h" 50 #include "emu/environment/emu_profile.h" 50 51 #include "emu/environment/win32/emu_env_w32.h" 51 52 #include "emu/environment/win32/emu_env_w32_dll.h" … … 55 56 int32_t env_w32_hook_accept(struct emu_env_w32 *env, struct emu_env_w32_dll_export *ex) 56 57 { 57 printf("Hook me Captain Cook!\n");58 printf("%s:%i %s\n",__FILE__,__LINE__,__FUNCTION__);59 60 58 struct emu_cpu *c = emu_cpu_get(env->emu); 61 59 … … 70 68 );*/ 71 69 72 uint32_t s; 73 POP_DWORD(c, &s); 70 emu_profile_function_add(env->profile, "accept"); 71 72 uint32_t s; 73 POP_DWORD(c, &s); 74 emu_profile_argument_add_int(env->profile, "SOCKET", "s", s); 74 75 75 76 uint32_t addr; 76 77 POP_DWORD(c, &addr); 78 emu_profile_argument_add_ref(env->profile, "sockaddr *", "addr", addr); 79 emu_profile_argument_start(env->profile, "", ""); 80 emu_profile_argument_end(env->profile); 77 81 78 82 uint32_t addrlen; 79 83 POP_DWORD(c, &addrlen); 84 emu_profile_argument_add_ref(env->profile, "int", "addrlen", addrlen); 85 emu_profile_argument_add_int(env->profile, "", "", 0); 80 86 81 87 printf("accept(s=%i, addr=%x, addrlen=%i);\n", s, addr, addrlen); … … 98 104 int32_t env_w32_hook_bind(struct emu_env_w32 *env, struct emu_env_w32_dll_export *ex) 99 105 { 100 printf("Hook me Captain Cook!\n");101 printf("%s:%i %s\n",__FILE__,__LINE__,__FUNCTION__);102 103 106 struct emu_cpu *c = emu_cpu_get(env->emu); 104 107 … … 112 115 const struct sockaddr* name, 113 116 int namelen 114 ); */ 115 116 uint32_t s; 117 POP_DWORD(c, &s); 117 ); 118 */ 119 120 emu_profile_function_add(env->profile, "bind"); 121 uint32_t s; 122 POP_DWORD(c, &s); 123 118 124 119 125 uint32_t name; 120 126 POP_DWORD(c, &name); 121 127 122 uint32_t namelen; 123 POP_DWORD(c, &namelen); 124 125 printf("bind(s=%i, name=%x, namelen=%i\n", s, name, namelen); 126 128 129 130 /* 131 struct sockaddr_in { 132 short sin_family; // e.g. AF_INET 133 unsigned short sin_port; // e.g. htons(3490) 134 struct in_addr sin_addr; // see struct in_addr, below 135 char sin_zero[8]; // zero this if you want to 136 }; 137 138 struct in_addr { 139 unsigned long s_addr; // load with inet_aton() 140 }; 141 */ 127 142 struct sockaddr sa; 143 128 144 emu_memory_read_block(emu_memory_get(env->emu), name, &sa, sizeof(struct sockaddr)); 129 145 if (sa.sa_family == AF_INET) 130 146 { 131 printf("host %s port %i\n", 132 inet_ntoa(*(struct in_addr *)&((struct sockaddr_in *)&sa)->sin_addr), 133 ntohs(((struct sockaddr_in *)&sa)->sin_port)); 147 struct sockaddr_in *si = (struct sockaddr_in *)&sa; 148 emu_profile_argument_add_ref(env->profile, "sockaddr_in *", "name", name); 149 emu_profile_argument_start(env->profile, "", ""); 150 emu_profile_argument_add_int(env->profile, "short", "sin_family", si->sin_family); 151 emu_profile_argument_add_port(env->profile, "unsigned short", "sin_port", si->sin_port); 152 emu_profile_argument_start(env->profile, "in_addr", "sin_addr"); 153 emu_profile_argument_add_ip(env->profile, "unsigned long", "s_addr", si->sin_addr.s_addr); 154 emu_profile_argument_end(env->profile); 155 emu_profile_argument_add_string(env->profile, "char", "sin_zero", " "); 156 emu_profile_argument_end(env->profile); 157 158 }else 159 { 160 emu_profile_argument_start(env->profile, "sockaddr *", "name"); 161 emu_profile_argument_end(env->profile); 134 162 } 163 164 165 166 uint32_t namelen; 167 POP_DWORD(c, &namelen); 168 169 printf("bind(s=%i, name=%x, namelen=%i\n", s, name, namelen); 170 135 171 136 172 int retval = 0; … … 162 198 ); 163 199 */ 164 uint32_t s; 165 POP_DWORD(c, &s); 200 emu_profile_function_add(env->profile, "closesocket"); 201 uint32_t s; 202 POP_DWORD(c, &s); 203 emu_profile_argument_add_int(env->profile, "SOCKET", "s", s); 166 204 167 205 #ifdef HAVE_INTERACTIVE_HOOKS … … 194 232 ) 195 233 */ 196 uint32_t s; 197 POP_DWORD(c, &s); 234 emu_profile_function_add(env->profile, "connect"); 235 uint32_t s; 236 POP_DWORD(c, &s); 237 emu_profile_argument_add_int(env->profile, "SOCKET", "s", s); 198 238 199 239 uint32_t name; 200 240 POP_DWORD(c, &name); 241 struct sockaddr sa; 242 243 emu_memory_read_block(emu_memory_get(env->emu), name, &sa, sizeof(struct sockaddr)); 244 if (sa.sa_family == AF_INET) 245 { 246 struct sockaddr_in *si = (struct sockaddr_in *)&sa; 247 emu_profile_argument_add_ref(env->profile, "sockaddr_in *", "name", name); 248 emu_profile_argument_start(env->profile, "", ""); 249 emu_profile_argument_add_int(env->profile, "short", "sin_family", si->sin_family); 250 emu_profile_argument_add_port(env->profile, "unsigned short", "sin_port", si->sin_port); 251 emu_profile_argument_start(env->profile, "in_addr", "sin_addr"); 252 emu_profile_argument_add_ip(env->profile, "unsigned long", "s_addr", si->sin_addr.s_addr); 253 emu_profile_argument_end(env->profile); 254 emu_profile_argument_add_string(env->profile, "char", "sin_zero", " "); 255 emu_profile_argument_end(env->profile); 256 257 }else 258 { 259 emu_profile_argument_start(env->profile, "sockaddr *", "name"); 260 emu_profile_argument_end(env->profile); 261 } 201 262 202 263 uint32_t namelen; 203 264 POP_DWORD(c, &namelen); 204 205 struct sockaddr sa; 206 emu_memory_read_block(emu_memory_get(env->emu), name, &sa, sizeof(struct sockaddr)); 207 printf("host %s port %i\n", 208 inet_ntoa(*(struct in_addr *)&((struct sockaddr_in *)&sa)->sin_addr), 209 ntohs(((struct sockaddr_in *)&sa)->sin_port)); 210 265 emu_profile_argument_add_int(env->profile, "int", "namelen", namelen); 211 266 212 267 int retval = 0; … … 242 297 ); 243 298 */ 244 245 uint32_t s; 246 POP_DWORD(c, &s); 299 emu_profile_function_add(env->profile, "listen"); 300 301 302 uint32_t s; 303 POP_DWORD(c, &s); 304 emu_profile_argument_add_int(env->profile, "SOCKET", "s", s); 247 305 248 306 uint32_t backlog; 249 307 POP_DWORD(c, &backlog); 308 emu_profile_argument_add_int(env->profile, "int", "backlog", backlog); 250 309 251 310 printf("listen(s=%i, backlog=%i)\n", s, backlog); … … 477 536 ); */ 478 537 538 emu_profile_function_add(env->profile, "WSASocket"); 539 479 540 uint32_t af; 480 541 POP_DWORD(c, &af); 542 emu_profile_argument_add_int(env->profile, "int", "af", af); 543 544 481 545 482 546 uint32_t type; 483 547 POP_DWORD(c, &type); 548 emu_profile_argument_add_int(env->profile, "int", "type", type); 484 549 485 550 uint32_t protocol; 486 551 POP_DWORD(c, &protocol); 552 emu_profile_argument_add_int(env->profile, "int", "protocol", protocol); 487 553 488 554 uint32_t protocolinfo; 489 555 POP_DWORD(c, &protocolinfo); 556 emu_profile_argument_add_int(env->profile, "LPWSAPROTOCOL_INFO", "lpProtocolInfo", protocolinfo); 557 490 558 491 559 uint32_t group; 492 560 POP_DWORD(c, &group); 561 emu_profile_argument_add_int(env->profile, "GROUP", "g", group); 562 493 563 494 564 uint32_t flags; 495 565 POP_DWORD(c, &flags); 566 emu_profile_argument_add_int(env->profile, "DWORD", "dwFlags", flags); 567 496 568 497 569 printf("SOCKET WSASocket(af=%i, type=%i, protocol=%i, lpProtocolInfo=%x, group=%i, dwFlags=%i);\n", … … 529 601 ); 530 602 */ 531 603 emu_profile_function_add(env->profile, "WSAStartup"); 604 532 605 uint32_t wsaversionreq; 533 606 POP_DWORD(c, &wsaversionreq); 534 607 printf("WSAStartup version %x\n", wsaversionreq); 608 emu_profile_argument_add_int(env->profile, "WORD", "wVersionRequested", wsaversionreq); 535 609 536 610 uint32_t wsadata; 537 611 POP_DWORD(c, &wsadata); 612 emu_profile_argument_add_int(env->profile, "LPWSADATA", "lpWSAData", wsadata); 538 613 539 614
