Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxsoft committed Jan 20, 2019
1 parent 1553f3b commit 441e83c
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 4 deletions.
Binary file modified HookDLL/HookDLL.cpp
Binary file not shown.
3 changes: 3 additions & 0 deletions HookDLL/HookDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
3 changes: 3 additions & 0 deletions HookDLL/HookDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion HookDLL/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Config::initialize() {
throw CLI::CallForHelp();
}
for (auto &f : scanList) {
if (!std::experimental::filesystem::exists(f)) {
if (!std::experimental::filesystem::exists(f) || !std::experimental::filesystem::is_directory(f)) {
std::cout << f << " not exists!";
ExitProcess(1);
}
Expand Down
21 changes: 18 additions & 3 deletions HookDLL/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
#include <Windows.h>
#include <tlhelp32.h>
#include <string>
#include <iostream>

namespace WebShellKillHook {

Data::Data() {
data.set<>(picojson::array());
WebShellKillHook::Global::event.on(WebShellKillHook::Global::EVENT_SCAN_START, [&]() {
isScanning = true;
enableCount = 0;
realFoundSomething = false;
});
}

std::string Data::serialize() {
Expand All @@ -21,27 +27,36 @@ namespace WebShellKillHook {
LRESULT CALLBACK Data::hookCallback(int nCode, WPARAM wParam, LPARAM lParam) {
CWPSTRUCT msg = *(CWPSTRUCT*)lParam;
if (msg.message == WM_ENABLE) {
if (isScanning) {
if (realFoundSomething) {
realFoundSomething = false;
isScanning = false;
Global::event.emit(Global::EVENT_SCAN_END);
}
else if (isScanning) {
if (++enableCount == 7) {
isScanning = false;
Global::event.emit(Global::EVENT_SCAN_END);
}
}
}
else if (msg.message == LVM_INSERTITEMA) {
currentColumnIndex = -1;
isWaitingForText = true;
isSecondCall = 0;
item.set<>(picojson::object());
isScanning = true;
realFoundSomething = true;
}
else if (msg.message == LVM_SETITEMA) {
if (isWaitingForText) {
data.get<picojson::array>().push_back(item);
std::cerr << item.serialize() << std::endl;
item.get<picojson::object>().clear();
isWaitingForText = false;
}
}
else if (msg.message == LVM_SETITEMTEXTA) {
if (isWaitingForText && ++isSecondCall % 2 == 1) {
++isSecondCall;
if (isWaitingForText && (isSecondCall % 2 == 0)) {
currentColumnIndex++;
LPSTR str = (LPSTR)(malloc(sizeof(LPSTR) * 255));
ListView_GetItemText(msg.hwnd, ((LVITEMA*)lParam)->iItem, currentColumnIndex, str, 255);
Expand Down
2 changes: 2 additions & 0 deletions HookDLL/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace WebShellKillHook {
int isSecondCall = 0;
bool isWaitingForText = false;
bool isScanning = false;
bool realFoundSomething = false;
int enableCount = 0;
std::string columnMap[6] = { "file", "level", "description", "size", "time", "crc32" };
picojson::value data;
picojson::value item;
Expand Down
1 change: 1 addition & 0 deletions HookDLL/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace WebShellKillHook {
void startScanQueue() {
currentIterator = Config::scanList.begin();
startScan();
event.emit(EVENT_SCAN_START);
}

void startScan() {
Expand Down
1 change: 1 addition & 0 deletions HookDLL/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebShellKillHook {
const int EVENT_READY = 1;
const int EVENT_GET_BUTTON_HWND = 2;
const int EVENT_SCAN_END = 3;
const int EVENT_SCAN_START = 4;
const int EVENT_DONE = 5;
extern EventEmitter event;
extern std::vector<std::string>::iterator currentIterator;
Expand Down
1 change: 1 addition & 0 deletions HookDLL/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "stdafx.h"
Binary file modified HookDLL/stdafx.h
Binary file not shown.
Binary file modified HookDLL/targetver.h
Binary file not shown.

0 comments on commit 441e83c

Please sign in to comment.