I have an application that works with NDI. But when I initialize it, error occurs: window with title "netsh.exe - Application Error" and error description - "The application was unable to start correctly (0xc0000142). Click OK to close the application". I skip this error and all the required NDI functionality works fine. But this error shouldn't occur anyway. I also found, that this error because of my "custom console" usage - my application is GUI-application and I want to see console window near it in some cases.
Very simplified but problem-contains example of this:
#include <iostream>
#include <Windows.h>
#include "ndi/Processing.NDI.Lib.h"
int main()
{
FreeConsole();
AllocConsole();
SetConsoleActiveScreenBuffer(CreateConsoleScreenBuffer(GENERIC_WRITE | GENERIC_READ, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL));
HMODULE m_NDIHandler = LoadLibraryA("Processing.NDI.Lib.x64.dll");
const NDIlib_v5* (*NDIlib_v5_load)(void) = NULL;
if (m_NDIHandler)
{
*((FARPROC*)&NDIlib_v5_load) = GetProcAddress(m_NDIHandler, "NDIlib_v5_load");
}
const NDIlib_v5* m_NDILib = NDIlib_v5_load();
m_NDILib->initialize();
return 0;
}
(Later I'm using WriteConsole for some purposes). Could you please tell me, what is wrong with my code? Error occur on m_NDILib->initialize();
I updated my NDI to latest version (5.1.3.0) and problem fixed.
Related
enter link description here[2][this image shows the error]
I tried this code for block the process before execution.But i got a 100 errors while import a ntddk.h and wdm.h in c++.How to solve it?
Then i got sme erroe like this expected a ')' in my 14 and 22 line of code.
So what should i do for removing the 100 error?
#include <ntstatus.h>
#include<DbgEng.h>
#include<Windows.h>
#include <ntddk.h>
#include <wdm.h>
int main()
{
PEPROCESS process1;
process1 = IoGetCurrentProcess();
HANDLE ProcessId = PsGetCurrentProcessId();
PS_CREATE_NOTIFY_INFO CreateInfo;
PCREATE_PROCESS_NOTIFY_ROUTINE_EX(process1, ProcessId, CreateInfo);
PCUNICODE_STRING ImageFileName;
NTSTATUS CreationStatus;
CreateInfo.CreationStatus = STATUS_ACCESS_DENIED;
ImageFileName = CreateInfo.ImageFileName;
if (ImageFileName == (PCUNICODE_STRING)L"firefox.exe")
{
NTSTATUS result;
result = PsSetCreateProcessNotifyRoutineEx(PCREATE_PROCESS_NOTIFY_ROUTINE_EX(process1, ProcessId, CreateInfo), FALSE);
if (result)
{
printf("blocked");
}
}
return 0;
}
Then i got sme erroe like this expected a ')' in my 14 and 22 line of code.
PCREATE_PROCESS_NOTIFY_ROUTINE_EX(process1, ProcessId, CreateInfo);
result=PsSetCreateProcessNotifyRoutineEx(PCREATE_PROCESS_NOTIFY_ROUTINE_EX(process1, ProcessId, CreateInfo), FALSE);
this is the link for showing my error
Don't mix SDK and DDK headers/libraries in one executable.
If you write a driver, don't include Windows.h. Driver code is not Win32 code.
If you want to create a process in suspended state from another Win32 process, use CREATE_SUSPENDED process creation flag in CreateProcess() (or a similar) Win32 call.
If you want to deny process creation for a particular process from a driver, check this StackOverflow question for the boilerplate code.
#include <graphics.h>
#include <conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\TURBOC3\\");
setbkcolor(CYAN);
getch();
closegraph();
}
The compiling was successful and tried running it, but the result was I see no display for my code It's just a blink of screen and gone back to the console.
you need to point initgraph to bgi subfolder of turboc3
initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
Yes your code may compile successfully but your code is having a runtime problem. Just add these line first below the line you initialized your graphics.
int errorcode = graphresult();
if (errorcode != grOk) { /* an error occurred */
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code(requires process.h) */
}
Through these lines runtime problems of graphics can be detected. Its just a safety method for avoid errors and system crash. Well these lines will tell you that they cannot find the file VGAEGA.bgi file. That's generally the default drivers of graphics.
The reason the file is not found is your path c:\\TURBOC3\\. see this post for avoiding the errors.
I've recently switched a project from using the VS2013 compiler to VS2017, and now the following code appears not to be working:
#include <windows.h>
#include <Fcntl.h>
#include <io.h>
#include <iostream>
#include <exception>
if( RedirectOutput )
{
//Setup stdout
HANDLE handle_stdout = GetStdHandle( STD_OUTPUT_HANDLE );
int fileDesc_stdout = _open_osfhandle( (long)handle_stdout, _O_TEXT );
if( fileDesc_stdout == -1 )
{
throw std::exception( "fileDesc_stdout is not valid" );
}
FILE* new_stdout = _fdopen( fileDesc_stdout, "w" );
if( !new_stdout )
{
throw std::exception( "new_stdout is not valid" );
}
FILE old_stdout = *stdout;
*stdout = *new_stdout;
std::cout.clear();
std::cout << "Output Redirected!\n";
}
This code is intended to redirect standard output to a console window, either the one that kicked off the current process or a console that is created via AllocConsole. (I've added the last line for testing purposes.)
The first time writing to cout occurs, the following exception is thrown (it otherwise doesn't write output and fails silently from then on):
Debug Assertion Failed!
Program: w:\build\MyApp.exe
File: minkernel\crts\ucrt\src\appcrt\stdio_flsbuf.cpp
Line: 26
Expression: ("inconsistent IOB fields", stream->_ptr - stream->_base >= 0)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
I can see that stdout is coming from corecrt_wstdio.h, but when I insert a breakpoint and add a watch, it says that the stdout is undefined, so I can't check the value.
Any ideas?
So I searched around a bit and found this post on SO.
Essentially, all of the code I posted can be replaced with the following:
freopen("CONOUT$", "w", stdout);
The first parameter of freopen is a filename, so I wonder if CONOUT$/CONIN$ represent an actual file, or if the function treats that input as a special case.
I have read several posts about running a command line in c++, but none of them does what I want : no display of the console in an external application when I use the dllfile.
My problem : I want to use a process that picks files from a database. For example : to get a file XYZ.xyz and copy it to the directory MyDirXYZ, I would use the command line
"MyDataGenerator XYZ.xyz C:\MyDirXYZ".
I use Visual studio
Let 's take the following example to clarify the issue, I am trying to create a directory with "mkdir" in C++ , without using CreateDirectory :
First method :
std::string lDirectory("c:\\MyDummyDir")
std::string lCmd("mkdir " + lDirectory);
system((lCmd).c_str());
It will work , however it displays the console when I run it with a dllfile on Excel .
Second Method ( convertToRightFormat() convert a char to a TChar)
std::string lDirectory("c:\\MyDummyDir")
std::string lCmd("mkdir " + lDirectory);
BOOL _status = TRUE;
DWORD _reply, _code;
STARTUPINFO _si = { sizeof(_si) };
PROCESS_INFORMATION _pi;
TCHAR *_cmd = NULL;
_cmd=convertToRightFormat(lCmd.c_str())
_status &= CreateProcess(NULL, _cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &_si, &_pi);
This method does not work(not even creating the folder) , and obviously it does not work either for the process "MyDataGenerator".
I tried to use the executable MKDIR.EXE and put it in the commandline. In that case, it works , but still does not work for MyDataGenerator.
Is there a generic to make all command lines work, without showing the console?
Thanks you.
#include <Windows.h> // FreeConsole, system
int main(int argc, char* argv[])
{
system("mkdir newdirectoryname");
FreeConsole();
}
This will result in cmd popping up for a split second though. It closes after that.
If thats not acceptable just target the windows subsystem instead of the console one and make sure to not draw the window.
I am delving into Mosync & its going pretty good, but for some reason I am getting the following errors which I dont understand:
First error = "Error: Unresolved symbol '__ZN4MAUI6LayoutC1EiiiiPNS_6WidgetEii',"
Second Error = "Error: Unresolved symbol '__ZN4MAUI7ListBoxC1EiiiiPNS_6WidgetENS0 _18ListBoxOrientationENS0_20ListBoxAnimationTypeEb',"
I have commented below which line the error refers to. I have also cleaned my project & rebuilt, this worked the 1st time but now it wont work & its creating these types of errors for other creations of widgets such as labels. What does this error mean?
#include <MAUtil/Moblet.h>
#include <MAUI/Layout.h>
#include <MAUI/ListBox.h>
#include <MAUI/Label.h>
#include <MAUI/EditBox.h>
using namespace MAUtil;
using namespace MAUI;
/// Functions ///
float toFahrenheit( float fahrenVal );
float toCelsius(float celsiusVal );
class TemperatureMoblet : public Moblet
{
public:
TemperatureMoblet()
{
mainLayout = NULL;
mainListBox = NULL;
initScreen();
}
void keyPressEvent(int keyCode, int nativeCode)
{
// todo: handle key presses
}
void keyReleaseEvent(int keyCode, int nativeCode)
{
// todo: handle key releases
}
void initScreen()
{
mainLayout = new Layout( 0, 0, 100, 600, NULL, 1, 3 ); // ERROR HERE
mainListBox = new ListBox( 0, 0, 100, 200, mainLayout,
ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR,
true ); // 2nd error here
......
}
You have a linking error which means that your code compiled fine, but when trying to bring the compiled code together some parts are missing. In this case it seems to be the UI classes. Generally this is because maui.lib is missing under the additional libraries. It is however strange that it worked the first time, perhaps you accidentally changed to the debug configuration?
If go right click on project -> properties -> MoSync project -> Build Settings. Is maui.lib among the additional libraries? Check both for the release and debug configurations (it should be mauiD.lib in the debug configuration).
If it doesn't work perhaps you can paste the whole build log somewhere, including all the calls to pipe-tool.