Posted August 9, 201114 yr 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?
August 9, 201114 yr Shouldn't you be using WCHAR and RTL_CONSTANT_STRING?Which API do you need to use that takes a PCHAR btw?
August 9, 201114 yr 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, 201114 yr by Jeremy__
August 9, 201114 yr Author 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, 201114 yr by Saduff
August 9, 201114 yr 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
August 9, 201114 yr Author 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.
August 9, 201114 yr 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.
August 12, 201114 yr 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.
August 12, 201114 yr 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.
Create an account or sign in to comment