12 replies to this topic
#1
Posted 23 January 2011 - 06:35 PM
I found some code for receiving notification when an event is logged in the Log Files that are shown in Event Viewer.
I would like to receive a notification whenever a particular error occurs in the Application Log.
Receiving Event Notification (Windows)
I would need help converting some C code if someone has some time.
I would like to receive a notification whenever a particular error occurs in the Application Log.
Receiving Event Notification (Windows)
I would need help converting some C code if someone has some time.
|
|
|
#2
Posted 23 January 2011 - 09:18 PM
#3
Posted 25 January 2011 - 05:30 PM
dargueta said:
You want to convert this to asm? Why?
Is this a serious question?
Andy
#4
Posted 25 January 2011 - 05:47 PM
#5
Posted 26 January 2011 - 09:34 AM
I don't need help with every line of code.
I could use help with the Unicode line and the Provider_Name equate.
Andy
I could use help with the Unicode line and the Provider_Name equate.
Andy
;#define UNICODE ; #include <windows.h> ; #include <stdio.h> ; ; #pragma comment(lib, "advapi32.lib") ; ; #define PROVIDER_NAME L"MyEventProvider" Provider_Name L equ "MyEventProvider" C:\masm32\SOURCE\C_Code.asm(23) : error A2008: syntax error : L ; #define KEYBOARD_EVENT 0 KEYBOARD_EVENT equ 0
Edited by dargueta, 26 January 2011 - 11:12 AM.
Added code tags
#6
Posted 26 January 2011 - 11:16 AM
You're going to need a data section and put this in:
By the way, in C/C++ code the 'L' must be directly adjacent to the quote it modifies. Usually it follows the string, but the programmer in this case decided not to do so.
Provider_Name dw "MyEventProvider", 0
By the way, in C/C++ code the 'L' must be directly adjacent to the quote it modifies. Usually it follows the string, but the programmer in this case decided not to do so.
Edited by dargueta, 26 January 2011 - 11:17 AM.
Typo
sudo rm -rf /
#7
Posted 26 January 2011 - 08:55 PM
I don't know what to do with the define UNICODE and pragma comment lines.
INCLUDE \masm32\include\masm32rt.inc
;#define UNICODE
;#include <windows.h>
;#include <stdio.h>
;#pragma comment(lib, "advapi32.lib")
.const
;#define KEYBOARD_EVENT 0
KEYBOARD_EVENT equ 0
;#define NOTIFICATION_EVENT 1
NOTIFICATION_EVENT equ 1
.data
;#define PROVIDER_NAME L"MyEventProvider"
Provider_Name db "MyEventProvider",0
; #define RESOURCE_DLL L"<path>\\Provider.dll"
; By the way, in C/C++ code the 'L' must be directly adjacent to the quote
; it modifies. Usually it follows the string, but the programmer in this
; case decided not to do so.
RESOURCE_DLL db "c:\masm32\source\Provider.dll",0
Compiles to here with no error messages.
HANDLE GetMessageResources();
DWORD SeekToLastRecord(HANDLE hEventLog);
DWORD GetLastRecordNumber(HANDLE hEventLog, DWORD* pdwMarker);
DWORD ReadRecord(HANDLE hEventLog, PBYTE & pBuffer, DWORD dwRecordNumber, DWORD dwFlags);
DWORD DumpNewRecords(HANDLE hEventLog);
DWORD GetEventTypeName(DWORD EventType);
LPWSTR GetMessageString(DWORD Id, DWORD argc, LPWSTR args);
DWORD ApplyParameterStringsToMessage(CONST LPCWSTR pMessage, LPWSTR & pFinalMessage);
BOOL IsKeyEvent(HANDLE hStdIn);
CONST LPWSTR pEventTypeNames[] = {L"Error", L"Warning", L"Informational", L"Audit Success", L"Audit Failure"};
HANDLE g_hResources = NULL;
.code
void wmain(void)
Edited by dargueta, 27 January 2011 - 12:23 AM.
#8
Posted 27 January 2011 - 12:30 AM
For the #define UNICODE part, when passing parameters to ml.exe on the command line, add /D UNICODE.
For the pragma, pass /Fo advapi32.lib on the command line. It should be one of the first ones since it's order-sensitive.
By the way, your "MyEventProvider" string should be declared with the dw directive, not db.
For the pragma, pass /Fo advapi32.lib on the command line. It should be one of the first ones since it's order-sensitive.
By the way, your "MyEventProvider" string should be declared with the dw directive, not db.
sudo rm -rf /
#9
Posted 27 January 2011 - 03:50 AM
I fixed it and am up to here on the conversion.
RESOURCE_DLL db "c:\masm32\source\Provider.dll",0
I think some of these are Prototypes?
HANDLE GetMessageResources();
DWORD SeekToLastRecord(HANDLE hEventLog);
DWORD GetLastRecordNumber(HANDLE hEventLog, DWORD* pdwMarker);
DWORD ReadRecord(HANDLE hEventLog, PBYTE & pBuffer, DWORD dwRecordNumber, DWORD dwFlags);
DWORD DumpNewRecords(HANDLE hEventLog);
DWORD GetEventTypeName(DWORD EventType);
LPWSTR GetMessageString(DWORD Id, DWORD argc, LPWSTR args);
DWORD ApplyParameterStringsToMessage(CONST LPCWSTR pMessage, LPWSTR & pFinalMessage);
BOOL IsKeyEvent(HANDLE hStdIn);
CONST LPWSTR pEventTypeNames[] = {L"Error", L"Warning", L"Informational", L"Audit Success", L"Audit Failure"};
HANDLE g_hResources = NULL;
.code
void wmain(void)
Edited by dargueta, 27 January 2011 - 11:07 AM.
Please use code tags next time.
#10
Posted 27 January 2011 - 11:34 AM
Yes, those are all prototypes. I don't know MASM as well as I do NASM, but I'm almost positive you can't put the actual function prototypes in there, and I'm definitely sure the CONST LPWSTR pEventTypeNames[] declaration will not work as is.
Not to be rude, but it doesn't seem like you really know what you're doing here. Why are you trying to convert this to assembly language by hand? If it's for exercise, I have some example code that you'll find easier and more useful.
Not to be rude, but it doesn't seem like you really know what you're doing here. Why are you trying to convert this to assembly language by hand? If it's for exercise, I have some example code that you'll find easier and more useful.
sudo rm -rf /
#11
Posted 27 January 2011 - 07:52 PM
I won't make any more posts concerning that project.
Andy
Andy
#12
Posted 27 January 2011 - 08:43 PM
It's not that I want you to stop, I'm just wondering why you want to do this. Maybe I can show you a less frustrating way?
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









