Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling klog_main.cpp errors #25

Closed
wicked opened this issue Feb 3, 2017 · 17 comments
Closed

Compiling klog_main.cpp errors #25

wicked opened this issue Feb 3, 2017 · 17 comments

Comments

@wicked
Copy link

wicked commented Feb 3, 2017

I have tried compiling the source on Dev-C++ and Visual Studio 2016, resulting in various errors. Using latest on master windows.

On Dev-C++ 5.11

In function 'LRESULT HookCallback(int, WPARAM, LPARAM)':
31 [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
In function 'void SetHook()':
47 [Error] cannot convert 'const wchar_t*' to 'LPCSTR {aka const char*}' for argument '2' to 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)'
114 [Error] '::main' must return 'int'

On Visual Studio 2015 Community Edition

argument of type "const wchar_t *" is incompatible with parameter of type "LPCSTR"	
'int MessageBoxA(HWND,LPCSTR,LPCSTR,UINT)': cannot convert argument 2 from 'const wchar_t [24]' to 'LPCSTR'
'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Very frustrating to compile and not simple anymore. The simplier choice would be version 2.0 but it takes up recurring 100% cpu usage.

@GiacomoLaw
Copy link
Owner

Apologies for this. Did you manage to compile it in the end?

@wicked
Copy link
Author

wicked commented Feb 3, 2017

No I couldn't compile any of the versions except version 2.0.

@zochris
Copy link
Contributor

zochris commented Feb 4, 2017

Try removing the L infront of the strings in MessageBox(...) (line 47)
MessageBox(NULL, "Failed to install hook!", "Error", MB_ICONERROR);

In my case it would not compile without them, but your compiler may be different.

Edit:
Technically you could just comment out that function, since it is only called incase the hook fails to install.

@GiacomoLaw
Copy link
Owner

@wicked Please do what @Z0ckerchris suggested, then report back.

@Z0ckerchris What do you use as a compiler? Thanks for helping out!

@wicked
Copy link
Author

wicked commented Feb 4, 2017

Using Dev-C++ 5.11, TDM-GCC 4.9.2 64-bit Release, removed L infront of the strings in MessageBox(...) (line 47)

MessageBox(NULL, "Failed to install hook!", "Error", MB_ICONERROR);

E:\Github\giacomolaw\windows\klog_main.cpp	In function 'LRESULT HookCallback(int, WPARAM, LPARAM)':
31	44	E:\Github\giacomolaw\windows\klog_main.cpp	[Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
E:\Github\giacomolaw\windows\klog_main.cpp	At global scope:
114	11	E:\Github\giacomolaw\windows\klog_main.cpp	[Error] '::main' must return 'int'

Using Visual Studio 2015, Visual C++ Empty Project, klog_main.cpp inside Source Files folder.

C4996	'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. 

Using fopen_s

C2660    'fopen_s': function does not take 2 arguments
62    a value of type "errno_t" cannot be assigned to an entity of type "FILE *"	
62    argument of type "char *" is incompatible with parameter of type "FILE **"	
62    too few arguments in function call

@GiacomoLaw
Copy link
Owner

@wicked

Can you see if the older Windows version worked?

https://github.com/GiacomoLaw/Keylogger/blob/c304e84f1636af453e42ba101501fb6988522b7b/windows/klog_invisible.cpp

Sorry for the issues

@GiacomoLaw
Copy link
Owner

Also, have you set whether the window is visible or not?

// defines whether the window is visible or not
// should be solved with makefile, not in this file
#define visible // (visible / invisible)

@wicked
Copy link
Author

wicked commented Feb 4, 2017

Using unmodified visible.

#define visible // (visible / invisible)

@wicked
Copy link
Author

wicked commented Feb 4, 2017

Using the older Windows version compiles, but with the following error on Dev-C++ 5.11, TDM-GCC 4.9.2 64-bit Release.

E:\Github\giacomolaw\windows\klog_main.cpp	In function 'int main()':
18	29	E:\Github\giacomolaw\windows\klog_main.cpp	[Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]

klog_main.exe works well, but it on win10 it takes up recurring 50% cpu. On win7 it takes up 100%-97% cpu.

But on Visual Studio 2015, using the older version having similar problem on fopen and fopen_s.

@GiacomoLaw
Copy link
Owner

@wicked Ah, okay. Does the new version compile for you even though the errors and work?

Thanks, sorry for the issue and the questions.

@wicked
Copy link
Author

wicked commented Feb 4, 2017

The newest version doesn't compile. No problem @GiacomoLaw , just reporting issues so other users won't have any trouble compiling.

@GiacomoLaw
Copy link
Owner

Okay, thanks. Does anyone else have compilation issues? I don't get them on VS Community edition.

Thanks for reporting!

@zochris
Copy link
Contributor

zochris commented Feb 4, 2017

@GiacomoLaw I'm also using VS Community Edition

@wicked The fopen is just a warning, which VS ignores until you tell it to treat them as error.
So it should compile if thats the only problem.

@wicked
Copy link
Author

wicked commented Mar 28, 2017

@GiacomoLaw is it possible to compile windows.cpp on linux gcc or g++?

@GiacomoLaw
Copy link
Owner

@wicked If they can compile C++, yes

@wicked
Copy link
Author

wicked commented Jun 20, 2017

Just compiled using the same version of Dev-C++, with two errors but compiles just fine. I may have messed up installation last time. Thanks @GiacomoLaw

In function 'LRESULT HookCallback(int, WPARAM, LPARAM)':
[Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]

@wicked wicked closed this as completed Jun 20, 2017
@GiacomoLaw
Copy link
Owner

No problem, glad to see it worked for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants