Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Paths.c « winapi « peloader - github.com/taviso/loadlibrary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a51aa8337c4edc4079836c18f63926015be40db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>
#include <search.h>
#include <assert.h>
#include <stdlib.h>

#include "winnt_types.h"
#include "pe_linker.h"
#include "ntoskernel.h"
#include "log.h"
#include "winexports.h"
#include "util.h"
#include "winstrings.h"

static const uint16_t kTempPath[] = L".\\FAKETEMP\\";

DWORD WINAPI GetTempPathW(DWORD nBufferLength, PVOID lpBuffer)
{
    DebugLog("%u, %p", nBufferLength, lpBuffer);

    memcpy(lpBuffer, kTempPath, sizeof(kTempPath));

    return sizeof(kTempPath) - 2;
}

DWORD WINAPI GetLogicalDrives(void)
{
    DebugLog("");

    return 1 << 2;
}

#define DRIVE_FIXED 3

UINT WINAPI GetDriveTypeW(PWCHAR lpRootPathName)
{
    char *path = CreateAnsiFromWide(lpRootPathName);
    DebugLog("%p [%s]", lpRootPathName, path);
    free(path);
    return DRIVE_FIXED;
}

DWORD WINAPI GetLongPathNameA(LPCSTR lpszShortPath,
                              LPSTR lpszLongPath,
                              DWORD cchBuffer)
{
    // For now we just return the 8.3 format path as the long path
    if (cchBuffer > strlen(lpszShortPath)) {
        memcpy(lpszLongPath, lpszShortPath, sizeof(lpszShortPath));
    }

    return strlen(lpszShortPath);
}

DWORD WINAPI GetLongPathNameW(LPCWSTR lpszShortPath,
                              LPWSTR lpszLongPath,
                              DWORD cchBuffer)
{
    // For now we just return the 8.3 format path as the long path
    if (cchBuffer > strlen(lpszShortPath)) {
        memcpy(lpszLongPath, lpszShortPath, sizeof(lpszShortPath));
    }

    return strlen(lpszShortPath);
}

DECLARE_CRT_EXPORT("GetTempPathW", GetTempPathW);
DECLARE_CRT_EXPORT("GetLogicalDrives", GetLogicalDrives);
DECLARE_CRT_EXPORT("GetDriveTypeW", GetDriveTypeW);
DECLARE_CRT_EXPORT("GetLongPathNameA", GetLongPathNameA);
DECLARE_CRT_EXPORT("GetLongPathNameW", GetLongPathNameW);