Assembly Language for Beginners

(nextflipdebug2) #1

3.21. MORE ABOUT POINTERS


ULONG IdPath[ 3 ];
PVOID p;

IdPath[ 0 ] = 0;
IdPath[ 1 ] = 0;
try {
if ((IdPath[ 0 ] = BaseDllMapResourceIdA( lpType )) == -1) {
Status = STATUS_INVALID_PARAMETER;
}
else
if ((IdPath[ 1 ] = BaseDllMapResourceIdA( lpName )) == -1) {
Status = STATUS_INVALID_PARAMETER;
...


Let’s proceed toBaseDllMapResourceIdA()in the same source file:


ULONG
BaseDllMapResourceIdA(
LPCSTR lpId
)
{
NTSTATUS Status;
ULONG Id;
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
PWSTR s;


try {
if ((ULONG)lpId & LDR_RESOURCE_ID_NAME_MASK) {
if (*lpId == '#') {
Status = RtlCharToInteger( lpId+1, 10, &Id );
if (!NT_SUCCESS( Status ) || Id & LDR_RESOURCE_ID_NAME_MASK) {
if (NT_SUCCESS( Status )) {
Status = STATUS_INVALID_PARAMETER;
}
BaseSetLastNTError( Status );
Id = (ULONG)-1;
}
}
else {
RtlInitAnsiString( &AnsiString, lpId );
Status = RtlAnsiStringToUnicodeString( &UnicodeString,
&AnsiString,
TRUE
);
if (!NT_SUCCESS( Status )){
BaseSetLastNTError( Status );
Id = (ULONG)-1;
}
else {
s = UnicodeString.Buffer;
while (*s != UNICODE_NULL) {
*s = RtlUpcaseUnicodeChar( *s );
s++;
}

Id = (ULONG)UnicodeString.Buffer;
}
}
}
else {
Id = (ULONG)lpId;
}
}
except (EXCEPTION_EXECUTE_HANDLER) {
BaseSetLastNTError( GetExceptionCode() );
Id = (ULONG)-1;
}
return Id;
}

Free download pdf