private void OnFunctionCalledPrinterStart(INktHook hhook, INktProcess proc, INktHookCallInfo callInfo) { if (IsWorkedPrintStart) { IsWorkedPrintStart = false; return; } int exitcode = 0; TypressService.eventLog1.WriteEntry("Printer Request Event!"); PageCnt = 0; if (TypressService.packet.IsLogin == false) { TypressService.eventLog1.WriteEntry("LoginForm 띄움"); //System.Diagnostics.Debugger.Launch(); } string applicationName = "C:\\Users\\jklh0\\source\\github\\Typress\\InterruptLogin\\InterruptLoginView\\InterruptLoginView\\bin\\x64\\Debug\\InterruptLoginView.exe"; ApplicationLoader.PROCESS_INFORMATION procInfo; ApplicationLoader.StartProcessAndBypassUAC(applicationName, out procInfo); WaitForSingleObject(procInfo.hProcess, 100000); GetExitCodeProcess(procInfo.hProcess, ref exitcode); //Process P = Process.Start("C:\\Users\\jklh0\\source\\github\\Typress\\InterruptLogin\\InterruptLoginView\\InterruptLoginView\\bin\\x64\\Debug\\InterruptLoginView.exe"); //P.WaitForExit(); // IsLogin 변수 바꼈는지? IsWorkedPrintStart = true; return; }
private void OnFunctionCalledPrinterEnd(INktHook hhook, INktProcess proc, INktHookCallInfo callInfo) { if (IsWorkedPrintEnd) { IsWorkedPrintEnd = false; return; } TypressService.eventLog1.WriteEntry("최종출력물 갯수 : "); TypressService.eventLog1.WriteEntry(PageCnt.ToString()); TypressService.eventLog1.WriteEntry("인쇄작업 종료!"); IsWorkedPrintEnd = true; }
private void OnFunctionCalledPrinter(INktHook hhook, INktProcess proc, INktHookCallInfo callInfo) { MyNewService.eventLog1.WriteEntry("Event."); if (num == "100") { MyNewService.eventLog1.WriteEntry("출력됩니당."); num = "0"; return; } MessageBox.Show("로그인"); if (num == "100") { MyNewService.eventLog1.WriteEntry("에엥?"); //hhook.Unhook(true); } }
private void OnNtWriteFile(INktHook hook, INktProcess proc, INktHookCallInfo callInfo) { var fileHandle = callInfo.Params().GetAt(0).SizeTVal; var fileName = ReadFileInfo(proc.Handle(WinEnum.PROCESS_WM_READ), fileHandle); if (fileName == null) { return; } lock (fileNames) { if (!fileNames.Contains(fileName)) { fileNames.Add(fileName); } } }
//When a hooked function executes (reflection) private void OnFunctionCalled(NktHook hook, INktProcess proc, INktHookCallInfo callInfo) { //Call the function specific handler from string //1:Split function name to the right of '!' and add the handler tag string mn = hook.FunctionName.Substring(hook.FunctionName.LastIndexOf('!') + 1) + 'H'; //2:Lowercase first letter mn = Char.ToLowerInvariant(mn[0]) + mn.Substring(1); //3:Invoke try { //3.1:Get correct hookmanager HookManager h = hManagers[proc.Id]; //3.2:Get its function handler MethodInfo mi = h.GetType().GetMethod(mn, BindingFlags.Instance | BindingFlags.NonPublic); Object[] funcParams = { callInfo }; mi.Invoke(h, funcParams); } catch (NullReferenceException) { Debug.WriteLine(mn + " has no handler"); } }
private void OnFunctionCalledPrintPage(INktHook hhook, INktProcess proc, INktHookCallInfo callInfo) { PageCnt++; TypressService.eventLog1.WriteEntry("Printer Count Increase Event Page."); TypressService.eventLog1.WriteEntry(PageCnt.ToString()); }