Skip to content

Commit 4608095

Browse files
committed
update
1 parent 30240e8 commit 4608095

7 files changed

+95
-251
lines changed

CreateProcess.h

+3-12
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ class CreateProcess {
8585

8686
static bool CreateProcessFromParent(char* lpPath)
8787
{
88-
/*
89-
if (!IsProcessRunAsAdmin()) {
90-
RunAsAdmin();
91-
exit(0);
92-
}
93-
94-
char lpPath[256];
95-
cout << "请输入启动程序路径:";
96-
cin >> lpPath;
97-
*/
9888

9989
char str[][20] = { "winlogon.exe","lsass.exe" };
10090
DWORD pid = 0;
@@ -108,10 +98,11 @@ class CreateProcess {
10898

10999
//程序提权
110100
if (!EnableDebugPriv()) {
111-
cout << "提权失败 !!!" << endl;
101+
cout << "EnableDebugPriv Failed !" << endl;
112102
return false;
113103
}
114104

105+
115106
//创建启动信息结构体
116107
STARTUPINFOEXA si;
117108

@@ -123,7 +114,7 @@ class CreateProcess {
123114

124115
//已全部权限打开services.exe 进程
125116
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
126-
printf("OpenProcess failed ! (%d). \n ", GetLastError());
117+
//printf("OpenProcess failed ! (%d). \n ", GetLastError());
127118

128119
SIZE_T lpSize = 0;
129120
InitializeProcThreadAttributeList(NULL, 1, 0, &lpSize);

CreateProcessFromSystem.cpp

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// CreateProcessFromSystem.cpp : 定义应用程序的入口点。
2+
//
3+
4+
#include "framework.h"
5+
#include "CreateProcess.h"
6+
#include "SelectFolderDlg.h"
7+
#include "CreateProcessFromSystem.h"
8+
9+
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
10+
_In_opt_ HINSTANCE hPrevInstance,
11+
_In_ LPWSTR lpCmdLine,
12+
_In_ int nCmdShow)
13+
{
14+
15+
if (!CreateProcess::IsProcessRunAsAdmin()) {
16+
CreateProcess::RunAsAdmin();
17+
exit(0);
18+
}
19+
20+
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, WndProc);
21+
return 0;
22+
}
23+
24+
25+
INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
26+
{
27+
switch (message)
28+
{
29+
case WM_CLOSE:
30+
EndDialog(hWnd, 0);
31+
break;
32+
case WM_COMMAND:
33+
{
34+
int wmId = LOWORD(wParam);
35+
36+
// 分析菜单选择:
37+
switch (wmId)
38+
{
39+
case ID_OK:
40+
{
41+
//DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
42+
HWND hEdit = FindWindowEx(hWnd, NULL, "Edit", NULL);
43+
char filePath[MAX_PATH] = { 0 };
44+
if (hEdit != nullptr) {
45+
GetWindowText(hEdit, filePath, MAX_PATH);
46+
CreateProcess::CreateProcessFromParent(filePath);
47+
}
48+
break;
49+
}
50+
case ID_SELECT:
51+
{
52+
HWND hEdit = FindWindowEx(hWnd,NULL,"Edit", NULL);
53+
char* temFilePath = CSelectFolderDlg::SelectFile();
54+
int len = strlen(temFilePath);
55+
char filePath[MAX_PATH] = {0};
56+
memcpy(filePath, temFilePath, len);
57+
//char* strLogMsg1 = strLogMsg;0x00d7f0d8 "H:\\ali213pk_6.36\\ali213Pk.exe"
58+
// MessageBox(NULL, strLogMsg, strLogMsg, 0);//输出获得的路径
59+
if (hEdit != nullptr) {
60+
SetWindowText(hEdit, filePath);
61+
}
62+
63+
break;
64+
}
65+
default:
66+
break;
67+
}
68+
}
69+
break;
70+
case WM_DESTROY:
71+
PostQuitMessage(0);
72+
break;
73+
default:
74+
break;
75+
}
76+
return 0;
77+
}

CreateProcessFromSystem.h

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
#include "resource.h"
4+
5+
INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

SelectFolderDlg.h

+10-18
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
#pragma once
44

5-
#include<windows.h>
6-
#include <atlstr.h>
5+
//#include<windows.h>
76
#include <shlobj.h>
87
#include "commdlg.h"
9-
#include <string>
108

119
class CSelectFolderDlg {
1210
public:
1311
//创建一个选择文件夹的对话框,返回所选路径
14-
static CString SelectFolder() {
12+
static char* SelectFolder() {
1513
TCHAR szFolderPath[MAX_PATH] = { 0 };
16-
CString strFolderPath = "";
14+
char strFolderPath[MAX_PATH] = {0};
1715

1816
BROWSEINFO sInfo;
1917
::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
@@ -40,52 +38,46 @@ class CSelectFolderDlg {
4038
if (lpidlBrowse != NULL) {
4139
// 取得文件夹名
4240
if (::SHGetPathFromIDList(lpidlBrowse, szFolderPath)) {
43-
strFolderPath = szFolderPath;
44-
41+
memcpy(strFolderPath, szFolderPath,sizeof(szFolderPath));
4542
}
4643
}
4744
if (lpidlBrowse != NULL) {
4845
::CoTaskMemFree(lpidlBrowse);
4946
}
5047
return strFolderPath;
5148
}
52-
static CString SelectFile() {
49+
//创建一个选择文件的对话框,返回所选路径
50+
static char* SelectFile() {
5351

5452
OPENFILENAME ofn;
55-
char szFile[300];
53+
char szFile[MAX_PATH] = {0};
5654

5755
ZeroMemory(&ofn, sizeof(ofn));
5856
ofn.lStructSize = sizeof(ofn);
5957
ofn.hwndOwner = NULL;
6058
ofn.lpstrFile = szFile;
61-
ofn.lpstrFile[0] = '\0';
6259
LPTSTR lpstrCustomFilter;
6360
DWORD nMaxCustFilter;
6461
ofn.nFilterIndex = 1;
6562
LPTSTR lpstrFile;
66-
ofn.nMaxFile = sizeof(szFile);
63+
ofn.nMaxFile = MAX_PATH;
6764
ofn.lpstrFilter = "ALL\0*.*\0Text\0*.TXT\0";
6865
ofn.lpstrFileTitle = NULL;
6966
ofn.nMaxFileTitle = 0;
7067
ofn.lpstrInitialDir = NULL;
7168

7269
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
7370

74-
CString path_image = "";
7571
if (GetOpenFileName(&ofn)) {//LPWSTR
76-
//std::string strTemp = std::Lpcwstr2String(ofn.lpstrFile);
77-
path_image = ofn.lpstrFile;
78-
//MessageBox(NULL, path_image, path_image, 0);//输出获得的路径
79-
return path_image;
72+
return ofn.lpstrFile;
8073
}
8174
else {
82-
return "";
75+
return szFile;
8376
}
8477
}
8578

8679
void FolderCallBack() {
8780

8881
}
89-
9082
};
9183

0 commit comments

Comments
 (0)