I can convert everything into assembly but the
"Hardcoded insert string for the event messages."
Could someone help me?
Thanks.
// Example shows how to use the ReportEvent function to write the
events defined
// in the above message text file.
#define UNICODE
#include <windows.h>
#include <stdio.h>
#include "provider.h"
#pragma comment(lib, "advapi32.lib")
#define PROVIDER_NAME L"MyEventProvider"
// Hardcoded insert string for the event messages.
CONST LPWSTR pBadCommand = L"The command that was not valid";
CONST LPWSTR pFilename = L"c:\\folder\\file.ext";
CONST LPWSTR pNumberOfRetries = L"3";
CONST LPWSTR pSuccessfulRetries = L"0";
CONST LPWSTR pQuarts = L"8";
CONST LPWSTR pGallons = L"2";
|
|
0
|
|
|
|
Reply
|
Andy
|
1/31/2011 10:00:34 PM |
|
On Mon, 31 Jan 2011 14:00:34 -0800 (PST), Andy
<chocolatemint77581@nospicedham.yahoo.com> wrote:
>I can convert everything into assembly but the
>"Hardcoded insert string for the event messages."
>
>Could someone help me?
>
>Thanks.
>
>// Example shows how to use the ReportEvent function to write the
>events defined
>// in the above message text file.
>#define UNICODE
>#include <windows.h>
>#include <stdio.h>
>#include "provider.h"
>
>#pragma comment(lib, "advapi32.lib")
>
>#define PROVIDER_NAME L"MyEventProvider"
>
>// Hardcoded insert string for the event messages.
>CONST LPWSTR pBadCommand = L"The command that was not valid";
>CONST LPWSTR pFilename = L"c:\\folder\\file.ext";
>CONST LPWSTR pNumberOfRetries = L"3";
>CONST LPWSTR pSuccessfulRetries = L"0";
>CONST LPWSTR pQuarts = L"8";
>CONST LPWSTR pGallons = L"2";
I'm not sure what the problem is you are asking about, but
I'm guessing it's how to put a size field in front of the
string. (Normally, null-terminated strings would be used,
but some applications put the size first.) Here's the way I
would approach this:
BadCommandLen DB SIZEOF BadCommand
BadCommand DB "The command that was not valid"
You can use a word or dword instead of a byte for the xxLen
field if your fromat requires it.
Then if you want a pointer to this, it would be:
pBadCommand DD OFFSET BadCommandLen
Note that the pointer goes to the xxLen entry, not the
string part. The xxLen *must* come just before the actual
string for this to work.
Normally, pointers are used only when you have an index
(such as an error number) that you want to associate with a
certain string. In that case, you put all the pointers in a
table whose index is the error number. In one-off
(non-index) situations, you don't use the pointer, but just
refer to the string by offset, as in:
mov esi,OFFSET BadCommandLen
call ShowString
Hope this helps!
Bob Masta
DAQARTA v6.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
Science with your sound card!
|
|
0
|
|
|
|
Reply
|
N0Spam
|
2/1/2011 1:38:37 PM
|
|
On Feb 1, 7:38=A0am, N0S...@daqarta.com (Bob Masta) wrote:
> On Mon, 31 Jan 2011 14:00:34 -0800 (PST), Andy
>
>
>
>
>
>
>
>
>
> <chocolatemint77...@nospicedham.yahoo.com> wrote:
> >I can convert everything into assembly but the
> >"Hardcoded insert string for the event messages."
>
> >Could someone help me?
>
> >Thanks.
>
> >// Example shows how to use the ReportEvent function to write the
> >events defined
> >// in the above message text file.
> >#define UNICODE
> >#include <windows.h>
> >#include <stdio.h>
> >#include "provider.h"
>
> >#pragma comment(lib, "advapi32.lib")
>
> >#define PROVIDER_NAME L"MyEventProvider"
>
> >// Hardcoded insert string for the event messages.
> >CONST LPWSTR pBadCommand =3D L"The command that was not valid";
> >CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
> >CONST LPWSTR pNumberOfRetries =3D L"3";
> >CONST LPWSTR pSuccessfulRetries =3D L"0";
> >CONST LPWSTR pQuarts =3D L"8";
> >CONST LPWSTR pGallons =3D L"2";
>
> I'm not sure what the problem is you are asking about, but
> I'm guessing it's how to put a size field in front of the
> string. =A0(Normally, null-terminated strings would be used,
> but some applications put the size first.) =A0Here's the way I
> would approach this:
>
> BadCommandLen =A0 =A0DB =A0 =A0 SIZEOF BadCommand =A0 =A0 =A0 =A0
> BadCommand =A0 =A0 =A0 =A0 =A0 DB =A0 =A0 "The command that was not valid=
"
>
> You can use a word or dword instead of a byte for the xxLen
> field if your fromat requires it.
>
> Then if you want a pointer to this, it would be:
>
> pBadCommand =A0 =A0 =A0 =A0 DD =A0 =A0 OFFSET BadCommandLen
>
> Note that the pointer goes to the xxLen entry, not the
> string part. =A0The xxLen *must* come just before the actual
> string for this to work.
>
> Normally, pointers are used only when you have an index
> (such as an error number) that you want to associate with a
> certain string. =A0In that case, you put all the pointers in a
> table whose index is the error number. =A0In one-off
> (non-index) situations, you don't use the pointer, but just
> refer to the string by offset, as in:
>
> mov esi,OFFSET BadCommandLen
> call ShowString
>
> Hope this helps!
>
> Bob Masta
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 DAQARTA =A0v6.00
> =A0 =A0Data AcQuisition And Real-Time Analysis
> =A0 =A0 =A0 =A0 =A0 =A0 =A0www.daqarta.com
> Scope, Spectrum, Spectrogram, Sound Level Meter
> =A0 =A0 Frequency Counter, FREE Signal Generator
> =A0 =A0 =A0 =A0 =A0 =A0Pitch Track, Pitch-to-MIDI
> =A0 =A0 =A0 =A0 =A0 Science with your sound card!
Thanks Bob.
Here is some more info that may help.
I think there is enough here to show what's going on.
If not I can post more of the C code.
I left a lot out
It is still messy. :-)
This full source example shows how to use the ReportEvent function to
write the events defined
in the above message text file.
I have made a required dll and the message file.
Andy
..data
pBadCommand WORD "T","h","e"," ","c","o","m","m","a","n","d","
","t","h","a","t"," ","w","a","s"," ","n","
void wmain(void)
{
HANDLE hEventLog =3D NULL;
LPWSTR pInsertStrings[2] =3D {NULL, NULL};
DWORD dwEventDataSize =3D 0;
// The source name (provider) must exist as a subkey of
Application.
hEventLog =3D RegisterEventSource(NULL, PROVIDER_NAME);
if (NULL =3D=3D hEventLog)
{
wprintf(L"RegisterEventSource failed with 0x%x.\n",
GetLastError());
goto cleanup;
}
// This event includes user-defined data as part of the event. The
event message
// does not use insert strings.
dwEventDataSize =3D (wcslen(pBadCommand) + 1) * sizeof(WCHAR);
if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, UI_CATEGORY,
MSG_INVALID_COMMAND, NULL, 0, dwEventDataSize, NULL, pBadCommand))
{
wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n",
GetLastError(), MSG_INVALID_COMMAND);
goto cleanup;
}
|
|
0
|
|
|
|
Reply
|
Andy
|
2/1/2011 4:38:33 PM
|
|
On Tue, 1 Feb 2011 08:38:33 -0800 (PST), Andy
<chocolatemint77581@nospicedham.yahoo.com> wrote:
>On Feb 1, 7:38=A0am, N0S...@daqarta.com (Bob Masta) wrote:
>> On Mon, 31 Jan 2011 14:00:34 -0800 (PST), Andy
>> <chocolatemint77...@nospicedham.yahoo.com> wrote:
>> >I can convert everything into assembly but the
>> >"Hardcoded insert string for the event messages."
>>
>> >Could someone help me?
>>
>> >Thanks.
>>
>> >// Example shows how to use the ReportEvent function to write the
>> >events defined
>> >// in the above message text file.
>> >#define UNICODE
>> >#include <windows.h>
>> >#include <stdio.h>
>> >#include "provider.h"
>>
>> >#pragma comment(lib, "advapi32.lib")
>>
>> >#define PROVIDER_NAME L"MyEventProvider"
>>
>> >// Hardcoded insert string for the event messages.
>> >CONST LPWSTR pBadCommand =3D L"The command that was not valid";
>> >CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
>> >CONST LPWSTR pNumberOfRetries =3D L"3";
>> >CONST LPWSTR pSuccessfulRetries =3D L"0";
>> >CONST LPWSTR pQuarts =3D L"8";
>> >CONST LPWSTR pGallons =3D L"2";
>>
>> I'm not sure what the problem is you are asking about, but
>> I'm guessing it's how to put a size field in front of the
>> string. =A0(Normally, null-terminated strings would be used,
>> but some applications put the size first.) =A0Here's the way I
>> would approach this:
>>
>> BadCommandLen =A0 =A0DB =A0 =A0 SIZEOF BadCommand =A0 =A0 =A0 =A0
>> BadCommand =A0 =A0 =A0 =A0 =A0 DB =A0 =A0 "The command that was not valid=
>"
>>
>> You can use a word or dword instead of a byte for the xxLen
>> field if your fromat requires it.
>>
>> Then if you want a pointer to this, it would be:
>>
>> pBadCommand =A0 =A0 =A0 =A0 DD =A0 =A0 OFFSET BadCommandLen
>>
>> Note that the pointer goes to the xxLen entry, not the
>> string part. =A0The xxLen *must* come just before the actual
>> string for this to work.
>>
>> Normally, pointers are used only when you have an index
>> (such as an error number) that you want to associate with a
>> certain string. =A0In that case, you put all the pointers in a
>> table whose index is the error number. =A0In one-off
>> (non-index) situations, you don't use the pointer, but just
>> refer to the string by offset, as in:
>>
>> mov esi,OFFSET BadCommandLen
>> call ShowString
>>
>> Hope this helps!
>>
>> Bob Masta
>>
>
>Thanks Bob.
>
>Here is some more info that may help.
>I think there is enough here to show what's going on.
>
>If not I can post more of the C code.
>
>I left a lot out
>
>It is still messy. :-)
>
>This full source example shows how to use the ReportEvent function to
>write the events defined
>in the above message text file.
>
>I have made a required dll and the message file.
>
>Andy
You need to explain what your problem is, not show more
code.
In my prior post I had to guess that you were having trouble
inserting the size in front of the string. Is that the
case? Or are you having trouble inserting variable values
in the midst of the string?
Are you replacing this entire function with an assembly
version? Or are you still going to use wprinf?
If you are creating a complete assembly replacement,
including a replacement for the wprintf parts, you should
omit the size prefix and use null-terminated strings. Since
you are forcing me to guess at this, my guess is that you
may be having trouble inserting variables into the strings.
The solution I use is simple: Don't attempt to do this all
with one wprintf-type operation, just show each part
separately.
You will need to have a function that shows a
null-terminated string when passed the offset of the string.
Then you just show the first part of the string, then show
the variable part (with a routine for converting your values
to displayable digits, etc), then show the next part of the
string. It would look like this:
mov esi,OFFSET Msg1Head
call ShowString
mov eax,Variable1
call ShowInteger
mov esi,OFFSET Msg1Tail
call ShowString
Best regards,
Bob Masta
DAQARTA v6.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
Science with your sound card!
|
|
0
|
|
|
|
Reply
|
N0Spam
|
2/2/2011 1:21:19 PM
|
|
On Feb 2, 1:21=A0pm, N0S...@daqarta.com (Bob Masta) wrote:
> You need to explain what your problem is, not show more
> code. =A0
Let me see if I can help. The OP stated that he can convert
everything into assembly but the
strings for the event messages. Therefore I assume his difficulty is
in generating an assembler equivalent to:
CONST LPWSTR pBadCommand =3D L"The command that was not valid";
CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
CONST LPWSTR pNumberOfRetries =3D L"3";
and so on.
In recent versions of NASM (I'm not sure when support for Unicode was
added) the equivalent would be:
%define L(x) __utf16__(x)
pBadCommand: dw L('The command that was not valid'), 0
pFilename: dw L('c:\folder\file.ext'), 0
pNumberOfRetries: dw L('3'), 0
> In my prior post I had to guess that you were having trouble
> inserting the size in front of the string.
I'm mystified by that comment, since the strings are NUL-terminated,
not preceded by a length value. The OP's code is in C not Pascal!
Richard.
http://www.rtrussell.co.uk/
|
|
0
|
|
|
|
Reply
|
Richard
|
2/2/2011 3:51:04 PM
|
|
On Feb 2, 9:51=A0am, Richard Russell <n...@nospicedham.rtrussell.co.uk>
wrote:
> On Feb 2, 1:21=A0pm, N0S...@daqarta.com (Bob Masta) wrote:
>
> > You need to explain what your problem is, not show more
> > code. =A0
>
> Let me see if I can help. =A0The OP stated that he can convert
> everything into assembly but the
> strings for the event messages. =A0Therefore I assume his difficulty is
> in generating an assembler equivalent to:
>
> CONST LPWSTR pBadCommand =3D L"The command that was not valid";
> CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
> CONST LPWSTR pNumberOfRetries =3D L"3";
> and so on.
>
> In recent versions of NASM (I'm not sure when support for Unicode was
> added) the equivalent would be:
>
> %define L(x) __utf16__(x)
> pBadCommand: dw L('The command that was not valid'), 0
> pFilename: =A0 dw L('c:\folder\file.ext'), 0
> pNumberOfRetries: dw L('3'), 0
>
> > In my prior post I had to guess that you were having trouble
> > inserting the size in front of the string.
>
> I'm mystified by that comment, since the strings are NUL-terminated,
> not preceded by a length value. =A0The OP's code is in C not Pascal!
>
> Richard.http://www.rtrussell.co.uk/
Thanks Richard.
It was necessary to use this format in the data section.
pBadCommand WORD "T","h","e",0
The C code is complex. (at least to me.)
I am learning a lot that has helped in another conversion project.
If you have time, I could use more help with the C -> asm conversion.
Andy
|
|
0
|
|
|
|
Reply
|
Andy
|
2/2/2011 10:53:35 PM
|
|
On Feb 2, 7:21=A0am, N0S...@daqarta.com (Bob Masta) wrote:
> On Tue, 1 Feb 2011 08:38:33 -0800 (PST), Andy
>
>
>
>
>
>
>
>
>
> <chocolatemint77...@nospicedham.yahoo.com> wrote:
> >On Feb 1, 7:38=3DA0am, N0S...@daqarta.com (Bob Masta) wrote:
> >> On Mon, 31 Jan 2011 14:00:34 -0800 (PST), Andy
> >> <chocolatemint77...@nospicedham.yahoo.com> wrote:
> >> >I can convert everything into assembly but the
> >> >"Hardcoded insert string for the event messages."
>
> >> >Could someone help me?
>
> >> >Thanks.
>
> >> >// Example shows how to use the ReportEvent function to write the
> >> >events defined
> >> >// in the above message text file.
> >> >#define UNICODE
> >> >#include <windows.h>
> >> >#include <stdio.h>
> >> >#include "provider.h"
>
> >> >#pragma comment(lib, "advapi32.lib")
>
> >> >#define PROVIDER_NAME L"MyEventProvider"
>
> >> >// Hardcoded insert string for the event messages.
> >> >CONST LPWSTR pBadCommand =3D3D L"The command that was not valid";
> >> >CONST LPWSTR pFilename =3D3D L"c:\\folder\\file.ext";
> >> >CONST LPWSTR pNumberOfRetries =3D3D L"3";
> >> >CONST LPWSTR pSuccessfulRetries =3D3D L"0";
> >> >CONST LPWSTR pQuarts =3D3D L"8";
> >> >CONST LPWSTR pGallons =3D3D L"2";
>
> >> I'm not sure what the problem is you are asking about, but
> >> I'm guessing it's how to put a size field in front of the
> >> string. =3DA0(Normally, null-terminated strings would be used,
> >> but some applications put the size first.) =3DA0Here's the way I
> >> would approach this:
>
> >> BadCommandLen =3DA0 =3DA0DB =3DA0 =3DA0 SIZEOF BadCommand =3DA0 =3DA0 =
=3DA0 =3DA0
> >> BadCommand =3DA0 =3DA0 =3DA0 =3DA0 =3DA0 DB =3DA0 =3DA0 "The command t=
hat was not valid=3D
> >"
>
> >> You can use a word or dword instead of a byte for the xxLen
> >> field if your fromat requires it.
>
> >> Then if you want a pointer to this, it would be:
>
> >> pBadCommand =3DA0 =3DA0 =3DA0 =3DA0 DD =3DA0 =3DA0 OFFSET BadCommandLe=
n
>
> >> Note that the pointer goes to the xxLen entry, not the
> >> string part. =3DA0The xxLen *must* come just before the actual
> >> string for this to work.
>
> >> Normally, pointers are used only when you have an index
> >> (such as an error number) that you want to associate with a
> >> certain string. =3DA0In that case, you put all the pointers in a
> >> table whose index is the error number. =3DA0In one-off
> >> (non-index) situations, you don't use the pointer, but just
> >> refer to the string by offset, as in:
>
> >> mov esi,OFFSET BadCommandLen
> >> call ShowString
>
> >> Hope this helps!
>
> >> Bob Masta
>
> >Thanks Bob.
>
> >Here is some more info that may help.
> >I think there is enough here to show what's going on.
>
> >If not I can post more of the C code.
>
> >I left a lot out
>
> >It is still messy. :-)
>
> >This full source example shows how to use the ReportEvent function to
> >write the events defined
> >in the above message text file.
>
> >I have made a required dll and the message file.
>
> >Andy
>
> You need to explain what your problem is, not show more
> code. =A0
>
> In my prior post I had to guess that you were having trouble
> inserting the size in front of the string. =A0Is that the
> case? =A0Or are you having trouble inserting variable values
> in the midst of the string?
>
> Are you replacing this entire function with an assembly
> version? =A0Or are you still going to use wprinf?
My goal is to produce an assembly program from the ENTIRE C code that
will work the same as the C style version.
So if replacing things is what is needed, then that would be fine.
Andy
|
|
0
|
|
|
|
Reply
|
Andy
|
2/3/2011 1:05:46 AM
|
|
On Feb 2, 4:53=A0pm, Andy <chocolatemint77...@nospicedham.yahoo.com>
wrote:
> Thanks Richard.
> It was necessary to use this format in the data section.
> pBadCommand =A0 =A0WORD "T","h","e",0
This will work, but isn't correct for every character. The ASCII
characters do not convert over exactly to 16-bit forms. That's why
toolsets like NASM allow for the conversion macro for you, same as in
higher level languages where they require something to surround the
text.
> The C code is complex. (at least to me.)
> I am learning a lot that has helped in another conversion project.
> If you have time, I could use more help with the C -> asm conversion.
I recommend starting with the assembly source listing output from your
favorite C compiler, and then comparing what you did in C source to
what it does for you in assembler source. In that way, you can learn
the natural conventions and conversions which are present in the
compiler from human readable form to the required form by the
computer, or the conventions of the operating system.
Hope this helps. Also, ask questions ... you'll get answers.
- Rick C. Hodgin
|
|
0
|
|
|
|
Reply
|
Rick
|
2/3/2011 1:22:37 AM
|
|
On Feb 2, 7:22=A0pm, Rick Hodgin <foxmuldrs...@nospicedham.gmail.com>
wrote:
> On Feb 2, 4:53=A0pm, Andy <chocolatemint77...@nospicedham.yahoo.com>
> wrote:
>
> > Thanks Richard.
> > It was necessary to use this format in the data section.
> > pBadCommand =A0 =A0WORD "T","h","e",0
>
> This will work, but isn't correct for every character. =A0The ASCII
> characters do not convert over exactly to 16-bit forms. =A0That's why
> toolsets like NASM allow for the conversion macro for you, same as in
> higher level languages where they require something to surround the
> text.
>
> > The C code is complex. (at least to me.)
> > I am learning a lot that has helped in another conversion project.
> > If you have time, I could use more help with the C -> asm conversion.
>
> I recommend starting with the assembly source listing output from your
> favorite C compiler, and then comparing what you did in C source to
> what it does for you in assembler source. =A0In that way, you can learn
> the natural conventions and conversions which are present in the
> compiler from human readable form to the required form by the
> computer, or the conventions of the operating system.
>
> Hope this helps. =A0Also, ask questions ... you'll get answers.
>
> - Rick C. Hodgin
Thanks.
I will get a C compiler and get the assembly source listing.
Andy
|
|
0
|
|
|
|
Reply
|
Andy
|
2/3/2011 12:23:08 PM
|
|
On Wed, 2 Feb 2011 07:51:04 -0800 (PST), Richard Russell
<news@nospicedham.rtrussell.co.uk> wrote:
>On Feb 2, 1:21=A0pm, N0S...@daqarta.com (Bob Masta) wrote:
>> You need to explain what your problem is, not show more
>> code. =A0
>
>Let me see if I can help. The OP stated that he can convert
>everything into assembly but the
>strings for the event messages. Therefore I assume his difficulty is
>in generating an assembler equivalent to:
>
>CONST LPWSTR pBadCommand =3D L"The command that was not valid";
>CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
>CONST LPWSTR pNumberOfRetries =3D L"3";
>and so on.
>
>In recent versions of NASM (I'm not sure when support for Unicode was
>added) the equivalent would be:
>
>%define L(x) __utf16__(x)
>pBadCommand: dw L('The command that was not valid'), 0
>pFilename: dw L('c:\folder\file.ext'), 0
>pNumberOfRetries: dw L('3'), 0
>
>> In my prior post I had to guess that you were having trouble
>> inserting the size in front of the string.
>
>I'm mystified by that comment, since the strings are NUL-terminated,
>not preceded by a length value. The OP's code is in C not Pascal!
>
My apologies. I don't use C or Pascal (just assembler) and
when I saw that there were no visible nulls after the
strings, and that they had 'L ' in front, I jumped to the
wrong conclusion.
Note to OP: If you are converting the whole code to
assembler, do you still need Unicode? There are no
Unicode-specific characters in the strings.
Best regards,
Bob Masta
DAQARTA v6.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
Science with your sound card!
|
|
0
|
|
|
|
Reply
|
N0Spam
|
2/3/2011 1:20:21 PM
|
|
On Feb 3, 7:20=A0am, N0S...@nospicedham.daqarta.com (Bob Masta) wrote:
> On Wed, 2 Feb 2011 07:51:04 -0800 (PST), Richard Russell
Did some chopping to save bandwidth. :-)
> Note to OP: =A0If you are converting the whole code to
> assembler, do you still need Unicode? =A0There are no
> Unicode-specific characters in the strings.
>
> Best regards,
>
> Bob Masta
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 DAQARTA =A0v6.00
> =A0 =A0Data AcQuisition And Real-Time Analysis
> =A0 =A0 =A0 =A0 =A0 =A0 =A0www.daqarta.com
> Scope, Spectrum, Spectrogram, Sound Level Meter
> =A0 =A0 Frequency Counter, FREE Signal Generator
> =A0 =A0 =A0 =A0 =A0 =A0Pitch Track, Pitch-to-MIDI
> =A0 =A0 =A0 =A0 =A0 Science with your sound card!
This is the C source code.
> Note to OP: If you are converting the whole code to
> assembler, do you still need Unicode? There are no
> Unicode-specific characters in the strings.
I honestly don't know if I still need to use any Unicode forms of the
A.P.I.s.
Andy
// Example shows how to use the ReportEvent function to write the
events defined
// in the above message text file.
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <stdio.h>
#include "provider.h"
#pragma comment(lib, "advapi32.lib")
#define PROVIDER_NAME L"MyEventProvider"
// Hardcoded insert string for the event messages.
CONST LPWSTR pBadCommand =3D L"The command that was not valid";
CONST LPWSTR pFilename =3D L"c:\\folder\\file.ext";
CONST LPWSTR pNumberOfRetries =3D L"3";
CONST LPWSTR pSuccessfulRetries =3D L"0";
CONST LPWSTR pQuarts =3D L"8";
CONST LPWSTR pGallons =3D L"2";
void wmain(void)
{
HANDLE hEventLog =3D NULL;
LPWSTR pInsertStrings[2] =3D {NULL, NULL};
DWORD dwEventDataSize =3D 0;
// The source name (provider) must exist as a subkey of
Application.
hEventLog =3D RegisterEventSource(NULL, PROVIDER_NAME);
if (NULL =3D=3D hEventLog)
{
wprintf(L"RegisterEventSource failed with 0x%x.\n",
GetLastError());
goto cleanup;
}
// This event includes user-defined data as part of the event. The
event message
// does not use insert strings.
dwEventDataSize =3D (wcslen(pBadCommand) + 1) * sizeof(WCHAR);
if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, UI_CATEGORY,
MSG_INVALID_COMMAND, NULL, 0, dwEventDataSize, NULL, pBadCommand))
{
wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n",
GetLastError(), MSG_INVALID_COMMAND);
goto cleanup;
}
// This event uses insert strings.
pInsertStrings[0] =3D pFilename;
if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE,
DATABASE_CATEGORY, MSG_BAD_FILE_CONTENTS, NULL, 1, 0,
(LPCWSTR*)pInsertStrings, NULL))
{
wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n",
GetLastError(), MSG_BAD_FILE_CONTENTS);
goto cleanup;
}
// This event uses insert strings.
pInsertStrings[0] =3D pNumberOfRetries;
pInsertStrings[1] =3D pSuccessfulRetries;
if (!ReportEvent(hEventLog, EVENTLOG_WARNING_TYPE,
NETWORK_CATEGORY, MSG_RETRIES, NULL, 2, 0, (LPCWSTR*)pInsertStrings,
NULL))
{
wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n",
GetLastError(), MSG_RETRIES);
goto cleanup;
}
// This event uses insert strings.
pInsertStrings[0] =3D pQuarts;
pInsertStrings[1] =3D pGallons;
if (!ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE,
UI_CATEGORY, MSG_COMPUTE_CONVERSION, NULL, 2, 0,
(LPCWSTR*)pInsertStrings, NULL))
{
wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n",
GetLastError(), MSG_COMPUTE_CONVERSION);
goto cleanup;
}
wprintf(L"All events successfully reported.\n");
cleanup:
if (hEventLog)
DeregisterEventSource(hEventLog);
}
|
|
0
|
|
|
|
Reply
|
Andy
|
2/3/2011 9:57:40 PM
|
|
Rick Hodgin <foxmuldrster@nospicedham.gmail.com> wrote:
>On Feb 2, 4:53=A0pm, Andy <chocolatemint77...@nospicedham.yahoo.com>
>wrote:
>> Thanks Richard.
>> It was necessary to use this format in the data section.
>> pBadCommand =A0 =A0WORD "T","h","e",0
>
>This will work, but isn't correct for every character. The ASCII
>characters do not convert over exactly to 16-bit forms.
I guess that depends on your definition. ASCII, by definition, consists
only of the first 128 characters. Those characters DO all convert to
Unicode through simple sign-extension.
--=20
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
|
|
0
|
|
|
|
Reply
|
Tim
|
2/4/2011 6:02:36 AM
|
|
"Andy" <chocolatemint77581@nospicedham.yahoo.com> ha scritto nel messaggio
news:55650680-83bc-44c8-a142-5e91c506fed0@d16g2000yqd.googlegroups.com...
>I can convert everything into assembly but the
> "Hardcoded insert string for the event messages."
>
> Could someone help me?
>
> Thanks.
>
> // Example shows how to use the ReportEvent function to write the
> events defined
> // in the above message text file.
> #define UNICODE
> #include <windows.h>
> #include <stdio.h>
> #include "provider.h"
>
> #pragma comment(lib, "advapi32.lib")
>
> #define PROVIDER_NAME L"MyEventProvider"
>
> // Hardcoded insert string for the event messages.
> CONST LPWSTR pBadCommand = L"The command that was not valid";
this above string, in memory could be as
'T',0,'h',0,'e','0, ..., 'd',0, 0, 0
unicode is 16 bit, the first 8[7] bit seems for ascii
PREPARSE MACRO2D
section DATA
%define wsprintfA 'user32.wsprintfA'
%define MessageBoxW 'user32.MessageBoxW'
testo1 db 't',0,'i',0,'t',0,'o',0,'l',0,'o', 0, 0, 0, 0
array times 1000 dd 0
section TEXT
main:
s-=64
int3
MessageBoxW(0, testo1, testo1, 0)
..z:
s+=64
ret
--------------------
this print "titolo" "titolo"
> CONST LPWSTR pFilename = L"c:\\folder\\file.ext";
> CONST LPWSTR pNumberOfRetries = L"3";
> CONST LPWSTR pSuccessfulRetries = L"0";
> CONST LPWSTR pQuarts = L"8";
> CONST LPWSTR pGallons = L"2";
|
|
0
|
|
|
|
Reply
|
io_x
|
2/6/2011 4:57:17 PM
|
|
|
12 Replies
285 Views
(page loaded in 0.218 seconds)
Similiar Articles: Hardcoded insert string for the event messages - comp.lang.asm.x86 ...I can convert everything into assembly but the "Hardcoded insert string for the event messages." Could someone help me? Thanks. // Example s... how insert tag? - comp.text.pdfHardcoded insert string for the event messages - comp.lang.asm.x86 ... how insert tag? - comp.text.pdf Hardcoded insert string for the event messages - comp.lang.asm ... Insert a string into the text of textarea. Caret? IE question ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ... Insert a string into the text of textarea. Caret? IE question ... Hardcoded insert string for the ... Insert variable into string - comp.soft-sys.matlabHardcoded insert string for the event messages - comp.lang.asm.x86 ... Since you are forcing me to guess at this, my guess is that you may be having trouble inserting ... Solid Works and .dll component - comp.cad.solidworks... comp.lang.ruby Solid Works and .dll component - comp.cad.solidworks Solid Works and .dll component - comp.cad.solidworks Hardcoded insert string for the event messages ... Problem inserting cell array using fastinsert() into mysql ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ..... wrote: > > > You need to explain what your problem ... i',0,'t',0,'o',0,'l',0,'o', 0, 0, 0, 0 ... null characters inserted when characters in buffer deleted - comp ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ..... everything into assembly but the "Hardcoded insert ... This will work, but isn't correct for ... Invalid Card Data message - comp.sys.hp48Hardcoded insert string for the event messages - comp.lang.asm.x86 ... Invalid Card Data message - comp.sys.hp48 Hardcoded insert string for the event messages - comp.lang ... Saving linebreaks in a TEXT field - comp.databases.mysql ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ..... Russell Did some chopping to save ... Can't get line breaks into email message body ... Libname Function and Connection Strings - comp.soft-sys.sas ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ... Libname Function and Connection Strings - comp.soft-sys.sas ... Hardcoded insert string for the ... TextArea with \n - comp.lang.java.guiHardcoded insert string for the event messages - comp.lang.asm.x86 ... Insert a string into the text of textarea. Caret? IE question ... Hardcoded insert string ... putting a space in string created with strcat - comp.soft-sys ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ..... how to put a size field in front of the >> string ... how to put C "const" variables into F2407 ... display integer in MessageBox - comp.lang.c++.moderatedHardcoded insert string for the event messages - comp.lang.asm.x86 ... Extract Program change number formula - comp.music.midi use a callback function ... Insert a GIF-image in the front panel - comp.lang.labview ...Hardcoded insert string for the event messages - comp.lang.asm.x86 ..... after the strings, and that they had 'L ' in front ... How to insert a picture in to a GUI ... Size of String Tables - comp.lang.cHi, I have a mysql database table of the ... want to insert the following data into the table id size 1x4 ... Hardcoded insert string for the event messages - comp ... Hardcoded insert string for the event messages - comp.lang.asm.x86 ...I can convert everything into assembly but the "Hardcoded insert string for the event messages." Could someone help me? Thanks. // Example s... Reporting Events - Microsoft Corporation: Software, Smartphones ...To report events, you must first define the events in a message ... PROVIDER_NAME L"MyEventProvider" // Hardcoded insert string for the event messages. 7/22/2012 3:12:12 PM
|