📄 process.c
字号:
}
childPrintf(hFile, "InputCP=%d\nOutputCP=%d\n",
GetConsoleCP(), GetConsoleOutputCP());
if (GetConsoleMode(hConIn, &modeIn))
childPrintf(hFile, "InputMode=%ld\n", modeIn);
if (GetConsoleMode(hConOut, &modeOut))
childPrintf(hFile, "OutputMode=%ld\n", modeOut);
/* now that we have written all relevant information, let's change it */
ok(SetConsoleCP(1252), "Setting CP\n");
ok(SetConsoleOutputCP(1252), "Setting SB CP\n");
ret = SetConsoleMode(hConIn, modeIn ^ 1);
ok( ret, "Setting mode (%ld)\n", GetLastError());
ret = SetConsoleMode(hConOut, modeOut ^ 1);
ok( ret, "Setting mode (%ld)\n", GetLastError());
sbi.dwCursorPosition.X ^= 1;
sbi.dwCursorPosition.Y ^= 1;
ret = SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition);
ok( ret, "Setting cursor position (%ld)\n", GetLastError());
}
if (option && strcmp(option, "stdhandle") == 0)
{
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdIn != INVALID_HANDLE_VALUE || hStdOut != INVALID_HANDLE_VALUE)
{
char buf[1024];
DWORD r, w;
ok(ReadFile(hStdIn, buf, sizeof(buf), &r, NULL) && r > 0, "Reading message from input pipe\n");
childPrintf(hFile, "[StdHandle]\nmsg=%s\n\n", encodeA(buf));
ok(WriteFile(hStdOut, buf, r, &w, NULL) && w == r, "Writing message to output pipe\n");
}
}
if (option && strcmp(option, "exit_code") == 0)
{
childPrintf(hFile, "[ExitCode]\nvalue=%d\n\n", 123);
CloseHandle(hFile);
ExitProcess(123);
}
CloseHandle(hFile);
}
static char* getChildString(const char* sect, const char* key)
{
char buf[1024+4*MAX_LISTED_ENV_VAR];
char* ret;
GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), resfile);
if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
assert(!(strlen(buf) & 1));
ret = decodeA(buf);
return ret;
}
/* FIXME: this may be moved to the wtmain.c file, because it may be needed by
* others... (windows uses stricmp while Un*x uses strcasecmp...)
*/
static int wtstrcasecmp(const char* p1, const char* p2)
{
char c1, c2;
c1 = c2 = '@';
while (c1 == c2 && c1)
{
c1 = *p1++; c2 = *p2++;
if (c1 != c2)
{
c1 = toupper(c1); c2 = toupper(c2);
}
}
return c1 - c2;
}
static int strCmp(const char* s1, const char* s2, BOOL sensitive)
{
if (!s1 && !s2) return 0;
if (!s2) return -1;
if (!s1) return 1;
return (sensitive) ? strcmp(s1, s2) : wtstrcasecmp(s1, s2);
}
#define okChildString(sect, key, expect) \
do { \
char* result = getChildString((sect), (key)); \
ok(strCmp(result, expect, 1) == 0, "%s:%s expected '%s', got '%s'\n", (sect), (key), (expect)?(expect):"(null)", result); \
} while (0)
#define okChildIString(sect, key, expect) \
do { \
char* result = getChildString(sect, key); \
ok(strCmp(result, expect, 0) == 0, "%s:%s expected '%s', got '%s'\n", sect, key, expect, result); \
} while (0)
/* using !expect ensures that the test will fail if the sect/key isn't present
* in result file
*/
#define okChildInt(sect, key, expect) \
do { \
UINT result = GetPrivateProfileIntA((sect), (key), !(expect), resfile); \
ok(result == expect, "%s:%s expected %d, but got %d\n", (sect), (key), (int)(expect), result); \
} while (0)
static void test_Startup(void)
{
char buffer[MAX_PATH];
PROCESS_INFORMATION info;
STARTUPINFOA startup,si;
/* let's start simplistic */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
GetStartupInfoA(&si);
okChildInt("StartupInfoA", "cb", startup.cb);
okChildString("StartupInfoA", "lpDesktop", si.lpDesktop);
okChildString("StartupInfoA", "lpTitle", si.lpTitle);
okChildInt("StartupInfoA", "dwX", startup.dwX);
okChildInt("StartupInfoA", "dwY", startup.dwY);
okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
release_memory();
assert(DeleteFileA(resfile) != 0);
/* not so simplistic now */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
startup.lpTitle = "I'm the title string";
startup.lpDesktop = "I'm the desktop string";
startup.dwXCountChars = 0x12121212;
startup.dwYCountChars = 0x23232323;
startup.dwX = 0x34343434;
startup.dwY = 0x45454545;
startup.dwXSize = 0x56565656;
startup.dwYSize = 0x67676767;
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
okChildInt("StartupInfoA", "cb", startup.cb);
okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
okChildInt("StartupInfoA", "dwX", startup.dwX);
okChildInt("StartupInfoA", "dwY", startup.dwY);
okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
release_memory();
assert(DeleteFileA(resfile) != 0);
/* not so simplistic now */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
startup.lpTitle = "I'm the title string";
startup.lpDesktop = NULL;
startup.dwXCountChars = 0x12121212;
startup.dwYCountChars = 0x23232323;
startup.dwX = 0x34343434;
startup.dwY = 0x45454545;
startup.dwXSize = 0x56565656;
startup.dwYSize = 0x67676767;
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
okChildInt("StartupInfoA", "cb", startup.cb);
okChildString("StartupInfoA", "lpDesktop", si.lpDesktop);
okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
okChildInt("StartupInfoA", "dwX", startup.dwX);
okChildInt("StartupInfoA", "dwY", startup.dwY);
okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
release_memory();
assert(DeleteFileA(resfile) != 0);
/* not so simplistic now */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
startup.lpTitle = "I'm the title string";
startup.lpDesktop = "";
startup.dwXCountChars = 0x12121212;
startup.dwYCountChars = 0x23232323;
startup.dwX = 0x34343434;
startup.dwY = 0x45454545;
startup.dwXSize = 0x56565656;
startup.dwYSize = 0x67676767;
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
okChildInt("StartupInfoA", "cb", startup.cb);
todo_wine okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
okChildInt("StartupInfoA", "dwX", startup.dwX);
okChildInt("StartupInfoA", "dwY", startup.dwY);
okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
release_memory();
assert(DeleteFileA(resfile) != 0);
/* not so simplistic now */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
startup.lpTitle = NULL;
startup.lpDesktop = "I'm the desktop string";
startup.dwXCountChars = 0x12121212;
startup.dwYCountChars = 0x23232323;
startup.dwX = 0x34343434;
startup.dwY = 0x45454545;
startup.dwXSize = 0x56565656;
startup.dwYSize = 0x67676767;
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
okChildInt("StartupInfoA", "cb", startup.cb);
okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
okChildString("StartupInfoA", "lpTitle", si.lpTitle);
okChildInt("StartupInfoA", "dwX", startup.dwX);
okChildInt("StartupInfoA", "dwY", startup.dwY);
okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
release_memory();
assert(DeleteFileA(resfile) != 0);
/* not so simplistic now */
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
startup.lpTitle = "";
startup.lpDesktop = "I'm the desktop string";
startup.dwXCountChars = 0x12121212;
startup.dwYCountChars = 0x23232323;
startup.dwX = 0x34343434;
startup.dwY = 0x45454545;
startup.dwXSize = 0x56565656;
startup.dwYSize = 0x67676767;
startup.dwFillAttribute = 0xA55A;
get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
okChildInt("StartupInfoA", "cb", startup.cb);
okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
todo_wine okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -