Saduff Posted August 9, 2011 Posted August 9, 2011 For some reason the WinDDK thinks this is not valid syntax:char* Hello = "Hello World!";The build utility gives these errors:error C2143: syntax error : missing ';' before 'type'error C2065: 'Hello' : undeclared identifierI was using the x86 WinXP Free Build Environment. The code is in C.Also, is char* correct type to pass as PCHAR to API?
Killboy Posted August 9, 2011 Posted August 9, 2011 Shouldn't you be using WCHAR and RTL_CONSTANT_STRING?Which API do you need to use that takes a PCHAR btw?
Jeremy__ Posted August 9, 2011 Posted August 9, 2011 (edited) For some reason the WinDDK thinks this is not valid syntax:char* Hello = "Hello World!";The build utility gives these errors:I was using the x86 WinXP Free Build Environment. The code is in C.Also, is char* correct type to pass as PCHAR to API?Lol, I hate this problem. I spent a while looking at this forever trying to make sense of it when I encountered it. It definitely confuses C++ programmers writing C drivers.. In C all variables must be declared before the executable statements. - I bet this is your problem; if not, we obviously need more information. If this doesn't work, check to assure the preceding line is teriminated with a semi-colon.int foo(){ return 0;}int main(){ foo(); int i = 0; //This is invalid because execution occurs vefore vairable declaration.}This is valid:int foo(){ return 0;}int main(){ int i = 0; foo();}IIRC, PCHAR is a char*/>http://msdn.microsoft.com/en-us/library/dd440601.aspxtypedef CHAR* PCHAR; Edited August 9, 2011 by Jeremy__
Saduff Posted August 9, 2011 Author Posted August 9, 2011 (edited) In C all variables must be declared before the executable statements. Yup, that was it. Thanks Jeremy. I had this line before the Hello var: DriverObject->DriverUnload = DriverUnload; But I think this applies only to initialized variables, because if you look in this thread, you can see that I declare variables later in the code, but it compiles fine. Look at these variables for example: static char buffer[0x78];int i;static LARGE_INTEGER byteOffset; Shouldn't you be using WCHAR and RTL_CONSTANT_STRING?Which API do you need to use that takes a PCHAR btw? I'm trying to use "VidDisplayString" and "VidDisplayStringXY" exported in bootvid.dll. These are undocumented APIs though, so the PCHAR type may be incorrect. I just found a header file, where it was prototyped with PCHAR. Most documented APIs use UNICODE_STRING and I've also seen PUCHAR. This one might be PUCHAR instead of PCHAR as well. -- EDIT -- No, PCHAR is correct. The API is working as expected. It prints "Hello World!" on the boot screen. Edited August 9, 2011 by Saduff
Killboy Posted August 9, 2011 Posted August 9, 2011 What is the build process like with C++? I read a guide about soem of the pitfalls of using C++ but I imagine if you just use the C subset it shouldn't be a problem?You could then use some of the useful features like being able to declare variables anywhere (e.g. in for loops) orcompile time constants without having to use #define
Saduff Posted August 9, 2011 Author Posted August 9, 2011 I tried C++, but it's giving a lot of errors, so I just went with C.And most, if not all, of the example projects in WDK are in C.I'm new to this stuff, so I don't know how to fix it.Haven't been coding in C/C++ for a long time either.
Jeremy__ Posted August 9, 2011 Posted August 9, 2011 I tried C++, but it's giving a lot of errors, so I just went with C.And most, if not all, of the example projects in WDK are in C.I'm new to this stuff, so I don't know how to fix it.Haven't been coding in C/C++ for a long time either.Yeah, C++ is a real pain in kernel mode. At least I found, plus usually an OOP design isn't nearly as critical as it would be in usermode.
GamingMasteR Posted August 12, 2011 Posted August 12, 2011 What is the build process like with C++? I read a guide about soem of the pitfalls of using C++ but I imagine if you just use the C subset it shouldn't be a problem?You could then use some of the useful features like being able to declare variables anywhere (e.g. in for loops) orcompile time constants without having to use #define Yes, it's more comfortable for me to use C++ compiler. I use VC++ 9.0 compiler and VS 2010 as IDE.
atom0s Posted August 12, 2011 Posted August 12, 2011 Yes, it's more comfortable for me to use C++ compiler. I use VC++ 9.0 compiler and VS 2010 as IDE.Any reason you aren't using VS2010's compiler? Kinda odd you'd download 2010 just for the IDE and not use the compiler too.
GamingMasteR Posted August 12, 2011 Posted August 12, 2011 Ops sorry for the mistake , I actually use VC++ 10.0
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now